aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOrestis Floros <orestisflo@gmail.com>2023-09-19 22:02:31 +0200
committerMichael Stapelberg <stapelberg@users.noreply.github.com>2023-09-21 18:55:01 +0200
commit5489db6bc84b402de85643e6e86b18379e67864b (patch)
tree1ed1b806b2c606be0722385f227412cd0af27120
parentf4959d5da426ec154fe56abeb3a7c78d0d80af81 (diff)
downloadi3-5489db6bc84b402de85643e6e86b18379e67864b.tar.gz
i3-5489db6bc84b402de85643e6e86b18379e67864b.zip
motif hints: respect maximum border style in append_layout
-rw-r--r--release-notes/bugfixes/6-motif-append_layout1
-rw-r--r--src/load_layout.c19
-rw-r--r--testcases/t/548-motif-hints.t53
3 files changed, 60 insertions, 13 deletions
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 = <<EOT;
+# i3 config file (v4)
+font -misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1
+
+EOT
+my $pid = launch_with_config($config);
+
+my ($fh, $filename) = tempfile(UNLINK => 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;