From 1ae08b196a84de61547497a067277ebb217049c4 Mon Sep 17 00:00:00 2001 From: Michael Stapelberg Date: Tue, 27 Nov 2012 09:26:31 +0100 Subject: [PATCH] =?utf8?q?Bugfix:=20Don=E2=80=99t=20move=20floating=20wind?= =?utf8?q?ows=20when=20their=20size=20constraints=20forbid=20resizing=20(T?= =?utf8?q?hanks=20aksr)?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit fixes #883 --- src/commands.c | 15 +++++++++++++-- testcases/t/189-floating-constraints.t | 7 +++++++ 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/src/commands.c b/src/commands.c index 0f36cd38..2ca8387c 100644 --- a/src/commands.c +++ b/src/commands.c @@ -576,19 +576,30 @@ void cmd_move_con_to_workspace_number(I3_CMD, char *which) { static void cmd_resize_floating(I3_CMD, char *way, char *direction, Con *floating_con, int px) { LOG("floating resize\n"); + Rect old_rect = floating_con->rect; + if (strcmp(direction, "up") == 0) { - floating_con->rect.y -= px; floating_con->rect.height += px; } else if (strcmp(direction, "down") == 0 || strcmp(direction, "height") == 0) { floating_con->rect.height += px; } else if (strcmp(direction, "left") == 0) { - floating_con->rect.x -= px; floating_con->rect.width += px; } else { floating_con->rect.width += px; } floating_check_size(floating_con); + + /* Did we actually resize anything or did the size constraints prevent us? + * If we could not resize, exit now to not move the window. */ + if (memcmp(&old_rect, &(floating_con->rect), sizeof(Rect)) == 0) + return; + + if (strcmp(direction, "up") == 0) { + floating_con->rect.y -= px; + } else if (strcmp(direction, "left") == 0) { + floating_con->rect.x -= px; + } } static bool cmd_resize_tiling_direction(I3_CMD, Con *current, char *way, char *direction, int ppt) { diff --git a/testcases/t/189-floating-constraints.t b/testcases/t/189-floating-constraints.t index d907ddcc..0d3d2268 100644 --- a/testcases/t/189-floating-constraints.t +++ b/testcases/t/189-floating-constraints.t @@ -174,6 +174,13 @@ $rect = $window->rect; is($rect->{width}, 100, 'width = 100'); is($rect->{height}, 100, 'height = 100'); +my $old_x = $rect->{x}; +my $old_y = $rect->{y}; +cmd 'resize grow up 10px or 10ppt'; +$rect = $window->rect; +is($rect->{x}, $old_x, 'window did not move when trying to resize'); +is($rect->{y}, $old_y, 'window did not move when trying to resize'); + exit_gracefully($pid); done_testing; -- 2.39.5