summaryrefslogtreecommitdiff
path: root/x11-wm/i3-4.8/move.patch
diff options
context:
space:
mode:
authorRené 'Necoro' Neumann <necoro@necoro.net>2014-07-28 13:44:51 +0200
committerRené 'Necoro' Neumann <necoro@necoro.net>2014-07-28 13:44:51 +0200
commitda6b916d06d98047cceeb5a8cbd0b5954d9308c5 (patch)
tree1e2555f50b867ad3891584b45fbf8b030c8f0c09 /x11-wm/i3-4.8/move.patch
parentc743f78a9708f80c5901d075fe96ed6595bd26e6 (diff)
downloadpatches-da6b916d06d98047cceeb5a8cbd0b5954d9308c5.tar.gz
patches-da6b916d06d98047cceeb5a8cbd0b5954d9308c5.tar.bz2
patches-da6b916d06d98047cceeb5a8cbd0b5954d9308c5.zip
[i3] Move patch
Diffstat (limited to '')
-rw-r--r--x11-wm/i3-4.8/move.patch152
1 files changed, 152 insertions, 0 deletions
diff --git a/x11-wm/i3-4.8/move.patch b/x11-wm/i3-4.8/move.patch
new file mode 100644
index 0000000..c65bd8a
--- /dev/null
+++ b/x11-wm/i3-4.8/move.patch
@@ -0,0 +1,152 @@
+From c2b6b06da7db49bd3ecd6fa1561ef2b407ff64a3 Mon Sep 17 00:00:00 2001
+From: Tony Crisci <tony@dubstepdish.com>
+Date: Thu, 19 Jun 2014 12:09:31 +0000
+Subject: Make command `move [direction]` work with criteria
+
+A container selected with criteria should be moved with the `move
+[direction]` command, instead of this command always acting on the
+focused container.
+---
+diff --git a/include/move.h b/include/move.h
+index 5c8a7d2..939665e 100644
+--- a/include/move.h
++++ b/include/move.h
+@@ -10,8 +10,8 @@
+ #pragma once
+
+ /**
+- * Moves the current container in the given direction (TOK_LEFT, TOK_RIGHT,
++ * Moves the given container in the given direction (TOK_LEFT, TOK_RIGHT,
+ * TOK_UP, TOK_DOWN from cmdparse.l)
+ *
+ */
+-void tree_move(int direction);
++void tree_move(Con *con, int direction);
+diff --git a/src/commands.c b/src/commands.c
+index a60dde6..baf1989 100644
+--- a/src/commands.c
++++ b/src/commands.c
+@@ -1545,26 +1545,36 @@ void cmd_move_direction(I3_CMD, char *direction, char *move_px) {
+ // TODO: We could either handle this in the parser itself as a separate token (and make the stack typed) or we need a better way to convert a string to a number with error checking
+ int px = atoi(move_px);
+
+- /* TODO: make 'move' work with criteria. */
+- DLOG("moving in direction %s, px %s\n", direction, move_px);
+- if (con_is_floating(focused)) {
+- DLOG("floating move with %d pixels\n", px);
+- Rect newrect = focused->parent->rect;
+- if (strcmp(direction, "left") == 0) {
+- newrect.x -= px;
+- } else if (strcmp(direction, "right") == 0) {
+- newrect.x += px;
+- } else if (strcmp(direction, "up") == 0) {
+- newrect.y -= px;
+- } else if (strcmp(direction, "down") == 0) {
+- newrect.y += px;
++ owindow *current;
++ HANDLE_EMPTY_MATCH;
++
++ Con *initially_focused = focused;
++
++ TAILQ_FOREACH (current, &owindows, owindows) {
++ DLOG("moving in direction %s, px %s\n", direction, move_px);
++ if (con_is_floating(current->con)) {
++ DLOG("floating move with %d pixels\n", px);
++ Rect newrect = current->con->parent->rect;
++ if (strcmp(direction, "left") == 0) {
++ newrect.x -= px;
++ } else if (strcmp(direction, "right") == 0) {
++ newrect.x += px;
++ } else if (strcmp(direction, "up") == 0) {
++ newrect.y -= px;
++ } else if (strcmp(direction, "down") == 0) {
++ newrect.y += px;
++ }
++ floating_reposition(current->con->parent, newrect);
++ } else {
++ tree_move(current->con, (strcmp(direction, "right") == 0 ? D_RIGHT : (strcmp(direction, "left") == 0 ? D_LEFT : (strcmp(direction, "up") == 0 ? D_UP : D_DOWN))));
++ cmd_output->needs_tree_render = true;
+ }
+- floating_reposition(focused->parent, newrect);
+- } else {
+- tree_move((strcmp(direction, "right") == 0 ? D_RIGHT : (strcmp(direction, "left") == 0 ? D_LEFT : (strcmp(direction, "up") == 0 ? D_UP : D_DOWN))));
+- cmd_output->needs_tree_render = true;
+ }
+
++ /* the move command should not disturb focus */
++ if (focused != initially_focused)
++ con_focus(initially_focused);
++
+ // XXX: default reply for now, make this a better reply
+ ysuccess(true);
+ }
+diff --git a/src/move.c b/src/move.c
+index 44045f2..9c0f310 100644
+--- a/src/move.c
++++ b/src/move.c
+@@ -132,18 +132,17 @@ static void move_to_output_directed(Con *con, direction_t direction) {
+ }
+
+ /*
+- * Moves the current container in the given direction (D_LEFT, D_RIGHT,
++ * Moves the given container in the given direction (D_LEFT, D_RIGHT,
+ * D_UP, D_DOWN).
+ *
+ */
+-void tree_move(int direction) {
++void tree_move(Con *con, int direction) {
+ position_t position;
+ Con *target;
+
+ DLOG("Moving in direction %d\n", direction);
+
+ /* 1: get the first parent with the same orientation */
+- Con *con = focused;
+
+ if (con->type == CT_WORKSPACE) {
+ DLOG("Not moving workspace\n");
+diff --git a/testcases/t/232-cmd-move-criteria.t b/testcases/t/232-cmd-move-criteria.t
+new file mode 100644
+index 0000000..22a2eb4
+--- a/dev/null
++++ b/testcases/t/232-cmd-move-criteria.t
+@@ -0,0 +1,37 @@
++#!perl
++# vim:ts=4:sw=4:expandtab
++#
++# Please read the following documents before working on tests:
++# • http://build.i3wm.org/docs/testsuite.html
++# (or docs/testsuite)
++#
++# • http://build.i3wm.org/docs/lib-i3test.html
++# (alternatively: perldoc ./testcases/lib/i3test.pm)
++#
++# • http://build.i3wm.org/docs/ipc.html
++# (or docs/ipc)
++#
++# • http://onyxneon.com/books/modern_perl/modern_perl_a4.pdf
++# (unless you are already familiar with Perl)
++#
++# Test that the `move [direction]` command works with criteria
++# Bug still in: 4.8-16-g6888a1f
++use i3test;
++
++my $ws = fresh_workspace;
++
++my $win1 = open_window;
++my $win2 = open_window;
++my $win3 = open_window;
++
++# move win1 from the left to the right
++cmd '[id="' . $win1->{id} . '"] move right';
++
++# now they should be switched, with win2 still being focused
++my $ws_con = get_ws($ws);
++
++# win2 should be on the left
++is($ws_con->{nodes}[0]->{window}, $win2->{id}, 'the `move [direction]` command should work with criteria');
++is($x->input_focus, $win3->{id}, 'it should not disturb focus');
++
++done_testing;
+--
+cgit v0.9.0.3