There are a number of window maximization options which are currently
only available to the user via keyboard shortcut:
* maximize vertically/horizontally
* maximize left/right/top/bottom half
* maximize left top/right top/left bottom/right bottom corner
* maximus
In this patch, they become available through the window menu, under
the "Other maximization options" submenu.
---
src/winmenu.c | 165 +++++++++++++++++++++++++++++++++++++++++++++++++++++-----
1 file changed, 151 insertions(+), 14 deletions(-)
diff --git a/src/winmenu.c b/src/winmenu.c
index 04db90d..a957ca7 100644
--- a/src/winmenu.c
+++ b/src/winmenu.c
@@ -48,26 +48,38 @@
#include "xinerama.h"
#include "winmenu.h"
-#define MC_MAXIMIZE 0
-#define MC_MINIATURIZE 1
-#define MC_SHADE 2
-#define MC_HIDE 3
-#define MC_MOVERESIZE 4
-#define MC_SELECT 5
-#define MC_DUMMY_MOVETO 6
-#define MC_PROPERTIES 7
-#define MC_OPTIONS 8
-#define MC_SHORTCUT 8
-#define MC_RELAUNCH 9
-
-#define MC_CLOSE 10
-#define MC_KILL 11
+#define MC_MAXIMIZE 0
+#define MC_OTHERMAX 1
+#define MC_MINIATURIZE 2
+#define MC_SHADE 3
+#define MC_HIDE 4
+#define MC_MOVERESIZE 5
+#define MC_SELECT 6
+#define MC_DUMMY_MOVETO 7
+#define MC_PROPERTIES 8
+#define MC_OPTIONS 9
+#define MC_SHORTCUT 9
+#define MC_RELAUNCH 10
+#define MC_CLOSE 11
+#define MC_KILL 12
+
#define WO_KEEP_ON_TOP 0
#define WO_KEEP_AT_BOTTOM 1
#define WO_OMNIPRESENT 2
#define WO_ENTRIES 3
+#define MAXC_V 0
+#define MAXC_H 1
+#define MAXC_LH 2
+#define MAXC_RH 3
+#define MAXC_TH 4
+#define MAXC_BH 5
+#define MAXC_LTC 6
+#define MAXC_RTC 7
+#define MAXC_LBC 8
+#define MAXC_RBC 9
+#define MAXC_MAXIMUS 10
static void updateOptionsMenu(WMenu * menu, WWindow * wwin);
@@ -99,6 +111,61 @@ static void execWindowOptionCommand(WMenu * menu,
WMenuEntry * entry)
}
}
+static void execMaximizeCommand(WMenu * menu, WMenuEntry * entry)
+{
+ WWindow *wwin = (WWindow *) entry->clientdata;
+
+ (void) menu;
+
+
+ switch (entry->order) {
+ case MAXC_V:
+ handleMaximize(wwin, MAX_VERTICAL);
+ break;
+
+ case MAXC_H:
+ handleMaximize(wwin,MAX_HORIZONTAL);
+ break;
+
+ case MAXC_LH:
+ handleMaximize(wwin,MAX_VERTICAL | MAX_LEFTHALF);
+ break;
+
+ case MAXC_RH:
+ handleMaximize(wwin,MAX_VERTICAL | MAX_RIGHTHALF);
+ break;
+
+ case MAXC_TH:
+ handleMaximize(wwin,MAX_HORIZONTAL | MAX_TOPHALF);
+ break;
+
+ case MAXC_BH:
+ handleMaximize(wwin,MAX_HORIZONTAL | MAX_BOTTOMHALF);
+ break;
+
+ case MAXC_LTC:
+ handleMaximize(wwin,MAX_LEFTHALF | MAX_TOPHALF);
+ break;
+
+ case MAXC_RTC:
+ handleMaximize(wwin,MAX_RIGHTHALF | MAX_TOPHALF);
+ break;
+
+ case MAXC_LBC:
+ handleMaximize(wwin,MAX_LEFTHALF | MAX_BOTTOMHALF);
+ break;
+
+ case MAXC_RBC:
+ handleMaximize(wwin,MAX_RIGHTHALF | MAX_BOTTOMHALF);
+ break;
+
+ case MAXC_MAXIMUS:
+ handleMaximize(wwin,MAX_MAXIMUS);
+ break;
+
+ }
+}
+
static void execMenuCommand(WMenu * menu, WMenuEntry * entry)
{
WWindow *wwin = (WWindow *) entry->clientdata;
@@ -345,6 +412,26 @@ static void updateOptionsMenu(WMenu * menu, WWindow * wwin)
wMenuRealize(smenu);
}
+static void updateMaximizeMenu(WMenu * menu, WWindow * wwin)
+{
+ WMenu *smenu = menu->cascades[menu->entries[MC_OTHERMAX]->cascade];
+
+ smenu->entries[MAXC_V]->clientdata = wwin;
+ smenu->entries[MAXC_H]->clientdata = wwin;
+ smenu->entries[MAXC_LH]->clientdata = wwin;
+ smenu->entries[MAXC_RH]->clientdata = wwin;
+ smenu->entries[MAXC_TH]->clientdata = wwin;
+ smenu->entries[MAXC_BH]->clientdata = wwin;
+ smenu->entries[MAXC_LTC]->clientdata = wwin;
+ smenu->entries[MAXC_RTC]->clientdata = wwin;
+ smenu->entries[MAXC_LBC]->clientdata = wwin;
+ smenu->entries[MAXC_RBC]->clientdata = wwin;
+ smenu->entries[MAXC_MAXIMUS]->clientdata = wwin;
+
+ smenu->flags.realized = 0;
+ wMenuRealize(smenu);
+}
+
static WMenu *makeWorkspaceMenu(WScreen * scr)
{
WMenu *menu;
@@ -400,6 +487,52 @@ static WMenu *makeOptionsMenu(WScreen * scr)
return menu;
}
+static WMenu *makeMaximizeMenu(WScreen * scr)
+{
+ WMenu *menu;
+ WMenuEntry *entry;
+
+ menu = wMenuCreate(scr, NULL, False);
+ if (!menu) {
+ wwarning(_("could not create submenu for window menu"));
+ return NULL;
+ }
+
+ entry = wMenuAddCallback(menu, _("Maximize vertically"),
execMaximizeCommand, NULL);
+ entry->rtext = GetShortcutKey(wKeyBindings[WKBD_VMAXIMIZE]);
+ entry = wMenuAddCallback(menu, _("Maximize horizontally"),
execMaximizeCommand, NULL);
+ entry->rtext = GetShortcutKey(wKeyBindings[WKBD_HMAXIMIZE]);
+
+ entry = wMenuAddCallback(menu, _("Maximize left half"),
execMaximizeCommand, NULL);
+ entry->rtext = GetShortcutKey(wKeyBindings[WKBD_LHMAXIMIZE]);
+
+ entry = wMenuAddCallback(menu, _("Maximize right half"),
execMaximizeCommand, NULL);
+ entry->rtext = GetShortcutKey(wKeyBindings[WKBD_RHMAXIMIZE]);
+
+ entry = wMenuAddCallback(menu, _("Maximize top half"),
execMaximizeCommand, NULL);
+ entry->rtext = GetShortcutKey(wKeyBindings[WKBD_THMAXIMIZE]);
+
+ entry = wMenuAddCallback(menu, _("Maximize bottom half"),
execMaximizeCommand, NULL);
+ entry->rtext = GetShortcutKey(wKeyBindings[WKBD_BHMAXIMIZE]);
+
+ entry = wMenuAddCallback(menu, _("Maximize left top corner"),
execMaximizeCommand, NULL);
+ entry->rtext = GetShortcutKey(wKeyBindings[WKBD_LTCMAXIMIZE]);
+
+ entry = wMenuAddCallback(menu, _("Maximize right top corner"),
execMaximizeCommand, NULL);
+ entry->rtext = GetShortcutKey(wKeyBindings[WKBD_RTCMAXIMIZE]);
+
+ entry = wMenuAddCallback(menu, _("Maximize left bottom corner"),
execMaximizeCommand, NULL);
+ entry->rtext = GetShortcutKey(wKeyBindings[WKBD_LBCMAXIMIZE]);
+
+ entry = wMenuAddCallback(menu, _("Maximize right bottom corner"),
execMaximizeCommand, NULL);
+ entry->rtext = GetShortcutKey(wKeyBindings[WKBD_RBCMAXIMIZE]);
+
+ entry = wMenuAddCallback(menu, _("Maximus: tiled maximization"),
execMaximizeCommand, NULL);
+ entry->rtext = GetShortcutKey(wKeyBindings[WKBD_MAXIMUS]);
+
+ return menu;
+}
+
static WMenu *createWindowMenu(WScreen * scr)
{
WMenu *menu;
@@ -414,6 +547,9 @@ static WMenu *createWindowMenu(WScreen * scr)
entry = wMenuAddCallback(menu, _("Maximize"), execMenuCommand, NULL);
entry->rtext = GetShortcutKey(wKeyBindings[WKBD_MAXIMIZE]);
+ entry = wMenuAddCallback(menu, _("Other maximization options"), NULL,
NULL);
+ wMenuEntrySetCascade(menu, entry, makeMaximizeMenu(scr));
+
entry = wMenuAddCallback(menu, _("Miniaturize"), execMenuCommand, NULL);
entry->rtext = GetShortcutKey(wKeyBindings[WKBD_MINIATURIZE]);
@@ -471,6 +607,7 @@ static void updateMenuForWindow(WMenu * menu, WWindow *
wwin)
int i;
updateOptionsMenu(menu, wwin);
+ updateMaximizeMenu(menu, wwin);
updateMakeShortcutMenu(menu, wwin);
--
1.8.1.2
--
To unsubscribe, send mail to [email protected].