diff options
-rw-r--r-- | sway/container.c | 4 | ||||
-rw-r--r-- | sway/handlers.c | 37 |
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) { | |||
516 | return NULL; | 516 | return NULL; |
517 | } | 517 | } |
518 | sway_log(L_DEBUG, "Destroying view '%p'", view); | 518 | sway_log(L_DEBUG, "Destroying view '%p'", view); |
519 | swayc_t *parent = view->parent; | ||
520 | free_swayc(view); | 519 | free_swayc(view); |
521 | 520 | ||
522 | // Destroy empty containers | 521 | // Destroy empty containers |
523 | if (parent->type == C_CONTAINER) { | 522 | swayc_t *parent = view->parent; |
523 | if (parent && parent->type == C_CONTAINER) { | ||
524 | return destroy_container(parent); | 524 | return destroy_container(parent); |
525 | } | 525 | } |
526 | return parent; | 526 | 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) { | |||
553 | bool fullscreen = swayc_is_fullscreen(view); | 553 | bool fullscreen = swayc_is_fullscreen(view); |
554 | remove_view_from_scratchpad(view); | 554 | remove_view_from_scratchpad(view); |
555 | swayc_t *parent = destroy_view(view); | 555 | swayc_t *parent = destroy_view(view); |
556 | if (fullscreen) { | 556 | if (parent) { |
557 | parent->fullscreen = NULL; | 557 | if (fullscreen) { |
558 | } | 558 | parent->fullscreen = NULL; |
559 | } | ||
559 | 560 | ||
560 | ipc_event_window(parent, "close"); | 561 | ipc_event_window(parent, "close"); |
561 | 562 | ||
562 | // Destroy empty workspaces | 563 | // Destroy empty workspaces |
563 | if (parent->type == C_WORKSPACE && | 564 | if (parent->type == C_WORKSPACE && |
564 | parent->children->length == 0 && | 565 | parent->children->length == 0 && |
565 | parent->floating->length == 0 && | 566 | parent->floating->length == 0 && |
566 | swayc_active_workspace() != parent && | 567 | swayc_active_workspace() != parent && |
567 | !parent->visible) { | 568 | !parent->visible) { |
568 | parent = destroy_workspace(parent); | 569 | parent = destroy_workspace(parent); |
569 | } | 570 | } |
570 | 571 | ||
571 | arrange_windows(parent, -1, -1); | 572 | arrange_windows(parent, -1, -1); |
573 | } | ||
572 | } else { | 574 | } else { |
573 | // Is it unmanaged? | 575 | // Is it unmanaged? |
574 | int i; | 576 | int i; |
@@ -584,6 +586,15 @@ static void handle_view_destroyed(wlc_handle handle) { | |||
584 | } | 586 | } |
585 | } | 587 | } |
586 | } | 588 | } |
589 | // Is it in the scratchpad? | ||
590 | for (i = 0; i < scratchpad->length; ++i) { | ||
591 | swayc_t *item = scratchpad->items[i]; | ||
592 | if (item->handle == handle) { | ||
593 | list_del(scratchpad, i); | ||
594 | destroy_view(item); | ||
595 | break; | ||
596 | } | ||
597 | } | ||
587 | } | 598 | } |
588 | set_focused_container(get_focused_view(&root_container)); | 599 | set_focused_container(get_focused_view(&root_container)); |
589 | } | 600 | } |