<div dir="ltr">v8 of this patch incorporates Remi's recommendations to use the hw_rawinput_t union for hardware_msg_data and send the rawinput messages to the relevant thread only.</div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Fri, Jul 26, 2019 at 3:30 PM Derek Lesho <<a href="mailto:dereklesho52@gmail.com">dereklesho52@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Signed-off-by: Derek Lesho <dereklesho52@Gmail.com><br>
---<br>
 server/protocol.def | 52 ++++++++++++++++++++++++++++-----------------<br>
 server/queue.c      | 52 +++++++++++++++++++++++++++++++++++++++++++++<br>
 server/trace.c      | 21 ++++++++++++++++++<br>
 tools/make_requests |  1 +<br>
 4 files changed, 107 insertions(+), 19 deletions(-)<br>
<br>
diff --git a/server/protocol.def b/server/protocol.def<br>
index 8b8a8a1512..b5368c71f6 100644<br>
--- a/server/protocol.def<br>
+++ b/server/protocol.def<br>
@@ -286,31 +286,40 @@ struct hw_msg_source<br>
     unsigned int    origin;        /* source origin (IMO_* values) */<br>
 };<br>
<br>
+typedef union<br>
+{<br>
+    int type;<br>
+    struct<br>
+    {<br>
+        int            type;    /* RIM_TYPEKEYBOARD */<br>
+        unsigned int   message; /* message generated by this rawinput event */<br>
+        unsigned short vkey;    /* virtual key code */<br>
+        unsigned short scan;    /* scan code */<br>
+    } kbd;<br>
+    struct<br>
+    {<br>
+        int            type;            /* RIM_TYPEMOUSE */<br>
+        int            x;               /* x coordinate */<br>
+        int            y;               /* y coordinate */<br>
+        unsigned short button_flags;    /* mouse button */<br>
+        unsigned short button_data;     /* event details */<br>
+    } mouse;<br>
+    struct<br>
+    {<br>
+        int type; /* RIM_TYPEHID */<br>
+        /* TODO: fill this in if/when necessary */<br>
+    } hid;<br>
+} hw_rawinput_t;<br>
+#define RIM_ENABLE_NATIVE_MOUSE_MOVE   0x0800<br>
+#define RIM_ENABLE_NATIVE_MOUSE_PRESS  0x1000<br>
+<br>
 struct hardware_msg_data<br>
 {<br>
     lparam_t             info;      /* extra info */<br>
     unsigned int         hw_id;     /* unique id */<br>
     unsigned int         flags;     /* hook flags */<br>
     struct hw_msg_source source;    /* message source */<br>
-    union<br>
-    {<br>
-        int type;<br>
-        struct<br>
-        {<br>
-            int            type;    /* RIM_TYPEKEYBOARD */<br>
-            unsigned int   message; /* message generated by this rawinput event */<br>
-            unsigned short vkey;    /* virtual key code */<br>
-            unsigned short scan;    /* scan code */<br>
-        } kbd;<br>
-        struct<br>
-        {<br>
-            int            type;            /* RIM_TYPEMOUSE */<br>
-            int            x;               /* x coordinate */<br>
-            int            y;               /* y coordinate */<br>
-            unsigned short button_flags;    /* mouse button */<br>
-            unsigned short button_data;     /* event details */<br>
-        } mouse;<br>
-    } rawinput;<br>
+    hw_rawinput_t        rawinput;<br>
 };<br>
<br>
 struct callback_msg_data<br>
@@ -2294,6 +2303,11 @@ enum message_type<br>
 #define SEND_HWMSG_INJECTED    0x01<br>
<br>
<br>
+@REQ(send_rawinput_message)<br>
+    hw_rawinput_t input;<br>
+@END<br>
+<br>
+<br>
 /* Get a message from the current queue */<br>
 @REQ(get_message)<br>
     unsigned int    flags;     /* PM_* flags */<br>
diff --git a/server/queue.c b/server/queue.c<br>
index d12db927b9..03e64341c1 100644<br>
--- a/server/queue.c<br>
+++ b/server/queue.c<br>
@@ -2421,6 +2421,58 @@ DECL_HANDLER(send_hardware_message)<br>
     release_object( desktop );<br>
 }<br>
