diff --git a/src/wm.c b/src/wm.c index aa125b6d..2d680cd6 100644 --- a/src/wm.c +++ b/src/wm.c @@ -243,6 +243,16 @@ void wm_stack_move_to_top(struct wm *wm, struct win *w) { wm_stack_move_before(wm, w, wm->window_stack.next); } +unsigned wm_stack_num_managed_windows(const struct wm *wm) { + unsigned count = 0; + list_foreach(struct win, w, &wm->window_stack, stack_neighbour) { + if (w->managed) { + count += 1; + } + } + return count; +} + struct managed_win *wm_find_by_client(struct wm *wm, xcb_window_t client) { if (!client) { return NULL; diff --git a/src/wm.h b/src/wm.h index 7d7a023a..b9778c19 100644 --- a/src/wm.h +++ b/src/wm.h @@ -87,6 +87,7 @@ void wm_stack_move_to_top(struct wm *wm, struct win *w); /// Replace window `old` with `new_` in the stack, also replace the window in the hash /// table. `old` will be freed. void wm_stack_replace(struct wm *wm, struct win *old, struct win *new_); +unsigned attr_const wm_stack_num_managed_windows(const struct wm *wm); struct subwin *wm_subwin_add_and_subscribe(struct wm *wm, struct x_connection *c, xcb_window_t id, xcb_window_t parent);