Skip to content

fix: support rotated monitors in screencopy and rendering - #167

Closed
neonvoidx wants to merge 1 commit into
hyprwm:mainfrom
neonvoidx:main
Closed

neonvoidx wants to merge 1 commit into
hyprwm:mainfrom
neonvoidx:main

Conversation

@neonvoidx

Copy link
Copy Markdown

Hyprland 0.56+ changed screencopy buffers here hyprwm/Hyprland#15714

The old approach of rotating the buffer in initSCFrame() via cairo transforms no longer works correctly the compositor applies the output transform when displaying layer surfaces, so rotating the buffer causes double-transformation on portrait or rotated monitors

Changes:

  • Removes the cairo pixel rotation from initSCFrame(), keeping the screenBuffer in its native physical orientation. A plain memcpy replaces the old cairo rendering pass
  • Adds rotation-aware cairo pattern matrices in renderSurface() that map between the physical screenBuffer and the logical PBUFFER at draw time, supporting both TR=1 (90° CW) and TR=3 (270° CW)
  • Adds matching rotation-aware coordinate mapping for CLICKPOSBUF (zoom circle source position) and outputColor() (final color sampling), so the zoom preview and picked color are correct on rotated outputs
  • Fixes the circle radius calculation which used integer division (5 / SCALEBUFS.x) instead of properly scaling the radius
  • Fixes sendFrame() which was toggling lastBuffer before using it, causing the wrong buffer to be attached. lastBuffer is now set by renderSurface() before calling sendFrame()
  • Uses CAIRO_OPERATOR_SOURCE for the initial buffer clear in renderSurface() to prevent rendering trails. The default OVER operator is a no-op when filling with transparent, leaving stale content from previous frames visible

Tested locally, previously rotated monitors were goofed up, this fixes that, didn't see any regressions

I also bumped the patch version up one because I figured since this is a notable change it should change /shrug

Hyprland 0.56+ delivers screencopy buffers in pre-transform (physical)
orientation, and the compositor applies the output transform when
displaying layer surfaces. The existing rendering code assumed the
screenBuffer matched the logical layer surface dimensions, which breaks
on portrait/rotated monitors — the zoom preview, color sampling, and
picked color are all incorrect.

- Track wl_output_transform via the output geometry event so renderSurface
  can map between physical screenBuffer coords and logical PBUFFER coords.

- Add rotation-aware cairo pattern matrices in renderSurface() for both
  the active and inactive branches, supporting TR=1 (90° CW) and TR=3
  (270° CW).

- Add rotation-aware coordinate mapping for CLICKPOSBUF (zoom circle
  source position) and outputColor() (final color sample position).

- Fix the circle radius calculation which previously used integer
  division instead of properly scaling the radius.

- Fix sendFrame() which toggled lastBuffer before using it, causing the
  wrong buffer to be attached. lastBuffer is now set by renderSurface()
  before calling sendFrame().

- Use CAIRO_OPERATOR_SOURCE for the initial buffer clear in
  renderSurface(). The default OVER operator is a no-op when filling
  with transparent, leaving stale content from previous frames visible.
@vaxerski

Copy link
Copy Markdown
Member

can be closed since #168 is basically the proper way

@vaxerski vaxerski closed this Aug 20, 2026
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.

2 participants