[PATCH 4/9] user32: Add support for RIDEV_INPUTSINK flag in RegisterRawInputDevices.

Rémi Bernon rbernon at codeweavers.com
Wed Sep 25 04:35:40 CDT 2019


This flag allows applications to receive rawinput messages while in
background. They have to specify a target hwnd in which queue to receive
them and the messages will carry a RIM_INPUTSINK wparam in this case.

Signed-off-by: Rémi Bernon <rbernon at codeweavers.com>
---
 dlls/user32/rawinput.c       | 9 ++++++++-
 dlls/user32/tests/rawinput.c | 2 --
 server/queue.c               | 8 ++++++--
 3 files changed, 14 insertions(+), 5 deletions(-)

diff --git a/dlls/user32/rawinput.c b/dlls/user32/rawinput.c
index 94cf7a9a5d2..182ee1e9eb7 100644
--- a/dlls/user32/rawinput.c
+++ b/dlls/user32/rawinput.c
@@ -267,6 +267,13 @@ BOOL WINAPI DECLSPEC_HOTPATCH RegisterRawInputDevices(RAWINPUTDEVICE *devices, U
 
     for (i = 0; i < device_count; ++i)
     {
+        if ((devices[i].dwFlags & RIDEV_INPUTSINK) &&
+            (devices[i].hwndTarget == NULL))
+        {
+            SetLastError(ERROR_INVALID_PARAMETER);
+            return FALSE;
+        }
+
         if ((devices[i].dwFlags & RIDEV_REMOVE) &&
             (devices[i].hwndTarget != NULL))
         {
@@ -282,7 +289,7 @@ BOOL WINAPI DECLSPEC_HOTPATCH RegisterRawInputDevices(RAWINPUTDEVICE *devices, U
         TRACE("device %u: page %#x, usage %#x, flags %#x, target %p.\n",
                 i, devices[i].usUsagePage, devices[i].usUsage,
                 devices[i].dwFlags, devices[i].hwndTarget);
-        if (devices[i].dwFlags & ~RIDEV_REMOVE)
+        if (devices[i].dwFlags & ~(RIDEV_REMOVE|RIDEV_INPUTSINK))
             FIXME("Unhandled flags %#x for device %u.\n", devices[i].dwFlags, i);
 
         d[i].usage_page = devices[i].usUsagePage;
diff --git a/dlls/user32/tests/rawinput.c b/dlls/user32/tests/rawinput.c
index f4c8eb6738b..3e459a53940 100644
--- a/dlls/user32/tests/rawinput.c
+++ b/dlls/user32/tests/rawinput.c
@@ -80,9 +80,7 @@ static void test_RegisterRawInputDevices(void)
 
     SetLastError(0xdeadbeef);
     res = RegisterRawInputDevices(raw_devices, ARRAY_SIZE(raw_devices), sizeof(RAWINPUTDEVICE));
-    todo_wine
     ok(res == FALSE, "RegisterRawInputDevices failed\n");
-    todo_wine
     ok(GetLastError() == ERROR_INVALID_PARAMETER, "RegisterRawInputDevices returned %08x\n", GetLastError());
 
     raw_devices[0].hwndTarget = hwnd;
diff --git a/server/queue.c b/server/queue.c
index d883811449e..5b557caa93b 100644
--- a/server/queue.c
+++ b/server/queue.c
@@ -1611,6 +1611,7 @@ static int queue_rawinput_message( struct process* process, void* user )
     struct desktop *desktop = NULL;
     struct thread *thread = NULL;
     struct message *msg;
+    int wparam = RIM_INPUT;
 
     if (raw_msg->data.rawinput.type == RIM_TYPEMOUSE)
         device = process->rawinput_mouse;
@@ -1629,14 +1630,17 @@ static int queue_rawinput_message( struct process* process, void* user )
         goto done;
 
     if (thread->queue->input != desktop->foreground_input)
-        goto done;
+    {
+        if (!(device->flags & RIDEV_INPUTSINK)) goto done;
+        wparam = RIM_INPUTSINK;
+    }
 
     if (!(msg = alloc_hardware_message( raw_msg->data.info, raw_msg->source, raw_msg->time )))
         goto done;
 
     msg->win    = device->target;
     msg->msg    = WM_INPUT;
-    msg->wparam = RIM_INPUT;
+    msg->wparam = wparam;
     msg->lparam = 0;
     memcpy( msg->data, &raw_msg->data, sizeof(raw_msg->data) );
 
-- 
2.23.0




More information about the wine-devel mailing list