diff options
author | Michael Stapelberg <stapelberg@users.noreply.github.com> | 2022-11-12 14:08:13 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-11-12 14:08:13 +0100 |
commit | d1301262048592390ff2e8e3bbc2300cd77bd917 (patch) | |
tree | 041cf3db9e0a479e33dff773d43a87dfbc29f0a5 /src | |
parent | 2b236955bd0dbe8a8a7322ecfd59304d6a7e92b8 (diff) | |
download | i3-d1301262048592390ff2e8e3bbc2300cd77bd917.tar.gz i3-d1301262048592390ff2e8e3bbc2300cd77bd917.zip |
gaps: fix inner gaps for stacked/tabbed containers in splith/splitv (#5275)
Fixes https://github.com/i3/i3/issues/5261
Diffstat (limited to 'src')
-rw-r--r-- | src/con.c | 15 | ||||
-rw-r--r-- | src/gaps.c | 23 |
2 files changed, 30 insertions, 8 deletions
@@ -2579,3 +2579,18 @@ void con_merge_into(Con *old, Con *new) { tree_close_internal(old, DONT_KILL_WINDOW, false); } + +/* + * Returns true if the container is within any stacked/tabbed split container. + * + */ +bool con_inside_stacked_or_tabbed(Con *con) { + if (con->parent == NULL) { + return false; + } + if (con->parent->layout == L_STACKED || + con->parent->layout == L_TABBED) { + return true; + } + return con_inside_stacked_or_tabbed(con->parent); +} @@ -47,20 +47,27 @@ gaps_t calculate_effective_gaps(Con *con) { * Decides whether the container should be inset. */ bool gaps_should_inset_con(Con *con, int children) { + /* No parent? None of the conditionals below can be true. */ + if (con->parent == NULL) { + return false; + } + + const bool leaf_or_stacked_tabbed = + con_is_leaf(con) || + (con->layout == L_STACKED || con->layout == L_TABBED); + /* Inset direct children of the workspace that are leaf containers or stacked/tabbed containers. */ - if (con->parent != NULL && - con->parent->type == CT_WORKSPACE && - (con_is_leaf(con) || - (con->layout == L_STACKED || con->layout == L_TABBED))) { + if (leaf_or_stacked_tabbed && + con->parent->type == CT_WORKSPACE) { return true; } /* Inset direct children of vertical or horizontal split containers at any - depth in the tree (only leaf containers, not split containers within - split containers, to avoid double insets). */ - if (con_is_leaf(con) && - con->parent != NULL && + depth in the tree. Do not inset as soon as any parent is a stacked or + tabbed container, to avoid double insets. */ + if (leaf_or_stacked_tabbed && + !con_inside_stacked_or_tabbed(con) && con->parent->type == CT_CON && (con->parent->layout == L_SPLITH || con->parent->layout == L_SPLITV)) { |