Support _NET_WM_STATE_FOCUSED
_NET_WM_STATE_FOCUSED is set on _NET_WM_STATE to indicate that the window is focused. It must be set when the window is newly focused and removed once the window no longer has focus. > _NET_WM_STATE_FOCUSED indicates whether the window's decorations are > drawn in an active state. Clients MUST regard it as a read-only hint. > It cannot be set at map time or changed via a _NET_WM_STATE client > message. For example, this is used by GTK applications to show the decoration in an active or inactive state. This change can be tested by opening a GTK application (like evince), focusing the window and unfocusing the window, and observing a change in the window decorations. Fixes #2273
This commit is contained in:
committed by
Orestis Floros
parent
9cd4b53231
commit
c42de09b1b
@ -51,6 +51,7 @@ our @EXPORT = qw(
|
||||
kill_all_windows
|
||||
events_for
|
||||
listen_for_binding
|
||||
is_net_wm_state_focused
|
||||
);
|
||||
|
||||
=head1 NAME
|
||||
@ -1026,6 +1027,40 @@ sub listen_for_binding {
|
||||
return $command;
|
||||
}
|
||||
|
||||
=head2 is_net_wm_state_focused
|
||||
|
||||
Returns true if the given window has the _NET_WM_STATE_FOCUSED atom.
|
||||
|
||||
ok(is_net_wm_state_focused($window), '_NET_WM_STATE_FOCUSED set');
|
||||
|
||||
=cut
|
||||
sub is_net_wm_state_focused {
|
||||
my ($window) = @_;
|
||||
|
||||
sync_with_i3;
|
||||
my $atom = $x->atom(name => '_NET_WM_STATE_FOCUSED');
|
||||
my $cookie = $x->get_property(
|
||||
0,
|
||||
$window->{id},
|
||||
$x->atom(name => '_NET_WM_STATE')->id,
|
||||
GET_PROPERTY_TYPE_ANY,
|
||||
0,
|
||||
4096
|
||||
);
|
||||
|
||||
my $reply = $x->get_property_reply($cookie->{sequence});
|
||||
my $len = $reply->{length};
|
||||
return 0 if $len == 0;
|
||||
|
||||
my @atoms = unpack("L$len", $reply->{value});
|
||||
for (my $i = 0; $i < $len; $i++) {
|
||||
return 1 if $atoms[$i] == $atom->id;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
=head1 AUTHOR
|
||||
|
||||
Michael Stapelberg <michael@i3wm.org>
|
||||
|
Reference in New Issue
Block a user