From 914d4e06effcc78df4ffcf92175d51e4af45ff75 Mon Sep 17 00:00:00 2001 From: Martin Frydl Date: Tue, 27 Nov 2012 11:13:34 +0100 Subject: [PATCH] Added option to ignore minimized windows during cycling. Added CycleIgnoreMinimized configuration option settable on Expert page in WPrefs. When option is set, switch panel cycling ignores minimized (grayed) windows. They are still visible and can be selected using left/right arrows or mouse click. --- WPrefs.app/Expert.c | 3 +++ src/WindowMaker.h | 1 + src/cycling.c | 6 +++--- src/defaults.c | 4 +++- src/switchpanel.c | 37 +++++++++++++++++++------------------ src/switchpanel.h | 2 +- 6 files changed, 30 insertions(+), 23 deletions(-) diff --git a/WPrefs.app/Expert.c b/WPrefs.app/Expert.c index c6ecefd5..d82bc6ff 100644 --- a/WPrefs.app/Expert.c +++ b/WPrefs.app/Expert.c @@ -62,6 +62,9 @@ static const struct { { N_("Cycle windows only on the active head."), /* default: */ False, OPTION_WMAKER, "CycleActiveHeadOnly" }, + { N_("Ignore minimized windows when cycling."), + /* default: */ False, OPTION_WMAKER, "CycleIgnoreMinimized" }, + { N_("Show workspace title on Clip."), /* default: */ True, OPTION_WMAKER, "ShowClipTitle" }, diff --git a/src/WindowMaker.h b/src/WindowMaker.h index afc28710..ee6dbf90 100644 --- a/src/WindowMaker.h +++ b/src/WindowMaker.h @@ -427,6 +427,7 @@ typedef struct WPreferences { char single_click; /* single click to lauch applications */ int history_lines; /* history of "Run..." dialog */ char cycle_active_head_only; /* Cycle only windows on the active head */ + char cycle_ignore_minimized; /* Ignore minimized windows when cycling */ RImage *swtileImage; RImage *swbackImage[9]; diff --git a/src/cycling.c b/src/cycling.c index 0b0dc7cf..b2c77268 100644 --- a/src/cycling.c +++ b/src/cycling.c @@ -123,7 +123,7 @@ void StartWindozeCycle(WWindow * wwin, XEvent * event, Bool next, Bool class_onl if (swpanel) { if (wwin->flags.mapped) - newFocused = wSwitchPanelSelectNext(swpanel, !next); + newFocused = wSwitchPanelSelectNext(swpanel, !next, True); else newFocused = wSwitchPanelSelectFirst(swpanel, False); @@ -157,7 +157,7 @@ void StartWindozeCycle(WWindow * wwin, XEvent * event, Bool next, Bool class_onl && wKeyBindings[WKBD_GROUPNEXT].modifier == modifiers) || ev.xkey.keycode == rightKey) { - newFocused = wSwitchPanelSelectNext(swpanel, False); + newFocused = wSwitchPanelSelectNext(swpanel, False, ev.xkey.keycode != rightKey); oldFocused = change_focus_and_raise(newFocused, oldFocused, swpanel, scr, False); } else if ((wKeyBindings[WKBD_FOCUSPREV].keycode == ev.xkey.keycode @@ -166,7 +166,7 @@ void StartWindozeCycle(WWindow * wwin, XEvent * event, Bool next, Bool class_onl && wKeyBindings[WKBD_GROUPPREV].modifier == modifiers) || ev.xkey.keycode == leftKey) { - newFocused = wSwitchPanelSelectNext(swpanel, True); + newFocused = wSwitchPanelSelectNext(swpanel, True, ev.xkey.keycode != leftKey); oldFocused = change_focus_and_raise(newFocused, oldFocused, swpanel, scr, False); } else if (ev.xkey.keycode == homeKey || ev.xkey.keycode == endKey) { diff --git a/src/defaults.c b/src/defaults.c index e8c33e05..84530700 100644 --- a/src/defaults.c +++ b/src/defaults.c @@ -684,7 +684,9 @@ WDefaultEntry optionList[] = { {"DialogHistoryLines", "500", NULL, &wPreferences.history_lines, getInt, NULL, NULL, NULL}, {"CycleActiveHeadOnly", "NO", NULL, - &wPreferences.cycle_active_head_only, getBool, NULL, NULL, NULL} + &wPreferences.cycle_active_head_only, getBool, NULL, NULL, NULL}, + {"CycleIgnoreMinimized", "NO", NULL, + &wPreferences.cycle_ignore_minimized, getBool, NULL, NULL, NULL} }; static void initDefaults() diff --git a/src/switchpanel.c b/src/switchpanel.c index ca2994cb..fcd61fa0 100644 --- a/src/switchpanel.c +++ b/src/switchpanel.c @@ -559,10 +559,11 @@ void wSwitchPanelDestroy(WSwitchPanel *panel) wfree(panel); } -WWindow *wSwitchPanelSelectNext(WSwitchPanel *panel, int back) +WWindow *wSwitchPanelSelectNext(WSwitchPanel *panel, int back, int ignore_minimized) { WWindow *wwin; int count = WMGetArrayItemCount(panel->windows); + int orig = panel->current; if (count == 0) return NULL; @@ -570,26 +571,26 @@ WWindow *wSwitchPanelSelectNext(WSwitchPanel *panel, int back) if (panel->win) changeImage(panel, panel->current, 0); - if (back) - panel->current--; - else - panel->current++; + if (!wPreferences.cycle_ignore_minimized) + ignore_minimized = False; - wwin = WMGetFromArray(panel->windows, (count + panel->current) % count); + if (ignore_minimized && canReceiveFocus(WMGetFromArray(panel->windows, (count + panel->current) % count)) < 0) + ignore_minimized = False; - if (back) { - if (panel->current < 0) - scrollIcons(panel, count); - else if (panel->current < panel->firstVisible) - scrollIcons(panel, -1); - } else { - if (panel->current >= count) - scrollIcons(panel, -count); - else if (panel->current - panel->firstVisible >= panel->visibleCount) - scrollIcons(panel, 1); - } + do { + if (back) + panel->current--; + else + panel->current++; + + panel->current= (count + panel->current) % count; + wwin = WMGetFromArray(panel->windows, panel->current); + } while (ignore_minimized && panel->current != orig && canReceiveFocus(wwin) < 0); - panel->current = (count + panel->current) % count; + if (panel->current < panel->firstVisible) + scrollIcons(panel, panel->current - panel->firstVisible); + else if (panel->current - panel->firstVisible >= panel->visibleCount) + scrollIcons(panel, panel->current - panel->firstVisible - panel->visibleCount + 1); if (panel->win) { drawTitle(panel, panel->current, wwin->frame->title); diff --git a/src/switchpanel.h b/src/switchpanel.h index 73efa634..041d222b 100644 --- a/src/switchpanel.h +++ b/src/switchpanel.h @@ -27,7 +27,7 @@ WSwitchPanel *wInitSwitchPanel(WScreen *scr, WWindow *curwin, Bool class_only); void wSwitchPanelDestroy(WSwitchPanel *panel); -WWindow *wSwitchPanelSelectNext(WSwitchPanel *panel, int back); +WWindow *wSwitchPanelSelectNext(WSwitchPanel *panel, int back, int ignore_minimized); WWindow *wSwitchPanelSelectFirst(WSwitchPanel *panel, int back); WWindow *wSwitchPanelHandleEvent(WSwitchPanel *panel, XEvent *event); -- 2.11.4.GIT