From 1089b0b201cef30fbfd03620339f5e8a166feded Mon Sep 17 00:00:00 2001 From: Joel Stemmer Date: Sat, 18 Aug 2012 15:25:00 +0200 Subject: [PATCH] fix resizing floating windows by height When resizing floating windows, changing the height was not correctly handled. This commit fixes that and adds testcases for shrinking and growing the width and height of floating windows. --- src/commands.c | 2 +- testcases/t/141-resize.t | 44 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 45 insertions(+), 1 deletion(-) diff --git a/src/commands.c b/src/commands.c index 66270f75..0cd7852b 100644 --- a/src/commands.c +++ b/src/commands.c @@ -490,7 +490,7 @@ static void cmd_resize_floating(I3_CMD, char *way, char *direction, Con *floatin if (strcmp(direction, "up") == 0) { floating_con->rect.y -= px; floating_con->rect.height += px; - } else if (strcmp(direction, "down") == 0) { + } 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; diff --git a/testcases/t/141-resize.t b/testcases/t/141-resize.t index 91aeca50..4f84f213 100644 --- a/testcases/t/141-resize.t +++ b/testcases/t/141-resize.t @@ -197,4 +197,48 @@ cmp_ok($content[0]->{rect}->{y}, '==', $oldrect->{y}, 'y the same as before'); cmp_ok($content[0]->{rect}->{height}, '>', $oldrect->{height}, 'height bigger than before'); cmp_ok($content[0]->{rect}->{width}, '==', $oldrect->{width}, 'width the same as before'); +# grow width +$oldrect = $content[0]->{rect}; + +cmd 'resize grow width 10px or 10ppt'; + +@content = @{get_ws($tmp)->{floating_nodes}}; +cmp_ok($content[0]->{rect}->{x}, '==', $oldrect->{x}, 'x the same as before'); +cmp_ok($content[0]->{rect}->{y}, '==', $oldrect->{y}, 'y the same as before'); +cmp_ok($content[0]->{rect}->{height}, '==', $oldrect->{height}, 'height the same as before'); +cmp_ok($content[0]->{rect}->{width}, '>', $oldrect->{width}, 'width bigger than before'); + +# shrink width +$oldrect = $content[0]->{rect}; + +cmd 'resize shrink width 10px or 10ppt'; + +@content = @{get_ws($tmp)->{floating_nodes}}; +cmp_ok($content[0]->{rect}->{x}, '==', $oldrect->{x}, 'x the same as before'); +cmp_ok($content[0]->{rect}->{y}, '==', $oldrect->{y}, 'y the same as before'); +cmp_ok($content[0]->{rect}->{height}, '==', $oldrect->{height}, 'height the same as before'); +cmp_ok($content[0]->{rect}->{width}, '<', $oldrect->{width}, 'width smaller than before'); + +# grow height +$oldrect = $content[0]->{rect}; + +cmd 'resize grow height 10px or 10ppt'; + +@content = @{get_ws($tmp)->{floating_nodes}}; +cmp_ok($content[0]->{rect}->{x}, '==', $oldrect->{x}, 'x the same as before'); +cmp_ok($content[0]->{rect}->{y}, '==', $oldrect->{y}, 'y the same as before'); +cmp_ok($content[0]->{rect}->{height}, '>', $oldrect->{height}, 'height bigger than before'); +cmp_ok($content[0]->{rect}->{width}, '==', $oldrect->{width}, 'width the same as before'); + +# shrink height +$oldrect = $content[0]->{rect}; + +cmd 'resize shrink height 10px or 10ppt'; + +@content = @{get_ws($tmp)->{floating_nodes}}; +cmp_ok($content[0]->{rect}->{x}, '==', $oldrect->{x}, 'x the same as before'); +cmp_ok($content[0]->{rect}->{y}, '==', $oldrect->{y}, 'y the same as before'); +cmp_ok($content[0]->{rect}->{height}, '<', $oldrect->{height}, 'height smaller than before'); +cmp_ok($content[0]->{rect}->{width}, '==', $oldrect->{width}, 'width the same as before'); + done_testing; -- 2.39.5