mirror of
https://github.com/gryf/wmaker.git
synced 2025-12-19 20:38:08 +01:00
fixed directory OPEN_MENU sorting bug and shortcut selection window problems
This commit is contained in:
59
src/event.c
59
src/event.c
@@ -1702,39 +1702,47 @@ handleKeyPress(XEvent *event)
|
||||
|
||||
index = command-WKBD_WINDOW1;
|
||||
|
||||
if (scr->shortcutSelectedWindows[index]) {
|
||||
WMBag *list = scr->shortcutSelectedWindows[index];
|
||||
if (scr->shortcutWindows[index]) {
|
||||
WMBag *list = scr->shortcutWindows[index];
|
||||
int cw;
|
||||
int i;
|
||||
int count = WMGetBagItemCount(list);
|
||||
WWindow *twin;
|
||||
|
||||
wUnselectWindows(scr);
|
||||
if (scr->shortcutWindow[index])
|
||||
wMakeWindowVisible(scr->shortcutWindow[index]);
|
||||
cw = scr->current_workspace;
|
||||
for (i = 0; i < WMGetBagItemCount(list); i++) {
|
||||
WWindow *wwin = WMGetFromBag(list, i);
|
||||
wWindowChangeWorkspace(wwin, cw);
|
||||
wMakeWindowVisible(wwin);
|
||||
wSelectWindow(wwin, True);
|
||||
}
|
||||
} else if (scr->shortcutWindow[index]){
|
||||
|
||||
wMakeWindowVisible(scr->shortcutWindow[index]);
|
||||
for (i = count-1; i >= 0; i--) {
|
||||
WWindow *wwin = WMGetFromBag(list, i);
|
||||
|
||||
if (count > 1)
|
||||
wWindowChangeWorkspace(wwin, cw);
|
||||
|
||||
wMakeWindowVisible(wwin);
|
||||
|
||||
if (count > 1)
|
||||
wSelectWindow(wwin, True);
|
||||
}
|
||||
|
||||
/* rotate the order of windows, to create a cycling effect */
|
||||
twin = WMGetFromBag(list, 0);
|
||||
WMDeleteFromBag(list, 0);
|
||||
WMPutInBag(list, twin);
|
||||
|
||||
} else if (wwin && ISMAPPED(wwin) && ISFOCUSED(wwin)) {
|
||||
|
||||
scr->shortcutWindow[index] = wwin;
|
||||
INITBAG(scr->shortcutWindows[index]);
|
||||
WMPutInBag(scr->shortcutWindows[index], wwin);
|
||||
|
||||
if (wwin->flags.selected && scr->selected_windows) {
|
||||
WMBag *bag;
|
||||
WMBag *selwins = scr->selected_windows;
|
||||
int i;
|
||||
|
||||
bag = scr->selected_windows;
|
||||
INITBAG(scr->shortcutSelectedWindows[index]);
|
||||
for (i = 0; i < WMGetBagItemCount(selwins); i++) {
|
||||
WWindow *tmp = WMGetFromBag(selwins, i);
|
||||
|
||||
for (i = 0; i < WMGetBagItemCount(bag); i++) {
|
||||
WWindow *tmp = WMGetFromBag(bag, i);
|
||||
|
||||
WMPutInBag(scr->shortcutSelectedWindows[index], tmp);
|
||||
if (tmp != wwin)
|
||||
WMPutInBag(scr->shortcutWindows[index], tmp);
|
||||
}
|
||||
}
|
||||
wSelectWindow(wwin, !wwin->flags.selected);
|
||||
@@ -1746,16 +1754,15 @@ handleKeyPress(XEvent *event)
|
||||
} else if (WMGetBagItemCount(scr->selected_windows)) {
|
||||
|
||||
if (wwin->flags.selected && scr->selected_windows) {
|
||||
WMBag *bag;
|
||||
WMBag *selwins = scr->selected_windows;
|
||||
int i;
|
||||
|
||||
bag = scr->selected_windows;
|
||||
INITBAG(scr->shortcutSelectedWindows[index]);
|
||||
INITBAG(scr->shortcutWindows[index]);
|
||||
|
||||
for (i = 0; i < WMGetBagItemCount(bag); i++) {
|
||||
WWindow *tmp = WMGetFromBag(bag, i);
|
||||
for (i = 0; i < WMGetBagItemCount(selwins); i++) {
|
||||
WWindow *tmp = WMGetFromBag(selwins, i);
|
||||
|
||||
WMPutInBag(scr->shortcutSelectedWindows[index], tmp);
|
||||
WMPutInBag(scr->shortcutWindows[index], tmp);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
13
src/misc.c
13
src/misc.c
@@ -116,6 +116,7 @@ MakeCPPArgs(char *path)
|
||||
int i;
|
||||
char buffer[MAXLINE], *buf, *line;
|
||||
Visual *visual;
|
||||
char *tmp;
|
||||
|
||||
line = wmalloc(MAXLINE);
|
||||
*line = 0;
|
||||
@@ -150,13 +151,13 @@ MakeCPPArgs(char *path)
|
||||
putidef(line, " -DSCR_HEIGHT=",
|
||||
HeightOfScreen(DefaultScreenOfDisplay(dpy)));
|
||||
|
||||
#if 0
|
||||
strcpy(buffer, path);
|
||||
buf = strrchr(buffer, '/');
|
||||
/* put the dir where the menu is being read from to the
|
||||
* search path */
|
||||
tmp = wstrdup(path);
|
||||
buf = strrchr(tmp, '/');
|
||||
if (buf) *buf = 0; /* trunc filename */
|
||||
putdef(line, " -I", buffer);
|
||||
#endif
|
||||
|
||||
putdef(line, " -I", tmp);
|
||||
free(tmp);
|
||||
|
||||
|
||||
/* this should be done just once, but it works this way */
|
||||
|
||||
@@ -1270,8 +1270,11 @@ typedef struct {
|
||||
|
||||
|
||||
static int
|
||||
myCompare(const void *d1, const void *d2)
|
||||
myCompare(const void **d1, const void **d2)
|
||||
{
|
||||
d1 = *d1;
|
||||
d2 = *d2;
|
||||
|
||||
return strcmp(((dir_data*) d1)->name, ((dir_data*) d2)->name);
|
||||
}
|
||||
|
||||
|
||||
@@ -281,8 +281,7 @@ typedef struct _WScreen {
|
||||
scrolled down for titlebar access */
|
||||
|
||||
/* for window shortcuts */
|
||||
struct WWindow *shortcutWindow[MAX_WINDOW_SHORTCUTS];
|
||||
WMBag *shortcutSelectedWindows[MAX_WINDOW_SHORTCUTS];
|
||||
WMBag *shortcutWindows[MAX_WINDOW_SHORTCUTS];
|
||||
|
||||
#ifdef XDND
|
||||
char *xdestring;
|
||||
|
||||
23
src/window.c
23
src/window.c
@@ -212,13 +212,14 @@ wWindowDestroy(WWindow *wwin)
|
||||
wwin->flags.destroyed = 1;
|
||||
|
||||
for (i = 0; i < MAX_WINDOW_SHORTCUTS; i++) {
|
||||
if (wwin->screen_ptr->shortcutSelectedWindows[i]) {
|
||||
WMRemoveFromBag(wwin->screen_ptr->shortcutSelectedWindows[i], wwin);
|
||||
if (!wwin->screen_ptr->shortcutWindows[i])
|
||||
continue;
|
||||
|
||||
if (!WMGetBagItemCount(wwin->screen_ptr->shortcutSelectedWindows[i])) {
|
||||
WMFreeBag(wwin->screen_ptr->shortcutSelectedWindows[i]);
|
||||
wwin->screen_ptr->shortcutSelectedWindows[i] = NULL;
|
||||
}
|
||||
WMRemoveFromBag(wwin->screen_ptr->shortcutWindows[i], wwin);
|
||||
|
||||
if (!WMGetBagItemCount(wwin->screen_ptr->shortcutWindows[i])) {
|
||||
WMFreeBag(wwin->screen_ptr->shortcutWindows[i]);
|
||||
wwin->screen_ptr->shortcutWindows[i] = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -802,8 +803,12 @@ wManageWindow(WScreen *scr, Window window)
|
||||
int i;
|
||||
|
||||
for (i = 0; i < MAX_WINDOW_SHORTCUTS; i++) {
|
||||
if (wstate->window_shortcuts & (1<<i))
|
||||
scr->shortcutWindow[i] = wwin;
|
||||
if (wstate->window_shortcuts & (1<<i)) {
|
||||
if (!scr->shortcutWindows[i])
|
||||
scr->shortcutWindows[i] = WMCreateBag(4);
|
||||
|
||||
WMPutInBag(scr->shortcutWindows[i], wwin);
|
||||
}
|
||||
}
|
||||
}
|
||||
free(wstate);
|
||||
@@ -2210,7 +2215,7 @@ wWindowSaveState(WWindow *wwin)
|
||||
data[3] = wwin->flags.hidden;
|
||||
|
||||
for (i = 0; i < MAX_WINDOW_SHORTCUTS; i++) {
|
||||
if (wwin->screen_ptr->shortcutWindow[i] == wwin)
|
||||
if (WMCountInBag(wwin->screen_ptr->shortcutWindows[i], wwin))
|
||||
data[9] |= 1<<i;
|
||||
}
|
||||
XChangeProperty(dpy, wwin->client_win, _XA_WINDOWMAKER_STATE,
|
||||
|
||||
@@ -197,31 +197,26 @@ makeShortcutCommand(WMenu *menu, WMenuEntry *entry)
|
||||
{
|
||||
WWindow *wwin = (WWindow*)entry->clientdata;
|
||||
WScreen *scr = wwin->screen_ptr;
|
||||
|
||||
scr->shortcutWindow[entry->order-WO_ENTRIES] = wwin;
|
||||
int index = entry->order-WO_ENTRIES;
|
||||
|
||||
if (scr->shortcutSelectedWindows[entry->order-WO_ENTRIES])
|
||||
WMFreeBag(scr->shortcutSelectedWindows[entry->order-WO_ENTRIES]);
|
||||
if (scr->shortcutWindows[index]) {
|
||||
WMFreeBag(scr->shortcutWindows[index]);
|
||||
scr->shortcutWindows[index] = NULL;
|
||||
}
|
||||
|
||||
if (wwin->flags.selected && scr->selected_windows) {
|
||||
WMBag *bag;
|
||||
WMBag *selwin = scr->selected_windows;
|
||||
int i;
|
||||
|
||||
scr->shortcutSelectedWindows[entry->order-WO_ENTRIES] = WMCreateBag(4);
|
||||
scr->shortcutWindows[index] = WMCreateBag(4);
|
||||
|
||||
bag = scr->selected_windows;
|
||||
for (i = 0; i < WMGetBagItemCount(selwin); i++) {
|
||||
WWindow *tmp = WMGetFromBag(selwin, i);
|
||||
|
||||
for (i = 0; i < WMGetBagItemCount(bag); i++) {
|
||||
WWindow *tmp = WMGetFromBag(bag, i);
|
||||
|
||||
WMPutInBag(scr->shortcutSelectedWindows[entry->order-WO_ENTRIES],
|
||||
tmp);
|
||||
WMPutInBag(scr->shortcutWindows[index], tmp);
|
||||
}
|
||||
}
|
||||
else {
|
||||
scr->shortcutSelectedWindows[entry->order-WO_ENTRIES] = NULL;
|
||||
}
|
||||
|
||||
|
||||
wSelectWindow(wwin, !wwin->flags.selected);
|
||||
XFlush(dpy);
|
||||
wusleep(3000);
|
||||
@@ -278,20 +273,17 @@ updateMakeShortcutMenu(WMenu *menu, WWindow *wwin)
|
||||
for (i=WO_ENTRIES; i<smenu->entry_no; i++) {
|
||||
char *tmp;
|
||||
int shortcutNo = i-WO_ENTRIES;
|
||||
WWindow *twin = wwin->screen_ptr->shortcutWindow[shortcutNo];
|
||||
WMenuEntry *entry = smenu->entries[i];
|
||||
WMBag *shortSelWindows = wwin->screen_ptr->shortcutSelectedWindows[shortcutNo];
|
||||
WMBag *shortSelWindows = wwin->screen_ptr->shortcutWindows[shortcutNo];
|
||||
|
||||
sprintf(buffer, "%s %i", _("Set Shortcut"), shortcutNo+1);
|
||||
|
||||
if (!twin && !shortSelWindows) {
|
||||
if (!shortSelWindows) {
|
||||
entry->flags.indicator_on = 0;
|
||||
} else {
|
||||
entry->flags.indicator_on = 1;
|
||||
if (twin == wwin)
|
||||
if (WMCountInBag(shortSelWindows, wwin))
|
||||
entry->flags.indicator_type = MI_DIAMOND;
|
||||
else if (shortSelWindows && WMCountInBag(shortSelWindows, wwin))
|
||||
entry->flags.indicator_type = MI_HIDDEN;
|
||||
else
|
||||
entry->flags.indicator_type = MI_CHECK;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user