diff options
Diffstat (limited to 'sway/tree')
-rw-r--r-- | sway/tree/container.c | 4 | ||||
-rw-r--r-- | sway/tree/view.c | 23 |
2 files changed, 17 insertions, 10 deletions
diff --git a/sway/tree/container.c b/sway/tree/container.c index d8ad3bc0..1cf5c8e7 100644 --- a/sway/tree/container.c +++ b/sway/tree/container.c @@ -169,8 +169,8 @@ static struct sway_container *surface_at_view(struct sway_container *con, double return NULL; } struct sway_view *view = con->view; - double view_sx = lx - con->content_x + view->geometry.x; - double view_sy = ly - con->content_y + view->geometry.y; + double view_sx = lx - con->surface_x + view->geometry.x; + double view_sy = ly - con->surface_y + view->geometry.y; double _sx, _sy; struct wlr_surface *_surface = NULL; diff --git a/sway/tree/view.c b/sway/tree/view.c index 561c6ef1..9ccb2a31 100644 --- a/sway/tree/view.c +++ b/sway/tree/view.c @@ -673,15 +673,22 @@ void view_unmap(struct sway_view *view) { } void view_update_size(struct sway_view *view, int width, int height) { - if (!sway_assert(container_is_floating(view->container), - "Expected a floating container")) { - return; + struct sway_container *con = view->container; + + if (container_is_floating(con)) { + con->content_width = width; + con->content_height = height; + con->current.content_width = width; + con->current.content_height = height; + container_set_geometry_from_content(con); + } else { + con->surface_x = con->content_x + (con->content_width - width) / 2; + con->surface_y = con->content_y + (con->content_height - height) / 2; + con->surface_x = fmax(con->surface_x, con->content_x); + con->surface_y = fmax(con->surface_y, con->content_y); } - view->container->content_width = width; - view->container->content_height = height; - view->container->current.content_width = width; - view->container->current.content_height = height; - container_set_geometry_from_content(view->container); + con->surface_width = width; + con->surface_width = height; } static const struct sway_view_child_impl subsurface_impl; |