qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] ui/gtk: use widget size for cursor motion event
@ 2023-03-20 16:08 Erico Nunes
  2023-03-20 16:08 ` [PATCH 2/2] ui/gtk-egl: fix scaling for cursor position in scanout mode Erico Nunes
  2023-03-21  3:29 ` [PATCH 1/2] ui/gtk: use widget size for cursor motion event Kasireddy, Vivek
  0 siblings, 2 replies; 7+ messages in thread
From: Erico Nunes @ 2023-03-20 16:08 UTC (permalink / raw)
  To: qemu-devel; +Cc: Erico Nunes

The gd_motion_event size has some calculations for the cursor position,
which also take into account things like different size of the
framebuffer compared to the window size.
The use of window size makes things more difficult though, as at least
in the case of Wayland includes the size of ui elements like a menu bar
at the top of the window. This leads to a wrong position calculation by
a few pixels.
Fix it by using the size of the widget, which already returns the size
of the actual space to render the framebuffer.

Signed-off-by: Erico Nunes <ernunes@redhat.com>
---
 ui/gtk.c | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/ui/gtk.c b/ui/gtk.c
index fd82e9b1ca..d1b2a80c2b 100644
--- a/ui/gtk.c
+++ b/ui/gtk.c
@@ -868,7 +868,6 @@ static gboolean gd_motion_event(GtkWidget *widget, GdkEventMotion *motion,
 {
     VirtualConsole *vc = opaque;
     GtkDisplayState *s = vc->s;
-    GdkWindow *window;
     int x, y;
     int mx, my;
     int fbh, fbw;
@@ -881,10 +880,9 @@ static gboolean gd_motion_event(GtkWidget *widget, GdkEventMotion *motion,
     fbw = surface_width(vc->gfx.ds) * vc->gfx.scale_x;
     fbh = surface_height(vc->gfx.ds) * vc->gfx.scale_y;
 
-    window = gtk_widget_get_window(vc->gfx.drawing_area);
-    ww = gdk_window_get_width(window);
-    wh = gdk_window_get_height(window);
-    ws = gdk_window_get_scale_factor(window);
+    ww = gtk_widget_get_allocated_width(widget);
+    wh = gtk_widget_get_allocated_height(widget);
+    ws = gtk_widget_get_scale_factor(widget);
 
     mx = my = 0;
     if (ww > fbw) {
-- 
2.39.2



^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2023-03-30 14:08 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-03-20 16:08 [PATCH 1/2] ui/gtk: use widget size for cursor motion event Erico Nunes
2023-03-20 16:08 ` [PATCH 2/2] ui/gtk-egl: fix scaling for cursor position in scanout mode Erico Nunes
2023-03-21  3:29 ` [PATCH 1/2] ui/gtk: use widget size for cursor motion event Kasireddy, Vivek
2023-03-22 16:10   ` Erico Nunes
2023-03-23  5:01     ` Kasireddy, Vivek
2023-03-23 14:41       ` Marc-André Lureau
2023-03-30 14:08         ` Erico Nunes

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).