Centre fullscreen surfaces smaller than output

Sway renders fullscreen surfaces smaller than the output left-aligned.

From xdg-shell:

> If the surface doesn't cover the whole output, the compositor will
> position the surface in the center of the output and compensate with
> with border fill covering the rest of the output. The content of the
> border fill is undefined, but should be assumed to be in some way that
> attempts to blend into the surrounding area (e.g. solid black).

Render surfaces smaller than the output centred. Can be tested easily
with:

    weston-simple-egl -f -r

Fixes: https://github.com/swaywm/sway/issues/8845
This commit is contained in:
Hugo Osvaldo Barrera 2026-03-23 22:18:24 +01:00 committed by Simon Ser
parent ec7e0186e0
commit 909a2ddb5f

View file

@ -988,7 +988,7 @@ void view_center_and_clip_surface(struct sway_view *view) {
bool clip_to_geometry = true; bool clip_to_geometry = true;
if (container_is_floating(con)) { if (container_is_floating(con) || con->pending.fullscreen_mode != FULLSCREEN_NONE) {
// We always center the current coordinates rather than the next, as the // We always center the current coordinates rather than the next, as the
// geometry immediately affects the currently active rendering. // geometry immediately affects the currently active rendering.
int x = (int) fmax(0, (con->current.content_width - view->geometry.width) / 2); int x = (int) fmax(0, (con->current.content_width - view->geometry.width) / 2);