window: destroy misc objects on display_destroy()

Windows are supposed to be destroyed by the application explicitly.

Deferred tasks are not supposed to be added after returning from
display_run().

Destroy remaining wl objects (except input related will be in a
following patch).

Close the epoll fd.

Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
diff --git a/clients/window.c b/clients/window.c
index c1aee89..9b557dd 100644
--- a/clients/window.c
+++ b/clients/window.c
@@ -2607,11 +2607,30 @@
 void
 display_destroy(struct display *display)
 {
+	if (!wl_list_empty(&display->window_list))
+		fprintf(stderr, "toytoolkit warning: windows exist.\n");
+
+	if (!wl_list_empty(&display->deferred_list))
+		fprintf(stderr, "toytoolkit warning: deferred tasks exist.\n");
+
 	display_destroy_outputs(display);
 
 	fini_xkb(display);
 	fini_egl(display);
 
+	if (display->shell)
+		wl_shell_destroy(display->shell);
+
+	if (display->shm)
+		wl_shm_destroy(display->shm);
+
+	if (display->data_device_manager)
+		wl_data_device_manager_destroy(display->data_device_manager);
+
+	wl_compositor_destroy(display->compositor);
+
+	close(display->epoll_fd);
+
 	wl_display_flush(display->display);
 	wl_display_destroy(display->display);
 	free(display);