use wl_container_of() instead of data in some functions

This commit is contained in:
Leonardo Hernández Hernández 2022-09-10 23:44:19 -05:00
parent c509046663
commit 77ba8e5127
Failed to generate hash of commit

8
dwl.c
View file

@ -739,8 +739,7 @@ cleanup(void)
void void
cleanupkeyboard(struct wl_listener *listener, void *data) cleanupkeyboard(struct wl_listener *listener, void *data)
{ {
struct wlr_input_device *device = data; Keyboard *kb = wl_container_of(listener, kb, destroy);
Keyboard *kb = device->data;
wl_list_remove(&kb->link); wl_list_remove(&kb->link);
wl_list_remove(&kb->modifiers.link); wl_list_remove(&kb->modifiers.link);
@ -752,14 +751,13 @@ cleanupkeyboard(struct wl_listener *listener, void *data)
void void
cleanupmon(struct wl_listener *listener, void *data) cleanupmon(struct wl_listener *listener, void *data)
{ {
struct wlr_output *wlr_output = data; Monitor *m = wl_container_of(listener, m, destroy);
Monitor *m = wlr_output->data;
int nmons, i = 0; int nmons, i = 0;
wl_list_remove(&m->destroy.link); wl_list_remove(&m->destroy.link);
wl_list_remove(&m->frame.link); wl_list_remove(&m->frame.link);
wl_list_remove(&m->link); wl_list_remove(&m->link);
wlr_output->data = NULL; m->wlr_output->data = NULL;
wlr_output_layout_remove(output_layout, m->wlr_output); wlr_output_layout_remove(output_layout, m->wlr_output);
wlr_scene_output_destroy(m->scene_output); wlr_scene_output_destroy(m->scene_output);