qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH 3/3] Fix zoom scale


From: liuyujun
Subject: [PATCH 3/3] Fix zoom scale
Date: Mon, 20 Feb 2023 18:13:42 +0800

Signed-off-by: Yujun <liuyujun@fingera.cn>
---
 ui/gtk.c | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/ui/gtk.c b/ui/gtk.c
index 1b43ed31e3..c4c8339d91 100644
--- a/ui/gtk.c
+++ b/ui/gtk.c
@@ -1482,9 +1482,10 @@ static void gd_menu_zoom_fixed(GtkMenuItem *item, void 
*opaque)
 {
     GtkDisplayState *s = opaque;
     VirtualConsole *vc = gd_vc_find_current(s);
+    int ws = 
gdk_window_get_scale_factor(gtk_widget_get_window(vc->gfx.drawing_area));
 
-    vc->gfx.scale_x = 1.0;
-    vc->gfx.scale_y = 1.0;
+    vc->gfx.scale_x = 1.0 / ws;
+    vc->gfx.scale_y = 1.0 / ws;
 
     gd_update_windowsize(vc);
 }
@@ -1493,13 +1494,15 @@ static void gd_menu_zoom_fit(GtkMenuItem *item, void 
*opaque)
 {
     GtkDisplayState *s = opaque;
     VirtualConsole *vc = gd_vc_find_current(s);
+    int ws = 
gdk_window_get_scale_factor(gtk_widget_get_window(vc->gfx.drawing_area));
 
     if (gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(s->zoom_fit_item))) 
{
         s->free_scale = TRUE;
     } else {
+        ws = 
gdk_window_get_scale_factor(gtk_widget_get_window(vc->gfx.drawing_area));
         s->free_scale = FALSE;
-        vc->gfx.scale_x = 1.0;
-        vc->gfx.scale_y = 1.0;
+        vc->gfx.scale_x = 1.0 / ws;
+        vc->gfx.scale_y = 1.0 / ws;
     }
 
     gd_update_windowsize(vc);
-- 
2.20.1




reply via email to

[Prev in Thread] Current Thread [Next in Thread]