qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] ui/gtk-egl: apply scale factor when calculating window's dimension
@ 2023-10-12 22:26 Dongwon Kim
  2023-10-16 13:44 ` Marc-André Lureau
  0 siblings, 1 reply; 2+ messages in thread
From: Dongwon Kim @ 2023-10-12 22:26 UTC (permalink / raw)
  To: qemu-devel; +Cc: Dongwon Kim, Marc-André Lureau

Scale factor needs to be applied when calculating width/height of the
GTK windows.

Cc: Marc-André Lureau <marcandre.lureau@redhat.com>
Signed-off-by: Dongwon Kim <dongwon.kim@intel.com>
---
 ui/gtk-egl.c | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/ui/gtk-egl.c b/ui/gtk-egl.c
index a1060fd80f..45c7544337 100644
--- a/ui/gtk-egl.c
+++ b/ui/gtk-egl.c
@@ -69,15 +69,16 @@ void gd_egl_draw(VirtualConsole *vc)
 #ifdef CONFIG_GBM
     QemuDmaBuf *dmabuf = vc->gfx.guest_fb.dmabuf;
 #endif
-    int ww, wh;
+    int ww, wh, ws;
 
     if (!vc->gfx.gls) {
         return;
     }
 
     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 = gdk_window_get_width(window) * ws;
+    wh = gdk_window_get_height(window) * ws;
 
     if (vc->gfx.scanout_mode) {
 #ifdef CONFIG_GBM
@@ -312,7 +313,7 @@ void gd_egl_scanout_flush(DisplayChangeListener *dcl,
 {
     VirtualConsole *vc = container_of(dcl, VirtualConsole, gfx.dcl);
     GdkWindow *window;
-    int ww, wh;
+    int ww, wh, ws;
 
     if (!vc->gfx.scanout_mode) {
         return;
@@ -325,8 +326,9 @@ void gd_egl_scanout_flush(DisplayChangeListener *dcl,
                    vc->gfx.esurface, vc->gfx.ectx);
 
     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 = gdk_window_get_width(window) * ws;
+    wh = gdk_window_get_height(window) * ws;
     egl_fb_setup_default(&vc->gfx.win_fb, ww, wh);
     if (vc->gfx.cursor_fb.texture) {
         egl_texture_blit(vc->gfx.gls, &vc->gfx.win_fb, &vc->gfx.guest_fb,
-- 
2.20.1



^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] ui/gtk-egl: apply scale factor when calculating window's dimension
  2023-10-12 22:26 [PATCH] ui/gtk-egl: apply scale factor when calculating window's dimension Dongwon Kim
@ 2023-10-16 13:44 ` Marc-André Lureau
  0 siblings, 0 replies; 2+ messages in thread
From: Marc-André Lureau @ 2023-10-16 13:44 UTC (permalink / raw)
  To: Dongwon Kim; +Cc: qemu-devel

On Fri, Oct 13, 2023 at 2:54 AM Dongwon Kim <dongwon.kim@intel.com> wrote:
>
> Scale factor needs to be applied when calculating width/height of the
> GTK windows.
>
> Cc: Marc-André Lureau <marcandre.lureau@redhat.com>
> Signed-off-by: Dongwon Kim <dongwon.kim@intel.com>

Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>

> ---
>  ui/gtk-egl.c | 14 ++++++++------
>  1 file changed, 8 insertions(+), 6 deletions(-)
>
> diff --git a/ui/gtk-egl.c b/ui/gtk-egl.c
> index a1060fd80f..45c7544337 100644
> --- a/ui/gtk-egl.c
> +++ b/ui/gtk-egl.c
> @@ -69,15 +69,16 @@ void gd_egl_draw(VirtualConsole *vc)
>  #ifdef CONFIG_GBM
>      QemuDmaBuf *dmabuf = vc->gfx.guest_fb.dmabuf;
>  #endif
> -    int ww, wh;
> +    int ww, wh, ws;
>
>      if (!vc->gfx.gls) {
>          return;
>      }
>
>      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 = gdk_window_get_width(window) * ws;
> +    wh = gdk_window_get_height(window) * ws;
>
>      if (vc->gfx.scanout_mode) {
>  #ifdef CONFIG_GBM
> @@ -312,7 +313,7 @@ void gd_egl_scanout_flush(DisplayChangeListener *dcl,
>  {
>      VirtualConsole *vc = container_of(dcl, VirtualConsole, gfx.dcl);
>      GdkWindow *window;
> -    int ww, wh;
> +    int ww, wh, ws;
>
>      if (!vc->gfx.scanout_mode) {
>          return;
> @@ -325,8 +326,9 @@ void gd_egl_scanout_flush(DisplayChangeListener *dcl,
>                     vc->gfx.esurface, vc->gfx.ectx);
>
>      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 = gdk_window_get_width(window) * ws;
> +    wh = gdk_window_get_height(window) * ws;
>      egl_fb_setup_default(&vc->gfx.win_fb, ww, wh);
>      if (vc->gfx.cursor_fb.texture) {
>          egl_texture_blit(vc->gfx.gls, &vc->gfx.win_fb, &vc->gfx.guest_fb,
> --
> 2.20.1
>
>


-- 
Marc-André Lureau


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2023-10-16 13:44 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-10-12 22:26 [PATCH] ui/gtk-egl: apply scale factor when calculating window's dimension Dongwon Kim
2023-10-16 13:44 ` Marc-André Lureau

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).