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
@@ -94,6 +94,28 @@ pub(all) struct ChandraCompositor {
|
||||
mut session_seen : String
|
||||
mut session_seen_at : UInt64
|
||||
mut session_check_at : UInt64
|
||||
/// Screenshots (screenshot.mbt): the selection overlay while it is up, the confirmation, a
|
||||
/// panel module's request waiting for a frame without its popup ((mode, frames_built then)),
|
||||
/// key codes whose release is swallowed, client frames held back while the screen is frozen,
|
||||
/// and where pictures go ("" for ~/Pictures/Screenshots).
|
||||
mut shot : ShotOverlay?
|
||||
mut shot_toast : ShotToast?
|
||||
mut shot_request : (ShotMode, Int)?
|
||||
mut rec_request : (ShotMode, Int)?
|
||||
mut frames_built : Int
|
||||
shot_swallow : Array[UInt]
|
||||
shot_frozen : Map[UInt64, @scene.ShmBufferSnapshot]
|
||||
mut shot_dir : String
|
||||
mut last_shot : String
|
||||
/// Reads the screen for screenshots when the host draws it (the wasm compositor sets it);
|
||||
/// None uses the software renderer's last frame.
|
||||
mut frame_source : (() -> @renderer.Pixmap?)?
|
||||
/// Screen recording (recorder.mbt): the recording running, whether it shows the pointer,
|
||||
/// a press on the REC pill (its release is swallowed too) and the last video saved.
|
||||
mut rec : Recording?
|
||||
mut rec_pointer : Bool
|
||||
mut rec_press : Bool
|
||||
mut last_recording : String
|
||||
}
|
||||
|
||||
///|
|
||||
@@ -160,6 +182,20 @@ pub fn ChandraCompositor::new(
|
||||
session_seen: "",
|
||||
session_seen_at: 0UL,
|
||||
session_check_at: 0UL,
|
||||
shot: None,
|
||||
shot_toast: None,
|
||||
shot_request: None,
|
||||
rec_request: None,
|
||||
frames_built: 0,
|
||||
shot_swallow: [],
|
||||
shot_frozen: {},
|
||||
shot_dir: "",
|
||||
last_shot: "",
|
||||
frame_source: None,
|
||||
rec: None,
|
||||
rec_pointer: true,
|
||||
rec_press: false,
|
||||
last_recording: "",
|
||||
}
|
||||
// Client popups (menus) are placed to stay on screen: the server asks for the output's
|
||||
// rectangle relative to the parent's content origin when it applies constraint adjustment.
|
||||
@@ -188,6 +224,8 @@ pub fn ChandraCompositor::resize(self : ChandraCompositor, w : Int, h : Int) ->
|
||||
self.output_w = w
|
||||
self.output_h = h
|
||||
self.work_area = work_area_for(w, h, self.theme)
|
||||
self.close_overlay() // its frozen frame is the old size
|
||||
self.stop_recording()
|
||||
self.server.set_output_size(w, h)
|
||||
self.shell.set_output(self.theme, w, h)
|
||||
self.apply_actions(self.wm.fit_work_area(self.work_area))
|
||||
@@ -199,6 +237,7 @@ pub fn ChandraCompositor::resize(self : ChandraCompositor, w : Int, h : Int) ->
|
||||
|
||||
///|
|
||||
pub fn ChandraCompositor::close(self : ChandraCompositor) -> Unit {
|
||||
self.stop_recording()
|
||||
for _, win in self.windows {
|
||||
release_snapshot(win.surface)
|
||||
}
|
||||
@@ -366,11 +405,16 @@ pub fn ChandraCompositor::step(self : ChandraCompositor) -> Unit {
|
||||
match self.windows.get(wid) {
|
||||
Some(win) => {
|
||||
match snap {
|
||||
Some(s) => {
|
||||
release_snapshot(win.surface)
|
||||
win.surface = Some(s)
|
||||
self.damage.mark_rect(win.geometry)
|
||||
}
|
||||
Some(s) =>
|
||||
if self.shot is Some(_) {
|
||||
// The screen is frozen under the screenshot overlay: show it afterwards.
|
||||
release_snapshot(self.shot_frozen.get(wid))
|
||||
self.shot_frozen.set(wid, s)
|
||||
} else {
|
||||
release_snapshot(win.surface)
|
||||
win.surface = Some(s)
|
||||
self.damage.mark_rect(win.geometry)
|
||||
}
|
||||
None => ()
|
||||
}
|
||||
}
|
||||
@@ -433,6 +477,8 @@ pub fn ChandraCompositor::step(self : ChandraCompositor) -> Unit {
|
||||
None => ()
|
||||
}
|
||||
ignore(self.windows.remove(wid))
|
||||
release_snapshot(self.shot_frozen.get(wid))
|
||||
self.shot_frozen.remove(wid)
|
||||
ignore(self.restore_claimed.remove(wid))
|
||||
if self.ptr_win == Some(wid) {
|
||||
self.ptr_win = None
|
||||
@@ -471,6 +517,8 @@ pub fn ChandraCompositor::step(self : ChandraCompositor) -> Unit {
|
||||
}
|
||||
}
|
||||
self.session_tick()
|
||||
self.screenshot_tick()
|
||||
self.recording_tick()
|
||||
}
|
||||
|
||||
///|
|
||||
@@ -590,11 +638,15 @@ fn ChandraCompositor::build_scene(
|
||||
}
|
||||
}
|
||||
self.shell.win_list = entries
|
||||
self.shell.screenshot_state = (if self.rec is Some(_) { 1 } else { 0 }) |
|
||||
(if self.rec_pointer { 2 } else { 0 })
|
||||
let t0 = @sys.monotonic_ms()
|
||||
let (bg_ops, panel_ops) = self.shell.render(self.output_w, self.output_h, self.theme)
|
||||
if self.switcher_on {
|
||||
panel_ops.append(self.switcher_ops())
|
||||
}
|
||||
panel_ops.append(self.screenshot_ops())
|
||||
self.frames_built = self.frames_built + 1
|
||||
self.run_shell_actions()
|
||||
// The wallpaper (the first ops) is cached by the renderer; the desktop card after it changes.
|
||||
let n_wall = if self.shell.wallpaper_len <= bg_ops.length() { self.shell.wallpaper_len } else { 0 }
|
||||
@@ -1043,6 +1095,7 @@ fn ChandraCompositor::run_shell_actions(self : ChandraCompositor) -> Unit {
|
||||
@shell.ShellAction::FocusWindow(wid) => self.activate_task(wid)
|
||||
@shell.ShellAction::Logout => self.quit_requested = true
|
||||
@shell.ShellAction::ThemeChanged => self.apply_theme()
|
||||
@shell.ShellAction::Screenshot(code) => self.screenshot_request(code)
|
||||
@shell.ShellAction::SetLayout(m) =>
|
||||
match m {
|
||||
0 => self.set_layout_mode(@wm.LayoutMode::Tiling)
|
||||
@@ -1125,6 +1178,9 @@ pub fn ChandraCompositor::handle_input(
|
||||
ev : @nested.InputEvent,
|
||||
time_ms : UInt,
|
||||
) -> Unit {
|
||||
if self.screenshot_input(ev, time_ms) {
|
||||
return
|
||||
}
|
||||
match ev {
|
||||
PointerMove(x, y) => {
|
||||
self.ptr_x = x
|
||||
@@ -1406,6 +1462,10 @@ pub fn ChandraCompositor::handle_input(
|
||||
///| Cursor shape (wp_cursor_shape_v1 value) for the current pointer position: shell UI
|
||||
/// decides over the launcher; a client window decides inside its client area; otherwise default.
|
||||
pub fn ChandraCompositor::desired_cursor(self : ChandraCompositor) -> UInt {
|
||||
match self.shot {
|
||||
Some(o) => return self.overlay_cursor(o)
|
||||
None => ()
|
||||
}
|
||||
let shell_shape = self.shell.cursor_at(self.ptr_x.to_int(), self.ptr_y.to_int())
|
||||
if shell_shape != 0U {
|
||||
return shell_shape
|
||||
|
||||
Reference in new issue
Block a user