Module: wine Branch: master Commit: 40f101e2884298045f52097b45a562b1054aab9e URL: https://source.winehq.org/git/wine.git/?a=commit;h=40f101e2884298045f52097b4...
Author: Rémi Bernon rbernon@codeweavers.com Date: Thu Mar 25 19:00:18 2021 +0100
winex11.drv: Introduce new map_event_coords helper.
Based on a patch from Gabriel Ivăncescu gabrielopcode@gmail.com.
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=46309 Signed-off-by: Rémi Bernon rbernon@codeweavers.com Signed-off-by: Gabriel Ivăncescu gabrielopcode@gmail.com Signed-off-by: Alexandre Julliard julliard@winehq.org
---
dlls/winex11.drv/mouse.c | 46 +++++++++++++++++++++++++++++----------------- 1 file changed, 29 insertions(+), 17 deletions(-)
diff --git a/dlls/winex11.drv/mouse.c b/dlls/winex11.drv/mouse.c index dd25f8b172c..8a379e5a3b7 100644 --- a/dlls/winex11.drv/mouse.c +++ b/dlls/winex11.drv/mouse.c @@ -587,6 +587,34 @@ static BOOL is_old_motion_event( unsigned long serial ) }
+/*********************************************************************** + * map_event_coords + * + * Map the input event coordinates so they're relative to the desktop. + */ +static POINT map_event_coords( HWND hwnd, Window window, struct x11drv_win_data *data, const INPUT *input ) +{ + POINT pt = { input->u.mi.dx, input->u.mi.dy }; + + TRACE( "hwnd %p, window %lx, data %p, input %p\n", hwnd, window, data, input ); + + if (window == root_window) pt = root_to_virtual_screen( pt.x, pt.y ); + 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; + MapWindowPoints( hwnd, 0, &pt, 1 ); + + TRACE( "mapped %s to %s\n", wine_dbgstr_point( (POINT *)&input->u.mi.dx ), wine_dbgstr_point( &pt ) ); + + return pt; +} + + /*********************************************************************** * send_mouse_input * @@ -618,24 +646,8 @@ 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 ); + pt = map_event_coords( hwnd, window, data, input );
if (InterlockedExchangePointer( (void **)&cursor_window, hwnd ) != hwnd || input->u.mi.time - last_cursor_change > 100)