1
0
mirror of https://github.com/gryf/wmaker.git synced 2025-12-19 04:20:27 +01:00

wmaker: Maintain sorting of windows by workspace in switch menu.

Previously, this sorting failed when one window was moved to another
workspace.

This fixes Debian bug #280851 [1].

[1] https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=280851
This commit is contained in:
Doug Torrance
2016-01-16 00:22:34 -05:00
committed by Carlos R. Mafra
parent fd19456d66
commit 2f33b3c2bc

View File

@@ -149,27 +149,22 @@ void OpenSwitchMenu(WScreen * scr, int x, int y, int keyboard)
static int menuIndexForWindow(WMenu * menu, WWindow * wwin, int old_pos) static int menuIndexForWindow(WMenu * menu, WWindow * wwin, int old_pos)
{ {
int idx; int idx, move_down;
if (menu->entry_no <= old_pos) if (menu->entry_no <= old_pos)
return -1; return -1;
#define WS(i) ((WWindow*)menu->entries[i]->clientdata)->frame->workspace for (idx = 0, move_down = 0; idx < menu->entry_no; idx++) {
if (old_pos >= 0) {
if (WS(old_pos) >= wwin->frame->workspace
&& (old_pos == 0 || WS(old_pos - 1) <= wwin->frame->workspace)) {
return old_pos;
}
}
#undef WS
for (idx = 0; idx < menu->entry_no; idx++) {
WWindow *tw = (WWindow *) menu->entries[idx]->clientdata; WWindow *tw = (WWindow *) menu->entries[idx]->clientdata;
if (!IS_OMNIPRESENT(tw) /* Is the window moving down in the menu? If so, we'll need to
&& tw->frame->workspace > wwin->frame->workspace) { adjust its new index by 1. */
break; if (tw == wwin)
} move_down = 1;
if (IS_OMNIPRESENT(tw) || (tw != wwin &&
tw->frame->workspace >= wwin->frame->workspace))
return idx - move_down;
} }
return idx; return idx;
@@ -215,7 +210,7 @@ void UpdateSwitchMenu(WScreen * scr, WWindow * wwin, int action)
if (IS_OMNIPRESENT(wwin)) if (IS_OMNIPRESENT(wwin))
idx = -1; idx = -1;
else { else {
idx = menuIndexForWindow(switchmenu, wwin, -1); idx = menuIndexForWindow(switchmenu, wwin, 0);
} }
entry = wMenuInsertCallback(switchmenu, idx, t, focusWindow, wwin); entry = wMenuInsertCallback(switchmenu, idx, t, focusWindow, wwin);