From: dongwon.kim@intel.com
To: qemu-devel@nongnu.org
Subject: [PATCH v2 1/3] ui/gtk: Enable fullscreen and zoom hotkeys for detached windows
Date: Tue, 11 Aug 2026 03:24:24 -0700 [thread overview]
Message-ID: <20260811102426.35538-2-dongwon.kim@intel.com> (raw)
In-Reply-To: <20260811102426.35538-1-dongwon.kim@intel.com>
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.
v2:
- Reuse gd_win_zoom_* in gd_menu_zoom_* to avoid duplicated scaling logic
- Guard zoom helpers against NULL or non-GFX consoles
(!vc || vc->type != GD_VC_GFX)
- Keep both GDK_KEY_plus and GDK_KEY_equal accelerators
Cc: Marc-André Lureau <marcandre.lureau@redhat.com>
Signed-off-by: Dongwon Kim <dongwon.kim@intel.com>
---
ui/gtk.c | 148 +++++++++++++++++++++++++++++++++++++++++--------------
1 file changed, 111 insertions(+), 37 deletions(-)
diff --git a/ui/gtk.c b/ui/gtk.c
index ed7ffc06b1..5427c2f174 100644
--- a/ui/gtk.c
+++ b/ui/gtk.c
@@ -1562,7 +1562,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 {
@@ -1571,6 +1570,96 @@ 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 || !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;
+
+ if (!vc || vc->type != GD_VC_GFX) {
+ return TRUE;
+ }
+
+ gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(vc->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;
+
+ if (!vc || vc->type != GD_VC_GFX) {
+ return TRUE;
+ }
+
+ gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(vc->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;
+
+ if (!vc || vc->type != GD_VC_GFX) {
+ return TRUE;
+ }
+
+ 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;
@@ -1609,9 +1698,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);
@@ -1691,17 +1795,7 @@ static void gd_menu_zoom_in(GtkMenuItem *item, void *opaque)
GtkDisplayState *s = opaque;
VirtualConsole *vc = gd_vc_find_current(s);
- if (!vc) {
- return;
- }
-
- 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);
+ gd_win_zoom_in(vc);
}
static void gd_accel_zoom_in(void *opaque)
@@ -1715,20 +1809,7 @@ static void gd_menu_zoom_out(GtkMenuItem *item, void *opaque)
GtkDisplayState *s = opaque;
VirtualConsole *vc = gd_vc_find_current(s);
- if (!vc) {
- return;
- }
-
- 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);
+ gd_win_zoom_out(vc);
}
static void gd_menu_zoom_fixed(GtkMenuItem *item, void *opaque)
@@ -1736,14 +1817,7 @@ static void gd_menu_zoom_fixed(GtkMenuItem *item, void *opaque)
GtkDisplayState *s = opaque;
VirtualConsole *vc = gd_vc_find_current(s);
- if (!vc) {
- return;
- }
-
- vc->gfx.scale_x = vc->gfx.preferred_scale;
- vc->gfx.scale_y = vc->gfx.preferred_scale;
-
- gd_update_windowsize(vc);
+ gd_win_zoom_fixed(vc);
}
static void gd_menu_zoom_fit(GtkMenuItem *item, void *opaque)
--
2.43.0
next prev parent reply other threads:[~2026-09-21 20:06 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-11 10:24 [PATCH v2 0/3] ui/gtk: Hotkey and fullscreen handling fixes dongwon.kim
2026-08-11 10:24 ` dongwon.kim [this message]
2026-08-11 10:24 ` [PATCH v2 2/3] ui/gtk: Register "Grab Input" shortcut to accel_group dongwon.kim
2026-08-11 10:24 ` [PATCH 3/3] ui/gtk: Defer initial fullscreen activation until window is mapped dongwon.kim
2026-10-07 19:09 ` [PATCH v2 0/3] ui/gtk: Hotkey and fullscreen handling fixes Kim, Dongwon
2026-10-13 10:52 ` Marc-André Lureau
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=20260811102426.35538-2-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.