<br>
+/* send a hardware rawinput message to the queue thread */<br>
+DECL_HANDLER(send_rawinput_message)<br>
+{<br>
+    const struct rawinput_device *device;<br>
+    struct hardware_msg_data *msg_data;<br>
+    struct message *msg;<br>
+    struct desktop *desktop;<br>
+    struct hw_msg_source source = { IMDT_MOUSE, IMO_HARDWARE };<br>
+<br>
+    desktop = get_thread_desktop( current, 0 );<br>
+<br>
+    switch (req->input.type)<br>
+    {<br>
+    case RIM_TYPEMOUSE:<br>
+        if ((device = current->process->rawinput_mouse))<br>
+        {<br>
+            struct thread *thread = device->target ? get_window_thread( device->target ) : NULL;<br>
+            if (device->target ? (thread != current) : (current->queue->input != desktop->foreground_input))<br>
+            {<br>
+                if ( thread )<br>
+                    release_object( thread );<br>
+                release_object( desktop );<br>
+                return;<br>
+            }<br>
+            if (thread)<br>
+                release_object( thread );<br>
+<br>
+            if (!(msg = alloc_hardware_message( 0, source, 0 ))) return;<br>
+            msg_data = msg->data;<br>
+<br>
+            msg->win       = device->target;<br>
+            msg->msg       = WM_INPUT;<br>
+            msg->wparam    = RIM_INPUT;<br>
+            msg->lparam    = 0;<br>
+<br>
+            msg_data->flags               = 0;<br>
+            msg_data->rawinput.type       = RIM_TYPEMOUSE;<br>
+            msg_data->rawinput.mouse.x    = req->input.mouse.x;<br>
+            msg_data->rawinput.mouse.y    = req->input.mouse.y;<br>
+            msg_data->rawinput.mouse.button_flags = req->input.mouse.button_flags;<br>
+            msg_data->rawinput.mouse.button_data = req->input.mouse.button_data;<br>
+<br>
+            queue_hardware_message( desktop, msg, 0 );<br>
+        }<br>
+        break;<br>
+    default:<br>
+        set_error( STATUS_INVALID_PARAMETER );<br>
+    }<br>
+<br>
+    release_object(desktop);<br>
+}<br>
+<br>
 /* post a quit message to the current queue */<br>
 DECL_HANDLER(post_quit_message)<br>
 {<br>
diff --git a/server/trace.c b/server/trace.c<br>
index 3562823659..bccab449cf 100644<br>
--- a/server/trace.c<br>
+++ b/server/trace.c<br>
@@ -390,6 +390,27 @@ static void dump_hw_input( const char *prefix, const hw_input_t *input )<br>
     }<br>
 }<br>
<br>
+static void dump_hw_rawinput( const char *prefix, const hw_rawinput_t *rawinput )<br>
+{<br>
+    switch (rawinput->type)<br>
+    {<br>
+    case RIM_TYPEMOUSE:<br>
+        fprintf( stderr, "%s{type=MOUSE,x=%d,y=%d,button_flags=%04hx,button_data=%04hx}",<br>
+                 prefix, rawinput->mouse.x, rawinput->mouse.y, rawinput->mouse.button_flags,<br>
+                 rawinput->mouse.button_data);<br>
+        break;<br>
+    case RIM_TYPEKEYBOARD:<br>
+        fprintf( stderr, "%s{type=KEYBOARD}\n", prefix);<br>
+        break;<br>
+    case RIM_TYPEHID:<br>
+        fprintf( stderr, "%s{type=HID}\n", prefix);<br>
+        break;<br>
+    default:<br>
+        fprintf( stderr, "%s{type=%04x}", prefix, rawinput->type);<br>
+        break;<br>
+    }<br>
+}<br>
+<br>
 static void dump_luid( const char *prefix, const luid_t *luid )<br>
 {<br>
     fprintf( stderr, "%s%d.%u", prefix, luid->high_part, luid->low_part );<br>
diff --git a/tools/make_requests b/tools/make_requests<br>
index 367f245653..cf631923a7 100755<br>
--- a/tools/make_requests<br>
+++ b/tools/make_requests<br>
@@ -53,6 +53,7 @@ my %formats =<br>
     "ioctl_code_t"  => [  4,   4,  "&dump_ioctl_code" ],<br>
     "cpu_type_t"    => [  4,   4,  "&dump_cpu_type" ],<br>
     "hw_input_t"    => [  32,  8,  "&dump_hw_input" ],<br>
+    "hw_rawinput_t" => [  16,  8,  "&dump_hw_rawinput" ]<br>
 );<br>
<br>
 my @requests = ();<br>
-- <br>
2.22.0<br>
<br>
</blockquote></div>