From f79379c0906c9aa0f40802d2b2da03c6924717cc Mon Sep 17 00:00:00 2001 From: "Carlos R. Mafra" Date: Sat, 22 Aug 2009 03:03:14 +0200 Subject: [PATCH] swpanel: Fix stacking issue with swpanel escape handling MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Daniel Déchelotte reported one problem with the escape handling in the switchpanel: "Start with two windows: a fullscreen one, and a smaller window that appears above the fullscreen one. With the mouse, focus the bigger window. Start alt-tabbing, then press Escape. The bigger window will then be focused (good) *and raised* (small problem)." Fix this by adding a test for the escape key before calling raiseWindow(). --- src/cycling.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/src/cycling.c b/src/cycling.c index 1f7189b2..0f2b807b 100644 --- a/src/cycling.c +++ b/src/cycling.c @@ -62,7 +62,7 @@ static void raiseWindow(WSwitchPanel * swpanel, WWindow * wwin) } static WWindow *change_focus_and_raise(WWindow *newFocused, WWindow *oldFocused, - WSwitchPanel *swpanel, WScreen *scr) + WSwitchPanel *swpanel, WScreen *scr, Bool esc_cancel) { if (!newFocused) return oldFocused; @@ -72,7 +72,9 @@ static WWindow *change_focus_and_raise(WWindow *newFocused, WWindow *oldFocused, if (wPreferences.circ_raise) { CommitStacking(scr); - raiseWindow(swpanel, newFocused); + + if (!esc_cancel) + raiseWindow(swpanel, newFocused); } return oldFocused; @@ -125,7 +127,7 @@ void StartWindozeCycle(WWindow * wwin, XEvent * event, Bool next) if (swpanel) { newFocused = wSwitchPanelSelectNext(swpanel, !next); - oldFocused = change_focus_and_raise(newFocused, oldFocused, swpanel, scr); + oldFocused = change_focus_and_raise(newFocused, oldFocused, swpanel, scr, False); } else { if (wwin->frame->workspace == scr->current_workspace) newFocused = wwin; @@ -154,25 +156,25 @@ void StartWindozeCycle(WWindow * wwin, XEvent * event, Bool next) || ev.xkey.keycode == rightKey) { newFocused = wSwitchPanelSelectNext(swpanel, False); - oldFocused = change_focus_and_raise(newFocused, oldFocused, swpanel, scr); + oldFocused = change_focus_and_raise(newFocused, oldFocused, swpanel, scr, False); } else if ((wKeyBindings[WKBD_FOCUSPREV].keycode == ev.xkey.keycode && wKeyBindings[WKBD_FOCUSPREV].modifier == modifiers) || ev.xkey.keycode == leftKey) { newFocused = wSwitchPanelSelectNext(swpanel, True); - oldFocused = change_focus_and_raise(newFocused, oldFocused, swpanel, scr); + oldFocused = change_focus_and_raise(newFocused, oldFocused, swpanel, scr, False); } else if (ev.xkey.keycode == homeKey || ev.xkey.keycode == endKey) { newFocused = wSwitchPanelSelectFirst(swpanel, ev.xkey.keycode != homeKey); - oldFocused = change_focus_and_raise(newFocused, oldFocused, swpanel, scr); + oldFocused = change_focus_and_raise(newFocused, oldFocused, swpanel, scr, False); } else if (ev.xkey.keycode == escapeKey) { /* Focus the first window of the swpanel, despite the 'False' */ newFocused = wSwitchPanelSelectFirst(swpanel, False); - oldFocused = change_focus_and_raise(newFocused, oldFocused, swpanel, scr); + oldFocused = change_focus_and_raise(newFocused, oldFocused, swpanel, scr, True); esc_cancel = True; done = True; @@ -206,7 +208,7 @@ void StartWindozeCycle(WWindow * wwin, XEvent * event, Bool next) case ButtonRelease: newFocused = wSwitchPanelHandleEvent(swpanel, &ev); - oldFocused = change_focus_and_raise(newFocused, oldFocused, swpanel, scr); + oldFocused = change_focus_and_raise(newFocused, oldFocused, swpanel, scr, False); if (ev.type == ButtonRelease) done = True;