Screenshot editor: annotate, blur, pixelate, redact and crop before saving
CI / test (push) Canceled after 12m58s
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:
14 files changed
+2127
-67
No files matched your search
@@ -36,6 +36,13 @@ fn png_size(png : Bytes) -> (Int, Int) {
|
||||
(be(16), be(20))
|
||||
}
|
||||
|
||||
///| In the screenshot editor: press Enter (save and copy).
|
||||
fn save_edit(comp : @host.ChandraCompositor, t : UInt) -> Unit raise {
|
||||
assert_true(comp.screenshot_editing())
|
||||
key(comp, 28U, true, t)
|
||||
key(comp, 28U, false, t + 1U)
|
||||
}
|
||||
|
||||
///| Drag with the left button from (x0, y0) to (x1, y1).
|
||||
fn drag(comp : @host.ChandraCompositor, x0 : Int, y0 : Int, x1 : Int, y1 : Int, t : UInt) -> Unit {
|
||||
comp.handle_input(@nested.InputEvent::PointerMove(x0.to_double(), y0.to_double()), t)
|
||||
@@ -71,10 +78,16 @@ test "super+shift+s: drag a region, Enter saves it as a PNG and puts it on the c
|
||||
comp.handle_input(@nested.InputEvent::Modifiers(0U, 0U, 0U, 0U), 43U)
|
||||
assert_eq(comp.screenshot_selection(), Some(@scene.Rect::new(120, 90, 321, 210)))
|
||||
ignore(comp.compose_frame())
|
||||
// Enter takes it.
|
||||
// Enter takes it: the editor opens with it; nothing is saved yet.
|
||||
key(comp, 28U, true, 50U)
|
||||
key(comp, 28U, false, 51U)
|
||||
assert_false(comp.screenshot_active())
|
||||
assert_true(comp.screenshot_editing())
|
||||
assert_eq(comp.last_screenshot(), "")
|
||||
ignore(comp.compose_frame())
|
||||
// Enter in the editor saves it.
|
||||
save_edit(comp, 52U)
|
||||
assert_false(comp.screenshot_editing())
|
||||
let path = comp.last_screenshot()
|
||||
assert_true(path.has_prefix(dir + "/Screenshot_"))
|
||||
assert_true(path.has_suffix(".png"))
|
||||
@@ -92,10 +105,12 @@ test "print takes the full screen at once; a second one gets its own name" {
|
||||
key(comp, 99U, true, 1U)
|
||||
key(comp, 99U, false, 2U)
|
||||
assert_false(comp.screenshot_active())
|
||||
save_edit(comp, 3U)
|
||||
let first = comp.last_screenshot()
|
||||
assert_eq(png_size(@sys.read_file_bytes(first)), (1280, 720))
|
||||
key(comp, 99U, true, 3U)
|
||||
key(comp, 99U, false, 4U)
|
||||
key(comp, 99U, true, 5U)
|
||||
key(comp, 99U, false, 6U)
|
||||
save_edit(comp, 7U)
|
||||
let second = comp.last_screenshot()
|
||||
assert_true(second.length() > 0 && second != first)
|
||||
}
|
||||
@@ -122,6 +137,7 @@ test "escape cancels the overlay; a click on a window selects it; W takes the ac
|
||||
// W takes the active window (B) instead.
|
||||
key(comp, 17U, true, 30U)
|
||||
key(comp, 17U, false, 31U)
|
||||
save_edit(comp, 32U)
|
||||
let gb = comp.windows.get(2UL).unwrap().geometry
|
||||
assert_eq(png_size(@sys.read_file_bytes(comp.last_screenshot())), (gb.w + 2, gb.h + 39))
|
||||
}
|
||||
@@ -139,6 +155,7 @@ test "the screenshot module's request waits for a frame, then opens the overlay"
|
||||
comp.screenshot_request(1)
|
||||
ignore(comp.compose_frame())
|
||||
comp.step()
|
||||
save_edit(comp, 1U)
|
||||
assert_eq(png_size(@sys.read_file_bytes(comp.last_screenshot())), (1280, 720))
|
||||
}
|
||||
|
||||
@@ -280,6 +297,7 @@ test "the screenshot panel module takes a full-screen shot without its popup in
|
||||
click_at(comp, pr.x + 40, pr.y + 6 + 2 * 30 + 5, 5U)
|
||||
assert_eq(comp.shell.slot_popup_rect(slot).w, 0)
|
||||
comp.step()
|
||||
save_edit(comp, 6U)
|
||||
assert_eq(png_size(@sys.read_file_bytes(comp.last_screenshot())), (1280, 720))
|
||||
// Row 1: Rectangular Region opens the overlay.
|
||||
click_module(comp, "screenshot", 10U)
|
||||
|
||||
Reference in new issue
Block a user