From: Orestis Floros Date: Wed, 2 May 2018 15:59:17 +0000 (+0300) Subject: resize set: accept 'width' and 'height' keywords X-Git-Tag: 4.16~83^2 X-Git-Url: https://git.sur5r.net/?p=i3%2Fi3;a=commitdiff_plain;h=c50bf50f09cb428c94ffacd5e37f7a5a47c01248 resize set: accept 'width' and 'height' keywords Fixes #3275 --- diff --git a/docs/userguide b/docs/userguide index e8240390..a8b35f3e 100644 --- a/docs/userguide +++ b/docs/userguide @@ -2320,7 +2320,9 @@ If you want to resize containers/windows using your keyboard, you can use the *Syntax*: ------------------------------------------------------- resize grow|shrink [ px [or ppt]] -resize set [px | ppt] [px | ppt] +resize set [width] [px | ppt] +resize set height [px | ppt] +resize set [width] [px | ppt] [height] [px | ppt] ------------------------------------------------------- Direction can either be one of +up+, +down+, +left+ or +right+. Or you can be diff --git a/parser-specs/commands.spec b/parser-specs/commands.spec index 106dac99..c0c32933 100644 --- a/parser-specs/commands.spec +++ b/parser-specs/commands.spec @@ -254,12 +254,24 @@ state RESIZE_TILING_FINAL: -> call cmd_resize($way, $direction, &resize_px, &resize_ppt) state RESIZE_SET: + 'height' + -> RESIZE_HEIGHT_GET_NUMBER + 'width' + -> width = number -> RESIZE_WIDTH state RESIZE_WIDTH: mode_width = 'px', 'ppt' -> + end + -> call cmd_resize_set(&width, $mode_width, 0, 0) + 'height' + -> RESIZE_HEIGHT_GET_NUMBER + height = number + -> RESIZE_HEIGHT + +state RESIZE_HEIGHT_GET_NUMBER: height = number -> RESIZE_HEIGHT diff --git a/src/commands.c b/src/commands.c index 2d5ef362..c7b57ab3 100644 --- a/src/commands.c +++ b/src/commands.c @@ -686,7 +686,7 @@ void cmd_resize_set(I3_CMD, long cwidth, const char *mode_width, long cheight, c } } - if (cheight > 0 && mode_width && strcmp(mode_width, "ppt") == 0) { + if (cheight > 0 && mode_height && strcmp(mode_height, "ppt") == 0) { /* get the appropriate current container (skip stacked/tabbed cons) */ Con *target = current->con; Con *dummy; diff --git a/testcases/t/252-floating-size.t b/testcases/t/252-floating-size.t index 7875cb07..5c746de9 100644 --- a/testcases/t/252-floating-size.t +++ b/testcases/t/252-floating-size.t @@ -96,4 +96,22 @@ do_test(0, 0); cmd 'resize set 100 ppt 0 px'; do_test(1333, 0); +################################################################################ +# Use 'width' and 'height' keywords. +# See issue: #3275. +################################################################################ + +cmd 'resize set width 200 px'; +do_test(200, 0); + +cmd 'resize set height 200 px'; +do_test(0, 200); + +cmd 'resize set width 300 px height 300 px'; +do_test(300, 300); + +# ppt + keyword used only for height +cmd 'resize set 100 ppt height 100 px'; +do_test(1333, 100); + done_testing; diff --git a/testcases/t/541-resize-set-tiling.t b/testcases/t/541-resize-set-tiling.t index 82267baf..fcf3267a 100644 --- a/testcases/t/541-resize-set-tiling.t +++ b/testcases/t/541-resize-set-tiling.t @@ -39,6 +39,14 @@ my ($nodes, $focus) = get_ws_content($tmp); cmp_float($nodes->[0]->{percent}, 0.25, 'left window got only 25%'); cmp_float($nodes->[1]->{percent}, 0.75, 'right window got 75%'); +# Same but use the 'width' keyword. +cmd 'resize set width 80 ppt'; + +($nodes, $focus) = get_ws_content($tmp); + +cmp_float($nodes->[0]->{percent}, 0.20, 'left window got 20%'); +cmp_float($nodes->[1]->{percent}, 0.80, 'right window got 80%'); + ############################################################ # resize vertically ############################################################ @@ -61,6 +69,13 @@ my ($nodes, $focus) = get_ws_content($tmp); cmp_float($nodes->[0]->{percent}, 0.25, 'top window got only 25%'); cmp_float($nodes->[1]->{percent}, 0.75, 'bottom window got 75%'); +# Same but use the 'height' keyword. +cmd 'resize set height 80 ppt'; + +($nodes, $focus) = get_ws_content($tmp); + +cmp_float($nodes->[0]->{percent}, 0.20, 'top window got 20%'); +cmp_float($nodes->[1]->{percent}, 0.80, 'bottom window got 80%'); ############################################################ # resize horizontally and vertically