swc

Unnamed repository; edit this file 'description' to name the repository.
git clone git://git.nihaljere.xyz/swc
Log | Files | Refs | README | LICENSE

commit 14e25e81b51d2bb2b75b48b5708979466a7ea5b4
parent dc3c54c000c1390f4a615e262d9a6d68a201c354
Author: Michael Forney <mforney@mforney.org>
Date:   Sat,  4 Jan 2020 16:24:35 -0800

subcompositor: Move away from global state

Diffstat:
Mlibswc/internal.h | 1+
Mlibswc/subcompositor.c | 19+++----------------
Mlibswc/subcompositor.h | 7+++----
Mlibswc/swc.c | 7++++---
4 files changed, 11 insertions(+), 23 deletions(-)

diff --git a/libswc/internal.h b/libswc/internal.h @@ -48,6 +48,7 @@ struct swc { struct wl_global *data_device_manager; struct wl_global *panel_manager; struct wl_global *shell; + struct wl_global *subcompositor; struct wl_global *xdg_shell; }; diff --git a/libswc/subcompositor.c b/libswc/subcompositor.c @@ -27,8 +27,6 @@ #include "subsurface.h" #include "util.h" -static struct wl_global *global; - static void get_subsurface(struct wl_client *client, struct wl_resource *resource, uint32_t id, struct wl_resource *surface_resource, struct wl_resource *parent_resource) @@ -61,19 +59,8 @@ bind_subcompositor(struct wl_client *client, void *data, uint32_t version, uint3 wl_resource_set_implementation(resource, &subcompositor_impl, NULL, NULL); } -bool -subcompositor_initialize(void) -{ - global = wl_global_create(swc.display, &wl_subcompositor_interface, 1, NULL, &bind_subcompositor); - - if (!global) - return false; - - return true; -} - -void -subcompositor_finalize(void) +struct wl_global * +subcompositor_create(struct wl_display *display) { - wl_global_destroy(global); + return wl_global_create(display, &wl_subcompositor_interface, 1, NULL, &bind_subcompositor); } diff --git a/libswc/subcompositor.h b/libswc/subcompositor.h @@ -1,6 +1,6 @@ /* swc: libswc/subcompositor.h * - * Copyright (c) 2015 Michael Forney + * Copyright (c) 2015-2020 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_SUBCOMPOSITOR_H #define SWC_SUBCOMPOSITOR_H -#include <stdbool.h> +struct wl_display; -bool subcompositor_initialize(void); -void subcompositor_finalize(void); +struct wl_global *subcompositor_create(struct wl_display *display); #endif diff --git a/libswc/swc.c b/libswc/swc.c @@ -1,6 +1,6 @@ /* swc: libswc/swc.c * - * Copyright (c) 2013-2019 Michael Forney + * Copyright (c) 2013-2020 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 @@ -127,7 +127,8 @@ swc_initialize(struct wl_display *display, struct wl_event_loop *event_loop, con goto error3; } - if (!subcompositor_initialize()) { + swc.subcompositor = subcompositor_create(display); + if (!swc.subcompositor) { ERROR("Could not initialize subcompositor\n"); goto error4; } @@ -185,7 +186,7 @@ error9: error8: wl_global_destroy(swc.data_device_manager); error7: - subcompositor_finalize(); + wl_global_destroy(swc.subcompositor); error6: compositor_finalize(); error5: