Make sure that GetMessagePos and GetMessageTime return sane values

for all messages.
This commit is contained in:
Alexandre Julliard 2001-10-17 17:48:49 +00:00
parent 2547121843
commit 516e40e154
7 changed files with 30 additions and 28 deletions

View File

@ -1239,21 +1239,24 @@ BOOL MSG_peek_message( MSG *msg, HWND hwnd, UINT first, UINT last, int flags )
continue; continue;
} }
break; break;
case MSG_POSTED:
goto got_one;
case MSG_HARDWARE_RAW: case MSG_HARDWARE_RAW:
if (!MSG_process_raw_hardware_message( &info.msg, extra_info, if (!MSG_process_raw_hardware_message( &info.msg, extra_info,
hwnd, first, last, flags & GET_MSG_REMOVE )) hwnd, first, last, flags & GET_MSG_REMOVE ))
continue; continue;
/* fall through */ /* fall through */
case MSG_HARDWARE_COOKED: 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; flags |= GET_MSG_REMOVE_LAST;
continue; continue;
} }
queue->GetMessagePosVal = MAKELONG( info.msg.pt.x, info.msg.pt.y );
/* fall through */
case MSG_POSTED:
queue->GetMessageExtraInfoVal = extra_info; 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 */ /* 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 ); 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())) if ((queue = QUEUE_Current()))
{ {
queue->GetMessageTimeVal = msg.time; 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 ); HOOK_CallHooksW( WH_GETMESSAGE, HC_ACTION, flags & PM_REMOVE, (LPARAM)&msg );

View File

@ -14,7 +14,7 @@
/* message.c */ /* message.c */
extern BOOL MSG_process_raw_hardware_message( MSG *msg, ULONG_PTR extra_info, HWND hwnd_filter, extern BOOL MSG_process_raw_hardware_message( MSG *msg, ULONG_PTR extra_info, HWND hwnd_filter,
UINT first, UINT last, BOOL remove ); 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); extern void MSG_JournalPlayBackMsg(void);
/* sendmsg.c */ /* sendmsg.c */

View File

@ -21,8 +21,6 @@
int debug_level = 0; int debug_level = 0;
int persistent_server = 0; int persistent_server = 0;
unsigned int server_start_ticks = 0;
/* parse-line args */ /* parse-line args */
/* FIXME: should probably use getopt, and add a (more complete?) help option */ /* 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 ); 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[] ) int main( int argc, char *argv[] )
{ {
parse_args( argc, argv ); parse_args( argc, argv );
@ -103,7 +93,6 @@ int main( int argc, char *argv[] )
setvbuf( stderr, NULL, _IOLBF, 0 ); setvbuf( stderr, NULL, _IOLBF, 0 );
if (debug_level) fprintf( stderr, "Server: starting (pid=%ld)\n", (long) getpid() ); if (debug_level) fprintf( stderr, "Server: starting (pid=%ld)\n", (long) getpid() );
get_start_ticks();
init_registry(); init_registry();
select_loop(); select_loop();
close_registry(); close_registry();

View File

@ -908,7 +908,7 @@ DECL_HANDLER(get_message)
req->lparam = 0; req->lparam = 0;
req->x = 0; req->x = 0;
req->y = 0; req->y = 0;
req->time = 0; req->time = get_tick_count();
req->info = 0; req->info = 0;
return; return;
} }
@ -924,7 +924,7 @@ DECL_HANDLER(get_message)
req->lparam = timer->lparam; req->lparam = timer->lparam;
req->x = 0; req->x = 0;
req->y = 0; req->y = 0;
req->time = 0; req->time = get_tick_count();
req->info = 0; req->info = 0;
return; return;
} }

View File

@ -71,6 +71,7 @@ static const struct object_ops master_socket_ops =
struct thread *current = NULL; /* thread handling the current request */ 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 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 */ 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; 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 ) static void master_socket_dump( struct object *obj, int verbose )
{ {
struct master_socket *sock = (struct master_socket *)obj; struct master_socket *sock = (struct master_socket *)obj;
@ -460,6 +469,9 @@ void open_master_socket(void)
msghdr.msg_iov = &myiovec; msghdr.msg_iov = &myiovec;
msghdr.msg_iovlen = 1; msghdr.msg_iovlen = 1;
/* init startup ticks */
server_start_ticks = get_tick_count();
/* go in the background */ /* go in the background */
switch(fork()) switch(fork())
{ {

View File

@ -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 int send_client_fd( struct process *process, int fd, handle_t handle );
extern void read_request( struct thread *thread ); extern void read_request( struct thread *thread );
extern void send_reply( struct thread *thread, union generic_request *request ); 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 open_master_socket(void);
extern void close_master_socket(void); extern void close_master_socket(void);
extern void lock_master_socket( int locked ); extern void lock_master_socket( int locked );

View File

@ -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 * 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; INT hittest = HTCLIENT;
UINT raw_message = msg->message; UINT raw_message = msg->message;
@ -464,14 +464,14 @@ static BOOL process_cooked_mouse_message( MSG *msg, BOOL remove )
hook.pt = msg->pt; hook.pt = msg->pt;
hook.hwnd = msg->hwnd; hook.hwnd = msg->hwnd;
hook.wHitTestCode = hittest; hook.wHitTestCode = hittest;
hook.dwExtraInfo = 0; hook.dwExtraInfo = extra_info;
if (HOOK_CallHooksA( WH_MOUSE, remove ? HC_ACTION : HC_NOREMOVE, if (HOOK_CallHooksA( WH_MOUSE, remove ? HC_ACTION : HC_NOREMOVE,
msg->message, (LPARAM)&hook )) msg->message, (LPARAM)&hook ))
{ {
hook.pt = msg->pt; hook.pt = msg->pt;
hook.hwnd = msg->hwnd; hook.hwnd = msg->hwnd;
hook.wHitTestCode = hittest; hook.wHitTestCode = hittest;
hook.dwExtraInfo = 0; hook.dwExtraInfo = extra_info;
HOOK_CallHooksA( WH_CBT, HCBT_CLICKSKIPPED, msg->message, (LPARAM)&hook ); HOOK_CallHooksA( WH_CBT, HCBT_CLICKSKIPPED, msg->message, (LPARAM)&hook );
return FALSE; 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 * 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 )) if (is_keyboard_message( msg->message ))
return process_cooked_keyboard_message( msg, remove ); return process_cooked_keyboard_message( msg, remove );
if (is_mouse_message( msg->message )) 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 ); ERR( "unknown message type %x\n", msg->message );
return FALSE; return FALSE;