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
24
src/x.c
24
src/x.c
@ -99,6 +99,23 @@ static con_state *state_for_frame(xcb_window_t window) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
* Changes the atoms on the root window and the windows themselves to properly
|
||||
* reflect the current focus for ewmh compliance.
|
||||
*
|
||||
*/
|
||||
static void change_ewmh_focus(xcb_window_t new_focus, xcb_window_t old_focus) {
|
||||
ewmh_update_active_window(new_focus);
|
||||
|
||||
if (new_focus != XCB_WINDOW_NONE) {
|
||||
ewmh_update_focused(new_focus, true);
|
||||
}
|
||||
|
||||
if (old_focus != XCB_WINDOW_NONE) {
|
||||
ewmh_update_focused(old_focus, false);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Initializes the X11 part for the given container. Called exactly once for
|
||||
* every container from con_new().
|
||||
@ -1120,7 +1137,7 @@ void x_push_changes(Con *con) {
|
||||
to_focus, focused, focused->name);
|
||||
send_take_focus(to_focus, last_timestamp);
|
||||
|
||||
ewmh_update_active_window((con_has_managed_window(focused) ? focused->window->id : XCB_WINDOW_NONE));
|
||||
change_ewmh_focus((con_has_managed_window(focused) ? focused->window->id : XCB_WINDOW_NONE), last_focused);
|
||||
|
||||
if (to_focus != last_focused && is_con_attached(focused))
|
||||
ipc_send_window_event("focus", focused);
|
||||
@ -1139,7 +1156,7 @@ void x_push_changes(Con *con) {
|
||||
xcb_change_window_attributes(conn, focused->window->id, XCB_CW_EVENT_MASK, values);
|
||||
}
|
||||
|
||||
ewmh_update_active_window((con_has_managed_window(focused) ? focused->window->id : XCB_WINDOW_NONE));
|
||||
change_ewmh_focus((con_has_managed_window(focused) ? focused->window->id : XCB_WINDOW_NONE), last_focused);
|
||||
|
||||
if (to_focus != XCB_NONE && to_focus != last_focused && focused->window != NULL && is_con_attached(focused))
|
||||
ipc_send_window_event("focus", focused);
|
||||
@ -1154,7 +1171,8 @@ void x_push_changes(Con *con) {
|
||||
* root window in order to avoid an X11 fallback mechanism causing a ghosting effect (see #1378). */
|
||||
DLOG("Still no window focused, better set focus to the EWMH support window (%d)\n", ewmh_window);
|
||||
xcb_set_input_focus(conn, XCB_INPUT_FOCUS_POINTER_ROOT, ewmh_window, last_timestamp);
|
||||
ewmh_update_active_window(XCB_WINDOW_NONE);
|
||||
change_ewmh_focus(XCB_WINDOW_NONE, last_focused);
|
||||
|
||||
focused_id = ewmh_window;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user