aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDrew DeVault <sir@cmpwn.com>2017-10-08 10:57:41 -0400
committerDrew DeVault <sir@cmpwn.com>2017-10-08 10:57:41 -0400
commit5ecedc7199fcd9788ae2d96f0ed1f25a2cbe7364 (patch)
tree61433d41f28947a576dc079e275df356bb831d2e
parent46e5aeac5016f336aa1184b2752146c04ece21d9 (diff)
Remove destroyed views from scratchpad
Fixes #1363
-rw-r--r--sway/container.c4
-rw-r--r--sway/handlers.c37
2 files changed, 26 insertions, 15 deletions
diff --git a/sway/container.c b/sway/container.c
index 14647b3a..718608ff 100644
--- a/sway/container.c
+++ b/sway/container.c
@@ -516,11 +516,11 @@ swayc_t *destroy_view(swayc_t *view) {
return NULL;
}
sway_log(L_DEBUG, "Destroying view '%p'", view);
- swayc_t *parent = view->parent;
free_swayc(view);
// Destroy empty containers
- if (parent->type == C_CONTAINER) {
+ swayc_t *parent = view->parent;
+ if (parent && parent->type == C_CONTAINER) {
return destroy_container(parent);
}
return parent;
diff --git a/sway/handlers.c b/sway/handlers.c
index db0c5e24..d37142a9 100644
--- a/sway/handlers.c
+++ b/sway/handlers.c
@@ -553,22 +553,24 @@ static void handle_view_destroyed(wlc_handle handle) {
bool fullscreen = swayc_is_fullscreen(view);
remove_view_from_scratchpad(view);
swayc_t *parent = destroy_view(view);
- if (fullscreen) {
- parent->fullscreen = NULL;
- }
+ if (parent) {
+ if (fullscreen) {
+ parent->fullscreen = NULL;
+ }
- ipc_event_window(parent, "close");
+ ipc_event_window(parent, "close");
- // Destroy empty workspaces
- if (parent->type == C_WORKSPACE &&
- parent->children->length == 0 &&
- parent->floating->length == 0 &&
- swayc_active_workspace() != parent &&
- !parent->visible) {
- parent = destroy_workspace(parent);
- }
+ // Destroy empty workspaces
+ if (parent->type == C_WORKSPACE &&
+ parent->children->length == 0 &&
+ parent->floating->length == 0 &&
+ swayc_active_workspace() != parent &&
+ !parent->visible) {
+ parent = destroy_workspace(parent);
+ }
- arrange_windows(parent, -1, -1);
+ arrange_windows(parent, -1, -1);
+ }
} else {
// Is it unmanaged?
int i;
@@ -584,6 +586,15 @@ static void handle_view_destroyed(wlc_handle handle) {
}
}
}
+ // Is it in the scratchpad?
+ for (i = 0; i < scratchpad->length; ++i) {
+ swayc_t *item = scratchpad->items[i];
+ if (item->handle == handle) {
+ list_del(scratchpad, i);
+ destroy_view(item);
+ break;
+ }
+ }
}
set_focused_container(get_focused_view(&root_container));
}