diff options
Diffstat (limited to 'sway/desktop/xwayland.c')
-rw-r--r-- | sway/desktop/xwayland.c | 66 |
1 files changed, 51 insertions, 15 deletions
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 | ||
17 | static 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 | |||
23 | static 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 | |||
34 | static 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 | |||
17 | static void unmanaged_handle_destroy(struct wl_listener *listener, void *data) { | 42 | static 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 | ||
25 | static void create_unmanaged(struct wlr_xwayland_surface *xsurface) { | 55 | static 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 | ||
132 | static void handle_commit(struct wl_listener *listener, void *data) { | 168 | static void handle_commit(struct wl_listener *listener, void *data) { |