Screenshot module after Spectacle (Super+Shift+S), with a screen recorder
CI / test (push) Failing after 16s
CI / test (push) Failing after 16s
- Super+Shift+S (or Super+Shift+Print) freezes the screen under a selection overlay, like Spectacle's Rectangular Region: drag a rectangle (size readout under it, magnifier while drawing), drag inside to move it, drag its handles to resize, or click a window to select it. Enter or a double-click takes it, Escape or right-click cancels; F full screen, W active window, arrows nudge (Shift+arrows resize). Print takes the full screen, Super+Print the active window, Super+Ctrl+Print the window under the pointer. - Saved as ~/Pictures/Screenshots/Screenshot_YYYYMMDD_HHMMSS.png (XDG_PICTURES_DIR honoured), put on the clipboard as image/png (compositor-owned wl_data selection, written to the paste pipe without blocking), and confirmed by a notification with a thumbnail. - Screen recording: Super+Shift+R picks a region on the same overlay, Super+Alt+R the screen, Super+Ctrl+R a window; the same shortcut or the REC pill (top centre) stops. Raw frames (<= 30 fps, wall-clock stamped) stream into ffmpeg over a unix socket; it writes H.264 MP4 to ~/Videos/Screencasts/Screencast_*.mp4. The pointer is drawn in unless switched off. - renderer: encode_png_compressed (per-row filters + LZ77/fixed-Huffman deflate): a 1280x720 desktop is ~90 KB instead of 3.7 MB. - New 'screenshot' capability and 'screenshot' panel module (in the default panel): Spectacle's modes and the recording modes with their shortcuts, and a pointer switch; the button becomes Stop while recording. Served by both hosts (wasmer stub request 12 / host int 4; host-wasm publish-screenshot and a screenshot request). Panel requests wait for a frame without the module's popup. - sys: pwrite with a negative offset is a non-blocking write (pipes, sockets), SIGPIPE ignored. - Tests: native overlay, shortcuts, window pick, module, recording (with ffmpeg); host-wasm module test; renderer compression test. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01DPL5hjMGSLc5tHuzjsxGVa
This commit is contained in:
45 files changed
+3177
-57
No files matched your search
@@ -0,0 +1,2 @@
|
||||
Screenshots and screen recordings, after KDE Spectacle. The compositor captures (it alone sees
|
||||
the screen); a module with this capability offers the modes and starts them.
|
||||
@@ -0,0 +1,20 @@
|
||||
// Generated by `wit-bindgen` 0.63.0. DO NOT EDIT!
|
||||
|
||||
///|
|
||||
fn wasmImportTake(p0 : Int) = "chandra:desktop/screenshot@0.1.0" "take"
|
||||
|
||||
///|
|
||||
fn wasmImportStartRecording(p0 : Int) = "chandra:desktop/screenshot@0.1.0" "start-recording"
|
||||
|
||||
///|
|
||||
fn wasmImportStopRecording() = "chandra:desktop/screenshot@0.1.0" "stop-recording"
|
||||
|
||||
///|
|
||||
fn wasmImportIsRecording() -> Int = "chandra:desktop/screenshot@0.1.0" "is-recording"
|
||||
|
||||
///|
|
||||
fn wasmImportRecordsPointer() -> Int = "chandra:desktop/screenshot@0.1.0" "records-pointer"
|
||||
|
||||
///|
|
||||
fn wasmImportSetRecordsPointer(p0 : Int) = "chandra:desktop/screenshot@0.1.0" "set-records-pointer"
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
warnings = "-44"
|
||||
@@ -0,0 +1,50 @@
|
||||
// Generated by `wit-bindgen` 0.63.0. DO NOT EDIT!
|
||||
///|
|
||||
/// Take a screenshot: 0 rectangular region (drawn on the selection overlay), 1 full screen,
|
||||
/// 2 active window, 3 window under cursor (clicked on the overlay). It is saved to
|
||||
/// ~/Pictures/Screenshots and put on the clipboard. Other values are ignored.
|
||||
pub fn take(mode : UInt) -> Unit {
|
||||
|
||||
wasmImportTake((mode).reinterpret_as_int());
|
||||
|
||||
}
|
||||
///|
|
||||
/// Record the screen to ~/Videos/Screencasts: 0 a region (picked on the overlay), 1 the full
|
||||
/// screen, 2 a window (clicked on the overlay). While a recording runs this stops it instead.
|
||||
pub fn start_recording(mode : UInt) -> Unit {
|
||||
|
||||
wasmImportStartRecording((mode).reinterpret_as_int());
|
||||
|
||||
}
|
||||
///|
|
||||
/// Stop the recording, if one is running.
|
||||
pub fn stop_recording() -> Unit {
|
||||
|
||||
wasmImportStopRecording();
|
||||
|
||||
}
|
||||
///|
|
||||
/// Whether a recording is running.
|
||||
pub fn is_recording() -> Bool {
|
||||
|
||||
let result : Int = wasmImportIsRecording();
|
||||
let ret = (result != 0)
|
||||
return ret
|
||||
|
||||
}
|
||||
///|
|
||||
/// Whether recordings show the pointer, and switching that.
|
||||
pub fn records_pointer() -> Bool {
|
||||
|
||||
let result : Int = wasmImportRecordsPointer();
|
||||
let ret = (result != 0)
|
||||
return ret
|
||||
|
||||
}
|
||||
///|
|
||||
pub fn set_records_pointer(on : Bool) -> Unit {
|
||||
|
||||
wasmImportSetRecordsPointer((if on { 1 } else { 0 }));
|
||||
|
||||
}
|
||||
|
||||
@@ -36,6 +36,9 @@ fn wasmImportPublishWallpaper(p0 : Int) = "chandra:host/plasmoids@0.1.0" "publi
|
||||
///|
|
||||
fn wasmImportPublishSessionSettings(p0 : Int) = "chandra:host/plasmoids@0.1.0" "publish-session-settings"
|
||||
|
||||
///|
|
||||
fn wasmImportPublishScreenshot(p0 : Int) = "chandra:host/plasmoids@0.1.0" "publish-screenshot"
|
||||
|
||||
///|
|
||||
fn wasmImportPublishSystem(p0 : Int, p1 : Int64, p2 : Int64, p3 : Int, p4 : Int, p5 : Int64, p6 : Int64, p7 : Int64, p8 : Int) = "chandra:host/plasmoids@0.1.0" "publish-system"
|
||||
|
||||
@@ -58,25 +61,11 @@ fn wasmImportPickerStart() -> Int = "chandra:host/plasmoids@0.1.0" "picker-start
|
||||
fn wasmImportPickerPoll(p0 : Int) = "chandra:host/plasmoids@0.1.0" "picker-poll"
|
||||
|
||||
///|
|
||||
extern "wasm" fn mbt_ffi_ptr2str(ptr : Int, len : Int) -> String =
|
||||
#|(func (param i32) (param i32) (result i32)
|
||||
#| local.get 0
|
||||
#| local.get 1 call $moonbit.init_array16
|
||||
#| local.get 0)
|
||||
|
||||
///|
|
||||
#owned(str)
|
||||
extern "wasm" fn mbt_ffi_str2ptr(str : String) -> Int =
|
||||
#|(func (param i32) (result i32) local.get 0)
|
||||
|
||||
///|
|
||||
extern "wasm" fn mbt_ffi_store8(offset : Int, value : Int) =
|
||||
#|(func (param i32) (param i32) local.get 0 local.get 1 i32.store8)
|
||||
|
||||
///|
|
||||
#owned(bytes)
|
||||
extern "wasm" fn mbt_ffi_bytes2ptr(bytes : FixedArray[Byte]) -> Int =
|
||||
#|(func (param i32) (result i32) local.get 0)
|
||||
extern "wasm" fn mbt_ffi_malloc(size : Int) -> Int =
|
||||
#|(func (param i32) (result i32) (local i32)
|
||||
#| local.get 0 i32.const 4 i32.add call $moonbit.gc.malloc
|
||||
#| local.tee 1 i32.const 0 call $moonbit.init_array8
|
||||
#| local.get 1)
|
||||
|
||||
///|
|
||||
extern "wasm" fn mbt_ffi_store64(offset : Int, value : Int64) =
|
||||
@@ -87,23 +76,37 @@ extern "wasm" fn mbt_ffi_load64(offset : Int) -> Int64 =
|
||||
#|(func (param i32) (result i64) local.get 0 i64.load)
|
||||
|
||||
///|
|
||||
extern "wasm" fn mbt_ffi_malloc(size : Int) -> Int =
|
||||
#|(func (param i32) (result i32) (local i32)
|
||||
#| local.get 0 i32.const 4 i32.add call $moonbit.gc.malloc
|
||||
#| local.tee 1 i32.const 0 call $moonbit.init_array8
|
||||
#| local.get 1)
|
||||
extern "wasm" fn mbt_ffi_free(position : Int) =
|
||||
#|(func (param i32) local.get 0 call $moonbit.decref)
|
||||
|
||||
///|
|
||||
extern "wasm" fn mbt_ffi_load8_u(offset : Int) -> Int =
|
||||
#|(func (param i32) (result i32) local.get 0 i32.load8_u)
|
||||
#owned(str)
|
||||
extern "wasm" fn mbt_ffi_str2ptr(str : String) -> Int =
|
||||
#|(func (param i32) (result i32) local.get 0)
|
||||
|
||||
///|
|
||||
extern "wasm" fn mbt_ffi_store32(offset : Int, value : Int) =
|
||||
#|(func (param i32) (param i32) local.get 0 local.get 1 i32.store)
|
||||
|
||||
///|
|
||||
extern "wasm" fn mbt_ffi_free(position : Int) =
|
||||
#|(func (param i32) local.get 0 call $moonbit.decref)
|
||||
#owned(bytes)
|
||||
extern "wasm" fn mbt_ffi_bytes2ptr(bytes : FixedArray[Byte]) -> Int =
|
||||
#|(func (param i32) (result i32) local.get 0)
|
||||
|
||||
///|
|
||||
extern "wasm" fn mbt_ffi_ptr2str(ptr : Int, len : Int) -> String =
|
||||
#|(func (param i32) (param i32) (result i32)
|
||||
#| local.get 0
|
||||
#| local.get 1 call $moonbit.init_array16
|
||||
#| local.get 0)
|
||||
|
||||
///|
|
||||
extern "wasm" fn mbt_ffi_load8_u(offset : Int) -> Int =
|
||||
#|(func (param i32) (result i32) local.get 0 i32.load8_u)
|
||||
|
||||
///|
|
||||
extern "wasm" fn mbt_ffi_store8(offset : Int, value : Int) =
|
||||
#|(func (param i32) (param i32) local.get 0 local.get 1 i32.store8)
|
||||
|
||||
///|
|
||||
extern "wasm" fn mbt_ffi_load32(offset : Int) -> Int =
|
||||
|
||||
@@ -60,6 +60,11 @@ fn wasmImportPublishSessionSettings(p0 : Int) -> Unit {
|
||||
abort("wasm-only host import")
|
||||
}
|
||||
|
||||
///|
|
||||
fn wasmImportPublishScreenshot(p0 : Int) -> Unit {
|
||||
abort("wasm-only host import")
|
||||
}
|
||||
|
||||
///|
|
||||
fn wasmImportPublishSystem(p0 : Int, p1 : Int64, p2 : Int64, p3 : Int, p4 : Int, p5 : Int64, p6 : Int64, p7 : Int64, p8 : Int) -> Unit {
|
||||
abort("wasm-only host import")
|
||||
@@ -96,22 +101,7 @@ fn wasmImportPickerPoll(p0 : Int) -> Unit {
|
||||
}
|
||||
|
||||
///|
|
||||
fn mbt_ffi_ptr2str(ptr : Int, len : Int) -> String {
|
||||
abort("wasm-only")
|
||||
}
|
||||
|
||||
///|
|
||||
fn mbt_ffi_str2ptr(str : String) -> Int {
|
||||
abort("wasm-only")
|
||||
}
|
||||
|
||||
///|
|
||||
fn mbt_ffi_store8(offset : Int, value : Int) -> Unit {
|
||||
abort("wasm-only")
|
||||
}
|
||||
|
||||
///|
|
||||
fn mbt_ffi_bytes2ptr(bytes : FixedArray[Byte]) -> Int {
|
||||
fn mbt_ffi_malloc(size : Int) -> Int {
|
||||
abort("wasm-only")
|
||||
}
|
||||
|
||||
@@ -126,12 +116,12 @@ fn mbt_ffi_load64(offset : Int) -> Int64 {
|
||||
}
|
||||
|
||||
///|
|
||||
fn mbt_ffi_malloc(size : Int) -> Int {
|
||||
fn mbt_ffi_free(position : Int) -> Unit {
|
||||
abort("wasm-only")
|
||||
}
|
||||
|
||||
///|
|
||||
fn mbt_ffi_load8_u(offset : Int) -> Int {
|
||||
fn mbt_ffi_str2ptr(str : String) -> Int {
|
||||
abort("wasm-only")
|
||||
}
|
||||
|
||||
@@ -141,7 +131,22 @@ fn mbt_ffi_store32(offset : Int, value : Int) -> Unit {
|
||||
}
|
||||
|
||||
///|
|
||||
fn mbt_ffi_free(position : Int) -> Unit {
|
||||
fn mbt_ffi_bytes2ptr(bytes : FixedArray[Byte]) -> Int {
|
||||
abort("wasm-only")
|
||||
}
|
||||
|
||||
///|
|
||||
fn mbt_ffi_ptr2str(ptr : Int, len : Int) -> String {
|
||||
abort("wasm-only")
|
||||
}
|
||||
|
||||
///|
|
||||
fn mbt_ffi_load8_u(offset : Int) -> Int {
|
||||
abort("wasm-only")
|
||||
}
|
||||
|
||||
///|
|
||||
fn mbt_ffi_store8(offset : Int, value : Int) -> Unit {
|
||||
abort("wasm-only")
|
||||
}
|
||||
|
||||
|
||||
@@ -23,6 +23,8 @@ pub fn picker_start() -> Bool
|
||||
|
||||
pub fn popup(UInt32) -> PopupSurface?
|
||||
|
||||
pub fn publish_screenshot(UInt32) -> Unit
|
||||
|
||||
pub fn publish_session_settings(UInt32) -> Unit
|
||||
|
||||
pub fn publish_state(Int32, Bool) -> Unit
|
||||
@@ -87,6 +89,7 @@ pub(all) enum Request {
|
||||
Logout
|
||||
SetWallpaper(Int32)
|
||||
SetSessionSetting(SettingChange)
|
||||
Screenshot(Int32)
|
||||
}
|
||||
|
||||
pub(all) struct SettingChange {
|
||||
|
||||
@@ -41,6 +41,7 @@ pub(all) enum Request {
|
||||
Logout
|
||||
SetWallpaper(Int)
|
||||
SetSessionSetting(SettingChange)
|
||||
Screenshot(Int)
|
||||
}
|
||||
///|
|
||||
/// A native file-chooser dialog (zenity on the host session) for "Add widget".
|
||||
@@ -400,6 +401,13 @@ pub fn publish_session_settings(on : UInt) -> Unit {
|
||||
|
||||
wasmImportPublishSessionSettings((on).reinterpret_as_int());
|
||||
|
||||
}
|
||||
///|
|
||||
/// Screenshot state: bit 0 a recording is running, bit 1 recordings show the pointer.
|
||||
pub fn publish_screenshot(state : UInt) -> Unit {
|
||||
|
||||
wasmImportPublishScreenshot((state).reinterpret_as_int());
|
||||
|
||||
}
|
||||
///|
|
||||
pub fn publish_system(s : SystemSnapshot) -> Unit {
|
||||
@@ -493,6 +501,10 @@ pub fn next_request() -> Request? {
|
||||
|
||||
Request::SetSessionSetting(SettingChange::{index : mbt_ffi_load32((return_area) + 8), on : (mbt_ffi_load8_u((return_area) + 12) != 0)})
|
||||
}
|
||||
10 => {
|
||||
|
||||
Request::Screenshot(mbt_ffi_load32((return_area) + 8))
|
||||
}
|
||||
_ => panic()
|
||||
}
|
||||
|
||||
|
||||
@@ -93,6 +93,8 @@ pub fn memfd_create(name : String, size : Int) -> Int {
|
||||
|
||||
}
|
||||
///|
|
||||
/// Write at `offset` (shm pools). A negative offset writes at the current position without
|
||||
/// blocking (a clipboard pipe): the byte count, 0 when the pipe is full, -1 on error.
|
||||
pub fn pwrite(fd : Int, data : FixedArray[Byte], offset : Int) -> Int {
|
||||
|
||||
let ptr = mbt_ffi_bytes2ptr(data)
|
||||
|
||||
Reference in new issue
Block a user