From f9bb2a428a52ee6aba07d160412478744c805751 Mon Sep 17 00:00:00 2001 From: "Carlos R. Mafra" Date: Thu, 20 Aug 2009 16:00:26 +0200 Subject: [PATCH] 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. --- src/cycling.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/cycling.c b/src/cycling.c index 87e23ee9..8e9473ed 100644 --- a/src/cycling.c +++ b/src/cycling.c @@ -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)