0 | |
From: Kirill Primak <vyivel@eclair.cafe>
|
1 | |
Date: Mon, 9 Jan 2023 15:21:22 +0300
|
2 | |
Subject: xwayland/xwm: unpair even if surface is NULL
|
3 | |
|
4 | |
This is a backport of a922428c41dedea2c27f614963e7876926bba7fb
|
5 | |
which partially reverts 32daa43a454bcea1306ad0976fd4161ce8c7e86f.
|
6 | |
|
7 | |
Fixes: https://gitlab.freedesktop.org/wlroots/wlroots/-/issues/3561
|
8 | |
---
|
9 | |
xwayland/xwm.c | 44 ++++++++++++++++++++++++--------------------
|
10 | |
1 file changed, 24 insertions(+), 20 deletions(-)
|
11 | |
|
12 | |
diff --git a/xwayland/xwm.c b/xwayland/xwm.c
|
13 | |
index 3a3d35f..c6273fa 100644
|
14 | |
--- a/xwayland/xwm.c
|
15 | |
+++ b/xwayland/xwm.c
|
16 | |
@@ -384,11 +384,30 @@ static void xsurface_set_net_wm_state(struct wlr_xwayland_surface *xsurface) {
|
17 | |
i, property);
|
18 | |
}
|
19 | |
|
20 | |
+static void xsurface_unpair(struct wlr_xwayland_surface *surface,
|
21 | |
+ bool destroy_role_object) {
|
22 | |
+ if (surface->mapped) {
|
23 | |
+ wl_signal_emit_mutable(&surface->events.unmap, surface);
|
24 | |
+ surface->mapped = false;
|
25 | |
+ xwm_set_net_client_list(surface->xwm);
|
26 | |
+ }
|
27 | |
+
|
28 | |
+ // Make sure we're not on the unpaired surface list or we
|
29 | |
+ // could be assigned a surface during surface creation that
|
30 | |
+ // was mapped before this unmap request.
|
31 | |
+ wl_list_remove(&surface->unpaired_link);
|
32 | |
+ wl_list_init(&surface->unpaired_link);
|
33 | |
+ surface->surface_id = 0;
|
34 | |
+
|
35 | |
+ if (destroy_role_object && surface->surface != NULL) {
|
36 | |
+ wlr_surface_destroy_role_object(surface->surface);
|
37 | |
+ }
|
38 | |
+ surface->surface = NULL;
|
39 | |
+}
|
40 | |
+
|
41 | |
static void xwayland_surface_destroy(
|
42 | |
struct wlr_xwayland_surface *xsurface) {
|
43 | |
- if (xsurface->surface != NULL) {
|
44 | |
- wlr_surface_destroy_role_object(xsurface->surface);
|
45 | |
- }
|
46 | |
+ xsurface_unpair(xsurface, true);
|
47 | |
|
48 | |
wl_signal_emit_mutable(&xsurface->events.destroy, xsurface);
|
49 | |
|
50 | |
@@ -851,19 +870,7 @@ static void xwayland_surface_role_destroy(struct wlr_surface *wlr_surface) {
|
51 | |
assert(wlr_surface->role == &xwayland_surface_role);
|
52 | |
struct wlr_xwayland_surface *surface = wlr_surface->role_data;
|
53 | |
|
54 | |
- if (surface->mapped) {
|
55 | |
- wl_signal_emit_mutable(&surface->events.unmap, surface);
|
56 | |
- surface->mapped = false;
|
57 | |
- xwm_set_net_client_list(surface->xwm);
|
58 | |
- }
|
59 | |
-
|
60 | |
- // Make sure we're not on the unpaired surface list or we
|
61 | |
- // could be assigned a surface during surface creation that
|
62 | |
- // was mapped before this unmap request.
|
63 | |
- wl_list_remove(&surface->unpaired_link);
|
64 | |
- wl_list_init(&surface->unpaired_link);
|
65 | |
- surface->surface_id = 0;
|
66 | |
- surface->surface = NULL;
|
67 | |
+ xsurface_unpair(surface, false);
|
68 | |
}
|
69 | |
|
70 | |
static const struct wlr_surface_role xwayland_surface_role = {
|
71 | |
@@ -1077,10 +1084,7 @@ static void xwm_handle_unmap_notify(struct wlr_xwm *xwm,
|
72 | |
return;
|
73 | |
}
|
74 | |
|
75 | |
- if (xsurface->surface != NULL) {
|
76 | |
- wlr_surface_destroy_role_object(xsurface->surface);
|
77 | |
- }
|
78 | |
-
|
79 | |
+ xsurface_unpair(xsurface, true);
|
80 | |
xsurface_set_wm_state(xsurface, XCB_ICCCM_WM_STATE_WITHDRAWN);
|
81 | |
}
|
82 | |
|