summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSam Spilsbury <smspillaz@gmail.com>2010-02-06 14:11:07 +0800
committerSam Spilsbury <smspillaz@gmail.com>2010-02-06 14:11:07 +0800
commit6829746b2bcb810b6a0cd18856c5646e6b054fbb (patch)
tree3f7c65df922d0f47db077c7b19c47f82c02c9fc2 /src
parent7b1242ae578139715f3cf75a1d4185752efc8121 (diff)
downloadzcomp-6829746b2bcb810b6a0cd18856c5646e6b054fbb.tar.gz
zcomp-6829746b2bcb810b6a0cd18856c5646e6b054fbb.tar.bz2
Properly send ClientMessage event after aquiring selections.
Send appropriate ClientMessage for both the compositing manager and the window manager. Also rework appropriate functions Forward port of e86e5bee8ee6f1f265a76fef5fb0dc4e2c56be06 to master
Diffstat (limited to 'src')
-rw-r--r--src/privatescreen.h2
-rw-r--r--src/screen.cpp55
2 files changed, 42 insertions, 15 deletions
diff --git a/src/privatescreen.h b/src/privatescreen.h
index 0f77294..124637a 100644
--- a/src/privatescreen.h
+++ b/src/privatescreen.h
@@ -288,6 +288,8 @@ class PrivateScreen : public CoreOptions {
void addScreenActions ();
+ bool aquireSelection (int scr, const char *name, Atom, Window, Time);
+
CompWindow *
focusTopMostWindow ();
diff --git a/src/screen.cpp b/src/screen.cpp
index cb40573..8acfcf5 100644
--- a/src/screen.cpp
+++ b/src/screen.cpp
@@ -4064,6 +4064,44 @@ CompScreen::CompScreen ():
}
bool
+PrivateScreen::aquireSelection (int scr,
+ const char *name,
+ Atom selection,
+ Window owner,
+ Time timestamp)
+{
+ Window root = XRootWindow (dpy, scr);
+ XEvent event;
+
+ XSetSelectionOwner (dpy, selection, owner, timestamp);
+
+ if (XGetSelectionOwner (dpy, selection) != owner)
+ {
+ compLogMessage ("core", CompLogLevelError,
+ "Could not acquire %s manager "
+ "selection on screen %d display \"%s\"",
+ name, scr, DisplayString (dpy));
+
+ return true;
+ }
+
+ /* Send client message indicating that we are now the manager */
+ event.xclient.type = ClientMessage;
+ event.xclient.window = root;
+ event.xclient.message_type = Atoms::manager;
+ event.xclient.format = 32;
+ event.xclient.data.l[0] = timestamp;
+ event.xclient.data.l[1] = selection;
+ event.xclient.data.l[2] = 0;
+ event.xclient.data.l[3] = 0;
+ event.xclient.data.l[4] = 0;
+
+ XSendEvent (dpy, root, FALSE, StructureNotifyMask, &event);
+
+ return true;
+}
+
+bool
CompScreen::init (const char *name)
{
Window focus;
@@ -4222,7 +4260,8 @@ CompScreen::init (const char *name)
XSetSelectionOwner (dpy, wmSnAtom, newWmSnOwner, wmSnTimestamp);
- if (XGetSelectionOwner (dpy, wmSnAtom) != newWmSnOwner)
+ if (!priv->aquireSelection (priv->screenNum, "window", wmSnAtom,
+ newWmSnOwner, wmSnTimestamp))
{
compLogMessage ("core", CompLogLevelError,
"Could not acquire window manager "
@@ -4234,20 +4273,6 @@ CompScreen::init (const char *name)
return false;
}
- /* Send client message indicating that we are now the WM */
- event.xclient.type = ClientMessage;
- event.xclient.window = XRootWindow (dpy, DefaultScreen (dpy));
- event.xclient.message_type = Atoms::manager;
- event.xclient.format = 32;
- event.xclient.data.l[0] = wmSnTimestamp;
- event.xclient.data.l[1] = wmSnAtom;
- event.xclient.data.l[2] = 0;
- event.xclient.data.l[3] = 0;
- event.xclient.data.l[4] = 0;
-
- XSendEvent (dpy, XRootWindow (dpy, DefaultScreen (dpy)), false,
- StructureNotifyMask, &event);
-
/* Wait for old window manager to go away */
if (currentWmSnOwner != None)
{