X11: Set ICCCM property WM_CLIENT_LEADER jv
authorJan Vrany <jan.vrany@fit.cvut.cz>
Sat, 05 Sep 2015 18:58:29 +0100
branchjv
changeset 6913 12bc34f97b84
parent 6912 feaaf525e0d4
child 6914 e2d3459c6309
X11: Set ICCCM property WM_CLIENT_LEADER Specified by ICCCM, Section 5.1. Client Support for Session Management, see https://tronche.com/gui/x/icccm/sec-5.html
XWorkstation.st
--- a/XWorkstation.st	Tue Sep 01 18:09:33 2015 +0100
+++ b/XWorkstation.st	Sat Sep 05 18:58:29 2015 +0100
@@ -31,7 +31,7 @@
 		selectionFetchers selectionHandlers preWaitAction xlibTimeout
 		xlibTimeoutForWindowCreation hasConnectionBroken uniqueDeviceID
 		stxDeviceAtom uuidAtom primaryBuffer windowGroupWindow
-		maxOperationsUntilFlush operationsUntilFlush lastError'
+		maxOperationsUntilFlush operationsUntilFlush lastError wmClientLeaderAtom'
 	classVariableNames:'RawKeySymTranslation ConservativeSync MaxStringLength
 		DefaultXLibTimeout DefaultXLibTimeoutForWindowCreation
 		ErrorDBCache'
@@ -1875,12 +1875,13 @@
     XSetWindowAttributes xswa;
     XSizeHints sizehints;
     int bw, bd, bg;
-    Window newWindow, parentWindow;
+    Window newWindow, parentWindow, windowGroupWindow;
     XFontStruct *f;
     Pixmap backPixmap = (Pixmap)0;
     int flags = 0, depth, ioClass;
     Atom WmDeleteWindowAtom, WmSaveYourselfAtom, WmProtocolsAtom;
     Atom WmQuitAppAtom, MotifWMHintsAtom;
+    Atom WmClientLeaderAtom;
     Atom STXDeviceAtom, UUIDAtom;
     Atom atoms[3];
     int atomCount = 0;
@@ -2014,6 +2015,12 @@
     __cnt_view++;
 #endif
 
+    if (__isExternalAddress(windowGroupWindowId)) {
+	windowGroupWindow = __WindowVal(windowGroupWindowId);	
+    } else {
+ 	windowGroupWindow = newWindow;
+    }
+
     /*
      * define its icon and name
      * (only makes sense for topWindows)
@@ -2032,10 +2039,10 @@
 	    }
 	}
 
-	if (__isExternalAddress(windowGroupWindowId)) {
-	    wmhints.window_group = __WindowVal(windowGroupWindowId);
-	    wmhints.flags |= WindowGroupHint;
-	}
+	
+	wmhints.window_group = windowGroupWindow;
+	wmhints.flags |= WindowGroupHint;
+	
 
 	if (__isExternalAddress(wiconViewId)) {
 	    wmhints.flags |= IconWindowHint;
@@ -2069,6 +2076,9 @@
 	    WmDeleteWindowAtom = XInternAtom(dpy, "WM_DELETE_WINDOW", False);
 	    __INST(deleteWindowAtom) = __MKATOMOBJ(WmDeleteWindowAtom);
 
+	    WmClientLeaderAtom = XInternAtom(dpy, "WM_CLIENT_LEADER", False);
+	    __INST(wmClientLeaderAtom) = __MKATOMOBJ(WmClientLeaderAtom);
+
 	    UUIDAtom = XInternAtom(dpy, "UUID", False);
 	    __INST(uuidAtom) = __MKATOMOBJ(UUIDAtom);
 	    STXDeviceAtom = XInternAtom(dpy, "STX_DEVICE_ID", False);
@@ -2088,6 +2098,7 @@
 #else
 	    WmSaveYourselfAtom = 0;
 #endif
+	    WmClientLeaderAtom = __AtomVal(__INST(wmClientLeaderAtom));
 	    UUIDAtom = __AtomVal(__INST(uuidAtom));;
 	    STXDeviceAtom = __AtomVal(__INST(stxDeviceAtom));;
 	}
@@ -2120,12 +2131,19 @@
 		bcopy(__byteArrayVal(__INST(uniqueDeviceID)), uuidBytes, numUUIDBytes);
 
 		ENTER_XLIB();
-		XChangeProperty (dpy, newWindow, STXDeviceAtom, UUIDAtom, 8, PropModeReplace,
+		XChangeProperty (dpy, newWindow, STXDeviceAtom, XA_ATOM, 8, PropModeReplace,
 				 uuidBytes, numUUIDBytes );
 		LEAVE_XLIB();
 	    }
 	}
 
+	/* Required by ICCCM, 
+	 * Section 5.1. Client Support for Session Management, 
+         * https://tronche.com/gui/x/icccm/sec-5.html
+         */
+	XChangeProperty (dpy, newWindow, WmClientLeaderAtom, XA_WINDOW, 32, PropModeReplace,
+				 &windowGroupWindow, 1);
+
 #ifdef SUPPORT_MOTIF_WM_HINTS
 	/*
 	 * less decoration
@@ -13464,8 +13482,8 @@
 "
     A special window to serve as window group id. This window
     is newer mapped. This window is used
-    in XWMHints & _NET_WM_LEADER properties to define
-    application window group
+    in XWMHints, _NET_WM_LEADER and WM_CLIENT_LEADER properties 
+    to define application window group
 
     [author:]
 	Jan Vrany <jan.vrany@fit.cvut.cz>