Screenshot editor: annotate, blur, pixelate, redact and crop before saving
CI / test (push) Canceled after 12m58s

Every screenshot now opens in an editor after KDE Spectacle's annotation mode:
Arrow, Line, Rectangle, Ellipse, Pen, Highlighter, Text, Number markers, Blur,
Pixelate, Redact and Crop, 8 colours, 3 sizes, undo/redo. Enter saves and
copies, Ctrl+C copies only, Esc discards.

- Drawn by the compositor (shot_editor.mbt), keyboard owned by it while up.
- Annotations are drawn into the picture's pixels at full size (annotate.mbt),
  so what is shown is what is saved. Blur = 6x6 block average + 3 box-blur
  passes; redact is opaque; both touch only their box (pixel tests).
- The picture goes to the renderer as <=2 MB strips: one 8 MB image-pixels
  call exhausts wasmtime's hostcall fuel and killed the wasm host.
- Frame callbacks are held while the overlay/editor freeze the screen, so apps
  behind stop drawing (0% CPU vs 52% with a full-screen animating app).
- wasmhost: error buffer 16 KB so trap causes aren't cut off; image-pixels
  limit 1024 -> 16384 a side (both hosts).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DPL5hh3TaFJh7nhCxAjV4Q
This commit is contained in:
Claude committed 2026-11-26 05:37:03 +00:00
1 parent 76a23f7816
commit 77fcc4db1c
14 files changed
+2127 -67

No files matched your search

+35 -4
View File
@@ -359,6 +359,10 @@ pub(all) struct WaylandServer {
/// Drag and drop in progress (dnd.mbt), and a drop its target is still taking.
mut drag : DragState?
mut drop_pending : DropState?
/// While the screen is frozen (screenshot overlay and editor) frame callbacks are held back,
/// so clients stop drawing frames nobody sees: (client id, callback id), sent on release.
mut hold_frames : Bool
held_frames : Array[(UInt, UInt)]
}
///|
@@ -392,9 +396,35 @@ pub fn WaylandServer::listen(
debug_configure: @sys.getenv("CHANDRA_DEBUG_CONFIGURE").length() > 0,
drag: None,
drop_pending: None,
hold_frames: false,
held_frames: [],
})
}
///| Tell a client its frame callback `cb_id` is done.
fn WaylandServer::frame_done(self : WaylandServer, c : ClientConn, cb_id : UInt) -> Unit {
let fw = WireWriter::new()
fw.u32(self.next_serial())
c.send_msg(fw.finish_msg(cb_id, 0U))
send_delete_id(c, cb_id)
}
///| Hold frame callbacks back (`on`), or send the ones held to the clients still connected.
pub fn WaylandServer::set_hold_frames(self : WaylandServer, on : Bool) -> Unit {
self.hold_frames = on
if on {
return
}
for h in self.held_frames {
for c in self.clients {
if c.client_id == h.0 {
self.frame_done(c, h.1)
}
}
}
self.held_frames.clear()
}
///|
pub fn WaylandServer::close(self : WaylandServer) -> Unit {
for t in self.transfers {
@@ -809,10 +839,11 @@ fn WaylandServer::dispatch_msg(
match surf.pending_frame_cb {
Some(cb_id) => {
surf.pending_frame_cb = None
let fw = WireWriter::new()
fw.u32(self.next_serial())
c.send_msg(fw.finish_msg(cb_id, 0U))
send_delete_id(c, cb_id)
if self.hold_frames {
self.held_frames.push((c.client_id, cb_id))
} else {
self.frame_done(c, cb_id)
}
}
None => ()
}