[virt-tools-list] [PATCH 2/2] virtviewer-window: Make sure fullscreen window stays on the same monitor

Hans de Goede hdegoede at redhat.com
Wed Feb 6 16:40:41 UTC 2013


Sometimes the guest may shortly disable and then re-enable a monitor while
in fullscreen mode, this happens for example when changing display resolution
through gnome-display-properties inside the guest. This causes the client
window-manager to remap the window, and this can cause it to end up
on a different monitor.

This patch fixes this by remembering the position the window is places at
when going fullcreen and moving it there again when its gets (re-)shown.

Signed-off-by: Hans de Goede <hdegoede at redhat.com>
---
 src/virt-viewer-window.c | 15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)

diff --git a/src/virt-viewer-window.c b/src/virt-viewer-window.c
index 6adba8e..c5b485c 100644
--- a/src/virt-viewer-window.c
+++ b/src/virt-viewer-window.c
@@ -100,6 +100,7 @@ struct _VirtViewerWindowPrivate {
     gboolean grabbed;
     gboolean before_saved;
     GdkRectangle before_fullscreen;
+    GdkPoint fullscreen_coordinate;
     gboolean desktop_resize_pending;
 
     gint zoomlevel;
@@ -288,6 +289,7 @@ virt_viewer_window_init (VirtViewerWindow *self)
     priv = self->priv;
 
     priv->auto_resize = TRUE;
+    priv->fullscreen_coordinate.x = priv->fullscreen_coordinate.y = -1;
     g_value_init(&priv->accel_setting, G_TYPE_STRING);
 
     priv->notebook = virt_viewer_notebook_new();
@@ -479,6 +481,7 @@ virt_viewer_window_leave_fullscreen(VirtViewerWindow *self)
 
     gtk_check_menu_item_set_active(check, FALSE);
     priv->fullscreen = FALSE;
+    priv->fullscreen_coordinate.x = priv->fullscreen_coordinate.y = -1;
     ViewAutoDrawer_SetActive(VIEW_AUTODRAWER(priv->layout), FALSE);
     gtk_widget_show(menu);
     gtk_widget_hide(priv->toolbar);
@@ -526,8 +529,11 @@ virt_viewer_window_enter_fullscreen(VirtViewerWindow *self, gboolean move, gint
     ViewAutoDrawer_Close(VIEW_AUTODRAWER(priv->layout));
 
     /* g_debug("enter fullscreen move:%d %d+%d", move, x, y); */
-    if (move)
+    if (move) {
         gtk_window_move(GTK_WINDOW(priv->window), x, y);
+        priv->fullscreen_coordinate.x = x;
+        priv->fullscreen_coordinate.y = y;
+    }
 
     gtk_window_fullscreen(GTK_WINDOW(priv->window));
 #ifdef G_OS_WIN32
@@ -1127,6 +1133,8 @@ virt_viewer_window_set_display(VirtViewerWindow *self, VirtViewerDisplay *displa
 void
 virt_viewer_window_show(VirtViewerWindow *self)
 {
+    VirtViewerWindowPrivate *priv = self->priv;
+
     gtk_widget_show(self->priv->window);
 
     if (self->priv->display)
@@ -1136,6 +1144,11 @@ virt_viewer_window_show(VirtViewerWindow *self)
         virt_viewer_window_resize(self, FALSE);
         self->priv->desktop_resize_pending = FALSE;
     }
+
+    if (priv->fullscreen && priv->fullscreen_coordinate.x != -1)
+        gtk_window_move(GTK_WINDOW(priv->window),
+                        priv->fullscreen_coordinate.x,
+                        priv->fullscreen_coordinate.y);
 }
 
 void
-- 
1.8.1




More information about the virt-tools-list mailing list