Only set the new window of a hardware message if the window belongs to
the same thread input, otherwise just drop the message.

diff --git a/server/queue.c b/server/queue.c
index bdce76a..ac7efca 100644
--- a/server/queue.c
+++ b/server/queue.c
@@ -1107,13 +1107,16 @@
         struct thread *owner = get_window_thread( new_win );
         if (owner)
         {
-            msg->win = new_win;
-            set_queue_bits( owner->queue, get_hardware_msg_bit( msg ));
+            if (owner->queue->input == input)
+            {
+                msg->win = new_win;
+                set_queue_bits( owner->queue, get_hardware_msg_bit( msg ));
+                remove = 0;
+            }
             release_object( owner );
         }
-        if (!remove) return;  /* don't release the message */
     }
-    else if (remove)
+    if (remove)
     {
         update_input_key_state( input, msg );
         list_remove( &msg->entry );