Multihead support:  For each graphical console we'll create a gtk
window, so with multiple graphics cards installed you get a gtk window
for each.  vte tabs are attached to the console #0 window.
---
 ui/gtk.c |   40 +++++++++++++++++++++++++++-------------
 1 file changed, 27 insertions(+), 13 deletions(-)

diff --git a/ui/gtk.c b/ui/gtk.c
index 512e974..1c86054 100644
--- a/ui/gtk.c
+++ b/ui/gtk.c
@@ -159,8 +159,6 @@ typedef struct GtkDisplayState
     bool external_pause_update;
 } GtkDisplayState;
 
-static GtkDisplayState *global_state;
-
 /** Utility Functions **/
 
 static bool gd_is_grab_active(GtkDisplayState *s)
@@ -1210,7 +1208,7 @@ static void gd_connect_signals(GtkDisplayState *s)
                      G_CALLBACK(gd_leave_event), s);
 }
 
-static void gd_create_menus(GtkDisplayState *s)
+static void gd_create_menus(GtkDisplayState *s, bool vtetabs)
 {
     GtkStockItem item;
     GtkAccelGroup *accel_group;
@@ -1302,11 +1300,13 @@ static void gd_create_menus(GtkDisplayState *s)
     gtk_accel_map_add_entry("<QEMU>/View/VGA", GDK_KEY_1, GDK_CONTROL_MASK | 
GDK_MOD1_MASK);
     gtk_menu_shell_append(GTK_MENU_SHELL(s->view_menu), s->vga_item);
 
-    for (i = 0; i < nb_vcs; i++) {
-        VirtualConsole *vc = &s->vc[i];
+    if (vtetabs) {
+        for (i = 0; i < nb_vcs; i++) {
+            VirtualConsole *vc = &s->vc[i];
 
-        group = gd_vc_init(s, vc, i, group);
-        s->nb_vcs++;
+            group = gd_vc_init(s, vc, i, group);
+            s->nb_vcs++;
+        }
     }
 
     separator = gtk_separator_menu_item_new();
@@ -1336,14 +1336,13 @@ static const DisplayChangeListenerOps dcl_ops = {
     .dpy_cursor_define = gd_cursor_define,
 };
 
-void gtk_display_init(DisplayState *ds)
+static void gtk_display_init_one(DisplayState *ds, QemuConsole *con,
+                                 bool vtetabs)
 {
     GtkDisplayState *s = g_malloc0(sizeof(*s));
 
-    gtk_init(NULL, NULL);
-
     s->dcl.ops = &dcl_ops;
-    s->dcl.con = qemu_console_lookup_by_index(0);
+    s->dcl.con = con;
 
     s->window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
 #if GTK_CHECK_VERSION(3, 2, 0)
@@ -1371,7 +1370,7 @@ void gtk_display_init(DisplayState *ds)
 
     gtk_notebook_append_page(GTK_NOTEBOOK(s->notebook), s->drawing_area, 
gtk_label_new("VGA"));
 
-    gd_create_menus(s);
+    gd_create_menus(s, vtetabs);
 
     gd_connect_signals(s);
 
@@ -1400,6 +1399,21 @@ void gtk_display_init(DisplayState *ds)
     gtk_widget_show_all(s->window);
 
     register_displaychangelistener(ds, &s->dcl);
+}
 
-    global_state = s;
+void gtk_display_init(DisplayState *ds)
+{
+    QemuConsole *con;
+    int i = 0;
+
+    gtk_init(NULL, NULL);
+
+    con = qemu_console_lookup_by_index(i++);
+    gtk_display_init_one(ds, con, true);
+    while ((con = qemu_console_lookup_by_index(i++)) != NULL) {
+        if (!qemu_console_is_graphic(con)) {
+            break;
+        }
+        gtk_display_init_one(ds, con, false);
+    }
 }
-- 
1.7.9.7


Reply via email to