]> git.sur5r.net Git - i3/i3/commitdiff
Implement the window::move event
authorTony Crisci <tony@dubstepdish.com>
Thu, 19 Jun 2014 08:58:03 +0000 (04:58 -0400)
committerMichael Stapelberg <michael@stapelberg.de>
Thu, 19 Jun 2014 11:00:17 +0000 (13:00 +0200)
The window::move event should be emitted when the window moves position
in the tree.

docs/ipc
src/con.c
src/move.c
testcases/t/231-ipc-window-move.t [new file with mode: 0644]

index 3b9f40bf4d77edf1e59908f6b1b003b1bcd11476..0560d4e378ae44f22a28fa40f2fd6843bdc5685a 100644 (file)
--- a/docs/ipc
+++ b/docs/ipc
@@ -721,6 +721,7 @@ This event consists of a single serialized map containing a property
 * +focus+ - the window has received input focus
 * +title+ - the window's title has changed
 * +fullscreen_mode+ - the window has entered or exited fullscreen mode
+* +move+ - the window has changed its position in the tree
 
 Additionally a +container (object)+ field will be present, which consists
 of the window's parent container. Be aware that for the "new" event, the
index ee4727b3f31405d79c35f168f969d9c8336db665..7934133e6f96248d6411da9247976a62c45a97e3 100644 (file)
--- a/src/con.c
+++ b/src/con.c
@@ -832,6 +832,8 @@ void con_move_to_workspace(Con *con, Con *workspace, bool fix_coordinates, bool
     }
 
     CALL(parent, on_remove_child);
+
+    ipc_send_window_event("move", con);
 }
 
 /*
index 42510d520823ec98e4dfcbb0edd116bb282ca444..44045f25f96c1d833168375dad88a260a1441542 100644 (file)
@@ -206,6 +206,7 @@ void tree_move(int direction) {
                 TAILQ_INSERT_HEAD(&(swap->parent->focus_head), con, focused);
 
                 DLOG("Swapped.\n");
+                ipc_send_window_event("move", con);
                 return;
             }
 
@@ -213,6 +214,7 @@ void tree_move(int direction) {
                 /*  If we couldn't find a place to move it on this workspace,
                  *  try to move it to a workspace on a different output */
                 move_to_output_directed(con, direction);
+                ipc_send_window_event("move", con);
                 return;
             }
 
@@ -264,4 +266,5 @@ end:
     FREE(con->deco_render_params);
 
     tree_flatten(croot);
+    ipc_send_window_event("move", con);
 }
diff --git a/testcases/t/231-ipc-window-move.t b/testcases/t/231-ipc-window-move.t
new file mode 100644 (file)
index 0000000..117d27f
--- /dev/null
@@ -0,0 +1,61 @@
+#!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)
+#
+# Tests that the ipc window::move event works properly
+#
+# Bug still in: 4.8-7-gf4a8253
+use i3test;
+
+my $i3 = i3(get_socket_path());
+$i3->connect()->recv;
+
+my $cv;
+my $t;
+
+sub reset_test {
+    $cv = AE::cv;
+    $t = AE::timer(0.5, 0, sub { $cv->send(0); });
+}
+
+reset_test;
+
+$i3->subscribe({
+        window => sub {
+            my ($e) = @_;
+            if ($e->{change} eq 'move') {
+                $cv->send($e->{container});
+            }
+        },
+    })->recv;
+
+my $dummy_window = open_window;
+my $window = open_window;
+
+cmd 'move right';
+my $con = $cv->recv;
+
+ok($con, 'moving a window should emit the window::move event');
+is($con->{window}, $window->{id}, 'the event should contain info about the window');
+
+reset_test;
+
+cmd 'move to workspace ws_new';
+$con = $cv->recv;
+
+ok($con, 'moving a window to a different workspace should emit the window::move event');
+is($con->{window}, $window->{id}, 'the event should contain info about the window');
+
+done_testing;