mirror of
https://gitlab.freedesktop.org/wayland/wayland.git
synced 2025-11-08 13:29:47 -05:00
Send client id range as an event.
This also makes the server send the event again when the client is about to exhaust its current client range.
This commit is contained in:
parent
fb6d68ddbe
commit
97079ad52c
4 changed files with 67 additions and 31 deletions
24
wayland.c
24
wayland.c
|
|
@ -44,6 +44,7 @@ struct wl_client {
|
|||
struct wl_display *display;
|
||||
struct wl_list object_list;
|
||||
struct wl_list link;
|
||||
uint32_t id_count;
|
||||
};
|
||||
|
||||
struct wl_display {
|
||||
|
|
@ -270,6 +271,15 @@ wl_client_connection_update(struct wl_connection *connection,
|
|||
return wl_event_source_fd_update(client->source, mask);
|
||||
}
|
||||
|
||||
static void
|
||||
wl_display_post_range(struct wl_display *display, struct wl_client *client)
|
||||
{
|
||||
wl_client_marshal(client, &client->display->base,
|
||||
WL_DISPLAY_RANGE, display->client_id_range);
|
||||
display->client_id_range += 256;
|
||||
client->id_count += 256;
|
||||
}
|
||||
|
||||
static struct wl_client *
|
||||
wl_client_create(struct wl_display *display, int fd)
|
||||
{
|
||||
|
|
@ -285,16 +295,13 @@ wl_client_create(struct wl_display *display, int fd)
|
|||
client->source = wl_event_loop_add_fd(display->loop, fd,
|
||||
WL_EVENT_READABLE,
|
||||
wl_client_connection_data, client);
|
||||
client->connection = wl_connection_create(fd,
|
||||
wl_client_connection_update,
|
||||
client);
|
||||
client->connection =
|
||||
wl_connection_create(fd, wl_client_connection_update, client);
|
||||
|
||||
wl_list_init(&client->object_list);
|
||||
wl_list_init(&client->link);
|
||||
|
||||
wl_connection_write(client->connection,
|
||||
&display->client_id_range,
|
||||
sizeof display->client_id_range);
|
||||
display->client_id_range += 256;
|
||||
wl_display_post_range(display, client);
|
||||
|
||||
ref = container_of(display->global_list.next,
|
||||
struct wl_object_ref, link);
|
||||
|
|
@ -353,6 +360,9 @@ wl_client_add_surface(struct wl_client *client,
|
|||
struct wl_display *display = client->display;
|
||||
struct wl_object_ref *ref;
|
||||
|
||||
if (client->id_count-- < 64)
|
||||
wl_display_post_range(display, client);
|
||||
|
||||
surface->base.id = id;
|
||||
surface->base.interface = &wl_surface_interface;
|
||||
surface->base.implementation = (void (**)(void)) implementation;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue