transaction: Move centering to view_center_surface

This will allow us to reuse it for centering elsewhere.
This commit is contained in:
Kenny Levinsen 2021-02-08 01:03:44 +01:00 committed by Simon Ser
parent cf1e3be228
commit 50205ade9d
3 changed files with 12 additions and 12 deletions

View file

@ -887,6 +887,16 @@ void view_update_size(struct sway_view *view, int width, int height) {
}
}
void view_center_surface(struct sway_view *view) {
struct sway_container *con = view->container;
// We always center the current coordinates rather than the next, as the
// geometry immediately affects the currently active rendering.
con->surface_x = fmax(con->current.content_x, con->current.content_x +
(con->current.content_width - view->geometry.width) / 2);
con->surface_y = fmax(con->current.content_y, con->current.content_y +
(con->current.content_height - view->geometry.height) / 2);
}
static const struct sway_view_child_impl subsurface_impl;
static void subsurface_get_root_coords(struct sway_view_child *child,