wine-staging/patches/user32-rawinput/0008-winex11.drv-Implement-native-mouse-button-raw-input-.patch

235 lines
9.2 KiB
Diff
Raw Normal View History

2019-09-29 01:06:18 -07:00
From f55c05132e87dd3e9436c68920ad512bdcfb8df8 Mon Sep 17 00:00:00 2001
From: Derek Lesho <dereklesho52@Gmail.com>
Date: Fri, 26 Jul 2019 17:37:19 -0400
2019-09-24 21:06:49 -07:00
Subject: [PATCH 08/11] winex11.drv: Implement native mouse-button raw-input
using RawButton*.
Signed-off-by: Derek Lesho <dereklesho52@Gmail.com>
---
2019-09-24 21:06:49 -07:00
dlls/winex11.drv/mouse.c | 97 +++++++++++++++++++++++++++++++---
dlls/winex11.drv/x11drv.h | 3 ++
dlls/winex11.drv/x11drv_main.c | 1 +
2019-09-24 21:06:49 -07:00
3 files changed, 95 insertions(+), 6 deletions(-)
diff --git a/dlls/winex11.drv/mouse.c b/dlls/winex11.drv/mouse.c
2019-09-29 01:06:18 -07:00
index 212511fde8..1d9833b5c9 100644
--- a/dlls/winex11.drv/mouse.c
+++ b/dlls/winex11.drv/mouse.c
2019-09-29 01:06:18 -07:00
@@ -264,12 +264,21 @@ static void update_relative_valuators(XIAnyClassInfo **valuators, int n_valuator
thread_data->y_rel_valuator.number = -1;
2019-09-24 21:06:49 -07:00
thread_data->x_abs_valuator.number = -1;
thread_data->y_abs_valuator.number = -1;
+ thread_data->wheel_valuator.number = -1;
2019-09-24 21:06:49 -07:00
+
+ thread_data->xi2_wheel_multiplier = 0;
for (i = 0; i < n_valuators; i++)
{
2019-09-24 21:06:49 -07:00
XIValuatorClassInfo *class = (XIValuatorClassInfo *)valuators[i];
+ XIScrollClassInfo *scroll_class = (XIScrollClassInfo *)valuators[i];
struct x11drv_valuator_data *valuator_data = NULL;
+ if (valuators[i]->type == XIScrollClass)
+ {
+ if (scroll_class->scroll_type == XIScrollTypeVertical)
2019-09-29 01:06:18 -07:00
+ thread_data->xi2_wheel_multiplier = -WHEEL_DELTA / scroll_class->increment;
2019-09-24 21:06:49 -07:00
+ }
if (valuators[i]->type != XIValuatorClass) continue;
if (class->label == x11drv_atom( Rel_X ) ||
(!class->label && class->number == 0 && class->mode == XIModeRelative))
2019-09-29 01:06:18 -07:00
@@ -291,6 +300,11 @@ static void update_relative_valuators(XIAnyClassInfo **valuators, int n_valuator
{
2019-09-24 21:06:49 -07:00
valuator_data = &thread_data->y_abs_valuator;
}
+ else if (class->label == x11drv_atom( Rel_Vert_Scroll ) ||
+ (!class->label && class->number == 3 && class->mode == XIModeRelative))
+ {
+ valuator_data = &thread_data->wheel_valuator;
+ }
if (valuator_data) {
valuator_data->number = class->number;
2019-09-29 01:06:18 -07:00
@@ -339,6 +353,8 @@ void X11DRV_XInput2_Enable(void)
2019-09-24 21:06:49 -07:00
XISetMask( mask_bits, XI_DeviceChanged );
XISetMask( mask_bits, XI_RawMotion );
2019-09-24 21:06:49 -07:00
XISetMask( mask_bits, XI_DeviceChanged );
+ XISetMask( mask_bits, XI_RawButtonPress );
+ XISetMask( mask_bits, XI_RawButtonRelease );
/* XInput 2.0 has a problematic behavior where master pointer will
* not send raw events to the root window whenever a grab is active
2019-09-29 01:06:18 -07:00
@@ -396,6 +412,7 @@ void X11DRV_XInput2_Disable(void)
pXIFreeDeviceInfo( data->xi2_devices );
data->x_rel_valuator.number = -1;
data->y_rel_valuator.number = -1;
+ data->wheel_valuator.number = -1;
data->xi2_devices = NULL;
data->xi2_core_pointer = 0;
data->xi2_current_slave = 0;
2019-09-29 01:06:18 -07:00
@@ -1833,12 +1850,13 @@ static BOOL X11DRV_RawMotion( XGenericEventCookie *xev )
INPUT input;
RAWINPUT raw_input;
int i;
2019-09-24 21:06:49 -07:00
- double dx = 0, dy = 0, raw_x = 0, raw_y = 0, val, raw_val;
+ double dx = 0, dy = 0, raw_x = 0, raw_y = 0, raw_dwheel = 0, val, raw_val;
struct x11drv_thread_data *thread_data = x11drv_thread_data();
2019-09-24 21:06:49 -07:00
- struct x11drv_valuator_data *x_rel, *y_rel, *x_abs, *y_abs;
+ struct x11drv_valuator_data *x_rel, *y_rel, *x_abs, *y_abs, *wheel;
if ((thread_data->x_rel_valuator.number < 0 || thread_data->y_rel_valuator.number < 0) &&
- (thread_data->x_abs_valuator.number < 0 || thread_data->y_abs_valuator.number < 0) return FALSE;
+ (thread_data->x_abs_valuator.number < 0 || thread_data->y_abs_valuator.number < 0) &&
+ thread_data->wheel_valuator.number < 0) return FALSE;
if (!event->valuators.mask_len) return FALSE;
if (thread_data->xi2_state < xi_enabled) return FALSE;
2019-09-29 01:06:18 -07:00
@@ -1874,6 +1892,7 @@ static BOOL X11DRV_RawMotion( XGenericEventCookie *xev )
y_rel = &thread_data->y_rel_valuator;
2019-09-24 21:06:49 -07:00
x_abs = &thread_data->x_abs_valuator;
y_abs = &thread_data->y_abs_valuator;
+ wheel = &thread_data->wheel_valuator;
input.type = INPUT_MOUSE;
input.u.mi.mouseData = 0;
2019-09-29 01:06:18 -07:00
@@ -1894,7 +1913,7 @@ static BOOL X11DRV_RawMotion( XGenericEventCookie *xev )
virtual_rect = get_virtual_screen_rect();
2019-09-24 21:06:49 -07:00
- for (i = 0; i <= max(max(max( x_abs->number, y_abs->number), x_rel->number), y_rel->number); i++)
+ for (i = 0; i <= max(max(max(max(x_abs->number, y_abs->number), x_rel->number), y_rel->number), wheel->number); i++)
{
if (!XIMaskIsSet( event->valuators.mask, i )) continue;
val = *values++;
2019-09-29 01:06:18 -07:00
@@ -1929,6 +1948,10 @@ static BOOL X11DRV_RawMotion( XGenericEventCookie *xev )
2019-09-24 21:06:49 -07:00
raw_input.data.mouse.usFlags = MOUSE_MOVE_ABSOLUTE | MOUSE_VIRTUAL_DESKTOP;
raw_input.data.mouse.lLastY = raw_y = raw_val * (65536 / (y_abs->max - y_abs->min));
}
+ if (i == wheel->number)
+ {
2019-09-24 21:06:49 -07:00
+ raw_dwheel = raw_val * thread_data->xi2_wheel_multiplier;
+ }
}
if (broken_rawevents && is_old_motion_event( xev->serial ))
2019-09-29 01:06:18 -07:00
@@ -1943,13 +1966,70 @@ static BOOL X11DRV_RawMotion( XGenericEventCookie *xev )
__wine_send_input( 0, &input );
}
2019-09-24 21:06:49 -07:00
- TRACE("raw %s event %f,%f\n",
- raw_input.data.mouse.usFlags ? "absolute" : "relative", raw_x, raw_y);
+ if (raw_dwheel)
+ {
+ raw_input.data.mouse.u.usButtonFlags = RI_MOUSE_WHEEL;
+ raw_input.data.mouse.u.usButtonData = raw_dwheel;
+ }
+
2019-09-24 21:06:49 -07:00
+ TRACE("raw %s event %f,%f + %f\n",
+ raw_input.data.mouse.usFlags ? "absolute" : "relative", raw_x, raw_y, raw_dwheel);
__wine_send_raw_input( &raw_input );
return TRUE;
}
+/***********************************************************************
+ * X11DRV_RawButton
+ */
+static BOOL X11DRV_RawButton( XGenericEventCookie *xev )
+{
+ RAWINPUT ri;
+
+ static const unsigned short raw_button_press_flags[] = {
+ 0, /* 0 = unused */
+ RI_MOUSE_LEFT_BUTTON_DOWN, /* 1 */
+ RI_MOUSE_MIDDLE_BUTTON_DOWN, /* 2 */
+ RI_MOUSE_RIGHT_BUTTON_DOWN, /* 3 */
+ 0, /* 4 = unknown */
+ 0, /* 5 = unknown */
+ 0, /* 6 = unknown */
+ 0, /* 7 = unknown */
+ RI_MOUSE_BUTTON_4_DOWN, /* 8 */
+ RI_MOUSE_BUTTON_5_DOWN /* 9 */
+ };
+
+ static const unsigned short raw_button_release_flags[] = {
+ 0, /* 0 = unused */
+ RI_MOUSE_LEFT_BUTTON_UP, /* 1 */
+ RI_MOUSE_MIDDLE_BUTTON_UP, /* 2 */
+ RI_MOUSE_RIGHT_BUTTON_UP, /* 3 */
+ 0, /* 4 = unknown */
+ 0, /* 5 = unknown */
+ 0, /* 6 = unknown */
+ 0, /* 7 = unknown */
+ RI_MOUSE_BUTTON_4_UP, /* 8 */
+ RI_MOUSE_BUTTON_5_UP /* 9 */
+ };
+
+ int detail = ((XIRawEvent*)xev->data)->detail;
+ if (detail > 9) return TRUE;
+
+ ri.header.dwType = RIM_TYPEMOUSE;
+ ri.data.mouse.u.usButtonFlags = xev->evtype == XI_RawButtonPress ? raw_button_press_flags[detail] : raw_button_release_flags[detail] ;
+ ri.data.mouse.u.usButtonData = 0;
+ ri.data.mouse.lLastX = 0;
+ ri.data.mouse.lLastY = 0;
+ ri.data.mouse.usFlags = 0;
+ ri.data.mouse.ulRawButtons = 0;
+ ri.data.mouse.ulExtraInformation = 0;
+
+ if (ri.data.mouse.u.usButtonFlags)
+ __wine_send_raw_input( &ri );
+
+ return TRUE;
+}
+
#endif /* HAVE_X11_EXTENSIONS_XINPUT2_H */
2019-09-29 01:06:18 -07:00
@@ -2014,6 +2094,11 @@ BOOL X11DRV_GenericEvent( HWND hwnd, XEvent *xev )
case XI_RawMotion:
ret = X11DRV_RawMotion( event );
break;
+ case XI_RawButtonPress:
+ /* fall through */
+ case XI_RawButtonRelease:
+ ret = X11DRV_RawButton( event );
+ break;
default:
TRACE( "Unhandled event %#x\n", event->evtype );
diff --git a/dlls/winex11.drv/x11drv.h b/dlls/winex11.drv/x11drv.h
2019-09-29 01:06:18 -07:00
index e9d9514ee2..599ed48154 100644
--- a/dlls/winex11.drv/x11drv.h
+++ b/dlls/winex11.drv/x11drv.h
2019-09-24 21:06:49 -07:00
@@ -344,6 +344,8 @@ struct x11drv_thread_data
struct x11drv_valuator_data y_rel_valuator;
2019-09-24 21:06:49 -07:00
struct x11drv_valuator_data x_abs_valuator;
struct x11drv_valuator_data y_abs_valuator;
+ struct x11drv_valuator_data wheel_valuator;
2019-09-24 21:06:49 -07:00
+ double xi2_wheel_multiplier;
int xi2_core_pointer; /* XInput2 core pointer id */
int xi2_current_slave; /* Current slave driving the Core pointer */
};
2019-09-29 01:06:18 -07:00
@@ -432,6 +434,7 @@ enum x11drv_atoms
XATOM_Rel_Y,
2019-09-24 21:06:49 -07:00
XATOM_Abs_X,
XATOM_Abs_Y,
+ XATOM_Rel_Vert_Scroll,
XATOM_WM_PROTOCOLS,
XATOM_WM_DELETE_WINDOW,
XATOM_WM_STATE,
diff --git a/dlls/winex11.drv/x11drv_main.c b/dlls/winex11.drv/x11drv_main.c
2019-09-24 21:06:49 -07:00
index fb25a45ae2..05a445a9c1 100644
--- a/dlls/winex11.drv/x11drv_main.c
+++ b/dlls/winex11.drv/x11drv_main.c
2019-09-24 21:06:49 -07:00
@@ -122,6 +122,7 @@ static const char * const atom_names[NB_XATOMS - FIRST_XATOM] =
"Rel Y",
2019-09-24 21:06:49 -07:00
"Abs X",
"Abs Y",
+ "Rel Vert Scroll",
"WM_PROTOCOLS",
"WM_DELETE_WINDOW",
"WM_STATE",
--
2019-09-24 21:06:49 -07:00
2.23.0