From: Rémi Bernon rbernon@codeweavers.com
Instead of NtUserMapWindowPoints, which will be problematic with display settings virtualization. --- dlls/winex11.drv/event.c | 49 +++++++++++++++++++++++----------------- 1 file changed, 28 insertions(+), 21 deletions(-)
diff --git a/dlls/winex11.drv/event.c b/dlls/winex11.drv/event.c index 048375e5adb..2533ab58ff1 100644 --- a/dlls/winex11.drv/event.c +++ b/dlls/winex11.drv/event.c @@ -1021,6 +1021,33 @@ static BOOL X11DRV_ReparentNotify( HWND hwnd, XEvent *xev ) return TRUE; }
+/* map XConfigureNotify event coordinates to parent-relative monitor DPI coordinates */ +static POINT map_configure_event_coords( struct x11drv_win_data *data, XConfigureEvent *event ) +{ + Window child, parent = data->embedder ? data->embedder : root_window; + POINT pos; + + if (parent == DefaultRootWindow( event->display )) + { + pos.x = event->x; + pos.y = event->y; + } + else if (event->send_event) + { + /* synthetic events are always in root coords */ + XTranslateCoordinates( event->display, DefaultRootWindow( event->display ), parent, + event->x, event->y, (int *)&pos.x, (int *)&pos.y, &child ); + } + else + { + /* query the current window position, events are relative to their parent */ + XTranslateCoordinates( event->display, event->window, parent, 0, 0, + (int *)&pos.x, (int *)&pos.y, &child ); + } + + if (parent == root_window) pos = root_to_virtual_screen( pos.x, pos.y ); + return pos; +}
/*********************************************************************** * X11DRV_ConfigureNotify @@ -1032,8 +1059,6 @@ static BOOL X11DRV_ConfigureNotify( HWND hwnd, XEvent *xev ) RECT rect; POINT pos; UINT flags; - HWND parent; - BOOL root_coords; int cx, cy, x = event->x, y = event->y; DWORD style;
@@ -1053,27 +1078,9 @@ static BOOL X11DRV_ConfigureNotify( HWND hwnd, XEvent *xev )
/* Get geometry */
- parent = NtUserGetAncestor( hwnd, GA_PARENT ); - root_coords = event->send_event; /* synthetic events are always in root coords */ - - if (!root_coords && parent == NtUserGetDesktopWindow()) /* normal event, map coordinates to the root */ - { - Window child; - XTranslateCoordinates( event->display, event->window, root_window, - 0, 0, &x, &y, &child ); - root_coords = TRUE; - } - - if (!root_coords) - { - pos.x = x; - pos.y = y; - } - else pos = root_to_virtual_screen( x, y ); - + pos = map_configure_event_coords( data, event ); SetRect( &rect, pos.x, pos.y, pos.x + event->width, pos.y + event->height ); rect = window_rect_from_visible( &data->rects, rect ); - if (root_coords) NtUserMapWindowPoints( 0, parent, (POINT *)&rect, 2, 0 /* per-monitor DPI */ );
TRACE( "win %p/%lx new X rect %d,%d,%dx%d (event %d,%d,%dx%d)\n", hwnd, data->whole_window, (int)rect.left, (int)rect.top,