Skip to content

Commit

Permalink
view: remove foreign toplevel listenesers on destroy
Browse files Browse the repository at this point in the history
  • Loading branch information
Ronan Pigott committed Aug 3, 2020
1 parent 0c0016e commit b586d50
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
1 change: 1 addition & 0 deletions include/sway/tree/view.h
Expand Up @@ -101,6 +101,7 @@ struct sway_view {
struct wl_listener foreign_activate_request;
struct wl_listener foreign_fullscreen_request;
struct wl_listener foreign_close_request;
struct wl_listener foreign_destroy;

bool destroying;

Expand Down
17 changes: 14 additions & 3 deletions sway/tree/view.c
Expand Up @@ -670,6 +670,17 @@ static void handle_foreign_close_request(
view_close(view);
}

static void handle_foreign_destroy(
struct wl_listener *listener, void *data) {
struct sway_view *view = wl_container_of(
listener, view, foreign_destroy);

wl_list_remove(&view->foreign_activate_request.link);
wl_list_remove(&view->foreign_fullscreen_request.link);
wl_list_remove(&view->foreign_close_request.link);
wl_list_remove(&listener->link);
}

void view_map(struct sway_view *view, struct wlr_surface *wlr_surface,
bool fullscreen, struct wlr_output *fullscreen_output,
bool decoration) {
Expand Down Expand Up @@ -709,6 +720,9 @@ void view_map(struct sway_view *view, struct wlr_surface *wlr_surface,
view->foreign_close_request.notify = handle_foreign_close_request;
wl_signal_add(&view->foreign_toplevel->events.request_close,
&view->foreign_close_request);
view->foreign_destroy.notify = handle_foreign_destroy;
wl_signal_add(&view->foreign_toplevel->events.destroy,
&view->foreign_destroy);

// If we're about to launch the view into the floating container, then
// launch it as a tiled view in the root of the workspace instead.
Expand Down Expand Up @@ -795,9 +809,6 @@ void view_unmap(struct sway_view *view) {
}

if (view->foreign_toplevel) {
wl_list_remove(&view->foreign_activate_request.link);
wl_list_remove(&view->foreign_fullscreen_request.link);
wl_list_remove(&view->foreign_close_request.link);
wlr_foreign_toplevel_handle_v1_destroy(view->foreign_toplevel);
view->foreign_toplevel = NULL;
}
Expand Down

0 comments on commit b586d50

Please sign in to comment.