Skip to content

fix(capture): accept COSMIC's combined portal screenshot for Zoom, Freeze, and PDF export - #443

Merged
devmobasa merged 2 commits into
mainfrom
fix/cosmic-portal-zoom
Nov 13, 2026
Merged

devmobasa merged 2 commits into
mainfrom
fix/cosmic-portal-zoom

Conversation

@devmobasa

Copy link
Copy Markdown
Owner

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-cosmic resizes 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:

  • Zoom and Freeze accept a whole-desktop image at density 1 in a COSMIC session. The session counts as COSMIC when XDG_CURRENT_DESKTOP starts with COSMIC, as COSMIC's session sets it.
  • Density 1 stays rejected elsewhere. Another portal can return an area screenshot, and an area captured at density 2 can have the logical desktop's size. The highest-density shape needs no such limit, because an area reaches that size only by covering the whole desktop.
  • The logical desktop and its density rules move to capture::desktop_raster, which Zoom, Freeze, and the PDF desktop background now share.
  • The PDF desktop background uses the same rules. It used to require the packed layout, so it also rejected KWin's highest-density image and grim's captures of mixed-scale layouts. A uniform crop keeps the image's own density, and the PDF scales it onto the page. An image that fits the packed and uniform layouts with different crops is rejected.

Limitations:

  • On a scaled COSMIC monitor, the portal image has fewer pixels than the monitor (2194x1234 for a 3840x2160 monitor at 1.75), so zoomed content is softer than with direct capture. Zoom could use ext-image-copy-capture, which COSMIC supports and Freeze already uses. That is a separate change.
  • A COSMIC session configured with a different screenshot portal is not detected.
  • grim truncates the scaled desktop size. At fractional scales where that differs from the rounded size, the PDF desktop background still rejects the capture. Capturing only the active output would avoid matching the layout. That is a separate change.
  • The PDF desktop background still fails when no output covers part of an axis, such as a gap between monitors. That behavior is unchanged.

Validation:

  • New repository tests cover the reported layout and image size, marked pixels, an area-sized image outside COSMIC, packed captures and an area screenshot within a pixel of the uniform size, the packed/uniform ambiguity in the PDF path, and session detection. The COSMIC and PDF tests fail without the fix.
  • cargo fmt --all -- --check, git diff --check, and cargo clippy --workspace --all-targets --all-features -- -D warnings passed.
  • ./tools/lint-and-test.sh passed.

… 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
@devmobasa
devmobasa merged commit db404ca into main Nov 13, 2026
6 checks passed
@devmobasa
devmobasa deleted the fix/cosmic-portal-zoom branch November 22, 2026 13:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] Zoom fails on COSMIC

1 participant