unlink global listeners on destroy

Continuation of 0925fe956a
This commit is contained in:
Leonardo Hernández Hernández 2025-01-19 14:04:03 -06:00
parent 4e7e2999d4
commit 9a9f67db1c
No known key found for this signature in database
GPG key ID: E538897EE11B9624

49
dwl.c
View file

@ -252,6 +252,7 @@ static void chvt(const Arg *arg);
static void checkidleinhibitor(struct wlr_surface *exclude); static void checkidleinhibitor(struct wlr_surface *exclude);
static void cleanup(void); static void cleanup(void);
static void cleanupmon(struct wl_listener *listener, void *data); static void cleanupmon(struct wl_listener *listener, void *data);
static void cleanuplisteners(void);
static void closemon(Monitor *m); static void closemon(Monitor *m);
static void commitlayersurfacenotify(struct wl_listener *listener, void *data); static void commitlayersurfacenotify(struct wl_listener *listener, void *data);
static void commitnotify(struct wl_listener *listener, void *data); static void commitnotify(struct wl_listener *listener, void *data);
@ -279,7 +280,6 @@ static void destroylocksurface(struct wl_listener *listener, void *data);
static void destroynotify(struct wl_listener *listener, void *data); static void destroynotify(struct wl_listener *listener, void *data);
static void destroypointerconstraint(struct wl_listener *listener, void *data); static void destroypointerconstraint(struct wl_listener *listener, void *data);
static void destroysessionlock(struct wl_listener *listener, void *data); static void destroysessionlock(struct wl_listener *listener, void *data);
static void destroysessionmgr(struct wl_listener *listener, void *data);
static void destroykeyboardgroup(struct wl_listener *listener, void *data); static void destroykeyboardgroup(struct wl_listener *listener, void *data);
static Monitor *dirtomon(enum wlr_direction dir); static Monitor *dirtomon(enum wlr_direction dir);
static void focusclient(Client *c, int lift); static void focusclient(Client *c, int lift);
@ -435,7 +435,6 @@ static struct wl_listener request_set_shape = {.notify = setcursorshape};
static struct wl_listener request_start_drag = {.notify = requeststartdrag}; static struct wl_listener request_start_drag = {.notify = requeststartdrag};
static struct wl_listener start_drag = {.notify = startdrag}; static struct wl_listener start_drag = {.notify = startdrag};
static struct wl_listener session_lock_create_lock = {.notify = locksession}; static struct wl_listener session_lock_create_lock = {.notify = locksession};
static struct wl_listener session_lock_mgr_destroy = {.notify = destroysessionmgr};
#ifdef XWAYLAND #ifdef XWAYLAND
static void activatex11(struct wl_listener *listener, void *data); static void activatex11(struct wl_listener *listener, void *data);
@ -696,6 +695,7 @@ checkidleinhibitor(struct wlr_surface *exclude)
void void
cleanup(void) cleanup(void)
{ {
cleanuplisteners();
#ifdef XWAYLAND #ifdef XWAYLAND
wlr_xwayland_destroy(xwayland); wlr_xwayland_destroy(xwayland);
xwayland = NULL; xwayland = NULL;
@ -745,6 +745,43 @@ cleanupmon(struct wl_listener *listener, void *data)
free(m); free(m);
} }
void
cleanuplisteners(void)
{
wl_list_remove(&cursor_axis.link);
wl_list_remove(&cursor_button.link);
wl_list_remove(&cursor_frame.link);
wl_list_remove(&cursor_motion.link);
wl_list_remove(&cursor_motion_absolute.link);
wl_list_remove(&gpu_reset.link);
wl_list_remove(&idle_inhibitor_create.link);
wl_list_remove(&layout_change.link);
wl_list_remove(&new_input.link);
wl_list_remove(&new_virtual_keyboard.link);
wl_list_remove(&new_virtual_pointer.link);
wl_list_remove(&new_pointer_constraint.link);
wl_list_remove(&new_output.link);
wl_list_remove(&new_xdg_surface.link);
wl_list_remove(&new_xdg_decoration.link);
wl_list_remove(&new_xdg_popup.link);
wl_list_remove(&new_layer_shell_surface.link);
wl_list_remove(&output_mgr_apply.link);
wl_list_remove(&output_mgr_test.link);
wl_list_remove(&output_power_mgr_set_mode.link);
wl_list_remove(&request_activate.link);
wl_list_remove(&request_cursor.link);
wl_list_remove(&request_set_psel.link);
wl_list_remove(&request_set_sel.link);
wl_list_remove(&request_set_shape.link);
wl_list_remove(&request_start_drag.link);
wl_list_remove(&start_drag.link);
wl_list_remove(&session_lock_create_lock.link);
#ifdef XWAYLAND
wl_list_remove(&new_xwayland_surface.link);
wl_list_remove(&xwayland_ready.link);
#endif
}
void void
closemon(Monitor *m) closemon(Monitor *m)
{ {
@ -1325,13 +1362,6 @@ destroysessionlock(struct wl_listener *listener, void *data)
destroylock(lock, 0); destroylock(lock, 0);
} }
void
destroysessionmgr(struct wl_listener *listener, void *data)
{
wl_list_remove(&session_lock_create_lock.link);
wl_list_remove(&session_lock_mgr_destroy.link);
}
void void
destroykeyboardgroup(struct wl_listener *listener, void *data) destroykeyboardgroup(struct wl_listener *listener, void *data)
{ {
@ -2528,7 +2558,6 @@ setup(void)
session_lock_mgr = wlr_session_lock_manager_v1_create(dpy); session_lock_mgr = wlr_session_lock_manager_v1_create(dpy);
wl_signal_add(&session_lock_mgr->events.new_lock, &session_lock_create_lock); wl_signal_add(&session_lock_mgr->events.new_lock, &session_lock_create_lock);
wl_signal_add(&session_lock_mgr->events.destroy, &session_lock_mgr_destroy);
locked_bg = wlr_scene_rect_create(layers[LyrBlock], sgeom.width, sgeom.height, locked_bg = wlr_scene_rect_create(layers[LyrBlock], sgeom.width, sgeom.height,
(float [4]){0.1f, 0.1f, 0.1f, 1.0f}); (float [4]){0.1f, 0.1f, 0.1f, 1.0f});
wlr_scene_node_set_enabled(&locked_bg->node, 0); wlr_scene_node_set_enabled(&locked_bg->node, 0);