mirror of
https://github.com/NickHu/sway
synced 2024-12-27 21:58:11 +01:00
lock: fix crash on output destroy
Closes: https://github.com/swaywm/sway/issues/7120
This commit is contained in:
parent
7862fa670e
commit
d945c8f519
1 changed files with 16 additions and 3 deletions
19
sway/lock.c
19
sway/lock.c
|
@ -15,6 +15,7 @@ struct sway_session_lock_surface {
|
||||||
struct wl_listener surface_commit;
|
struct wl_listener surface_commit;
|
||||||
struct wl_listener output_mode;
|
struct wl_listener output_mode;
|
||||||
struct wl_listener output_commit;
|
struct wl_listener output_commit;
|
||||||
|
struct wl_listener output_destroy;
|
||||||
};
|
};
|
||||||
|
|
||||||
static void set_lock_focused_surface(struct wlr_surface *focused) {
|
static void set_lock_focused_surface(struct wlr_surface *focused) {
|
||||||
|
@ -57,9 +58,7 @@ static void handle_output_commit(struct wl_listener *listener, void *data) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void handle_surface_destroy(struct wl_listener *listener, void *data) {
|
static void destroy_lock_surface(struct sway_session_lock_surface *surf) {
|
||||||
struct sway_session_lock_surface *surf = wl_container_of(listener, surf, destroy);
|
|
||||||
|
|
||||||
// Move the seat focus to another surface if one is available
|
// Move the seat focus to another surface if one is available
|
||||||
if (server.session_lock.focused == surf->surface) {
|
if (server.session_lock.focused == surf->surface) {
|
||||||
struct wlr_surface *next_focus = NULL;
|
struct wlr_surface *next_focus = NULL;
|
||||||
|
@ -79,10 +78,22 @@ static void handle_surface_destroy(struct wl_listener *listener, void *data) {
|
||||||
wl_list_remove(&surf->surface_commit.link);
|
wl_list_remove(&surf->surface_commit.link);
|
||||||
wl_list_remove(&surf->output_mode.link);
|
wl_list_remove(&surf->output_mode.link);
|
||||||
wl_list_remove(&surf->output_commit.link);
|
wl_list_remove(&surf->output_commit.link);
|
||||||
|
wl_list_remove(&surf->output_destroy.link);
|
||||||
output_damage_whole(surf->output);
|
output_damage_whole(surf->output);
|
||||||
free(surf);
|
free(surf);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void handle_surface_destroy(struct wl_listener *listener, void *data) {
|
||||||
|
struct sway_session_lock_surface *surf = wl_container_of(listener, surf, destroy);
|
||||||
|
destroy_lock_surface(surf);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void handle_output_destroy(struct wl_listener *listener, void *data) {
|
||||||
|
struct sway_session_lock_surface *surf =
|
||||||
|
wl_container_of(listener, surf, output_destroy);
|
||||||
|
destroy_lock_surface(surf);
|
||||||
|
}
|
||||||
|
|
||||||
static void handle_new_surface(struct wl_listener *listener, void *data) {
|
static void handle_new_surface(struct wl_listener *listener, void *data) {
|
||||||
struct wlr_session_lock_surface_v1 *lock_surface = data;
|
struct wlr_session_lock_surface_v1 *lock_surface = data;
|
||||||
struct sway_session_lock_surface *surf = calloc(1, sizeof(*surf));
|
struct sway_session_lock_surface *surf = calloc(1, sizeof(*surf));
|
||||||
|
@ -108,6 +119,8 @@ static void handle_new_surface(struct wl_listener *listener, void *data) {
|
||||||
wl_signal_add(&output->wlr_output->events.mode, &surf->output_mode);
|
wl_signal_add(&output->wlr_output->events.mode, &surf->output_mode);
|
||||||
surf->output_commit.notify = handle_output_commit;
|
surf->output_commit.notify = handle_output_commit;
|
||||||
wl_signal_add(&output->wlr_output->events.commit, &surf->output_commit);
|
wl_signal_add(&output->wlr_output->events.commit, &surf->output_commit);
|
||||||
|
surf->output_destroy.notify = handle_output_destroy;
|
||||||
|
wl_signal_add(&output->node.events.destroy, &surf->output_destroy);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void handle_unlock(struct wl_listener *listener, void *data) {
|
static void handle_unlock(struct wl_listener *listener, void *data) {
|
||||||
|
|
Loading…
Reference in a new issue