]> git.mdlowis.com Git - proto/labwc.git/commitdiff
Add action UnMaximize
authorJohan Malm <jgm323@gmail.com>
Sun, 19 May 2024 17:10:44 +0000 (18:10 +0100)
committerJohan Malm <johanmalm@users.noreply.github.com>
Mon, 27 May 2024 20:02:31 +0000 (21:02 +0100)
Suggested-by: @Vladimir-csp
Fixes: #1825
docs/labwc-actions.5.scd
src/action.c

index 1c1fe7817155684a6711ea4b93934fbd78a8df94..a8d8bba57e4e36dc331814bc0921bcfcde9532e5 100644 (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" />*
index 3d14d5d0317d73ad3ff0d5b77549b17e47d0fbd1..6f6bee946c6796fb8a38b0052669f282d3dbf168 100644 (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);