From ca0c2a46e434e546c59537189b4cdf9ad1268e2f Mon Sep 17 00:00:00 2001 From: Michael Stapelberg Date: Thu, 27 Oct 2011 21:22:41 +0100 Subject: [PATCH 1/4] t/124-move.t: re-activate test for useless move commands --- testcases/t/124-move.t | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/testcases/t/124-move.t b/testcases/t/124-move.t index 4df3a2a1..936693fe 100644 --- a/testcases/t/124-move.t +++ b/testcases/t/124-move.t @@ -24,13 +24,13 @@ is(@{$old_content}, 1, 'one container on this workspace'); my $first = $old_content->[0]->{id}; -#cmd 'move before h'; -#cmd 'move before v'; -#cmd 'move after v'; -#cmd 'move after h'; +cmd 'move left'; +cmd 'move right'; +cmd 'move up'; +cmd 'move down'; my $content = get_ws_content($tmp); -#is_deeply($old_content, $content, 'workspace unmodified after useless moves'); +is_deeply($old_content, $content, 'workspace unmodified after useless moves'); ###################################################################### # 2) move a container before another single container From edfa9febae7cecd7743cecfaf27f6cb4f71d9d50 Mon Sep 17 00:00:00 2001 From: Michael Stapelberg Date: Thu, 27 Oct 2011 21:46:01 +0100 Subject: [PATCH 2/4] extend t/124-move.t to test move for floating containers --- testcases/t/124-move.t | 73 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 73 insertions(+) diff --git a/testcases/t/124-move.t b/testcases/t/124-move.t index 936693fe..a6eb6164 100644 --- a/testcases/t/124-move.t +++ b/testcases/t/124-move.t @@ -8,7 +8,9 @@ # 4) move a container in a different direction so that we need to go up in tree # use i3test; +use X11::XCB::Connection; +my $x = X11::XCB::Connection->new; my $i3 = i3(get_socket_path()); my $tmp = fresh_workspace; @@ -131,4 +133,75 @@ cmd "move right"; $content = get_ws_content($otmp); is(@{$content}, 1, 'only one nodes on this workspace'); +###################################################################### +# 5) test moving floating containers. +###################################################################### + +$tmp = fresh_workspace; +my $floatwin = open_floating_window($x); +my ($absolute_before, $top_before) = $floatwin->rect; + +cmd 'move left'; + +my ($absolute, $top) = $floatwin->rect; + +is($absolute->x, ($absolute_before->x - 10), 'moved 10 px to the left'); +is($absolute->y, $absolute_before->y, 'y not changed'); +is($absolute->width, $absolute_before->width, 'width not changed'); +is($absolute->height, $absolute_before->height, 'height not changed'); + +$absolute_before = $absolute; +$top_before = $top; + +cmd 'move right'; + +($absolute, $top) = $floatwin->rect; + +is($absolute->x, ($absolute_before->x + 10), 'moved 10 px to the right'); +is($absolute->y, $absolute_before->y, 'y not changed'); +is($absolute->width, $absolute_before->width, 'width not changed'); +is($absolute->height, $absolute_before->height, 'height not changed'); + +$absolute_before = $absolute; +$top_before = $top; + +cmd 'move up'; + +($absolute, $top) = $floatwin->rect; + +is($absolute->x, $absolute_before->x, 'x not changed'); +is($absolute->y, ($absolute_before->y - 10), 'moved 10 px up'); +is($absolute->width, $absolute_before->width, 'width not changed'); +is($absolute->height, $absolute_before->height, 'height not changed'); + +$absolute_before = $absolute; +$top_before = $top; + +cmd 'move down'; + +($absolute, $top) = $floatwin->rect; + +is($absolute->x, $absolute_before->x, 'x not changed'); +is($absolute->y, ($absolute_before->y + 10), 'moved 10 px up'); +is($absolute->width, $absolute_before->width, 'width not changed'); +is($absolute->height, $absolute_before->height, 'height not changed'); + +$absolute_before = $absolute; +$top_before = $top; + +###################################################################### +# 6) test moving floating containers with a specific amount of px +###################################################################### + +cmd 'move left 20 px'; + +($absolute, $top) = $floatwin->rect; + +is($absolute->x, ($absolute_before->x - 20), 'moved 10 px to the left'); +is($absolute->y, $absolute_before->y, 'y not changed'); +is($absolute->width, $absolute_before->width, 'width not changed'); +is($absolute->height, $absolute_before->height, 'height not changed'); + + + done_testing; From df980bffa4efbb7f37af876292177a6507334c84 Mon Sep 17 00:00:00 2001 From: Michael Stapelberg Date: Thu, 27 Oct 2011 21:46:15 +0100 Subject: [PATCH 3/4] Make 'move' handle floating windows properly This means you can now specify an amount of pixels for the move command. The default is 10. Note that this of course only works for floating windows. Example: move left 20 px --- src/cmdparse.y | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/src/cmdparse.y b/src/cmdparse.y index 3eb33426..0144524b 100644 --- a/src/cmdparse.y +++ b/src/cmdparse.y @@ -734,10 +734,27 @@ border_style: ; move: - TOK_MOVE direction + TOK_MOVE direction resize_px { - printf("moving in direction %d\n", $2); - tree_move($2); + int direction = $2; + int px = $3; + + /* TODO: make 'move' work with criteria. */ + printf("moving in direction %d\n", direction); + if (con_is_floating(focused)) { + printf("floating move with %d pixels\n", px); + if (direction == TOK_LEFT) { + focused->parent->rect.x -= px; + } else if (direction == TOK_RIGHT) { + focused->parent->rect.x += px; + } else if (direction == TOK_UP) { + focused->parent->rect.y -= px; + } else if (direction == TOK_DOWN) { + focused->parent->rect.y += px; + } + } else { + tree_move(direction); + } tree_render(); } From 18c2ef33d3312e1d72cc2d2ab49d3e1ea6632cdf Mon Sep 17 00:00:00 2001 From: Michael Stapelberg Date: Thu, 27 Oct 2011 21:52:39 +0100 Subject: [PATCH 4/4] docs/userguide: Document the move syntax --- docs/userguide | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/docs/userguide b/docs/userguide index 851d66c3..d97ef6ae 100644 --- a/docs/userguide +++ b/docs/userguide @@ -1134,9 +1134,19 @@ mode_toggle:: For moving, use +move left+, +move right+, +move down+ and +move up+. +*Syntax*: +----------------------------------- +focus +focus +move [ px] +----------------------------------- + +Note that the amount of pixels you can specify for the +move+ command is only +relevant for floating containers. The default amount is 10 pixels. + *Examples*: ---------------------- -# Focus clients on the left, bottom, top, right: +# Focus container on the left, bottom, top, right: bindsym mod+j focus left bindsym mod+k focus down bindsym mod+l focus up @@ -1148,11 +1158,15 @@ bindsym mod+u focus parent # Focus last floating/tiling container bindsym mod+g focus mode_toggle -# Move client to the left, bottom, top, right: +# Move container to the left, bottom, top, right: bindsym mod+j move left bindsym mod+k move down bindsym mod+l move up bindsym mod+semicolon move right + +# Move container, but make floating containers +# move more than the default +bindsym mod+j move left 20 px ---------------------- === Changing (named) workspaces/moving to workspaces