Blame SOURCES/0004-Leave-windows-in-place-on-a-crash-respawn.patch

68333f
From 443608282901a16565ef01e70d3fb1f66beb14f5 Mon Sep 17 00:00:00 2001
68333f
From: "Owen W. Taylor" <otaylor@fishsoup.net>
68333f
Date: Tue, 8 Jul 2014 21:35:47 -0400
68333f
Subject: [PATCH 4/4] Leave windows in place on a crash respawn
68333f
68333f
When Mutter is restarted and cleans up the window positions
68333f
cleanly, we need to add gravity adjustments. We can detect
68333f
this easily.
68333f
68333f
 - Windows started before the window manager (should add
68333f
   add gravity adjustments)
68333f
 - Replacing a different window manager (should add gravity
68333f
   adjustments)
68333f
 - A crash (no adjustments needed)
68333f
68333f
In GNOME the first two cases shouldn't happen in normal
68333f
usage, so assume the third case (though that *shouldn't*
68333f
happen in normal usage either.)
68333f
---
68333f
 src/core/display.c        |  4 ++--
68333f
 src/core/screen.c         |  2 +-
68333f
 src/core/window-private.h |  3 ++-
68333f
 src/core/window.c         | 33 ++++++++++++++++++++++++++-------
68333f
 4 files changed, 31 insertions(+), 11 deletions(-)
68333f
68333f
diff --git a/src/core/display.c b/src/core/display.c
68333f
index 9ed0f6e..90888c5 100644
68333f
--- a/src/core/display.c
68333f
+++ b/src/core/display.c
68333f
@@ -2613,14 +2613,14 @@ event_callback (XEvent   *event,
68333f
               && meta_display_screen_for_root (display, event->xmap.event))
68333f
             {
68333f
               window = meta_window_new (display, event->xmap.window,
68333f
-                                        FALSE);
68333f
+                                        FALSE, FALSE);
68333f
             }
68333f
           break;
68333f
         case MapRequest:
68333f
           if (window == NULL)
68333f
             {
68333f
               window = meta_window_new (display, event->xmaprequest.window,
68333f
-                                        FALSE);
68333f
+                                        FALSE, FALSE);
68333f
             }
68333f
           /* if frame was receiver it's some malicious send event or something */
68333f
           else if (!frame_was_receiver && window)        
68333f
diff --git a/src/core/screen.c b/src/core/screen.c
68333f
index 6db3ea3..6d8d018 100644
68333f
--- a/src/core/screen.c
68333f
+++ b/src/core/screen.c
68333f
@@ -1093,7 +1093,7 @@ meta_screen_manage_all_windows (MetaScreen *screen)
68333f
       WindowInfo *info = list->data;
68333f
 
68333f
       meta_window_new_with_attrs (screen->display, info->xwindow, TRUE,
68333f
-                                  META_COMP_EFFECT_NONE,
68333f
+                                  TRUE,
68333f
                                   &info->attrs);
68333f
     }
68333f
   meta_stack_thaw (screen->stack);
68333f
diff --git a/src/core/window-private.h b/src/core/window-private.h
68333f
index e9f935f..cc77861 100644
68333f
--- a/src/core/window-private.h
68333f
+++ b/src/core/window-private.h
68333f
@@ -481,11 +481,12 @@ struct _MetaWindowClass
68333f
 
68333f
 MetaWindow* meta_window_new                (MetaDisplay *display,
68333f
                                             Window       xwindow,
68333f
+                                            gboolean     managing_screen,
68333f
                                             gboolean     must_be_viewable);
68333f
 MetaWindow* meta_window_new_with_attrs     (MetaDisplay       *display,
68333f
                                             Window             xwindow,
68333f
+                                            gboolean           managing_screen,
68333f
                                             gboolean           must_be_viewable,
68333f
-                                            MetaCompEffect     effect,
68333f
                                             XWindowAttributes *attrs);
68333f
 void        meta_window_unmanage           (MetaWindow  *window,
68333f
                                             guint32      timestamp);
68333f
diff --git a/src/core/window.c b/src/core/window.c
68333f
index 8d221e3..8a290f3 100644
68333f
--- a/src/core/window.c
68333f
+++ b/src/core/window.c
68333f
@@ -40,6 +40,7 @@
68333f
 #include "keybindings-private.h"
