From: dongwon.kim@intel.com
To: qemu-devel@nongnu.org
Subject: [PATCH] ui/gtk: Enable fullscreen and zoom hotkeys for detached windows
Date: Wed, 5 Aug 2026 02:20:16 -0700 [thread overview]
Message-ID: <20260805092017.21028-1-dongwon.kim@intel.com> (raw)
From: Dongwon Kim <dongwon.kim@intel.com>
Currently, the fullscreen toggle hotkey (Ctrl+Alt+f by default) and zoom
hotkeys (Ctrl+Alt++, Ctrl+Alt+-, Ctrl+Alt+0) only function for the main
QEMU window. When a VC is detached (untabified), it loses these capabilities.
Implement toggle helpers, gd_win_full_screen and zoom helpers
(gd_win_zoom_in, gd_win_zoom_out, gd_win_zoom_fixed) and connect them
to the detached window's accelerator group in gd_menu_untabify.
Also remove a leftover debug fprintf in gd_win_grab.
Cc: Marc-André Lureau <marcandre.lureau@redhat.com>
Signed-off-by: Dongwon Kim <dongwon.kim@intel.com>
---
ui/gtk.c | 102 ++++++++++++++++++++++++++++++++++++++++++++++++++++---
1 file changed, 98 insertions(+), 4 deletions(-)
diff --git a/ui/gtk.c b/ui/gtk.c
index a723c8215d..632e302ed7 100644
--- a/ui/gtk.c
+++ b/ui/gtk.c
@@ -1547,7 +1547,6 @@ static gboolean gd_win_grab(void *opaque)
{
VirtualConsole *vc = opaque;
- fprintf(stderr, "%s: %s\n", __func__, vc->label);
if (vc->s->ptr_owner) {
gd_ungrab_pointer(vc->s);
} else {
@@ -1556,6 +1555,86 @@ static gboolean gd_win_grab(void *opaque)
return TRUE;
}
+static gboolean gd_win_full_screen(void *opaque)
+{
+ VirtualConsole *vc = opaque;
+ GdkWindow *window;
+ GdkWindowState state;
+
+ if (!vc->window || !gtk_widget_get_realized(vc->window)) {
+ return TRUE;
+ }
+
+ window = gtk_widget_get_window(vc->window);
+ if (!window) {
+ return TRUE;
+ }
+
+ state = gdk_window_get_state(window);
+
+ if (state & GDK_WINDOW_STATE_FULLSCREEN) {
+ gtk_window_unfullscreen(GTK_WINDOW(vc->window));
+
+ if (vc->type == GD_VC_GFX) {
+ vc->gfx.scale_x = vc->gfx.preferred_scale;
+ vc->gfx.scale_y = vc->gfx.preferred_scale;
+ gd_update_windowsize(vc);
+ }
+ } else {
+ if (vc->type == GD_VC_GFX) {
+ gtk_widget_set_size_request(vc->gfx.drawing_area, -1, -1);
+ }
+ gtk_window_fullscreen(GTK_WINDOW(vc->window));
+ }
+
+ gd_update_cursor(vc);
+ return TRUE;
+}
+
+static gboolean gd_win_zoom_in(void *opaque)
+{
+ VirtualConsole *vc = opaque;
+ GtkDisplayState *s = vc->s;
+
+ gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(s->zoom_fit_item),
+ FALSE);
+
+ vc->gfx.scale_x += VC_SCALE_STEP;
+ vc->gfx.scale_y += VC_SCALE_STEP;
+
+ gd_update_windowsize(vc);
+ return TRUE;
+}
+
+static gboolean gd_win_zoom_out(void *opaque)
+{
+ VirtualConsole *vc = opaque;
+ GtkDisplayState *s = vc->s;
+
+ gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(s->zoom_fit_item),
+ FALSE);
+
+ vc->gfx.scale_x -= VC_SCALE_STEP;
+ vc->gfx.scale_y -= VC_SCALE_STEP;
+
+ vc->gfx.scale_x = MAX(vc->gfx.scale_x, VC_SCALE_MIN);
+ vc->gfx.scale_y = MAX(vc->gfx.scale_y, VC_SCALE_MIN);
+
+ gd_update_windowsize(vc);
+ return TRUE;
+}
+
+static gboolean gd_win_zoom_fixed(void *opaque)
+{
+ VirtualConsole *vc = opaque;
+
+ vc->gfx.scale_x = vc->gfx.preferred_scale;
+ vc->gfx.scale_y = vc->gfx.preferred_scale;
+
+ gd_update_windowsize(vc);
+ return TRUE;
+}
+
static void gd_menu_untabify(GtkMenuItem *item, void *opaque)
{
GtkDisplayState *s = opaque;
@@ -1590,9 +1669,24 @@ static void gd_menu_untabify(GtkMenuItem *item, void *opaque)
GtkAccelGroup *ag = gtk_accel_group_new();
gtk_window_add_accel_group(GTK_WINDOW(vc->window), ag);
- GClosure *cb = g_cclosure_new_swap(G_CALLBACK(gd_win_grab),
- vc, NULL);
- gtk_accel_group_connect(ag, GDK_KEY_g, HOTKEY_MODIFIERS, 0, cb);
+ gtk_accel_group_connect(ag, GDK_KEY_g, HOTKEY_MODIFIERS, 0,
+ g_cclosure_new_swap(G_CALLBACK(gd_win_grab),
+ vc, NULL));
+ gtk_accel_group_connect(ag, GDK_KEY_f, HOTKEY_MODIFIERS, 0,
+ g_cclosure_new_swap(G_CALLBACK(gd_win_full_screen),
+ vc, NULL));
+ gtk_accel_group_connect(ag, GDK_KEY_plus, HOTKEY_MODIFIERS, 0,
+ g_cclosure_new_swap(G_CALLBACK(gd_win_zoom_in),
+ vc, NULL));
+ gtk_accel_group_connect(ag, GDK_KEY_equal, HOTKEY_MODIFIERS, 0,
+ g_cclosure_new_swap(G_CALLBACK(gd_win_zoom_in),
+ vc, NULL));
+ gtk_accel_group_connect(ag, GDK_KEY_minus, HOTKEY_MODIFIERS, 0,
+ g_cclosure_new_swap(G_CALLBACK(gd_win_zoom_out),
+ vc, NULL));
+ gtk_accel_group_connect(ag, GDK_KEY_0, HOTKEY_MODIFIERS, 0,
+ g_cclosure_new_swap(G_CALLBACK(gd_win_zoom_fixed),
+ vc, NULL));
}
gd_rebuild_vc_menu(s);
--
2.43.0
next reply other threads:[~2026-09-15 19:01 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-05 9:20 dongwon.kim [this message]
2026-08-05 9:20 ` [PATCH v2] ui/gtk: Register "Grab Input" shortcut to accel_group dongwon.kim
2026-09-17 8:23 ` [PATCH] ui/gtk: Enable fullscreen and zoom hotkeys for detached windows Marc-André Lureau
2026-09-18 1:32 ` Kim, Dongwon
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=20260805092017.21028-1-dongwon.kim@intel.com \
--to=dongwon.kim@intel.com \
--cc=qemu-devel@nongnu.org \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.