aboutsummaryrefslogtreecommitdiffstats
path: root/sway/desktop/xdg_shell.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/xdg_shell.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/xdg_shell.c')
-rw-r--r--sway/desktop/xdg_shell.c35
1 files changed, 26 insertions, 9 deletions
diff --git a/sway/desktop/xdg_shell.c b/sway/desktop/xdg_shell.c
index d22c967c..ab35b98f 100644
--- a/sway/desktop/xdg_shell.c
+++ b/sway/desktop/xdg_shell.c
@@ -143,16 +143,12 @@ static void _close(struct sway_view *view) {
143 } 143 }
144} 144}
145 145
146static void destroy(struct sway_view *view) { 146static void _free(struct sway_view *view) {
147 struct sway_xdg_shell_view *xdg_shell_view = 147 struct sway_xdg_shell_view *xdg_shell_view =
148 xdg_shell_view_from_view(view); 148 xdg_shell_view_from_view(view);
149 if (xdg_shell_view == NULL) { 149 if (xdg_shell_view == NULL) {
150 return; 150 return;
151 } 151 }
152 wl_list_remove(&xdg_shell_view->destroy.link);
153 wl_list_remove(&xdg_shell_view->map.link);
154 wl_list_remove(&xdg_shell_view->unmap.link);
155 wl_list_remove(&xdg_shell_view->request_fullscreen.link);
156 free(xdg_shell_view); 152 free(xdg_shell_view);
157} 153}
158 154
@@ -164,7 +160,7 @@ static const struct sway_view_impl view_impl = {
164 .wants_floating = wants_floating, 160 .wants_floating = wants_floating,
165 .for_each_surface = for_each_surface, 161 .for_each_surface = for_each_surface,
166 .close = _close, 162 .close = _close,
167 .destroy = destroy, 163 .free = _free,
168}; 164};
169 165
170static void handle_commit(struct wl_listener *listener, void *data) { 166static void handle_commit(struct wl_listener *listener, void *data) {
@@ -173,7 +169,11 @@ static void handle_commit(struct wl_listener *listener, void *data) {
173 struct sway_view *view = &xdg_shell_view->view; 169 struct sway_view *view = &xdg_shell_view->view;
174 struct wlr_xdg_surface *xdg_surface = view->wlr_xdg_surface; 170 struct wlr_xdg_surface *xdg_surface = view->wlr_xdg_surface;
175 171
176 if (view->instructions->length) { 172 if (!view->swayc) {
173 return;
174 }
175
176 if (view->swayc->instructions->length) {
177 transaction_notify_view_ready(view, xdg_surface->configure_serial); 177 transaction_notify_view_ready(view, xdg_surface->configure_serial);
178 } 178 }
179 179
@@ -191,11 +191,18 @@ static void handle_new_popup(struct wl_listener *listener, void *data) {
191static void handle_unmap(struct wl_listener *listener, void *data) { 191static void handle_unmap(struct wl_listener *listener, void *data) {
192 struct sway_xdg_shell_view *xdg_shell_view = 192 struct sway_xdg_shell_view *xdg_shell_view =
193 wl_container_of(listener, xdg_shell_view, unmap); 193 wl_container_of(listener, xdg_shell_view, unmap);
194 struct sway_view *view = &xdg_shell_view->view;
195
196 if (!sway_assert(view->surface, "Cannot unmap unmapped view")) {
197 return;
198 }
194 199
195 view_unmap(&xdg_shell_view->view); 200 struct sway_container *parent = view_unmap(view);
201 arrange_and_commit(parent);
196 202
197 wl_list_remove(&xdg_shell_view->commit.link); 203 wl_list_remove(&xdg_shell_view->commit.link);
198 wl_list_remove(&xdg_shell_view->new_popup.link); 204 wl_list_remove(&xdg_shell_view->new_popup.link);
205 view->surface = NULL;
199} 206}
200 207
201static void handle_map(struct wl_listener *listener, void *data) { 208static void handle_map(struct wl_listener *listener, void *data) {
@@ -230,7 +237,17 @@ static void handle_map(struct wl_listener *listener, void *data) {
230static void handle_destroy(struct wl_listener *listener, void *data) { 237static void handle_destroy(struct wl_listener *listener, void *data) {
231 struct sway_xdg_shell_view *xdg_shell_view = 238 struct sway_xdg_shell_view *xdg_shell_view =
232 wl_container_of(listener, xdg_shell_view, destroy); 239 wl_container_of(listener, xdg_shell_view, destroy);
233 view_destroy(&xdg_shell_view->view); 240 struct sway_view *view = &xdg_shell_view->view;
241 if (!sway_assert(view->swayc == NULL || view->swayc->destroying,
242 "Tried to destroy a mapped view")) {
243 return;
244 }
245 wl_list_remove(&xdg_shell_view->destroy.link);
246 wl_list_remove(&xdg_shell_view->map.link);
247 wl_list_remove(&xdg_shell_view->unmap.link);
248 wl_list_remove(&xdg_shell_view->request_fullscreen.link);
249 view->wlr_xdg_surface = NULL;
250 view_destroy(view);
234} 251}
235 252
236static void handle_request_fullscreen(struct wl_listener *listener, void *data) { 253static void handle_request_fullscreen(struct wl_listener *listener, void *data) {