Added option to ignore minimized windows during cycling.
authorMartin Frydl <mfrydl@gmail.com>
Tue, 27 Nov 2012 10:13:34 +0000 (27 11:13 +0100)
committerCarlos R. Mafra <crmafra@gmail.com>
Tue, 27 Nov 2012 23:07:13 +0000 (28 00:07 +0100)
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
src/WindowMaker.h
src/cycling.c
src/defaults.c
src/switchpanel.c
src/switchpanel.h

index c6ecefd..d82bc6f 100644 (file)
@@ -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" },
 
index afc2871..ee6dbf9 100644 (file)
@@ -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];
index 0b0dc7c..b2c7726 100644 (file)
@@ -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) {
index e8c33e0..8453070 100644 (file)
@@ -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()
index ca2994c..fcd61fa 100644 (file)
@@ -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);
index 73efa63..041d222 100644 (file)
@@ -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);