Updated user32-rawinput-mouse-experimental patchset

This commit is contained in:
Alistair Leslie-Hughes 2019-12-24 08:17:06 +11:00
parent a08376bca0
commit 2782e6db1e
4 changed files with 46 additions and 210 deletions

View File

@ -6650,12 +6650,10 @@ fi
if test "$enable_user32_rawinput_mouse_experimental" -eq 1; then
patch_apply user32-rawinput-mouse-experimental/0001-winex11.drv-Add-support-for-absolute-RawMotion-event.patch
patch_apply user32-rawinput-mouse-experimental/0002-winex11.drv-Send-relative-RawMotion-events-unprocess.patch
patch_apply user32-rawinput-mouse-experimental/0003-winex11.drv-Implement-relative-wheel-input-from-RawM.patch
patch_apply user32-rawinput-mouse-experimental/0004-winex11.drv-Accumulate-mouse-movement-to-avoid-round.patch
patch_apply user32-rawinput-mouse-experimental/0003-winex11.drv-Accumulate-mouse-movement-to-avoid-round.patch
(
printf '%s\n' '+ { "Derek Lesho", "winex11.drv: Add support for absolute RawMotion events.", 1 },';
printf '%s\n' '+ { "Rémi Bernon", "winex11.drv: Send relative RawMotion events unprocessed.", 1 },';
printf '%s\n' '+ { "Derek Lesho", "winex11.drv: Implement relative wheel input from RawMotion events.", 1 },';
printf '%s\n' '+ { "Jordan Galby", "winex11.drv: Accumulate mouse movement to avoid rounding losses.", 1 },';
) >> "$patchlist"
fi

View File

