Bugfix: Switch to appropriate workspace when using 'focus' (+test) (Thanks rogutes)
Fixes #432
This commit is contained in:
parent
26d63fffc2
commit
2d71102796
@ -412,6 +412,8 @@ focus:
|
||||
|
||||
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++;
|
||||
|
@ -12,7 +12,7 @@ BEGIN {
|
||||
my $x = X11::XCB::Connection->new;
|
||||
|
||||
my $i3 = i3("/tmp/nestedcons");
|
||||
fresh_workspace;
|
||||
my $tmp = fresh_workspace;
|
||||
|
||||
cmd 'split h';
|
||||
|
||||
@ -73,5 +73,17 @@ is($focus, $top->id, "Top window focused");
|
||||
$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;
|
||||
|
@ -7,11 +7,6 @@
|
||||
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
|
||||
@ -53,24 +48,6 @@ cmd 'open';
|
||||
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';
|
||||
|
@ -17,11 +17,6 @@ my $tmp = fresh_workspace;
|
||||
# 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;
|
||||
|
@ -14,7 +14,7 @@ use Try::Tiny;
|
||||
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();
|
||||
|
||||
@ -167,6 +167,24 @@ sub cmd {
|
||||
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}};
|
||||
|
Loading…
Reference in New Issue
Block a user