From 281a77df28bdea2b4c475a26d4c2d92b2d931af9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Date: Mon, 20 Mar 2023 17:26:24 +0400 Subject: [PATCH] ui/gtk: fix cursor moved to left corner MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Do not attempt to move the pointer if the widget is not yet realized. The mouse cursor is placed to the corner of the screen, on X11 at least, as x_root and y_root are then miscalculated. (this is not reproducible on Wayland, because Gtk doesn't implement device warping there) This also fixes the following warning at start: qemu: Gdk: gdk_window_get_root_coords: assertion 'GDK_IS_WINDOW (window)' failed Fixes: 6effaa16ac98 ("ui: set cursor position upon listener registration") Reported-by: Bernhard Beschow Signed-off-by: Marc-André Lureau Reviewed-by: Daniel P. Berrangé Tested-by: Bernhard Beschow Message-Id: <20230320132624.1612464-1-marcandre.lureau@redhat.com> --- ui/gtk.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ui/gtk.c b/ui/gtk.c index fd82e9b1ca..e9564f2baa 100644 --- a/ui/gtk.c +++ b/ui/gtk.c @@ -450,7 +450,8 @@ static void gd_mouse_set(DisplayChangeListener *dcl, GdkDisplay *dpy; gint x_root, y_root; - if (qemu_input_is_absolute()) { + if (!gtk_widget_get_realized(vc->gfx.drawing_area) || + qemu_input_is_absolute()) { return; }