229c8506a45cfcdc22bc52f7da6dc525ef57657e
[AGL/meta-agl.git] / meta-agl-core / recipes-graphics / wayland / weston / 0002-libweston-desktop-introduce-weston_desktop_client_de.patch
1 From f53c05d3c2c19c139c52e9bd621c2654dd3dac69 Mon Sep 17 00:00:00 2001
2 From: Pekka Paalanen <pekka.paalanen@collabora.com>
3 Upstream-Status: Backport
4 Date: Fri, 14 May 2021 16:04:45 +0300
5 Subject: [PATCH] libweston-desktop: introduce weston_desktop_client_destroy()
6
7 This new function is callable explicitly, unlike the old function that
8 used to have the same name.
9
10 This will be needed when tearing down what
11 weston_desktop_xwayland_init() puts up.
12
13 Since calling weston_desktop_client_destroy() for an external client
14 (one that has a wl_resource for this) is a bug, add asserts to prevent
15 it. This will only be needed for the internal client: XWM.
16
17 Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
18 ---
19  libweston-desktop/client.c   | 21 +++++++++++++++++----
20  libweston-desktop/internal.h |  2 ++
21  2 files changed, 19 insertions(+), 4 deletions(-)
22
23 diff --git a/libweston-desktop/client.c b/libweston-desktop/client.c
24 index ba7bfbc46..44718e2db 100644
25 --- a/libweston-desktop/client.c
26 +++ b/libweston-desktop/client.c
27 @@ -24,6 +24,7 @@
28  #include "config.h"
29  
30  #include <wayland-server.h>
31 +#include <assert.h>
32  
33  #include <libweston/libweston.h>
34  #include <libweston/zalloc.h>
35 @@ -48,14 +49,14 @@ weston_desktop_client_add_destroy_listener(struct weston_desktop_client *client,
36         wl_signal_add(&client->destroy_signal, listener);
37  }
38  
39 -static void
40 -weston_desktop_client_handle_destroy(struct wl_resource *resource)
41 +void
42 +weston_desktop_client_destroy(struct weston_desktop_client *client)
43  {
44 -       struct weston_desktop_client *client =
45 -               wl_resource_get_user_data(resource);
46         struct wl_list *list = &client->surface_list;
47         struct wl_list *link, *tmp;
48  
49 +       assert(client->resource == NULL);
50 +
51         wl_signal_emit(&client->destroy_signal, client);
52  
53         for (link = list->next, tmp = link->next;
54 @@ -71,6 +72,18 @@ weston_desktop_client_handle_destroy(struct wl_resource *resource)
55         free(client);
56  }
57  
58 +static void
59 +weston_desktop_client_handle_destroy(struct wl_resource *resource)
60 +{
61 +       struct weston_desktop_client *client =
62 +               wl_resource_get_user_data(resource);
63 +
64 +       assert(client->resource == resource);
65 +       client->resource = NULL;
66 +
67 +       weston_desktop_client_destroy(client);
68 +}
69 +
70  static int
71  weston_desktop_client_ping_timeout(void *user_data)
72  {
73 diff --git a/libweston-desktop/internal.h b/libweston-desktop/internal.h
74 index e4ab2701b..7a815bd87 100644
75 --- a/libweston-desktop/internal.h
76 +++ b/libweston-desktop/internal.h
77 @@ -134,6 +134,8 @@ weston_desktop_client_create(struct weston_desktop *desktop,
78                              const struct wl_interface *interface,
79                              const void *implementation, uint32_t version,
80                              uint32_t id);
81 +void
82 +weston_desktop_client_destroy(struct weston_desktop_client *client);
83  
84  void
85  weston_desktop_client_add_destroy_listener(struct weston_desktop_client *client,
86 -- 
87 GitLab
88