2021-05-21 23:30:39 -07:00
|
|
|
From 29097b205bc5d0861d14409988da04880626b879 Mon Sep 17 00:00:00 2001
|
2019-12-23 01:03:44 -08:00
|
|
|
From: =?UTF-8?q?R=C3=A9mi=20Bernon?= <rbernon@codeweavers.com>
|
|
|
|
Date: Thu, 19 Dec 2019 22:34:44 +0100
|
2020-04-07 16:15:39 -07:00
|
|
|
Subject: [PATCH] winex11.drv: Keep track of pointer and device button
|
2019-12-23 01:03:44 -08:00
|
|
|
mappings.
|
|
|
|
|
|
|
|
We are going to receive raw button events and we will need to apply the
|
|
|
|
correct button mappings ourselves.
|
|
|
|
|
|
|
|
Original patch by Andrew Eikum <aeikum@codeweavers.com>.
|
|
|
|
---
|
|
|
|
dlls/winex11.drv/keyboard.c | 23 ++++++---
|
|
|
|
dlls/winex11.drv/mouse.c | 89 +++++++++++++++++++++++++++++++++-
|
|
|
|
dlls/winex11.drv/x11drv.h | 1 +
|
|
|
|
dlls/winex11.drv/x11drv_main.c | 1 +
|
|
|
|
4 files changed, 106 insertions(+), 8 deletions(-)
|
|
|
|
|
|
|
|
diff --git a/dlls/winex11.drv/keyboard.c b/dlls/winex11.drv/keyboard.c
|
2021-05-21 23:30:39 -07:00
|
|
|
index d86f418a64e..f905794b23a 100644
|
2019-12-23 01:03:44 -08:00
|
|
|
--- a/dlls/winex11.drv/keyboard.c
|
|
|
|
+++ b/dlls/winex11.drv/keyboard.c
|
2021-05-21 23:30:39 -07:00
|
|
|
@@ -1882,13 +1882,24 @@ BOOL X11DRV_MappingNotify( HWND dummy, XEvent *event )
|
2019-12-23 01:03:44 -08:00
|
|
|
{
|
|
|
|
HWND hwnd;
|
|
|
|
|
|
|
|
- XRefreshKeyboardMapping(&event->xmapping);
|
|
|
|
- X11DRV_InitKeyboard( event->xmapping.display );
|
|
|
|
+ switch (event->xmapping.request)
|
|
|
|
+ {
|
|
|
|
+ case MappingModifier:
|
|
|
|
+ case MappingKeyboard:
|
|
|
|
+ XRefreshKeyboardMapping( &event->xmapping );
|
|
|
|
+ X11DRV_InitKeyboard( event->xmapping.display );
|
|
|
|
+
|
|
|
|
+ hwnd = GetFocus();
|
|
|
|
+ if (!hwnd) hwnd = GetActiveWindow();
|
|
|
|
+ PostMessageW(hwnd, WM_INPUTLANGCHANGEREQUEST,
|
2021-05-05 15:14:30 -07:00
|
|
|
+ 0 /*FIXME*/, (LPARAM)GetKeyboardLayout(0));
|
2019-12-23 01:03:44 -08:00
|
|
|
+ break;
|
|
|
|
+
|
|
|
|
+ case MappingPointer:
|
|
|
|
+ X11DRV_InitMouse( event->xmapping.display );
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
|
|
|
|
- hwnd = GetFocus();
|
|
|
|
- if (!hwnd) hwnd = GetActiveWindow();
|
|
|
|
- PostMessageW(hwnd, WM_INPUTLANGCHANGEREQUEST,
|
2021-05-05 15:14:30 -07:00
|
|
|
- 0 /*FIXME*/, (LPARAM)GetKeyboardLayout(0));
|
2019-12-23 01:03:44 -08:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
diff --git a/dlls/winex11.drv/mouse.c b/dlls/winex11.drv/mouse.c
|
2021-04-09 15:39:38 -07:00
|
|
|
index 0d41438c5c7..fc5fd29d7b6 100644
|
2019-12-23 01:03:44 -08:00
|
|
|
--- a/dlls/winex11.drv/mouse.c
|
|
|
|
+++ b/dlls/winex11.drv/mouse.c
|
|
|
|
@@ -25,6 +25,9 @@
|
|
|
|
#include <X11/Xlib.h>
|
|
|
|
#include <X11/cursorfont.h>
|
|
|
|
#include <stdarg.h>
|
|
|
|
+#ifdef HAVE_X11_EXTENSIONS_XINPUT_H
|
|
|
|
+#include <X11/extensions/XInput.h>
|
|
|
|
+#endif
|
|
|
|
#ifdef HAVE_X11_EXTENSIONS_XINPUT2_H
|
|
|
|
#include <X11/extensions/XInput2.h>
|
|
|
|
#endif
|
2020-04-07 16:15:39 -07:00
|
|
|
@@ -142,6 +145,14 @@ MAKE_FUNCPTR(XISelectEvents);
|
2019-12-23 01:03:44 -08:00
|
|
|
#undef MAKE_FUNCPTR
|
|
|
|
#endif
|
|
|
|
|
|
|
|
+#ifdef HAVE_X11_EXTENSIONS_XINPUT_H
|
|
|
|
+#define MAKE_FUNCPTR(f) static typeof(f) * p##f
|
|
|
|
+MAKE_FUNCPTR(XOpenDevice);
|
|
|
|
+MAKE_FUNCPTR(XCloseDevice);
|
|
|
|
+MAKE_FUNCPTR(XGetDeviceButtonMapping);
|
|
|
|
+#undef MAKE_FUNCPTR
|
|
|
|
+#endif
|
|
|
|
+
|
|
|
|
/***********************************************************************
|
|
|
|
* X11DRV_Xcursor_Init
|
|
|
|
*
|
2020-04-07 16:15:39 -07:00
|
|
|
@@ -247,6 +258,70 @@ void sync_window_cursor( Window window )
|
2019-12-23 01:03:44 -08:00
|
|
|
set_window_cursor( window, cursor );
|
|
|
|
}
|
|
|
|
|
|
|
|
+struct mouse_button_mapping
|
|
|
|
+{
|
|
|
|
+ int deviceid;
|
|
|
|
+ unsigned int button_count;
|
|
|
|
+ unsigned char buttons[256];
|
|
|
|
+};
|
|
|
|
+
|
|
|
|
+static struct mouse_button_mapping *pointer_mapping;
|
|
|
|
+static struct mouse_button_mapping *device_mapping;
|
|
|
|
+
|
|
|
|
+static void update_pointer_mapping( Display *display )
|
|
|
|
+{
|
|
|
|
+ struct mouse_button_mapping *tmp;
|
|
|
|
+
|
|
|
|
+ if (!(tmp = HeapAlloc( GetProcessHeap(), 0, sizeof(*tmp) )))
|
|
|
|
+ {
|
|
|
|
+ WARN("Unable to allocate device mapping.\n");
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ tmp->button_count = ARRAY_SIZE( tmp->buttons );
|
|
|
|
+ tmp->button_count = XGetPointerMapping( display, tmp->buttons, tmp->button_count );
|
|
|
|
+
|
|
|
|
+ tmp = InterlockedExchangePointer( (void**)&pointer_mapping, tmp );
|
|
|
|
+
|
|
|
|
+ HeapFree( GetProcessHeap(), 0, tmp );
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+static void update_device_mapping( Display *display, int deviceid )
|
|
|
|
+{
|
|
|
|
+#ifdef HAVE_X11_EXTENSIONS_XINPUT_H
|
|
|
|
+ struct mouse_button_mapping *tmp;
|
|
|
|
+ XDevice *device;
|
|
|
|
+
|
|
|
|
+ if (!(device = pXOpenDevice( display, deviceid )))
|
|
|
|
+ {
|
|
|
|
+ WARN( "Unable to open cursor device %d\n", deviceid );
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (!(tmp = HeapAlloc( GetProcessHeap(), 0, sizeof(*tmp) )))
|
|
|
|
+ {
|
|
|
|
+ WARN( "Unable to allocate device mapping.\n" );
|
|
|
|
+ pXCloseDevice( display, device );
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ tmp->deviceid = deviceid;
|
|
|
|
+ tmp->button_count = ARRAY_SIZE( tmp->buttons );
|
|
|
|
+ tmp->button_count = pXGetDeviceButtonMapping( display, device, tmp->buttons, tmp->button_count );
|
|
|
|
+
|
|
|
|
+ tmp = InterlockedExchangePointer( (void**)&device_mapping, tmp );
|
|
|
|
+
|
|
|
|
+ HeapFree( GetProcessHeap(), 0, tmp );
|
|
|
|
+
|
|
|
|
+ pXCloseDevice( display, device );
|
|
|
|
+#endif
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+void X11DRV_InitMouse( Display *display )
|
|
|
|
+{
|
|
|
|
+ update_pointer_mapping( display );
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
#ifdef HAVE_X11_EXTENSIONS_XINPUT2_H
|
|
|
|
/***********************************************************************
|
|
|
|
* update_relative_valuators
|
2021-04-09 15:39:38 -07:00
|
|
|
@@ -1847,6 +1922,8 @@ static BOOL X11DRV_DeviceChanged( XGenericEventCookie *xev )
|
2019-12-23 01:03:44 -08:00
|
|
|
if (event->reason != XISlaveSwitch) return FALSE;
|
|
|
|
|
|
|
|
update_relative_valuators( event->classes, event->num_classes );
|
|
|
|
+ update_device_mapping( event->display, event->sourceid );
|
|
|
|
+
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2021-04-09 15:39:38 -07:00
|
|
|
@@ -1916,13 +1993,12 @@ static BOOL X11DRV_RawMotion( XGenericEventCookie *xev )
|
2019-12-23 01:03:44 -08:00
|
|
|
|
|
|
|
#endif /* HAVE_X11_EXTENSIONS_XINPUT2_H */
|
|
|
|
|
|
|
|
-
|
|
|
|
/***********************************************************************
|
2021-04-09 15:39:38 -07:00
|
|
|
* x11drv_xinput_load
|
2019-12-23 01:03:44 -08:00
|
|
|
*/
|
2021-04-09 15:39:38 -07:00
|
|
|
void x11drv_xinput_load(void)
|
2019-12-23 01:03:44 -08:00
|
|
|
{
|
|
|
|
-#if defined(SONAME_LIBXI) && defined(HAVE_X11_EXTENSIONS_XINPUT2_H)
|
|
|
|
+#if defined(SONAME_LIBXI)
|
|
|
|
int event, error;
|
2020-04-07 16:15:39 -07:00
|
|
|
void *libxi_handle = dlopen( SONAME_LIBXI, RTLD_NOW );
|
2019-12-23 01:03:44 -08:00
|
|
|
|
2021-04-09 15:39:38 -07:00
|
|
|
@@ -1938,11 +2014,20 @@ void x11drv_xinput_load(void)
|
2019-12-23 01:03:44 -08:00
|
|
|
return; \
|
|
|
|
}
|
|
|
|
|
|
|
|
+#ifdef HAVE_X11_EXTENSIONS_XINPUT2_H
|
|
|
|
LOAD_FUNCPTR(XIGetClientPointer);
|
|
|
|
LOAD_FUNCPTR(XIFreeDeviceInfo);
|
|
|
|
LOAD_FUNCPTR(XIQueryDevice);
|
|
|
|
LOAD_FUNCPTR(XIQueryVersion);
|
|
|
|
LOAD_FUNCPTR(XISelectEvents);
|
|
|
|
+#endif
|
|
|
|
+
|
|
|
|
+#ifdef HAVE_X11_EXTENSIONS_XINPUT_H
|
|
|
|
+ LOAD_FUNCPTR(XOpenDevice);
|
|
|
|
+ LOAD_FUNCPTR(XCloseDevice);
|
|
|
|
+ LOAD_FUNCPTR(XGetDeviceButtonMapping);
|
|
|
|
+#endif
|
|
|
|
+
|
|
|
|
#undef LOAD_FUNCPTR
|
|
|
|
|
|
|
|
xinput2_available = XQueryExtension( gdi_display, "XInputExtension", &xinput2_opcode, &event, &error );
|
|
|
|
diff --git a/dlls/winex11.drv/x11drv.h b/dlls/winex11.drv/x11drv.h
|
2021-05-21 23:30:39 -07:00
|
|
|
index b7c876e35fe..7a89a010395 100644
|
2019-12-23 01:03:44 -08:00
|
|
|
--- a/dlls/winex11.drv/x11drv.h
|
|
|
|
+++ b/dlls/winex11.drv/x11drv.h
|
2021-05-21 23:30:39 -07:00
|
|
|
@@ -643,6 +643,7 @@ extern void retry_grab_clipping_window(void) DECLSPEC_HIDDEN;
|
2019-12-23 01:03:44 -08:00
|
|
|
extern BOOL clip_fullscreen_window( HWND hwnd, BOOL reset ) DECLSPEC_HIDDEN;
|
|
|
|
extern void move_resize_window( HWND hwnd, int dir ) DECLSPEC_HIDDEN;
|
|
|
|
extern void X11DRV_InitKeyboard( Display *display ) DECLSPEC_HIDDEN;
|
|
|
|
+extern void X11DRV_InitMouse( Display *display ) DECLSPEC_HIDDEN;
|
|
|
|
extern DWORD CDECL X11DRV_MsgWaitForMultipleObjectsEx( DWORD count, const HANDLE *handles, DWORD timeout,
|
|
|
|
DWORD mask, DWORD flags ) DECLSPEC_HIDDEN;
|
|
|
|
|
|
|
|
diff --git a/dlls/winex11.drv/x11drv_main.c b/dlls/winex11.drv/x11drv_main.c
|
2021-05-21 23:30:39 -07:00
|
|
|
index 43c30ab369c..d8576949aea 100644
|
2019-12-23 01:03:44 -08:00
|
|
|
--- a/dlls/winex11.drv/x11drv_main.c
|
|
|
|
+++ b/dlls/winex11.drv/x11drv_main.c
|
2021-05-21 23:30:39 -07:00
|
|
|
@@ -616,6 +616,7 @@ static BOOL process_attach(void)
|
2019-12-23 01:03:44 -08:00
|
|
|
if (use_xkb) use_xkb = XkbUseExtension( gdi_display, NULL, NULL );
|
|
|
|
#endif
|
|
|
|
X11DRV_InitKeyboard( gdi_display );
|
|
|
|
+ X11DRV_InitMouse( gdi_display );
|
|
|
|
if (use_xim) use_xim = X11DRV_InitXIM( input_style );
|
|
|
|
|
|
|
|
X11DRV_DisplayDevices_Init(FALSE);
|
|
|
|
--
|
2021-04-09 15:39:38 -07:00
|
|
|
2.30.2
|
2019-12-23 01:03:44 -08:00
|
|
|
|