libweston-desktop: introduce weston_desktop_client_destroy()
This new function is callable explicitly, unlike the old function that used to have the same name. This will be needed when tearing down what weston_desktop_xwayland_init() puts up. Since calling weston_desktop_client_destroy() for an external client (one that has a wl_resource for this) is a bug, add asserts to prevent it. This will only be needed for the internal client: XWM. Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
This commit is contained in:
@@ -24,6 +24,7 @@
|
|||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
#include <wayland-server.h>
|
#include <wayland-server.h>
|
||||||
|
#include <assert.h>
|
||||||
|
|
||||||
#include <libweston/libweston.h>
|
#include <libweston/libweston.h>
|
||||||
#include <libweston/zalloc.h>
|
#include <libweston/zalloc.h>
|
||||||
@@ -48,14 +49,14 @@ weston_desktop_client_add_destroy_listener(struct weston_desktop_client *client,
|
|||||||
wl_signal_add(&client->destroy_signal, listener);
|
wl_signal_add(&client->destroy_signal, listener);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
void
|
||||||
weston_desktop_client_handle_destroy(struct wl_resource *resource)
|
weston_desktop_client_destroy(struct weston_desktop_client *client)
|
||||||
{
|
{
|
||||||
struct weston_desktop_client *client =
|
|
||||||
wl_resource_get_user_data(resource);
|
|
||||||
struct wl_list *list = &client->surface_list;
|
struct wl_list *list = &client->surface_list;
|
||||||
struct wl_list *link, *tmp;
|
struct wl_list *link, *tmp;
|
||||||
|
|
||||||
|
assert(client->resource == NULL);
|
||||||
|
|
||||||
wl_signal_emit(&client->destroy_signal, client);
|
wl_signal_emit(&client->destroy_signal, client);
|
||||||
|
|
||||||
for (link = list->next, tmp = link->next;
|
for (link = list->next, tmp = link->next;
|
||||||
@@ -71,6 +72,18 @@ weston_desktop_client_handle_destroy(struct wl_resource *resource)
|
|||||||
free(client);
|
free(client);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
weston_desktop_client_handle_destroy(struct wl_resource *resource)
|
||||||
|
{
|
||||||
|
struct weston_desktop_client *client =
|
||||||
|
wl_resource_get_user_data(resource);
|
||||||
|
|
||||||
|
assert(client->resource == resource);
|
||||||
|
client->resource = NULL;
|
||||||
|
|
||||||
|
weston_desktop_client_destroy(client);
|
||||||
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
weston_desktop_client_ping_timeout(void *user_data)
|
weston_desktop_client_ping_timeout(void *user_data)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -134,6 +134,8 @@ weston_desktop_client_create(struct weston_desktop *desktop,
|
|||||||
const struct wl_interface *interface,
|
const struct wl_interface *interface,
|
||||||
const void *implementation, uint32_t version,
|
const void *implementation, uint32_t version,
|
||||||
uint32_t id);
|
uint32_t id);
|
||||||
|
void
|
||||||
|
weston_desktop_client_destroy(struct weston_desktop_client *client);
|
||||||
|
|
||||||
void
|
void
|
||||||
weston_desktop_client_add_destroy_listener(struct weston_desktop_client *client,
|
weston_desktop_client_add_destroy_listener(struct weston_desktop_client *client,
|
||||||
|
|||||||
Reference in New Issue
Block a user