68333f
 #include "ui.h"
68333f
 #include "place.h"
68333f
+#include <meta/main.h>
68333f
 #include "session.h"
68333f
 #include <meta/prefs.h>
68333f
 #include "resizepopup.h"
68333f
@@ -659,6 +660,7 @@ maybe_leave_show_desktop_mode (MetaWindow *window)
68333f
 MetaWindow*
68333f
 meta_window_new (MetaDisplay *display,
68333f
                  Window       xwindow,
68333f
+                 gboolean     managing_screen,
68333f
                  gboolean     must_be_viewable)
68333f
 {
68333f
   XWindowAttributes attrs;
68333f
@@ -682,8 +684,8 @@ meta_window_new (MetaDisplay *display,
68333f
           return NULL;
68333f
        }
68333f
       window = meta_window_new_with_attrs (display, xwindow,
68333f
+                                           managing_screen,
68333f
                                            must_be_viewable,
68333f
-                                           META_COMP_EFFECT_CREATE,
68333f
                                            &attrs);
68333f
    }
68333f
   else
68333f
@@ -815,8 +817,8 @@ meta_window_should_attach_to_parent (MetaWindow *window)
68333f
 MetaWindow*
68333f
 meta_window_new_with_attrs (MetaDisplay       *display,
68333f
                             Window             xwindow,
68333f
+                            gboolean           managing_screen,
68333f
                             gboolean           must_be_viewable,
68333f
-                            MetaCompEffect     effect,
68333f
                             XWindowAttributes *attrs)
68333f
 {
68333f
   MetaWindow *window;
68333f
@@ -827,6 +829,8 @@ meta_window_new_with_attrs (MetaDisplay       *display,
68333f
   MetaMoveResizeFlags flags;
68333f
   gboolean has_shape;
68333f
   MetaScreen *screen;
68333f
+  MetaCompEffect effect =
68333f
+    managing_screen ? META_COMP_EFFECT_NONE : META_COMP_EFFECT_CREATE;
68333f
 
68333f
   g_assert (attrs != NULL);
68333f
 
68333f
@@ -1425,12 +1429,27 @@ meta_window_new_with_attrs (MetaDisplay       *display,
68333f
   else
68333f
     window->layer = META_LAYER_OVERRIDE_REDIRECT; /* otherwise set by MetaStack */
68333f
 
68333f
-  /* Put our state back where it should be,
68333f
-   * passing TRUE for is_configure_request, ICCCM says
68333f
-   * initial map is handled same as configure request
68333f
-   */
68333f
   flags =
68333f
-    META_IS_CONFIGURE_REQUEST | META_IS_MOVE_ACTION | META_IS_RESIZE_ACTION | META_IS_INITIAL_RESIZE;
68333f
+    META_IS_MOVE_ACTION | META_IS_RESIZE_ACTION | META_IS_INITIAL_RESIZE;
68333f
+
68333f
+  /* ICCCM says initial map is handled same as configure request. When
68333f
+   * we are initially managing the screen, we distinguish two cases:
68333f
+   *
68333f
+   *  Restart: in this case, we put the windows back to the unframed
68333f
+   *   position before exiting, so we need to give them gravity
68333f
+   *   adjustments.
68333f
+   *  Something else: (perhaps a crash) if we didn't exit cleanly, then
68333f
+   *   windows will be reparented by the X server so that the client
68333f
+   *   origin stays the same, and no frame adjustment is needed.
68333f
+   *
68333f
+   * We don't have any way to distinguish replacing a different window
68333f
+   * manager from respawning on crash, so when we replace a different
68333f
+   * window manager, windows will shift onscreen, but this is expected
68333f
+   * to only happen in development.
68333f
+   */
68333f
+  if (!managing_screen || meta_is_restart())
68333f
+    flags |= META_IS_CONFIGURE_REQUEST;
68333f
+
68333f
   if (!window->override_redirect)
68333f
     meta_window_move_resize_internal (window,
68333f
                                       flags,
68333f
-- 
68333f
1.9.3
68333f