Skip to content

Commit

Permalink
motif hints: respect maximum border style in append_layout
Browse files Browse the repository at this point in the history
  • Loading branch information
orestisfl authored and stapelberg committed Sep 21, 2023
1 parent f4959d5 commit 5489db6
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 13 deletions.
1 change: 1 addition & 0 deletions release-notes/bugfixes/6-motif-append_layout
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
motif hints: respect maximum border style in append_layout
19 changes: 10 additions & 9 deletions src/load_layout.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
53 changes: 49 additions & 4 deletions testcases/t/548-motif-hints.t
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -71,17 +73,20 @@ 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) {
$open = \&open_floating_window;
}

my $window = $open->(
%args,
before_map => sub {
my ($window) = @_;
_change_motif_property($window, $value);
Expand Down Expand Up @@ -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);
}

###############################################################################
Expand Down Expand Up @@ -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;

0 comments on commit 5489db6

Please sign in to comment.