From cf2f14212a52204581fcb26ca819558e56d57816 Mon Sep 17 00:00:00 2001 From: Alexandre Julliard Date: Mon, 14 Mar 2005 17:17:09 +0000 Subject: [PATCH] Avoid returning hardware messages if they have no chance to match the filter. --- server/queue.c | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/server/queue.c b/server/queue.c index cd78cba7b01..05f4c7c9383 100644 --- a/server/queue.c +++ b/server/queue.c @@ -38,6 +38,9 @@ #include "request.h" #include "user.h" +#define WM_NCMOUSEFIRST WM_NCMOUSEMOVE +#define WM_NCMOUSELAST WM_NCMBUTTONDBLCLK + enum message_kind { SEND_MESSAGE, POST_MESSAGE }; #define NB_MSG_KINDS (POST_MESSAGE+1) @@ -324,6 +327,21 @@ inline static int is_keyboard_msg( struct message *msg ) return (msg->msg >= WM_KEYFIRST && msg->msg <= WM_KEYLAST); } +/* check whether a message filter contains at least one potential hardware message */ +inline static int filter_contains_hw_range( unsigned int first, unsigned int last ) +{ + /* hardware message ranges are (in numerical order): + * WM_NCMOUSEFIRST .. WM_NCMOUSELAST + * WM_KEYFIRST .. WM_KEYLAST + * WM_MOUSEFIRST .. WM_MOUSELAST + */ + if (last < WM_NCMOUSEFIRST) return 0; + if (first > WM_NCMOUSELAST && last < WM_KEYFIRST) return 0; + if (first > WM_KEYLAST && last < WM_MOUSEFIRST) return 0; + if (first > WM_MOUSELAST) return 0; + return 1; +} + /* get the QS_* bit corresponding to a given hardware message */ inline static int get_hardware_msg_bit( struct message *msg ) { @@ -1515,7 +1533,8 @@ DECL_HANDLER(get_message) return; /* then check for any raw hardware message */ - if (get_hardware_message( current, req->get_next_hw, first_hw_msg, get_win, reply )) + if (filter_contains_hw_range( req->get_first, req->get_last ) && + get_hardware_message( current, req->get_next_hw, first_hw_msg, get_win, reply )) return; /* now check for WM_PAINT */