diff options
-rw-r--r-- | include/sway/tree/view.h | 1 | ||||
-rw-r--r-- | sway/desktop/transaction.c | 13 | ||||
-rw-r--r-- | sway/tree/view.c | 10 |
3 files changed, 12 insertions, 12 deletions
diff --git a/include/sway/tree/view.h b/include/sway/tree/view.h index e071e6c9..18dc2019 100644 --- a/include/sway/tree/view.h +++ b/include/sway/tree/view.h | |||
@@ -317,6 +317,7 @@ void view_map(struct sway_view *view, struct wlr_surface *wlr_surface, | |||
317 | void view_unmap(struct sway_view *view); | 317 | void view_unmap(struct sway_view *view); |
318 | 318 | ||
319 | void view_update_size(struct sway_view *view, int width, int height); | 319 | void view_update_size(struct sway_view *view, int width, int height); |
320 | void view_center_surface(struct sway_view *view); | ||
320 | 321 | ||
321 | void view_child_init(struct sway_view_child *child, | 322 | void view_child_init(struct sway_view_child *child, |
322 | const struct sway_view_child_impl *impl, struct sway_view *view, | 323 | const struct sway_view_child_impl *impl, struct sway_view *view, |
diff --git a/sway/desktop/transaction.c b/sway/desktop/transaction.c index 2d71ad2b..ead662f9 100644 --- a/sway/desktop/transaction.c +++ b/sway/desktop/transaction.c | |||
@@ -255,18 +255,7 @@ static void apply_container_state(struct sway_container *container, | |||
255 | // the container. This is important for fullscreen views which | 255 | // the container. This is important for fullscreen views which |
256 | // refuse to resize to the size of the output. | 256 | // refuse to resize to the size of the output. |
257 | if (view && view->surface) { | 257 | if (view && view->surface) { |
258 | if (view->geometry.width < container->current.content_width) { | 258 | view_center_surface(view); |
259 | container->surface_x = container->current.content_x + | ||
260 | (container->current.content_width - view->geometry.width) / 2; | ||
261 | } else { | ||
262 | container->surface_x = container->current.content_x; | ||
263 | } | ||
264 | if (view->geometry.height < container->current.content_height) { | ||
265 | container->surface_y = container->current.content_y + | ||
266 | (container->current.content_height - view->geometry.height) / 2; | ||
267 | } else { | ||
268 | container->surface_y = container->current.content_y; | ||
269 | } | ||
270 | } | 259 | } |
271 | 260 | ||
272 | if (!container->node.destroying) { | 261 | if (!container->node.destroying) { |
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, |