summaryrefslogtreecommitdiffstats
path: root/wayland.c
diff options
context:
space:
mode:
authorKristian Høgsberg <krh@redhat.com>2008-11-23 19:10:23 -0500
committerKristian Høgsberg <krh@redhat.com>2008-11-23 19:10:23 -0500
commit14fcff77265bbdf9893925c993c10d52c178e566 (patch)
treec7745519075734e2bdad7c1ca42bdede908627a5 /wayland.c
parent548798266ebecea12bdd01869c0d09476e9ce81f (diff)
downloadwayland-14fcff77265bbdf9893925c993c10d52c178e566.tar.gz
wayland-14fcff77265bbdf9893925c993c10d52c178e566.tar.xz
wayland-14fcff77265bbdf9893925c993c10d52c178e566.zip
Generalize the object advertising mechanism.
Diffstat (limited to 'wayland.c')
-rw-r--r--wayland.c34
1 files changed, 33 insertions, 1 deletions
diff --git a/wayland.c b/wayland.c
index 15bb6bf..5da047e 100644
--- a/wayland.c
+++ b/wayland.c
@@ -57,6 +57,8 @@ struct wl_display {
struct wl_list client_list;
uint32_t client_id_range;
+ struct wl_list global_list;
+
int32_t pointer_x;
int32_t pointer_y;
};
@@ -425,6 +427,7 @@ static struct wl_client *
wl_client_create(struct wl_display *display, int fd)
{
struct wl_client *client;
+ struct wl_object_ref *ref;
client = malloc(sizeof *client);
if (client == NULL)
@@ -445,7 +448,14 @@ wl_client_create(struct wl_display *display, int fd)
sizeof display->client_id_range);
display->client_id_range += 256;
- advertise_object(client, &display->base);
+ ref = container_of(display->global_list.next,
+ struct wl_object_ref, link);
+ while (&ref->link != &display->global_list) {
+ advertise_object(client, ref->object);
+
+ ref = container_of(ref->link.next,
+ struct wl_object_ref, link);
+ }
wl_list_insert(display->client_list.prev, &client->link);
@@ -558,14 +568,36 @@ wl_display_create(void)
wl_hash_insert(&display->objects, &display->base);
wl_list_init(&display->surface_list);
wl_list_init(&display->client_list);
+ wl_list_init(&display->global_list);
wl_display_create_input_devices(display);
display->client_id_range = 256; /* Gah, arbitrary... */
+ if (wl_display_add_global(display, &display->base)) {
+ wl_event_loop_destroy(display->loop);
+ free(display);
+ return NULL;
+ }
+
return display;
}
+WL_EXPORT int
+wl_display_add_global(struct wl_display *display, struct wl_object *object)
+{
+ struct wl_object_ref *ref;
+
+ ref = malloc(sizeof *ref);
+ if (ref == NULL)
+ return -1;
+
+ ref->object = object;
+ wl_list_insert(display->global_list.prev, &ref->link);
+
+ return 0;
+}
+
static void
wl_display_send_event(struct wl_display *display, uint32_t *data, size_t size)
{