]> git.sur5r.net Git - i3/i3/blobdiff - testcases/t/158-wm_take_focus.t
tests: rename files (00x-*.t is basic stuff, >=100-*.t are tests using IPC)
[i3/i3] / testcases / t / 158-wm_take_focus.t
diff --git a/testcases/t/158-wm_take_focus.t b/testcases/t/158-wm_take_focus.t
new file mode 100644 (file)
index 0000000..a90ce1c
--- /dev/null
@@ -0,0 +1,44 @@
+#!perl
+# vim:ts=4:sw=4:expandtab
+#
+# Tests if the WM_TAKE_FOCUS protocol is correctly handled by i3
+#
+use X11::XCB qw(:all);
+use i3test;
+use v5.10;
+
+my $x = X11::XCB::Connection->new;
+
+subtest 'Window without WM_TAKE_FOCUS', sub {
+    fresh_workspace;
+
+    my $window = open_window($x);
+
+    ok(!wait_for_event($x, 1, sub { $_[0]->{response_type} == 161 }), 'did not receive ClientMessage');
+
+    done_testing;
+};
+
+subtest 'Window with WM_TAKE_FOCUS', sub {
+    fresh_workspace;
+
+    my $take_focus = $x->atom(name => 'WM_TAKE_FOCUS');
+
+    my $window = open_window($x, {
+        dont_map => 1,
+        protocols => [ $take_focus ],
+    });
+
+    $window->map;
+
+    ok(wait_for_event($x, 1, sub {
+        return 0 unless $_[0]->{response_type} == 161;
+        my ($data, $time) = unpack("L2", $_[0]->{data});
+        return ($data == $take_focus->id);
+    }), 'got ClientMessage with WM_TAKE_FOCUS atom');
+
+    done_testing;
+};
+
+
+done_testing;