[PATCH] Add wl_display_remove_global.

Laszlo Agocs laszlo.p.agocs at nokia.com
Fri Jun 10 03:43:16 PDT 2011


 From 9306be3637fd36aca936cfd797298a8e22c88c56 Mon Sep 17 00:00:00 2001
From: Laszlo Agocs <laszlo.p.agocs at nokia.com>
Date: Fri, 10 Jun 2011 11:17:51 +0200
Subject: [PATCH] Add wl_display_remove_global.

Change 4453ba084aae5a00318b9dfdeda95e8eaa17494c disallows using
post_global with objects not on the global list. Therefore selection
and drag offers have to be added to the global list from now on.
However these may often get replaced by a newer object and thus need a
way to remove a global from the global list.
---
  wayland/wayland-server.c |   18 ++++++++++++++++++
  wayland/wayland-server.h |    3 +++
  2 files changed, 21 insertions(+), 0 deletions(-)

diff --git a/wayland/wayland-server.c b/wayland/wayland-server.c
index 886ec69..043343a 100644
--- a/wayland/wayland-server.c
+++ b/wayland/wayland-server.c
@@ -656,6 +656,24 @@ wl_display_add_global(struct wl_display *display,
  	return 0;
  }

+WL_EXPORT int
+wl_display_remove_global(struct wl_display *display,
+                         struct wl_object *object)
+{
+    struct wl_global *global = NULL, *p;
+    wl_list_for_each(p, &display->global_list, link)
+        if (p->object == object) {
+            global = p;
+            break;
+        }
+    if (global) {
+        wl_list_remove(&global->link);
+        free(global);
+        return 0;
+    }
+    return -1;
+}
+
  WL_EXPORT void
  wl_display_post_frame(struct wl_display *display, struct wl_surface 
*surface,
  		      uint32_t time)
diff --git a/wayland/wayland-server.h b/wayland/wayland-server.h
index 6a042cd..d1c655a 100644
--- a/wayland/wayland-server.h
+++ b/wayland/wayland-server.h
@@ -93,6 +93,9 @@ int wl_display_add_global(struct wl_display *display,
  			  struct wl_object *object,
  			  wl_global_bind_func_t func);

+int wl_display_remove_global(struct wl_display *display,
+                             struct wl_object *object);
+
  struct wl_client *wl_client_create(struct wl_display *display, int fd);
  void wl_client_destroy(struct wl_client *client);
  void wl_client_post_error(struct wl_client *client, struct wl_object 
*object,
-- 
1.7.1




More information about the wayland-devel mailing list