HID rawinput messages are sent from winedevice.exe, which is not attached to any desktop. We need to broadcast the messages to all desktops in that case.
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=50506 Signed-off-by: Rémi Bernon rbernon@codeweavers.com --- server/queue.c | 44 ++++++++++++++++++++++++++++++-------------- 1 file changed, 30 insertions(+), 14 deletions(-)
diff --git a/server/queue.c b/server/queue.c index ed11c69e879..d1561ec81e8 100644 --- a/server/queue.c +++ b/server/queue.c @@ -1675,8 +1675,8 @@ static int queue_rawinput_message( struct process* process, void *arg ) const struct rawinput_message* raw_msg = arg; const struct rawinput_device_entry *entry; const struct rawinput_device *device = NULL; - struct desktop *target_desktop = NULL; - struct thread *target_thread = NULL; + struct desktop *target_desktop = NULL, *desktop = NULL; + struct thread *target_thread = NULL, *foreground = NULL; struct message *msg; struct hardware_msg_data *msg_data; int wparam = RIM_INPUT; @@ -1689,12 +1689,18 @@ static int queue_rawinput_message( struct process* process, void *arg ) device = &entry->device; if (!device) return 0;
- if (process != raw_msg->foreground->process) + if (raw_msg->desktop) desktop = (struct desktop *)grab_object( raw_msg->desktop ); + else if (!(desktop = get_desktop_obj( process, process->desktop, 0 ))) goto done; + + if (raw_msg->foreground) foreground = (struct thread *)grab_object( raw_msg->foreground ); + else if (!(foreground = get_foreground_thread( desktop, 0 ))) goto done; + + if (process != foreground->process) { if (!(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 != raw_msg->desktop) goto done; + if (target_desktop != desktop) goto done; wparam = RIM_INPUTSINK; }
@@ -1711,11 +1717,13 @@ static int queue_rawinput_message( struct process* process, void *arg ) if (raw_msg->extra_len && raw_msg->extra) memcpy( msg_data + 1, raw_msg->extra, raw_msg->extra_len );
- queue_hardware_message( raw_msg->desktop, msg, 1 ); + queue_hardware_message( desktop, msg, 1 );
done: if (target_thread) release_object( target_thread ); if (target_desktop) release_object( target_desktop ); + if (foreground) release_object( foreground ); + if (desktop) release_object( desktop ); return 0; }
@@ -2499,15 +2507,14 @@ DECL_HANDLER(send_message) DECL_HANDLER(send_hardware_message) { struct thread *thread = NULL; - struct desktop *desktop; + struct desktop *desktop = get_thread_desktop( current, 0 ); 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() );
- if (!(desktop = get_thread_desktop( current, 0 ))) return; - if (req->win) { + if (!desktop) return; if (!(thread = get_window_thread( req->win ))) return; if (desktop != thread->queue->input->desktop) { @@ -2517,18 +2524,24 @@ DECL_HANDLER(send_hardware_message) } }
- reply->prev_x = desktop->cursor.x; - reply->prev_y = desktop->cursor.y; + if (desktop) + { + reply->prev_x = desktop->cursor.x; + reply->prev_y = desktop->cursor.y; + }
switch (req->input.type) { case HW_INPUT_MOUSE: + if (!desktop) return; reply->wait = queue_mouse_message( desktop, req->win, &req->input, origin, sender ); break; case HW_INPUT_KEYBOARD: + if (!desktop) return; reply->wait = queue_keyboard_message( desktop, req->win, &req->input, origin, sender ); break; case HW_INPUT_HARDWARE: + if (!desktop) return; queue_custom_hardware_message( desktop, req->win, origin, &req->input ); break; case HW_INPUT_HID: @@ -2539,10 +2552,13 @@ DECL_HANDLER(send_hardware_message) } if (thread) release_object( thread );
- reply->new_x = desktop->cursor.x; - reply->new_y = desktop->cursor.y; - set_reply_data( desktop->keystate, size ); - release_object( desktop ); + if (desktop) + { + reply->new_x = desktop->cursor.x; + reply->new_y = desktop->cursor.y; + set_reply_data( desktop->keystate, size ); + release_object( desktop ); + } }
/* post a quit message to the current queue */