]> git.mdlowis.com Git - proto/labwc.git/commitdiff
action: add UnSnap action
authorJens Peters <jp7677@gmail.com>
Sat, 21 Sep 2024 13:54:30 +0000 (15:54 +0200)
committerHiroaki Yamamoto <hrak1529@gmail.com>
Wed, 25 Sep 2024 08:59:10 +0000 (17:59 +0900)
Same untiling behavior as ToggleSnapToEdge/Region,
but unconditionally.

Co-authored-by: tokyo4j <hrak1529@gmail.com>
docs/labwc-actions.5.scd
src/action.c

index 0731f8cc61f20e2327867489f5ac20c45b39d5f5..8aaae041e2a7b3427716b6a8142db1a3c60201ae 100644 (file)
@@ -108,6 +108,10 @@ Actions are used in menus and keyboard/mouse bindings.
 
        See labwc-config(5) for further information on how to define regions.
 
+*<action name="UnSnap" />*
+       Resize and move active window back to its untiled position if
+       it had been tiled to a direction or region.
+
 *<action name="NextWindow" />*++
 *<action name="PreviousWindow" />*
        Cycle focus to next/previous window respectively.++
index fcbfc47ab4cbb45b5b23031b67658c74f43acaac..de259e88daa0636a416e187991f961a9e121b73c 100644 (file)
@@ -102,6 +102,7 @@ enum action_type {
        ACTION_TYPE_GO_TO_DESKTOP,
        ACTION_TYPE_TOGGLE_SNAP_TO_REGION,
        ACTION_TYPE_SNAP_TO_REGION,
+       ACTION_TYPE_UNSNAP,
        ACTION_TYPE_TOGGLE_KEYBINDS,
        ACTION_TYPE_FOCUS_OUTPUT,
        ACTION_TYPE_MOVE_TO_OUTPUT,
@@ -165,6 +166,7 @@ const char *action_names[] = {
        "GoToDesktop",
        "ToggleSnapToRegion",
        "SnapToRegion",
+       "UnSnap",
        "ToggleKeybinds",
        "FocusOutput",
        "MoveToOutput",
@@ -1169,6 +1171,13 @@ actions_run(struct view *activator, struct server *server,
                                wlr_log(WLR_ERROR, "Invalid SnapToRegion id: '%s'", region_name);
                        }
                        break;
+               case ACTION_TYPE_UNSNAP:
+                       if (view && view->maximized == VIEW_AXIS_NONE && !view->fullscreen
+                                       && view_is_tiled(view)) {
+                               view_set_untiled(view);
+                               view_apply_natural_geometry(view);
+                       }
+                       break;
                case ACTION_TYPE_TOGGLE_KEYBINDS:
                        if (view) {
                                view_toggle_keybinds(view);