mirror of
https://github.com/DreamMaoMao/maomaowm.git
synced 2026-06-19 14:33:16 -04:00
fix: miss clean workspace when monitor destroy
This commit is contained in:
parent
b211f50e27
commit
7549a33cf0
2 changed files with 30 additions and 16 deletions
|
|
@ -95,7 +95,28 @@ static char *get_name_from_tag(unsigned int tag) {
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void remove_workspace(unsigned int tag, Monitor *m) {
|
void destroy_workspace(struct workspace *workspace) {
|
||||||
|
// Clean up external workspace
|
||||||
|
wl_list_remove(&workspace->on_ext.activate.link);
|
||||||
|
dwl_ext_workspace_destroy(workspace->ext_workspace);
|
||||||
|
|
||||||
|
// Remove from the list and free resources
|
||||||
|
wl_list_remove(&workspace->link);
|
||||||
|
wlr_scene_node_destroy(&workspace->tree->node);
|
||||||
|
free(workspace->name);
|
||||||
|
free(workspace);
|
||||||
|
}
|
||||||
|
|
||||||
|
void cleanup_workspaces_by_monitor(Monitor *m) {
|
||||||
|
struct workspace *workspace, *tmp;
|
||||||
|
wl_list_for_each_safe(workspace, tmp, &workspaces, link) {
|
||||||
|
if (workspace->m == m) {
|
||||||
|
destroy_workspace(workspace);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void remove_workspace_by_tag(unsigned int tag, Monitor *m) {
|
||||||
char *name = get_name_from_tag(tag);
|
char *name = get_name_from_tag(tag);
|
||||||
struct workspace *workspace, *tmp;
|
struct workspace *workspace, *tmp;
|
||||||
wl_list_for_each_safe(workspace, tmp, &workspaces, link) {
|
wl_list_for_each_safe(workspace, tmp, &workspaces, link) {
|
||||||
|
|
@ -122,22 +143,14 @@ static void remove_workspace(unsigned int tag, Monitor *m) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Clean up external workspace
|
destroy_workspace(workspace);
|
||||||
wl_list_remove(&workspace->on_ext.activate.link);
|
|
||||||
dwl_ext_workspace_destroy(workspace->ext_workspace);
|
|
||||||
|
|
||||||
// Remove from the list and free resources
|
|
||||||
wl_list_remove(&workspace->link);
|
|
||||||
wlr_scene_node_destroy(&workspace->tree->node);
|
|
||||||
free(workspace->name);
|
|
||||||
free(workspace);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Internal API */
|
/* Internal API */
|
||||||
static void add_workspace(int tag, Monitor *m) {
|
static void add_workspace_by_tag(int tag, Monitor *m) {
|
||||||
char *name = get_name_from_tag(tag);
|
char *name = get_name_from_tag(tag);
|
||||||
struct workspace *workspace = znew(*workspace);
|
struct workspace *workspace = znew(*workspace);
|
||||||
workspace->name = xstrdup(name);
|
workspace->name = xstrdup(name);
|
||||||
|
|
|
||||||
11
src/maomao.c
11
src/maomao.c
|
|
@ -2991,6 +2991,7 @@ void cleanupmon(struct wl_listener *listener, void *data) {
|
||||||
// clean ext-workspaces grouplab
|
// clean ext-workspaces grouplab
|
||||||
dwl_ext_workspace_group_output_leave(m->ext_group, m->wlr_output);
|
dwl_ext_workspace_group_output_leave(m->ext_group, m->wlr_output);
|
||||||
dwl_ext_workspace_group_destroy(m->ext_group);
|
dwl_ext_workspace_group_destroy(m->ext_group);
|
||||||
|
cleanup_workspaces_by_monitor(m);
|
||||||
|
|
||||||
wl_list_remove(&m->destroy.link);
|
wl_list_remove(&m->destroy.link);
|
||||||
wl_list_remove(&m->frame.link);
|
wl_list_remove(&m->frame.link);
|
||||||
|
|
@ -3501,7 +3502,7 @@ void createmon(struct wl_listener *listener, void *data) {
|
||||||
dwl_ext_workspace_group_output_enter(m->ext_group, m->wlr_output);
|
dwl_ext_workspace_group_output_enter(m->ext_group, m->wlr_output);
|
||||||
|
|
||||||
for (i = 1; i <= LENGTH(tags); i++) {
|
for (i = 1; i <= LENGTH(tags); i++) {
|
||||||
add_workspace(i, m);
|
add_workspace_by_tag(i, m);
|
||||||
}
|
}
|
||||||
|
|
||||||
printstatus();
|
printstatus();
|
||||||
|
|
@ -7060,13 +7061,13 @@ void toggleoverview(const Arg *arg) {
|
||||||
|
|
||||||
if (selmon->isoverview) {
|
if (selmon->isoverview) {
|
||||||
for (i = 1; i <= LENGTH(tags); i++) {
|
for (i = 1; i <= LENGTH(tags); i++) {
|
||||||
remove_workspace(i, selmon);
|
remove_workspace_by_tag(i, selmon);
|
||||||
}
|
}
|
||||||
add_workspace(0, selmon);
|
add_workspace_by_tag(0, selmon);
|
||||||
} else {
|
} else {
|
||||||
remove_workspace(0, selmon);
|
remove_workspace_by_tag(0, selmon);
|
||||||
for (i = 1; i <= LENGTH(tags); i++) {
|
for (i = 1; i <= LENGTH(tags); i++) {
|
||||||
add_workspace(i, selmon);
|
add_workspace_by_tag(i, selmon);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue