aboutsummaryrefslogtreecommitdiffstats
path: root/sway/desktop/xwayland.c
diff options
context:
space:
mode:
authorLibravatar Ryan Dwyer <ryandwyer1@gmail.com>2018-06-23 16:24:11 +1000
committerLibravatar Ryan Dwyer <ryandwyer1@gmail.com>2018-06-23 16:24:11 +1000
commit38398e2d77d57dc06b67ec88a54091c897915602 (patch)
treec80935807865fd96ab7d037070287d4dfaba1863 /sway/desktop/xwayland.c
parentPreserve buffers during transactions (diff)
downloadsway-38398e2d77d57dc06b67ec88a54091c897915602.tar.gz
sway-38398e2d77d57dc06b67ec88a54091c897915602.tar.zst
sway-38398e2d77d57dc06b67ec88a54091c897915602.zip
Implement atomic layout updates for tree operations
This implements atomic layout updates for when views map, reparent or unmap.
Diffstat (limited to 'sway/desktop/xwayland.c')
-rw-r--r--sway/desktop/xwayland.c45
1 files changed, 32 insertions, 13 deletions
diff --git a/sway/desktop/xwayland.c b/sway/desktop/xwayland.c
index 55917bf6..a1837420 100644
--- a/sway/desktop/xwayland.c
+++ b/sway/desktop/xwayland.c
@@ -218,19 +218,11 @@ static void _close(struct sway_view *view) {
218 wlr_xwayland_surface_close(view->wlr_xwayland_surface); 218 wlr_xwayland_surface_close(view->wlr_xwayland_surface);
219} 219}
220 220
221static void destroy(struct sway_view *view) { 221static void _free(struct sway_view *view) {
222 struct sway_xwayland_view *xwayland_view = xwayland_view_from_view(view); 222 struct sway_xwayland_view *xwayland_view = xwayland_view_from_view(view);
223 if (xwayland_view == NULL) { 223 if (xwayland_view == NULL) {
224 return; 224 return;
225 } 225 }
226 wl_list_remove(&xwayland_view->destroy.link);
227 wl_list_remove(&xwayland_view->request_configure.link);
228 wl_list_remove(&xwayland_view->request_fullscreen.link);
229 wl_list_remove(&xwayland_view->set_title.link);
230 wl_list_remove(&xwayland_view->set_class.link);
231 wl_list_remove(&xwayland_view->set_window_type.link);
232 wl_list_remove(&xwayland_view->map.link);
233 wl_list_remove(&xwayland_view->unmap.link);
234 free(xwayland_view); 226 free(xwayland_view);
235} 227}
236 228
@@ -242,7 +234,7 @@ static const struct sway_view_impl view_impl = {
242 .set_fullscreen = set_fullscreen, 234 .set_fullscreen = set_fullscreen,
243 .wants_floating = wants_floating, 235 .wants_floating = wants_floating,
244 .close = _close, 236 .close = _close,
245 .destroy = destroy, 237 .free = _free,
246}; 238};
247 239
248static void handle_commit(struct wl_listener *listener, void *data) { 240static void handle_commit(struct wl_listener *listener, void *data) {
@@ -254,7 +246,7 @@ static void handle_commit(struct wl_listener *listener, void *data) {
254 // Don't allow xwayland views to do resize or reposition themselves if 246 // Don't allow xwayland views to do resize or reposition themselves if
255 // they're involved in a transaction. Once the transaction has finished 247 // they're involved in a transaction. Once the transaction has finished
256 // they'll apply the next time a commit happens. 248 // they'll apply the next time a commit happens.
257 if (view->instructions->length) { 249 if (view->swayc && view->swayc->instructions->length) {
258 if (view->swayc && container_is_floating(view->swayc)) { 250 if (view->swayc && container_is_floating(view->swayc)) {
259 view_update_size(view, xsurface->width, xsurface->height); 251 view_update_size(view, xsurface->width, xsurface->height);
260 } else { 252 } else {
@@ -268,8 +260,17 @@ static void handle_commit(struct wl_listener *listener, void *data) {
268static void handle_unmap(struct wl_listener *listener, void *data) { 260static void handle_unmap(struct wl_listener *listener, void *data) {
269 struct sway_xwayland_view *xwayland_view = 261 struct sway_xwayland_view *xwayland_view =
270 wl_container_of(listener, xwayland_view, unmap); 262 wl_container_of(listener, xwayland_view, unmap);
263 struct sway_view *view = &xwayland_view->view;
264
265 if (!sway_assert(view->surface, "Cannot unmap unmapped view")) {
266 return;
267 }
268
269 struct sway_container *parent = view_unmap(view);
270 arrange_and_commit(parent);
271
271 wl_list_remove(&xwayland_view->commit.link); 272 wl_list_remove(&xwayland_view->commit.link);
272 view_unmap(&xwayland_view->view); 273 view->surface = NULL;
273} 274}
274 275
275static void handle_map(struct wl_listener *listener, void *data) { 276static void handle_map(struct wl_listener *listener, void *data) {
@@ -293,12 +294,30 @@ static void handle_map(struct wl_listener *listener, void *data) {
293 if (xsurface->fullscreen) { 294 if (xsurface->fullscreen) {
294 view_set_fullscreen(view, true); 295 view_set_fullscreen(view, true);
295 } 296 }
296 arrange_and_commit(view->swayc); 297 arrange_and_commit(view->swayc->parent);
297} 298}
298 299
299static void handle_destroy(struct wl_listener *listener, void *data) { 300static void handle_destroy(struct wl_listener *listener, void *data) {
300 struct sway_xwayland_view *xwayland_view = 301 struct sway_xwayland_view *xwayland_view =
301 wl_container_of(listener, xwayland_view, destroy); 302 wl_container_of(listener, xwayland_view, destroy);
303 struct sway_view *view = &xwayland_view->view;
304
305 if (view->surface) {
306 struct sway_container *parent = view_unmap(view);
307 arrange_and_commit(parent);
308
309 wl_list_remove(&xwayland_view->commit.link);
310 view->surface = NULL;
311 }
312
313 wl_list_remove(&xwayland_view->destroy.link);
314 wl_list_remove(&xwayland_view->request_configure.link);
315 wl_list_remove(&xwayland_view->request_fullscreen.link);
316 wl_list_remove(&xwayland_view->set_title.link);
317 wl_list_remove(&xwayland_view->set_class.link);
318 wl_list_remove(&xwayland_view->set_window_type.link);
319 wl_list_remove(&xwayland_view->map.link);
320 wl_list_remove(&xwayland_view->unmap.link);
302 view_destroy(&xwayland_view->view); 321 view_destroy(&xwayland_view->view);
303} 322}
304 323