From f8918e85f726a1f948d082497fe1f053bab6bc8e Mon Sep 17 00:00:00 2001 From: id Date: Tue, 4 May 1999 21:03:11 +0000 Subject: [PATCH] Window shortcuts will apply to a group of selected windows, too. --- src/event.c | 51 +++++++++++++++++++++++++++++++++++++++++++++------ src/window.c | 13 ++++++++++--- src/winmenu.c | 29 ++++++++++++++++++++++++----- 3 files changed, 79 insertions(+), 14 deletions(-) diff --git a/src/event.c b/src/event.c index 79dd8004..b745e6ff 100644 --- a/src/event.c +++ b/src/event.c @@ -56,6 +56,7 @@ #include "framewin.h" #include "properties.h" #include "balloon.h" +#include "list.h" #ifdef GNOME_STUFF # include "gnome.h" #endif @@ -1672,16 +1673,54 @@ handleKeyPress(XEvent *event) case WKBD_WINDOW9: case WKBD_WINDOW10: #endif - if (scr->shortcutWindow[command-WKBD_WINDOW1]) { + if ( scr->shortcutSelectedWindows[command-WKBD_WINDOW1]) { + LinkedList *list = scr->shortcutSelectedWindows[command-WKBD_WINDOW1]; + int cw; + + wUnselectWindows(scr); + if (scr->shortcutWindow[command-WKBD_WINDOW1]) + wMakeWindowVisible(scr->shortcutWindow[command-WKBD_WINDOW1]); + cw = scr->current_workspace; + while (list) { + wWindowChangeWorkspace(list->head, cw); + wMakeWindowVisible(list->head); + wSelectWindow(list->head, True); + list = list->tail; + } + } else if (scr->shortcutWindow[command-WKBD_WINDOW1]) { wMakeWindowVisible(scr->shortcutWindow[command-WKBD_WINDOW1]); } else if (wwin && ISMAPPED(wwin) && ISFOCUSED(wwin)) { scr->shortcutWindow[command-WKBD_WINDOW1] = wwin; - wSelectWindow(wwin, !wwin->flags.selected); - XFlush(dpy); - wusleep(3000); - wSelectWindow(wwin, !wwin->flags.selected); - XFlush(dpy); + if (wwin->flags.selected /* && scr->selected_windows */ ) { + LinkedList *sl; + + sl = scr->selected_windows; + list_free(scr->shortcutSelectedWindows[command-WKBD_WINDOW1]); + + while (sl) { + scr->shortcutSelectedWindows[command-WKBD_WINDOW1] = list_cons(sl->head,scr->shortcutSelectedWindows[command-WKBD_WINDOW1]); + sl = sl->tail; + } + } + wSelectWindow(wwin, !wwin->flags.selected); + XFlush(dpy); + wusleep(3000); + wSelectWindow(wwin, !wwin->flags.selected); + XFlush(dpy); + } else if (scr->selected_windows) { + if (wwin->flags.selected /* && scr->selected_windows */ ) { + LinkedList *sl; + + sl = scr->selected_windows; + list_free(scr->shortcutSelectedWindows[command-WKBD_WINDOW1]); + + while (sl) { + scr->shortcutSelectedWindows[command-WKBD_WINDOW1] = list_cons(sl->head,scr->shortcutSelectedWindows[command-WKBD_WINDOW1]); + sl = sl->tail; + } + } } + break; case WKBD_NEXTWSLAYER: case WKBD_PREVWSLAYER: diff --git a/src/window.c b/src/window.c index e4dbcc1d..4eee4a00 100644 --- a/src/window.c +++ b/src/window.c @@ -51,6 +51,7 @@ #include "stacking.h" #include "defaults.h" #include "workspace.h" +#include "list.h" #ifdef MWM_HINTS # include "motif.h" @@ -208,9 +209,15 @@ wWindowDestroy(WWindow *wwin) wwin->flags.destroyed = 1; for (i = 0; i < MAX_WINDOW_SHORTCUTS; i++) { - if (wwin->screen_ptr->shortcutWindow[i] == wwin) { - wwin->screen_ptr->shortcutWindow[i] = NULL; - } + wwin->screen_ptr->shortcutSelectedWindows[i] = list_remove_elem(wwin->screen_ptr->shortcutSelectedWindows[i], wwin); + if (wwin->screen_ptr->shortcutWindow[i] == wwin) { + if (wwin->screen_ptr->shortcutSelectedWindows[i]) { + LinkedList *list = wwin->screen_ptr->shortcutSelectedWindows[i]; + wwin->screen_ptr->shortcutWindow[i] = + list->head; + } + else wwin->screen_ptr->shortcutWindow[i] = NULL; + } } if (wwin->normal_hints) diff --git a/src/winmenu.c b/src/winmenu.c index 1dcc6699..0d065803 100644 --- a/src/winmenu.c +++ b/src/winmenu.c @@ -44,6 +44,7 @@ #include "dialog.h" #include "stacking.h" #include "icon.h" +#include "list.h" #define MC_MAXIMIZE 0 #define MC_MINIATURIZE 1 @@ -195,8 +196,24 @@ static void makeShortcutCommand(WMenu *menu, WMenuEntry *entry) { WWindow *wwin = (WWindow*)entry->clientdata; + WScreen *scr = wwin->screen_ptr; - wwin->screen_ptr->shortcutWindow[entry->order-WO_ENTRIES] = wwin; + scr->shortcutWindow[entry->order-WO_ENTRIES] = wwin; + list_free(scr->shortcutSelectedWindows[entry->order-WO_ENTRIES]); + scr->shortcutSelectedWindows[entry->order-WO_ENTRIES] = NULL; + if (wwin->flags.selected /* && scr->selected_windows */ ) { + LinkedList *sl; + + sl = scr->selected_windows; + + while (sl) { + scr->shortcutSelectedWindows[entry->order-WO_ENTRIES] = list_cons(sl->head,scr->shortcutSelectedWindows[entry->order-WO_ENTRIES]); + sl = sl->tail; + } + } + else { + scr->shortcutSelectedWindows[entry->order-WO_ENTRIES] = NULL; + } wSelectWindow(wwin, !wwin->flags.selected); XFlush(dpy); @@ -259,14 +276,16 @@ updateMakeShortcutMenu(WMenu *menu, WWindow *wwin) sprintf(buffer, "%s %i", _("Set Shortcut"), shortcutNo+1); - if (!twin) { + if (!twin && !wwin->screen_ptr->shortcutSelectedWindows[shortcutNo]) { entry->flags.indicator_on = 0; } else { entry->flags.indicator_on = 1; - if (twin != wwin) - entry->flags.indicator_type = MI_CHECK; - else + if (twin == wwin) entry->flags.indicator_type = MI_DIAMOND; + else if (list_find(wwin->screen_ptr->shortcutSelectedWindows[shortcutNo], wwin)) + entry->flags.indicator_type = MI_HIDDEN; + else + entry->flags.indicator_type = MI_CHECK; } if (strcmp(buffer, entry->text)!=0) {