1
0
mirror of https://github.com/gryf/wmaker.git synced 2025-12-25 07:32:36 +01:00

Escape key handling in switchpanel

Pressing the escape key (ESC) while the switchpanel is active
cancels it and gives the focus back to the window which had it
before the switchpanel was invoked.

If all windows are minimized before the switchpanel was called,
they will continue to be if ESC is pressed.

In other words, pressing ESC is like going to the parallel universe
where you never entered the switchpanel in the first place.

Based on a patch by Nicolas Bonifas from 17.08.2009.
This commit is contained in:
Carlos R. Mafra
2009-08-20 16:00:26 +02:00
parent 333dbf5418
commit f9bb2a428a

View File

@@ -86,6 +86,8 @@ void StartWindozeCycle(WWindow * wwin, XEvent * event, Bool next)
KeyCode endKey = XKeysymToKeycode(dpy, XK_End);
KeyCode shiftLKey = XKeysymToKeycode(dpy, XK_Shift_L);
KeyCode shiftRKey = XKeysymToKeycode(dpy, XK_Shift_R);
KeyCode escapeKey = XKeysymToKeycode(dpy, XK_Escape);
Bool esc_cancel = False;
Bool somethingElse = False;
Bool done = False;
Bool hasModifier;
@@ -164,6 +166,14 @@ void StartWindozeCycle(WWindow * wwin, XEvent * event, Bool next)
newFocused = wSwitchPanelSelectFirst(swpanel, ev.xkey.keycode != homeKey);
if (newFocused)
oldFocused = change_focus_and_raise(newFocused, oldFocused, swpanel, scr);
} else if (ev.xkey.keycode == escapeKey) {
/* Focus the first window of the swpanel, despite the 'False' */
newFocused = wSwitchPanelSelectFirst(swpanel, False);
if (newFocused) {
oldFocused = change_focus_and_raise(newFocused, oldFocused, swpanel, scr);
esc_cancel = True;
done = True;
}
} else if (ev.xkey.keycode != shiftLKey && ev.xkey.keycode != shiftRKey) {
somethingElse = True;
@@ -215,7 +225,7 @@ void StartWindozeCycle(WWindow * wwin, XEvent * event, Bool next)
if (swpanel)
wSwitchPanelDestroy(swpanel);
if (newFocused) {
if (newFocused && !esc_cancel) {
wRaiseFrame(newFocused->frame->core);
CommitStacking(scr);
if (!newFocused->flags.mapped)