aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoremersion <contact@emersion.fr>2017-12-07 00:44:45 +0100
committeremersion <contact@emersion.fr>2017-12-07 00:44:45 +0100
commite6d2e72401200743ba13e20945dfad9f458a87e1 (patch)
tree1cf743d2506dc5aba34cb72ab8df513806754ef2
parent32591d66d61e2a4ef06db89276f8d158d22d81a8 (diff)
Remove display destroy listeners, add compositor listener
-rw-r--r--include/wlr/types/wlr_compositor.h7
-rw-r--r--types/wlr_compositor.c16
-rw-r--r--types/wlr_screenshooter.c1
-rw-r--r--types/wlr_server_decoration.c1
4 files changed, 19 insertions, 6 deletions
diff --git a/include/wlr/types/wlr_compositor.h b/include/wlr/types/wlr_compositor.h
index b2f5a972..ceeb64ca 100644
--- a/include/wlr/types/wlr_compositor.h
+++ b/include/wlr/types/wlr_compositor.h
@@ -9,7 +9,8 @@ struct wlr_compositor {
struct wl_list wl_resources;
struct wlr_renderer *renderer;
struct wl_list surfaces;
- struct wl_listener destroy_surface_listener;
+
+ struct wl_listener display_destroy;
struct {
struct wl_signal create_surface;
@@ -20,8 +21,4 @@ void wlr_compositor_destroy(struct wlr_compositor *wlr_compositor);
struct wlr_compositor *wlr_compositor_create(struct wl_display *display,
struct wlr_renderer *renderer);
-struct wlr_surface;
-void wl_compositor_surface_destroyed(struct wlr_compositor *wlr_compositor,
- struct wlr_surface *surface);
-
#endif
diff --git a/types/wlr_compositor.c b/types/wlr_compositor.c
index 986b7e60..919d0e32 100644
--- a/types/wlr_compositor.c
+++ b/types/wlr_compositor.c
@@ -78,6 +78,7 @@ static void wl_compositor_bind(struct wl_client *wl_client, void *data,
}
void wlr_compositor_destroy(struct wlr_compositor *compositor) {
+ wl_list_remove(&compositor->display_destroy.link);
wl_global_destroy(compositor->wl_global);
free(compositor);
}
@@ -151,6 +152,12 @@ static void subcompositor_bind(struct wl_client *client, void *data,
compositor, NULL);
}
+static void handle_display_destroy(struct wl_listener *listener, void *data) {
+ struct wlr_compositor *compositor =
+ wl_container_of(listener, compositor, display_destroy);
+ wlr_compositor_destroy(compositor);
+}
+
struct wlr_compositor *wlr_compositor_create(struct wl_display *display,
struct wlr_renderer *renderer) {
struct wlr_compositor *compositor =
@@ -162,7 +169,11 @@ struct wlr_compositor *wlr_compositor_create(struct wl_display *display,
struct wl_global *compositor_global = wl_global_create(display,
&wl_compositor_interface, 4, compositor, wl_compositor_bind);
-
+ if (!compositor_global) {
+ wlr_log_errno(L_ERROR, "Could not allocate compositor global");
+ free(compositor);
+ return NULL;
+ }
compositor->wl_global = compositor_global;
compositor->renderer = renderer;
@@ -173,5 +184,8 @@ struct wlr_compositor *wlr_compositor_create(struct wl_display *display,
wl_list_init(&compositor->surfaces);
wl_signal_init(&compositor->events.create_surface);
+ compositor->display_destroy.notify = handle_display_destroy;
+ wl_display_add_destroy_listener(display, &compositor->display_destroy);
+
return compositor;
}
diff --git a/types/wlr_screenshooter.c b/types/wlr_screenshooter.c
index cb831827..8939f073 100644
--- a/types/wlr_screenshooter.c
+++ b/types/wlr_screenshooter.c
@@ -165,6 +165,7 @@ void wlr_screenshooter_destroy(struct wlr_screenshooter *screenshooter) {
return;
}
wl_signal_emit(&screenshooter->events.destroy, screenshooter);
+ wl_list_remove(&screenshooter->display_destroy.link);
struct wlr_screenshot *screenshot, *tmp;
wl_list_for_each_safe(screenshot, tmp, &screenshooter->screenshots, link) {
screenshot_destroy(screenshot);
diff --git a/types/wlr_server_decoration.c b/types/wlr_server_decoration.c
index 3531c453..09909bb6 100644
--- a/types/wlr_server_decoration.c
+++ b/types/wlr_server_decoration.c
@@ -145,6 +145,7 @@ void wlr_server_decoration_manager_destroy(
if (manager == NULL) {
return;
}
+ wl_list_remove(&manager->display_destroy.link);
struct wlr_server_decoration *decoration, *tmp_decoration;
wl_list_for_each_safe(decoration, tmp_decoration, &manager->decorations,
link) {