From 3b6155eb533936f756d9e3e4c5802c188b7db35a Mon Sep 17 00:00:00 2001 From: Yann Droneaud Date: Tue, 24 Mar 2009 12:02:03 +0100 Subject: Check for _NET_WM_CM_Sn before trying to install ourself as composite manager Check for a selection owner of _NET_WM_CM_Sn is the first thing to do before taking ownership on it, so clients watching for selection ownership changes won't be disturbed. --- xcompmgr.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/xcompmgr.c b/xcompmgr.c index 54aaa41..bf7910b 100644 --- a/xcompmgr.c +++ b/xcompmgr.c @@ -1876,7 +1876,7 @@ usage (char *program) exit (1); } -static void +static Bool register_cm (void) { Window w; @@ -1886,6 +1886,12 @@ register_cm (void) snprintf (net_wm_cm, sizeof (net_wm_cm), "_NET_WM_CM_S%d", scr); a = XInternAtom (dpy, net_wm_cm, False); + if (XGetSelectionOwner (dpy, a) != None) + { + fprintf (stderr, "Another composite manager is already running\n"); + return False; + } + w = XCreateSimpleWindow (dpy, RootWindow (dpy, scr), 0, 0, 1, 1, 0, None, None); @@ -1893,6 +1899,8 @@ register_cm (void) NULL); XSetSelectionOwner (dpy, a, w, 0); + + return True; } int @@ -2016,7 +2024,10 @@ main (int argc, char **argv) exit (1); } - register_cm(); + if (!register_cm()) + { + exit (1); + } /* get atoms */ opacityAtom = XInternAtom (dpy, OPACITY_PROP, False); -- cgit v1.2.3