qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Michael Tokarev <mjt@tls.msk.ru>
To: marcandre.lureau@redhat.com, qemu-devel@nongnu.org
Cc: Weifeng Liu <weifeng.liu.z@gmail.com>,
	qemu-stable <qemu-stable@nongnu.org>
Subject: Re: [PULL 17/19] ui/gtk: Consider scaling when propagating ui info
Date: Wed, 8 Oct 2025 17:23:38 +0300	[thread overview]
Message-ID: <075bffac-c5fb-4fb7-917f-0bdd230922ed@tls.msk.ru> (raw)
In-Reply-To: <20250524173514.317886-18-marcandre.lureau@redhat.com>

On 5/24/25 20:35, marcandre.lureau@redhat.com wrote:
> From: Weifeng Liu <weifeng.liu.z@gmail.com>
> 
> The ui width and height sent to guest is supposed to be in buffer
> coordinate. Hence conversion is required.
> 
> If scaling (global window scale and zooming scale) is not respected in
> non-free-scale mode, window size could keep changing because of the
> existence of the iteration of the following steps:
> 
> 1. In resize event or configure event, a size larger (or smaller) than
>     the currently used one might be calculated due to not considering
>     scaling.
> 2. On reception of the display size change event in guest, the guest
>     might decide to do a mode setting and use the larger (or smaller)
>     mode.
> 3. When the new guest scan-out command arrives, QEMU would request the
>     window size to change to fit the new buffer size. This will trigger a
>     resize event or a configure event, making us go back to step 1.
> 
> Signed-off-by: Weifeng Liu <weifeng.liu.z@gmail.com>
> Message-ID: <20250511073337.876650-8-weifeng.liu.z@gmail.com>
> Acked-by: Gerd Hoffmann <kraxel@redhat.com>
> Acked-by: Marc-André Lureau <marcandre.lureau@redhat.com>
> ---
>   ui/gtk.c | 25 +++++++++++++++++++++++--
>   1 file changed, 23 insertions(+), 2 deletions(-)

Hi!

I just stumbled upon this change, which looks like a good candidate
for qemu-stable 10.0.x series (lts), what do you think?

Thanks,

/mjt

> diff --git a/ui/gtk.c b/ui/gtk.c
> index 47af49e387..8c4a94c8f6 100644
> --- a/ui/gtk.c
> +++ b/ui/gtk.c
> @@ -772,8 +772,21 @@ static void gd_resize_event(GtkGLArea *area,
>                               gint width, gint height, gpointer *opaque)
>   {
>       VirtualConsole *vc = (void *)opaque;
> +    double pw = width, ph = height;
> +    double sx = vc->gfx.scale_x, sy = vc->gfx.scale_y;
> +    GdkWindow *window = gtk_widget_get_window(GTK_WIDGET(area));
> +    const int gs = gdk_window_get_scale_factor(window);
>   
> -    gd_set_ui_size(vc, width, height);
> +    if (!vc->s->free_scale && !vc->s->full_screen) {
> +        pw /= sx;
> +        ph /= sy;
> +    }
> +
> +    /**
> +     * width and height here are in pixel coordinate, so we must divide it
> +     * by global window scale (gs)
> +     */
> +    gd_set_ui_size(vc, pw / gs, ph / gs);
>   }
>   
>   #endif
> @@ -1836,8 +1849,16 @@ static gboolean gd_configure(GtkWidget *widget,
>                                GdkEventConfigure *cfg, gpointer opaque)
>   {
>       VirtualConsole *vc = opaque;
> +    const double sx = vc->gfx.scale_x, sy = vc->gfx.scale_y;
> +    double width = cfg->width, height = cfg->height;
> +
> +    if (!vc->s->free_scale && !vc->s->full_screen) {
> +        width /= sx;
> +        height /= sy;
> +    }
> +
> +    gd_set_ui_size(vc, width, height);
>   
> -    gd_set_ui_size(vc, cfg->width, cfg->height);
>       return FALSE;
>   }
>   



  reply	other threads:[~2025-10-08 14:26 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-05-24 17:34 [PULL 00/19] Ui patches marcandre.lureau
2025-05-24 17:34 ` [PULL 01/19] ui/gtk: warn if setting the clipboard failed marcandre.lureau
2025-05-24 17:34 ` [PULL 02/19] ui/clipboard: use int for selection field marcandre.lureau
2025-05-24 17:34 ` [PULL 03/19] ui/clipboard: split out QemuClipboardContent marcandre.lureau
2025-05-24 17:34 ` [PULL 04/19] ui/clipboard: add vmstate_cbinfo marcandre.lureau
2025-05-24 17:34 ` [PULL 05/19] ui/clipboard: delay clipboard update when not running marcandre.lureau
2025-05-24 17:34 ` [PULL 06/19] ui/vdagent: replace Buffer with GByteArray marcandre.lureau
2025-05-24 17:35 ` [PULL 07/19] ui/vdagent: keep "connected" state marcandre.lureau
2025-05-24 17:35 ` [PULL 08/19] ui/vdagent: factor out clipboard peer registration marcandre.lureau
2025-05-24 17:35 ` [PULL 09/19] ui/vdagent: add migration support marcandre.lureau
2025-05-24 17:35 ` [PULL 10/19] ui/vdagent: remove migration blocker marcandre.lureau
2025-05-24 17:35 ` [PULL 11/19] ui/gtk: Document scale and coordinate handling marcandre.lureau
2025-05-24 17:35 ` [PULL 12/19] ui/gtk: Use consistent naming for variables in different coordinates marcandre.lureau
2025-05-24 17:35 ` [PULL 13/19] gtk/ui: Introduce helper gd_update_scale marcandre.lureau
2025-05-24 17:35 ` [PULL 14/19] ui/gtk: Update scales in fixed-scale mode when rendering GL area marcandre.lureau
2025-07-10 12:22   ` Peter Maydell
2025-07-11  7:01     ` Marc-André Lureau
2025-07-11  8:38       ` Weifeng Liu
2025-05-24 17:35 ` [PULL 15/19] ui/sdl: Consider scaling in mouse event handling marcandre.lureau
2025-05-24 17:35 ` [PULL 16/19] ui/gtk: Don't update scale in fixed scale mode in gtk-egl.c marcandre.lureau
2025-05-24 17:35 ` [PULL 17/19] ui/gtk: Consider scaling when propagating ui info marcandre.lureau
2025-10-08 14:23   ` Michael Tokarev [this message]
2025-05-24 17:35 ` [PULL 18/19] ui/gtk-gl-area: Render guest content with padding in fixed-scale mode marcandre.lureau
2025-05-24 17:35 ` [PULL 19/19] ui/gtk-egl: " marcandre.lureau
2025-05-25 15:20 ` [PULL 00/19] Ui patches Stefan Hajnoczi

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=075bffac-c5fb-4fb7-917f-0bdd230922ed@tls.msk.ru \
    --to=mjt@tls.msk.ru \
    --cc=marcandre.lureau@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-stable@nongnu.org \
    --cc=weifeng.liu.z@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).