Skip to content

feat(ruler-app): composite image export; session copies close the app - #72

Open
pgivel wants to merge 12 commits into
dev/wlroots-rotationfrom
dev/image-export
Open

pgivel wants to merge 12 commits into
dev/wlroots-rotationfrom
dev/image-export

Conversation

@pgivel

@pgivel pgivel commented Nov 4, 2026

Copy link
Copy Markdown
Collaborator

Part of #65. Stacked on #71.

Every session copy now ends the run, as in quick mode.

  • MD and Ctrl+C in a session copy the Markdown and quit.
  • A copy that fails keeps the session open with its message, so annotations are not lost.
  • On Linux without wl-copy or xclip the app quits anyway, and stderr warns that the copy may not last.

Image export (Ctrl+Shift+C, or the new IMG button).

  • In a session, drag a region, or click a screen, to copy it as a PNG of the frozen screenshot with the placed annotations, then quit.
  • A drag under 1 px counts as a click. Esc disarms first.
  • At least one annotation is needed; an undo that leaves none disarms the export.
  • The window is re-rendered offscreen without the panel, hints, border, outline, live marks and edge map. This runs on the next turn of the event loop, so it never runs inside the App borrow.
  • The image has the screen's own pixels. Only when the compositor renders the window at a scale that differs from the capture's by more than about 1 % is the region resampled to the capture's pixels.

Across screens.

  • A drag may span screens. Each window is placed in the desktop frame from winit's monitor position: logical px on Wayland and macOS, physical px on X11 and Windows. This is capture::desktop_frame_is_logical.
  • Each screen gives its own part. On Wayland and macOS the image takes the highest scale and enlarges lower-scale parts. Gaps between screens are transparent.
  • If the layout looks wrong (the drag ends on no screen, or screens overlap, as mirrored displays do), the image is cut at the start screen, with a note on stderr.

Also in this branch.

  • The clipboard helper timeout now runs from the last write that made progress. Large PNGs (8K, or 6K with a photo) used to always fail.
  • The stderr install hint names xclip only for images, since xsel cannot copy them.
  • PNG encoding is optimised in dev builds.

Tested by hand, on GNOME Wayland (mixed scales):

  • copy and quit;
  • arming;
  • a click export (sharp, full size);
  • a drag export;
  • Esc and undo.

Not tested yet:

  • A drag across screens on real hardware. In particular, stock GNOME without scale-monitor-framebuffer lays screens out in physical px, which may misplace a 2x screen next to a 1x one. The image would be silently wrong; only the outline drifting from the pointer would show it.
  • X11, KDE, Windows and macOS.
  • Mirrored displays.
  • SLINT_SCALE_FACTOR.

Reviewed in several rounds (internal team review, then talos-reviewer until APPROVE). Each commit builds and passes fmt, clippy and the tests.

🤖 Generated with Claude Code

pgivel and others added 12 commits November 4, 2026 12:18
MD and Ctrl+C in a session now copy and quit, like a quick-mode copy,
so every copy ends the run (the image export will too). A copy that
fails in a session stays open with its message, so the annotations are
not lost; without a Linux clipboard helper the app quits anyway and
warns on stderr, as quick mode does. Command::CopyText is gone.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Ctrl+Shift+C and the IMG button will toggle the export, and a click
will export a whole screen, so add toggle_export and export_region.
The command becomes CopyImageAndQuit, since every session copy now
ends the run; the arming and copied messages go, as a persistent hint
and the quit replace them.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
An image copied through arboard on Linux goes when the app quits,
unless a clipboard manager takes it, and every session copy now quits.
copy_image returns Copied like copy_text, so the export can warn.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A window snapshot's pixels follow the window's own scale factor, which
can differ from the capture's, so a crop taken with the monitor's
capture scale could cover the wrong area. device_crop moves to Rect and
takes the scale; an unusable scale crops nothing rather than guessing.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
In a session, Ctrl+Shift+C or the IMG button arms the export: drag a
region, or click a screen, to copy it as an image of the frozen screen
with its annotations, then quit. The window is re-rendered offscreen
with only the backdrop and annotations, on the next turn of the event
loop so the snapshot never runs inside the App borrow. The region is
cut from the snapshot as it is; only when the compositor rendered the
window at another scale than the capture's is that region resampled
to the capture's pixels. A failed copy stays open, as for Markdown.
A region that leaves its screen is cut at that screen's edge for now.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
FORK_TIMEOUT covered the whole transfer, and the loop slept 2 ms after
every pipe-buffer write, so throughput topped out near 30 MiB/s and a
large PNG (an 8K screen, or 6K with a photo) always failed, reported as
the helper having stopped reading. The deadline now restarts whenever a
write makes progress, and the loop only sleeps when nothing moved; a
helper that stalls still times out.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The image export encodes a whole screen as PNG on the UI thread; in an
unoptimised build that froze the overlay for several seconds.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
An export region that spans screens is placed through the coordinate
frame the window system reports out-of-window pointer positions in:
logical on Wayland and macOS, physical on X11 and Windows. That is
platform knowledge, so it lives with the capture backends.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A drag may now run onto other screens. Each window is placed in the
desktop frame from winit's monitor position, each touched screen gives
its own snapshot part, and the parts are stitched at the highest density
among them; lower-density parts are upscaled and gaps between screens
are transparent. If the drag ends on no placed screen the layout is not
trusted and the region is cut at the start screen, with a note on
stderr. One screen is the one-part case.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@pgivel
pgivel added this pull request to stack #73 November 4, 2026 17:34
@pgivel pgivel changed the title feat: composite image export, and session copies close the app feat(ruler-app): composite image export; session copies close the app Nov 4, 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.

1 participant