summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLibravatar emersion <contact@emersion.fr>2018-04-05 17:08:30 -0400
committerLibravatar emersion <contact@emersion.fr>2018-04-05 17:08:30 -0400
commit7ce1038478de99f9328beaa289503826f107ac83 (patch)
treeb97c605d90e72993a4bded65c663d6d947f316bc
parentTrack damage of xdg-shell-v6 popups (diff)
downloadsway-7ce1038478de99f9328beaa289503826f107ac83.tar.gz
sway-7ce1038478de99f9328beaa289503826f107ac83.tar.zst
sway-7ce1038478de99f9328beaa289503826f107ac83.zip
Fix xwayland unmanaged surfaces
-rw-r--r--include/sway/tree/view.h3
-rw-r--r--sway/desktop/wl_shell.c1
-rw-r--r--sway/desktop/xdg_shell_v6.c1
-rw-r--r--sway/desktop/xwayland.c66
4 files changed, 56 insertions, 15 deletions
diff --git a/include/sway/tree/view.h b/include/sway/tree/view.h
index 2eca7a3e..e52bee66 100644
--- a/include/sway/tree/view.h
+++ b/include/sway/tree/view.h
@@ -87,6 +87,9 @@ struct sway_xwayland_unmanaged {
87 struct wlr_xwayland_surface *wlr_xwayland_surface; 87 struct wlr_xwayland_surface *wlr_xwayland_surface;
88 struct wl_list link; 88 struct wl_list link;
89 89
90 struct wl_listener commit;
91 struct wl_listener map;
92 struct wl_listener unmap;
90 struct wl_listener destroy; 93 struct wl_listener destroy;
91}; 94};
92 95
diff --git a/sway/desktop/wl_shell.c b/sway/desktop/wl_shell.c
index 5955fa9d..fff31da8 100644
--- a/sway/desktop/wl_shell.c
+++ b/sway/desktop/wl_shell.c
@@ -68,6 +68,7 @@ static const struct sway_view_impl view_impl = {
68 .get_prop = get_prop, 68 .get_prop = get_prop,
69 .configure = configure, 69 .configure = configure,
70 .close = _close, 70 .close = _close,
71 .destroy = destroy,
71}; 72};
72 73
73static void handle_commit(struct wl_listener *listener, void *data) { 74static void handle_commit(struct wl_listener *listener, void *data) {
diff --git a/sway/desktop/xdg_shell_v6.c b/sway/desktop/xdg_shell_v6.c
index baf07a1e..c66cc39a 100644
--- a/sway/desktop/xdg_shell_v6.c
+++ b/sway/desktop/xdg_shell_v6.c
@@ -147,6 +147,7 @@ static const struct sway_view_impl view_impl = {
147 .configure = configure, 147 .configure = configure,
148 .set_activated = set_activated, 148 .set_activated = set_activated,
149 .close = _close, 149 .close = _close,
150 .destroy = destroy,
150}; 151};
151 152
152static void handle_commit(struct wl_listener *listener, void *data) { 153static void handle_commit(struct wl_listener *listener, void *data) {
diff --git a/sway/desktop/xwayland.c b/sway/desktop/xwayland.c
index 384f4236..543c914e 100644
--- a/sway/desktop/xwayland.c
+++ b/sway/desktop/xwayland.c
@@ -14,30 +14,65 @@
14#include "sway/input/input-manager.h" 14#include "sway/input/input-manager.h"
15#include "log.h" 15#include "log.h"
16 16
17static void unmanaged_handle_commit(struct wl_listener *listener, void *data) {
18 struct sway_xwayland_unmanaged *surface =
19 wl_container_of(listener, surface, commit);
20 // TODO: damage tracking
21}
22
23static void unmanaged_handle_map(struct wl_listener *listener, void *data) {
24 struct sway_xwayland_unmanaged *surface =
25 wl_container_of(listener, surface, map);
26 struct wlr_xwayland_surface *xsurface = surface->wlr_xwayland_surface;
27 wl_list_insert(&root_container.sway_root->xwayland_unmanaged,
28 &surface->link);
29 wl_signal_add(&xsurface->surface->events.commit, &surface->commit);
30 surface->commit.notify = unmanaged_handle_commit;
31 // TODO: damage tracking
32}
33
34static void unmanaged_handle_unmap(struct wl_listener *listener, void *data) {
35 struct sway_xwayland_unmanaged *surface =
36 wl_container_of(listener, surface, unmap);
37 wl_list_remove(&surface->link);
38 wl_list_remove(&surface->commit.link);
39 // TODO: damage tracking
40}
41
17static void unmanaged_handle_destroy(struct wl_listener *listener, void *data) { 42static void unmanaged_handle_destroy(struct wl_listener *listener, void *data) {
18 struct sway_xwayland_unmanaged *sway_surface = 43 struct sway_xwayland_unmanaged *surface =
19 wl_container_of(listener, sway_surface, destroy); 44 wl_container_of(listener, surface, destroy);
20 wl_list_remove(&sway_surface->destroy.link); 45 struct wlr_xwayland_surface *xsurface = surface->wlr_xwayland_surface;
21 wl_list_remove(&sway_surface->link); 46 if (xsurface->mapped) {
22 free(sway_surface); 47 unmanaged_handle_unmap(&surface->unmap, xsurface);
48 }
49 wl_list_remove(&surface->map.link);
50 wl_list_remove(&surface->unmap.link);
51 wl_list_remove(&surface->destroy.link);
52 free(surface);
23} 53}
24 54
25static void create_unmanaged(struct wlr_xwayland_surface *xsurface) { 55static struct sway_xwayland_unmanaged *create_unmanaged(
26 struct sway_xwayland_unmanaged *sway_surface = 56 struct wlr_xwayland_surface *xsurface) {
57 struct sway_xwayland_unmanaged *surface =
27 calloc(1, sizeof(struct sway_xwayland_unmanaged)); 58 calloc(1, sizeof(struct sway_xwayland_unmanaged));
28 if (!sway_assert(sway_surface, "Failed to allocate surface")) { 59 if (surface == NULL) {
29 return; 60 wlr_log(L_ERROR, "Allocation failed");
61 return NULL;
30 } 62 }
31 63
32 sway_surface->wlr_xwayland_surface = xsurface; 64 surface->wlr_xwayland_surface = xsurface;
33 65
34 wl_signal_add(&xsurface->events.destroy, &sway_surface->destroy); 66 wl_signal_add(&xsurface->events.map, &surface->map);
35 sway_surface->destroy.notify = unmanaged_handle_destroy; 67 surface->map.notify = unmanaged_handle_map;
68 wl_signal_add(&xsurface->events.unmap, &surface->unmap);
69 surface->unmap.notify = unmanaged_handle_unmap;
70 wl_signal_add(&xsurface->events.destroy, &surface->destroy);
71 surface->destroy.notify = unmanaged_handle_destroy;
36 72
37 wl_list_insert(&root_container.sway_root->xwayland_unmanaged, 73 unmanaged_handle_map(&surface->map, xsurface);
38 &sway_surface->link);
39 74
40 // TODO: damage tracking 75 return surface;
41} 76}
42 77
43 78
@@ -127,6 +162,7 @@ static const struct sway_view_impl view_impl = {
127 .configure = configure, 162 .configure = configure,
128 .set_activated = set_activated, 163 .set_activated = set_activated,
129 .close = _close, 164 .close = _close,
165 .destroy = destroy,
130}; 166};
131 167
132static void handle_commit(struct wl_listener *listener, void *data) { 168static void handle_commit(struct wl_listener *listener, void *data) {