Blob Blame History Raw
From 254f2f8b03461fbb2cae39e7e11dcf52b3b684a4 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= <marcandre.lureau@gmail.com>
Date: Tue, 1 Apr 2014 18:37:28 +0200
Subject: [PATCH] Fix race with metacity in fullscreen

To avoid some races with metacity, the window should be placed as
early as possible, before it is (re)allocated & mapped (rhbz#809546).
---
 src/virt-viewer-window.c | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/src/virt-viewer-window.c b/src/virt-viewer-window.c
index 05d5fe7..a6ccaa1 100644
--- a/src/virt-viewer-window.c
+++ b/src/virt-viewer-window.c
@@ -475,7 +475,7 @@ virt_viewer_window_move_to_monitor(VirtViewerWindow *self)
     GdkRectangle mon;
     gint n = priv->fullscreen_monitor;
 
-    if (n == -1 || !priv->fullscreen)
+    if (n == -1)
         return;
 
     gdk_screen_get_monitor_geometry(gdk_screen_get_default(), n, &mon);
@@ -550,6 +550,12 @@ virt_viewer_window_enter_fullscreen(VirtViewerWindow *self, gint monitor)
     priv->fullscreen = TRUE;
 
     if (!gtk_widget_get_mapped(priv->window)) {
+        /*
+         * To avoid some races with metacity, the window should be placed
+         * as early as possible, before it is (re)allocated & mapped
+         * Position & size should not be queried yet. (rhbz#809546).
+         */
+        virt_viewer_window_move_to_monitor(self);
         g_signal_connect(priv->window, "map-event", G_CALLBACK(mapped), self);
         return;
     }
@@ -1312,7 +1318,8 @@ virt_viewer_window_show(VirtViewerWindow *self)
     if (self->priv->kiosk)
         virt_viewer_window_enable_kiosk(self);
 
-    virt_viewer_window_move_to_monitor(self);
+    if (self->priv->fullscreen)
+        virt_viewer_window_move_to_monitor(self);
 }
 
 void