diff options
author | msizanoen1 <msizanoen@qtmlabs.xyz> | 2022-12-10 17:47:21 +0700 |
---|---|---|
committer | Marc-André Lureau <marcandre.lureau@gmail.com> | 2023-01-09 15:48:16 +0000 |
commit | 5e88a10dc891e3693cab76533506af0425770901 (patch) | |
tree | 4db671bf150cb54634bfb20acfcd368961b40547 | |
parent | f5cc0ca4a4a65ccc56a64b9ba451b6a3a74eec32 (diff) |
spice-widget: fix hotspot position on Wayland/HiDPI
Same as a945a3c24b11de017a3b22acb5085fec59efa662 but for Wayland.
Fixes breakage caused by GTK behavior change in
https://gitlab.gnome.org/GNOME/gtk/-/merge_requests/5159.
-rw-r--r-- | src/spice-widget.c | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/src/spice-widget.c b/src/spice-widget.c index 5f7c061..7b5b5c1 100644 --- a/src/spice-widget.c +++ b/src/spice-widget.c @@ -3044,6 +3044,11 @@ static void update_mouse_cursor(SpiceDisplay *display) gint scale_factor; gint hotspot_x, hotspot_y; +#if defined(GDK_WINDOWING_X11) || defined(GDK_WINDOWING_WAYLAND) + GdkDisplay *gdk_display = gtk_widget_get_display(GTK_WIDGET(display)); + bool should_unscale_hotspot = false; +#endif + if (G_UNLIKELY(!d->mouse_pixbuf)) { return; } @@ -3080,9 +3085,17 @@ static void update_mouse_cursor(SpiceDisplay *display) hotspot_x = d->mouse_hotspot.x * scale; hotspot_y = d->mouse_hotspot.y * scale; -#ifdef GDK_WINDOWING_X11 +#if defined(GDK_WINDOWING_X11) + should_unscale_hotspot |= GDK_IS_X11_DISPLAY(gdk_display); +#endif + +#if defined(GDK_WINDOWING_WAYLAND) + should_unscale_hotspot |= GDK_IS_WAYLAND_DISPLAY(gdk_display); +#endif + +#if defined(GDK_WINDOWING_X11) || defined(GDK_WINDOWING_WAYLAND) /* undo hotspot scaling in gdkcursor */ - if (GDK_IS_X11_DISPLAY(gtk_widget_get_display(GTK_WIDGET(display)))) { + if (should_unscale_hotspot) { hotspot_x /= scale_factor; hotspot_y /= scale_factor; } |