Commit 039e1311 authored by Alexandre Julliard's avatar Alexandre Julliard

Implemented inter-thread SendMessageCallback.

parent 30573158
...@@ -38,6 +38,7 @@ ...@@ -38,6 +38,7 @@
#include "wine/debug.h" #include "wine/debug.h"
WINE_DEFAULT_DEBUG_CHANNEL(msg); WINE_DEFAULT_DEBUG_CHANNEL(msg);
WINE_DECLARE_DEBUG_CHANNEL(relay);
#define WM_NCMOUSEFIRST WM_NCMOUSEMOVE #define WM_NCMOUSEFIRST WM_NCMOUSEMOVE
#define WM_NCMOUSELAST WM_NCMBUTTONDBLCLK #define WM_NCMOUSELAST WM_NCMBUTTONDBLCLK
...@@ -1469,6 +1470,26 @@ static BOOL process_hardware_message( MSG *msg, ULONG_PTR extra_info, HWND hwnd, ...@@ -1469,6 +1470,26 @@ static BOOL process_hardware_message( MSG *msg, ULONG_PTR extra_info, HWND hwnd,
/*********************************************************************** /***********************************************************************
* call_sendmsg_callback
*
* Call the callback function of SendMessageCallback.
*/
static inline void call_sendmsg_callback( SENDASYNCPROC callback, HWND hwnd, UINT msg,
ULONG_PTR data, LRESULT result )
{
if (TRACE_ON(relay))
DPRINTF( "%04lx:Call message callback %p (hwnd=%p,msg=%s,data=%08lx,result=%08lx)\n",
GetCurrentThreadId(), callback, hwnd, SPY_GetMsgName( msg, hwnd ),
data, result );
callback( hwnd, msg, data, result );
if (TRACE_ON(relay))
DPRINTF( "%04lx:Ret message callback %p (hwnd=%p,msg=%s,data=%08lx,result=%08lx)\n",
GetCurrentThreadId(), callback, hwnd, SPY_GetMsgName( msg, hwnd ),
data, result );
}
/***********************************************************************
* 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.
...@@ -1540,6 +1561,10 @@ BOOL MSG_peek_message( MSG *msg, HWND hwnd, UINT first, UINT last, int flags ) ...@@ -1540,6 +1561,10 @@ BOOL MSG_peek_message( MSG *msg, HWND hwnd, UINT first, UINT last, int flags )
case MSG_CALLBACK: case MSG_CALLBACK:
info.flags = ISMEX_CALLBACK; info.flags = ISMEX_CALLBACK;
break; break;
case MSG_CALLBACK_RESULT:
call_sendmsg_callback( (SENDASYNCPROC)info.msg.wParam, info.msg.hwnd,
info.msg.message, extra_info, info.msg.lParam );
goto next;
case MSG_OTHER_PROCESS: case MSG_OTHER_PROCESS:
info.flags = ISMEX_SEND; info.flags = ISMEX_SEND;
if (!unpack_message( info.msg.hwnd, info.msg.message, &info.msg.wParam, if (!unpack_message( info.msg.hwnd, info.msg.message, &info.msg.wParam,
...@@ -1690,6 +1715,13 @@ static BOOL put_message_in_queue( DWORD dest_tid, const struct send_message_info ...@@ -1690,6 +1715,13 @@ static BOOL put_message_in_queue( DWORD dest_tid, const struct send_message_info
req->lparam = info->lparam; req->lparam = info->lparam;
req->time = GetCurrentTime(); req->time = GetCurrentTime();
req->timeout = timeout; req->timeout = timeout;
if (info->type == MSG_CALLBACK)
{
req->callback = info->callback;
req->info = info->data;
}
if (info->flags & SMTO_ABORTIFHUNG) req->flags |= SEND_MSG_ABORT_IF_HUNG; if (info->flags & SMTO_ABORTIFHUNG) req->flags |= SEND_MSG_ABORT_IF_HUNG;
for (i = 0; i < data.count; i++) wine_server_add_data( req, data.data[i], data.size[i] ); for (i = 0; i < data.count; i++) wine_server_add_data( req, data.data[i], data.size[i] );
if ((res = wine_server_call( req ))) if ((res = wine_server_call( req )))
...@@ -2043,7 +2075,7 @@ BOOL WINAPI SendMessageCallbackW( HWND hwnd, UINT msg, WPARAM wparam, LPARAM lpa ...@@ -2043,7 +2075,7 @@ BOOL WINAPI SendMessageCallbackW( HWND hwnd, UINT msg, WPARAM wparam, LPARAM lpa
if (dest_tid == GetCurrentThreadId()) if (dest_tid == GetCurrentThreadId())
{ {
result = call_window_proc( hwnd, msg, wparam, lparam, TRUE, TRUE ); result = call_window_proc( hwnd, msg, wparam, lparam, TRUE, TRUE );
callback( hwnd, msg, data, result ); call_sendmsg_callback( callback, hwnd, msg, data, result );
return TRUE; return TRUE;
} }
FIXME( "callback will not be called\n" ); FIXME( "callback will not be called\n" );
......
...@@ -2214,6 +2214,7 @@ struct send_message_request ...@@ -2214,6 +2214,7 @@ struct send_message_request
unsigned int time; unsigned int time;
unsigned int info; unsigned int info;
int timeout; int timeout;
void* callback;
/* VARARG(data,bytes); */ /* VARARG(data,bytes); */
}; };
struct send_message_reply struct send_message_reply
...@@ -2227,6 +2228,7 @@ enum message_type ...@@ -2227,6 +2228,7 @@ enum message_type
MSG_UNICODE, MSG_UNICODE,
MSG_NOTIFY, MSG_NOTIFY,
MSG_CALLBACK, MSG_CALLBACK,
MSG_CALLBACK_RESULT,
MSG_OTHER_PROCESS, MSG_OTHER_PROCESS,
MSG_POSTED, MSG_POSTED,
MSG_HARDWARE MSG_HARDWARE
...@@ -3645,6 +3647,6 @@ union generic_reply ...@@ -3645,6 +3647,6 @@ union generic_reply
struct open_token_reply open_token_reply; struct open_token_reply open_token_reply;
}; };
#define SERVER_PROTOCOL_VERSION 117 #define SERVER_PROTOCOL_VERSION 118
#endif /* __WINE_WINE_SERVER_PROTOCOL_H */ #endif /* __WINE_WINE_SERVER_PROTOCOL_H */
...@@ -1574,6 +1574,7 @@ enum char_info_mode ...@@ -1574,6 +1574,7 @@ enum char_info_mode
unsigned int time; /* message time */ unsigned int time; /* message time */
unsigned int info; /* extra info */ unsigned int info; /* extra info */
int timeout; /* timeout for reply */ int timeout; /* timeout for reply */
void* callback; /* callback address */
VARARG(data,bytes); /* message data for sent messages */ VARARG(data,bytes); /* message data for sent messages */
@END @END
...@@ -1583,6 +1584,7 @@ enum message_type ...@@ -1583,6 +1584,7 @@ enum message_type
MSG_UNICODE, /* Unicode message (from SendMessageW) */ MSG_UNICODE, /* Unicode message (from SendMessageW) */
MSG_NOTIFY, /* notify message (from SendNotifyMessageW), always Unicode */ MSG_NOTIFY, /* notify message (from SendNotifyMessageW), always Unicode */
MSG_CALLBACK, /* callback message (from SendMessageCallbackW), always Unicode */ MSG_CALLBACK, /* callback message (from SendMessageCallbackW), always Unicode */
MSG_CALLBACK_RESULT,/* result of a callback message */
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 /* hardware message */ MSG_HARDWARE /* hardware message */
...@@ -1600,12 +1602,12 @@ enum message_type ...@@ -1600,12 +1602,12 @@ enum message_type
int type; /* message type */ int type; /* message type */
user_handle_t win; /* window handle */ user_handle_t win; /* window handle */
unsigned int msg; /* message code */ unsigned int msg; /* message code */
unsigned int wparam; /* parameters */ unsigned int wparam; /* parameters (callback function for MSG_CALLBACK_RESULT) */
unsigned int lparam; /* parameters */ unsigned int lparam; /* parameters (result for MSG_CALLBACK_RESULT) */
int x; /* x position */ int x; /* x position */
int y; /* y position */ int y; /* y position */
unsigned int time; /* message time */ unsigned int time; /* message time */
unsigned int info; /* extra info */ unsigned int info; /* extra info (callback argument for MSG_CALLBACK_RESULT) */
size_t total; /* total size of extra data */ size_t total; /* total size of extra data */
VARARG(data,bytes); /* message data for sent messages */ VARARG(data,bytes); /* message data for sent messages */
@END @END
......
...@@ -1844,6 +1844,7 @@ static void dump_send_message_request( const struct send_message_request *req ) ...@@ -1844,6 +1844,7 @@ static void dump_send_message_request( const struct send_message_request *req )
fprintf( stderr, " time=%08x,", req->time ); fprintf( stderr, " time=%08x,", req->time );
fprintf( stderr, " info=%08x,", req->info ); fprintf( stderr, " info=%08x,", req->info );
fprintf( stderr, " timeout=%d,", req->timeout ); fprintf( stderr, " timeout=%d,", req->timeout );
fprintf( stderr, " callback=%p,", req->callback );
fprintf( stderr, " data=" ); fprintf( stderr, " data=" );
dump_varargs_bytes( cur_size ); dump_varargs_bytes( cur_size );
} }
......
...@@ -112,17 +112,19 @@ static void queue_hardware_message( UINT message, HWND hwnd, WPARAM wParam, LPAR ...@@ -112,17 +112,19 @@ static void queue_hardware_message( UINT message, HWND hwnd, WPARAM wParam, LPAR
{ {
SERVER_START_REQ( send_message ) SERVER_START_REQ( send_message )
{ {
req->id = GetCurrentThreadId(); req->id = GetCurrentThreadId();
req->type = MSG_HARDWARE; req->type = MSG_HARDWARE;
req->win = hwnd; req->flags = 0;
req->msg = message; req->win = hwnd;
req->wparam = wParam; req->msg = message;
req->lparam = lParam; req->wparam = wParam;
req->x = xPos; req->lparam = lParam;
req->y = yPos; req->x = xPos;
req->time = time; req->y = yPos;
req->info = extraInfo; req->time = time;
req->timeout = 0; req->info = extraInfo;
req->timeout = -1;
req->callback = NULL;
wine_server_call( req ); wine_server_call( req );
} }
SERVER_END_REQ; SERVER_END_REQ;
......
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