qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Erico Nunes <ernunes@redhat.com>
To: "Kasireddy, Vivek" <vivek.kasireddy@intel.com>,
	"qemu-devel@nongnu.org" <qemu-devel@nongnu.org>
Cc: "Marc-André Lureau" <marcandre.lureau@redhat.com>
Subject: Re: [PATCH 1/2] ui/gtk: use widget size for cursor motion event
Date: Wed, 22 Mar 2023 17:10:19 +0100	[thread overview]
Message-ID: <a38996cb-1ca9-6bfd-3fb8-2ba037243472@redhat.com> (raw)
In-Reply-To: <IA0PR11MB71850EDD187027261A5D260BF8819@IA0PR11MB7185.namprd11.prod.outlook.com>

Hi Vivek,

On 21/03/2023 04:29, Kasireddy, Vivek wrote:
> Hi Erico,
> 
>>
>> 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);
> [Kasireddy, Vivek] Could you please confirm if this works in X-based compositor
> environments as well? Last time I checked (with Fedora 36 and Gnome + X), the
> get_allocated_xxx APIs were not accurate in X-based environments. Therefore,
> I restricted the above change to Wayland-based environments only:
> https://lists.nongnu.org/archive/html/qemu-devel/2022-11/msg03100.html

Yes, I tested again and it seems to work fine for me even with the gtk
ui running on X. I'm using Fedora 37.

I was not aware of that patch series though and just spent some time
debugging these ui issues. It looks like your series was missed?

I'm still debugging additional issues with cursor position calculation,
especially in wayland environments (and in particular with
vhost-user-gpu now). Do those patches address more cursor issues?

Thank you

Erico



  reply	other threads:[~2023-03-22 16:11 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
2023-03-23  5:01     ` Kasireddy, Vivek
2023-03-23 14:41       ` Marc-André Lureau
2023-03-30 14:08         ` Erico Nunes

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=a38996cb-1ca9-6bfd-3fb8-2ba037243472@redhat.com \
    --to=ernunes@redhat.com \
    --cc=marcandre.lureau@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=vivek.kasireddy@intel.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).