[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[virt-tools-list] [PATCH virt-viewer 3/6] window: wait until mapped before fullscreen



From: Marc-André Lureau <marcandre lureau redhat com>

On RHEL6, when starting virt-viewer --full-screen, metacity will
remaximize & force-fullscreen when leaving fullscreen, which prevents
user from accessing window titlebar, and end up with an incorrect
fullscreen state.

Thanks Owen Taylor for help debugging this:

<owen> elmarco: So the interesting thing here is that the "legacy" isn't
       triggered off a configure request to a particular size, mutter seems to
       constrain the window back to fullscreen size on its own when it sees a
       change to WM_NORMAL_HINTS
<owen> commit 4943d79d6844af3f7fc0a15ceadb69d95c4c5c61
<owen> Author: Peter Bloomfield <PeterBloomfield BellSouth net>
<owen> Date:   Wed Jan 20 10:59:07 2010 -0500
<owen>     prevent window self-maximisation
<owen> Is not in rhel6 metacity
<owen> So probably that's the main difference
<owen> can you just make your program not fullscreen initially but wait until
       it's mapped? (gets map-event on the toplevel)
<elmarco> owen that seems to work
<owen> I don't have a better solution to offer - sorry for the ugliness (code and
       initial mapping appearance)

https://bugzilla.redhat.com/show_bug.cgi?id=876445
---
 src/virt-viewer-window.c | 56 +++++++++++++++++++++++++-----------------------
 1 file changed, 29 insertions(+), 27 deletions(-)

diff --git a/src/virt-viewer-window.c b/src/virt-viewer-window.c
index 22aec0e..2d75e74 100644
--- a/src/virt-viewer-window.c
+++ b/src/virt-viewer-window.c
@@ -98,7 +98,6 @@ struct _VirtViewerWindowPrivate {
     GSList *accel_list;
     gboolean enable_mnemonics_save;
     gboolean grabbed;
-    gboolean before_saved;
     GdkRectangle before_fullscreen;
     gint fullscreen_monitor;
     gboolean desktop_resize_pending;
@@ -503,22 +502,21 @@ virt_viewer_window_leave_fullscreen(VirtViewerWindow *self)
 #endif
     gtk_window_unfullscreen(GTK_WINDOW(priv->window));
 
-    if (priv->before_saved) {
-        gtk_window_move(GTK_WINDOW(priv->window),
-                        priv->before_fullscreen.x,
-                        priv->before_fullscreen.y);
-        gtk_window_resize(GTK_WINDOW(priv->window),
-                          priv->before_fullscreen.width,
-                          priv->before_fullscreen.height);
-    } else {
-#ifdef G_OS_WIN32
-        /* win32 window manager isn't smart enough to place
-         * the window so that titlebar would be visible */
-        gtk_window_maximize(GTK_WINDOW(priv->window));
-#else
-        virt_viewer_display_queue_resize(priv->display);
-#endif
-    }
+    gtk_window_move(GTK_WINDOW(priv->window),
+                    priv->before_fullscreen.x,
+                    priv->before_fullscreen.y);
+    gtk_window_resize(GTK_WINDOW(priv->window),
+                      priv->before_fullscreen.width,
+                      priv->before_fullscreen.height);
+}
+
+static gboolean
+mapped(GtkWidget *widget, GdkEvent *event G_GNUC_UNUSED,
+       VirtViewerWindow *self)
+{
+    g_signal_handlers_disconnect_by_func(widget, mapped, self);
+    virt_viewer_window_enter_fullscreen(self, self->priv->fullscreen_monitor);
+    return FALSE;
 }
 
 void
@@ -530,25 +528,29 @@ virt_viewer_window_enter_fullscreen(VirtViewerWindow *self, gint monitor)
 
     if (priv->fullscreen)
         return;
-    priv->fullscreen = TRUE;
 
-    if (gtk_widget_get_realized(priv->window)) {
-        gtk_window_get_position(GTK_WINDOW(priv->window),
-                                &priv->before_fullscreen.x,
-                                &priv->before_fullscreen.y);
-        gtk_window_get_size(GTK_WINDOW(priv->window),
-                            &priv->before_fullscreen.width,
-                            &priv->before_fullscreen.height);
-        priv->before_saved = TRUE;
+    priv->fullscreen_monitor = monitor;
+
+    if (!gtk_widget_get_mapped(priv->window)) {
+        g_signal_connect(priv->window, "map-event", G_CALLBACK(mapped), self);
+        return;
     }
 
+    priv->fullscreen = TRUE;
+
+    gtk_window_get_position(GTK_WINDOW(priv->window),
+                            &priv->before_fullscreen.x,
+                            &priv->before_fullscreen.y);
+    gtk_window_get_size(GTK_WINDOW(priv->window),
+                        &priv->before_fullscreen.width,
+                        &priv->before_fullscreen.height);
+
     gtk_check_menu_item_set_active(check, TRUE);
     gtk_widget_hide(menu);
     gtk_widget_show(priv->toolbar);
     ViewAutoDrawer_SetActive(VIEW_AUTODRAWER(priv->layout), TRUE);
     ViewAutoDrawer_Close(VIEW_AUTODRAWER(priv->layout));
 
-    priv->fullscreen_monitor = monitor;
     if (priv->display)
         virt_viewer_display_set_monitor(priv->display, monitor);
     virt_viewer_window_move_to_monitor(self);
-- 
1.8.3.rc1.49.g8d97506


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]