[metacity] xrender: move XCompositeRedirectSubwindows to MetaCompositor



commit 2603347e30d30b11668f7dd35517bc2f9a8ca82b
Author: Alberts Muktupāvels <alberts muktupavels gmail com>
Date:   Wed Mar 15 20:46:15 2017 +0200

    xrender: move XCompositeRedirectSubwindows to MetaCompositor

 src/compositor/meta-compositor-private.h |    3 ++
 src/compositor/meta-compositor-xrender.c |   19 +------------
 src/compositor/meta-compositor.c         |   43 ++++++++++++++++++++++++++++++
 3 files changed, 48 insertions(+), 17 deletions(-)
---
diff --git a/src/compositor/meta-compositor-private.h b/src/compositor/meta-compositor-private.h
index 9d6bff1..3212446 100644
--- a/src/compositor/meta-compositor-private.h
+++ b/src/compositor/meta-compositor-private.h
@@ -79,6 +79,9 @@ gboolean     meta_compositor_set_selection      (MetaCompositor  *compositor,
 
 Window       meta_compositor_get_overlay_window (MetaCompositor  *compositor);
 
+gboolean     meta_compositor_redirect_windows   (MetaCompositor  *compositor,
+                                                 GError         **error);
+
 MetaDisplay *meta_compositor_get_display        (MetaCompositor  *compositor);
 
 G_END_DECLS
diff --git a/src/compositor/meta-compositor-xrender.c b/src/compositor/meta-compositor-xrender.c
index 521b3a2..b944470 100644
--- a/src/compositor/meta-compositor-xrender.c
+++ b/src/compositor/meta-compositor-xrender.c
@@ -2474,13 +2474,11 @@ meta_compositor_xrender_finalize (GObject *object)
   MetaCompositorXRender *xrender;
   MetaDisplay *display;
   Display *xdisplay;
-  Window xroot;
   GList *index;
 
   xrender = META_COMPOSITOR_XRENDER (object);
   display = meta_compositor_get_display (META_COMPOSITOR (xrender));
   xdisplay = meta_display_get_xdisplay (display);
-  xroot = display->screen->xroot;
 
   if (xrender->prefs_listener_added)
     {
@@ -2511,8 +2509,6 @@ meta_compositor_xrender_finalize (GObject *object)
         g_free (xrender->shadows[i]->gaussian_map);
     }
 
-  XCompositeUnredirectSubwindows (xdisplay, xroot, CompositeRedirectManual);
-
   G_OBJECT_CLASS (meta_compositor_xrender_parent_class)->finalize (object);
 }
 
@@ -2527,7 +2523,6 @@ meta_compositor_xrender_manage (MetaCompositor  *compositor,
   XRenderPictureAttributes pa;
   XRenderPictFormat *visual_format;
   int screen_number = meta_screen_get_screen_number (screen);
-  Window xroot = meta_screen_get_xroot (screen);
 
   if (!meta_compositor_check_extensions (compositor, error))
     return FALSE;
@@ -2543,18 +2538,8 @@ meta_compositor_xrender_manage (MetaCompositor  *compositor,
   if (!meta_compositor_set_selection (compositor, error))
     return FALSE;
 
-  gdk_error_trap_push ();
-  XCompositeRedirectSubwindows (xdisplay, xroot, CompositeRedirectManual);
-  XSync (xdisplay, FALSE);
-
-  if (gdk_error_trap_pop ())
-    {
-      g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
-                   "Another compositing manager is running on screen %i",
-                   screen_number);
-
-      return FALSE;
-    }
+  if (!meta_compositor_redirect_windows (compositor, error))
+    return FALSE;
 
   xrender->screen = screen;
 
diff --git a/src/compositor/meta-compositor.c b/src/compositor/meta-compositor.c
index 5afa21e..55bf002 100644
--- a/src/compositor/meta-compositor.c
+++ b/src/compositor/meta-compositor.c
@@ -23,6 +23,7 @@
 #include <X11/extensions/Xfixes.h>
 
 #include "display-private.h"
+#include "errors.h"
 #include "meta-compositor-none.h"
 #include "meta-compositor-xrender.h"
 #include "meta-compositor-vulkan.h"
@@ -39,6 +40,9 @@ typedef struct
 
   /* XCompositeGetOverlayWindow */
   Window       overlay_window;
+
+  /* XCompositeRedirectSubwindows */
+  gboolean     windows_redirected;
 } MetaCompositorPrivate;
 
 enum
@@ -90,6 +94,15 @@ meta_compositor_finalize (GObject *object)
   priv = meta_compositor_get_instance_private (compositor);
   xdisplay = priv->display->xdisplay;
 
+  if (priv->windows_redirected)
+    {
+      Window xroot;
+
+      xroot = DefaultRootWindow (xdisplay);
+      XCompositeUnredirectSubwindows (xdisplay, xroot, CompositeRedirectManual);
+      priv->windows_redirected = FALSE;
+    }
+
   if (priv->overlay_window != None)
     {
       Window overlay;
@@ -501,6 +514,36 @@ meta_compositor_get_overlay_window (MetaCompositor *compositor)
   return overlay;
 }
 
+gboolean
+meta_compositor_redirect_windows (MetaCompositor  *compositor,
+                                  GError         **error)
+{
+  MetaCompositorPrivate *priv;
+  Display *xdisplay;
+  Window xroot;
+
+  priv = meta_compositor_get_instance_private (compositor);
+
+  xdisplay = priv->display->xdisplay;
+  xroot = DefaultRootWindow (xdisplay);
+
+  meta_error_trap_push (priv->display);
+  XCompositeRedirectSubwindows (xdisplay, xroot, CompositeRedirectManual);
+  XSync (xdisplay, FALSE);
+
+  if (meta_error_trap_pop_with_return (priv->display) != Success)
+    {
+      g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
+                   "Another compositing manager is running on screen %i",
+                   DefaultScreen (xdisplay));
+
+      return FALSE;
+    }
+
+  priv->windows_redirected = TRUE;
+  return TRUE;
+}
+
 MetaDisplay *
 meta_compositor_get_display (MetaCompositor *compositor)
 {


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