commit 83770325de02bf656f0889130706e0e374f9711b
parent 1f26824fb4ccc73322bad78c73d28d4fa4733c1e
Author: Michael Forney <mforney@mforney.org>
Date: Thu, 29 Aug 2019 00:25:17 -0700
data_device_manager: Move away from global state
Diffstat:
4 files changed, 14 insertions(+), 26 deletions(-)
diff --git a/libswc/data_device_manager.c b/libswc/data_device_manager.c
@@ -1,6 +1,6 @@
/* swc: data_device_manager.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 "internal.h"
#include "seat.h"
-static struct {
- struct wl_global *global;
-} data_device_manager;
-
static void
create_data_source(struct wl_client *client, struct wl_resource *resource, uint32_t id)
{
@@ -65,17 +61,8 @@ bind_data_device_manager(struct wl_client *client, void *data, uint32_t version,
wl_resource_set_implementation(resource, &data_device_manager_implementation, NULL, NULL);
}
-bool
-data_device_manager_initialize(void)
-{
- data_device_manager.global = wl_global_create(swc.display, &wl_data_device_manager_interface, 1,
- NULL, &bind_data_device_manager);
-
- return data_device_manager.global != NULL;
-}
-
-void
-data_device_manager_finalize(void)
+struct wl_global *
+data_device_manager_create(struct wl_display *display)
{
- wl_global_destroy(data_device_manager.global);
+ return wl_global_create(display, &wl_data_device_manager_interface, 1, NULL, &bind_data_device_manager);
}
diff --git a/libswc/data_device_manager.h b/libswc/data_device_manager.h
@@ -1,6 +1,6 @@
/* swc: data_device_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_DATA_DEVICE_MANAGER_H
#define SWC_DATA_DEVICE_MANAGER_H
-#include <stdbool.h>
+struct wl_display;
-bool data_device_manager_initialize(void);
-void data_device_manager_finalize(void);
+struct wl_global *data_device_manager_create(struct wl_display *display);
#endif
diff --git a/libswc/internal.h b/libswc/internal.h
@@ -1,6 +1,6 @@
/* swc: swc/internal.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
@@ -45,6 +45,7 @@ struct swc {
struct swc_compositor *const compositor;
struct swc_shm *const shm;
struct swc_drm *const drm;
+ struct wl_global *data_device_manager;
};
extern struct swc swc;
diff --git a/libswc/swc.c b/libswc/swc.c
@@ -1,6 +1,6 @@
/* swc: libswc/swc.c
*
- * Copyright (c) 2013, 2014, 2018 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
@@ -145,7 +145,8 @@ swc_initialize(struct wl_display *display, struct wl_event_loop *event_loop, con
goto error6;
}
- if (!data_device_manager_initialize()) {
+ swc.data_device_manager = data_device_manager_create(display);
+ if (!swc.data_device_manager) {
ERROR("Could not initialize data device manager\n");
goto error7;
}
@@ -181,7 +182,7 @@ error10:
error9:
seat_finalize();
error8:
- data_device_manager_finalize();
+ wl_global_destroy(swc.data_device_manager);
error7:
subcompositor_finalize();
error6:
@@ -206,7 +207,7 @@ swc_finalize(void)
panel_manager_finalize();
shell_finalize();
seat_finalize();
- data_device_manager_finalize();
+ wl_global_destroy(swc.data_device_manager);
compositor_finalize();
screens_finalize();
bindings_finalize();