commit de8e33b
Michael Forney
·
2019-08-30 03:34:29 +0000 UTC
parent badab71
xdg_shell: Move away from global state
4 files changed,
+11,
-21
+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 *xdg_shell;
6 };
7
8 extern struct swc swc;
+4,
-3
1@@ -159,7 +159,8 @@ swc_initialize(struct wl_display *display, struct wl_event_loop *event_loop, con
2 goto error9;
3 }
4
5- if (!xdg_shell_initialize()) {
6+ swc.xdg_shell = xdg_shell_create(display);
7+ if (!swc.xdg_shell) {
8 ERROR("Could not initialize XDG shell\n");
9 goto error10;
10 }
11@@ -174,7 +175,7 @@ swc_initialize(struct wl_display *display, struct wl_event_loop *event_loop, con
12 return true;
13
14 error11:
15- xdg_shell_finalize();
16+ wl_global_destroy(swc.xdg_shell);
17 error10:
18 shell_finalize();
19 error9:
20@@ -203,7 +204,7 @@ EXPORT void
21 swc_finalize(void)
22 {
23 panel_manager_finalize();
24- xdg_shell_finalize();
25+ wl_global_destroy(swc.xdg_shell);
26 shell_finalize();
27 seat_destroy(swc.seat);
28 wl_global_destroy(swc.data_device_manager);
+3,
-14
1@@ -462,10 +462,6 @@ error0:
2 }
3
4 /* xdg_shell */
5-static struct {
6- struct wl_global *global;
7-} shell;
8-
9 static void
10 create_positioner(struct wl_client *client, struct wl_resource *resource, uint32_t id)
11 {
12@@ -527,15 +523,8 @@ bind_wm_base(struct wl_client *client, void *data, uint32_t version, uint32_t id
13 wl_resource_set_implementation(resource, &wm_base_impl, NULL, NULL);
14 }
15
16-bool
17-xdg_shell_initialize(void)
18-{
19- shell.global = wl_global_create(swc.display, &xdg_wm_base_interface, 1, NULL, &bind_wm_base);
20- return shell.global;
21-}
22-
23-void
24-xdg_shell_finalize(void)
25+struct wl_global *
26+xdg_shell_create(struct wl_display *display)
27 {
28- wl_global_destroy(shell.global);
29+ return wl_global_create(display, &xdg_wm_base_interface, 1, NULL, &bind_wm_base);
30 }
+3,
-4
1@@ -1,6 +1,6 @@
2 /* swc: libswc/xdg_shell.h
3 *
4- * Copyright (c) 2018 Michael Forney
5+ * Copyright (c) 2018-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_XDG_SHELL_H
11 #define SWC_XDG_SHELL_H
12
13-#include <stdbool.h>
14+struct wl_display;
15
16-bool xdg_shell_initialize(void);
17-void xdg_shell_finalize(void);
18+struct wl_global *xdg_shell_create(struct wl_display *display);
19
20 #endif