Commit 242e395b authored by Alexandre Julliard's avatar Alexandre Julliard

Store the hardware messages in the thread input structure, not in the

thread queue. Get rid of the cooked messages queue.
parent ae4311c7
...@@ -1388,6 +1388,35 @@ static LRESULT call_window_proc( HWND hwnd, UINT msg, WPARAM wparam, LPARAM lpar ...@@ -1388,6 +1388,35 @@ static LRESULT call_window_proc( HWND hwnd, UINT msg, WPARAM wparam, LPARAM lpar
/*********************************************************************** /***********************************************************************
* process_hardware_message
*
* Process a hardware message; return TRUE if message should be passed on to the app
*/
static BOOL process_hardware_message( MSG *msg, ULONG_PTR extra_info, HWND hwnd,
UINT first, UINT last, BOOL remove )
{
BOOL ret;
if (!MSG_process_raw_hardware_message( msg, extra_info, hwnd, first, last, remove ))
return FALSE;
ret = MSG_process_cooked_hardware_message( msg, extra_info, remove );
/* tell the server we have passed it to the app
* (even though we may end up dropping it later on)
*/
SERVER_START_REQ( reply_message )
{
req->result = 0;
req->remove = remove || !ret;
wine_server_call( req );
}
SERVER_END_REQ;
return ret;
}
/***********************************************************************
* MSG_peek_message * MSG_peek_message
* *
* Peek for a message matching the given parameters. Return FALSE if none available. * Peek for a message matching the given parameters. Return FALSE if none available.
...@@ -1471,17 +1500,12 @@ BOOL MSG_peek_message( MSG *msg, HWND hwnd, UINT first, UINT last, int flags ) ...@@ -1471,17 +1500,12 @@ BOOL MSG_peek_message( MSG *msg, HWND hwnd, UINT first, UINT last, int flags )
goto next; goto next;
} }
break; break;
case MSG_HARDWARE_RAW: case MSG_HARDWARE:
if (!MSG_process_raw_hardware_message( &info.msg, extra_info, if (!process_hardware_message( &info.msg, extra_info,
hwnd, first, last, flags & GET_MSG_REMOVE )) hwnd, first, last, flags & GET_MSG_REMOVE ))
goto next;
/* fall through */
case MSG_HARDWARE_COOKED:
if (!MSG_process_cooked_hardware_message( &info.msg, extra_info,
flags & GET_MSG_REMOVE ))
{ {
flags |= GET_MSG_REMOVE_LAST; TRACE("dropping msg %x\n", info.msg.message );
goto next; goto next; /* ignore it */
} }
queue->GetMessagePosVal = MAKELONG( info.msg.pt.x, info.msg.pt.y ); queue->GetMessagePosVal = MAKELONG( info.msg.pt.x, info.msg.pt.y );
/* fall through */ /* fall through */
...@@ -1495,8 +1519,7 @@ BOOL MSG_peek_message( MSG *msg, HWND hwnd, UINT first, UINT last, int flags ) ...@@ -1495,8 +1519,7 @@ BOOL MSG_peek_message( MSG *msg, HWND hwnd, UINT first, UINT last, int flags )
ERR( "invalid packed dde-message %x (%s) hwnd %p wp %x lp %lx size %d\n", ERR( "invalid packed dde-message %x (%s) hwnd %p wp %x lp %lx size %d\n",
info.msg.message, SPY_GetMsgName(info.msg.message, info.msg.hwnd), info.msg.message, SPY_GetMsgName(info.msg.message, info.msg.hwnd),
info.msg.hwnd, info.msg.wParam, info.msg.lParam, size ); info.msg.hwnd, info.msg.wParam, info.msg.lParam, size );
/* ignore it */ goto next; /* ignore it */
continue;
} }
} }
*msg = info.msg; *msg = info.msg;
......
...@@ -2162,8 +2162,7 @@ enum message_type ...@@ -2162,8 +2162,7 @@ enum message_type
MSG_CALLBACK, MSG_CALLBACK,
MSG_OTHER_PROCESS, MSG_OTHER_PROCESS,
MSG_POSTED, MSG_POSTED,
MSG_HARDWARE_RAW, MSG_HARDWARE
MSG_HARDWARE_COOKED
}; };
...@@ -2193,7 +2192,6 @@ struct get_message_reply ...@@ -2193,7 +2192,6 @@ struct get_message_reply
}; };
#define GET_MSG_REMOVE 1 #define GET_MSG_REMOVE 1
#define GET_MSG_SENT_ONLY 2 #define GET_MSG_SENT_ONLY 2
#define GET_MSG_REMOVE_LAST 4
struct reply_message_request struct reply_message_request
...@@ -3479,6 +3477,6 @@ union generic_reply ...@@ -3479,6 +3477,6 @@ union generic_reply
struct get_next_hook_reply get_next_hook_reply; struct get_next_hook_reply get_next_hook_reply;
}; };
#define SERVER_PROTOCOL_VERSION 92 #define SERVER_PROTOCOL_VERSION 93
#endif /* __WINE_WINE_SERVER_PROTOCOL_H */ #endif /* __WINE_WINE_SERVER_PROTOCOL_H */
...@@ -1530,8 +1530,7 @@ enum message_type ...@@ -1530,8 +1530,7 @@ enum message_type
MSG_CALLBACK, /* callback message (from SendMessageCallbackW), always Unicode */ MSG_CALLBACK, /* callback message (from SendMessageCallbackW), always Unicode */
MSG_OTHER_PROCESS, /* sent from other process, may include vararg data, always Unicode */ MSG_OTHER_PROCESS, /* sent from other process, may include vararg data, always Unicode */
MSG_POSTED, /* posted message (from PostMessageW), always Unicode */ MSG_POSTED, /* posted message (from PostMessageW), always Unicode */
MSG_HARDWARE_RAW, /* raw hardware message */ MSG_HARDWARE /* hardware message */
MSG_HARDWARE_COOKED /* cooked hardware message */
}; };
...@@ -1556,7 +1555,6 @@ enum message_type ...@@ -1556,7 +1555,6 @@ enum message_type
@END @END
#define GET_MSG_REMOVE 1 /* remove the message */ #define GET_MSG_REMOVE 1 /* remove the message */
#define GET_MSG_SENT_ONLY 2 /* only get sent messages */ #define GET_MSG_SENT_ONLY 2 /* only get sent messages */
#define GET_MSG_REMOVE_LAST 4 /* remove last message returned before checking for a new one */
/* Reply to a sent message */ /* Reply to a sent message */
@REQ(reply_message) @REQ(reply_message)
......
...@@ -62,6 +62,7 @@ extern int is_child_window( user_handle_t parent, user_handle_t child ); ...@@ -62,6 +62,7 @@ extern int is_child_window( user_handle_t parent, user_handle_t child );
extern int is_top_level_window( user_handle_t window ); extern int is_top_level_window( user_handle_t window );
extern int make_window_active( user_handle_t window ); extern int make_window_active( user_handle_t window );
extern struct thread *get_window_thread( user_handle_t handle ); extern struct thread *get_window_thread( user_handle_t handle );
extern user_handle_t window_from_point( int x, int y );
extern user_handle_t find_window_to_repaint( user_handle_t parent, struct thread *thread ); extern user_handle_t find_window_to_repaint( user_handle_t parent, struct thread *thread );
#endif /* __WINE_SERVER_USER_H */ #endif /* __WINE_SERVER_USER_H */
...@@ -343,6 +343,46 @@ int make_window_active( user_handle_t window ) ...@@ -343,6 +343,46 @@ int make_window_active( user_handle_t window )
return 1; return 1;
} }
/* find child of 'parent' that contains the given point (in parent-relative coords) */
static struct window *child_window_from_point( struct window *parent, int x, int y )
{
struct window *ptr, *ret = NULL;
for (ptr = parent->first_child; ptr && !ret; ptr = ptr->next)
{
if (!(ptr->style & WS_VISIBLE)) continue; /* not visible -> skip */
if ((ptr->style & (WS_POPUP|WS_CHILD|WS_DISABLED)) == (WS_CHILD|WS_DISABLED))
continue; /* disabled child -> skip */
if ((ptr->ex_style & (WS_EX_LAYERED|WS_EX_TRANSPARENT)) == (WS_EX_LAYERED|WS_EX_TRANSPARENT))
continue; /* transparent -> skip */
if (x < ptr->window_rect.left || x >= ptr->window_rect.right ||
y < ptr->window_rect.top || y >= ptr->window_rect.bottom)
continue; /* not in window -> skip */
/* FIXME: check window region here */
/* if window is minimized or disabled, return at once */
if (ptr->style & (WS_MINIMIZE|WS_DISABLED)) return ptr;
/* if point is not in client area, return at once */
if (x < ptr->client_rect.left || x >= ptr->client_rect.right ||
y < ptr->client_rect.top || y >= ptr->client_rect.bottom)
return ptr;
return child_window_from_point( ptr, x - ptr->client_rect.left, y - ptr->client_rect.top );
}
return parent; /* not found any child */
}
/* find window containing point (in absolute coords) */
user_handle_t window_from_point( int x, int y )
{
struct window *ret;
if (!top_window) return 0;
ret = child_window_from_point( top_window, x, y );
return ret->handle;
}
/* return the thread owning a window */ /* return the thread owning a window */
struct thread *get_window_thread( user_handle_t handle ) struct thread *get_window_thread( user_handle_t handle )
......
...@@ -102,19 +102,19 @@ static WORD get_key_state(void) ...@@ -102,19 +102,19 @@ static WORD get_key_state(void)
/*********************************************************************** /***********************************************************************
* queue_raw_hardware_message * queue_hardware_message
* *
* Add a message to the raw hardware queue. * Add a message to the hardware queue.
* Note: the position is relative to the desktop window. * Note: the position is relative to the desktop window.
*/ */
static void queue_raw_hardware_message( UINT message, WPARAM wParam, LPARAM lParam, static void queue_hardware_message( UINT message, HWND hwnd, WPARAM wParam, LPARAM lParam,
int xPos, int yPos, DWORD time, ULONG_PTR extraInfo ) int xPos, int yPos, DWORD time, ULONG_PTR extraInfo )
{ {
SERVER_START_REQ( send_message ) SERVER_START_REQ( send_message )
{ {
req->id = GetCurrentThreadId(); req->id = GetCurrentThreadId();
req->type = MSG_HARDWARE_RAW; req->type = MSG_HARDWARE;
req->win = 0; req->win = hwnd;
req->msg = message; req->msg = message;
req->wparam = wParam; req->wparam = wParam;
req->lparam = lParam; req->lparam = lParam;
...@@ -182,8 +182,8 @@ static void queue_kbd_event( const KEYBDINPUT *ki, UINT injected_flags ) ...@@ -182,8 +182,8 @@ static void queue_kbd_event( const KEYBDINPUT *ki, UINT injected_flags )
hook.time = ki->time; hook.time = ki->time;
hook.dwExtraInfo = ki->dwExtraInfo; hook.dwExtraInfo = ki->dwExtraInfo;
if (!HOOK_CallHooks( WH_KEYBOARD_LL, HC_ACTION, message, (LPARAM)&hook, TRUE )) if (!HOOK_CallHooks( WH_KEYBOARD_LL, HC_ACTION, message, (LPARAM)&hook, TRUE ))
queue_raw_hardware_message( message, ki->wVk, keylp.lp2, queue_hardware_message( message, 0, ki->wVk, keylp.lp2,
PosX, PosY, ki->time, ki->dwExtraInfo ); PosX, PosY, ki->time, ki->dwExtraInfo );
} }
...@@ -202,8 +202,9 @@ static void queue_raw_mouse_message( UINT message, UINT flags, INT x, INT y, con ...@@ -202,8 +202,9 @@ static void queue_raw_mouse_message( UINT message, UINT flags, INT x, INT y, con
hook.dwExtraInfo = mi->dwExtraInfo; hook.dwExtraInfo = mi->dwExtraInfo;
if (!HOOK_CallHooks( WH_MOUSE_LL, HC_ACTION, message, (LPARAM)&hook, TRUE )) if (!HOOK_CallHooks( WH_MOUSE_LL, HC_ACTION, message, (LPARAM)&hook, TRUE ))
queue_raw_hardware_message( message, MAKEWPARAM( get_key_state(), mi->mouseData ), queue_hardware_message( message, (HWND)mi->dwExtraInfo /*FIXME*/,
0, x, y, mi->time, mi->dwExtraInfo ); MAKEWPARAM( get_key_state(), mi->mouseData ),
0, x, y, mi->time, mi->dwExtraInfo );
} }
......
...@@ -107,11 +107,12 @@ inline static void process_sent_messages(void) ...@@ -107,11 +107,12 @@ inline static void process_sent_messages(void)
* *
* store a hardware message in the thread queue * store a hardware message in the thread queue
*/ */
static void queue_hardware_message( MSG *msg, ULONG_PTR extra_info, enum message_type type ) #if 0
static void queue_hardware_message( MSG *msg, ULONG_PTR extra_info )
{ {
SERVER_START_REQ( send_message ) SERVER_START_REQ( send_message )
{ {
req->type = type; req->type = MSG_HARDWARE;
req->id = GetWindowThreadProcessId( msg->hwnd, NULL ); req->id = GetWindowThreadProcessId( msg->hwnd, NULL );
req->win = msg->hwnd; req->win = msg->hwnd;
req->msg = msg->message; req->msg = msg->message;
...@@ -126,6 +127,7 @@ static void queue_hardware_message( MSG *msg, ULONG_PTR extra_info, enum message ...@@ -126,6 +127,7 @@ static void queue_hardware_message( MSG *msg, ULONG_PTR extra_info, enum message
} }
SERVER_END_REQ; SERVER_END_REQ;
} }
#endif
/*********************************************************************** /***********************************************************************
...@@ -274,7 +276,7 @@ void MSG_JournalPlayBackMsg(void) ...@@ -274,7 +276,7 @@ void MSG_JournalPlayBackMsg(void)
msg.lParam |= 0x01000000; msg.lParam |= 0x01000000;
msg.pt.x = msg.pt.y = 0; msg.pt.x = msg.pt.y = 0;
queue_hardware_message( &msg, 0, MSG_HARDWARE_RAW ); queue_hardware_message( &msg, 0 );
} }
else if ((tmpMsg.message>= WM_MOUSEFIRST) && (tmpMsg.message <= WM_MOUSELAST)) else if ((tmpMsg.message>= WM_MOUSEFIRST) && (tmpMsg.message <= WM_MOUSELAST))
{ {
...@@ -311,7 +313,7 @@ void MSG_JournalPlayBackMsg(void) ...@@ -311,7 +313,7 @@ void MSG_JournalPlayBackMsg(void)
msg.pt.x = tmpMsg.paramL; msg.pt.x = tmpMsg.paramL;
msg.pt.y = tmpMsg.paramH; msg.pt.y = tmpMsg.paramH;
queue_hardware_message( &msg, 0, MSG_HARDWARE_RAW ); queue_hardware_message( &msg, 0 );
} }
HOOK_CallHooks( WH_JOURNALPLAYBACK, HC_SKIP, 0, (LPARAM)&tmpMsg, TRUE ); HOOK_CallHooks( WH_JOURNALPLAYBACK, HC_SKIP, 0, (LPARAM)&tmpMsg, TRUE );
} }
...@@ -399,7 +401,7 @@ static BOOL process_cooked_keyboard_message( MSG *msg, BOOL remove ) ...@@ -399,7 +401,7 @@ static BOOL process_cooked_keyboard_message( MSG *msg, BOOL remove )
* *
* returns TRUE if the contents of 'msg' should be passed to the application * returns TRUE if the contents of 'msg' should be passed to the application
*/ */
static BOOL process_raw_mouse_message( MSG *msg, ULONG_PTR extra_info ) static BOOL process_raw_mouse_message( MSG *msg, ULONG_PTR extra_info, BOOL remove )
{ {
static MSG clk_msg; static MSG clk_msg;
...@@ -407,6 +409,7 @@ static BOOL process_raw_mouse_message( MSG *msg, ULONG_PTR extra_info ) ...@@ -407,6 +409,7 @@ static BOOL process_raw_mouse_message( MSG *msg, ULONG_PTR extra_info )
INT hittest; INT hittest;
EVENTMSG event; EVENTMSG event;
GUITHREADINFO info; GUITHREADINFO info;
HWND hWndScope = msg->hwnd;
/* find the window to dispatch this mouse message to */ /* find the window to dispatch this mouse message to */
...@@ -416,8 +419,6 @@ static BOOL process_raw_mouse_message( MSG *msg, ULONG_PTR extra_info ) ...@@ -416,8 +419,6 @@ static BOOL process_raw_mouse_message( MSG *msg, ULONG_PTR extra_info )
{ {
/* If no capture HWND, find window which contains the mouse position. /* If no capture HWND, find window which contains the mouse position.
* Also find the position of the cursor hot spot (hittest) */ * Also find the position of the cursor hot spot (hittest) */
HWND hWndScope = (HWND)extra_info;
if (!IsWindow(hWndScope)) hWndScope = 0; if (!IsWindow(hWndScope)) hWndScope = 0;
if (!(msg->hwnd = WINPOS_WindowFromPoint( hWndScope, msg->pt, &hittest ))) if (!(msg->hwnd = WINPOS_WindowFromPoint( hWndScope, msg->pt, &hittest )))
msg->hwnd = GetDesktopWindow(); msg->hwnd = GetDesktopWindow();
...@@ -436,7 +437,7 @@ static BOOL process_raw_mouse_message( MSG *msg, ULONG_PTR extra_info ) ...@@ -436,7 +437,7 @@ static BOOL process_raw_mouse_message( MSG *msg, ULONG_PTR extra_info )
(msg->message == WM_RBUTTONDOWN) || (msg->message == WM_RBUTTONDOWN) ||
(msg->message == WM_MBUTTONDOWN)) (msg->message == WM_MBUTTONDOWN))
{ {
BOOL update = TRUE; BOOL update = remove;
/* translate double clicks - /* translate double clicks -
* note that ...MOUSEMOVEs can slip in between * note that ...MOUSEMOVEs can slip in between
* ...BUTTONDOWN and ...BUTTONDBLCLK messages */ * ...BUTTONDOWN and ...BUTTONDBLCLK messages */
...@@ -452,8 +453,11 @@ static BOOL process_raw_mouse_message( MSG *msg, ULONG_PTR extra_info ) ...@@ -452,8 +453,11 @@ static BOOL process_raw_mouse_message( MSG *msg, ULONG_PTR extra_info )
(abs(msg->pt.y - clk_msg.pt.y) < GetSystemMetrics(SM_CYDOUBLECLK)/2)) (abs(msg->pt.y - clk_msg.pt.y) < GetSystemMetrics(SM_CYDOUBLECLK)/2))
{ {
msg->message += (WM_LBUTTONDBLCLK - WM_LBUTTONDOWN); msg->message += (WM_LBUTTONDBLCLK - WM_LBUTTONDOWN);
clk_msg.message = 0; if (remove)
update = FALSE; {
clk_msg.message = 0;
update = FALSE;
}
} }
} }
/* update static double click conditions */ /* update static double click conditions */
...@@ -602,26 +606,14 @@ BOOL MSG_process_raw_hardware_message( MSG *msg, ULONG_PTR extra_info, HWND hwnd ...@@ -602,26 +606,14 @@ BOOL MSG_process_raw_hardware_message( MSG *msg, ULONG_PTR extra_info, HWND hwnd
} }
else if (is_mouse_message( msg->message )) else if (is_mouse_message( msg->message ))
{ {
if (!process_raw_mouse_message( msg, extra_info )) return FALSE; if (!process_raw_mouse_message( msg, extra_info, remove )) return FALSE;
} }
else else
{ {
ERR( "unknown message type %x\n", msg->message ); ERR( "unknown message type %x\n", msg->message );
return FALSE; return FALSE;
} }
return check_message_filter( msg, hwnd_filter, first, last );
/* check destination thread and filters */
if (!check_message_filter( msg, hwnd_filter, first, last ) ||
!WIN_IsCurrentThread( msg->hwnd ))
{
/* queue it for later, or for another thread */
queue_hardware_message( msg, extra_info, MSG_HARDWARE_COOKED );
return FALSE;
}
/* save the message in the cooked queue if we didn't want to remove it */
if (!remove) queue_hardware_message( msg, extra_info, MSG_HARDWARE_COOKED );
return TRUE;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment