Added winex11.drv-mouse-coorrds patchset

This commit is contained in:
Alistair Leslie-Hughes 2019-04-23 10:09:57 +10:00
parent 39738f05d6
commit 7cc69d7707
3 changed files with 238 additions and 0 deletions

View File

@ -356,6 +356,7 @@ patch_enable_all ()
enable_winex11_key_translation="$1"
enable_winex11_mouse_movements="$1"
enable_winex11_wglShareLists="$1"
enable_winex11_drv_mouse_coorrds="$1"
enable_winhttp_System_Proxy_Autoconfig="$1"
enable_wininet_Cleanup="$1"
enable_wininet_Http_Decoding="$1"
@ -1203,6 +1204,9 @@ patch_enable ()
winex11-wglShareLists)
enable_winex11_wglShareLists="$2"
;;
winex11.drv-mouse-coorrds)
enable_winex11_drv_mouse_coorrds="$2"
;;
winhttp-System_Proxy_Autoconfig)
enable_winhttp_System_Proxy_Autoconfig="$2"
;;
@ -7184,6 +7188,21 @@ if test "$enable_winex11_wglShareLists" -eq 1; then
) >> "$patchlist"
fi
# Patchset winex11.drv-mouse-coorrds
# |
# | This patchset fixes the following Wine bugs:
# | * [#46309] winex11.drv: Use root-relative coordinates for events, if possible.
# |
# | Modified files:
# | * dlls/winex11.drv/mouse.c
# |
if test "$enable_winex11_drv_mouse_coorrds" -eq 1; then
patch_apply winex11.drv-mouse-coorrds/0001-winex11.drv-mouse-Use-root-relative-coordinates-for-ev.patch
(
printf '%s\n' '+ { "Gabriel Ivăncescu", "winex11.drv/mouse: Use root-relative coordinates for events, if possible.", 1 },';
) >> "$patchlist"
fi
# Patchset winhttp-System_Proxy_Autoconfig
# |
# | Modified files:

View File

