[Xfce4-commits] [xfce/xfwm4] 02/02: Rely on compositor selection

noreply at xfce.org noreply at xfce.org
Mon Mar 2 21:41:15 CET 2015


This is an automated email from the git hooks/post-receive script.

olivier pushed a commit to branch master
in repository xfce/xfwm4.

commit 2d1e2d1d9b7f1654833d5df02bf5284b7a0ca8fb
Author: Olivier Fourdan <fourdan at xfce.org>
Date:   Mon Mar 2 21:37:56 2015 +0100

    Rely on compositor selection
    
    To detect if a compositor is already running.
    
    Signed-off-by: Olivier Fourdan <fourdan at xfce.org>
---
 src/compositor.c |   45 ++++++++++++++++++++++++++++++++++-----------
 1 file changed, 34 insertions(+), 11 deletions(-)

diff --git a/src/compositor.c b/src/compositor.c
index 64c6701..f80ecd2 100644
--- a/src/compositor.c
+++ b/src/compositor.c
@@ -2863,6 +2863,34 @@ compositorHandleRandrNotify (DisplayInfo *display_info, XRRScreenChangeNotifyEve
 }
 #endif /* HAVE_RANDR */
 
+static gboolean
+compositorCheckCMSelection (ScreenInfo *screen_info)
+{
+    DisplayInfo *display_info;
+    gchar selection[32];
+    Window w;
+    Atom a;
+
+    display_info = screen_info->display_info;
+
+    /* Newer EWMH standard property "_NET_WM_CM_S<n>" */
+    g_snprintf (selection, sizeof (selection), "_NET_WM_CM_S%d", screen_info->screen);
+    a = XInternAtom (display_info->dpy, selection, FALSE);
+    if (XGetSelectionOwner (display_info->dpy, a) != None)
+    {
+        return TRUE;
+    }
+
+    /* Older property "COMPOSITING_MANAGER" */
+    a = XInternAtom (display_info->dpy, COMPOSITING_MANAGER, FALSE);
+    if (XGetSelectionOwner (display_info->dpy, a) != None)
+    {
+        return TRUE;
+    }
+
+    return FALSE;
+}
+
 static void
 compositorSetCMSelection (ScreenInfo *screen_info, Window w)
 {
@@ -3425,21 +3453,17 @@ compositorManageScreen (ScreenInfo *screen_info)
     g_return_val_if_fail (screen_info != NULL, FALSE);
     TRACE ("entering compositorManageScreen");
 
-    display_info = screen_info->display_info;
-    screen_info->compositor_active = TRUE;
-
-    gdk_error_trap_push ();
-    XCompositeRedirectSubwindows (display_info->dpy, screen_info->xroot, display_info->composite_mode);
-    XSync (display_info->dpy, FALSE);
-    xerror = gdk_error_trap_pop ();
-
-    if (xerror == BadAccess)
+    if (compositorCheckCMSelection (screen_info))
     {
         g_warning ("Another compositing manager is running on screen %i", screen_info->screen);
-        compositorUnmanageScreen (screen_info);
         return FALSE;
     }
 
+    compositorSetCMSelection (screen_info, screen_info->xfwm4_win);
+    display_info = screen_info->display_info;
+    XCompositeRedirectSubwindows (display_info->dpy, screen_info->xroot, display_info->composite_mode);
+    screen_info->compositor_active = TRUE;
+
     if (display_info->composite_mode == CompositeRedirectAutomatic)
     {
         /* That's enough for automatic compositing */
@@ -3519,7 +3543,6 @@ compositorManageScreen (ScreenInfo *screen_info)
     screen_info->damages_pending = FALSE;
 
     XClearArea (display_info->dpy, screen_info->output, 0, 0, 0, 0, TRUE);
-    compositorSetCMSelection (screen_info, screen_info->xfwm4_win);
     TRACE ("Manual compositing enabled");
 
 #ifdef HAVE_LIBDRM

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the Xfce4-commits mailing list