Module: wine Branch: master Commit: 949a3b891bdf16851b67ffe7fa1267bacb0382d3 URL: https://gitlab.winehq.org/wine/wine/-/commit/949a3b891bdf16851b67ffe7fa1267b...
Author: Rémi Bernon rbernon@codeweavers.com Date: Mon Jun 3 20:20:33 2024 +0200
winex11: Force the DPI context when restoring cursor clipping.
Avoiding any lossy conversion.
---
dlls/winex11.drv/event.c | 4 ++-- dlls/winex11.drv/mouse.c | 11 +++++------ dlls/winex11.drv/x11drv.h | 2 +- 3 files changed, 8 insertions(+), 9 deletions(-)
diff --git a/dlls/winex11.drv/event.c b/dlls/winex11.drv/event.c index 88863e62dd1..095820596de 100644 --- a/dlls/winex11.drv/event.c +++ b/dlls/winex11.drv/event.c @@ -772,7 +772,7 @@ static BOOL X11DRV_FocusIn( HWND hwnd, XEvent *xev )
if (event->detail == NotifyPointer) return FALSE; /* when focusing in the virtual desktop window, re-apply the cursor clipping rect */ - if (is_virtual_desktop() && hwnd == NtUserGetDesktopWindow()) retry_grab_clipping_window(); + if (is_virtual_desktop() && hwnd == NtUserGetDesktopWindow()) reapply_cursor_clipping(); if (hwnd == NtUserGetDesktopWindow()) return FALSE;
x11drv_thread_data()->keymapnotify_hwnd = hwnd; @@ -780,7 +780,7 @@ static BOOL X11DRV_FocusIn( HWND hwnd, XEvent *xev ) /* when keyboard grab is released, re-apply the cursor clipping rect */ was_grabbed = keyboard_grabbed; keyboard_grabbed = event->mode == NotifyGrab || event->mode == NotifyWhileGrabbed; - if (was_grabbed > keyboard_grabbed) retry_grab_clipping_window(); + if (was_grabbed > keyboard_grabbed) reapply_cursor_clipping(); /* ignore wm specific NotifyUngrab / NotifyGrab events w.r.t focus */ if (event->mode == NotifyGrab || event->mode == NotifyUngrab) return FALSE;
diff --git a/dlls/winex11.drv/mouse.c b/dlls/winex11.drv/mouse.c index 1196986424d..dce3c888170 100644 --- a/dlls/winex11.drv/mouse.c +++ b/dlls/winex11.drv/mouse.c @@ -458,15 +458,14 @@ void ungrab_clipping_window(void) }
/*********************************************************************** - * retry_grab_clipping_window - * - * Restore the current clip rectangle. + * reapply_cursor_clipping */ -void retry_grab_clipping_window(void) +void reapply_cursor_clipping(void) { RECT rect; - NtUserGetClipCursor( &rect ); - NtUserClipCursor( &rect ); + UINT context = NtUserSetThreadDpiAwarenessContext( NTUSER_DPI_PER_MONITOR_AWARE ); + if (NtUserGetClipCursor( &rect )) NtUserClipCursor( &rect ); + NtUserSetThreadDpiAwarenessContext( context ); }
diff --git a/dlls/winex11.drv/x11drv.h b/dlls/winex11.drv/x11drv.h index a221198ffbc..be76dd2609e 100644 --- a/dlls/winex11.drv/x11drv.h +++ b/dlls/winex11.drv/x11drv.h @@ -674,7 +674,7 @@ extern UINT get_win_monitor_dpi( HWND hwnd ); extern BOOL is_current_process_focused(void); extern void X11DRV_SetFocus( HWND hwnd ); extern void set_window_cursor( Window window, HCURSOR handle ); -extern void retry_grab_clipping_window(void); +extern void reapply_cursor_clipping(void); extern void ungrab_clipping_window(void); extern void move_resize_window( HWND hwnd, int dir ); extern void X11DRV_InitKeyboard( Display *display );