@ -0,0 +1,218 @@
From 292705b9649903fec512844773110b235b5ea8f8 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Gabriel=20Iv=C4=83ncescu?= <gabrielopcode@gmail.com>
Date: Thu, 20 Dec 2018 12:52:48 +0200
Subject: [PATCH] winex11.drv/mouse: Use root-relative coordinates for events,
if possible
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Some applications control their own position when they are being moved. Since
events' x and y fields are reported relative to the window, this can
apparently result in them being out of sync from the X server side and ours
(hwnd). This makes applications like Winamp go nuts when they are being
moved and move all over the place "randomly".
The solution is to use x_root and y_root instead, when the root is the
same as our root_window, which solves this issue. The final coordinates
will have to be relative to the virtual screen anyway so this actually
simplifies most of the code in send_mouse_input.
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=46309
Signed-off-by: Gabriel Ivăncescu <gabrielopcode@gmail.com>
---
dlls/winex11.drv/mouse.c | 100 ++++++++++++++++++++++++---------------
1 file changed, 62 insertions(+), 38 deletions(-)
diff --git a/dlls/winex11.drv/mouse.c b/dlls/winex11.drv/mouse.c
index d678706..b12e214 100644
--- a/dlls/winex11.drv/mouse.c
+++ b/dlls/winex11.drv/mouse.c
@@ -554,6 +554,32 @@ static BOOL is_old_motion_event( unsigned long serial )
}
+/***********************************************************************
+ * map_to_root_coords
+ *
+ * Map the window-relative coordinates so they're relative to the root.
+ */
+static POINT map_to_root_coords(HWND hwnd, Window window, int x, int y)
+{
+ struct x11drv_win_data *data;
+ POINT pt = { x, y };
+
+ if (!(data = get_win_data(hwnd))) return pt;
+ if (window == data->whole_window)
+ {
+ pt.x += data->whole_rect.left - data->client_rect.left;
+ pt.y += data->whole_rect.top - data->client_rect.top;
+ }
+
+ if (GetWindowLongW(hwnd, GWL_EXSTYLE) & WS_EX_LAYOUTRTL)
+ pt.x = data->client_rect.right - data->client_rect.left - 1 - pt.x;
+ release_win_data(data);
+ MapWindowPoints(hwnd, 0, &pt, 1);
+
+ return pt;
+}
+
+
/***********************************************************************
* send_mouse_input
*
@@ -562,7 +588,6 @@ static BOOL is_old_motion_event( unsigned long serial )
static void send_mouse_input( HWND hwnd, Window window, unsigned int state, INPUT *input )
{
struct x11drv_win_data *data;
- POINT pt;
input->type = INPUT_MOUSE;
@@ -585,32 +610,14 @@ static void send_mouse_input( HWND hwnd, Window window, unsigned int state, INPU
return;
}
- if (window != root_window)
- {
- pt.x = input->u.mi.dx;
- pt.y = input->u.mi.dy;
- }
- else pt = root_to_virtual_screen( input->u.mi.dx, input->u.mi.dy );
-
- if (!(data = get_win_data( hwnd ))) return;
-
- if (window == data->whole_window)
- {
- pt.x += data->whole_rect.left - data->client_rect.left;
- pt.y += data->whole_rect.top - data->client_rect.top;
- }
-
- if (GetWindowLongW( data->hwnd, GWL_EXSTYLE ) & WS_EX_LAYOUTRTL)
- pt.x = data->client_rect.right - data->client_rect.left - 1 - pt.x;
- MapWindowPoints( hwnd, 0, &pt, 1 );
-
- if (InterlockedExchangePointer( (void **)&cursor_window, hwnd ) != hwnd ||
- input->u.mi.time - last_cursor_change > 100)
+ if ((InterlockedExchangePointer( (void **)&cursor_window, hwnd ) != hwnd ||
+ input->u.mi.time - last_cursor_change > 100) &&
+ (data = get_win_data( hwnd )))
{
sync_window_cursor( data->whole_window );
last_cursor_change = input->u.mi.time;
+ release_win_data( data );
}
- release_win_data( data );
if (hwnd != GetDesktopWindow())
{
@@ -625,8 +632,7 @@ static void send_mouse_input( HWND hwnd, Window window, unsigned int state, INPU
/* ignore event if a button is pressed, since the mouse is then grabbed too */
!(state & (Button1Mask|Button2Mask|Button3Mask|Button4Mask|Button5Mask|Button6Mask|Button7Mask)))
{
- RECT rect;
- SetRect( &rect, pt.x, pt.y, pt.x + 1, pt.y + 1 );
+ RECT rect = { input->u.mi.dx, input->u.mi.dy, input->u.mi.dx + 1, input->u.mi.dy + 1 };
SERVER_START_REQ( update_window_zorder )
{
@@ -640,8 +646,6 @@ static void send_mouse_input( HWND hwnd, Window window, unsigned int state, INPU
SERVER_END_REQ;
}
- input->u.mi.dx = pt.x;
- input->u.mi.dy = pt.y;
__wine_send_input( hwnd, input );
}
@@ -1598,13 +1602,18 @@ BOOL X11DRV_ButtonPress( HWND hwnd, XEvent *xev )
XButtonEvent *event = &xev->xbutton;
int buttonNum = event->button - 1;
INPUT input;
+ POINT pt;
if (buttonNum >= NB_BUTTONS) return FALSE;
- TRACE( "hwnd %p/%lx button %u pos %d,%d\n", hwnd, event->window, buttonNum, event->x, event->y );
+ pt = root_to_virtual_screen(event->x_root, event->y_root);
+ if (event->root != root_window || !event->same_screen)
+ pt = map_to_root_coords(hwnd, event->window, event->x, event->y);
+
+ TRACE( "hwnd %p/%lx button %u pos %d,%d\n", hwnd, event->window, buttonNum, pt.x, pt.y );
- input.u.mi.dx = event->x;
- input.u.mi.dy = event->y;
+ input.u.mi.dx = pt.x;
+ input.u.mi.dy = pt.y;
input.u.mi.mouseData = button_down_data[buttonNum];
input.u.mi.dwFlags = button_down_flags[buttonNum] | MOUSEEVENTF_ABSOLUTE | MOUSEEVENTF_MOVE;
input.u.mi.time = EVENT_x11_time_to_win32_time( event->time );
@@ -1624,13 +1633,18 @@ BOOL X11DRV_ButtonRelease( HWND hwnd, XEvent *xev )
XButtonEvent *event = &xev->xbutton;
int buttonNum = event->button - 1;
INPUT input;
+ POINT pt;
if (buttonNum >= NB_BUTTONS || !button_up_flags[buttonNum]) return FALSE;
- TRACE( "hwnd %p/%lx button %u pos %d,%d\n", hwnd, event->window, buttonNum, event->x, event->y );
+ pt = root_to_virtual_screen(event->x_root, event->y_root);
+ if (event->root != root_window || !event->same_screen)
+ pt = map_to_root_coords(hwnd, event->window, event->x, event->y);
+
+ TRACE( "hwnd %p/%lx button %u pos %d,%d\n", hwnd, event->window, buttonNum, pt.x, pt.y );
- input.u.mi.dx = event->x;
- input.u.mi.dy = event->y;
+ input.u.mi.dx = pt.x;
+ input.u.mi.dy = pt.y;
input.u.mi.mouseData = button_up_data[buttonNum];
input.u.mi.dwFlags = button_up_flags[buttonNum] | MOUSEEVENTF_ABSOLUTE | MOUSEEVENTF_MOVE;
input.u.mi.time = EVENT_x11_time_to_win32_time( event->time );
@@ -1648,12 +1662,17 @@ BOOL X11DRV_MotionNotify( HWND hwnd, XEvent *xev )
{
XMotionEvent *event = &xev->xmotion;
INPUT input;
+ POINT pt;
+
+ pt = root_to_virtual_screen(event->x_root, event->y_root);
+ if (event->root != root_window || !event->same_screen)
+ pt = map_to_root_coords(hwnd, event->window, event->x, event->y);
TRACE( "hwnd %p/%lx pos %d,%d is_hint %d serial %lu\n",
- hwnd, event->window, event->x, event->y, event->is_hint, event->serial );
+ hwnd, event->window, pt.x, pt.y, event->is_hint, event->serial );
- input.u.mi.dx = event->x;
- input.u.mi.dy = event->y;
+ input.u.mi.dx = pt.x;
+ input.u.mi.dy = pt.y;
input.u.mi.mouseData = 0;
input.u.mi.dwFlags = MOUSEEVENTF_MOVE | MOUSEEVENTF_ABSOLUTE;
input.u.mi.time = EVENT_x11_time_to_win32_time( event->time );
@@ -1676,6 +1695,7 @@ BOOL X11DRV_EnterNotify( HWND hwnd, XEvent *xev )
{
XCrossingEvent *event = &xev->xcrossing;
INPUT input;
+ POINT pt;
TRACE( "hwnd %p/%lx pos %d,%d detail %d\n", hwnd, event->window, event->x, event->y, event->detail );
@@ -1683,8 +1703,12 @@ BOOL X11DRV_EnterNotify( HWND hwnd, XEvent *xev )
if (hwnd == x11drv_thread_data()->grab_hwnd) return FALSE;
/* simulate a mouse motion event */
- input.u.mi.dx = event->x;
- input.u.mi.dy = event->y;
+ pt = root_to_virtual_screen(event->x_root, event->y_root);
+ if (event->root != root_window || !event->same_screen)
+ pt = map_to_root_coords(hwnd, event->window, event->x, event->y);
+
+ input.u.mi.dx = pt.x;
+ input.u.mi.dy = pt.y;
input.u.mi.mouseData = 0;
input.u.mi.dwFlags = MOUSEEVENTF_MOVE | MOUSEEVENTF_ABSOLUTE;
input.u.mi.time = EVENT_x11_time_to_win32_time( event->time );
--
2.19.1

View File

@ -0,0 +1 @@
Fixes: [46309] winex11.drv: Use root-relative coordinates for events, if possible.