2019-09-19 15:59:46 -07:00
|
|
|
From cd40a026040d5f981e2dc3051826befa3d5df8f6 Mon Sep 17 00:00:00 2001
|
2019-08-21 21:33:10 -07:00
|
|
|
From: Derek Lesho <dereklesho52@Gmail.com>
|
|
|
|
Date: Fri, 26 Jul 2019 17:37:19 -0400
|
|
|
|
Subject: [PATCH 08/10] winex11.drv: Implement native mouse-button raw-input
|
|
|
|
using RawButton*.
|
|
|
|
|
|
|
|
Signed-off-by: Derek Lesho <dereklesho52@Gmail.com>
|
|
|
|
---
|
|
|
|
dlls/winex11.drv/mouse.c | 89 ++++++++++++++++++++++++++++++++--
|
|
|
|
dlls/winex11.drv/x11drv.h | 2 +
|
|
|
|
dlls/winex11.drv/x11drv_main.c | 1 +
|
|
|
|
3 files changed, 87 insertions(+), 5 deletions(-)
|
|
|
|
|
|
|
|
diff --git a/dlls/winex11.drv/mouse.c b/dlls/winex11.drv/mouse.c
|
2019-09-19 15:59:46 -07:00
|
|
|
index 1ec077bca74..6e09bebfdb8 100644
|
2019-08-21 21:33:10 -07:00
|
|
|
--- a/dlls/winex11.drv/mouse.c
|
|
|
|
+++ b/dlls/winex11.drv/mouse.c
|
2019-09-19 15:59:46 -07:00
|
|
|
@@ -262,6 +262,7 @@ static void update_relative_valuators(XIAnyClassInfo **valuators, int n_valuator
|
2019-08-21 21:33:10 -07:00
|
|
|
|
|
|
|
thread_data->x_rel_valuator.number = -1;
|
|
|
|
thread_data->y_rel_valuator.number = -1;
|
|
|
|
+ thread_data->wheel_valuator.number = -1;
|
|
|
|
|
|
|
|
for (i = 0; i < n_valuators; i++)
|
|
|
|
{
|
2019-09-19 15:59:46 -07:00
|
|
|
@@ -279,6 +280,11 @@ static void update_relative_valuators(XIAnyClassInfo **valuators, int n_valuator
|
2019-08-21 21:33:10 -07:00
|
|
|
{
|
|
|
|
valuator_data = &thread_data->y_rel_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-19 15:59:46 -07:00
|
|
|
@@ -325,6 +331,8 @@ void X11DRV_XInput2_Enable(void)
|
2019-08-21 21:33:10 -07:00
|
|
|
mask.deviceid = XIAllMasterDevices;
|
|
|
|
memset( mask_bits, 0, sizeof(mask_bits) );
|
|
|
|
XISetMask( mask_bits, XI_RawMotion );
|
|
|
|
+ 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-19 15:59:46 -07:00
|
|
|
@@ -383,6 +391,7 @@ void X11DRV_XInput2_Disable(void)
|
2019-08-21 21:33:10 -07:00
|
|
|
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-19 15:59:46 -07:00
|
|
|
@@ -1850,11 +1859,11 @@ static BOOL X11DRV_RawMotion( XGenericEventCookie *xev )
|
2019-08-21 21:33:10 -07:00
|
|
|
INPUT input;
|
|
|
|
RAWINPUT raw_input;
|
|
|
|
int i;
|
|
|
|
- double dx = 0, dy = 0, raw_dx = 0, raw_dy = 0, val, raw_val;
|
|
|
|
+ double dx = 0, dy = 0, raw_dx = 0, raw_dy = 0, raw_dwheel = 0, val, raw_val;
|
|
|
|
struct x11drv_thread_data *thread_data = x11drv_thread_data();
|
|
|
|
- struct x11drv_valuator_data *x_rel, *y_rel;
|
|
|
|
+ struct x11drv_valuator_data *x_rel, *y_rel, *wheel;
|
|
|
|
|
|
|
|
- if (thread_data->x_rel_valuator.number < 0 || thread_data->y_rel_valuator.number < 0) return FALSE;
|
|
|
|
+ if (thread_data->x_rel_valuator.number < 0 || thread_data->y_rel_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-19 15:59:46 -07:00
|
|
|
@@ -1887,6 +1896,7 @@ static BOOL X11DRV_RawMotion( XGenericEventCookie *xev )
|
2019-08-21 21:33:10 -07:00
|
|
|
|
|
|
|
x_rel = &thread_data->x_rel_valuator;
|
|
|
|
y_rel = &thread_data->y_rel_valuator;
|
|
|
|
+ wheel = &thread_data->wheel_valuator;
|
|
|
|
|
|
|
|
input.type = INPUT_MOUSE;
|
|
|
|
input.u.mi.mouseData = 0;
|
2019-09-19 15:59:46 -07:00
|
|
|
@@ -1907,7 +1917,7 @@ static BOOL X11DRV_RawMotion( XGenericEventCookie *xev )
|
2019-08-21 21:33:10 -07:00
|
|
|
|
|
|
|
virtual_rect = get_virtual_screen_rect();
|
|
|
|
|
|
|
|
- for (i = 0; i <= max ( x_rel->number, y_rel->number ); i++)
|
|
|
|
+ for (i = 0; i <= max( wheel->number, max( x_rel->number, y_rel->number ) ); i++)
|
|
|
|
{
|
|
|
|
if (!XIMaskIsSet( event->valuators.mask, i )) continue;
|
|
|
|
val = *values++;
|
2019-09-19 15:59:46 -07:00
|
|
|
@@ -1930,6 +1940,13 @@ static BOOL X11DRV_RawMotion( XGenericEventCookie *xev )
|
2019-08-21 21:33:10 -07:00
|
|
|
|
|
|
|
raw_input.data.mouse.lLastY = raw_dy = raw_val;
|
|
|
|
}
|
|
|
|
+ if (i == wheel->number)
|
|
|
|
+ {
|
|
|
|
+ /* NOTE: Testing showed a 8x factor between X11 and Windows
|
|
|
|
+ * values, but that may be device specific
|
|
|
|
+ */
|
|
|
|
+ raw_dwheel = raw_val * -8;
|
|
|
|
+ }
|
|
|
|
}
|
|
|
|
|
|
|
|
if (broken_rawevents && is_old_motion_event( xev->serial ))
|
2019-09-19 15:59:46 -07:00
|
|
|
@@ -1944,12 +1961,69 @@ static BOOL X11DRV_RawMotion( XGenericEventCookie *xev )
|
2019-08-21 21:33:10 -07:00
|
|
|
__wine_send_input( 0, &input );
|
|
|
|
}
|
|
|
|
|
|
|
|
- TRACE("raw event %f,%f\n", raw_dx, raw_dy);
|
|
|
|
+ if (raw_dwheel)
|
|
|
|
+ {
|
|
|
|
+ raw_input.data.mouse.u.usButtonFlags = RI_MOUSE_WHEEL;
|
|
|
|
+ raw_input.data.mouse.u.usButtonData = raw_dwheel;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ TRACE("raw event %f,%f + %f\n", raw_dx, raw_dy, 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-19 15:59:46 -07:00
|
|
|
@@ -2014,6 +2088,11 @@ BOOL X11DRV_GenericEvent( HWND hwnd, XEvent *xev )
|
2019-08-21 21:33:10 -07:00
|
|
|
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-19 15:59:46 -07:00
|
|
|
index 81ad38df918..7a9b2c8b909 100644
|
2019-08-21 21:33:10 -07:00
|
|
|
--- a/dlls/winex11.drv/x11drv.h
|
|
|
|
+++ b/dlls/winex11.drv/x11drv.h
|
2019-09-19 15:59:46 -07:00
|
|
|
@@ -344,6 +344,7 @@ struct x11drv_thread_data
|
2019-08-21 21:33:10 -07:00
|
|
|
int xi2_device_count;
|
|
|
|
struct x11drv_valuator_data x_rel_valuator;
|
|
|
|
struct x11drv_valuator_data y_rel_valuator;
|
|
|
|
+ struct x11drv_valuator_data wheel_valuator;
|
|
|
|
int xi2_core_pointer; /* XInput2 core pointer id */
|
|
|
|
int xi2_current_slave; /* Current slave driving the Core pointer */
|
|
|
|
};
|
2019-09-19 15:59:46 -07:00
|
|
|
@@ -431,6 +432,7 @@ enum x11drv_atoms
|
2019-08-21 21:33:10 -07:00
|
|
|
XATOM_RAW_CAP_HEIGHT,
|
|
|
|
XATOM_Rel_X,
|
|
|
|
XATOM_Rel_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-19 15:59:46 -07:00
|
|
|
index cfcf1f19dd1..093a5fa785e 100644
|
2019-08-21 21:33:10 -07:00
|
|
|
--- a/dlls/winex11.drv/x11drv_main.c
|
|
|
|
+++ b/dlls/winex11.drv/x11drv_main.c
|
2019-09-19 15:59:46 -07:00
|
|
|
@@ -121,6 +121,7 @@ static const char * const atom_names[NB_XATOMS - FIRST_XATOM] =
|
2019-08-21 21:33:10 -07:00
|
|
|
"RAW_CAP_HEIGHT",
|
|
|
|
"Rel X",
|
|
|
|
"Rel Y",
|
|
|
|
+ "Rel Vert Scroll",
|
|
|
|
"WM_PROTOCOLS",
|
|
|
|
"WM_DELETE_WINDOW",
|
|
|
|
"WM_STATE",
|
|
|
|
--
|
2019-09-19 15:59:46 -07:00
|
|
|
2.17.1
|
2019-08-21 21:33:10 -07:00
|
|
|
|