commit b64702a
Michael Forney
·
2019-09-03 22:05:39 +0000 UTC
parent 5c889bf
panel_manager: Move away from global state
4 files changed,
+11,
-25
+1,
-0
1@@ -46,6 +46,7 @@ struct swc {
2 struct swc_shm *shm;
3 struct swc_drm *const drm;
4 struct wl_global *data_device_manager;
5+ struct wl_global *panel_manager;
6 struct wl_global *xdg_shell;
7 };
8
+4,
-19
1@@ -1,6 +1,6 @@
2 /* swc: libswc/panel_manager.c
3 *
4- * Copyright (c) 2013, 2014 Michael Forney
5+ * Copyright (c) 2013-2019 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@@ -28,10 +28,6 @@
10 #include <wayland-server.h>
11 #include "swc-server-protocol.h"
12
13-static struct {
14- struct wl_global *global;
15-} panel_manager;
16-
17 static void
18 create_panel(struct wl_client *client, struct wl_resource *resource, uint32_t id, struct wl_resource *surface_resource)
19 {
20@@ -57,19 +53,8 @@ bind_panel_manager(struct wl_client *client, void *data, uint32_t version, uint3
21 wl_resource_set_implementation(resource, &panel_manager_impl, NULL, NULL);
22 }
23
24-bool
25-panel_manager_initialize(void)
26-{
27- panel_manager.global = wl_global_create(swc.display, &swc_panel_manager_interface, 1, NULL, &bind_panel_manager);
28-
29- if (!panel_manager.global)
30- return false;
31-
32- return true;
33-}
34-
35-void
36-panel_manager_finalize(void)
37+struct wl_global *
38+panel_manager_create(struct wl_display *display)
39 {
40- wl_global_destroy(panel_manager.global);
41+ return wl_global_create(display, &swc_panel_manager_interface, 1, NULL, &bind_panel_manager);
42 }
+3,
-4
1@@ -1,6 +1,6 @@
2 /* swc: libswc/panel_manager.h
3 *
4- * Copyright (c) 2013 Michael Forney
5+ * Copyright (c) 2013-2019 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_PANEL_MANAGER_H
11 #define SWC_PANEL_MANAGER_H
12
13-#include <stdbool.h>
14+struct wl_display;
15
16-bool panel_manager_initialize(void);
17-void panel_manager_finalize(void);
18+struct wl_global *panel_manager_create(struct wl_display *display);
19
20 #endif
+3,
-2
1@@ -165,7 +165,8 @@ swc_initialize(struct wl_display *display, struct wl_event_loop *event_loop, con
2 goto error10;
3 }
4
5- if (!panel_manager_initialize()) {
6+ swc.panel_manager = panel_manager_create(display);
7+ if (!swc.panel_manager) {
8 ERROR("Could not initialize panel manager\n");
9 goto error11;
10 }
11@@ -203,7 +204,7 @@ error0:
12 EXPORT void
13 swc_finalize(void)
14 {
15- panel_manager_finalize();
16+ wl_global_destroy(swc.panel_manager);
17 wl_global_destroy(swc.xdg_shell);
18 shell_finalize();
19 seat_destroy(swc.seat);