diff options
-rw-r--r-- | sway/desktop/xdg_shell.c | 11 | ||||
-rw-r--r-- | sway/desktop/xwayland.c | 23 | ||||
-rw-r--r-- | sway/tree/view.c | 14 |
3 files changed, 23 insertions, 25 deletions
diff --git a/sway/desktop/xdg_shell.c b/sway/desktop/xdg_shell.c index 667fb9e5..cbf16662 100644 --- a/sway/desktop/xdg_shell.c +++ b/sway/desktop/xdg_shell.c | |||
@@ -295,17 +295,20 @@ static void handle_commit(struct wl_listener *listener, void *data) { | |||
295 | if (new_size) { | 295 | if (new_size) { |
296 | // The view has unexpectedly sent a new size | 296 | // The view has unexpectedly sent a new size |
297 | desktop_damage_view(view); | 297 | desktop_damage_view(view); |
298 | view_update_size(view, new_geo.width, new_geo.height); | ||
299 | memcpy(&view->geometry, &new_geo, sizeof(struct wlr_box)); | 298 | memcpy(&view->geometry, &new_geo, sizeof(struct wlr_box)); |
299 | if (container_is_floating(view->container)) { | ||
300 | view_update_size(view, new_geo.width, new_geo.height); | ||
301 | transaction_commit_dirty(); | ||
302 | transaction_notify_view_ready_immediately(view); | ||
303 | } else { | ||
304 | view_center_surface(view); | ||
305 | } | ||
300 | desktop_damage_view(view); | 306 | desktop_damage_view(view); |
301 | transaction_commit_dirty(); | ||
302 | } | 307 | } |
303 | 308 | ||
304 | if (view->container->node.instruction) { | 309 | if (view->container->node.instruction) { |
305 | transaction_notify_view_ready_by_serial(view, | 310 | transaction_notify_view_ready_by_serial(view, |
306 | xdg_surface->configure_serial); | 311 | xdg_surface->configure_serial); |
307 | } else if (new_size) { | ||
308 | transaction_notify_view_ready_immediately(view); | ||
309 | } | 312 | } |
310 | 313 | ||
311 | view_damage_from(view); | 314 | view_damage_from(view); |
diff --git a/sway/desktop/xwayland.c b/sway/desktop/xwayland.c index e1a2e463..be9503e5 100644 --- a/sway/desktop/xwayland.c +++ b/sway/desktop/xwayland.c | |||
@@ -406,22 +406,25 @@ static void handle_commit(struct wl_listener *listener, void *data) { | |||
406 | } else { | 406 | } else { |
407 | struct wlr_box new_geo; | 407 | struct wlr_box new_geo; |
408 | get_geometry(view, &new_geo); | 408 | get_geometry(view, &new_geo); |
409 | bool new_size = new_geo.width != view->geometry.width || | ||
410 | new_geo.height != view->geometry.height || | ||
411 | new_geo.x != view->geometry.x || | ||
412 | new_geo.y != view->geometry.y; | ||
409 | 413 | ||
410 | if ((new_geo.width != view->geometry.width || | 414 | if (new_size) { |
411 | new_geo.height != view->geometry.height || | ||
412 | new_geo.x != view->geometry.x || | ||
413 | new_geo.y != view->geometry.y)) { | ||
414 | // The view has unexpectedly sent a new size | 415 | // The view has unexpectedly sent a new size |
415 | // eg. The Firefox "Save As" dialog when downloading a file | 416 | // eg. The Firefox "Save As" dialog when downloading a file |
416 | desktop_damage_view(view); | 417 | desktop_damage_view(view); |
417 | view_update_size(view, new_geo.width, new_geo.height); | ||
418 | memcpy(&view->geometry, &new_geo, sizeof(struct wlr_box)); | 418 | memcpy(&view->geometry, &new_geo, sizeof(struct wlr_box)); |
419 | desktop_damage_view(view); | 419 | if (container_is_floating(view->container)) { |
420 | transaction_commit_dirty(); | 420 | view_update_size(view, new_geo.width, new_geo.height); |
421 | transaction_notify_view_ready_by_geometry(view, | 421 | transaction_commit_dirty(); |
422 | transaction_notify_view_ready_by_geometry(view, | ||
422 | xsurface->x, xsurface->y, new_geo.width, new_geo.height); | 423 | xsurface->x, xsurface->y, new_geo.width, new_geo.height); |
423 | } else { | 424 | } else { |
424 | memcpy(&view->geometry, &new_geo, sizeof(struct wlr_box)); | 425 | view_center_surface(view); |
426 | } | ||
427 | desktop_damage_view(view); | ||
425 | } | 428 | } |
426 | } | 429 | } |
427 | 430 | ||
diff --git a/sway/tree/view.c b/sway/tree/view.c index f4ae8171..38417874 100644 --- a/sway/tree/view.c +++ b/sway/tree/view.c | |||
@@ -874,17 +874,9 @@ void view_unmap(struct sway_view *view) { | |||
874 | 874 | ||
875 | void view_update_size(struct sway_view *view, int width, int height) { | 875 | void view_update_size(struct sway_view *view, int width, int height) { |
876 | struct sway_container *con = view->container; | 876 | struct sway_container *con = view->container; |
877 | 877 | con->content_width = width; | |
878 | if (container_is_floating(con)) { | 878 | con->content_height = height; |
879 | con->content_width = width; | 879 | container_set_geometry_from_content(con); |
880 | con->content_height = height; | ||
881 | container_set_geometry_from_content(con); | ||
882 | } else { | ||
883 | con->surface_x = con->content_x + (con->content_width - width) / 2; | ||
884 | con->surface_y = con->content_y + (con->content_height - height) / 2; | ||
885 | con->surface_x = fmax(con->surface_x, con->content_x); | ||
886 | con->surface_y = fmax(con->surface_y, con->content_y); | ||
887 | } | ||
888 | } | 880 | } |
889 | 881 | ||
890 | void view_center_surface(struct sway_view *view) { | 882 | void view_center_surface(struct sway_view *view) { |