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';
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';
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';
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';
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';
subtest 'button 6 does not move focus while pressed', \&focus_subtest,
sub {
xtest_button_press(6, 3, 3);
- xtest_sync_with($i3bar_window);
+ sync;
},
[],
'button 6 does not move focus while pressed';
subtest 'button 6 release moves focus right', \&focus_subtest,
sub {
xtest_button_release(6, 3, 3);
- xtest_sync_with($i3bar_window);
+ sync;
},
[ $right->{id} ],
'button 6 release moves focus right';
subtest 'button 7 press moves focus left', \&focus_subtest,
sub {
xtest_button_press(7, 3, 3);
- xtest_sync_with($i3bar_window);
+ 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);
- xtest_sync_with($i3bar_window);
+ sync;
},
[ $right->{id} ],
'button 7 release moves focus right';