user32: Implement GetCurrentInputMessageSource().
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
771123afb6
commit
4da1c4370b
|
@ -280,6 +280,8 @@ struct send_message_info
|
|||
enum wm_char_mapping wm_char;
|
||||
};
|
||||
|
||||
static const INPUT_MESSAGE_SOURCE msg_source_unavailable = { IMDT_UNAVAILABLE, IMO_UNAVAILABLE };
|
||||
|
||||
|
||||
/* Message class descriptor */
|
||||
static const WCHAR messageW[] = {'M','e','s','s','a','g','e',0};
|
||||
|
@ -2701,6 +2703,9 @@ static BOOL process_hardware_message( MSG *msg, UINT hw_id, const struct hardwar
|
|||
DPI_AWARENESS_CONTEXT context;
|
||||
BOOL ret = FALSE;
|
||||
|
||||
get_user_thread_info()->msg_source.deviceType = msg_data->source.device;
|
||||
get_user_thread_info()->msg_source.originId = msg_data->source.origin;
|
||||
|
||||
/* hardware messages are always in physical coords */
|
||||
context = SetThreadDpiAwarenessContext( DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE );
|
||||
|
||||
|
@ -2745,6 +2750,7 @@ static BOOL peek_message( MSG *msg, HWND hwnd, UINT first, UINT last, UINT flags
|
|||
{
|
||||
LRESULT result;
|
||||
struct user_thread_info *thread_info = get_user_thread_info();
|
||||
INPUT_MESSAGE_SOURCE prev_source = thread_info->msg_source;
|
||||
struct received_message_info info, *old_info;
|
||||
unsigned int hw_id = 0; /* id of previous hardware message */
|
||||
void *buffer;
|
||||
|
@ -2761,6 +2767,8 @@ static BOOL peek_message( MSG *msg, HWND hwnd, UINT first, UINT last, UINT flags
|
|||
size_t size = 0;
|
||||
const message_data_t *msg_data = buffer;
|
||||
|
||||
thread_info->msg_source = prev_source;
|
||||
|
||||
SERVER_START_REQ( get_message )
|
||||
{
|
||||
req->flags = flags;
|
||||
|
@ -2952,6 +2960,7 @@ static BOOL peek_message( MSG *msg, HWND hwnd, UINT first, UINT last, UINT flags
|
|||
thread_info->GetMessagePosVal = MAKELONG( msg->pt.x, msg->pt.y );
|
||||
thread_info->GetMessageTimeVal = info.msg.time;
|
||||
thread_info->GetMessageExtraInfoVal = 0;
|
||||
thread_info->msg_source = msg_source_unavailable;
|
||||
HeapFree( GetProcessHeap(), 0, buffer );
|
||||
HOOK_CallHooks( WH_GETMESSAGE, HC_ACTION, flags & PM_REMOVE, (LPARAM)msg, TRUE );
|
||||
return TRUE;
|
||||
|
@ -2960,6 +2969,7 @@ static BOOL peek_message( MSG *msg, HWND hwnd, UINT first, UINT last, UINT flags
|
|||
/* if we get here, we have a sent message; call the window procedure */
|
||||
old_info = thread_info->receive_info;
|
||||
thread_info->receive_info = &info;
|
||||
thread_info->msg_source = msg_source_unavailable;
|
||||
result = call_window_proc( info.msg.hwnd, info.msg.message, info.msg.wParam,
|
||||
info.msg.lParam, (info.type != MSG_ASCII), FALSE,
|
||||
WMCHAR_MAP_RECVMESSAGE );
|
||||
|
@ -3252,6 +3262,8 @@ static BOOL is_message_broadcastable(UINT msg)
|
|||
*/
|
||||
static BOOL send_message( struct send_message_info *info, DWORD_PTR *res_ptr, BOOL unicode )
|
||||
{
|
||||
struct user_thread_info *thread_info = get_user_thread_info();
|
||||
INPUT_MESSAGE_SOURCE prev_source = thread_info->msg_source;
|
||||
DWORD dest_pid;
|
||||
BOOL ret;
|
||||
LRESULT result;
|
||||
|
@ -3268,6 +3280,7 @@ static BOOL send_message( struct send_message_info *info, DWORD_PTR *res_ptr, BO
|
|||
|
||||
if (USER_IsExitingThread( info->dest_tid )) return FALSE;
|
||||
|
||||
thread_info->msg_source = msg_source_unavailable;
|
||||
SPY_EnterMessage( SPY_SENDMESSAGE, info->hwnd, info->msg, info->wparam, info->lparam );
|
||||
|
||||
if (info->dest_tid == GetCurrentThreadId())
|
||||
|
@ -3293,6 +3306,7 @@ static BOOL send_message( struct send_message_info *info, DWORD_PTR *res_ptr, BO
|
|||
}
|
||||
|
||||
SPY_ExitMessage( SPY_RESULT_OK, info->hwnd, info->msg, result, info->wparam, info->lparam );
|
||||
thread_info->msg_source = prev_source;
|
||||
if (ret && res_ptr) *res_ptr = result;
|
||||
return ret;
|
||||
}
|
||||
|
@ -4136,8 +4150,8 @@ LPARAM WINAPI SetMessageExtraInfo(LPARAM lParam)
|
|||
*/
|
||||
BOOL WINAPI GetCurrentInputMessageSource( INPUT_MESSAGE_SOURCE *source )
|
||||
{
|
||||
FIXME( "stub\n" );
|
||||
return FALSE;
|
||||
*source = get_user_thread_info()->msg_source;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -169,21 +169,22 @@ struct wm_char_mapping_data
|
|||
/* no attempt is made to keep the layout compatible with the Windows one */
|
||||
struct user_thread_info
|
||||
{
|
||||
DPI_AWARENESS dpi_awareness; /* DPI awareness */
|
||||
HANDLE server_queue; /* Handle to server-side queue */
|
||||
DWORD wake_mask; /* Current queue wake mask */
|
||||
DWORD changed_mask; /* Current queue changed mask */
|
||||
WORD recursion_count; /* SendMessage recursion counter */
|
||||
WORD message_count; /* Get/PeekMessage loop counter */
|
||||
WORD hook_call_depth; /* Number of recursively called hook procs */
|
||||
BOOL hook_unicode; /* Is current hook unicode? */
|
||||
WORD hook_unicode; /* Is current hook unicode? */
|
||||
HHOOK hook; /* Current hook */
|
||||
UINT active_hooks; /* Bitmap of active hooks */
|
||||
DPI_AWARENESS dpi_awareness; /* DPI awareness */
|
||||
INPUT_MESSAGE_SOURCE msg_source; /* Message source for current message */
|
||||
struct received_message_info *receive_info; /* Message being currently received */
|
||||
struct wm_char_mapping_data *wmchar_data; /* Data for WM_CHAR mappings */
|
||||
DWORD GetMessageTimeVal; /* Value for GetMessageTime */
|
||||
DWORD GetMessagePosVal; /* Value for GetMessagePos */
|
||||
ULONG_PTR GetMessageExtraInfoVal; /* Value for GetMessageExtraInfo */
|
||||
UINT active_hooks; /* Bitmap of active hooks */
|
||||
struct user_key_state_info *key_state; /* Cache of global key state */
|
||||
HWND top_window; /* Desktop window */
|
||||
HWND msg_window; /* HWND_MESSAGE parent window */
|
||||
|
|
|
@ -264,11 +264,18 @@ typedef struct
|
|||
|
||||
|
||||
|
||||
struct hw_msg_source
|
||||
{
|
||||
unsigned int device;
|
||||
unsigned int origin;
|
||||
};
|
||||
|
||||
struct hardware_msg_data
|
||||
{
|
||||
lparam_t info;
|
||||
unsigned int hw_id;
|
||||
unsigned int flags;
|
||||
lparam_t info;
|
||||
unsigned int hw_id;
|
||||
unsigned int flags;
|
||||
struct hw_msg_source source;
|
||||
union
|
||||
{
|
||||
int type;
|
||||
|
@ -6546,6 +6553,6 @@ union generic_reply
|
|||
struct terminate_job_reply terminate_job_reply;
|
||||
};
|
||||
|
||||
#define SERVER_PROTOCOL_VERSION 570
|
||||
#define SERVER_PROTOCOL_VERSION 571
|
||||
|
||||
#endif /* __WINE_WINE_SERVER_PROTOCOL_H */
|
||||
|
|
|
@ -280,11 +280,18 @@ typedef struct
|
|||
|
||||
/* structures for extra message data */
|
||||
|
||||
struct hw_msg_source
|
||||
{
|
||||
unsigned int device; /* source device (IMDT_* values) */
|
||||
unsigned int origin; /* source origin (IMO_* values) */
|
||||
};
|
||||
|
||||
struct hardware_msg_data
|
||||
{
|
||||
lparam_t info; /* extra info */
|
||||
unsigned int hw_id; /* unique id */
|
||||
unsigned int flags; /* hook flags */
|
||||
lparam_t info; /* extra info */
|
||||
unsigned int hw_id; /* unique id */
|
||||
unsigned int flags; /* hook flags */
|
||||
struct hw_msg_source source; /* message source */
|
||||
union
|
||||
{
|
||||
int type;
|
||||
|
|
|
@ -340,7 +340,8 @@ static int assign_thread_input( struct thread *thread, struct thread_input *new_
|
|||
}
|
||||
|
||||
/* allocate a hardware message and its data */
|
||||
static struct message *alloc_hardware_message( lparam_t info, unsigned int time )
|
||||
static struct message *alloc_hardware_message( lparam_t info, struct hw_msg_source source,
|
||||
unsigned int time )
|
||||
{
|
||||
struct hardware_msg_data *msg_data;
|
||||
struct message *msg;
|
||||
|
@ -359,15 +360,17 @@ static struct message *alloc_hardware_message( lparam_t info, unsigned int time
|
|||
|
||||
memset( msg_data, 0, sizeof(*msg_data) );
|
||||
msg_data->info = info;
|
||||
msg_data->source = source;
|
||||
return msg;
|
||||
}
|
||||
|
||||
/* set the cursor position and queue the corresponding mouse message */
|
||||
static void set_cursor_pos( struct desktop *desktop, int x, int y )
|
||||
{
|
||||
static const struct hw_msg_source source = { IMDT_UNAVAILABLE, IMO_SYSTEM };
|
||||
struct message *msg;
|
||||
|
||||
if (!(msg = alloc_hardware_message( 0, get_tick_count() ))) return;
|
||||
if (!(msg = alloc_hardware_message( 0, source, get_tick_count() ))) return;
|
||||
|
||||
msg->msg = WM_MOUSEMOVE;
|
||||
msg->x = x;
|
||||
|
@ -1593,12 +1596,13 @@ static int send_hook_ll_message( struct desktop *desktop, struct message *hardwa
|
|||
|
||||
/* queue a hardware message for a mouse event */
|
||||
static int queue_mouse_message( struct desktop *desktop, user_handle_t win, const hw_input_t *input,
|
||||
unsigned int hook_flags, struct msg_queue *sender )
|
||||
unsigned int origin, struct msg_queue *sender )
|
||||
{
|
||||
const struct rawinput_device *device;
|
||||
struct hardware_msg_data *msg_data;
|
||||
struct message *msg;
|
||||
unsigned int i, time, flags;
|
||||
struct hw_msg_source source = { IMDT_MOUSE, origin };
|
||||
int wait = 0, x, y;
|
||||
|
||||
static const unsigned int messages[] =
|
||||
|
@ -1647,7 +1651,7 @@ static int queue_mouse_message( struct desktop *desktop, user_handle_t win, cons
|
|||
|
||||
if ((device = current->process->rawinput_mouse))
|
||||
{
|
||||
if (!(msg = alloc_hardware_message( input->mouse.info, time ))) return 0;
|
||||
if (!(msg = alloc_hardware_message( input->mouse.info, source, time ))) return 0;
|
||||
msg_data = msg->data;
|
||||
|
||||
msg->win = device->target;
|
||||
|
@ -1670,7 +1674,7 @@ static int queue_mouse_message( struct desktop *desktop, user_handle_t win, cons
|
|||
if (!(flags & (1 << i))) continue;
|
||||
flags &= ~(1 << i);
|
||||
|
||||
if (!(msg = alloc_hardware_message( input->mouse.info, time ))) return 0;
|
||||
if (!(msg = alloc_hardware_message( input->mouse.info, source, time ))) return 0;
|
||||
msg_data = msg->data;
|
||||
|
||||
msg->win = get_user_full_handle( win );
|
||||
|
@ -1679,7 +1683,7 @@ static int queue_mouse_message( struct desktop *desktop, user_handle_t win, cons
|
|||
msg->lparam = 0;
|
||||
msg->x = x;
|
||||
msg->y = y;
|
||||
if (hook_flags & SEND_HWMSG_INJECTED) msg_data->flags = LLMHF_INJECTED;
|
||||
if (origin == IMO_INJECTED) msg_data->flags = LLMHF_INJECTED;
|
||||
|
||||
/* specify a sender only when sending the last message */
|
||||
if (!(flags & ((1 << ARRAY_SIZE( messages )) - 1)))
|
||||
|
@ -1695,8 +1699,9 @@ static int queue_mouse_message( struct desktop *desktop, user_handle_t win, cons
|
|||
|
||||
/* queue a hardware message for a keyboard event */
|
||||
static int queue_keyboard_message( struct desktop *desktop, user_handle_t win, const hw_input_t *input,
|
||||
unsigned int hook_flags, struct msg_queue *sender )
|
||||
unsigned int origin, struct msg_queue *sender )
|
||||
{
|
||||
struct hw_msg_source source = { IMDT_KEYBOARD, origin };
|
||||
const struct rawinput_device *device;
|
||||
struct hardware_msg_data *msg_data;
|
||||
struct message *msg;
|
||||
|
@ -1770,7 +1775,7 @@ static int queue_keyboard_message( struct desktop *desktop, user_handle_t win, c
|
|||
break;
|
||||
}
|
||||
|
||||
if (!(msg = alloc_hardware_message( input->kbd.info, time ))) return 0;
|
||||
if (!(msg = alloc_hardware_message( input->kbd.info, source, time ))) return 0;
|
||||
msg_data = msg->data;
|
||||
|
||||
if ((device = current->process->rawinput_kbd))
|
||||
|
@ -1791,7 +1796,7 @@ static int queue_keyboard_message( struct desktop *desktop, user_handle_t win, c
|
|||
msg->win = get_user_full_handle( win );
|
||||
msg->msg = message_code;
|
||||
msg->lparam = (input->kbd.scan << 16) | 1u; /* repeat count */
|
||||
if (hook_flags & SEND_HWMSG_INJECTED) msg_data->flags = LLKHF_INJECTED;
|
||||
if (origin == IMO_INJECTED) msg_data->flags = LLKHF_INJECTED;
|
||||
|
||||
if (input->kbd.flags & KEYEVENTF_UNICODE)
|
||||
{
|
||||
|
@ -1818,11 +1823,12 @@ static int queue_keyboard_message( struct desktop *desktop, user_handle_t win, c
|
|||
|
||||
/* queue a hardware message for a custom type of event */
|
||||
static void queue_custom_hardware_message( struct desktop *desktop, user_handle_t win,
|
||||
const hw_input_t *input )
|
||||
unsigned int origin, const hw_input_t *input )
|
||||
{
|
||||
struct hw_msg_source source = { IMDT_UNAVAILABLE, origin };
|
||||
struct message *msg;
|
||||
|
||||
if (!(msg = alloc_hardware_message( 0, get_tick_count() ))) return;
|
||||
if (!(msg = alloc_hardware_message( 0, source, get_tick_count() ))) return;
|
||||
|
||||
msg->win = get_user_full_handle( win );
|
||||
msg->msg = input->hw.msg;
|
||||
|
@ -2317,6 +2323,7 @@ DECL_HANDLER(send_hardware_message)
|
|||
{
|
||||
struct thread *thread = NULL;
|
||||
struct desktop *desktop;
|
||||
unsigned int origin = (req->flags & SEND_HWMSG_INJECTED ? IMO_INJECTED : IMO_HARDWARE);
|
||||
struct msg_queue *sender = get_current_queue();
|
||||
data_size_t size = min( 256, get_reply_max_size() );
|
||||
|
||||
|
@ -2339,13 +2346,13 @@ DECL_HANDLER(send_hardware_message)
|
|||
switch (req->input.type)
|
||||
{
|
||||
case INPUT_MOUSE:
|
||||
reply->wait = queue_mouse_message( desktop, req->win, &req->input, req->flags, sender );
|
||||
reply->wait = queue_mouse_message( desktop, req->win, &req->input, origin, sender );
|
||||
break;
|
||||
case INPUT_KEYBOARD:
|
||||
reply->wait = queue_keyboard_message( desktop, req->win, &req->input, req->flags, sender );
|
||||
reply->wait = queue_keyboard_message( desktop, req->win, &req->input, origin, sender );
|
||||
break;
|
||||
case INPUT_HARDWARE:
|
||||
queue_custom_hardware_message( desktop, req->win, &req->input );
|
||||
queue_custom_hardware_message( desktop, req->win, origin, &req->input );
|
||||
break;
|
||||
default:
|
||||
set_error( STATUS_INVALID_PARAMETER );
|
||||
|
|
Loading…
Reference in New Issue