From: Johan Malm Date: Sun, 19 May 2024 17:10:44 +0000 (+0100) Subject: Add action UnMaximize X-Git-Url: https://git.mdlowis.com/?a=commitdiff_plain;h=b1b48537a1f0c0a1264630ceb6a91cd8faaa537b;p=proto%2Flabwc.git Add action UnMaximize Suggested-by: @Vladimir-csp Fixes: #1825 --- diff --git a/docs/labwc-actions.5.scd b/docs/labwc-actions.5.scd index 1c1fe781..a8d8bba5 100644 --- a/docs/labwc-actions.5.scd +++ b/docs/labwc-actions.5.scd @@ -150,7 +150,12 @@ Actions are used in menus and keyboard/mouse bindings. "both" (default), "horizontal", and "vertical". ** - Maximize focused window. Supported directions are "both" (default), + Maximize focused window in the direction(s) specified. Supported + directions are "both" (default), "horizontal", and "vertical". + +** + Unmaximize focused window in the direction(s) specified and return it to + its pre-maximized dimensions. Supported directions are "both" (default), "horizontal", and "vertical". ** diff --git a/src/action.c b/src/action.c index 3d14d5d0..6f6bee94 100644 --- a/src/action.c +++ b/src/action.c @@ -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);