mirror of
https://github.com/gryf/wmaker.git
synced 2025-12-28 09:22:27 +01:00
Add "Other maximization options" to window menu.
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.
This commit is contained in:
committed by
Carlos R. Mafra
parent
3ba54ed0d6
commit
86fbf8baaa
184
src/winmenu.c
184
src/winmenu.c
@@ -48,26 +48,45 @@
|
|||||||
#include "xinerama.h"
|
#include "xinerama.h"
|
||||||
#include "winmenu.h"
|
#include "winmenu.h"
|
||||||
|
|
||||||
#define MC_MAXIMIZE 0
|
enum
|
||||||
#define MC_MINIATURIZE 1
|
{
|
||||||
#define MC_SHADE 2
|
MC_MAXIMIZE,
|
||||||
#define MC_HIDE 3
|
MC_OTHERMAX,
|
||||||
#define MC_MOVERESIZE 4
|
MC_MINIATURIZE,
|
||||||
#define MC_SELECT 5
|
MC_SHADE,
|
||||||
#define MC_DUMMY_MOVETO 6
|
MC_HIDE,
|
||||||
#define MC_PROPERTIES 7
|
MC_MOVERESIZE,
|
||||||
#define MC_OPTIONS 8
|
MC_SELECT,
|
||||||
#define MC_SHORTCUT 8
|
MC_DUMMY_MOVETO,
|
||||||
#define MC_RELAUNCH 9
|
MC_PROPERTIES,
|
||||||
|
MC_OPTIONS,
|
||||||
|
MC_RELAUNCH,
|
||||||
|
MC_CLOSE,
|
||||||
|
MC_KILL
|
||||||
|
};
|
||||||
|
|
||||||
#define MC_CLOSE 10
|
enum
|
||||||
#define MC_KILL 11
|
{
|
||||||
|
WO_KEEP_ON_TOP,
|
||||||
#define WO_KEEP_ON_TOP 0
|
WO_KEEP_AT_BOTTOM,
|
||||||
#define WO_KEEP_AT_BOTTOM 1
|
WO_OMNIPRESENT,
|
||||||
#define WO_OMNIPRESENT 2
|
WO_ENTRIES
|
||||||
#define WO_ENTRIES 3
|
};
|
||||||
|
|
||||||
|
enum
|
||||||
|
{
|
||||||
|
MAXC_V,
|
||||||
|
MAXC_H,
|
||||||
|
MAXC_LH,
|
||||||
|
MAXC_RH,
|
||||||
|
MAXC_TH,
|
||||||
|
MAXC_BH,
|
||||||
|
MAXC_LTC,
|
||||||
|
MAXC_RTC,
|
||||||
|
MAXC_LBC,
|
||||||
|
MAXC_RBC,
|
||||||
|
MAXC_MAXIMUS
|
||||||
|
};
|
||||||
|
|
||||||
static void updateOptionsMenu(WMenu * menu, WWindow * wwin);
|
static void updateOptionsMenu(WMenu * menu, WWindow * wwin);
|
||||||
|
|
||||||
@@ -99,6 +118,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)
|
static void execMenuCommand(WMenu * menu, WMenuEntry * entry)
|
||||||
{
|
{
|
||||||
WWindow *wwin = (WWindow *) entry->clientdata;
|
WWindow *wwin = (WWindow *) entry->clientdata;
|
||||||
@@ -259,7 +333,7 @@ static void updateWorkspaceMenu(WMenu * menu)
|
|||||||
|
|
||||||
static void updateMakeShortcutMenu(WMenu *menu, WWindow *wwin)
|
static void updateMakeShortcutMenu(WMenu *menu, WWindow *wwin)
|
||||||
{
|
{
|
||||||
WMenu *smenu = menu->cascades[menu->entries[MC_SHORTCUT]->cascade];
|
WMenu *smenu = menu->cascades[menu->entries[MC_OPTIONS]->cascade];
|
||||||
int i;
|
int i;
|
||||||
char *buffer;
|
char *buffer;
|
||||||
int buflen;
|
int buflen;
|
||||||
@@ -345,6 +419,26 @@ static void updateOptionsMenu(WMenu * menu, WWindow * wwin)
|
|||||||
wMenuRealize(smenu);
|
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)
|
static WMenu *makeWorkspaceMenu(WScreen * scr)
|
||||||
{
|
{
|
||||||
WMenu *menu;
|
WMenu *menu;
|
||||||
@@ -400,6 +494,52 @@ static WMenu *makeOptionsMenu(WScreen * scr)
|
|||||||
return menu;
|
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)
|
static WMenu *createWindowMenu(WScreen * scr)
|
||||||
{
|
{
|
||||||
WMenu *menu;
|
WMenu *menu;
|
||||||
@@ -408,12 +548,15 @@ static WMenu *createWindowMenu(WScreen * scr)
|
|||||||
menu = wMenuCreate(scr, NULL, False);
|
menu = wMenuCreate(scr, NULL, False);
|
||||||
/*
|
/*
|
||||||
* Warning: If you make some change that affects the order of the
|
* Warning: If you make some change that affects the order of the
|
||||||
* entries, you must update the command #defines in the top of
|
* entries, you must update the command enum in the top of
|
||||||
* this file.
|
* this file.
|
||||||
*/
|
*/
|
||||||
entry = wMenuAddCallback(menu, _("Maximize"), execMenuCommand, NULL);
|
entry = wMenuAddCallback(menu, _("Maximize"), execMenuCommand, NULL);
|
||||||
entry->rtext = GetShortcutKey(wKeyBindings[WKBD_MAXIMIZE]);
|
entry->rtext = GetShortcutKey(wKeyBindings[WKBD_MAXIMIZE]);
|
||||||
|
|
||||||
|
entry = wMenuAddCallback(menu, _("Other maximization"), NULL, NULL);
|
||||||
|
wMenuEntrySetCascade(menu, entry, makeMaximizeMenu(scr));
|
||||||
|
|
||||||
entry = wMenuAddCallback(menu, _("Miniaturize"), execMenuCommand, NULL);
|
entry = wMenuAddCallback(menu, _("Miniaturize"), execMenuCommand, NULL);
|
||||||
entry->rtext = GetShortcutKey(wKeyBindings[WKBD_MINIATURIZE]);
|
entry->rtext = GetShortcutKey(wKeyBindings[WKBD_MINIATURIZE]);
|
||||||
|
|
||||||
@@ -471,6 +614,7 @@ static void updateMenuForWindow(WMenu * menu, WWindow * wwin)
|
|||||||
int i;
|
int i;
|
||||||
|
|
||||||
updateOptionsMenu(menu, wwin);
|
updateOptionsMenu(menu, wwin);
|
||||||
|
updateMaximizeMenu(menu, wwin);
|
||||||
|
|
||||||
updateMakeShortcutMenu(menu, wwin);
|
updateMakeShortcutMenu(menu, wwin);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user