mirror of
https://github.com/swaywm/sway.git
synced 2024-12-29 16:36:26 +01:00
transaction: Move centering to view_center_surface
This will allow us to reuse it for centering elsewhere.
This commit is contained in:
parent
cf1e3be228
commit
50205ade9d
3 changed files with 12 additions and 12 deletions
|
@ -317,6 +317,7 @@ void view_map(struct sway_view *view, struct wlr_surface *wlr_surface,
|
||||||
void view_unmap(struct sway_view *view);
|
void view_unmap(struct sway_view *view);
|
||||||
|
|
||||||
void view_update_size(struct sway_view *view, int width, int height);
|
void view_update_size(struct sway_view *view, int width, int height);
|
||||||
|
void view_center_surface(struct sway_view *view);
|
||||||
|
|
||||||
void view_child_init(struct sway_view_child *child,
|
void view_child_init(struct sway_view_child *child,
|
||||||
const struct sway_view_child_impl *impl, struct sway_view *view,
|
const struct sway_view_child_impl *impl, struct sway_view *view,
|
||||||
|
|
|
@ -255,18 +255,7 @@ static void apply_container_state(struct sway_container *container,
|
||||||
// the container. This is important for fullscreen views which
|
// the container. This is important for fullscreen views which
|
||||||
// refuse to resize to the size of the output.
|
// refuse to resize to the size of the output.
|
||||||
if (view && view->surface) {
|
if (view && view->surface) {
|
||||||
if (view->geometry.width < container->current.content_width) {
|
view_center_surface(view);
|
||||||
container->surface_x = container->current.content_x +
|
|
||||||
(container->current.content_width - view->geometry.width) / 2;
|
|
||||||
} else {
|
|
||||||
container->surface_x = container->current.content_x;
|
|
||||||
}
|
|
||||||
if (view->geometry.height < container->current.content_height) {
|
|
||||||
container->surface_y = container->current.content_y +
|
|
||||||
(container->current.content_height - view->geometry.height) / 2;
|
|
||||||
} else {
|
|
||||||
container->surface_y = container->current.content_y;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!container->node.destroying) {
|
if (!container->node.destroying) {
|
||||||
|
|
|
@ -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 const struct sway_view_child_impl subsurface_impl;
|
||||||
|
|
||||||
static void subsurface_get_root_coords(struct sway_view_child *child,
|
static void subsurface_get_root_coords(struct sway_view_child *child,
|
||||||
|
|
Loading…
Reference in a new issue