summaryrefslogtreecommitdiff
path: root/src/window.cpp
diff options
context:
space:
mode:
authorSam Spilsbury <smspillaz@gmail.com>2010-02-03 11:16:12 +0800
committerSam Spilsbury <smspillaz@gmail.com>2010-02-03 11:16:12 +0800
commita6e62e23a2065e8ce2aa265ee73cba052895ff9c (patch)
treec1d7a5a5e70be86774b8deb9e2f655de8eacbf96 /src/window.cpp
parente259d46920b561b13e3a45c5b902c8cf093d2afb (diff)
downloadunity-window-decorator-a6e62e23a2065e8ce2aa265ee73cba052895ff9c.tar.gz
unity-window-decorator-a6e62e23a2065e8ce2aa265ee73cba052895ff9c.tar.bz2
Activate the topmost window when lowering a window, unless click-to-focus is off.
Forward port of 85ba708cb894658c9bf9862a311010a9b79ec6f2 to master
Diffstat (limited to 'src/window.cpp')
-rw-r--r--src/window.cpp51
1 files changed, 51 insertions, 0 deletions
diff --git a/src/window.cpp b/src/window.cpp
index 3bbe71d..4ce36cc 100644
--- a/src/window.cpp
+++ b/src/window.cpp
@@ -3030,11 +3030,62 @@ CompWindow::raise ()
configureXWindow (mask, &xwc);
}
+CompWindow *
+PrivateScreen::focusTopMostWindow ()
+{
+ CompWindow *focus = NULL;
+ CompWindowList::reverse_iterator it = windows.rbegin ();
+
+ for (; it != windows.rend (); it++)
+ {
+ CompWindow *w = *it;
+
+ if (w->type () & CompWindowTypeDockMask)
+ continue;
+
+ if (w->focus ())
+ {
+ focus = w;
+ break;
+ }
+ }
+
+ if (focus)
+ {
+ if (focus->id () != activeWindow)
+ focus->moveInputFocusTo ();
+ }
+ else
+ XSetInputFocus (dpy, root, RevertToPointerRoot,
+ CurrentTime);
+ return focus;
+}
+
+
void
CompWindow::lower ()
{
XWindowChanges xwc;
int mask;
+
+ /* when lowering a window, focus the topmost window if
+ the click-to-focus option is on */
+ if ((screen->getOption ("click_to_focus")->value ().b ()))
+ {
+ Window aboveId = next ? next->id () : None;
+ screen->unhookWindow (this);
+ CompWindow *focusedWindow = screen->priv->focusTopMostWindow ();
+ screen->insertWindow (this , aboveId);
+
+ /* if the newly focused window is a desktop window,
+ give the focus back to w */
+ if (focusedWindow &&
+ focusedWindow->type () & CompWindowTypeDesktopMask)
+ {
+ moveInputFocusTo ();
+ }
+ }
+
mask = priv->addWindowStackChanges (&xwc,
PrivateWindow::findLowestSiblingBelow (this));