summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSam Spilsbury <sam.spilsbury@canonical.com>2011-01-25 22:47:25 +0800
committerSam Spilsbury <sam.spilsbury@canonical.com>2011-01-25 22:52:13 +0800
commitcd3aef51b210e78050c722f470a6cd90a8b43117 (patch)
tree4a6bf5c58577eb9a07a08649fb6a954f5cd6d715
parent2b7e7570d2d7f98869c7258aa50db1f260a5870c (diff)
downloadmobileperf-cd3aef51b210e78050c722f470a6cd90a8b43117.tar.gz
mobileperf-cd3aef51b210e78050c722f470a6cd90a8b43117.tar.bz2
Fix stacking madness
1) Don't create windows after registering for CreateNotify on the root window and then do XQueryTree after calling XCreateWindow since this will add the window to the internal stack twice (once for XQueryTree and once for the CreateNotify) 2) Enforce a full restack on all windows once we have decided what our initial stack order is - so that dock windows don't end up going underneath desktop windows 3) Immediately stack the frame window underneath the client and wait for the stacking operation to complete before reparenting since sometimes the frame window would be created and mapped at the top of the X11 stack whereas the client window would be tracked from the bottom of the stack. Remove hack to restack window within compiz since that didn't actually work.
-rw-r--r--src/screen.cpp27
-rw-r--r--src/window.cpp23
2 files changed, 32 insertions, 18 deletions
diff --git a/src/screen.cpp b/src/screen.cpp
index 96d5416..63e0c96 100644
--- a/src/screen.cpp
+++ b/src/screen.cpp
@@ -4417,6 +4417,14 @@ CompScreen::init (const char *name)
return false;
}
+ /* We only care about windows we're not going to
+ * get a CreateNotify for later, so query the tree
+ * here, init plugin screens, and then init windows */
+
+ XQueryTree (dpy, root,
+ &rootReturn, &parentReturn,
+ &children, &nchildren);
+
for (i = 0; i < SCREEN_EDGE_NUM; i++)
{
priv->screenEdge[i].id = None;
@@ -4563,12 +4571,7 @@ CompScreen::init (const char *name)
if (priv->dirtyPluginList)
priv->updatePlugins ();
- priv->vpSize.setWidth (priv->optionGetHsize ());
- priv->vpSize.setHeight (priv->optionGetVsize ());
-
- XQueryTree (dpy, priv->root,
- &rootReturn, &parentReturn,
- &children, &nchildren);
+ /* Start initializing windows here */
for (unsigned int i = 0; i < nchildren; i++)
{
@@ -4594,13 +4597,23 @@ CompScreen::init (const char *name)
}
}
+ /* enforce restack on all windows */
+ for (CompWindowList::reverse_iterator rit = priv->windows.rbegin ();
+ rit != priv->windows.rend (); rit++)
+ children[i] = (*rit)->id ();
+
+ XRestackWindows (dpy, children, i);
+
+ XFree (children);
+
foreach (CompWindow *w, priv->windows)
{
if (w->isViewable ())
w->priv->activeNum = priv->activeNum++;
}
- XFree (children);
+ priv->vpSize.setWidth (priv->optionGetHsize ());
+ priv->vpSize.setHeight (priv->optionGetVsize ());
XGetInputFocus (dpy, &focus, &revertTo);
diff --git a/src/window.cpp b/src/window.cpp
index 5bd5fd1..b043fa5 100644
--- a/src/window.cpp
+++ b/src/window.cpp
@@ -5654,8 +5654,6 @@ PrivateWindow::reparent ()
int mask;
CompWindow::Geometry sg = serverGeometry;
Display *dpy = screen->dpy ();
- CompWindow *sibling = window->next ? window->next : window->prev;
- bool above = window->next ? false : true;
Window root_ret;
unsigned int uidummy;
int idummy;
@@ -5705,7 +5703,19 @@ PrivateWindow::reparent ()
sg.width (), sg.height (), 0, attrib.depth,
InputOutput, visual, mask, &attr);
+ xwc.stack_mode = Below;
+ xwc.sibling = id;
+
+ /* Make sure the frame is underneath the client */
+ XConfigureWindow (dpy, frame, CWSibling | CWStackMode, &xwc);
+
+ /* Wait for the restacking to finish */
+ XSync (dpy, false);
+
+ /* Always need to have the wrapper window mapped */
XMapWindow (dpy, wrapper);
+
+ /* Reparent the client into the wrapper window */
XReparentWindow (dpy, id, wrapper, 0, 0);
attr.event_mask = PropertyChangeMask | FocusChangeMask |
@@ -5759,15 +5769,6 @@ PrivateWindow::reparent ()
updatePassiveButtonGrabs ();
- /* Try to use a relative window as a stacking anchor point */
- if (sibling)
- {
- if (above)
- window->restackAbove (sibling);
- else
- priv->restack (sibling->id ());
- }
-
window->windowNotify (CompWindowNotifyReparent);
return true;