Skip to content

fix(capture): turn 90° and 270° output captures upright for Freeze and Zoom - #448

Merged
devmobasa merged 1 commit into
mainfrom
fix/issue-446-rotated-freeze
Nov 20, 2026
Merged

devmobasa merged 1 commit into
mainfrom
fix/issue-446-rotated-freeze

Conversation

@devmobasa

Copy link
Copy Markdown
Owner

Fixes #446.

On an output rotated 90° (niri, wlr-randr --output … --transform 90), wayscriber --active --freeze showed the frozen screen upside down. Annotations drawn on top stayed upright.

A screencopy frame holds the output's framebuffer: the logical image with the output transform already applied. For 90°, that is the content rotated 90° counter-clockwise. To paint it on the logical overlay, Wayscriber must apply the inverse transform, but transformed_coords applied the transform itself. 180° and the four flipped transforms are their own inverses, so they were already correct. 90° and 270° were rotated the wrong way, and two quarter turns in the same direction leave the image upside down. The 270° Hyprland case from #178 had the same inverted rotation.

Changes:

  • transformed_coords swaps the 90° and 270° mappings. Freeze and Zoom now rotate screencopy and ext-image-copy-capture frames back to the logical orientation, and crops of the frozen or zoom image read the upright raster.
  • The with_output_transform docs say it undoes the compositor's transform, and state that screencopy frames are assumed to be in framebuffer orientation.

Limitations:

  • Hyprland 0.57 and newer render screencopy frames upright and report a normal transform for them, while wl_output still advertises the rotation. Freeze and Zoom rotate those frames a second time. At 90° and 270° the image then fails the size check, and at 180° it shows upside down. This happens with and without this change. ext-image-copy-capture reports each frame's own transform and would avoid the problem. That is a separate change.
  • Not tested on a rotated output on a live compositor.

Validation:

  • A new test compares all eight transforms against grim's out2com composition, which uses pixman's rotation matrix. It covers padded SHM rows, both y_invert values, and the output size and stride. It fails without the fix: at 90°, the expected and actual pixels come out in reverse order, which means the image is upside down. The existing 90°, 270°, and rotated-crop tests had locked in the wrong direction, and their expectations are corrected.
  • git diff --check passed. All Rust steps of ./tools/lint-and-test.sh passed: fmt, clippy, and builds and tests with all features and with no default features, plus the isolated render tests. The C# repository checks passed. One C# packaging test, RepositoryBuildProducesAVerifiableSignedRpm, could not run locally because dpkg-deb is not installed; this change does not touch packaging.

…d Zoom

A screencopy frame holds the output's framebuffer: the logical image
with the output transform already applied. For a 90° output, that is
the content rotated 90° counter-clockwise, and ext-image-copy-capture
reports the same transform for its frames. Painting the frame on the
logical overlay needs the inverse transform, but transformed_coords
applied the transform itself. 180° and the four flipped transforms are
their own inverses, so only 90° and 270° were wrong: they were rotated
a second quarter turn in the same direction, and the frozen or zoomed
screen came out upside down. The 270° Hyprland case from #178 had the
same inverted rotation.

Swap the 90° and 270° mappings, and document that screencopy frames
are assumed to be in framebuffer orientation.

Hyprland 0.57 and newer render screencopy frames upright while
wl_output still advertises the rotation, so Freeze and Zoom still turn
those frames a second time. That is unchanged here; ext-image-copy-
capture reports each frame's own transform and would avoid it.

A new test compares all eight transforms against grim's out2com
composition, with padded SHM rows, both y_invert values, and the output
size and stride. It fails without the fix. The existing 90°, 270°, and
rotated-crop tests had locked in the wrong direction and are corrected.

Fixes #446
@devmobasa
devmobasa merged commit 141546f into main Nov 20, 2026
6 checks passed
@devmobasa
devmobasa deleted the fix/issue-446-rotated-freeze 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] Screen is flipped in freeze mode on 90° rotated outputs

1 participant