Skip to content
Myr

wayland: track current frame callback, and destroy on exit

Before adoption: this commit came in with the history the project adopted, so no landing records it.

This fixes a memory leak when exiting fuzzel while a frame callback is scheduled.

authored by Daniel Eklöf · committed by Daniel Eklöf · parent ed76833 · Browse files · 1 file+11 added−7 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+11 added−7 removed

  • other:+11 added−7 removed

1 file+11 added−7 removed

modified:wayland.c+11 added-7 removed
170 unmodified lines
171 int exit_code;172 enum dmenu_mode dmenu_mode;173 const char *launch_prefix;174175 bool frame_is_scheduled;175 struct wl_callback *frame_cb;176 struct buffer *pending;177178 struct wl_display *display;179 struct wl_registry *registry;
1252 unmodified lines
1432 wl_surface_set_buffer_scale(wayl->surface, wayl->scale);1433 wl_surface_attach(wayl->surface, buf->wl_buf, 0, 0);1434 wl_surface_damage_buffer(wayl->surface, 0, 0, buf->width, buf->height);14351436 assert(wayl->frame_cb == NULL);1436 struct wl_callback *cb = wl_surface_frame(wayl->surface);1437 wl_callback_add_listener(cb, &frame_listener, wayl);1437 wayl->frame_cb = wl_surface_frame(wayl->surface);1438 wl_callback_add_listener(wayl->frame_cb, &frame_listener, wayl);14391439 wayl->frame_is_scheduled = true;1440 wl_surface_commit(wayl->surface);1441}14421443static void1444frame_callback(void *data, struct wl_callback *wl_callback, uint32_t callback_data)1445{1446 struct wayland *wayl = data;14471448 wayl->frame_is_scheduled = false;1449 wl_callback_destroy(wl_callback);1448 assert(wayl->frame_cb == wl_callback);1449 wl_callback_destroy(wayl->frame_cb);1450 wayl->frame_cb = NULL;14511452 if (wayl->pending != NULL) {1453 commit_buffer(wayl, wayl->pending);1454 wayl->pending = NULL;
36 unmodified lines
1491#if defined(FUZZEL_ENABLE_CAIRO)1492 cairo_surface_flush(buf->cairo_surface);1493#endif14941494 if (wayl->frame_is_scheduled) {1495 if (wayl->frame_cb != NULL) {1496 /* There's already a frame being drawn - delay current frame1497 * (overwriting any previous pending frame) */14981499 if (wayl->pending != NULL)
303 unmodified lines
1803{1804 if (wayl == NULL)1805 return;18061807 if (wayl->frame_cb != NULL)1808 wl_callback_destroy(wayl->frame_cb);18091810 if (wayl->display != NULL)1811 fdm_del_no_close(wayl->fdm, wl_display_get_fd(wayl->display));18121813 tll_foreach(wayl->seats, it)
52 unmodified lines