mirror of
https://github.com/gryf/wmaker.git
synced 2025-12-23 06:38:05 +01:00
wmaker: improve windows listing in switchpanel
This patch is updating makeWindowListArray function, as it crosses the whole window focused list each time we don't have to bother on checking previous and then next focused windows, so saving some cycles here. Signed-off-by: Carlos R. Mafra <crmafra@gmail.com>
This commit is contained in:
committed by
Carlos R. Mafra
parent
1497bc354b
commit
334e2cc5f4
@@ -358,41 +358,22 @@ static void drawTitle(WSwitchPanel *panel, int idecks, const char *title)
|
|||||||
free(ntitle);
|
free(ntitle);
|
||||||
}
|
}
|
||||||
|
|
||||||
static WMArray *makeWindowListArray(WWindow *curwin, int include_unmapped, Bool class_only)
|
static WMArray *makeWindowListArray(WScreen *scr, int include_unmapped, Bool class_only)
|
||||||
{
|
{
|
||||||
WMArray *windows = WMCreateArray(10);
|
WMArray *windows = WMCreateArray(10);
|
||||||
int fl;
|
WWindow *wwin = scr->focused_window;
|
||||||
WWindow *wwin;
|
|
||||||
|
|
||||||
for (fl = 0; fl < 2; fl++) {
|
while (wwin) {
|
||||||
for (wwin = curwin; wwin; wwin = wwin->prev) {
|
if ((canReceiveFocus(wwin) != 0) &&
|
||||||
if (((!fl && canReceiveFocus(wwin) > 0) || (fl && canReceiveFocus(wwin) < 0)) &&
|
(wwin->flags.mapped || wwin->flags.shaded || include_unmapped)) {
|
||||||
(wwin->flags.mapped || wwin->flags.shaded || include_unmapped)) {
|
if (class_only)
|
||||||
if (class_only)
|
if (!sameWindowClass(scr->focused_window, wwin))
|
||||||
if (!sameWindowClass(wwin, curwin))
|
|
||||||
continue;
|
|
||||||
|
|
||||||
if (!WFLAGP(wwin, skip_switchpanel))
|
|
||||||
WMAddToArray(windows, wwin);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
wwin = curwin;
|
|
||||||
/* start over from the beginning of the list */
|
|
||||||
while (wwin->next)
|
|
||||||
wwin = wwin->next;
|
|
||||||
|
|
||||||
for (wwin = curwin; wwin && wwin != curwin; wwin = wwin->prev) {
|
|
||||||
if (((!fl && canReceiveFocus(wwin) > 0) || (fl && canReceiveFocus(wwin) < 0)) &&
|
|
||||||
(wwin->flags.mapped || wwin->flags.shaded || include_unmapped)) {
|
|
||||||
if (class_only)
|
|
||||||
if (!sameWindowClass(wwin, curwin))
|
|
||||||
continue;
|
continue;
|
||||||
if (!WFLAGP(wwin, skip_switchpanel))
|
if (!WFLAGP(wwin, skip_switchpanel))
|
||||||
WMAddToArray(windows, wwin);
|
WMAddToArray(windows, wwin);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
wwin = wwin->prev;
|
||||||
}
|
}
|
||||||
|
|
||||||
return windows;
|
return windows;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -416,7 +397,7 @@ WSwitchPanel *wInitSwitchPanel(WScreen *scr, WWindow *curwin, Bool class_only)
|
|||||||
WMRect rect = wGetRectForHead(scr, wGetHeadForPointerLocation(scr));
|
WMRect rect = wGetRectForHead(scr, wGetHeadForPointerLocation(scr));
|
||||||
|
|
||||||
panel->scr = scr;
|
panel->scr = scr;
|
||||||
panel->windows = makeWindowListArray(curwin, wPreferences.swtileImage != NULL, class_only);
|
panel->windows = makeWindowListArray(scr, wPreferences.swtileImage != NULL, class_only);
|
||||||
count = WMGetArrayItemCount(panel->windows);
|
count = WMGetArrayItemCount(panel->windows);
|
||||||
if (count)
|
if (count)
|
||||||
panel->flags = makeWindowFlagsArray(count);
|
panel->flags = makeWindowFlagsArray(count);
|
||||||
@@ -623,7 +604,7 @@ WWindow *wSwitchPanelSelectNext(WSwitchPanel *panel, int back, int ignore_minimi
|
|||||||
else
|
else
|
||||||
panel->current++;
|
panel->current++;
|
||||||
|
|
||||||
panel->current= (count + panel->current) % count;
|
panel->current = (count + panel->current) % count;
|
||||||
wwin = WMGetFromArray(panel->windows, panel->current);
|
wwin = WMGetFromArray(panel->windows, panel->current);
|
||||||
|
|
||||||
if (!class_only)
|
if (!class_only)
|
||||||
|
|||||||
Reference in New Issue
Block a user