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
@@ -141,6 +141,12 @@ pub fn memfd_create(name : String, size : Int) -> Int {
|
||||
c_memfd_create(str_to_utf8_bytes(name), size)
|
||||
}
|
||||
|
||||
///| Write as much of `buf` as a pipe takes without blocking (the fd is made non-blocking):
|
||||
/// the byte count, 0 when the pipe is full, -1 on an error (the reader went away).
|
||||
pub fn write_nonblock(fd : Int, buf : Bytes) -> Int {
|
||||
c_pwrite_bytes(fd, buf, buf.length(), -1)
|
||||
}
|
||||
|
||||
///|
|
||||
pub fn pwrite_bytes(fd : Int, buf : Bytes, offset : Int) -> Int {
|
||||
c_pwrite_bytes(fd, buf, buf.length(), offset)
|
||||
|
||||
@@ -227,6 +227,16 @@ MOONBIT_FFI_EXPORT
|
||||
int32_t mp_pwrite_bytes(int32_t fd, moonbit_bytes_t buf, int32_t len, int32_t offset) {
|
||||
int32_t cap = Moonbit_array_length(buf);
|
||||
int32_t n = len < cap ? len : cap;
|
||||
if (offset < 0) {
|
||||
/* A pipe or socket (clipboard paste, screen recording): write what fits now. 0 when it is
|
||||
* full, -1 on error. A reader that went away must not kill us with SIGPIPE. */
|
||||
signal(SIGPIPE, SIG_IGN);
|
||||
int fl = fcntl(fd, F_GETFL);
|
||||
if (fl >= 0 && !(fl & O_NONBLOCK)) fcntl(fd, F_SETFL, fl | O_NONBLOCK);
|
||||
ssize_t w = write(fd, buf, (size_t)n);
|
||||
if (w < 0) return (errno == EAGAIN || errno == EWOULDBLOCK || errno == EINTR) ? 0 : -1;
|
||||
return (int32_t)w;
|
||||
}
|
||||
ssize_t w = pwrite(fd, buf, (size_t)n, (off_t)offset);
|
||||
return w < 0 ? -1 : (int32_t)w;
|
||||
}
|
||||
@@ -394,6 +404,7 @@ int32_t mp_spawn(moonbit_bytes_t cmd_bytes, moonbit_bytes_t display_bytes) {
|
||||
setsid();
|
||||
/* SIG_IGN survives exec; apps (e.g. terminals that wait() on a helper) need the default. */
|
||||
signal(SIGCHLD, SIG_DFL);
|
||||
signal(SIGPIPE, SIG_DFL);
|
||||
/* Flatpak apps reach the host (shell lookup, portals) through org.freedesktop.Flatpak
|
||||
* on the real session bus, so they keep it; the sandbox isolates their instances anyway. */
|
||||
if (private_bus[0] && strstr(cmd, "flatpak run") == NULL) setenv("DBUS_SESSION_BUS_ADDRESS", private_bus, 1);
|
||||
|
||||
@@ -93,6 +93,12 @@ pub fn memfd_create(name : String, size : Int) -> Int {
|
||||
@hostsys.memfd_create(name, size)
|
||||
}
|
||||
|
||||
///| Write as much of `buf` as a pipe takes without blocking (the fd is made non-blocking):
|
||||
/// the byte count, 0 when the pipe is full, -1 on an error (the reader went away).
|
||||
pub fn write_nonblock(fd : Int, buf : Bytes) -> Int {
|
||||
@hostsys.pwrite(fd, to_fixed(buf), -1)
|
||||
}
|
||||
|
||||
///|
|
||||
pub fn pwrite_bytes(fd : Int, buf : Bytes, offset : Int) -> Int {
|
||||
@hostsys.pwrite(fd, to_fixed(buf), offset)
|
||||
|
||||
Reference in new issue
Block a user