[PATCH v9 8/8] winex11.drv: Don't react to small slow mouse movements.
Derek Lesho
dereklesho52 at gmail.com
Fri Jul 26 18:22:59 CDT 2019
I tried to send this patch as a new email since it's now patch #8 but git
send-email still replied here for some reason, sorry.
On Fri, Jul 26, 2019 at 7:20 PM Derek Lesho <dereklesho52 at gmail.com> wrote:
> From: Jordan Galby <gravemind2a+wine at gmail.com>
>
> Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=42631
> From: Jordan Galby <gravemind2a+wine at gmail.com>
> Signed-off-by: Derek Lesho <dereklesho52 at Gmail.com>
> ---
> v9:
> - Remove accumulation of raw mouse movement, as it was incorrect and raw
> events are always whole anyway.
> - Add accumulation for the mouse-wheel.
> ---
> dlls/winex11.drv/mouse.c | 50 +++++++++++++++++++++++++++++----------
> dlls/winex11.drv/x11drv.h | 1 +
> 2 files changed, 39 insertions(+), 12 deletions(-)
>
> diff --git a/dlls/winex11.drv/mouse.c b/dlls/winex11.drv/mouse.c
> index 9259907eb5..5cd8e07e21 100644
> --- a/dlls/winex11.drv/mouse.c
> +++ b/dlls/winex11.drv/mouse.c
> @@ -259,6 +259,10 @@ static void update_relative_valuators(XIAnyClassInfo
> **valuators, int n_valuator
> thread_data->y_rel_valuator.number = -1;
> thread_data->wheel_valuator.number = -1;
>
> + thread_data->x_rel_valuator.accum = 0;
> + thread_data->y_rel_valuator.accum = 0;
> + thread_data->wheel_valuator.accum = 0;
> +
> for (i = 0; i < n_valuators; i++)
> {
> XIValuatorClassInfo *class = (XIValuatorClassInfo *)valuators[i];
> @@ -1755,8 +1759,6 @@ static BOOL X11DRV_RawMotion( XGenericEventCookie
> *xev )
> input.u.mi.dwFlags = MOUSEEVENTF_MOVE;
> input.u.mi.time = EVENT_x11_time_to_win32_time( event->time );
> input.u.mi.dwExtraInfo = 0;
> - input.u.mi.dx = 0;
> - input.u.mi.dy = 0;
>
> raw_input.header.dwType = RIM_TYPEMOUSE;
> raw_input.data.mouse.u.usButtonFlags = 0;
> @@ -1774,18 +1776,18 @@ static BOOL X11DRV_RawMotion( XGenericEventCookie
> *xev )
> raw_val = *raw_values++;
> if (i == x_rel->number)
> {
> - input.u.mi.dx = dx = val;
> + dx = val;
> if (x_rel->min < x_rel->max)
> - input.u.mi.dx = val * (virtual_rect.right -
> virtual_rect.left)
> + dx = val * (virtual_rect.right - virtual_rect.left)
> / (x_rel->max - x_rel->min);
>
> raw_input.data.mouse.lLastX = raw_dx = raw_val;
> }
> if (i == y_rel->number)
> {
> - input.u.mi.dy = dy = val;
> + dy = val;
> if (y_rel->min < y_rel->max)
> - input.u.mi.dy = val * (virtual_rect.bottom -
> virtual_rect.top)
> + dy = val * (virtual_rect.bottom - virtual_rect.top)
> / (y_rel->max - y_rel->min);
>
> raw_input.data.mouse.lLastY = raw_dy = raw_val;
> @@ -1796,20 +1798,44 @@ static BOOL X11DRV_RawMotion( XGenericEventCookie
> *xev )
>
> if (broken_rawevents && is_old_motion_event( xev->serial ))
> {
> - TRACE( "pos %d,%d old serial %lu, ignoring\n", input.u.mi.dx,
> input.u.mi.dy, xev->serial );
> + TRACE( "pos %d,%d old serial %lu, ignoring\n", (LONG) dx, (LONG)
> dy, xev->serial );
> return FALSE;
> }
>
> - if (thread_data->xi2_state == xi_extra)
> + /* Accumulate the *double* motions so sub-pixel motions
> + * wont be lost when sent/cast to *LONG* target fields.
> + */
> +
> + x_rel->accum += dx;
> + y_rel->accum += dy;
> + if (fabs(x_rel->accum) < 1.0 && fabs(y_rel->accum) < 1.0)
> {
> - TRACE( "pos %d,%d (event %f,%f)\n", input.u.mi.dx, input.u.mi.dy,
> dx, dy );
> - __wine_send_input( 0, &input );
> + TRACE( "accumulating raw motion (event %f,%f, accum %f,%f)\n",
> dx, dy, x_rel->accum, y_rel->accum );
> }
> + else
> + {
> + input.u.mi.dx = x_rel->accum;
> + input.u.mi.dy = y_rel->accum;
> + x_rel->accum -= input.u.mi.dx;
> + y_rel->accum -= input.u.mi.dy;
>
> - if (dwheel)
> + if (thread_data->xi2_state == xi_extra)
> + {
> + TRACE( "pos %d,%d (event %f,%f)\n", input.u.mi.dx,
> input.u.mi.dy, dx, dy );
> + __wine_send_input( 0, &input );
> + }
> + }
> +
> + wheel->accum += dwheel;
> + if (fabs(wheel->accum) < 1.0)
> + {
> + TRACE("accumulating wheel motion (event %f, accum %f)\n", dwheel,
> wheel->accum);
> + }
> + else
> {
> raw_input.data.mouse.u.usButtonFlags = RI_MOUSE_WHEEL;
> - raw_input.data.mouse.u.usButtonData = dwheel;
> + raw_input.data.mouse.u.usButtonData = wheel->accum;
> + wheel->accum -= dwheel;
> }
>
> TRACE("raw event %f,%f + %f\n", raw_dx, raw_dy, dwheel);
> diff --git a/dlls/winex11.drv/x11drv.h b/dlls/winex11.drv/x11drv.h
> index 8af2ebfcef..565cf83b89 100644
> --- a/dlls/winex11.drv/x11drv.h
> +++ b/dlls/winex11.drv/x11drv.h
> @@ -320,6 +320,7 @@ struct x11drv_valuator_data
> double min;
> double max;
> int number;
> + double accum;
> };
>
> struct x11drv_thread_data
> --
> 2.22.0
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.winehq.org/pipermail/wine-devel/attachments/20190726/48b2ba6a/attachment-0001.html>
More information about the wine-devel
mailing list