Rebase against 07544942e2c9c2f35263adb5104998f18967dc6c.

This commit is contained in:
Alistair Leslie-Hughes
2024-06-27 08:37:31 +10:00
parent 7fc08a960b
commit 1b9ef03b2c
5 changed files with 65 additions and 61 deletions

View File

@@ -1,4 +1,4 @@
From 898c8d269bdcda704a2a923349d2a1967a1f23eb Mon Sep 17 00:00:00 2001
From f53204bf14a0ac962d389467e9e915724639ad03 Mon Sep 17 00:00:00 2001
From: Sebastian Lackner <sebastian@fds-team.de>
Date: Sun, 15 Mar 2015 01:05:48 +0100
Subject: [PATCH] server: Fix handling of GetMessage after previous PeekMessage
@@ -15,10 +15,10 @@ Changes in v3:
2 files changed, 65 insertions(+), 17 deletions(-)
diff --git a/dlls/user32/tests/msg.c b/dlls/user32/tests/msg.c
index 1169d82271c..bee49c302cb 100644
index 398bb0a69ed..2aec627604c 100644
--- a/dlls/user32/tests/msg.c
+++ b/dlls/user32/tests/msg.c
@@ -14329,13 +14329,10 @@ static void test_PeekMessage3(void)
@@ -14353,13 +14353,10 @@ static void test_PeekMessage3(void)
ok(msg.message == WM_TIMER, "msg.message = %u instead of WM_TIMER\n", msg.message);
PostMessageA(hwnd, WM_USER, 0, 0);
ret = PeekMessageA(&msg, hwnd, 0, 0, PM_NOREMOVE);
@@ -32,7 +32,7 @@ index 1169d82271c..bee49c302cb 100644
ok(ret && msg.message == WM_USER, "msg.message = %u instead of WM_USER\n", msg.message);
ret = PeekMessageA(&msg, hwnd, 0, 0, 0);
ok(!ret, "expected PeekMessage to return FALSE, got %u\n", ret);
@@ -14345,10 +14342,8 @@ static void test_PeekMessage3(void)
@@ -14369,10 +14366,8 @@ static void test_PeekMessage3(void)
ok(msg.message == WM_TIMER, "msg.message = %u instead of WM_TIMER\n", msg.message);
PostMessageA(hwnd, WM_USER, 0, 0);
ret = PeekMessageA(&msg, hwnd, 0, 0, PM_REMOVE);
@@ -43,7 +43,7 @@ index 1169d82271c..bee49c302cb 100644
ok(ret && msg.message == WM_USER, "msg.message = %u instead of WM_USER\n", msg.message);
ret = PeekMessageA(&msg, hwnd, 0, 0, 0);
ok(!ret, "expected PeekMessage to return FALSE, got %u\n", ret);
@@ -14360,10 +14355,11 @@ static void test_PeekMessage3(void)
@@ -14384,10 +14379,11 @@ static void test_PeekMessage3(void)
ok(msg.message == WM_TIMER, "msg.message = %u instead of WM_TIMER\n", msg.message);
PostMessageA(hwnd, WM_USER, 0, 0);
ret = GetMessageA(&msg, hwnd, 0, 0);
@@ -57,7 +57,7 @@ index 1169d82271c..bee49c302cb 100644
ok(ret && msg.message == WM_USER, "msg.message = %u instead of WM_USER\n", msg.message);
ret = PeekMessageA(&msg, hwnd, 0, 0, 0);
ok(!ret, "expected PeekMessage to return FALSE, got %u\n", ret);
@@ -14391,14 +14387,32 @@ static void test_PeekMessage3(void)
@@ -14415,14 +14411,32 @@ static void test_PeekMessage3(void)
ret = GetMessageA(&msg, hwnd, 0, 0);
ok(ret && msg.message == WM_USER, "msg.message = %u instead of WM_USER\n", msg.message);
ret = GetMessageA(&msg, hwnd, 0, 0);
@@ -93,18 +93,18 @@ index 1169d82271c..bee49c302cb 100644
* because both messages are in the same queue. */
diff --git a/server/queue.c b/server/queue.c
index ed099b3b989..35926b701af 100644
index 53306f46793..3cf1a20926d 100644
--- a/server/queue.c
+++ b/server/queue.c
@@ -145,6 +145,7 @@ struct msg_queue
struct hook_table *hooks; /* hook table */
@@ -147,6 +147,7 @@ struct msg_queue
timeout_t last_get_msg; /* time of last get message call */
int keystate_lock; /* owns an input keystate lock */
const queue_shm_t *shared; /* queue in session shared memory */
+ unsigned int ignore_post_msg; /* ignore post messages newer than this unique id */
};
struct hotkey
@@ -313,6 +314,7 @@ static struct msg_queue *create_msg_queue( struct thread *thread, struct thread_
@@ -317,6 +318,7 @@ static struct msg_queue *create_msg_queue( struct thread *thread, struct thread_
queue->hooks = NULL;
queue->last_get_msg = current_time;
queue->keystate_lock = 0;
@@ -112,7 +112,7 @@ index ed099b3b989..35926b701af 100644
list_init( &queue->send_result );
list_init( &queue->callback_result );
list_init( &queue->pending_timers );
@@ -656,13 +658,21 @@ static inline struct msg_queue *get_current_queue(void)
@@ -712,13 +714,21 @@ static inline struct msg_queue *get_current_queue(void)
}
/* get a (pseudo-)unique id to tag hardware messages */
@@ -135,7 +135,7 @@ index ed099b3b989..35926b701af 100644
/* try to merge a WM_MOUSEMOVE message with the last in the list; return 1 if successful */
static int merge_mousemove( struct thread_input *input, const struct message *msg )
{
@@ -973,7 +983,7 @@ static int match_window( user_handle_t win, user_handle_t msg_win )
@@ -1029,7 +1039,7 @@ static int match_window( user_handle_t win, user_handle_t msg_win )
}
/* retrieve a posted message */
@@ -144,7 +144,7 @@ index ed099b3b989..35926b701af 100644
unsigned int first, unsigned int last, unsigned int flags,
struct get_message_reply *reply )
{
@@ -984,6 +994,7 @@ static int get_posted_message( struct msg_queue *queue, user_handle_t win,
@@ -1040,6 +1050,7 @@ static int get_posted_message( struct msg_queue *queue, user_handle_t win,
{
if (!match_window( win, msg->win )) continue;
if (!check_msg_filter( msg->msg, first, last )) continue;
@@ -152,7 +152,7 @@ index ed099b3b989..35926b701af 100644
goto found; /* found one */
}
return 0;
@@ -1598,6 +1609,7 @@ found:
@@ -1654,6 +1665,7 @@ found:
msg->msg = WM_HOTKEY;
msg->wparam = hotkey->id;
msg->lparam = ((hotkey->vkey & 0xffff) << 16) | modifiers;
@@ -160,7 +160,7 @@ index ed099b3b989..35926b701af 100644
free( msg->data );
msg->data = NULL;
@@ -2503,7 +2515,7 @@ static int get_hardware_message( struct thread *thread, unsigned int hw_id, user
@@ -2624,7 +2636,7 @@ static int get_hardware_message( struct thread *thread, unsigned int hw_id, user
}
/* now we can return it */
@@ -169,7 +169,7 @@ index ed099b3b989..35926b701af 100644
reply->type = MSG_HARDWARE;
reply->win = win;
reply->msg = msg_code;
@@ -2610,6 +2622,7 @@ void post_message( user_handle_t win, unsigned int message, lparam_t wparam, lpa
@@ -2731,6 +2743,7 @@ void post_message( user_handle_t win, unsigned int message, lparam_t wparam, lpa
msg->result = NULL;
msg->data = NULL;
msg->data_size = 0;
@@ -177,7 +177,7 @@ index ed099b3b989..35926b701af 100644
get_message_defaults( thread->queue, &msg->x, &msg->y, &msg->time );
@@ -2896,6 +2909,7 @@ DECL_HANDLER(send_message)
@@ -3025,6 +3038,7 @@ DECL_HANDLER(send_message)
set_queue_bits( recv_queue, QS_SENDMESSAGE );
break;
case MSG_POSTED:
@@ -185,7 +185,7 @@ index ed099b3b989..35926b701af 100644
list_add_tail( &recv_queue->msg_list[POST_MESSAGE], &msg->entry );
set_queue_bits( recv_queue, QS_POSTMESSAGE|QS_ALLPOSTMESSAGE );
if (msg->msg == WM_HOTKEY)
@@ -3022,12 +3036,12 @@ DECL_HANDLER(get_message)
@@ -3151,12 +3165,12 @@ DECL_HANDLER(get_message)
/* then check for posted messages */
if ((filter & QS_POSTMESSAGE) &&
@@ -200,7 +200,7 @@ index ed099b3b989..35926b701af 100644
return;
/* only check for quit messages if not posted messages pending */
@@ -3038,7 +3052,7 @@ DECL_HANDLER(get_message)
@@ -3167,7 +3181,7 @@ DECL_HANDLER(get_message)
if ((filter & QS_INPUT) &&
filter_contains_hw_range( req->get_first, req->get_last ) &&
get_hardware_message( current, req->hw_id, get_win, req->get_first, req->get_last, req->flags, reply ))
@@ -209,7 +209,7 @@ index ed099b3b989..35926b701af 100644
/* now check for WM_PAINT */
if ((filter & QS_PAINT) &&
@@ -3051,7 +3065,7 @@ DECL_HANDLER(get_message)
@@ -3180,7 +3194,7 @@ DECL_HANDLER(get_message)
reply->wparam = 0;
reply->lparam = 0;
get_message_defaults( queue, &reply->x, &reply->y, &reply->time );
@@ -218,7 +218,7 @@ index ed099b3b989..35926b701af 100644
}
/* now check for timer */
@@ -3067,13 +3081,30 @@ DECL_HANDLER(get_message)
@@ -3196,13 +3210,30 @@ DECL_HANDLER(get_message)
get_message_defaults( queue, &reply->x, &reply->y, &reply->time );
if (!(req->flags & PM_NOYIELD) && current->process->idle_event)
set_event( current->process->idle_event );
@@ -250,7 +250,7 @@ index ed099b3b989..35926b701af 100644
}
@@ -3091,7 +3122,10 @@ DECL_HANDLER(reply_message)
@@ -3220,7 +3251,10 @@ DECL_HANDLER(reply_message)
DECL_HANDLER(accept_hardware_message)
{
if (current->queue)