[virt-tools-list] [PATCH virt-viewer] Don't show extra screens in fullscreen mode

Jonathon Jongsma jjongsma at redhat.com
Tue Sep 23 21:57:41 UTC 2014


When using the fullscreen display mapping configuration file, extra
monitors could end up enabled by mistake. This was because
virt_viewer_app_get_initial_monitor_for_display would end up returning
Nmonitor = Ndisplay when the display map hash lookup failed. In
reality, when a display map is specified, but the hash lookup fails,
the display should not be enabled. This function now returns -1 to
distinguish this case, and the display is not enabled when this value is
returned.
---

The implementation was apparently incomplete. This patch attempts to fix an
issue that was found during testing:
see https://bugzilla.redhat.com/show_bug.cgi?id=1129477#c9

 src/virt-viewer-app.c           | 22 ++++++++++++----------
 src/virt-viewer-session-spice.c |  3 +++
 2 files changed, 15 insertions(+), 10 deletions(-)

diff --git a/src/virt-viewer-app.c b/src/virt-viewer-app.c
index a890bf6..12d01eb 100644
--- a/src/virt-viewer-app.c
+++ b/src/virt-viewer-app.c
@@ -314,8 +314,11 @@ gint virt_viewer_app_get_initial_monitor_for_display(VirtViewerApp* self, gint d
 
     if (self->priv->initial_display_map) {
         gpointer value = NULL;
-        if (g_hash_table_lookup_extended(self->priv->initial_display_map, GINT_TO_POINTER(display), NULL, &value))
+        if (g_hash_table_lookup_extended(self->priv->initial_display_map, GINT_TO_POINTER(display), NULL, &value)) {
             monitor = GPOINTER_TO_INT(value);
+        } else {
+            monitor = -1;
+        }
     }
 
     return monitor;
@@ -326,13 +329,14 @@ app_window_try_fullscreen(VirtViewerApp *self G_GNUC_UNUSED,
                           VirtViewerWindow *win, gint nth)
 {
     GdkScreen *screen = gdk_screen_get_default();
-
-    if (nth >= gdk_screen_get_n_monitors(screen)) {
-        g_debug("skipping display %d", nth);
+    gint monitor = virt_viewer_app_get_initial_monitor_for_display(self, nth);
+    if (monitor == -1 || monitor >= gdk_screen_get_n_monitors(screen)) {
+        g_debug("skipping fullscreen for display %d", nth);
+        virt_viewer_window_hide(win);
         return;
     }
 
-    virt_viewer_window_enter_fullscreen(win, nth);
+    virt_viewer_window_enter_fullscreen(win, monitor);
 }
 
 
@@ -449,8 +453,7 @@ void virt_viewer_app_set_uuid_string(VirtViewerApp *self, const gchar *uuid_stri
 
         g_hash_table_iter_init(&iter, self->priv->windows);
         while (g_hash_table_iter_next(&iter, NULL, &value)) {
-            gint monitor = virt_viewer_app_get_initial_monitor_for_display(self, i);
-            app_window_try_fullscreen(self, VIRT_VIEWER_WINDOW(value), monitor);
+            app_window_try_fullscreen(self, VIRT_VIEWER_WINDOW(value), i);
             i++;
         }
     }
@@ -880,8 +883,7 @@ virt_viewer_app_window_new(VirtViewerApp *self, gint nth)
         virt_viewer_window_set_zoom_level(window, virt_viewer_window_get_zoom_level(self->priv->main_window));
     virt_viewer_app_set_nth_window(self, nth, window);
     if (self->priv->fullscreen)
-        app_window_try_fullscreen(self, window,
-                                  virt_viewer_app_get_initial_monitor_for_display(self, nth));
+        app_window_try_fullscreen(self, window, nth);
 
     w = virt_viewer_window_get_window(window);
     g_signal_connect(w, "hide", G_CALLBACK(viewer_window_visible_cb), self);
@@ -2104,7 +2106,7 @@ static void fullscreen_cb(gpointer key,
                           gpointer user_data)
 {
     FullscreenOptions *options = (FullscreenOptions *)user_data;
-    gint nth = virt_viewer_app_get_initial_monitor_for_display(options->app, *(gint*)key);
+    gint nth = *(gint*)key;
     VirtViewerWindow *vwin = VIRT_VIEWER_WINDOW(value);
 
     g_debug("fullscreen display %d: %d", nth, options->fullscreen);
diff --git a/src/virt-viewer-session-spice.c b/src/virt-viewer-session-spice.c
index 2323832..b856e78 100644
--- a/src/virt-viewer-session-spice.c
+++ b/src/virt-viewer-session-spice.c
@@ -807,6 +807,9 @@ virt_viewer_session_spice_fullscreen_auto_conf(VirtViewerSessionSpice *self)
 
     for (i = 0; i < ndisplays; i++) {
         gint j = virt_viewer_app_get_initial_monitor_for_display(app, i);
+        if (j == -1)
+            continue;
+
         gdk_screen_get_monitor_geometry(screen, j, &dest);
         g_debug("Set SPICE display %d to (%d,%d)-(%dx%d)",
                   i, dest.x, dest.y, dest.width, dest.height);
-- 
1.9.3




More information about the virt-tools-list mailing list