input: Clean up input_method_relay in seat_destoy()

This fixes a crash that happens when input_method_new or text_method_new
events are emitted after the seat has been freed.
This commit is contained in:
Andri Yngvason 2020-12-28 02:07:41 +00:00 committed by Simon Ser
parent 53f5197c26
commit 98eece53ad
3 changed files with 8 additions and 0 deletions

View file

@ -53,6 +53,8 @@ struct sway_text_input {
void sway_input_method_relay_init(struct sway_seat *seat, void sway_input_method_relay_init(struct sway_seat *seat,
struct sway_input_method_relay *relay); struct sway_input_method_relay *relay);
void sway_input_method_relay_finish(struct sway_input_method_relay *relay);
// Updates currently focused surface. Surface must belong to the same seat. // Updates currently focused surface. Surface must belong to the same seat.
void sway_input_method_relay_set_focus(struct sway_input_method_relay *relay, void sway_input_method_relay_set_focus(struct sway_input_method_relay *relay,
struct wlr_surface *surface); struct wlr_surface *surface);

View file

@ -51,6 +51,7 @@ void seat_destroy(struct sway_seat *seat) {
wl_list_for_each_safe(seat_device, next, &seat->devices, link) { wl_list_for_each_safe(seat_device, next, &seat->devices, link) {
seat_device_destroy(seat_device); seat_device_destroy(seat_device);
} }
sway_input_method_relay_finish(&seat->im_relay);
sway_cursor_destroy(seat->cursor); sway_cursor_destroy(seat->cursor);
wl_list_remove(&seat->new_node.link); wl_list_remove(&seat->new_node.link);
wl_list_remove(&seat->request_start_drag.link); wl_list_remove(&seat->request_start_drag.link);

View file

@ -263,6 +263,11 @@ void sway_input_method_relay_init(struct sway_seat *seat,
&relay->input_method_new); &relay->input_method_new);
} }
void sway_input_method_relay_finish(struct sway_input_method_relay *relay) {
wl_list_remove(&relay->input_method_new.link);
wl_list_remove(&relay->text_input_new.link);
}
void sway_input_method_relay_set_focus(struct sway_input_method_relay *relay, void sway_input_method_relay_set_focus(struct sway_input_method_relay *relay,
struct wlr_surface *surface) { struct wlr_surface *surface) {
struct sway_text_input *text_input; struct sway_text_input *text_input;