]> git.sur5r.net Git - i3/i3/blobdiff - testcases/t/525-i3bar-mouse-bindings.t
resize set: accept 'width' and 'height' keywords
[i3/i3] / testcases / t / 525-i3bar-mouse-bindings.t
index d3216d974cba8381ef7ed0ec59468ca40095f3e3..3593ea0b54cc70f72da6dc1b82336cd2dfe219cc 100644 (file)
@@ -30,6 +30,9 @@ bar {
     bindsym button3 focus left
     bindsym button4 focus right
     bindsym button5 focus left
+    bindsym --release button6 focus right
+    bindsym button7 focus left
+    bindsym button7 --release focus right
 }
 EOT
 use i3test::XTEST;
@@ -39,7 +42,7 @@ $i3->connect()->recv;
 my $ws = fresh_workspace;
 
 my $cv = AnyEvent->condvar;
-my $timer = AnyEvent->timer(1, 0, sub { $cv->send(0) });
+my $timer = AnyEvent->timer(after => 1, interval => 0, cb => sub { $cv->send(0) });
 $i3->subscribe({
         window => sub {
             my ($event) = @_;
@@ -87,8 +90,6 @@ diag('i3bar window = ' . $i3bar_window);
 my $left = open_window;
 my $right = open_window;
 sync_with_i3;
-my $con = $cv->recv;
-is($con->{window}, $right->{id}, 'focus is initially on the right container');
 
 sub focus_subtest {
     my ($subscribecb, $want, $msg) = @_;
@@ -99,11 +100,19 @@ sub focus_subtest {
     is_deeply(\@focus, $want, $msg);
 }
 
+sub sync {
+    # Ensure XTEST events were sent to i3, which grabs and hence needs to
+    # forward any events to i3bar:
+    xtest_sync_with_i3;
+    # Ensure any pending i3bar IPC messages were handled by i3:
+    xtest_sync_with($i3bar_window);
+}
+
 subtest 'button 1 moves focus left', \&focus_subtest,
     sub {
        xtest_button_press(1, 3, 3);
        xtest_button_release(1, 3, 3);
-       xtest_sync_with($i3bar_window);
+       sync;
     },
     [ $left->{id} ],
     'button 1 moves focus left';
@@ -112,7 +121,7 @@ subtest 'button 2 moves focus right', \&focus_subtest,
     sub {
        xtest_button_press(2, 3, 3);
        xtest_button_release(2, 3, 3);
-       xtest_sync_with($i3bar_window);
+       sync;
     },
     [ $right->{id} ],
     'button 2 moves focus right';
@@ -121,7 +130,7 @@ subtest 'button 3 moves focus left', \&focus_subtest,
     sub {
        xtest_button_press(3, 3, 3);
        xtest_button_release(3, 3, 3);
-       xtest_sync_with($i3bar_window);
+       sync;
     },
     [ $left->{id} ],
     'button 3 moves focus left';
@@ -130,7 +139,7 @@ subtest 'button 4 moves focus right', \&focus_subtest,
     sub {
        xtest_button_press(4, 3, 3);
        xtest_button_release(4, 3, 3);
-       xtest_sync_with($i3bar_window);
+       sync;
     },
     [ $right->{id} ],
     'button 4 moves focus right';
@@ -139,9 +148,48 @@ subtest 'button 5 moves focus left', \&focus_subtest,
     sub {
        xtest_button_press(5, 3, 3);
        xtest_button_release(5, 3, 3);
-       xtest_sync_with($i3bar_window);
+       sync;
     },
     [ $left->{id} ],
     'button 5 moves focus left';
 
+# Test --release flag with bar bindsym.
+# See issue: #3068.
+
+my $old_focus = get_focused($ws);
+subtest 'button 6 does not move focus while pressed', \&focus_subtest,
+    sub {
+        xtest_button_press(6, 3, 3);
+        sync;
+    },
+    [],
+    'button 6 does not move focus while pressed';
+is(get_focused($ws), $old_focus, 'focus unchanged');
+
+subtest 'button 6 release moves focus right', \&focus_subtest,
+    sub {
+        xtest_button_release(6, 3, 3);
+        sync;
+    },
+    [ $right->{id} ],
+    'button 6 release moves focus right';
+
+# Test same bindsym button with and without --release.
+
+subtest 'button 7 press moves focus left', \&focus_subtest,
+    sub {
+        xtest_button_press(7, 3, 3);
+        sync;
+    },
+    [ $left->{id} ],
+    'button 7 press moves focus left';
+
+subtest 'button 7 release moves focus right', \&focus_subtest,
+    sub {
+        xtest_button_release(7, 3, 3);
+        sync;
+    },
+    [ $right->{id} ],
+    'button 7 release moves focus right';
+
 done_testing;