aboutsummaryrefslogtreecommitdiffstats
path: root/sway/desktop
diff options
context:
space:
mode:
authorLibravatar emersion <contact@emersion.fr>2018-04-02 14:35:43 -0400
committerLibravatar emersion <contact@emersion.fr>2018-04-02 14:35:43 -0400
commit2f64ce86c47efb2ee4c0e3a3c2b31307d21404d9 (patch)
tree5342d958ece5bf77338d1b1015763e65073fc4f1 /sway/desktop
parentAddress review comments (diff)
downloadsway-2f64ce86c47efb2ee4c0e3a3c2b31307d21404d9.tar.gz
sway-2f64ce86c47efb2ee4c0e3a3c2b31307d21404d9.tar.zst
sway-2f64ce86c47efb2ee4c0e3a3c2b31307d21404d9.zip
Xwayland unmanaged views aren't views anymore
Diffstat (limited to 'sway/desktop')
-rw-r--r--sway/desktop/output.c14
-rw-r--r--sway/desktop/xwayland.c47
2 files changed, 45 insertions, 16 deletions
diff --git a/sway/desktop/output.c b/sway/desktop/output.c
index 6c97ac37..352f4af3 100644
--- a/sway/desktop/output.c
+++ b/sway/desktop/output.c
@@ -257,15 +257,15 @@ static void render_output(struct sway_output *output, struct timespec *when,
257 container_descendants(workspace, C_VIEW, render_view, &rdata); 257 container_descendants(workspace, C_VIEW, render_view, &rdata);
258 258
259 // render unmanaged views on top 259 // render unmanaged views on top
260 struct sway_view *view; 260 struct wl_list *unmanaged = &root_container.sway_root->xwayland_unmanaged;
261 wl_list_for_each(view, &root_container.sway_root->unmanaged_views, 261 struct sway_xwayland_unmanaged *sway_surface;
262 unmanaged_view_link) { 262 wl_list_for_each(sway_surface, unmanaged, link) {
263 if (view->type != SWAY_XWAYLAND_VIEW) { 263 struct wlr_xwayland_surface *xsurface =
264 sway_surface->wlr_xwayland_surface;
265 if (xsurface->surface == NULL) {
264 continue; 266 continue;
265 } 267 }
266 268
267 struct wlr_xwayland_surface *xsurface = view->wlr_xwayland_surface;
268
269 const struct wlr_box view_box = { 269 const struct wlr_box view_box = {
270 .x = xsurface->x, 270 .x = xsurface->x,
271 .y = xsurface->y, 271 .y = xsurface->y,
@@ -277,7 +277,7 @@ static void render_output(struct sway_output *output, struct timespec *when,
277 continue; 277 continue;
278 } 278 }
279 279
280 render_surface(view->surface, wlr_output, &output->last_frame, 280 render_surface(xsurface->surface, wlr_output, &output->last_frame,
281 view_box.x - output_box->x, view_box.y - output_box->y, 0); 281 view_box.x - output_box->x, view_box.y - output_box->y, 0);
282 } 282 }
283 283
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
17static 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
25static 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
17static bool assert_xwayland(struct sway_view *view) { 44static 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
133static void handle_request_configure(struct wl_listener *listener, void *data) { 155static 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