From 170a322cc2bc411257014943ad84c19cc4779e05 Mon Sep 17 00:00:00 2001 From: Michael Stapelberg Date: Sat, 12 Nov 2022 14:58:13 +0100 Subject: [PATCH] fix: prevent gaps inside floating split containers (#5276) Fixes https://github.com/i3/i3/issues/5272 --- src/con.c | 5 ++++- src/gaps.c | 5 +++++ testcases/t/319-gaps.t | 31 +++++++++++++++++++++++++++++++ 3 files changed, 40 insertions(+), 1 deletion(-) diff --git a/src/con.c b/src/con.c index 5bf559a1..5ecc2700 100644 --- a/src/con.c +++ b/src/con.c @@ -618,7 +618,10 @@ bool con_is_docked(Con *con) { * */ Con *con_inside_floating(Con *con) { - assert(con != NULL); + if (con == NULL) { + return NULL; + } + if (con->type == CT_FLOATING_CON) return con; diff --git a/src/gaps.c b/src/gaps.c index 545c8b65..a67e8ceb 100644 --- a/src/gaps.c +++ b/src/gaps.c @@ -52,6 +52,11 @@ bool gaps_should_inset_con(Con *con, int children) { return false; } + /* Floating split containers should never have gaps inside them. */ + if (con_inside_floating(con)) { + return false; + } + const bool leaf_or_stacked_tabbed = con_is_leaf(con) || (con->layout == L_STACKED || con->layout == L_TABBED); diff --git a/testcases/t/319-gaps.t b/testcases/t/319-gaps.t index 1747c37d..eefb9281 100644 --- a/testcases/t/319-gaps.t +++ b/testcases/t/319-gaps.t @@ -202,4 +202,35 @@ is_gaps(); exit_gracefully($pid); +################################################################################ +# Ensure floating split containers don’t get gaps (issue #5272). +################################################################################ + +$config = <rect; +cmd 'border pixel 0'; +sync_with_i3; +is_deeply(scalar $floating->rect, $orig_rect, 'floating window position unchanged after border pixel 0'); + +cmd 'layout stacking'; +sync_with_i3; +is_deeply(scalar $floating->rect, $orig_rect, 'floating window position unchanged after border pixel 0'); + +exit_gracefully($pid); + done_testing;