aboutsummaryrefslogtreecommitdiff
path: root/ui
diff options
context:
space:
mode:
authorErico Nunes <ernunes@redhat.com>2023-03-20 17:08:55 +0100
committerMichael Tokarev <mjt@tls.msk.ru>2023-05-31 09:43:56 +0300
commit95c9059e66526bc0f728c45516cb0366ecaeefc7 (patch)
treeb7201a68af580ae4cafa2f59697385c69e8141e1 /ui
parentb201fb8c5aca78400d4f364632fb1e19827da942 (diff)
ui/gtk: use widget size for cursor motion event
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> Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com> Acked-by: Vivek Kasireddy <vivek.kasireddy@intel.com> Message-Id: <20230320160856.364319-1-ernunes@redhat.com> (cherry picked from commit 2f31663ed4b5631b5e1c79f5cdd6463e55410eb8) Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
Diffstat (limited to 'ui')
-rw-r--r--ui/gtk.c8
1 files changed, 3 insertions, 5 deletions
diff --git a/ui/gtk.c b/ui/gtk.c
index dfaf6d33c3..e681e8c319 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) {