int count = 0;
TAILQ_FOREACH(current, &owindows, owindows) {
+ Con *ws = con_get_workspace(current->con);
+ workspace_show(ws->name);
LOG("focusing %p / %s\n", current->con, current->con->name);
con_focus(current->con);
count++;
my $x = X11::XCB::Connection->new;
my $i3 = i3("/tmp/nestedcons");
-fresh_workspace;
+my $tmp = fresh_workspace;
cmd 'split h';
$focus = focus_after(qq|[con_mark="$random_mark" con_mark="$random_mark"] focus|);
is($focus, $mid->id, "goto worked");
+#####################################################################
+# Check whether the focus command will switch to a different
+# workspace if necessary
+#####################################################################
+
+my $tmp2 = fresh_workspace;
+
+is(focused_ws(), $tmp2, 'tmp2 now focused');
+
+cmd qq|[con_mark="$random_mark"] focus|;
+
+is(focused_ws(), $tmp, 'tmp now focused');
done_testing;
use List::Util qw(first);
use i3test;
-sub workspace_exists {
- my ($name) = @_;
- ($name ~~ @{get_workspace_names()})
-}
-
my $tmp = fresh_workspace;
ok(workspace_exists($tmp), 'workspace created');
# if the workspace could not be created, we cannot run any other test
ok(workspace_exists($tmp), 'workspace tmp still exists');
ok(workspace_exists($otmp), 'workspace otmp created');
-sub focused_ws_con {
- my $i3 = i3("/tmp/nestedcons");
- my $tree = $i3->get_tree->recv;
- my @outputs = @{$tree->{nodes}};
- my @cons;
- for my $output (@outputs) {
- # get the first CT_CON of each output
- my $content = first { $_->{type} == 2 } @{$output->{nodes}};
- my @focused = @{$content->{focus}};
- return first { $_->{id} == $focused[0] } @{$content->{nodes}};
- }
-}
-
-sub focused_ws {
- my $con = focused_ws_con;
- return $con->{name};
-}
-
is(focused_ws(), $otmp, 'focused workspace is otmp');
cmd 'workspace prev';
# 1: open a floating window, get it mapped
#############################################################################
-sub workspace_exists {
- my ($name) = @_;
- ($name ~~ @{get_workspace_names()})
-}
-
ok(workspace_exists($tmp), "workspace $tmp exists");
my $x = X11::XCB::Connection->new;
use v5.10;
use Exporter ();
-our @EXPORT = qw(get_workspace_names get_unused_workspace fresh_workspace get_ws_content get_ws get_focused open_empty_con open_standard_window get_dock_clients cmd does_i3_live exit_gracefully);
+our @EXPORT = qw(get_workspace_names get_unused_workspace fresh_workspace get_ws_content get_ws get_focused open_empty_con open_standard_window get_dock_clients cmd does_i3_live exit_gracefully workspace_exists focused_ws);
my $tester = Test::Builder->new();
i3("/tmp/nestedcons")->command(@_)->recv
}
+sub workspace_exists {
+ my ($name) = @_;
+ ($name ~~ @{get_workspace_names()})
+}
+
+sub focused_ws {
+ my $i3 = i3("/tmp/nestedcons");
+ my $tree = $i3->get_tree->recv;
+ my @outputs = @{$tree->{nodes}};
+ my @cons;
+ for my $output (@outputs) {
+ # get the first CT_CON of each output
+ my $content = first { $_->{type} == 2 } @{$output->{nodes}};
+ my $first = first { $_->{fullscreen_mode} == 1 } @{$content->{nodes}};
+ return $first->{name}
+ }
+}
+
sub does_i3_live {
my $tree = i3('/tmp/nestedcons')->get_tree->recv;
my @nodes = @{$tree->{nodes}};