diff --git a/src/ext-workspace/tag-worksapce.h b/src/ext-workspace/tag-worksapce.h index ced3e1f8..7355eb08 100644 --- a/src/ext-workspace/tag-worksapce.h +++ b/src/ext-workspace/tag-worksapce.h @@ -4,7 +4,6 @@ typedef struct Monitor Monitor; -/* Double use: as config in config/rcxml.c and as instance in workspaces.c */ struct workspace { struct wl_list link; @@ -22,24 +21,16 @@ struct workspace { } on_ext; }; -/* Workspaces */ struct dwl_ext_workspace_manager *ext_manager; struct wl_list workspaces; /* struct workspace.link */ -/* - * update_focus should normally be set to true. It is set to false only - * when this function is called from desktop_focus_view(), in order to - * avoid unnecessary extra focus changes and possible recursion. - */ void workspaces_switch_to(struct workspace *target) { if (target == target->m->workspace_current) { return; } - /* Disable the old workspace */ wlr_scene_node_set_enabled(&target->m->workspace_current->tree->node, false); - dwl_ext_workspace_set_active(target->m->workspace_current->ext_workspace, false); @@ -52,15 +43,9 @@ void workspaces_switch_to(struct workspace *target) { view(&(Arg){.ui = tag}, true); } - /* Enable the new workspace */ wlr_scene_node_set_enabled(&target->tree->node, true); - - /* Save the last visited workspace */ target->m->workspace_last = target->m->workspace_current; - - /* Make sure new views will spawn on the new workspace */ target->m->workspace_current = target; - dwl_ext_workspace_set_active(target->ext_workspace, true); } @@ -119,7 +104,6 @@ static void add_workspace(int tag, Monitor *m) { bool active = m->workspace_current == workspace; - /* ext */ workspace->ext_workspace = dwl_ext_workspace_create(ext_manager, /*id*/ NULL); dwl_ext_workspace_assign_to_group(workspace->ext_workspace, m->ext_group); diff --git a/src/maomao.c b/src/maomao.c index a7378fa0..8b6211bb 100644 --- a/src/maomao.c +++ b/src/maomao.c @@ -5089,46 +5089,53 @@ void pointerfocus(Client *c, struct wlr_surface *surface, double sx, double sy, wlr_seat_pointer_notify_motion(seat, time, sx, sy); } -void printstatus(void) { - Monitor *m; +bool tag_has_clients(unsigned int tag) { + Client *c; + bool has_clients = false; + wl_list_for_each(c, &clients, link) { + if (c->tags & 1 << (tag - 1) & TAGMASK) { + has_clients = true; + break; + } + } + return has_clients; +} + +void dwl_ext_workspace_printstatus(Monitor *m) { unsigned int current_tag; struct workspace *w; - Client *c; bool has_clients = false; bool is_active = false; + current_tag = get_tags_first_tag_num(m->tagset[m->seltags]); + + wl_list_for_each(w, &workspaces, link) { + if (w && w->m == m) { + is_active = (w->tag == current_tag) && !m->isoverview; + has_clients = tag_has_clients(w->tag); + if (is_active) { + dwl_ext_workspace_set_hidden(w->ext_workspace, false); + dwl_ext_workspace_set_active(w->ext_workspace, true); + } else if (has_clients) { + dwl_ext_workspace_set_hidden(w->ext_workspace, false); + dwl_ext_workspace_set_active(w->ext_workspace, false); + } else { + dwl_ext_workspace_set_active(w->ext_workspace, false); + dwl_ext_workspace_set_hidden(w->ext_workspace, true); + } + } + } +} + +void printstatus(void) { + Monitor *m; wl_list_for_each(m, &mons, link) { if (!m->wlr_output->enabled) { continue; } - // Get current tag for this monitor - current_tag = get_tags_first_tag_num(m->tagset[m->seltags]); // Update workspace active states - if (workspaces.next != &workspaces) { // If workspaces list is not empty - wl_list_for_each(w, &workspaces, link) { - if (w && w->m == m) { - is_active = (w->tag == current_tag) && !m->isoverview; - has_clients = false; - wl_list_for_each(c, &clients, link) { - if (c->tags & 1 << (w->tag - 1) & TAGMASK) { - has_clients = true; - break; - } - } - if (is_active) { - dwl_ext_workspace_set_active(w->ext_workspace, - is_active); - } else if (has_clients) { - dwl_ext_workspace_set_hidden(w->ext_workspace, false); - dwl_ext_workspace_set_active(w->ext_workspace, false); - } else { - dwl_ext_workspace_set_active(w->ext_workspace, false); - dwl_ext_workspace_set_hidden(w->ext_workspace, true); - } - } - } - } + dwl_ext_workspace_printstatus(m); // Update IPC output status dwl_ipc_output_printstatus(m);