From 5489db6bc84b402de85643e6e86b18379e67864b Mon Sep 17 00:00:00 2001 From: Orestis Floros Date: Tue, 19 Sep 2023 22:02:31 +0200 Subject: motif hints: respect maximum border style in append_layout --- release-notes/bugfixes/6-motif-append_layout | 1 + src/load_layout.c | 19 +++++----- testcases/t/548-motif-hints.t | 53 +++++++++++++++++++++++++--- 3 files changed, 60 insertions(+), 13 deletions(-) create mode 100644 release-notes/bugfixes/6-motif-append_layout diff --git a/release-notes/bugfixes/6-motif-append_layout b/release-notes/bugfixes/6-motif-append_layout new file mode 100644 index 00000000..4437ab5a --- /dev/null +++ b/release-notes/bugfixes/6-motif-append_layout @@ -0,0 +1 @@ +motif hints: respect maximum border style in append_layout diff --git a/src/load_layout.c b/src/load_layout.c index edcd50e9..603b029d 100644 --- a/src/load_layout.c +++ b/src/load_layout.c @@ -351,17 +351,18 @@ static int json_string(void *ctx, const unsigned char *val, size_t len) { } else if (strcasecmp(last_key, "border") == 0) { char *buf = NULL; sasprintf(&buf, "%.*s", (int)len, val); - if (strcasecmp(buf, "none") == 0) - json_node->border_style = BS_NONE; - else if (strcasecmp(buf, "1pixel") == 0) { - json_node->border_style = BS_PIXEL; + if (strcasecmp(buf, "none") == 0) { + json_node->max_user_border_style = json_node->border_style = BS_NONE; + } else if (strcasecmp(buf, "1pixel") == 0) { + json_node->max_user_border_style = json_node->border_style = BS_PIXEL; json_node->current_border_width = 1; - } else if (strcasecmp(buf, "pixel") == 0) - json_node->border_style = BS_PIXEL; - else if (strcasecmp(buf, "normal") == 0) - json_node->border_style = BS_NORMAL; - else + } else if (strcasecmp(buf, "pixel") == 0) { + json_node->max_user_border_style = json_node->border_style = BS_PIXEL; + } else if (strcasecmp(buf, "normal") == 0) { + json_node->max_user_border_style = json_node->border_style = BS_NORMAL; + } else { LOG("Unhandled \"border\": %s\n", buf); + } free(buf); } else if (strcasecmp(last_key, "type") == 0) { char *buf = NULL; diff --git a/testcases/t/548-motif-hints.t b/testcases/t/548-motif-hints.t index 1f0276fa..7174af82 100644 --- a/testcases/t/548-motif-hints.t +++ b/testcases/t/548-motif-hints.t @@ -18,10 +18,12 @@ # accordingly, respecting user configuration. # Ticket: #3678 # Ticket: #5149 +# Ticket: #5438 # Bug still in: 4.21 +use File::Temp qw(tempfile); use List::Util qw(first); -use i3test i3_autostart => 0; use X11::XCB qw(:all); +use i3test i3_autostart => 0; my $use_floating; sub subtest_with_config { @@ -71,10 +73,12 @@ sub _change_motif_property { } sub open_window_with_motifs { - my $value = shift; + my ($value, %args) = @_; + + $args{kill_all} //= 1; # we don't need other windows anymore, simplifies get_border_style - kill_all_windows; + kill_all_windows if $args{kill_all}; my $open = \&open_window; if ($use_floating) { @@ -82,6 +86,7 @@ sub open_window_with_motifs { } my $window = $open->( + %args, before_map => sub { my ($window) = @_; _change_motif_property($window, $value); @@ -117,7 +122,7 @@ sub is_border_style { } local $Test::Builder::Level = $Test::Builder::Level + 1; - is(get_border_style($window), $expected, $msg); + is(get_border_style, $expected, $msg); } ############################################################################### @@ -202,4 +207,44 @@ change_motif_property(1); is_border_style('pixel', 'because of user maximum=pixel'); }; +############################################################################### +# Test with append_layout +# See #5438 +############################################################################### + +$use_floating = 0; + +my $config = < 1); +print $fh <<'EOT'; +{ + "nodes": [ + { + "border": "none", + "swallows": [ + { + "class": "^Special$" + } + ], + "type": "con" + } + ], + "type": "con" +} +EOT +$fh->flush; +cmd "append_layout $filename"; + +# can't use get_border_style because append_layout creates a parent container +is(@{get_ws(focused_ws)->{nodes}}[0]->{nodes}[0]->{border}, 'none', 'placeholder has border style none'); + +$window = open_window_with_motifs(1, wm_class => 'Special', instance => 'Special', kill_all => 0); +is(@{get_ws(focused_ws)->{nodes}}[0]->{nodes}[0]->{border}, 'none', 'window has border style none'); + done_testing; -- cgit v1.2.3-54-g00ecf