From f41db5b5beeb0f28d19e09c50ae3a9208f882c6e Mon Sep 17 00:00:00 2001 From: "Alexey I. Froloff" Date: Fri, 10 Sep 2010 20:51:05 +0400 Subject: [PATCH] Add key binding to minimize all windows MinimizeAllKey - minimize all windows on current workspace. Original-patch-by: Pavel S. Khmelinsky Signed-off-by: Alexey I. Froloff [crmafra: AllMinimizeKey --> MinimizeAllKey] --- src/actions.c | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ src/actions.h | 1 + src/defaults.c | 2 ++ src/event.c | 4 ++++ src/keybind.h | 1 + 5 files changed, 56 insertions(+) diff --git a/src/actions.c b/src/actions.c index 282bfc1b..aba2d14d 100644 --- a/src/actions.c +++ b/src/actions.c @@ -1216,6 +1216,54 @@ static void hideWindow(WIcon *icon, int icon_x, int icon_y, WWindow *wwin, int a WMPostNotificationName(WMNChangedState, wwin, "hide"); } +void wHideAll(WScreen *scr) +{ + WWindow *wwin; + WWindow **windows; + Window FocusedWin; + WMenu *menu; + unsigned int wcount = 0; + int FocusState; + int i; + + if (!scr) + return; + + menu = scr->switch_menu; + + windows = malloc(sizeof(WWindow *)); + + if (menu != NULL) { + for (i = 0; i < menu->entry_no; i++) { + windows[wcount] = (WWindow *) menu->entries[i]->clientdata; + wcount++; + windows = realloc(windows, sizeof(WWindow *) * (wcount+1)); + } + } else { + wwin = scr->focused_window; + + while (wwin) { + windows[wcount] = wwin; + wcount++; + windows = realloc(windows, sizeof(WWindow *) * (wcount+1)); + wwin = wwin->prev; + + } + } + + for (i = 0; i < wcount; i++) { + wwin = windows[i]; + if (wwin->frame->workspace == scr->current_workspace + && !(wwin->flags.miniaturized || wwin->flags.hidden) + && !wwin->flags.internal_window + && !WFLAGP(wwin, no_miniaturizable) + ) { + wwin->flags.skip_next_animation = 1; + wIconifyWindow(wwin); + } + } +} + void wHideOtherApplications(WWindow *awin) { WWindow *wwin; diff --git a/src/actions.h b/src/actions.h index 382cb213..2dc14596 100644 --- a/src/actions.h +++ b/src/actions.h @@ -53,6 +53,7 @@ void wUnselectWindows(WScreen *scr); void wMaximizeWindow(WWindow *wwin, int directions); void wUnmaximizeWindow(WWindow *wwin); +void wHideAll(WScreen *src); void wHideOtherApplications(WWindow *wwin); void wShowAllWindows(WScreen *scr); diff --git a/src/defaults.c b/src/defaults.c index 930d47c0..d43640cf 100644 --- a/src/defaults.c +++ b/src/defaults.c @@ -516,6 +516,8 @@ WDefaultEntry optionList[] = { NULL, getKeybind, setKeyGrab, NULL, NULL}, {"MiniaturizeKey", "None", (void *)WKBD_MINIATURIZE, NULL, getKeybind, setKeyGrab, NULL, NULL}, + {"MinimizeAllKey", "None", (void *)WKBD_MINIMIZEALL, + NULL, getKeybind, setKeyGrab, NULL, NULL }, {"HideKey", "None", (void *)WKBD_HIDE, NULL, getKeybind, setKeyGrab, NULL, NULL}, {"HideOthersKey", "None", (void *)WKBD_HIDE_OTHERS, diff --git a/src/event.c b/src/event.c index 5d80fbe7..45e4122c 100644 --- a/src/event.c +++ b/src/event.c @@ -1402,6 +1402,10 @@ static void handleKeyPress(XEvent * event) if (ISMAPPED(wwin) && ISFOCUSED(wwin)) OpenWindowMenu(wwin, wwin->frame_x, wwin->frame_y + wwin->frame->top_width, True); break; + case WKBD_MINIMIZEALL: + CloseWindowMenu(scr); + wHideAll(scr); + break; case WKBD_MINIATURIZE: if (ISMAPPED(wwin) && ISFOCUSED(wwin) && !WFLAGP(wwin, no_miniaturizable)) { diff --git a/src/keybind.h b/src/keybind.h index 6c7cc152..e49bde9d 100644 --- a/src/keybind.h +++ b/src/keybind.h @@ -30,6 +30,7 @@ enum { /* window */ WKBD_MINIATURIZE, + WKBD_MINIMIZEALL, WKBD_HIDE, WKBD_HIDE_OTHERS, WKBD_MAXIMIZE,