Skip to content

Commit

Permalink
winex11.drv: [HACK] XWayland workaround.
Browse files Browse the repository at this point in the history
  • Loading branch information
Guy1524 committed Sep 6, 2019
1 parent 0704e88 commit 6709734
Showing 1 changed file with 32 additions and 4 deletions.
36 changes: 32 additions & 4 deletions dlls/winex11.drv/mouse.c
Expand Up @@ -25,6 +25,7 @@
#include <X11/Xlib.h>
#include <X11/cursorfont.h>
#include <stdarg.h>
#include <stdlib.h>
#ifdef HAVE_X11_EXTENSIONS_XINPUT2_H
#include <X11/extensions/XInput2.h>
#endif
Expand Down Expand Up @@ -1784,6 +1785,17 @@ static BOOL X11DRV_DeviceChanged( XGenericEventCookie *xev )
return TRUE;
}

/* XWayland only reports normalized absolute values and raw relative values,
* all under an absolute valuator.
*/
static inline int xwayland_workaround(void)
{
static int workaround = -1;
if (workaround != -1) return workaround;
workaround = !!getenv("WAYLAND_DISPLAY");
return workaround;
}

/***********************************************************************
* X11DRV_RawMotion
*/
Expand Down Expand Up @@ -1886,13 +1898,29 @@ static BOOL X11DRV_RawMotion( XGenericEventCookie *xev )
}
if (i == x_abs->number)
{
raw_input.data.mouse.usFlags = MOUSE_MOVE_ABSOLUTE | MOUSE_VIRTUAL_DESKTOP;
raw_input.data.mouse.lLastX = raw_x = raw_val * (65536 / (x_abs->max - x_abs->min));
if (xwayland_workaround())
{
raw_input.data.mouse.usFlags = MOUSE_MOVE_RELATIVE;
raw_input.data.mouse.lLastX = raw_x = raw_val;
}
else
{
raw_input.data.mouse.usFlags = MOUSE_MOVE_ABSOLUTE | MOUSE_VIRTUAL_DESKTOP;
raw_input.data.mouse.lLastX = raw_x = raw_val * (65536 / (x_abs->max - x_abs->min));
}
}
if (i == y_abs->number)
{
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 (xwayland_workaround())
{
raw_input.data.mouse.usFlags = MOUSE_MOVE_RELATIVE;
raw_input.data.mouse.lLastY = raw_y = raw_val;
}
else
{
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)
{
Expand Down

0 comments on commit 6709734

Please sign in to comment.