From: "Daniel P. Berrangé" <berrange@redhat.com>
To: marcandre.lureau@redhat.com
Cc: qemu-devel@nongnu.org, shentey@gmail.com,
Gerd Hoffmann <kraxel@redhat.com>
Subject: Re: [PATCH v2] ui/gtk: fix cursor moved to left corner
Date: Mon, 20 Mar 2023 13:32:42 +0000 [thread overview]
Message-ID: <ZBhgen5zqT92fFyr@redhat.com> (raw)
In-Reply-To: <20230320132624.1612464-1-marcandre.lureau@redhat.com>
On Mon, Mar 20, 2023 at 05:26:24PM +0400, marcandre.lureau@redhat.com wrote:
> From: Marc-André Lureau <marcandre.lureau@redhat.com>
>
> 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
Ah, this assertion means that gdk_window_get_root_coords returns
control without setting x_root and y_root. So they contain
whatever garbage is on the stack. They could end up pointing anywhere,
and because max value of an 'int' is way larger than the screen size
they'll usually get capped at the sceen size and thus end up bottom
right corner.
>
> Fixes: 6effaa16ac98 ("ui: set cursor position upon listener
> registration")
> Reported-by: Bernhard Beschow <shentey@gmail.com>
> Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
> ---
> ui/gtk.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
>
> 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;
> }
>
> --
> 2.39.2
>
With regards,
Daniel
--
|: https://berrange.com -o- https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org -o- https://fstop138.berrange.com :|
|: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|
next prev parent reply other threads:[~2023-03-20 13:33 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-03-20 13:26 [PATCH v2] ui/gtk: fix cursor moved to left corner marcandre.lureau
2023-03-20 13:32 ` Daniel P. Berrangé [this message]
2023-03-20 22:39 ` Bernhard Beschow
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=ZBhgen5zqT92fFyr@redhat.com \
--to=berrange@redhat.com \
--cc=kraxel@redhat.com \
--cc=marcandre.lureau@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=shentey@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).