mirror of
https://gitlab.freedesktop.org/wayland/wayland.git
synced 2025-11-10 13:29:48 -05:00
server: Add client destroy signal
This commit is contained in:
parent
18a770c80d
commit
fa5f7b1191
4 changed files with 121 additions and 2 deletions
|
|
@ -63,6 +63,7 @@ struct wl_client {
|
|||
uint32_t mask;
|
||||
struct wl_list link;
|
||||
struct wl_map objects;
|
||||
struct wl_signal destroy_signal;
|
||||
struct ucred ucred;
|
||||
int error;
|
||||
};
|
||||
|
|
@ -336,6 +337,7 @@ wl_client_create(struct wl_display *display, int fd)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
wl_signal_init(&client->destroy_signal);
|
||||
bind_display(client, display, 1, 1);
|
||||
|
||||
wl_list_insert(display->client_list.prev, &client->link);
|
||||
|
|
@ -409,6 +411,20 @@ wl_resource_destroy(struct wl_resource *resource)
|
|||
}
|
||||
}
|
||||
|
||||
WL_EXPORT void
|
||||
wl_client_add_destroy_listener(struct wl_client *client,
|
||||
struct wl_listener *listener)
|
||||
{
|
||||
wl_signal_add(&client->destroy_signal, listener);
|
||||
}
|
||||
|
||||
WL_EXPORT struct wl_listener *
|
||||
wl_client_get_destroy_listener(struct wl_client *client,
|
||||
wl_notify_func_t notify)
|
||||
{
|
||||
return wl_signal_get(&client->destroy_signal, notify);
|
||||
}
|
||||
|
||||
WL_EXPORT void
|
||||
wl_client_destroy(struct wl_client *client)
|
||||
{
|
||||
|
|
@ -416,6 +432,8 @@ wl_client_destroy(struct wl_client *client)
|
|||
|
||||
printf("disconnect from client %p\n", client);
|
||||
|
||||
wl_signal_emit(&client->destroy_signal, client);
|
||||
|
||||
wl_client_flush(client);
|
||||
wl_map_for_each(&client->objects, destroy_resource, &serial);
|
||||
wl_map_release(&client->objects);
|
||||
|
|
|
|||
|
|
@ -75,6 +75,8 @@ int wl_event_loop_get_fd(struct wl_event_loop *loop);
|
|||
struct wl_client;
|
||||
struct wl_display;
|
||||
struct wl_input_device;
|
||||
struct wl_listener;
|
||||
typedef void (*wl_notify_func_t)(struct wl_listener *listener, void *data);
|
||||
|
||||
struct wl_display *wl_display_create(void);
|
||||
void wl_display_destroy(struct wl_display *display);
|
||||
|
|
@ -106,6 +108,11 @@ void wl_client_flush(struct wl_client *client);
|
|||
void wl_client_get_credentials(struct wl_client *client,
|
||||
pid_t *pid, uid_t *uid, gid_t *gid);
|
||||
|
||||
void wl_client_add_destroy_listener(struct wl_client *client,
|
||||
struct wl_listener *listener);
|
||||
struct wl_listener *wl_client_get_destroy_listener(struct wl_client *client,
|
||||
wl_notify_func_t notify);
|
||||
|
||||
struct wl_resource *
|
||||
wl_client_add_object(struct wl_client *client,
|
||||
const struct wl_interface *interface,
|
||||
|
|
@ -117,7 +124,7 @@ wl_client_new_object(struct wl_client *client,
|
|||
|
||||
struct wl_listener {
|
||||
struct wl_list link;
|
||||
void (*notify)(struct wl_listener *listener, void *data);
|
||||
wl_notify_func_t notify;
|
||||
};
|
||||
|
||||
struct wl_signal {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue