From 516e40e154719d0aa523e4aa7dbe971b07211202 Mon Sep 17 00:00:00 2001 From: Alexandre Julliard Date: Wed, 17 Oct 2001 17:48:49 +0000 Subject: [PATCH] Make sure that GetMessagePos and GetMessageTime return sane values for all messages. --- dlls/user/message.c | 18 +++++++++--------- include/message.h | 2 +- server/main.c | 11 ----------- server/queue.c | 4 ++-- server/request.c | 12 ++++++++++++ server/request.h | 1 + windows/message.c | 10 +++++----- 7 files changed, 30 insertions(+), 28 deletions(-) diff --git a/dlls/user/message.c b/dlls/user/message.c index 04cd9ab0b19..a9608cbaca7 100644 --- a/dlls/user/message.c +++ b/dlls/user/message.c @@ -1239,21 +1239,24 @@ BOOL MSG_peek_message( MSG *msg, HWND hwnd, UINT first, UINT last, int flags ) continue; } break; - case MSG_POSTED: - goto got_one; case MSG_HARDWARE_RAW: if (!MSG_process_raw_hardware_message( &info.msg, extra_info, hwnd, first, last, flags & GET_MSG_REMOVE )) continue; /* fall through */ case MSG_HARDWARE_COOKED: - if (!MSG_process_cooked_hardware_message( &info.msg, flags & GET_MSG_REMOVE )) + if (!MSG_process_cooked_hardware_message( &info.msg, extra_info, + flags & GET_MSG_REMOVE )) { flags |= GET_MSG_REMOVE_LAST; continue; } + queue->GetMessagePosVal = MAKELONG( info.msg.pt.x, info.msg.pt.y ); + /* fall through */ + case MSG_POSTED: queue->GetMessageExtraInfoVal = extra_info; - goto got_one; + *msg = info.msg; + return TRUE; } /* if we get here, we have a sent message; call the window procedure */ @@ -1266,10 +1269,6 @@ BOOL MSG_peek_message( MSG *msg, HWND hwnd, UINT first, UINT last, int flags ) if (buffer) HeapFree( GetProcessHeap(), 0, buffer ); } - - got_one: - *msg = info.msg; - return TRUE; } @@ -1898,7 +1897,8 @@ BOOL WINAPI PeekMessageW( MSG *msg_out, HWND hwnd, UINT first, UINT last, UINT f if ((queue = QUEUE_Current())) { queue->GetMessageTimeVal = msg.time; - queue->GetMessagePosVal = MAKELONG( msg.pt.x, msg.pt.y ); + msg.pt.x = LOWORD( queue->GetMessagePosVal ); + msg.pt.y = HIWORD( queue->GetMessagePosVal ); } HOOK_CallHooksW( WH_GETMESSAGE, HC_ACTION, flags & PM_REMOVE, (LPARAM)&msg ); diff --git a/include/message.h b/include/message.h index f27bc6b4997..c5f80bc97e0 100644 --- a/include/message.h +++ b/include/message.h @@ -14,7 +14,7 @@ /* message.c */ extern BOOL MSG_process_raw_hardware_message( MSG *msg, ULONG_PTR extra_info, HWND hwnd_filter, UINT first, UINT last, BOOL remove ); -extern BOOL MSG_process_cooked_hardware_message( MSG *msg, BOOL remove ); +extern BOOL MSG_process_cooked_hardware_message( MSG *msg, ULONG_PTR extra_info, BOOL remove ); extern void MSG_JournalPlayBackMsg(void); /* sendmsg.c */ diff --git a/server/main.c b/server/main.c index 02b62445489..03123b9ae44 100644 --- a/server/main.c +++ b/server/main.c @@ -21,8 +21,6 @@ int debug_level = 0; int persistent_server = 0; -unsigned int server_start_ticks = 0; - /* parse-line args */ /* FIXME: should probably use getopt, and add a (more complete?) help option */ @@ -87,14 +85,6 @@ static void signal_init(void) signal( SIGABRT, sigterm_handler ); } -/* get server start ticks used to calculate GetTickCount() in Wine clients */ -static void get_start_ticks(void) -{ - struct timeval t; - gettimeofday( &t, NULL ); - server_start_ticks = (t.tv_sec * 1000) + (t.tv_usec / 1000); -} - int main( int argc, char *argv[] ) { parse_args( argc, argv ); @@ -103,7 +93,6 @@ int main( int argc, char *argv[] ) setvbuf( stderr, NULL, _IOLBF, 0 ); if (debug_level) fprintf( stderr, "Server: starting (pid=%ld)\n", (long) getpid() ); - get_start_ticks(); init_registry(); select_loop(); close_registry(); diff --git a/server/queue.c b/server/queue.c index 4cf92e0b52a..c1c0e7854c3 100644 --- a/server/queue.c +++ b/server/queue.c @@ -908,7 +908,7 @@ DECL_HANDLER(get_message) req->lparam = 0; req->x = 0; req->y = 0; - req->time = 0; + req->time = get_tick_count(); req->info = 0; return; } @@ -924,7 +924,7 @@ DECL_HANDLER(get_message) req->lparam = timer->lparam; req->x = 0; req->y = 0; - req->time = 0; + req->time = get_tick_count(); req->info = 0; return; } diff --git a/server/request.c b/server/request.c index 1867ddf718c..b7207a131f6 100644 --- a/server/request.c +++ b/server/request.c @@ -71,6 +71,7 @@ static const struct object_ops master_socket_ops = struct thread *current = NULL; /* thread handling the current request */ unsigned int global_error = 0; /* global error code for when no thread is current */ +unsigned int server_start_ticks = 0; /* tick count offset from server startup */ static struct master_socket *master_socket; /* the master socket object */ @@ -316,6 +317,14 @@ int send_client_fd( struct process *process, int fd, handle_t handle ) return -1; } +/* get current tick count to return to client */ +unsigned int get_tick_count(void) +{ + struct timeval t; + gettimeofday( &t, NULL ); + return (t.tv_sec * 1000) + (t.tv_usec / 1000) - server_start_ticks; +} + static void master_socket_dump( struct object *obj, int verbose ) { struct master_socket *sock = (struct master_socket *)obj; @@ -460,6 +469,9 @@ void open_master_socket(void) msghdr.msg_iov = &myiovec; msghdr.msg_iovlen = 1; + /* init startup ticks */ + server_start_ticks = get_tick_count(); + /* go in the background */ switch(fork()) { diff --git a/server/request.h b/server/request.h index 6202c002e27..aae7aeae32f 100644 --- a/server/request.h +++ b/server/request.h @@ -37,6 +37,7 @@ extern int receive_fd( struct process *process ); extern int send_client_fd( struct process *process, int fd, handle_t handle ); extern void read_request( struct thread *thread ); extern void send_reply( struct thread *thread, union generic_request *request ); +extern unsigned int get_tick_count(void); extern void open_master_socket(void); extern void close_master_socket(void); extern void lock_master_socket( int locked ); diff --git a/windows/message.c b/windows/message.c index 077af8619ba..a9e5c39d5cc 100644 --- a/windows/message.c +++ b/windows/message.c @@ -438,7 +438,7 @@ static BOOL process_raw_mouse_message( MSG *msg, ULONG_PTR extra_info ) * * returns TRUE if the contents of 'msg' should be passed to the application */ -static BOOL process_cooked_mouse_message( MSG *msg, BOOL remove ) +static BOOL process_cooked_mouse_message( MSG *msg, ULONG_PTR extra_info, BOOL remove ) { INT hittest = HTCLIENT; UINT raw_message = msg->message; @@ -464,14 +464,14 @@ static BOOL process_cooked_mouse_message( MSG *msg, BOOL remove ) hook.pt = msg->pt; hook.hwnd = msg->hwnd; hook.wHitTestCode = hittest; - hook.dwExtraInfo = 0; + hook.dwExtraInfo = extra_info; if (HOOK_CallHooksA( WH_MOUSE, remove ? HC_ACTION : HC_NOREMOVE, msg->message, (LPARAM)&hook )) { hook.pt = msg->pt; hook.hwnd = msg->hwnd; hook.wHitTestCode = hittest; - hook.dwExtraInfo = 0; + hook.dwExtraInfo = extra_info; HOOK_CallHooksA( WH_CBT, HCBT_CLICKSKIPPED, msg->message, (LPARAM)&hook ); return FALSE; } @@ -582,13 +582,13 @@ BOOL MSG_process_raw_hardware_message( MSG *msg, ULONG_PTR extra_info, HWND hwnd * * returns TRUE if the contents of 'msg' should be passed to the application */ -BOOL MSG_process_cooked_hardware_message( MSG *msg, BOOL remove ) +BOOL MSG_process_cooked_hardware_message( MSG *msg, ULONG_PTR extra_info, BOOL remove ) { if (is_keyboard_message( msg->message )) return process_cooked_keyboard_message( msg, remove ); if (is_mouse_message( msg->message )) - return process_cooked_mouse_message( msg, remove ); + return process_cooked_mouse_message( msg, extra_info, remove ); ERR( "unknown message type %x\n", msg->message ); return FALSE;