server: Implement WM_INPUT_DEVICE_CHANGE message dispatch.

Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=50506
Signed-off-by: Rémi Bernon <rbernon@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Rémi Bernon 2021-05-11 10:17:21 +02:00 committed by Alexandre Julliard
parent 3481dc05e9
commit 4e956dc0fe
2 changed files with 40 additions and 9 deletions

View File

@ -2289,11 +2289,14 @@ static void accept_hardware_message( UINT hw_id )
static BOOL process_rawinput_message( MSG *msg, UINT hw_id, const struct hardware_msg_data *msg_data )
{
struct rawinput_thread_data *thread_data = rawinput_thread_data();
if (!rawinput_from_hardware_message( thread_data->buffer, msg_data ))
return FALSE;
thread_data->hw_id = hw_id;
msg->lParam = (LPARAM)hw_id;
if (msg->message == WM_INPUT)
{
if (!rawinput_from_hardware_message( thread_data->buffer, msg_data )) return FALSE;
thread_data->hw_id = hw_id;
msg->lParam = (LPARAM)hw_id;
}
msg->pt = point_phys_to_win_dpi( msg->hwnd, msg->pt );
return TRUE;
}
@ -2613,7 +2616,7 @@ static BOOL process_hardware_message( MSG *msg, UINT hw_id, const struct hardwar
/* hardware messages are always in physical coords */
context = SetThreadDpiAwarenessContext( DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE );
if (msg->message == WM_INPUT)
if (msg->message == WM_INPUT || msg->message == WM_INPUT_DEVICE_CHANGE)
ret = process_rawinput_message( msg, hw_id, msg_data );
else if (is_keyboard_message( msg->message ))
ret = process_keyboard_message( msg, hw_id, hwnd_filter, first, last, remove );

View File

@ -1464,7 +1464,7 @@ static user_handle_t find_hardware_message_window( struct desktop *desktop, stru
*thread = NULL;
*msg_code = msg->msg;
if (msg->msg == WM_INPUT)
if (msg->msg == WM_INPUT || msg->msg == WM_INPUT_DEVICE_CHANGE)
{
if (!(win = msg->win) && input) win = input->focus;
}
@ -1553,7 +1553,7 @@ static void queue_hardware_message( struct desktop *desktop, struct message *msg
if (msg->wparam == VK_SHIFT || msg->wparam == VK_LSHIFT || msg->wparam == VK_RSHIFT)
msg->lparam &= ~(KF_EXTENDED << 16);
}
else if (msg->msg != WM_INPUT)
else if (msg->msg != WM_INPUT && msg->msg != WM_INPUT_DEVICE_CHANGE)
{
if (msg->msg == WM_MOUSEMOVE)
{
@ -1695,7 +1695,7 @@ static int queue_rawinput_message( struct process* process, void *arg )
if (process != foreground->process)
{
if (!(device->flags & RIDEV_INPUTSINK)) goto done;
if (raw_msg->message == WM_INPUT && !(device->flags & RIDEV_INPUTSINK)) goto done;
if (!(target_thread = get_window_thread( device->target ))) goto done;
if (!(target_desktop = get_thread_desktop( target_thread, 0 ))) goto done;
if (target_desktop != desktop) goto done;
@ -1711,6 +1711,12 @@ static int queue_rawinput_message( struct process* process, void *arg )
msg->lparam = 0;
memcpy( msg->data, &raw_msg->data, sizeof(raw_msg->data) );
if (raw_msg->message == WM_INPUT_DEVICE_CHANGE && raw_msg->data.rawinput.type == RIM_TYPEHID)
{
msg->wparam = raw_msg->data.rawinput.hid.param;
msg->lparam = raw_msg->data.rawinput.hid.device;
}
queue_hardware_message( desktop, msg, 1 );
done:
@ -1975,8 +1981,30 @@ static void queue_custom_hardware_message( struct desktop *desktop, user_handle_
unsigned int origin, const hw_input_t *input )
{
struct hw_msg_source source = { IMDT_UNAVAILABLE, origin };
struct hardware_msg_data *msg_data;
struct rawinput_message raw_msg;
struct message *msg;
switch (input->hw.msg)
{
case WM_INPUT_DEVICE_CHANGE:
raw_msg.foreground = NULL;
raw_msg.desktop = NULL;
raw_msg.source = source;
raw_msg.time = get_tick_count();
raw_msg.message = input->hw.msg;
msg_data = &raw_msg.data;
msg_data->info = 0;
msg_data->flags = 0;
msg_data->rawinput = input->hw.rawinput;
enum_processes( queue_rawinput_message, &raw_msg );
if (raw_msg.foreground) release_object( raw_msg.foreground );
return;
}
if (!(msg = alloc_hardware_message( 0, source, get_tick_count() ))) return;
msg->win = get_user_full_handle( win );
@ -2109,7 +2137,7 @@ static int get_hardware_message( struct thread *thread, unsigned int hw_id, user
data->hw_id = msg->unique_id;
set_reply_data( msg->data, msg->data_size );
if (msg->msg == WM_INPUT && (flags & PM_REMOVE))
if ((msg->msg == WM_INPUT || msg->msg == WM_INPUT_DEVICE_CHANGE) && (flags & PM_REMOVE))
release_hardware_message( current->queue, data->hw_id );
return 1;
}