fix: Correct buffer scaling when using fractional scale protocol - #28
Merged
Merged
Conversation
This was allowing incorrectly-formatted Zig code to pass CI.
When wp_fractional_scale_manager_v1 is active, the compositor expects the buffer scale to be 1, with scaling handled via wp_viewport. Previously, we were mistakenly applying the integer output scale (e.g. 2x) to the buffer, resulting in a logical size mismatch and rendering errors on compositors like Niri.
sin-ack
force-pushed
the
fractional-scaling
branch
from
November 30, 2025 01:03
72472bb to
7e196e6
Compare
sin-ack
approved these changes
Nov 30, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
This PR fixes an issue where the application would render with incorrect dimensions on Wayland compositors using fractional scaling (in my case Niri).
The Problem
When the
wp_fractional_scale_manager_v1protocol is active, the application is responsible for rendering at the exact physical pixel size, and the Wayland surface buffer scale should be set to 1.Previously, the application was correctly using
wp_viewportfor sizing but was also setting thewl_surfacebuffer scale to the integer scale factor provided bywl_output(e.g., setting it to2on a 1.25x scale output).This "double scaling" caused the compositor to interpret the buffer as having half the intended logical size (e.g., 3840 physical pixels / scale 2 = 1920 logical pixels), resulting in mismatched window geometry and errors such as:
wp_viewport: source rectangle extends outside of the content areaThe Fix
The fix ensures that
wl_surface.setBufferScaleis explicitly set to1whenever thewp_fractional_scale_manager_v1is available and in use. The existing logic for integer-only scaling remains unchanged to prevent regressions on compositors that do not support fractional scaling.Verification