floating_con->rect.height += border_rect.height;
}
+ if (focused_con->window->max_width) {
+ floating_con->rect.width -= border_rect.width;
+ floating_con->rect.width = min(floating_con->rect.width, focused_con->window->max_width);
+ floating_con->rect.width += border_rect.width;
+ }
+
+ if (focused_con->window->max_height) {
+ floating_con->rect.height -= border_rect.height;
+ floating_con->rect.height = min(floating_con->rect.height, focused_con->window->max_height);
+ floating_con->rect.height += border_rect.height;
+ }
+
if (focused_con->window->height_increment &&
floating_con->rect.height >= focused_con->window->base_height + border_rect.height) {
floating_con->rect.height -= focused_con->window->base_height + border_rect.height;
con->window->min_height = size_hints.min_height;
}
+ if ((size_hints.flags & XCB_ICCCM_SIZE_HINT_P_MAX_SIZE)) {
+ DLOG("Maximum size: %d (width) x %d (height)\n", size_hints.max_width, size_hints.max_height);
+
+ con->window->max_width = size_hints.max_width;
+ con->window->max_height = size_hints.max_height;
+ }
+
if (con_is_floating(con)) {
win_width = MAX(win_width, con->window->min_width);
win_height = MAX(win_height, con->window->min_height);
+ win_width = MIN(win_width, con->window->max_width);
+ win_height = MIN(win_height, con->window->max_height);
}
bool changed = false;
nc->window->min_height = wm_size_hints.min_height;
}
+ if (wm_size_hints.flags & XCB_ICCCM_SIZE_HINT_P_MAX_SIZE) {
+ DLOG("Window specifies maximum size %d x %d\n", wm_size_hints.max_width, wm_size_hints.max_height);
+ nc->window->max_width = wm_size_hints.max_width;
+ nc->window->max_height = wm_size_hints.max_height;
+ }
+
/* Store the requested geometry. The width/height gets raised to at least
* 75x50 when entering floating mode, which is the minimum size for a
* window to be useful (smaller windows are usually overlays/toolbars/…
#
use i3test i3_autostart => 0;
+use X11::XCB qw/PROP_MODE_REPLACE/;
################################################################################
# 1: check floating_minimum_size (with non-default limits)
exit_gracefully($pid);
+################################################################################
+# 8: check minimum_size and maximum_size set by WM_NORMAL_HINTS
+################################################################################
+
+$config = <<EOT;
+# i3 config file (v4)
+font -misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1
+EOT
+
+my $min_width = 150;
+my $min_height = 100;
+my $max_width = 250;
+my $max_height = 200;
+
+my sub open_with_max_size {
+ # The type of the WM_NORMAL_HINTS property is WM_SIZE_HINTS
+ # https://tronche.com/gui/x/icccm/sec-4.html#s-4.1.2.3
+ my $XCB_ICCCM_SIZE_HINT_P_MIN_SIZE = 0x32;
+ my $XCB_ICCCM_SIZE_HINT_P_MAX_SIZE = 0x16;
+
+ my $flags = $XCB_ICCCM_SIZE_HINT_P_MIN_SIZE | $XCB_ICCCM_SIZE_HINT_P_MAX_SIZE;
+
+ my $pad = 0x00;
+
+ my $window = open_window(
+ before_map => sub {
+ my ($window) = @_;
+
+ my $atomname = $x->atom(name => 'WM_NORMAL_HINTS');
+ my $atomtype = $x->atom(name => 'WM_SIZE_HINTS');
+ $x->change_property(
+ PROP_MODE_REPLACE,
+ $window->id,
+ $atomname->id,
+ $atomtype->id,
+ 32,
+ 13,
+ pack('C5N8', $flags, $pad, $pad, $pad, $pad, 0, 0, 0, $min_width, $min_height, $max_width, $max_height),
+ );
+ },
+ );
+
+ return $window;
+}
+
+my sub check_minsize {
+ is($window->rect->{width}, $min_width, 'width = min_width');
+ is($window->rect->{height}, $min_height, 'height = min_height');
+}
+
+my sub check_maxsize {
+ is($window->rect->{width}, $max_width, 'width = max_width');
+ is($window->rect->{height}, $max_height, 'height = max_height');
+}
+
+$pid = launch_with_config($config);
+
+$window = open_with_max_size;
+cmd 'floating enable';
+cmd 'border none';
+sync_with_i3;
+
+cmd "resize set $min_width px $min_height px";
+check_minsize;
+
+# Try to resize below minimum width
+cmd 'resize set ' . ($min_width - 10) . ' px ' . ($min_height - 50) . ' px';
+check_minsize;
+
+cmd "resize set $max_width px $max_height px";
+check_maxsize;
+
+# Try to resize above maximum width
+cmd 'resize set ' . ($max_width + 150) . ' px ' . ($max_height + 500) . ' px';
+check_maxsize;
+
+exit_gracefully($pid);
+
done_testing;