@ -1,50 +1,48 @@
From cf8668ffad406a26dde59993b81619c966446975 Mon Sep 17 00:00:00 2001
From e53124abe8f6eaeebdb8ccb75cd884543f63a996 Mon Sep 17 00:00:00 2001
From: Jordan Galby <gravemind2a+wine@gmail.com>
Date: Tue, 16 Jul 2019 00:34:38 -0400
Subject: [PATCH 4/4] winex11.drv: Accumulate mouse movement to avoid rounding
Subject: [PATCH 3/3] winex11.drv: Accumulate mouse movement to avoid rounding
losses.
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=42631
From: Jordan Galby <gravemind2a+wine@gmail.com>
---
dlls/winex11.drv/mouse.c | 44 +++++++++++++++++++++++++++++++++-------
1 file changed, 37 insertions(+), 7 deletions(-)
dlls/winex11.drv/mouse.c | 40 +++++++++++++++++++++++++++++++++-------
1 file changed, 33 insertions(+), 7 deletions(-)
diff --git a/dlls/winex11.drv/mouse.c b/dlls/winex11.drv/mouse.c
index 49734ba195b..b5cba492d7e 100644
index a2310297ff9..e1273571fe2 100644
--- a/dlls/winex11.drv/mouse.c
+++ b/dlls/winex11.drv/mouse.c
@@ -376,6 +376,10 @@ static void update_relative_valuators(XIAnyClassInfo **valuators, int n_valuator
@@ -367,6 +367,9 @@ static void update_relative_valuators(XIAnyClassInfo **valuators, int n_valuator
thread_data->x_pos_valuator.min = thread_data->x_pos_valuator.max = 0;
if (thread_data->y_pos_valuator.min >= thread_data->y_pos_valuator.max)
thread_data->y_pos_valuator.min = thread_data->y_pos_valuator.max = 0;
+
+ thread_data->x_pos_valuator.value = 0;
+ thread_data->y_pos_valuator.value = 0;
+ thread_data->wheel_valuator.value = 0;
}
#endif
@@ -1917,6 +1921,7 @@ static BOOL X11DRV_RawMotion( XGenericEventCookie *xev )
double dx = 0, dy = 0, dw = 0, val;
@@ -1906,6 +1909,7 @@ static BOOL X11DRV_RawMotion( XGenericEventCookie *xev )
double dx = 0, dy = 0, val;
double raw_dx = 0, raw_dy = 0, raw_val;
double x_scale = 1, y_scale = 1;
+ double x_accum = 0, y_accum = 0, w_accum = 0;
+ double x_accum = 0, y_accum = 0;
struct x11drv_thread_data *thread_data = x11drv_thread_data();
XIValuatorClassInfo *x_pos, *y_pos, *wheel;
XIValuatorClassInfo *x_pos, *y_pos;
@@ -1929,6 +1934,10 @@ static BOOL X11DRV_RawMotion( XGenericEventCookie *xev )
@@ -1917,6 +1921,9 @@ static BOOL X11DRV_RawMotion( XGenericEventCookie *xev )
x_pos = &thread_data->x_pos_valuator;
y_pos = &thread_data->y_pos_valuator;
wheel = &thread_data->wheel_valuator;
+ x_accum = x_pos->value;
+ y_accum = y_pos->value;
+ w_accum = wheel->value;
+
input.type = INPUT_MOUSE;
input.u.mi.mouseData = 0;
input.u.mi.dwFlags = MOUSEEVENTF_MOVE;
@@ -1956,9 +1965,9 @@ static BOOL X11DRV_RawMotion( XGenericEventCookie *xev )
@@ -1944,9 +1951,9 @@ static BOOL X11DRV_RawMotion( XGenericEventCookie *xev )
raw_dx = raw_val;
input.u.mi.dwFlags |= (x_pos->mode == XIModeAbsolute ? MOUSEEVENTF_ABSOLUTE : 0);
if (x_pos->mode == XIModeAbsolute)
@ -56,7 +54,7 @@ index 49734ba195b..b5cba492d7e 100644
}
if (i == y_pos->number)
{
@@ -1966,24 +1975,38 @@ static BOOL X11DRV_RawMotion( XGenericEventCookie *xev )
@@ -1954,18 +1961,30 @@ static BOOL X11DRV_RawMotion( XGenericEventCookie *xev )
raw_dy = raw_val;
input.u.mi.dwFlags |= (y_pos->mode == XIModeAbsolute ? MOUSEEVENTF_ABSOLUTE : 0);
if (y_pos->mode == XIModeAbsolute)
@ -66,24 +64,16 @@ index 49734ba195b..b5cba492d7e 100644
- input.u.mi.dy = dy * y_scale;
+ y_accum += dy * y_scale;
}
if (i == wheel->number)
{
dw = val;
input.u.mi.dwFlags |= MOUSEEVENTF_WHEEL;
- input.u.mi.mouseData = dw * thread_data->wheel_scale;
+ w_accum += dw * thread_data->wheel_scale;
}
}
+ /* Accumulate the fractional parts so they aren't lost after casting
+ * successive motion values to integral fields.
+ *
+ * Note: It looks like raw_dx, raw_dy and raw_dw are already
+ * Note: It looks like raw_dx, raw_dy are already
+ * integral values but that may be wrong.
+ */
+ input.u.mi.dx = (LONG)x_accum;
+ input.u.mi.dy = (LONG)y_accum;
+ input.u.mi.mouseData = (DWORD)w_accum;
+
if (broken_rawevents && is_old_motion_event( xev->serial ))
{
@ -93,29 +83,35 @@ index 49734ba195b..b5cba492d7e 100644
+ x_pos->value = x_accum - input.u.mi.dx;
+ y_pos->value = y_accum - input.u.mi.dy;
+ wheel->value = w_accum - input.u.mi.mouseData;
+
if (x_pos->mode == XIModeAbsolute)
{
TRACE( "pos %d,%d w:%d (event %f,%f,%f)\n", input.u.mi.dx, input.u.mi.dy, input.u.mi.mouseData, dx, dy, dw );
@@ -1991,8 +2014,15 @@ static BOOL X11DRV_RawMotion( XGenericEventCookie *xev )
TRACE( "pos %d,%d (event %f,%f)\n", input.u.mi.dx, input.u.mi.dy, dx, dy );
@@ -1973,14 +1992,21 @@ static BOOL X11DRV_RawMotion( XGenericEventCookie *xev )
}
else if (!thread_data->xi2_rawinput_only)
{
- TRACE( "pos %d,%d w:%d (event %f,%f,%f)\n", input.u.mi.dx, input.u.mi.dy, input.u.mi.mouseData, dx, dy, dw );
- TRACE( "pos %d,%d (event %f,%f)\n", input.u.mi.dx, input.u.mi.dy, dx, dy );
- __wine_send_input( 0, &input, SEND_HWMSG_WINDOW );
+ if ((dy || dy || dw) && !(input.u.mi.dx || input.u.mi.dy || input.u.mi.mouseData))
+ if ((dy || dy) && !(input.u.mi.dx || input.u.mi.dy))
+ {
+ TRACE( "accumulating raw motion (event %f,%f,%f accum %f,%f,%f)\n", dx, dy, dw, x_pos->value, y_pos->value, wheel->value );
+ TRACE( "accumulating raw motion (event %f,%f accum %f,%f)\n", dx, dy, x_pos->value, y_pos->value );
+ }
+ else
+ {
+ TRACE( "pos %d,%d w:%d (event %f,%f,%f)\n", input.u.mi.dx, input.u.mi.dy, input.u.mi.mouseData, dx, dy, dw );
+ TRACE( "pos %d,%d (event %f,%f)\n", input.u.mi.dx, input.u.mi.dy, dx, dy );
+ __wine_send_input( 0, &input, SEND_HWMSG_WINDOW );
+ }
}
else
{
input.u.mi.dx = raw_dx;
input.u.mi.dy = raw_dy;
- TRACE( "raw pos %d,%d (event %f,%f)\n", input.u.mi.dx, input.u.mi.dy, dx, dy );
+ TRACE( "raw pos %d,%d (event %f,%f)\n", input.u.mi.dx, input.u.mi.dy, raw_dx, raw_dy );
__wine_send_input( 0, &input, SEND_HWMSG_RAWINPUT );
}
return TRUE;
--
2.24.1

View File

@ -1,166 +0,0 @@
From f4b6ceb3c008b73dfdb89acc601da3be83c47f86 Mon Sep 17 00:00:00 2001
From: Derek Lesho <dereklesho52@Gmail.com>
Date: Fri, 26 Jul 2019 17:37:19 -0400
Subject: [PATCH 3/4] winex11.drv: Implement relative wheel input from
RawMotion events.
---
dlls/winex11.drv/mouse.c | 33 +++++++++++++++++++++++++++------
dlls/winex11.drv/x11drv.h | 3 +++
dlls/winex11.drv/x11drv_main.c | 1 +
3 files changed, 31 insertions(+), 6 deletions(-)
diff --git a/dlls/winex11.drv/mouse.c b/dlls/winex11.drv/mouse.c
index a2310297ff9..49734ba195b 100644
--- a/dlls/winex11.drv/mouse.c
+++ b/dlls/winex11.drv/mouse.c
@@ -335,11 +335,17 @@ static void update_relative_valuators(XIAnyClassInfo **valuators, int n_valuator
thread_data->x_pos_valuator.number = -1;
thread_data->y_pos_valuator.number = -1;
+ thread_data->wheel_valuator.number = -1;
+ thread_data->wheel_scale = 1;
for (i = 0; i < n_valuators; i++)
{
XIValuatorClassInfo *class = (XIValuatorClassInfo *)valuators[i];
+ XIScrollClassInfo *scroll_class = (XIScrollClassInfo *)valuators[i];
+ if (valuators[i]->type == XIScrollClass &&
+ scroll_class->scroll_type == XIScrollTypeVertical)
+ thread_data->wheel_scale = WHEEL_DELTA / scroll_class->increment;
if (valuators[i]->type != XIValuatorClass)
continue;
else if (class->label == x11drv_atom( Rel_X ) ||
@@ -350,6 +356,9 @@ static void update_relative_valuators(XIAnyClassInfo **valuators, int n_valuator
class->label == x11drv_atom( Abs_Y ) ||
(!class->label && class->number == 1))
thread_data->y_pos_valuator = *class;
+ else if (class->label == x11drv_atom( Rel_Vert_Scroll ) ||
+ (!class->label && class->number == 3 && class->mode == XIModeRelative))
+ thread_data->wheel_valuator = *class;
}
if (thread_data->x_pos_valuator.number < 0 || thread_data->y_pos_valuator.number < 0)
@@ -453,6 +462,8 @@ void X11DRV_XInput2_Disable(void)
pXISelectEvents( data->display, DefaultRootWindow( data->display ), &mask, 1 );
data->x_pos_valuator.number = -1;
data->y_pos_valuator.number = -1;
+ data->wheel_valuator.number = -1;
+ data->wheel_scale = 1;
data->xi2_core_pointer = 0;
#endif
}
@@ -1903,11 +1914,11 @@ static BOOL X11DRV_RawMotion( XGenericEventCookie *xev )
RECT virtual_rect;
INPUT input;
int i;
- double dx = 0, dy = 0, val;
+ double dx = 0, dy = 0, dw = 0, val;
double raw_dx = 0, raw_dy = 0, raw_val;
double x_scale = 1, y_scale = 1;
struct x11drv_thread_data *thread_data = x11drv_thread_data();
- XIValuatorClassInfo *x_pos, *y_pos;
+ XIValuatorClassInfo *x_pos, *y_pos, *wheel;
if (thread_data->x_pos_valuator.number < 0 || thread_data->y_pos_valuator.number < 0) return FALSE;
if (!event->valuators.mask_len) return FALSE;
@@ -1916,6 +1927,7 @@ static BOOL X11DRV_RawMotion( XGenericEventCookie *xev )
x_pos = &thread_data->x_pos_valuator;
y_pos = &thread_data->y_pos_valuator;
+ wheel = &thread_data->wheel_valuator;
input.type = INPUT_MOUSE;
input.u.mi.mouseData = 0;
@@ -1933,7 +1945,7 @@ static BOOL X11DRV_RawMotion( XGenericEventCookie *xev )
y_scale = (y_pos->mode == XIModeAbsolute ? 65535 : (virtual_rect.bottom - virtual_rect.top)) /
(y_pos->max - y_pos->min);
- for (i = 0; i <= max( x_pos->number, y_pos->number ); i++)
+ for (i = 0; i <= max( max( x_pos->number, y_pos->number ), wheel->number ); i++)
{
if (!XIMaskIsSet( event->valuators.mask, i )) continue;
val = *values++;
@@ -1958,6 +1970,12 @@ static BOOL X11DRV_RawMotion( XGenericEventCookie *xev )
else
input.u.mi.dy = dy * y_scale;
}
+ if (i == wheel->number)
+ {
+ dw = val;
+ input.u.mi.dwFlags |= MOUSEEVENTF_WHEEL;
+ input.u.mi.mouseData = dw * thread_data->wheel_scale;
+ }
}
if (broken_rawevents && is_old_motion_event( xev->serial ))
@@ -1968,19 +1986,19 @@ static BOOL X11DRV_RawMotion( XGenericEventCookie *xev )
if (x_pos->mode == XIModeAbsolute)
{
- TRACE( "pos %d,%d (event %f,%f)\n", input.u.mi.dx, input.u.mi.dy, dx, dy );
+ TRACE( "pos %d,%d w:%d (event %f,%f,%f)\n", input.u.mi.dx, input.u.mi.dy, input.u.mi.mouseData, dx, dy, dw );
__wine_send_input( 0, &input, SEND_HWMSG_RAWINPUT );
}
else if (!thread_data->xi2_rawinput_only)
{
- TRACE( "pos %d,%d (event %f,%f)\n", input.u.mi.dx, input.u.mi.dy, dx, dy );
+ TRACE( "pos %d,%d w:%d (event %f,%f,%f)\n", input.u.mi.dx, input.u.mi.dy, input.u.mi.mouseData, dx, dy, dw );
__wine_send_input( 0, &input, SEND_HWMSG_WINDOW );
}
else
{
input.u.mi.dx = raw_dx;
input.u.mi.dy = raw_dy;
- TRACE( "raw pos %d,%d (event %f,%f)\n", input.u.mi.dx, input.u.mi.dy, dx, dy );
+ TRACE( "raw pos %d,%d w:%d (event %f,%f,%f)\n", input.u.mi.dx, input.u.mi.dy, input.u.mi.mouseData, raw_dx, raw_dy, dw );
__wine_send_input( 0, &input, SEND_HWMSG_RAWINPUT );
}
return TRUE;
@@ -2009,6 +2027,9 @@ static BOOL X11DRV_RawButtonEvent( XGenericEventCookie *cookie )
if (thread_data->xi2_state != xi_enabled) return FALSE;
if (event->deviceid != thread_data->xi2_core_pointer) return FALSE;
+ /* mouse wheel is already handled by RawMotion events */
+ if (button == 3 || button == 4) return TRUE;
+
TRACE( "raw button %u (raw: %u) %s\n", button, event->detail, event->evtype == XI_RawButtonRelease ? "up" : "down" );
input.type = INPUT_MOUSE;
diff --git a/dlls/winex11.drv/x11drv.h b/dlls/winex11.drv/x11drv.h
index c4218699034..47c19a83175 100644
--- a/dlls/winex11.drv/x11drv.h
+++ b/dlls/winex11.drv/x11drv.h
@@ -341,6 +341,8 @@ struct x11drv_thread_data
enum { xi_unavailable = -1, xi_unknown, xi_disabled, xi_enabled } xi2_state; /* XInput2 state */
XIValuatorClassInfo x_pos_valuator;
XIValuatorClassInfo y_pos_valuator;
+ XIValuatorClassInfo wheel_valuator;
+ double wheel_scale;
int xi2_core_pointer; /* XInput2 core pointer id */
int xi2_rawinput_only;
#endif
@@ -429,6 +431,7 @@ enum x11drv_atoms
XATOM_RAW_CAP_HEIGHT,
XATOM_Rel_X,
XATOM_Rel_Y,
+ XATOM_Rel_Vert_Scroll,
XATOM_Abs_X,
XATOM_Abs_Y,
XATOM_WM_PROTOCOLS,
diff --git a/dlls/winex11.drv/x11drv_main.c b/dlls/winex11.drv/x11drv_main.c
index 3e8dd82654a..3ed8058fc50 100644
--- a/dlls/winex11.drv/x11drv_main.c
+++ b/dlls/winex11.drv/x11drv_main.c
@@ -144,6 +144,7 @@ static const char * const atom_names[NB_XATOMS - FIRST_XATOM] =
"RAW_CAP_HEIGHT",
"Rel X",
"Rel Y",
+ "Rel Vert Scroll",
"Abs X",
"Abs Y",
"WM_PROTOCOLS",
--
2.24.1

View File

@ -1,7 +1,7 @@
From 8304a54fbb8d34bf4278155624464d2b47ce37cf Mon Sep 17 00:00:00 2001
From cb1312120a60b6b70ac45197b0c0ac2ed834fbb6 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?R=C3=A9mi=20Bernon?= <rbernon@codeweavers.com>
Date: Mon, 26 Aug 2019 15:20:32 +0200
Subject: [PATCH 06/12] user32: Add __wine_send_input flags to hint raw input
Subject: [PATCH] user32: Add __wine_send_input flags to hint raw input
translation.
---
@ -9,13 +9,13 @@ Subject: [PATCH 06/12] user32: Add __wine_send_input flags to hint raw input
dlls/user32/user32.spec | 2 +-
dlls/wineandroid.drv/keyboard.c | 2 +-
dlls/wineandroid.drv/window.c | 4 ++--
dlls/winemac.drv/ime.c | 4 ++--
dlls/winemac.drv/ime.c | 5 +++--
dlls/winemac.drv/keyboard.c | 2 +-
dlls/winemac.drv/mouse.c | 2 +-
dlls/winex11.drv/keyboard.c | 2 +-
dlls/winex11.drv/mouse.c | 8 ++++----
include/winuser.h | 2 +-
10 files changed, 16 insertions(+), 16 deletions(-)
10 files changed, 17 insertions(+), 16 deletions(-)
diff --git a/dlls/user32/input.c b/dlls/user32/input.c
index 7d947a98d0f..97a5ada922e 100644
@ -80,10 +80,18 @@ index 2fc258dfd90..d96f001432d 100644
default:
diff --git a/dlls/winemac.drv/ime.c b/dlls/winemac.drv/ime.c
index dabe6654f98..2ed6e6f66a3 100644
index dabe6654f98..3593374a613 100644
--- a/dlls/winemac.drv/ime.c
+++ b/dlls/winemac.drv/ime.c
@@ -1427,10 +1427,10 @@ void macdrv_im_set_text(const macdrv_event *event)
@@ -42,6 +42,7 @@
#include "winuser.h"
#include "imm.h"
#include "ddk/imm.h"
+#include "wine/server.h"
WINE_DEFAULT_DEBUG_CHANNEL(imm);
@@ -1427,10 +1428,10 @@ void macdrv_im_set_text(const macdrv_event *event)
{
input.ki.wScan = chars[i];
input.ki.dwFlags = KEYEVENTF_UNICODE;
@ -123,10 +131,10 @@ index dd6443fe1ba..91cafdf1362 100644
diff --git a/dlls/winex11.drv/keyboard.c b/dlls/winex11.drv/keyboard.c
index 3c38784ebf9..7856b04c8f5 100644
index 48da12c0292..2a3bed787ab 100644
--- a/dlls/winex11.drv/keyboard.c
+++ b/dlls/winex11.drv/keyboard.c
@@ -1149,7 +1149,7 @@ static void X11DRV_send_keyboard_input( HWND hwnd, WORD vkey, WORD scan, DWORD f
@@ -1148,7 +1148,7 @@ static void X11DRV_send_keyboard_input( HWND hwnd, WORD vkey, WORD scan, DWORD f
input.u.ki.time = time;
input.u.ki.dwExtraInfo = 0;
@ -189,5 +197,5 @@ index 51c73d25c2f..10cebfa97d0 100644
#ifdef __cplusplus
--
2.24.1
2.24.0