diff mbox series

ui/gtk: Consider the scaling factor when getting the root coordinates

Message ID 20241105020929.3982540-1-dongwon.kim@intel.com (mailing list archive)
State New
Headers show
Series ui/gtk: Consider the scaling factor when getting the root coordinates | expand

Commit Message

Kim, Dongwon Nov. 5, 2024, 2:09 a.m. UTC
From: Vivek Kasireddy <vivek.kasireddy@intel.com>

Since gdk_window_get_root_coords() expects a position within the window,
we need to translate Guest's cooridinates to window local coordinates
by multiplying them with the scaling factor.

Cc: Marc-André Lureau <marcandre.lureau@redhat.com>
Signed-off-by: Vivek Kasireddy <vivek.kasireddy@intel.com>
Signed-off-by: Dongwon Kim <dongwon.kim@intel.com>
---
 ui/gtk.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/ui/gtk.c b/ui/gtk.c
index 8e14c2ac81..5009db59eb 100644
--- a/ui/gtk.c
+++ b/ui/gtk.c
@@ -459,7 +459,8 @@  static void gd_mouse_set(DisplayChangeListener *dcl,
 
     dpy = gtk_widget_get_display(vc->gfx.drawing_area);
     gdk_window_get_root_coords(gtk_widget_get_window(vc->gfx.drawing_area),
-                               x, y, &x_root, &y_root);
+                               x * vc->gfx.scale_x, y * vc->gfx.scale_y,
+                               &x_root, &y_root);
     gdk_device_warp(gd_get_pointer(dpy),
                     gtk_widget_get_screen(vc->gfx.drawing_area),
                     x_root, y_root);