commit 411db3e
Michael Forney
·
2019-09-07 08:26:23 +0000 UTC
parent b64702a
shell: Move away from global state
4 files changed,
+12,
-22
+1,
-0
1@@ -47,6 +47,7 @@ struct swc {
2 struct swc_drm *const drm;
3 struct wl_global *data_device_manager;
4 struct wl_global *panel_manager;
5+ struct wl_global *shell;
6 struct wl_global *xdg_shell;
7 };
8
+4,
-15
1@@ -1,6 +1,6 @@
2 /* swc: libswc/shell.c
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@@ -27,10 +27,6 @@
10
11 #include <wayland-server.h>
12
13-static struct {
14- struct wl_global *global;
15-} shell;
16-
17 static void
18 get_shell_surface(struct wl_client *client, struct wl_resource *resource, uint32_t id, struct wl_resource *surface_resource)
19 {
20@@ -59,15 +55,8 @@ bind_shell(struct wl_client *client, void *data, uint32_t version, uint32_t id)
21 wl_resource_set_implementation(resource, &shell_implementation, NULL, NULL);
22 }
23
24-bool
25-shell_initialize(void)
26-{
27- shell.global = wl_global_create(swc.display, &wl_shell_interface, 1, NULL, &bind_shell);
28- return shell.global;
29-}
30-
31-void
32-shell_finalize(void)
33+struct wl_global *
34+shell_create(struct wl_display *display)
35 {
36- wl_global_destroy(shell.global);
37+ return wl_global_create(display, &wl_shell_interface, 1, NULL, &bind_shell);
38 }
+3,
-4
1@@ -1,6 +1,6 @@
2 /* swc: libswc/shell.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_SHELL_H
11 #define SWC_SHELL_H
12
13-#include <stdbool.h>
14+struct wl_display;
15
16-bool shell_initialize(void);
17-void shell_finalize(void);
18+struct wl_global *shell_create(struct wl_display *display);
19
20 #endif
+4,
-3
1@@ -154,7 +154,8 @@ swc_initialize(struct wl_display *display, struct wl_event_loop *event_loop, con
2 goto error8;
3 }
4
5- if (!shell_initialize()) {
6+ swc.shell = shell_create(display);
7+ if (!swc.shell) {
8 ERROR("Could not initialize shell\n");
9 goto error9;
10 }
11@@ -178,7 +179,7 @@ swc_initialize(struct wl_display *display, struct wl_event_loop *event_loop, con
12 error11:
13 wl_global_destroy(swc.xdg_shell);
14 error10:
15- shell_finalize();
16+ wl_global_destroy(swc.shell);
17 error9:
18 seat_destroy(swc.seat);
19 error8:
20@@ -206,7 +207,7 @@ swc_finalize(void)
21 {
22 wl_global_destroy(swc.panel_manager);
23 wl_global_destroy(swc.xdg_shell);
24- shell_finalize();
25+ wl_global_destroy(swc.shell);
26 seat_destroy(swc.seat);
27 wl_global_destroy(swc.data_device_manager);
28 compositor_finalize();