diff mbox series

[2/2] ui/gtk: specify detached window's size and location

Message ID 20210719214157.5863-2-dongwon.kim@intel.com (mailing list archive)
State New, archived
Headers show
Series [1/2] ui/gtk: detach_all option for making all VCs detached upon starting | expand

Commit Message

Kim, Dongwon July 19, 2021, 9:41 p.m. UTC
Specify location and size of detached window based on top level window's
location and size info when detachment happens.

Signed-off-by: Dongwon Kim <dongwon.kim@intel.com>
---
 ui/gtk.c | 14 ++++++++++++++
 1 file changed, 14 insertions(+)
diff mbox series

Patch

diff --git a/ui/gtk.c b/ui/gtk.c
index a07e5a049e..9b4e85624a 100644
--- a/ui/gtk.c
+++ b/ui/gtk.c
@@ -1274,6 +1274,8 @@  static void gd_menu_untabify(GtkMenuItem *item, void *opaque)
 {
     GtkDisplayState *s = opaque;
     VirtualConsole *vc = gd_vc_find_current(s);
+    gint x, y, w, h;
+    int i;
 
     if (vc->type == GD_VC_GFX &&
         qemu_console_is_graphic(vc->gfx.dcl.con)) {
@@ -1284,6 +1286,18 @@  static void gd_menu_untabify(GtkMenuItem *item, void *opaque)
         gtk_widget_set_sensitive(vc->menu_item, false);
         vc->window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
         gd_widget_reparent(s->notebook, vc->window, vc->tab_item);
+        gtk_window_get_position(GTK_WINDOW(s->window), &x, &y);
+        gtk_window_get_size(GTK_WINDOW(s->window), &w, &h);
+
+        for (i = 0; i < s->nb_vcs; i++) {
+            if (vc == &s->vc[i]) {
+                break;
+            }
+        }
+
+        gtk_window_move(GTK_WINDOW(vc->window),
+                        x + w * (i % (s->nb_vcs/2) + 1), y + h * (i / (s->nb_vcs/2)));
+        gtk_window_resize(GTK_WINDOW(vc->window), w, h);
 
         g_signal_connect(vc->window, "delete-event",
                          G_CALLBACK(gd_tab_window_close), vc);