diff options
author | Kenny Levinsen <kl@kl.wtf> | 2021-02-08 01:03:44 +0100 |
---|---|---|
committer | Simon Ser <contact@emersion.fr> | 2021-02-09 09:37:10 +0100 |
commit | 50205ade9d7b3d4c014fce5364db329c29acfa86 (patch) | |
tree | 5bb5f51f6fd9caf58be821b534682afa51217c68 /sway/tree/view.c | |
parent | view: Save surface x and y on saved buffers (diff) | |
download | sway-50205ade9d7b3d4c014fce5364db329c29acfa86.tar.gz sway-50205ade9d7b3d4c014fce5364db329c29acfa86.tar.zst sway-50205ade9d7b3d4c014fce5364db329c29acfa86.zip |
transaction: Move centering to view_center_surface
This will allow us to reuse it for centering elsewhere.
Diffstat (limited to 'sway/tree/view.c')
-rw-r--r-- | sway/tree/view.c | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/sway/tree/view.c b/sway/tree/view.c index 3b1e67ea..f4ae8171 100644 --- a/sway/tree/view.c +++ b/sway/tree/view.c | |||
@@ -887,6 +887,16 @@ void view_update_size(struct sway_view *view, int width, int height) { | |||
887 | } | 887 | } |
888 | } | 888 | } |
889 | 889 | ||
890 | void view_center_surface(struct sway_view *view) { | ||
891 | struct sway_container *con = view->container; | ||
892 | // We always center the current coordinates rather than the next, as the | ||
893 | // geometry immediately affects the currently active rendering. | ||
894 | con->surface_x = fmax(con->current.content_x, con->current.content_x + | ||
895 | (con->current.content_width - view->geometry.width) / 2); | ||
896 | con->surface_y = fmax(con->current.content_y, con->current.content_y + | ||
897 | (con->current.content_height - view->geometry.height) / 2); | ||
898 | } | ||
899 | |||
890 | static const struct sway_view_child_impl subsurface_impl; | 900 | static const struct sway_view_child_impl subsurface_impl; |
891 | 901 | ||
892 | static void subsurface_get_root_coords(struct sway_view_child *child, | 902 | static void subsurface_get_root_coords(struct sway_view_child *child, |