commit ae98130
Michael Forney
·
2013-12-04 04:33:50 +0000 UTC
parent c704742
Move data_device_manager initialization to swc.c Also keep track of global created.
4 files changed,
+38,
-15
+0,
-1
1@@ -416,7 +416,6 @@ void swc_compositor_add_globals(struct swc_compositor * compositor,
2 wl_global_create(display, &wl_compositor_interface, 3, compositor,
3 &bind_compositor);
4
5- swc_data_device_manager_add_globals(display);
6 swc_drm_add_globals(&compositor->drm, display);
7
8 wl_list_for_each(output, &compositor->outputs, link)
+16,
-3
1@@ -27,6 +27,11 @@
2 #include "internal.h"
3 #include "seat.h"
4
5+static struct
6+{
7+ struct wl_global * global;
8+} data_device_manager;
9+
10 static void create_data_source(struct wl_client * client,
11 struct wl_resource * resource, uint32_t id)
12 {
13@@ -62,9 +67,17 @@ static void bind_data_device_manager(struct wl_client * client, void * data,
14 (resource, &data_device_manager_implementation, NULL, NULL);
15 }
16
17-void swc_data_device_manager_add_globals(struct wl_display * display)
18+bool swc_data_device_manager_initialize()
19+{
20+ data_device_manager.global
21+ = wl_global_create(swc.display, &wl_data_device_manager_interface, 1,
22+ NULL, &bind_data_device_manager);
23+
24+ return data_device_manager.global != NULL;
25+}
26+
27+void swc_data_device_manager_finalize()
28 {
29- wl_global_create(display, &wl_data_device_manager_interface, 1, NULL,
30- &bind_data_device_manager);
31+ wl_global_destroy(data_device_manager.global);
32 }
33
+3,
-2
1@@ -24,9 +24,10 @@
2 #ifndef SWC_DATA_DEVICE_MANAGER_H
3 #define SWC_DATA_DEVICE_MANAGER_H
4
5-#include <wayland-server.h>
6+#include <stdbool.h>
7
8-void swc_data_device_manager_add_globals(struct wl_display * display);
9+bool swc_data_device_manager_initialize();
10+void swc_data_device_manager_finalize();
11
12 #endif
13
+19,
-9
1@@ -24,6 +24,7 @@
2 #include "swc.h"
3 #include "bindings.h"
4 #include "compositor.h"
5+#include "data_device_manager.h"
6 #include "internal.h"
7 #include "keyboard.h"
8 #include "pointer.h"
9@@ -71,22 +72,28 @@ bool swc_initialize(struct wl_display * display,
10 goto error0;
11 }
12
13+ if (!swc_data_device_manager_initialize())
14+ {
15+ ERROR("Could not initialize data device manager\n");
16+ goto error1;
17+ }
18+
19 if (!swc_seat_initialize())
20 {
21 fprintf(stderr, "Could not initialize seat\n");
22- goto error1;
23+ goto error2;
24 }
25
26 if (!swc_bindings_initialize())
27 {
28 fprintf(stderr, "Could not initialize bindings\n");
29- goto error2;
30+ goto error3;
31 }
32
33 if (!swc_compositor_initialize(&compositor, display, swc.event_loop))
34 {
35 fprintf(stderr, "Could not initialize compositor\n");
36- goto error3;
37+ goto error4;
38 }
39
40 swc_compositor_add_globals(&compositor, display);
41@@ -94,14 +101,14 @@ bool swc_initialize(struct wl_display * display,
42 if (!swc_shell_initialize())
43 {
44 fprintf(stderr, "Could not initialize shell\n");
45- goto error4;
46+ goto error5;
47 }
48
49 #ifdef ENABLE_XWAYLAND
50 if (!swc_xserver_initialize())
51 {
52 fprintf(stderr, "Could not initialize xwayland\n");
53- goto error5;
54+ goto error6;
55 }
56 #endif
57
58@@ -109,14 +116,16 @@ bool swc_initialize(struct wl_display * display,
59
60 return true;
61
62- error5:
63+ error6:
64 swc_shell_finalize();
65- error4:
66+ error5:
67 swc_compositor_finish(&compositor);
68- error3:
69+ error4:
70 swc_bindings_finalize();
71- error2:
72+ error3:
73 swc_seat_finalize();
74+ error2:
75+ swc_data_device_manager_finalize();
76 error1:
77 udev_unref(swc.udev);
78 error0:
79@@ -133,6 +142,7 @@ void swc_finalize()
80 swc_compositor_finish(&compositor);
81 swc_bindings_finalize();
82 swc_seat_finalize();
83+ swc_data_device_manager_finalize();
84 udev_unref(swc.udev);
85 }
86