commit 411db3e00b153227e2d462288d082bee4f7b7530
parent b64702ae8239df5318b25bef2ce08341efe6929c
Author: Michael Forney <mforney@mforney.org>
Date: Sat, 7 Sep 2019 01:26:23 -0700
shell: Move away from global state
Diffstat:
4 files changed, 12 insertions(+), 22 deletions(-)
diff --git a/libswc/internal.h b/libswc/internal.h
@@ -47,6 +47,7 @@ struct swc {
struct swc_drm *const drm;
struct wl_global *data_device_manager;
struct wl_global *panel_manager;
+ struct wl_global *shell;
struct wl_global *xdg_shell;
};
diff --git a/libswc/shell.c b/libswc/shell.c
@@ -1,6 +1,6 @@
/* swc: libswc/shell.c
*
- * Copyright (c) 2013 Michael Forney
+ * Copyright (c) 2013-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
@@ -27,10 +27,6 @@
#include <wayland-server.h>
-static struct {
- struct wl_global *global;
-} shell;
-
static void
get_shell_surface(struct wl_client *client, struct wl_resource *resource, uint32_t id, struct wl_resource *surface_resource)
{
@@ -59,15 +55,8 @@ bind_shell(struct wl_client *client, void *data, uint32_t version, uint32_t id)
wl_resource_set_implementation(resource, &shell_implementation, NULL, NULL);
}
-bool
-shell_initialize(void)
-{
- shell.global = wl_global_create(swc.display, &wl_shell_interface, 1, NULL, &bind_shell);
- return shell.global;
-}
-
-void
-shell_finalize(void)
+struct wl_global *
+shell_create(struct wl_display *display)
{
- wl_global_destroy(shell.global);
+ return wl_global_create(display, &wl_shell_interface, 1, NULL, &bind_shell);
}
diff --git a/libswc/shell.h b/libswc/shell.h
@@ -1,6 +1,6 @@
/* swc: libswc/shell.h
*
- * Copyright (c) 2013 Michael Forney
+ * Copyright (c) 2013-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_SHELL_H
#define SWC_SHELL_H
-#include <stdbool.h>
+struct wl_display;
-bool shell_initialize(void);
-void shell_finalize(void);
+struct wl_global *shell_create(struct wl_display *display);
#endif
diff --git a/libswc/swc.c b/libswc/swc.c
@@ -154,7 +154,8 @@ swc_initialize(struct wl_display *display, struct wl_event_loop *event_loop, con
goto error8;
}
- if (!shell_initialize()) {
+ swc.shell = shell_create(display);
+ if (!swc.shell) {
ERROR("Could not initialize shell\n");
goto error9;
}
@@ -178,7 +179,7 @@ swc_initialize(struct wl_display *display, struct wl_event_loop *event_loop, con
error11:
wl_global_destroy(swc.xdg_shell);
error10:
- shell_finalize();
+ wl_global_destroy(swc.shell);
error9:
seat_destroy(swc.seat);
error8:
@@ -206,7 +207,7 @@ swc_finalize(void)
{
wl_global_destroy(swc.panel_manager);
wl_global_destroy(swc.xdg_shell);
- shell_finalize();
+ wl_global_destroy(swc.shell);
seat_destroy(swc.seat);
wl_global_destroy(swc.data_device_manager);
compositor_finalize();