Skip to content
This repository has been archived by the owner on Nov 7, 2022. It is now read-only.

Commit

Permalink
Fix motif logic for new floats
Browse files Browse the repository at this point in the history
- manage.c still used wrong `motif_border_style == BS_NORMAL`
- container must be set to floating first for correct code path and
  correct max_user_border_style to be used in con_set_border_style
- Motif test now includes default_floating_border
  • Loading branch information
orestisfl authored and stapelberg committed Sep 24, 2022
1 parent f6097d4 commit 8ec4133
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 16 deletions.
18 changes: 7 additions & 11 deletions src/manage.c
Original file line number Diff line number Diff line change
Expand Up @@ -511,6 +511,13 @@ void manage_window(xcb_window_t window, xcb_get_window_attributes_cookie_t cooki
if (nc->geometry.width == 0)
nc->geometry = (Rect){geom->x, geom->y, geom->width, geom->height};

if (want_floating) {
DLOG("geometry = %d x %d\n", nc->geometry.width, nc->geometry.height);
if (floating_enable(nc, true)) {
nc->floating = FLOATING_AUTO_ON;
}
}

if (has_mwm_hints) {
DLOG("MOTIF_WM_HINTS specifies decorations (border_style = %d)\n", motif_border_style);
if (want_floating) {
Expand All @@ -520,17 +527,6 @@ void manage_window(xcb_window_t window, xcb_get_window_attributes_cookie_t cooki
}
}

if (want_floating) {
DLOG("geometry = %d x %d\n", nc->geometry.width, nc->geometry.height);
/* automatically set the border to the default value if a motif border
* was not specified */
bool automatic_border = (motif_border_style == BS_NORMAL);

if (floating_enable(nc, automatic_border)) {
nc->floating = FLOATING_AUTO_ON;
}
}

/* explicitly set the border width to the default */
if (nc->current_border_width == -1) {
nc->current_border_width = (want_floating ? config.default_floating_border_width : config.default_border_width);
Expand Down
42 changes: 37 additions & 5 deletions testcases/t/548-motif-hints.t
Original file line number Diff line number Diff line change
Expand Up @@ -23,18 +23,38 @@ use List::Util qw(first);
use i3test i3_autostart => 0;
use X11::XCB qw(:all);

my $use_floating;
sub subtest_with_config {
my ($style, $cb) = @_;
my $some_other_style = $style eq "normal" ? "pixel" : "normal";

subtest 'with tiling', sub {
my $config = <<EOT;
# i3 config file (v4)
font -misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1
default_border $style
default_floating_border $some_other_style
EOT
my $pid = launch_with_config($config);
$use_floating = 0;
$cb->();
exit_gracefully($pid);
};

subtest 'with floating', sub {
my $config = <<EOT;
# i3 config file (v4)
font -misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1
default_border $some_other_style
default_floating_border $style
EOT
my $pid = launch_with_config($config);
$use_floating = 1;
$cb->();
kill_all_windows;
exit_gracefully($pid);
};
}

sub _change_motif_property {
Expand All @@ -51,7 +71,16 @@ sub _change_motif_property {

sub open_window_with_motifs {
my $value = shift;
my $window = open_window(

# we don't need other windows anymore, simplifies get_border_style
kill_all_windows;

my $open = \&open_window;
if ($use_floating) {
$open = \&open_floating_window;
}

my $window = $open->(
before_map => sub {
my ($window) = @_;
_change_motif_property($window, $value);
Expand All @@ -71,9 +100,12 @@ sub change_motif_property {
}

sub get_border_style {
my @content = @{get_ws_content(focused_ws)};
my $wininfo = first { $_->{window} == $window->id } @content;
return $wininfo->{border};
if ($use_floating) {
my @floating = @{get_ws(focused_ws)->{floating_nodes}};
return $floating[0]->{nodes}[0]->{border};
}

return @{get_ws(focused_ws)->{nodes}}[0]->{border};
}

sub is_border_style {
Expand Down

0 comments on commit 8ec4133

Please sign in to comment.