diff --git a/include/con.h b/include/con.h index 0205dfc6..b8fd60ad 100644 --- a/include/con.h +++ b/include/con.h @@ -37,6 +37,12 @@ void con_focus(Con *con); */ bool con_is_leaf(Con *con); +/** + * Returns true when this con is a leaf node with a managed X11 window (e.g., + * excluding dock containers) + */ +bool con_has_managed_window(Con *con); + /* * Returns true if a container should be considered split. * diff --git a/src/con.c b/src/con.c index 6918d648..66c9db69 100644 --- a/src/con.c +++ b/src/con.c @@ -241,6 +241,17 @@ bool con_is_leaf(Con *con) { return TAILQ_EMPTY(&(con->nodes_head)); } +/* + * Returns true when this con is a leaf node with a managed X11 window (e.g., + * excluding dock containers) + */ +bool con_has_managed_window(Con *con) { + return (con != NULL + && con->window != NULL + && con->window->id != XCB_WINDOW_NONE + && con_get_workspace(con) != NULL); +} + /** * Returns true if this node has regular or floating children. * diff --git a/src/x.c b/src/x.c index 02fc338f..8e7a710c 100644 --- a/src/x.c +++ b/src/x.c @@ -908,7 +908,7 @@ void x_push_changes(Con *con) { * stack afterwards */ int cnt = 0; CIRCLEQ_FOREACH_REVERSE(state, &state_head, state) - if (state->con && state->con->window) + if (con_has_managed_window(state->con)) cnt++; /* The bottom-to-top window stack of all windows which are managed by i3. @@ -925,7 +925,7 @@ void x_push_changes(Con *con) { /* X11 correctly represents the stack if we push it from bottom to top */ CIRCLEQ_FOREACH_REVERSE(state, &state_head, state) { - if (state->con && state->con->window) + if (con_has_managed_window(state->con)) memcpy(walk++, &(state->con->window->id), sizeof(xcb_window_t)); //DLOG("stack: 0x%08x\n", state->id); @@ -956,7 +956,7 @@ void x_push_changes(Con *con) { /* reorder by initial mapping */ TAILQ_FOREACH(state, &initial_mapping_head, initial_mapping_order) { - if (state->con && state->con->window) + if (con_has_managed_window(state->con)) *walk++ = state->con->window->id; } diff --git a/testcases/t/223-net-client-list.t b/testcases/t/223-net-client-list.t index 74bd2cdf..82855ade 100644 --- a/testcases/t/223-net-client-list.t +++ b/testcases/t/223-net-client-list.t @@ -96,4 +96,13 @@ wait_for_unmap($win3); @clients = get_client_list; is(@clients, 0, 'Removed unmapped client from list (0)'); +# Dock clients should not be included in this list + +my $dock_win = open_window({ + window_type => $x->atom(name => '_NET_WM_WINDOW_TYPE_DOCK'), + }); + +@clients = get_client_list; +is(@clients, 0, 'Dock clients are not included in the list'); + done_testing;