commit b64702ae8239df5318b25bef2ce08341efe6929c
parent 5c889bf5af72abd78a5f01baf060a09c5f1b8e3c
Author: Michael Forney <mforney@mforney.org>
Date: Tue, 3 Sep 2019 15:05:39 -0700
panel_manager: Move away from global state
Diffstat:
4 files changed, 11 insertions(+), 25 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 *panel_manager;
struct wl_global *xdg_shell;
};
diff --git a/libswc/panel_manager.c b/libswc/panel_manager.c
@@ -1,6 +1,6 @@
/* swc: libswc/panel_manager.c
*
- * Copyright (c) 2013, 2014 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
@@ -28,10 +28,6 @@
#include <wayland-server.h>
#include "swc-server-protocol.h"
-static struct {
- struct wl_global *global;
-} panel_manager;
-
static void
create_panel(struct wl_client *client, struct wl_resource *resource, uint32_t id, struct wl_resource *surface_resource)
{
@@ -57,19 +53,8 @@ bind_panel_manager(struct wl_client *client, void *data, uint32_t version, uint3
wl_resource_set_implementation(resource, &panel_manager_impl, NULL, NULL);
}
-bool
-panel_manager_initialize(void)
-{
- panel_manager.global = wl_global_create(swc.display, &swc_panel_manager_interface, 1, NULL, &bind_panel_manager);
-
- if (!panel_manager.global)
- return false;
-
- return true;
-}
-
-void
-panel_manager_finalize(void)
+struct wl_global *
+panel_manager_create(struct wl_display *display)
{
- wl_global_destroy(panel_manager.global);
+ return wl_global_create(display, &swc_panel_manager_interface, 1, NULL, &bind_panel_manager);
}
diff --git a/libswc/panel_manager.h b/libswc/panel_manager.h
@@ -1,6 +1,6 @@
/* swc: libswc/panel_manager.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_PANEL_MANAGER_H
#define SWC_PANEL_MANAGER_H
-#include <stdbool.h>
+struct wl_display;
-bool panel_manager_initialize(void);
-void panel_manager_finalize(void);
+struct wl_global *panel_manager_create(struct wl_display *display);
#endif
diff --git a/libswc/swc.c b/libswc/swc.c
@@ -165,7 +165,8 @@ swc_initialize(struct wl_display *display, struct wl_event_loop *event_loop, con
goto error10;
}
- if (!panel_manager_initialize()) {
+ swc.panel_manager = panel_manager_create(display);
+ if (!swc.panel_manager) {
ERROR("Could not initialize panel manager\n");
goto error11;
}
@@ -203,7 +204,7 @@ error0:
EXPORT void
swc_finalize(void)
{
- panel_manager_finalize();
+ wl_global_destroy(swc.panel_manager);
wl_global_destroy(swc.xdg_shell);
shell_finalize();
seat_destroy(swc.seat);