mirror of
https://github.com/gryf/wmaker.git
synced 2025-12-26 08:22:37 +01:00
Update shortcut label for Unmaximize menu entry.
The window menu Unmaximize entry had the Maximize shortcut key as its label. That's because the Maximize and Unmaximize menu options are in fact the same single entry with different text depending on the window's state. It can, however, cause confusion if a window is maximized using one of the "Other maximization" options such as Maximus. Selecting the Unmaximize entry from the window menu would indeed unmaximize the window but pressing the listed shortcut key would not. We now dynamically update the shortcut label so that it shows a key which will actually unmaximize the window. Thus the menu description and shortcut action are now consistent.
This commit is contained in:
committed by
Carlos R. Mafra
parent
df7fb014e5
commit
766e8ad575
@@ -173,6 +173,63 @@ static void execMaximizeCommand(WMenu * menu, WMenuEntry * entry)
|
||||
}
|
||||
}
|
||||
|
||||
static void updateUnmaximizeShortcut(WMenuEntry * entry, int flags)
|
||||
{
|
||||
int key;
|
||||
|
||||
switch (flags & (MAX_HORIZONTAL | MAX_VERTICAL | MAX_LEFTHALF | MAX_RIGHTHALF | MAX_TOPHALF | MAX_BOTTOMHALF | MAX_MAXIMUS)) {
|
||||
case MAX_HORIZONTAL:
|
||||
key = WKBD_HMAXIMIZE;
|
||||
break;
|
||||
|
||||
case MAX_VERTICAL:
|
||||
key = WKBD_VMAXIMIZE;
|
||||
break;
|
||||
|
||||
case MAX_LEFTHALF | MAX_VERTICAL:
|
||||
key = WKBD_LHMAXIMIZE;
|
||||
break;
|
||||
|
||||
case MAX_RIGHTHALF | MAX_VERTICAL:
|
||||
key = WKBD_RHMAXIMIZE;
|
||||
break;
|
||||
|
||||
case MAX_TOPHALF | MAX_HORIZONTAL:
|
||||
key = WKBD_THMAXIMIZE;
|
||||
break;
|
||||
|
||||
case MAX_BOTTOMHALF | MAX_HORIZONTAL:
|
||||
key = WKBD_BHMAXIMIZE;
|
||||
break;
|
||||
|
||||
case MAX_LEFTHALF | MAX_TOPHALF:
|
||||
key = WKBD_LTCMAXIMIZE;
|
||||
break;
|
||||
|
||||
case MAX_RIGHTHALF | MAX_TOPHALF:
|
||||
key = WKBD_RTCMAXIMIZE;
|
||||
break;
|
||||
|
||||
case MAX_LEFTHALF | MAX_BOTTOMHALF:
|
||||
key = WKBD_LBCMAXIMIZE;
|
||||
break;
|
||||
|
||||
case MAX_RIGHTHALF | MAX_BOTTOMHALF:
|
||||
key = WKBD_RBCMAXIMIZE;
|
||||
break;
|
||||
|
||||
case MAX_MAXIMUS:
|
||||
key = WKBD_MAXIMUS;
|
||||
break;
|
||||
|
||||
default:
|
||||
key = WKBD_MAXIMIZE;
|
||||
break;
|
||||
}
|
||||
|
||||
entry->rtext = GetShortcutKey(wKeyBindings[key]);
|
||||
}
|
||||
|
||||
static void execMenuCommand(WMenu * menu, WMenuEntry * entry)
|
||||
{
|
||||
WWindow *wwin = (WWindow *) entry->clientdata;
|
||||
@@ -644,12 +701,14 @@ static void updateMenuForWindow(WMenu * menu, WWindow * wwin)
|
||||
text = _("Unmaximize");
|
||||
|
||||
menu->entries[MC_MAXIMIZE]->text = text;
|
||||
updateUnmaximizeShortcut(menu->entries[MC_MAXIMIZE], wwin->flags.maximized);
|
||||
} else {
|
||||
static char *text = NULL;
|
||||
if (!text)
|
||||
text = _("Maximize");
|
||||
|
||||
menu->entries[MC_MAXIMIZE]->text = text;
|
||||
menu->entries[MC_MAXIMIZE]->rtext = GetShortcutKey(wKeyBindings[WKBD_MAXIMIZE]);
|
||||
}
|
||||
wMenuSetEnabled(menu, MC_MAXIMIZE, IS_RESIZABLE(wwin));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user