commit 14e25e8
Michael Forney
·
2020-01-05 00:24:35 +0000 UTC
parent dc3c54c
subcompositor: Move away from global state
4 files changed,
+11,
-23
+1,
-0
1@@ -48,6 +48,7 @@ struct swc {
2 struct wl_global *data_device_manager;
3 struct wl_global *panel_manager;
4 struct wl_global *shell;
5+ struct wl_global *subcompositor;
6 struct wl_global *xdg_shell;
7 };
8
+3,
-16
1@@ -27,8 +27,6 @@
2 #include "subsurface.h"
3 #include "util.h"
4
5-static struct wl_global *global;
6-
7 static void
8 get_subsurface(struct wl_client *client, struct wl_resource *resource,
9 uint32_t id, struct wl_resource *surface_resource, struct wl_resource *parent_resource)
10@@ -61,19 +59,8 @@ bind_subcompositor(struct wl_client *client, void *data, uint32_t version, uint3
11 wl_resource_set_implementation(resource, &subcompositor_impl, NULL, NULL);
12 }
13
14-bool
15-subcompositor_initialize(void)
16-{
17- global = wl_global_create(swc.display, &wl_subcompositor_interface, 1, NULL, &bind_subcompositor);
18-
19- if (!global)
20- return false;
21-
22- return true;
23-}
24-
25-void
26-subcompositor_finalize(void)
27+struct wl_global *
28+subcompositor_create(struct wl_display *display)
29 {
30- wl_global_destroy(global);
31+ return wl_global_create(display, &wl_subcompositor_interface, 1, NULL, &bind_subcompositor);
32 }
+3,
-4
1@@ -1,6 +1,6 @@
2 /* swc: libswc/subcompositor.h
3 *
4- * Copyright (c) 2015 Michael Forney
5+ * Copyright (c) 2015-2020 Michael Forney
6 *
7 * Permission is hereby granted, free of charge, to any person obtaining a copy
8 * of this software and associated documentation files (the "Software"), to deal
9@@ -24,9 +24,8 @@
10 #ifndef SWC_SUBCOMPOSITOR_H
11 #define SWC_SUBCOMPOSITOR_H
12
13-#include <stdbool.h>
14+struct wl_display;
15
16-bool subcompositor_initialize(void);
17-void subcompositor_finalize(void);
18+struct wl_global *subcompositor_create(struct wl_display *display);
19
20 #endif
+4,
-3
1@@ -1,6 +1,6 @@
2 /* swc: libswc/swc.c
3 *
4- * Copyright (c) 2013-2019 Michael Forney
5+ * Copyright (c) 2013-2020 Michael Forney
6 *
7 * Permission is hereby granted, free of charge, to any person obtaining a copy
8 * of this software and associated documentation files (the "Software"), to deal
9@@ -127,7 +127,8 @@ swc_initialize(struct wl_display *display, struct wl_event_loop *event_loop, con
10 goto error3;
11 }
12
13- if (!subcompositor_initialize()) {
14+ swc.subcompositor = subcompositor_create(display);
15+ if (!swc.subcompositor) {
16 ERROR("Could not initialize subcompositor\n");
17 goto error4;
18 }
19@@ -185,7 +186,7 @@ error9:
20 error8:
21 wl_global_destroy(swc.data_device_manager);
22 error7:
23- subcompositor_finalize();
24+ wl_global_destroy(swc.subcompositor);
25 error6:
26 compositor_finalize();
27 error5: