Merge pull request #3178 from orestisf1993/pr-2314

Support _NET_WM_STATE_FOCUSED
This commit is contained in:
Ingo Bürk
2018-03-23 14:50:46 +01:00
committed by GitHub
8 changed files with 131 additions and 10 deletions

View File

@ -55,6 +55,7 @@ subtest 'Window without WM_TAKE_FOCUS', sub {
my $window = open_window;
ok(!recv_take_focus($window), 'did not receive ClientMessage');
ok(is_net_wm_state_focused($window), '_NET_WM_STATE_FOCUSED set');
my ($nodes) = get_ws_content($ws);
my $con = shift @$nodes;
@ -91,6 +92,7 @@ subtest 'Window with WM_TAKE_FOCUS and without InputHint', sub {
$window->map;
ok(!recv_take_focus($window), 'did not receive ClientMessage');
ok(is_net_wm_state_focused($window), '_NET_WM_STATE_FOCUSED set');
my ($nodes) = get_ws_content($ws);
my $con = shift @$nodes;
@ -112,6 +114,7 @@ subtest 'Window with WM_TAKE_FOCUS and unspecified InputHint', sub {
my $window = open_window({ protocols => [ $take_focus ] });
ok(!recv_take_focus($window), 'did not receive ClientMessage');
ok(is_net_wm_state_focused($window), '_NET_WM_STATE_FOCUSED set');
my ($nodes) = get_ws_content($ws);
my $con = shift @$nodes;

View File

@ -36,7 +36,7 @@ sub get_wm_state {
return undef if $len == 0;
my @atoms = unpack("L$len", $reply->{value});
return \@atoms;
return @atoms;
}
my $wm_state_sticky = $x->atom(name => '_NET_WM_STATE_STICKY')->id;
@ -51,18 +51,24 @@ my $wm_state_fullscreen = $x->atom(name => '_NET_WM_STATE_FULLSCREEN')->id;
fresh_workspace;
my $window = open_window;
cmd 'sticky enable';
is_deeply(get_wm_state($window), [ $wm_state_sticky ], 'sanity check: _NET_WM_STATE_STICKY is set');
my @state = get_wm_state($window);
ok((scalar grep { $_ == $wm_state_sticky } @state) > 0, 'sanity check: _NET_WM_STATE_STICKY is set');
cmd 'fullscreen enable';
is_deeply(get_wm_state($window), [ $wm_state_sticky, $wm_state_fullscreen ],
'both _NET_WM_STATE_FULLSCREEN and _NET_WM_STATE_STICKY are set');
@state = get_wm_state($window);
ok((scalar grep { $_ == $wm_state_sticky } @state) > 0, '_NET_WM_STATE_STICKY is set');
ok((scalar grep { $_ == $wm_state_fullscreen } @state) > 0, '_NET_WM_STATE_FULLSCREEN is set');
cmd 'sticky disable';
is_deeply(get_wm_state($window), [ $wm_state_fullscreen ], 'only _NET_WM_STATE_FULLSCREEN is set');
@state = get_wm_state($window);
ok((scalar grep { $_ == $wm_state_sticky } @state) == 0, '_NET_WM_STATE_STICKY is not set');
ok((scalar grep { $_ == $wm_state_fullscreen } @state) > 0, '_NET_WM_STATE_FULLSCREEN is set');
cmd 'sticky enable';
cmd 'fullscreen disable';
is_deeply(get_wm_state($window), [ $wm_state_sticky ], 'only _NET_WM_STATE_STICKY is set');
@state = get_wm_state($window);
ok((scalar grep { $_ == $wm_state_sticky } @state) > 0, '_NET_WM_STATE_STICKY is set');
ok((scalar grep { $_ == $wm_state_fullscreen } @state) == 0, '_NET_WM_STATE_FULLSCREEN is not set');
###############################################################################
# _NET_WM_STATE is removed when the window is withdrawn.
@ -71,7 +77,8 @@ is_deeply(get_wm_state($window), [ $wm_state_sticky ], 'only _NET_WM_STATE_STICK
fresh_workspace;
$window = open_window;
cmd 'sticky enable';
is_deeply(get_wm_state($window), [ $wm_state_sticky ], 'sanity check: _NET_WM_STATE_STICKY is set');
@state = get_wm_state($window);
ok((scalar grep { $_ == $wm_state_sticky } @state) > 0, '_NET_WM_STATE_STICKY is set');
$window->unmap;
wait_for_unmap($window);

View File

@ -0,0 +1,37 @@
#!perl
# vim:ts=4:sw=4:expandtab
#
# Please read the following documents before working on tests:
# • http://build.i3wm.org/docs/testsuite.html
# (or docs/testsuite)
#
# • http://build.i3wm.org/docs/lib-i3test.html
# (alternatively: perldoc ./testcases/lib/i3test.pm)
#
# • http://build.i3wm.org/docs/ipc.html
# (or docs/ipc)
#
# • http://onyxneon.com/books/modern_perl/modern_perl_a4.pdf
# (unless you are already familiar with Perl)
#
# Tests for setting and removing the _NET_WM_STATE_FOCUSED atom properly.
# Ticket: #2273
use i3test;
use X11::XCB qw(:all);
my ($windowA, $windowB);
fresh_workspace;
$windowA = open_window;
ok(is_net_wm_state_focused($windowA), 'a newly opened window that is focused should have _NET_WM_STATE_FOCUSED set');
$windowB = open_window;
ok(!is_net_wm_state_focused($windowA), 'when a another window is focused, the old window should not have _NET_WM_STATE_FOCUSED set');
fresh_workspace;
ok(!is_net_wm_state_focused($windowB), 'when focus moves to the ewmh support window, neither window should have _NET_WM_STATE_FOCUSED set');
done_testing;