commit de8e33bc5df25546d9a44d93d8cb9d0f504cab1b
parent badab714e7810623790ecf4997a2a66c26ebdfce
Author: Michael Forney <mforney@mforney.org>
Date: Thu, 29 Aug 2019 20:34:29 -0700
xdg_shell: Move away from global state
Diffstat:
4 files changed, 11 insertions(+), 21 deletions(-)
diff --git a/libswc/internal.h b/libswc/internal.h
@@ -46,6 +46,7 @@ struct swc {
struct swc_shm *shm;
struct swc_drm *const drm;
struct wl_global *data_device_manager;
+ struct wl_global *xdg_shell;
};
extern struct swc swc;
diff --git a/libswc/swc.c b/libswc/swc.c
@@ -159,7 +159,8 @@ swc_initialize(struct wl_display *display, struct wl_event_loop *event_loop, con
goto error9;
}
- if (!xdg_shell_initialize()) {
+ swc.xdg_shell = xdg_shell_create(display);
+ if (!swc.xdg_shell) {
ERROR("Could not initialize XDG shell\n");
goto error10;
}
@@ -174,7 +175,7 @@ swc_initialize(struct wl_display *display, struct wl_event_loop *event_loop, con
return true;
error11:
- xdg_shell_finalize();
+ wl_global_destroy(swc.xdg_shell);
error10:
shell_finalize();
error9:
@@ -203,7 +204,7 @@ EXPORT void
swc_finalize(void)
{
panel_manager_finalize();
- xdg_shell_finalize();
+ wl_global_destroy(swc.xdg_shell);
shell_finalize();
seat_destroy(swc.seat);
wl_global_destroy(swc.data_device_manager);
diff --git a/libswc/xdg_shell.c b/libswc/xdg_shell.c
@@ -462,10 +462,6 @@ error0:
}
/* xdg_shell */
-static struct {
- struct wl_global *global;
-} shell;
-
static void
create_positioner(struct wl_client *client, struct wl_resource *resource, uint32_t id)
{
@@ -527,15 +523,8 @@ bind_wm_base(struct wl_client *client, void *data, uint32_t version, uint32_t id
wl_resource_set_implementation(resource, &wm_base_impl, NULL, NULL);
}
-bool
-xdg_shell_initialize(void)
-{
- shell.global = wl_global_create(swc.display, &xdg_wm_base_interface, 1, NULL, &bind_wm_base);
- return shell.global;
-}
-
-void
-xdg_shell_finalize(void)
+struct wl_global *
+xdg_shell_create(struct wl_display *display)
{
- wl_global_destroy(shell.global);
+ return wl_global_create(display, &xdg_wm_base_interface, 1, NULL, &bind_wm_base);
}
diff --git a/libswc/xdg_shell.h b/libswc/xdg_shell.h
@@ -1,6 +1,6 @@
/* swc: libswc/xdg_shell.h
*
- * Copyright (c) 2018 Michael Forney
+ * Copyright (c) 2018-2019 Michael Forney
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
@@ -24,9 +24,8 @@
#ifndef SWC_XDG_SHELL_H
#define SWC_XDG_SHELL_H
-#include <stdbool.h>
+struct wl_display;
-bool xdg_shell_initialize(void);
-void xdg_shell_finalize(void);
+struct wl_global *xdg_shell_create(struct wl_display *display);
#endif