mirror of
https://gitlab.freedesktop.org/wayland/wayland.git
synced 2025-11-04 13:29:51 -05:00
Generalize the object advertising mechanism.
This commit is contained in:
parent
548798266e
commit
14fcff7726
2 changed files with 35 additions and 1 deletions
34
wayland.c
34
wayland.c
|
|
@ -57,6 +57,8 @@ struct wl_display {
|
||||||
struct wl_list client_list;
|
struct wl_list client_list;
|
||||||
uint32_t client_id_range;
|
uint32_t client_id_range;
|
||||||
|
|
||||||
|
struct wl_list global_list;
|
||||||
|
|
||||||
int32_t pointer_x;
|
int32_t pointer_x;
|
||||||
int32_t pointer_y;
|
int32_t pointer_y;
|
||||||
};
|
};
|
||||||
|
|
@ -425,6 +427,7 @@ static struct wl_client *
|
||||||
wl_client_create(struct wl_display *display, int fd)
|
wl_client_create(struct wl_display *display, int fd)
|
||||||
{
|
{
|
||||||
struct wl_client *client;
|
struct wl_client *client;
|
||||||
|
struct wl_object_ref *ref;
|
||||||
|
|
||||||
client = malloc(sizeof *client);
|
client = malloc(sizeof *client);
|
||||||
if (client == NULL)
|
if (client == NULL)
|
||||||
|
|
@ -445,7 +448,14 @@ wl_client_create(struct wl_display *display, int fd)
|
||||||
sizeof display->client_id_range);
|
sizeof display->client_id_range);
|
||||||
display->client_id_range += 256;
|
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);
|
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_hash_insert(&display->objects, &display->base);
|
||||||
wl_list_init(&display->surface_list);
|
wl_list_init(&display->surface_list);
|
||||||
wl_list_init(&display->client_list);
|
wl_list_init(&display->client_list);
|
||||||
|
wl_list_init(&display->global_list);
|
||||||
|
|
||||||
wl_display_create_input_devices(display);
|
wl_display_create_input_devices(display);
|
||||||
|
|
||||||
display->client_id_range = 256; /* Gah, arbitrary... */
|
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;
|
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
|
static void
|
||||||
wl_display_send_event(struct wl_display *display, uint32_t *data, size_t size)
|
wl_display_send_event(struct wl_display *display, uint32_t *data, size_t size)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -122,6 +122,8 @@ void wl_surface_iterator_destroy(struct wl_surface_iterator *iterator);
|
||||||
struct wl_object *
|
struct wl_object *
|
||||||
wl_input_device_create(struct wl_display *display,
|
wl_input_device_create(struct wl_display *display,
|
||||||
const char *path, uint32_t id);
|
const char *path, uint32_t id);
|
||||||
|
int
|
||||||
|
wl_display_add_global(struct wl_display *display, struct wl_object *object);
|
||||||
void
|
void
|
||||||
wl_display_post_relative_event(struct wl_display *display,
|
wl_display_post_relative_event(struct wl_display *display,
|
||||||
struct wl_object *source, int dx, int dy);
|
struct wl_object *source, int dx, int dy);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue