]> git.sur5r.net Git - i3/i3/blobdiff - testcases/t/158-wm_take_focus.t
Merge pull request #1805 from lasers/next
[i3/i3] / testcases / t / 158-wm_take_focus.t
index ba03913a8f524ce8c2355f1bf52c21f09397d882..b8dae3b1b1d0b6e84f19bd6b4bc9ea170860e0e1 100644 (file)
@@ -50,17 +50,32 @@ sub recv_take_focus {
 }
 
 subtest 'Window without WM_TAKE_FOCUS', sub {
-    fresh_workspace;
+    my $ws = fresh_workspace;
 
     my $window = open_window;
 
     ok(!recv_take_focus($window), 'did not receive ClientMessage');
 
+    my $con = shift get_ws_content($ws);
+    ok($con->{focused}, 'con is focused');
+
     done_testing;
 };
 
+# http://tronche.com/gui/x/icccm/sec-4.html#s-4.1.7
+# > Clients using the Globally Active model can only use a SetInputFocus request
+# > to acquire the input focus when they do not already have it on receipt of one
+# > of the following events:
+# > * ButtonPress
+# > * ButtonRelease
+# > * Passive-grabbed KeyPress
+# > * Passive-grabbed KeyRelease
+#
+# Since managing a window happens on a MapNotify (which is absent from this
+# list), the window cannot accept input focus, so we should not try to focus
+# the window at all.
 subtest 'Window with WM_TAKE_FOCUS and without InputHint', sub {
-    fresh_workspace;
+    my $ws = fresh_workspace;
 
     my $take_focus = $x->atom(name => 'WM_TAKE_FOCUS');
 
@@ -74,7 +89,10 @@ subtest 'Window with WM_TAKE_FOCUS and without InputHint', sub {
 
     $window->map;
 
-    ok(recv_take_focus($window), 'got ClientMessage with WM_TAKE_FOCUS atom');
+    ok(!recv_take_focus($window), 'did not receive ClientMessage');
+
+    my $con = shift get_ws_content($ws);
+    ok($con->{focused}, 'con is focused');
 
     done_testing;
 };
@@ -85,7 +103,7 @@ subtest 'Window with WM_TAKE_FOCUS and without InputHint', sub {
 # nearly identical presently, so this is currently used also as a proxy test
 # for the latter case.
 subtest 'Window with WM_TAKE_FOCUS and unspecified InputHint', sub {
-    fresh_workspace;
+    my $ws = fresh_workspace;
 
     my $take_focus = $x->atom(name => 'WM_TAKE_FOCUS');
 
@@ -93,6 +111,9 @@ subtest 'Window with WM_TAKE_FOCUS and unspecified InputHint', sub {
 
     ok(!recv_take_focus($window), 'did not receive ClientMessage');
 
+    my $con = shift get_ws_content($ws);
+    ok($con->{focused}, 'con is focused');
+
     done_testing;
 };