$window->map;
-sleep(0.25);
+sleep(0.5);
my $new_rect = $window->rect;
ok(!eq_hash($new_rect, $original_rect), "Window got repositioned");
my $floating = get_focused($tmp);
diag("focused floating: " . get_focused($tmp));
cmd 'mode toggle';
-# TODO: eliminate this race conditition
-sleep 1;
+sync_with_i3;
# kill old container
cmd qq|[con_id="$old"] focus|;
cmd qq|[con_id="$floating"] focus|;
is(get_focused($tmp), $floating, 'floating window focused');
-sleep 1;
+sync_with_i3;
cmd 'mode toggle';
does_i3_live;
##############################################################
cmd 'kill';
-# TODO: this testcase sometimes has different outcomes when the
-# sleep is missing. why?
-sleep 0.25;
+sync_with_i3;
+
($nodes, $focus) = get_ws_content($tmp);
is($nodes->[1]->{nodes}->[0]->{id}, $second, 'second container found');
ok($nodes->[1]->{nodes}->[0]->{focused}, 'second container focused');
cmd qq|[con_id="$middle"] focus|;
$win->destroy;
-
-sleep 0.25;
+sync_with_i3;
is(get_focused($tmp), $middle, 'middle container focused');
#
use i3test;
+sub sync_cmd {
+ cmd @_;
+ sync_with_i3;
+}
+
my $tmp = fresh_workspace;
my $left = open_window;
my $right = open_window;
# go to workspace level
-cmd 'level up';
-sleep 0.25;
+sync_cmd 'level up';
# make it floating
-cmd 'mode toggle';
-sleep 0.25;
+sync_cmd 'mode toggle';
# move the con outside the floating con
-cmd 'move up';
-sleep 0.25;
+sync_cmd 'move up';
does_i3_live;
# move another con outside
-cmd '[id="' . $mid->id . '"] focus';
-cmd 'move up';
-sleep 0.25;
+sync_cmd '[id="' . $mid->id . '"] focus';
+sync_cmd 'move up';
does_i3_live;
# open a tiling window on the first workspace
open_window;
-#sleep 0.25;
my $first = get_focused($tmp);
# on a different ws, open a floating window
my $otmp = fresh_workspace;
open_window;
-#sleep 0.25;
my $float = get_focused($otmp);
cmd 'mode toggle';
-#sleep 0.25;
+sync_with_i3;
# move the floating con to first workspace
cmd "move workspace $tmp";
-#sleep 0.25;
+sync_with_i3;
# switch to the first ws and check focus
is(get_focused($tmp), $float, 'floating client correctly focused');
open_window;
cmd 'layout stacking';
-sleep 1;
+sync_with_i3;
cmd 'fullscreen';
-sleep 1;
+sync_with_i3;
cmd 'restart';
sleep 1;