@@ -220,6 +220,7 @@ static const struct wl_registry_listener registry_listener = {
220220};
221221
222222bool wl_init (void ) {
223+ ctx .dirty = false;
223224 wl_list_init (& ctx .outputs );
224225 wl_list_init (& ctx .seats );
225226 wl_list_init (& toplevel_list );
@@ -334,11 +335,15 @@ void wl_deinit(void) {
334335 if (ctx .layer_surface != NULL ) {
335336 g_clear_pointer (& ctx .layer_surface , zwlr_layer_surface_v1_destroy );
336337 }
338+ if (ctx .frame_callback ) {
339+ g_clear_pointer (& ctx .frame_callback , wl_callback_destroy );
340+ }
337341 if (ctx .surface != NULL ) {
338342 g_clear_pointer (& ctx .surface , wl_surface_destroy );
339343 }
340344 finish_buffer (& ctx .buffers [0 ]);
341345 finish_buffer (& ctx .buffers [1 ]);
346+ ctx .current_buffer = NULL ;
342347
343348 // The output list is initialized at the start of init, so no need to
344349 // check for NULL
@@ -383,10 +388,20 @@ void wl_deinit(void) {
383388 if (ctx .cursor_theme != NULL ) {
384389 g_clear_pointer (& ctx .cursor_theme , wl_cursor_theme_destroy );
385390 g_clear_pointer (& ctx .cursor_surface , wl_surface_destroy );
391+ ctx .cursor_image = NULL ;
392+ }
393+
394+ if (ctx .toplevel_manager ) {
395+ zwlr_foreign_toplevel_manager_v1_stop (ctx .toplevel_manager );
396+ g_clear_pointer (& ctx .toplevel_manager , zwlr_foreign_toplevel_manager_v1_destroy );
397+ // Set it to the default initialization value instead to UINT32_MAX
398+ // (the latter is used on initialization to mark a bad value)
399+ ctx .toplevel_manager_name = 0 ;
386400 }
387401
388402 // this also disconnects the wl_display
389403 g_clear_pointer (& ctx .esrc , g_water_wayland_source_free );
404+ ctx .display = NULL ;
390405}
391406
392407static void schedule_frame_and_commit (void );
0 commit comments