wm: add a function to count managed windows

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
This commit is contained in:
Yuxuan Shui 2024-04-02 04:01:11 +01:00
parent 9210536db1
commit d8c34ed4f7
No known key found for this signature in database
GPG Key ID: D3A4405BE6CC17F4
2 changed files with 11 additions and 0 deletions

View File

@ -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;

View File

@ -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);