Rebase against e8f4909ac3cc58e67ad73b9d4a0cbe6fe7b3bf90.

This commit is contained in:
Zebediah Figura
2024-02-12 17:29:03 -06:00
parent dc3b4e6589
commit eedc72d581
5 changed files with 15 additions and 352 deletions

View File

@ -1,133 +0,0 @@
From 1d5433cc0d7cd37af7c79fb2468c02b1c5a9a9ac Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?R=C3=A9mi=20Bernon?= <rbernon@codeweavers.com>
Date: Fri, 17 Jan 2020 16:33:11 +0100
Subject: [PATCH] winex11.drv: Split XInput2 thread initialization.
And rename the library and function loader to x11drv_xinput_load.
---
dlls/winex11.drv/mouse.c | 46 +++++++++++++++++++++++-----------
dlls/winex11.drv/x11drv.h | 3 ++-
dlls/winex11.drv/x11drv_main.c | 4 ++-
3 files changed, 36 insertions(+), 17 deletions(-)
diff --git a/dlls/winex11.drv/mouse.c b/dlls/winex11.drv/mouse.c
index 612fff9995c..911e93d8de1 100644
--- a/dlls/winex11.drv/mouse.c
+++ b/dlls/winex11.drv/mouse.c
@@ -253,6 +253,32 @@ static void update_relative_valuators(XIAnyClassInfo **valuators, int n_valuator
}
+/***********************************************************************
+ * x11drv_xinput_init
+ */
+void x11drv_xinput_init(void)
+{
+#ifdef HAVE_X11_EXTENSIONS_XINPUT2_H
+ struct x11drv_thread_data *data = x11drv_thread_data();
+ int major = 2, minor = 0;
+
+ if (data->xi2_state != xi_unknown) return;
+
+ if (xinput2_available &&
+ !pXIQueryVersion( data->display, &major, &minor ))
+ {
+ TRACE( "XInput2 %d.%d available\n", major, minor );
+ data->xi2_state = xi_disabled;
+ }
+ else
+ {
+ data->xi2_state = xi_unavailable;
+ WARN( "XInput 2.0 not available\n" );
+ }
+#endif
+}
+
+
/***********************************************************************
* enable_xinput2
*/
@@ -264,19 +290,9 @@ static void enable_xinput2(void)
unsigned char mask_bits[XIMaskLen(XI_LASTEVENT)];
int count;
- if (!xinput2_available) return;
+ TRACE( "state:%d\n", data->xi2_state );
+ if (data->xi2_state != xi_disabled) return;
- if (data->xi2_state == xi_unknown)
- {
- int major = 2, minor = 0;
- if (!pXIQueryVersion( data->display, &major, &minor )) data->xi2_state = xi_disabled;
- else
- {
- data->xi2_state = xi_unavailable;
- WARN( "X Input 2 not available\n" );
- }
- }
- if (data->xi2_state == xi_unavailable) return;
if (!pXIGetClientPointer( data->display, None, &data->xi2_core_pointer )) return;
mask.mask = mask_bits;
@@ -317,9 +333,9 @@ static void disable_xinput2(void)
struct x11drv_thread_data *data = x11drv_thread_data();
XIEventMask mask;
+ TRACE( "state:%d\n", data->xi2_state );
if (data->xi2_state != xi_enabled) return;
- TRACE( "disabling\n" );
data->xi2_state = xi_disabled;
mask.mask = NULL;
@@ -1755,9 +1771,9 @@ static BOOL X11DRV_RawMotion( XGenericEventCookie *xev )
/***********************************************************************
- * X11DRV_XInput2_Init
+ * x11drv_xinput_load
*/
-void X11DRV_XInput2_Init(void)
+void x11drv_xinput_load(void)
{
#if defined(SONAME_LIBXI) && defined(HAVE_X11_EXTENSIONS_XINPUT2_H)
int event, error;
diff --git a/dlls/winex11.drv/x11drv.h b/dlls/winex11.drv/x11drv.h
index 2917579927c..fd69e55054c 100644
--- a/dlls/winex11.drv/x11drv.h
+++ b/dlls/winex11.drv/x11drv.h
@@ -261,7 +261,8 @@ extern void X11DRV_ThreadDetach(void);
/* X11 driver internal functions */
extern void X11DRV_Xcursor_Init(void);
-extern void X11DRV_XInput2_Init(void);
+extern void x11drv_xinput_load(void);
+extern void x11drv_xinput_init(void);
extern DWORD copy_image_bits( BITMAPINFO *info, BOOL is_r8g8b8, XImage *image,
const struct gdi_image_bits *src_bits, struct gdi_image_bits *dst_bits,
diff --git a/dlls/winex11.drv/x11drv_main.c b/dlls/winex11.drv/x11drv_main.c
index 32a20e0e4f2..573a41bbe96 100644
--- a/dlls/winex11.drv/x11drv_main.c
+++ b/dlls/winex11.drv/x11drv_main.c
@@ -700,7 +700,7 @@ static NTSTATUS x11drv_init( void *arg )
#ifdef SONAME_LIBXCOMPOSITE
X11DRV_XComposite_Init();
#endif
- X11DRV_XInput2_Init();
+ x11drv_xinput_load();
XkbUseExtension( gdi_display, NULL, NULL );
X11DRV_InitKeyboard( gdi_display );
@@ -790,6 +790,8 @@ struct x11drv_thread_data *x11drv_init_thread_data(void)
if (use_xim) xim_thread_attach( data );
+ x11drv_xinput_init();
+
return data;
}
--
2.42.0

View File

@ -1,147 +0,0 @@
From 9e5a2e10d466cbd51338a46d0385457bcb612b97 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?R=C3=A9mi=20Bernon?= <rbernon@codeweavers.com>
Date: Sun, 24 Oct 2021 22:30:56 +0200
Subject: [PATCH] winex11.drv: Advertise XInput2 version 2.1 support.
Under XInput2 protocol version < 2.1, RawEvents are not supposed to be
sent if a pointer grab is active. However slave device events are still
received regardless of this specification and Wine implemented a
workaround to receive RawEvents during pointer grabs by listening to
these slave device events. Then, as soon as a mouse button is pressed
only the grabbing client will receive the raw motion events.
By advertising the support of XInput2 version >= 2.1, where RawEvents
are sent even during pointer grabs, we ensure to receive the RawMotion
events from the desktop window thread, even if a mouse grab is active.
It is now also possible to simplify the code by listening to master
device events only and get rid of slave device id tracking.
---
dlls/winex11.drv/mouse.c | 42 +++++----------------------------------
dlls/winex11.drv/x11drv.h | 3 ---
2 files changed, 5 insertions(+), 40 deletions(-)
diff --git a/dlls/winex11.drv/mouse.c b/dlls/winex11.drv/mouse.c
index f11e73f436b..ff91aecb67f 100644
--- a/dlls/winex11.drv/mouse.c
+++ b/dlls/winex11.drv/mouse.c
@@ -260,7 +260,7 @@ void x11drv_xinput_init(void)
{
#ifdef HAVE_X11_EXTENSIONS_XINPUT2_H
struct x11drv_thread_data *data = x11drv_thread_data();
- int major = 2, minor = 0;
+ int major = 2, minor = 1;
if (data->xi2_state != xi_unknown) return;
@@ -273,7 +273,7 @@ void x11drv_xinput_init(void)
else
{
data->xi2_state = xi_unavailable;
- WARN( "XInput 2.0 not available\n" );
+ WARN( "XInput 2.1 not available\n" );
}
#endif
}
@@ -309,7 +309,7 @@ void x11drv_xinput_enable( Display *display, Window window, long event_mask )
mask.mask = mask_bits;
mask.mask_len = sizeof(mask_bits);
- mask.deviceid = XIAllDevices;
+ mask.deviceid = XIAllMasterDevices;
memset( mask_bits, 0, sizeof(mask_bits) );
XISetMask( mask_bits, XI_DeviceChanged );
XISetMask( mask_bits, XI_RawMotion );
@@ -322,16 +322,6 @@ void x11drv_xinput_enable( Display *display, Window window, long event_mask )
update_relative_valuators( pointer_info->classes, pointer_info->num_classes );
pXIFreeDeviceInfo( pointer_info );
- /* This device info list is only used to find the initial current slave if
- * no XI_DeviceChanged events happened. If any hierarchy change occurred that
- * might be relevant here (eg. user switching mice after (un)plugging), a
- * XI_DeviceChanged event will point us to the right slave. So this list is
- * safe to be obtained statically at x11drv_xinput_enable() time.
- */
- if (data->xi2_devices) pXIFreeDeviceInfo( data->xi2_devices );
- data->xi2_devices = pXIQueryDevice( data->display, XIAllDevices, &data->xi2_device_count );
- data->xi2_current_slave = 0;
-
data->xi2_state = xi_enabled;
}
@@ -364,19 +354,16 @@ void x11drv_xinput_disable( Display *display, Window window, long event_mask )
mask.mask = NULL;
mask.mask_len = 0;
- mask.deviceid = XIAllDevices;
+ mask.deviceid = XIAllMasterDevices;
pXISelectEvents( display, DefaultRootWindow( display ), &mask, 1 );
if (!data) return;
- pXIFreeDeviceInfo( data->xi2_devices );
data->x_valuator.number = -1;
data->y_valuator.number = -1;
data->x_valuator.value = 0;
data->y_valuator.value = 0;
- data->xi2_devices = NULL;
data->xi2_core_pointer = 0;
- data->xi2_current_slave = 0;
data->xi2_state = xi_disabled;
#endif
}
@@ -1688,7 +1675,6 @@ static BOOL X11DRV_DeviceChanged( XGenericEventCookie *xev )
if (event->reason != XISlaveSwitch) return FALSE;
update_relative_valuators( event->classes, event->num_classes );
- data->xi2_current_slave = event->sourceid;
return TRUE;
}
@@ -1704,25 +1690,7 @@ static BOOL map_raw_event_coords( XIRawEvent *event, INPUT *input )
if (x->number < 0 || y->number < 0) return FALSE;
if (!event->valuators.mask_len) return FALSE;
if (thread_data->xi2_state != xi_enabled) return FALSE;
-
- /* If there is no slave currently detected, no previous motion nor device
- * change events were received. Look it up now on the device list in this
- * case.
- */
- if (!thread_data->xi2_current_slave)
- {
- XIDeviceInfo *devices = thread_data->xi2_devices;
-
- for (i = 0; i < thread_data->xi2_device_count; i++)
- {
- if (devices[i].use != XISlavePointer) continue;
- if (devices[i].deviceid != event->deviceid) continue;
- if (devices[i].attachment != thread_data->xi2_core_pointer) continue;
- thread_data->xi2_current_slave = event->deviceid;
- break;
- }
- }
- if (event->deviceid != thread_data->xi2_current_slave) return FALSE;
+ if (event->deviceid != thread_data->xi2_core_pointer) return FALSE;
virtual_rect = NtUserGetVirtualScreenRect();
diff --git a/dlls/winex11.drv/x11drv.h b/dlls/winex11.drv/x11drv.h
index e8cc85a15bd..fc3231ed40d 100644
--- a/dlls/winex11.drv/x11drv.h
+++ b/dlls/winex11.drv/x11drv.h
@@ -402,12 +402,9 @@ struct x11drv_thread_data
BOOL clipping_cursor; /* whether thread is currently clipping the cursor */
#ifdef HAVE_X11_EXTENSIONS_XINPUT2_H
enum xi2_state xi2_state; /* XInput2 state */
- void *xi2_devices; /* list of XInput2 devices (valid when state is enabled) */
- int xi2_device_count;
XIValuatorClassInfo x_valuator;
XIValuatorClassInfo y_valuator;
int xi2_core_pointer; /* XInput2 core pointer id */
- int xi2_current_slave; /* Current slave driving the Core pointer */
#endif /* HAVE_X11_EXTENSIONS_XINPUT2_H */
};
--
2.40.1