From eee5ecbed5c813be03d4b540675f1c4792101567 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Bernon?= Date: Mon, 11 Nov 2019 18:35:18 +0100 Subject: [PATCH] server: Make it possible to queue rawinput message on all desktops. --- server/queue.c | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/server/queue.c b/server/queue.c index f5d19031485..59c6cbb6921 100644 --- a/server/queue.c +++ b/server/queue.c @@ -1658,8 +1658,8 @@ static int queue_rawinput_message( struct process* process, void *arg ) { const struct rawinput_message* raw_msg = arg; 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; @@ -1670,12 +1670,18 @@ static int queue_rawinput_message( struct process* process, void *arg ) device = process->rawinput_kbd; 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; } @@ -1692,11 +1698,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; } -- 2.27.0