[PATCH 3/4] xwayland: Keep a list of wayland globals
Dima Ryazanov
dima at gmail.com
Tue May 12 10:21:20 PDT 2015
The logic is pretty much copied from weston's clients/window.c.
Signed-off-by: Dima Ryazanov <dima at gmail.com>
---
hw/xwayland/xwayland.c | 25 ++++++++++++++++++++++++-
hw/xwayland/xwayland.h | 8 ++++++++
2 files changed, 32 insertions(+), 1 deletion(-)
diff --git a/hw/xwayland/xwayland.c b/hw/xwayland/xwayland.c
index 7e8d667..e99fbac 100644
--- a/hw/xwayland/xwayland.c
+++ b/hw/xwayland/xwayland.c
@@ -383,6 +383,17 @@ registry_global(void *data, struct wl_registry *registry, uint32_t id,
const char *interface, uint32_t version)
{
struct xwl_screen *xwl_screen = data;
+ struct xwl_global *xwl_global;
+
+ xwl_global = calloc(sizeof *xwl_global, 1);
+ if (xwl_global == NULL) {
+ ErrorF("registry_global ENOMEM\n");
+ return;
+ }
+ xwl_global->name = id;
+ xwl_global->interface = strdup(interface);
+ xwl_global->version = version;
+ xorg_list_add(&xwl_global->link, &xwl_screen->global_list);
if (strcmp(interface, "wl_compositor") == 0) {
xwl_screen->compositor =
@@ -410,7 +421,18 @@ registry_global(void *data, struct wl_registry *registry, uint32_t id,
static void
global_remove(void *data, struct wl_registry *registry, uint32_t name)
{
- /* Nothing to do here, wl_compositor and wl_shm should not be removed */
+ struct xwl_screen *xwl_screen = data;
+ struct xwl_global *xwl_global, *next_xwl_global;
+
+ xorg_list_for_each_entry_safe(xwl_global, next_xwl_global,
+ &xwl_screen->global_list, link) {
+ if (xwl_global->name != name)
+ continue;
+
+ xorg_list_del(&xwl_global->link);
+ free(xwl_global->interface);
+ free(xwl_global);
+ }
}
static const struct wl_registry_listener registry_listener = {
@@ -562,6 +584,7 @@ xwl_screen_init(ScreenPtr pScreen, int argc, char **argv)
listen_on_fds(xwl_screen);
}
+ xorg_list_init(&xwl_screen->global_list);
xorg_list_init(&xwl_screen->output_list);
xorg_list_init(&xwl_screen->seat_list);
xorg_list_init(&xwl_screen->damage_window_list);
diff --git a/hw/xwayland/xwayland.h b/hw/xwayland/xwayland.h
index cfb343d..2ba5312 100644
--- a/hw/xwayland/xwayland.h
+++ b/hw/xwayland/xwayland.h
@@ -64,6 +64,7 @@ struct xwl_screen {
UnrealizeWindowProcPtr UnrealizeWindow;
XYToWindowProcPtr XYToWindow;
+ struct xorg_list global_list;
struct xorg_list output_list;
struct xorg_list seat_list;
struct xorg_list damage_window_list;
@@ -95,6 +96,13 @@ struct xwl_screen {
struct glamor_context *glamor_ctx;
};
+struct xwl_global {
+ uint32_t name;
+ char *interface;
+ uint32_t version;
+ struct xorg_list link;
+};
+
struct xwl_window {
struct xwl_screen *xwl_screen;
struct wl_surface *surface;
--
2.4.0
More information about the wayland-devel
mailing list