Maintain the _NET_CLIENT_LIST property

Add and update the _NET_CLIENT_LIST property on the root window to
better comply with ewmh standards.

Information on this property can be found here:
http://standards.freedesktop.org/wm-spec/latest/ar01s03.html

> These arrays contain all X Windows managed by the Window Manager.
> _NET_CLIENT_LIST has initial mapping order, starting with the oldest window.

fixes #1099
This commit is contained in:
Tony Crisci
2014-04-08 14:27:40 -04:00
committed by Michael Stapelberg
parent 77abb2ef19
commit 819bc09375
5 changed files with 153 additions and 13 deletions

43
src/x.c
View File

@ -20,11 +20,6 @@ xcb_window_t focused_id = XCB_NONE;
* tell whether the focused window actually changed. */
static xcb_window_t last_focused = XCB_NONE;
/* The bottom-to-top window stack of all windows which are managed by i3.
* Used for x_get_window_stack(). */
static xcb_window_t *btt_stack;
static int btt_stack_num;
/* Stores coordinates to warp mouse pointer to if set */
static Rect *warp_to;
@ -60,6 +55,7 @@ typedef struct con_state {
CIRCLEQ_ENTRY(con_state) state;
CIRCLEQ_ENTRY(con_state) old_state;
TAILQ_ENTRY(con_state) initial_mapping_order;
} con_state;
CIRCLEQ_HEAD(state_head, con_state) state_head =
@ -68,6 +64,9 @@ CIRCLEQ_HEAD(state_head, con_state) state_head =
CIRCLEQ_HEAD(old_state_head, con_state) old_state_head =
CIRCLEQ_HEAD_INITIALIZER(old_state_head);
TAILQ_HEAD(initial_mapping_head, con_state) initial_mapping_head =
TAILQ_HEAD_INITIALIZER(initial_mapping_head);
/*
* Returns the container state for the given frame. This function always
* returns a container state (otherwise, there is a bug in the code and the
@ -151,8 +150,10 @@ void x_con_init(Con *con, uint16_t depth) {
state->id = con->frame;
state->mapped = false;
state->initial = true;
DLOG("Adding window 0x%08x to lists\n", state->id);
CIRCLEQ_INSERT_HEAD(&state_head, state, state);
CIRCLEQ_INSERT_HEAD(&old_state_head, state, old_state);
TAILQ_INSERT_TAIL(&initial_mapping_head, state, initial_mapping_order);
DLOG("adding new state for window id 0x%08x\n", state->id);
}
@ -233,6 +234,7 @@ void x_con_kill(Con *con) {
state = state_for_frame(con->frame);
CIRCLEQ_REMOVE(&state_head, state, state);
CIRCLEQ_REMOVE(&old_state_head, state, old_state);
TAILQ_REMOVE(&initial_mapping_head, state, initial_mapping_order);
FREE(state->name);
free(state);
@ -909,12 +911,17 @@ void x_push_changes(Con *con) {
if (state->con && state->con->window)
cnt++;
if (cnt != btt_stack_num) {
btt_stack = srealloc(btt_stack, sizeof(xcb_window_t) * cnt);
btt_stack_num = cnt;
/* The bottom-to-top window stack of all windows which are managed by i3.
* Used for x_get_window_stack(). */
static xcb_window_t *client_list_windows = NULL;
static int client_list_count = 0;
if (cnt != client_list_count) {
client_list_windows = srealloc(client_list_windows, sizeof(xcb_window_t) * cnt);
client_list_count = cnt;
}
xcb_window_t *walk = btt_stack;
xcb_window_t *walk = client_list_windows;
/* X11 correctly represents the stack if we push it from bottom to top */
CIRCLEQ_FOREACH_REVERSE(state, &state_head, state) {
@ -940,9 +947,21 @@ void x_push_changes(Con *con) {
}
/* If we re-stacked something (or a new window appeared), we need to update
* the _NET_CLIENT_LIST_STACKING hint */
if (stacking_changed)
ewmh_update_client_list_stacking(btt_stack, btt_stack_num);
* the _NET_CLIENT_LIST and _NET_CLIENT_LIST_STACKING hints */
if (stacking_changed) {
DLOG("Client list changed (%i clients)\n", cnt);
ewmh_update_client_list_stacking(client_list_windows, client_list_count);
walk = client_list_windows;
/* reorder by initial mapping */
TAILQ_FOREACH(state, &initial_mapping_head, initial_mapping_order) {
if (state->con && state->con->window)
*walk++ = state->con->window->id;
}
ewmh_update_client_list(client_list_windows, client_list_count);
}
DLOG("PUSHING CHANGES\n");
x_push_node(con);