From 694c5a7469e89987dc1aa873a1848f9a015b9d7f Mon Sep 17 00:00:00 2001 From: Jens Peters Date: Sat, 21 Sep 2024 15:54:30 +0200 Subject: [PATCH] action: add UnSnap action Same untiling behavior as ToggleSnapToEdge/Region, but unconditionally. Co-authored-by: tokyo4j --- docs/labwc-actions.5.scd | 4 ++++ src/action.c | 9 +++++++++ 2 files changed, 13 insertions(+) diff --git a/docs/labwc-actions.5.scd b/docs/labwc-actions.5.scd index 0731f8cc..8aaae041 100644 --- a/docs/labwc-actions.5.scd +++ b/docs/labwc-actions.5.scd @@ -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. +** + Resize and move active window back to its untiled position if + it had been tiled to a direction or region. + **++ ** Cycle focus to next/previous window respectively.++ diff --git a/src/action.c b/src/action.c index fcbfc47a..de259e88 100644 --- a/src/action.c +++ b/src/action.c @@ -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);