diff --git a/include/sway/tree/view.h b/include/sway/tree/view.h index 86bd981c3..4507a750d 100644 --- a/include/sway/tree/view.h +++ b/include/sway/tree/view.h @@ -316,7 +316,7 @@ void view_map(struct sway_view *view, struct wlr_surface *wlr_surface, void view_unmap(struct sway_view *view); -void view_update_size(struct sway_view *view); +void view_update_size(struct sway_view *view, int dx, int dy); void view_center_surface(struct sway_view *view); void view_child_init(struct sway_view_child *child, diff --git a/sway/desktop/output.c b/sway/desktop/output.c index 691a285d2..7f12b28a9 100644 --- a/sway/desktop/output.c +++ b/sway/desktop/output.c @@ -99,8 +99,8 @@ static bool get_surface_box(struct surface_iterator_data *data, int sw = surface->current.width; int sh = surface->current.height; - double _sx = sx + surface->sx; - double _sy = sy + surface->sy; + double _sx = sx; + double _sy = sy; rotate_child_position(&_sx, &_sy, sw, sh, data->width, data->height, data->rotation); diff --git a/sway/desktop/xdg_shell.c b/sway/desktop/xdg_shell.c index 14880dcd3..3e99240e5 100644 --- a/sway/desktop/xdg_shell.c +++ b/sway/desktop/xdg_shell.c @@ -284,20 +284,25 @@ static void handle_commit(struct wl_listener *listener, void *data) { wl_container_of(listener, xdg_shell_view, commit); struct sway_view *view = &xdg_shell_view->view; struct wlr_xdg_surface *xdg_surface = view->wlr_xdg_surface; + struct wlr_surface *surface = xdg_surface->surface; struct wlr_box new_geo; wlr_xdg_surface_get_geometry(xdg_surface, &new_geo); bool new_size = new_geo.width != view->geometry.width || new_geo.height != view->geometry.height || new_geo.x != view->geometry.x || - new_geo.y != view->geometry.y; + new_geo.y != view->geometry.y || + surface->sx != 0 || + surface->sy != 0; if (new_size) { // The view has unexpectedly sent a new size desktop_damage_view(view); memcpy(&view->geometry, &new_geo, sizeof(struct wlr_box)); if (container_is_floating(view->container)) { - view_update_size(view); + view_update_size(view, xdg_surface->surface->sx, xdg_surface->surface->sy); + xdg_surface->surface->sx = 0; + xdg_surface->surface->sy = 0; transaction_commit_dirty(); transaction_notify_view_ready_immediately(view); } else { diff --git a/sway/desktop/xwayland.c b/sway/desktop/xwayland.c index 4cd5f9d01..58f2a92e9 100644 --- a/sway/desktop/xwayland.c +++ b/sway/desktop/xwayland.c @@ -412,7 +412,7 @@ static void handle_commit(struct wl_listener *listener, void *data) { desktop_damage_view(view); memcpy(&view->geometry, &new_geo, sizeof(struct wlr_box)); if (container_is_floating(view->container)) { - view_update_size(view); + view_update_size(view, 0, 0); transaction_commit_dirty(); } else { view_center_surface(view); diff --git a/sway/tree/view.c b/sway/tree/view.c index e62fd018c..a255bbb36 100644 --- a/sway/tree/view.c +++ b/sway/tree/view.c @@ -872,10 +872,13 @@ void view_unmap(struct sway_view *view) { view->surface = NULL; } -void view_update_size(struct sway_view *view) { +void view_update_size(struct sway_view *view, int dx, int dy) { struct sway_container *con = view->container; + con->content_x += dx; + con->content_y += dy; con->content_width = view->geometry.width; con->content_height = view->geometry.height; + container_set_geometry_from_content(con); }