diff options
Diffstat (limited to 'sway/desktop/xwayland.c')
-rw-r--r-- | sway/desktop/xwayland.c | 47 |
1 files changed, 38 insertions, 9 deletions
diff --git a/sway/desktop/xwayland.c b/sway/desktop/xwayland.c index 39076fab..bfef68cf 100644 --- a/sway/desktop/xwayland.c +++ b/sway/desktop/xwayland.c | |||
@@ -14,6 +14,33 @@ | |||
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_destroy(struct wl_listener *listener, void *data) { | ||
18 | struct sway_xwayland_unmanaged *sway_surface = | ||
19 | wl_container_of(listener, sway_surface, destroy); | ||
20 | wl_list_remove(&sway_surface->destroy.link); | ||
21 | wl_list_remove(&sway_surface->link); | ||
22 | free(sway_surface); | ||
23 | } | ||
24 | |||
25 | static void create_unmanaged(struct wlr_xwayland_surface *xsurface) { | ||
26 | struct sway_xwayland_unmanaged *sway_surface = | ||
27 | calloc(1, sizeof(struct sway_xwayland_unmanaged)); | ||
28 | if (!sway_assert(sway_surface, "Failed to allocate surface")) { | ||
29 | return; | ||
30 | } | ||
31 | |||
32 | sway_surface->wlr_xwayland_surface = xsurface; | ||
33 | |||
34 | wl_signal_add(&xsurface->events.destroy, &sway_surface->destroy); | ||
35 | sway_surface->destroy.notify = unmanaged_handle_destroy; | ||
36 | |||
37 | wl_list_insert(&root_container.sway_root->xwayland_unmanaged, | ||
38 | &sway_surface->link); | ||
39 | |||
40 | // TODO: damage tracking | ||
41 | } | ||
42 | |||
43 | |||
17 | static bool assert_xwayland(struct sway_view *view) { | 44 | static bool assert_xwayland(struct sway_view *view) { |
18 | return sway_assert(view->type == SWAY_XWAYLAND_VIEW, | 45 | return sway_assert(view->type == SWAY_XWAYLAND_VIEW, |
19 | "Expected xwayland view!"); | 46 | "Expected xwayland view!"); |
@@ -121,13 +148,8 @@ static void handle_map(struct wl_listener *listener, void *data) { | |||
121 | struct sway_view *view = sway_surface->view; | 148 | struct sway_view *view = sway_surface->view; |
122 | 149 | ||
123 | // put it back into the tree | 150 | // put it back into the tree |
124 | if (wlr_xwayland_surface_is_unmanaged(xsurface) || | 151 | wlr_xwayland_surface_set_maximized(xsurface, true); |
125 | xsurface->override_redirect) { | 152 | view_map(view, xsurface->surface); |
126 | view_map_unmanaged(view, xsurface->surface); | ||
127 | } else { | ||
128 | wlr_xwayland_surface_set_maximized(xsurface, true); | ||
129 | view_map(view, xsurface->surface); | ||
130 | } | ||
131 | } | 153 | } |
132 | 154 | ||
133 | static void handle_request_configure(struct wl_listener *listener, void *data) { | 155 | static void handle_request_configure(struct wl_listener *listener, void *data) { |
@@ -147,12 +169,19 @@ void handle_xwayland_surface(struct wl_listener *listener, void *data) { | |||
147 | listener, server, xwayland_surface); | 169 | listener, server, xwayland_surface); |
148 | struct wlr_xwayland_surface *xsurface = data; | 170 | struct wlr_xwayland_surface *xsurface = data; |
149 | 171 | ||
172 | if (wlr_xwayland_surface_is_unmanaged(xsurface) || | ||
173 | xsurface->override_redirect) { | ||
174 | wlr_log(L_DEBUG, "New xwayland unmanaged surface"); | ||
175 | create_unmanaged(xsurface); | ||
176 | return; | ||
177 | } | ||
178 | |||
150 | wlr_log(L_DEBUG, "New xwayland surface title='%s' class='%s'", | 179 | wlr_log(L_DEBUG, "New xwayland surface title='%s' class='%s'", |
151 | xsurface->title, xsurface->class); | 180 | xsurface->title, xsurface->class); |
152 | 181 | ||
153 | struct sway_xwayland_surface *sway_surface = | 182 | struct sway_xwayland_surface *sway_surface = |
154 | calloc(1, sizeof(struct sway_xwayland_surface)); | 183 | calloc(1, sizeof(struct sway_xwayland_surface)); |
155 | if (!sway_assert(sway_surface, "Failed to allocate surface!")) { | 184 | if (!sway_assert(sway_surface, "Failed to allocate surface")) { |
156 | return; | 185 | return; |
157 | } | 186 | } |
158 | 187 | ||