Repository navigation
Conversation
cropToMonitor() resized each monitor's crop to its logical size times QScreen::devicePixelRatio(). With fractional scaling on Wayland that value is the integer wl_output scale rounded up, e.g. 2 for a monitor at 1.25, so a correct 1920x1200 portal capture was stretched to 3072x1920 and then shrunk again on screen, which blurred it. The portal returns the whole desktop at a single scale (the highest monitor scale), and the reported DPR is never lower than a monitor's real scale. So only shrink a crop when the screen reports a lower scale than the image has (a lower-scale monitor that the portal enlarged). Otherwise keep the pixels and tag them with their real ratio instead of enlarging them. With monitors at different scales, the lower-scale monitor's capture is still soft: the portal (grim on wlroots compositors) has already enlarged it before flameshot gets the image.
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.
Fix blurry captures with fractional scaling on Wayland
Note
This PR was made with AI assistance (Claude Code). All test cases listed above were run and checked manually on real hardware.
Problem
On Wayland with fractional scaling, captures come out blurry.
cropToMonitor()resized each monitor's crop to its logical size timesQScreen::devicePixelRatio(). On Wayland, that value comes fromwl_output.scale, which can only be a whole number, so compositors round it up. A monitor at 1.25 reports a DPR of 2.Example: a 1920×1200 panel at scale 1.25 (1536×960 logical). The portal returns a correct 1920×1200 image, but flameshot saw 1.25 ≠ 2 and stretched it to 3072×1920 with smoothing. The capture window then shrank it back to 1.25 on screen, and saved files were the stretched 3072×1920 version.
Fix
On Linux, the portal returns the whole desktop at a single scale (the highest monitor scale), and the reported DPR is never lower than a monitor's real scale. So the crop is now handled like this:
Enlarging was the only step that caused blur, and it no longer happens. Windows and macOS code is unchanged.
Testing
Hyprland, Qt 6.12.0, xdg-desktop-portal-hyprland. Laptop panel 1920×1200 at 1.25, external 2560×1440 at 1. Debug build with
-DFLAMESHOT_DEBUG_CAPTURE=ON.Crop positions inside the combined 5120×1800 portal image were checked to be correct.
The laptop-only row was measured with both builds (
flameshot screen -n 0 -p …):The other "before" values follow from the same code path and logged DPRs.
Not tested: X11, GNOME/KDE portals, a whole-number scale of 2, and a fractional monitor next to a monitor at scale 2. In that last case both report DPR 2, so the crop keeps the portal's pixels without shrinking.
Known limitation
With monitors at different scales, the lower-scale monitor's capture is still soft. This happens before flameshot gets the image: xdg-desktop-portal-hyprland runs plain
grim, which builds the image at the highest scale and enlarges lower-scale monitors with smoothing. Flameshot can't recover the lost detail, and this PR doesn't change that case. Fixing it would mean capturing each monitor directly on wlroots-style compositors (e.g.grim -o <output>or the screen-capture protocol) instead of through the portal. I'm happy to discuss that separately if there's interest.