diff options
author | Danny Baumann <dannybaumann@web.de> | 2010-09-08 11:33:17 +0200 |
---|---|---|
committer | Danny Baumann <dannybaumann@web.de> | 2010-09-08 11:33:17 +0200 |
commit | 0df941c26aef7bccf8c8530b41bdc7e9af0aaa9e (patch) | |
tree | 0a3d477e367a9c760bac43001bb75b1c623c248d | |
parent | e2eb5145e53464199d4261c2b00ad8110b2d2e66 (diff) | |
download | staticswitcher-0df941c26aef7bccf8c8530b41bdc7e9af0aaa9e.tar.gz staticswitcher-0df941c26aef7bccf8c8530b41bdc7e9af0aaa9e.tar.bz2 |
Give highlighted window keyboard focus.
This allows key bindings (e.g. Alt+F4) to be carried out on the
highlighted window.
-rw-r--r-- | staticswitcher.c | 27 |
1 files changed, 22 insertions, 5 deletions
diff --git a/staticswitcher.c b/staticswitcher.c index 37f5c20..1b3c585 100644 --- a/staticswitcher.c +++ b/staticswitcher.c @@ -41,6 +41,8 @@ typedef struct _SwitchDisplay { int screenPrivateIndex; HandleEventProc handleEvent; + Window lastActiveWindow; + Atom selectWinAtom; Atom selectFgColorAtom; } SwitchDisplay; @@ -192,7 +194,8 @@ static void switchActivateEvent (CompScreen *s, Bool activating) { - CompOption o[2]; + CompOption o[2]; + CompDisplay *d = s->display; o[0].type = CompOptionTypeInt; o[0].name = "root"; @@ -202,8 +205,7 @@ switchActivateEvent (CompScreen *s, o[1].name = "active"; o[1].value.b = activating; - (*s->display->handleCompizEvent) (s->display, "staticswitcher", "activate", - o, 2); + (*d->handleCompizEvent) (s->display, "staticswitcher", "activate", o, 2); } static int @@ -472,6 +474,7 @@ switchToWindow (CompScreen *s, } ss->selectedWindow = w; + moveInputFocusToWindow (w); if (old != w) { @@ -591,10 +594,12 @@ switchInitiate (CompScreen *s, SwitchWindowSelection selection, Bool showPopup) { - int count; - Bool mouseSelect; + CompDisplay *d = s->display; + int count; + Bool mouseSelect; SWITCH_SCREEN (s); + SWITCH_DISPLAY (d); if (otherScreenGrabExist (s, "cube", NULL)) return; @@ -699,6 +704,7 @@ switchInitiate (CompScreen *s, } } + sd->lastActiveWindow = d->activeWindow; switchActivateEvent (s, TRUE); } @@ -724,6 +730,7 @@ switchTerminate (CompDisplay *d, for (s = d->screens; s; s = s->next) { SWITCH_SCREEN (s); + SWITCH_DISPLAY (d); if (xid && s->root != xid) continue; @@ -755,7 +762,15 @@ switchTerminate (CompDisplay *d, ss->switching = FALSE; if (state & CompActionStateCancel) + { ss->selectedWindow = NULL; + if (d->activeWindow != sd->lastActiveWindow) + { + w = findWindowAtDisplay (d, sd->lastActiveWindow); + if (w) + moveInputFocusToWindow (w); + } + } if (state && ss->selectedWindow && !ss->selectedWindow->destroyed) sendWindowActivationRequest (s, ss->selectedWindow->id); @@ -1982,6 +1997,8 @@ switchInitDisplay (CompPlugin *p, sd->selectFgColorAtom = XInternAtom (d->display, DECOR_SWITCH_FOREGROUND_COLOR_ATOM_NAME, 0); + sd->lastActiveWindow = None; + WRAP (sd, d, handleEvent, switchHandleEvent); d->base.privates[SwitchDisplayPrivateIndex].ptr = sd; |