Module: wine Branch: master Commit: 3d351fddeb9a04b24a81528eaca1ea2d8499042e URL: https://gitlab.winehq.org/wine/wine/-/commit/3d351fddeb9a04b24a81528eaca1ea2...
Author: Rémi Bernon rbernon@codeweavers.com Date: Mon Jun 3 20:20:33 2024 +0200
winewayland: Force the DPI context when restoring cursor clipping.
Avoiding any lossy conversion.
---
dlls/winewayland.drv/wayland_pointer.c | 11 +++++++++-- dlls/winewayland.drv/window.c | 12 +++++++++--- 2 files changed, 18 insertions(+), 5 deletions(-)
diff --git a/dlls/winewayland.drv/wayland_pointer.c b/dlls/winewayland.drv/wayland_pointer.c index df76a4e9954..1d8acaeabd2 100644 --- a/dlls/winewayland.drv/wayland_pointer.c +++ b/dlls/winewayland.drv/wayland_pointer.c @@ -659,12 +659,19 @@ clear_cursor: } }
+static void reapply_cursor_clipping(void) +{ + RECT rect; + UINT context = NtUserSetThreadDpiAwarenessContext(NTUSER_DPI_PER_MONITOR_AWARE); + if (NtUserGetClipCursor(&rect)) NtUserClipCursor(&rect); + NtUserSetThreadDpiAwarenessContext(context); +} + static void wayland_set_cursor(HWND hwnd, HCURSOR hcursor, BOOL use_hcursor) { struct wayland_pointer *pointer = &process_wayland.pointer; struct wayland_surface *surface; double scale; - RECT clip; BOOL reapply_clip = FALSE;
if ((surface = wayland_surface_lock_hwnd(hwnd))) @@ -697,7 +704,7 @@ static void wayland_set_cursor(HWND hwnd, HCURSOR hcursor, BOOL use_hcursor)
/* Reapply cursor clip since cursor visibility affects pointer constraint * behavior. */ - if (reapply_clip && NtUserGetClipCursor(&clip)) NtUserClipCursor(&clip); + if (reapply_clip) reapply_cursor_clipping(); }
/********************************************************************** diff --git a/dlls/winewayland.drv/window.c b/dlls/winewayland.drv/window.c index cd8ca76b679..73bee46cc35 100644 --- a/dlls/winewayland.drv/window.c +++ b/dlls/winewayland.drv/window.c @@ -199,12 +199,19 @@ static void wayland_win_data_get_config(struct wayland_win_data *data, conf->managed = data->managed; }
+static void reapply_cursor_clipping(void) +{ + RECT rect; + UINT context = NtUserSetThreadDpiAwarenessContext(NTUSER_DPI_PER_MONITOR_AWARE); + if (NtUserGetClipCursor(&rect )) NtUserClipCursor(&rect); + NtUserSetThreadDpiAwarenessContext(context); +} + static void wayland_win_data_update_wayland_surface(struct wayland_win_data *data) { struct wayland_surface *surface = data->wayland_surface; HWND parent = NtUserGetAncestor(data->hwnd, GA_PARENT); BOOL visible, xdg_visible; - RECT clip; WCHAR text[1024];
TRACE("hwnd=%p\n", data->hwnd); @@ -255,8 +262,7 @@ static void wayland_win_data_update_wayland_surface(struct wayland_win_data *dat
/* Size/position changes affect the effective pointer constraint, so update * it as needed. */ - if (data->hwnd == NtUserGetForegroundWindow() && NtUserGetClipCursor(&clip)) - NtUserClipCursor(&clip); + if (data->hwnd == NtUserGetForegroundWindow()) reapply_cursor_clipping();
out: TRACE("hwnd=%p surface=%p=>%p\n", data->hwnd, data->wayland_surface, surface);