Repository navigation
fix(capture): accept COSMIC's combined portal screenshot for Zoom, Freeze, and PDF export - #443
Merged
Merged
Conversation
… Freeze COSMIC has no wlr-screencopy, so Zoom always takes the screenshot portal there. With more than one output, xdg-desktop-portal-cosmic resizes each output to its logical size and pastes it at its logical position, so the image is the desktop at density 1. The portal raster check accepted only the packed native layout and a uniform image at the highest output density (KWin), so on any scaled multi-monitor COSMIC layout it rejected the image and Zoom did nothing. Accept a uniform raster at density 1 in a COSMIC session. Other portals can return an area screenshot, and an area captured at a higher density can have the logical desktop's size, so density 1 stays rejected elsewhere. The highest-density rule needs no such limit: an area can only reach that size by covering the whole desktop. The session counts as COSMIC when XDG_CURRENT_DESKTOP starts with COSMIC, as COSMIC's session sets it. xdg-desktop-portal also picks its backend from those names in order. A COSMIC session configured with a different screenshot portal is not detected. The logical desktop and its density rules move to capture::desktop_raster so the PDF desktop background can share them. The half-pixel size tolerance is unchanged; a wider one would let packed captures and area screenshots pass as uniform ones. Freeze's portal fallback uses the same check as Zoom. Tests cover the layout from the report (two 3840x2160 outputs at 1.75 and 1.5, a 4754x1440 image), marked pixels, an area-sized image that only COSMIC may pass, packed captures and an area screenshot within a pixel of the uniform size, and the session detection. Fixes #442
…unds With transparent_background = "desktop", board PDF export captures the desktop and crops the active output for transparent pages. The crop required the packed layout, with each output at its native density. Desktops with several outputs at different scales return other shapes, so the export failed there: COSMIC's portal combines outputs at their logical size, and KWin's portal and grim draw the whole desktop at the highest output density. The request now lists every output and the densities this desktop may use, and the crop uses the same rules as Zoom and Freeze: a packed screenshot, a uniform one at the highest output density, or in a COSMIC session one at density 1. An image that fits the packed and uniform layouts with different crops is rejected. A uniform crop keeps the screenshot's own density; the PDF already scales the backdrop onto the page. grim truncates the scaled size. At fractional scales where that differs from the rounded size, the capture is still rejected. Tests cover a COSMIC image, the same image outside COSMIC, a highest-density image, and the ambiguous case. Refs #442
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.
Fixes #442.
Zoom did nothing on COSMIC with several scaled monitors: the "Requesting screen capture..." notice appeared, and the overlay came back unzoomed. The same layouts broke board PDF export with
transparent_background = "desktop".COSMIC has no
wlr-screencopy, so Zoom uses the screenshot portal there. With more than one output,xdg-desktop-portal-cosmicresizes each output to its logical size and pastes it at its logical position, so the image is the whole desktop at density 1. In the report, two 3840x2160 monitors at 1.75 and 1.5 gave a 4754x1440 image. Wayscriber accepted only two shapes: the packed layout, with each output at its native density (7680x2469 here), and the whole desktop at the highest output density, as KWin draws it. So it rejected the image with "Portal capture does not match an unambiguous active output layout". With one monitor, COSMIC returns native pixels, which is why Zoom works there.Changes:
XDG_CURRENT_DESKTOPstarts withCOSMIC, as COSMIC's session sets it.capture::desktop_raster, which Zoom, Freeze, and the PDF desktop background now share.Limitations:
ext-image-copy-capture, which COSMIC supports and Freeze already uses. That is a separate change.Validation:
cargo fmt --all -- --check,git diff --check, andcargo clippy --workspace --all-targets --all-features -- -D warningspassed../tools/lint-and-test.shpassed.