diff options
author | Ryan Dwyer <ryandwyer1@gmail.com> | 2018-08-18 15:10:06 +1000 |
---|---|---|
committer | Ryan Dwyer <ryandwyer1@gmail.com> | 2018-08-18 15:10:06 +1000 |
commit | b0a5f3a25f52bc1d48d771cb02820042006d8d9e (patch) | |
tree | e7a2e4c60e562589e3b9a54c6ce559a41dcf7534 /sway/desktop/xwayland.c | |
parent | Set current size when a floating xwayland view resizes (diff) | |
download | sway-b0a5f3a25f52bc1d48d771cb02820042006d8d9e.tar.gz sway-b0a5f3a25f52bc1d48d771cb02820042006d8d9e.tar.zst sway-b0a5f3a25f52bc1d48d771cb02820042006d8d9e.zip |
Store geometry in the view and handle any floating view resizing
Diffstat (limited to 'sway/desktop/xwayland.c')
-rw-r--r-- | sway/desktop/xwayland.c | 36 |
1 files changed, 27 insertions, 9 deletions
diff --git a/sway/desktop/xwayland.c b/sway/desktop/xwayland.c index e0c44b39..ce7235e4 100644 --- a/sway/desktop/xwayland.c +++ b/sway/desktop/xwayland.c | |||
@@ -277,6 +277,17 @@ static const struct sway_view_impl view_impl = { | |||
277 | .destroy = destroy, | 277 | .destroy = destroy, |
278 | }; | 278 | }; |
279 | 279 | ||
280 | static void get_geometry(struct sway_view *view, struct wlr_box *box) { | ||
281 | box->x = box->y = 0; | ||
282 | if (view->surface) { | ||
283 | box->width = view->surface->current.width; | ||
284 | box->height = view->surface->current.height; | ||
285 | } else { | ||
286 | box->width = 0; | ||
287 | box->height = 0; | ||
288 | } | ||
289 | } | ||
290 | |||
280 | static void handle_commit(struct wl_listener *listener, void *data) { | 291 | static void handle_commit(struct wl_listener *listener, void *data) { |
281 | struct sway_xwayland_view *xwayland_view = | 292 | struct sway_xwayland_view *xwayland_view = |
282 | wl_container_of(listener, xwayland_view, commit); | 293 | wl_container_of(listener, xwayland_view, commit); |
@@ -285,18 +296,25 @@ static void handle_commit(struct wl_listener *listener, void *data) { | |||
285 | struct wlr_surface_state *state = &xsurface->surface->current; | 296 | struct wlr_surface_state *state = &xsurface->surface->current; |
286 | 297 | ||
287 | if (view->swayc->instruction) { | 298 | if (view->swayc->instruction) { |
299 | get_geometry(view, &view->geometry); | ||
288 | transaction_notify_view_ready_by_size(view, | 300 | transaction_notify_view_ready_by_size(view, |
289 | state->width, state->height); | 301 | state->width, state->height); |
290 | } else if ((state->width != view->width || state->height != view->height) && | 302 | } else { |
303 | struct wlr_box new_geo; | ||
304 | get_geometry(view, &new_geo); | ||
305 | |||
306 | if ((new_geo.width != view->width || new_geo.height != view->height) && | ||
291 | container_is_floating(view->swayc)) { | 307 | container_is_floating(view->swayc)) { |
292 | // eg. The Firefox "Save As" dialog when downloading a file | 308 | // A floating view has unexpectedly sent a new size |
293 | // It maps at a small size then changes afterwards. | 309 | // eg. The Firefox "Save As" dialog when downloading a file |
294 | view->width = state->width; | 310 | desktop_damage_view(view); |
295 | view->height = state->height; | 311 | view_update_size(view, new_geo.width, new_geo.height); |
296 | view->swayc->current.view_width = state->width; | 312 | memcpy(&view->geometry, &new_geo, sizeof(struct wlr_box)); |
297 | view->swayc->current.view_height = state->height; | 313 | desktop_damage_view(view); |
298 | container_set_geometry_from_floating_view(view->swayc); | 314 | transaction_commit_dirty(); |
299 | transaction_commit_dirty(); | 315 | } else { |
316 | memcpy(&view->geometry, &new_geo, sizeof(struct wlr_box)); | ||
317 | } | ||
300 | } | 318 | } |
301 | 319 | ||
302 | view_damage_from(view); | 320 | view_damage_from(view); |