Add action UnMaximize

Suggested-by: @Vladimir-csp

Fixes: #1825
This commit is contained in:
Johan Malm 2024-05-19 18:10:44 +01:00 committed by Johan Malm
parent 21f079e306
commit b1b48537a1
2 changed files with 17 additions and 1 deletions

View file

@ -150,7 +150,12 @@ Actions are used in menus and keyboard/mouse bindings.
"both" (default), "horizontal", and "vertical".
*<action name="Maximize" direction="value" />*
Maximize focused window. Supported directions are "both" (default),
Maximize focused window in the direction(s) specified. Supported
directions are "both" (default), "horizontal", and "vertical".
*<action name="UnMaximize" direction="value" />*
Unmaximize focused window in the direction(s) specified and return it to
its pre-maximized dimensions. Supported directions are "both" (default),
"horizontal", and "vertical".
*<action name="ToggleAlwaysOnTop" />*

View file

@ -78,6 +78,7 @@ enum action_type {
ACTION_TYPE_SHOW_MENU,
ACTION_TYPE_TOGGLE_MAXIMIZE,
ACTION_TYPE_MAXIMIZE,
ACTION_TYPE_UNMAXIMIZE,
ACTION_TYPE_TOGGLE_FULLSCREEN,
ACTION_TYPE_SET_DECORATIONS,
ACTION_TYPE_TOGGLE_DECORATIONS,
@ -135,6 +136,7 @@ const char *action_names[] = {
"ShowMenu",
"ToggleMaximize",
"Maximize",
"UnMaximize",
"ToggleFullscreen",
"SetDecorations",
"ToggleDecorations",
@ -338,6 +340,7 @@ action_arg_from_xml_node(struct action *action, const char *nodename, const char
break;
case ACTION_TYPE_TOGGLE_MAXIMIZE:
case ACTION_TYPE_MAXIMIZE:
case ACTION_TYPE_UNMAXIMIZE:
if (!strcmp(argument, "direction")) {
enum view_axis axis = view_axis_parse(content);
if (axis == VIEW_AXIS_NONE) {
@ -814,6 +817,14 @@ actions_run(struct view *activator, struct server *server,
/*store_natural_geometry*/ true);
}
break;
case ACTION_TYPE_UNMAXIMIZE:
if (view) {
enum view_axis axis = action_get_int(action,
"direction", VIEW_AXIS_BOTH);
view_maximize(view, view->maximized & ~axis,
/*store_natural_geometry*/ true);
}
break;
case ACTION_TYPE_TOGGLE_FULLSCREEN:
if (view) {
view_toggle_fullscreen(view);