2026-10-21 00:54:54 +00:00
|
|
|
use std::{
|
|
|
|
|
fs,
|
|
|
|
|
path::{Path, PathBuf},
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
use chrono::Local;
|
|
|
|
|
use image::GenericImageView;
|
|
|
|
|
use tauri::{AppHandle, Emitter, LogicalPosition, LogicalSize, Manager, State};
|
|
|
|
|
|
|
|
|
|
use crate::{
|
|
|
|
|
editor,
|
|
|
|
|
files::app_cache_dir,
|
|
|
|
|
models::{ActionOutcome, CaptureSessionInfo, CaptureSource, NormalizedRect},
|
release: 0.1.1 — update channel, settings/UI trims, macOS + Windows x64 only
Update path
- `src-tauri/src/update.rs`: manifest fetch, semver compare, optional ed25519
signature check against a key baked in at build time, then a size + SHA256
gate before an installer can run. `UpdateStatus` now reports the artifact key
it resolved so the UI can name what it will install.
- Settings → Updates panel shows the feed, the check/download state machine, and
the local OS, architecture and release artifact for this machine.
- `scripts/publish-release.sh` + `scripts/release-key.py` publish installers and a
signed `shift-update.json` onto an orphan `releases` branch.
Scope trims requested for this release
- Settings: the Radial rings tab is gone, so ring orders are read from
`settings.json` with no in-app editor for now.
- Main window: the update entry in the header bar is gone; updates live in
Settings → Updates only.
- Release targets are macOS universal and Windows x64. ARM64 and Linux stay
buildable and are no longer published; `docs/RELEASE.md` records the decision.
Gates: cargo fmt --check clean, `cargo test --lib` 142 passed / 2 ignored,
`pnpm check` clean, `pnpm test` 34 passed, `pnpm build` ok.
2026-10-25 19:06:46 +00:00
|
|
|
result_card, settings, AppState,
|
2026-10-21 00:54:54 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
#[cfg(target_os = "macos")]
|
|
|
|
|
#[link(name = "CoreGraphics", kind = "framework")]
|
|
|
|
|
extern "C" {
|
|
|
|
|
fn CGPreflightScreenCaptureAccess() -> bool;
|
|
|
|
|
fn CGRequestScreenCaptureAccess() -> bool;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[cfg(target_os = "macos")]
|
|
|
|
|
fn ensure_screen_capture_access() -> Result<(), String> {
|
|
|
|
|
unsafe {
|
|
|
|
|
if screen_capture_access_allowed() || CGRequestScreenCaptureAccess() {
|
|
|
|
|
return Ok(());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
Err(
|
|
|
|
|
"Screen Recording permission is required. Enable Shift in System Settings > Privacy & Security > Screen Recording, then restart Shift if macOS asks."
|
|
|
|
|
.into(),
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[cfg(not(target_os = "macos"))]
|
|
|
|
|
fn ensure_screen_capture_access() -> Result<(), String> {
|
|
|
|
|
Ok(())
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[cfg(target_os = "macos")]
|
|
|
|
|
fn screen_capture_access_allowed() -> bool {
|
|
|
|
|
unsafe { CGPreflightScreenCaptureAccess() }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[cfg(not(target_os = "macos"))]
|
|
|
|
|
fn screen_capture_access_allowed() -> bool {
|
|
|
|
|
true
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[tauri::command]
|
|
|
|
|
pub fn screen_capture_access_status() -> bool {
|
|
|
|
|
screen_capture_access_allowed()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fn monitor_at_cursor(app: &AppHandle) -> Result<tauri::Monitor, String> {
|
|
|
|
|
let cursor = app.cursor_position().map_err(|error| error.to_string())?;
|
|
|
|
|
let monitors = app
|
|
|
|
|
.available_monitors()
|
|
|
|
|
.map_err(|error| error.to_string())?;
|
|
|
|
|
monitors
|
|
|
|
|
.into_iter()
|
|
|
|
|
.find(|monitor| {
|
|
|
|
|
let x = monitor.position().x as f64;
|
|
|
|
|
let y = monitor.position().y as f64;
|
|
|
|
|
cursor.x >= x
|
|
|
|
|
&& cursor.y >= y
|
|
|
|
|
&& cursor.x <= x + monitor.size().width as f64
|
|
|
|
|
&& cursor.y <= y + monitor.size().height as f64
|
|
|
|
|
})
|
|
|
|
|
.or_else(|| app.primary_monitor().ok().flatten())
|
|
|
|
|
.ok_or_else(|| "No monitor found under the cursor.".to_string())
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fn capture_screen(app: &AppHandle, monitor: &tauri::Monitor) -> Result<CaptureSource, String> {
|
|
|
|
|
let directory = app_cache_dir(app)?;
|
|
|
|
|
let filename = format!("screen-{}.png", Local::now().format("%Y%m%d-%H%M%S-%3f"));
|
|
|
|
|
let output = directory.join(filename);
|
|
|
|
|
|
|
|
|
|
#[cfg(target_os = "macos")]
|
|
|
|
|
{
|
|
|
|
|
let scale = monitor.scale_factor();
|
|
|
|
|
let region = format!(
|
|
|
|
|
"{},{},{},{}",
|
|
|
|
|
(monitor.position().x as f64 / scale).round() as i64,
|
|
|
|
|
(monitor.position().y as f64 / scale).round() as i64,
|
|
|
|
|
(monitor.size().width as f64 / scale).round() as u32,
|
|
|
|
|
(monitor.size().height as f64 / scale).round() as u32,
|
|
|
|
|
);
|
2026-10-25 04:24:05 +00:00
|
|
|
let status = crate::process::command("/usr/sbin/screencapture")
|
2026-10-21 00:54:54 +00:00
|
|
|
.args([
|
|
|
|
|
"-x",
|
|
|
|
|
"-R",
|
|
|
|
|
®ion,
|
|
|
|
|
"-t",
|
|
|
|
|
"png",
|
|
|
|
|
output.to_string_lossy().as_ref(),
|
|
|
|
|
])
|
|
|
|
|
.status()
|
|
|
|
|
.map_err(|error| format!("Could not launch screencapture: {error}"))?;
|
|
|
|
|
if !status.success() {
|
|
|
|
|
return Err(
|
|
|
|
|
"Screen capture was cancelled or blocked. Allow Screen Recording in System Settings."
|
|
|
|
|
.into(),
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[cfg(target_os = "windows")]
|
|
|
|
|
{
|
2026-10-25 04:24:05 +00:00
|
|
|
capture_windows_screen(monitor, &output)?;
|
2026-10-21 00:54:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[cfg(target_os = "linux")]
|
|
|
|
|
{
|
|
|
|
|
let status = if let Some(grim) = crate::files::resolve_tool("grim") {
|
|
|
|
|
if let Some(name) = monitor.name() {
|
2026-10-25 04:24:05 +00:00
|
|
|
crate::process::command(grim)
|
2026-10-21 00:54:54 +00:00
|
|
|
.args(["-o", name, output.to_string_lossy().as_ref()])
|
|
|
|
|
.status()
|
|
|
|
|
} else {
|
2026-10-25 04:24:05 +00:00
|
|
|
crate::process::command(grim)
|
2026-10-21 00:54:54 +00:00
|
|
|
.arg(output.to_string_lossy().as_ref())
|
|
|
|
|
.status()
|
|
|
|
|
}
|
|
|
|
|
} else if let Some(gnome_screenshot) = crate::files::resolve_tool("gnome-screenshot") {
|
2026-10-25 04:24:05 +00:00
|
|
|
crate::process::command(gnome_screenshot)
|
2026-10-21 00:54:54 +00:00
|
|
|
.args(["-f", output.to_string_lossy().as_ref()])
|
|
|
|
|
.status()
|
|
|
|
|
} else {
|
|
|
|
|
return Err("Install grim or gnome-screenshot to capture the screen on Linux.".into());
|
|
|
|
|
};
|
|
|
|
|
let status = status.map_err(|error| error.to_string())?;
|
|
|
|
|
if !status.success() {
|
|
|
|
|
return Err("Screen capture failed.".into());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
let (width, height) =
|
|
|
|
|
image::image_dimensions(&output).map_err(|error| format!("Invalid capture: {error}"))?;
|
|
|
|
|
Ok(CaptureSource {
|
|
|
|
|
path: output.to_string_lossy().to_string(),
|
|
|
|
|
width,
|
|
|
|
|
height,
|
|
|
|
|
monitor_x: monitor.position().x as f64,
|
|
|
|
|
monitor_y: monitor.position().y as f64,
|
|
|
|
|
scale_factor: monitor.scale_factor(),
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
2026-10-25 04:24:05 +00:00
|
|
|
#[cfg(target_os = "windows")]
|
|
|
|
|
fn capture_windows_screen(monitor: &tauri::Monitor, output: &Path) -> Result<(), String> {
|
|
|
|
|
use windows_sys::Win32::Graphics::Gdi::{
|
|
|
|
|
BitBlt, CreateCompatibleBitmap, CreateCompatibleDC, DeleteDC, DeleteObject, GetDC,
|
|
|
|
|
GetDIBits, ReleaseDC, SelectObject, BITMAPINFO, BITMAPINFOHEADER, BI_RGB, CAPTUREBLT,
|
|
|
|
|
DIB_RGB_COLORS, HGDIOBJ, SRCCOPY,
|
|
|
|
|
};
|
|
|
|
|
use windows_sys::Win32::UI::HiDpi::{
|
|
|
|
|
SetThreadDpiAwarenessContext, DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2,
|
|
|
|
|
};
|
|
|
|
|
// Capture only the monitor under the cursor. Grabbing the virtual desktop
|
|
|
|
|
// would make a mixed-DPI or multi-monitor setup produce an image whose
|
|
|
|
|
// origin no longer matches the overlay window.
|
|
|
|
|
let x = monitor.position().x;
|
|
|
|
|
let y = monitor.position().y;
|
|
|
|
|
let width = monitor.size().width as i32;
|
|
|
|
|
let height = monitor.size().height as i32;
|
|
|
|
|
unsafe {
|
|
|
|
|
// Tauri's monitor bounds are physical pixels. Pin this worker thread
|
|
|
|
|
// to per-monitor-v2 while calling GDI; otherwise GetDC(NULL) may use a
|
|
|
|
|
// thread-scaled virtual desktop and the capture no longer aligns with
|
|
|
|
|
// the overlay.
|
|
|
|
|
let previous_awareness =
|
|
|
|
|
SetThreadDpiAwarenessContext(DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2);
|
|
|
|
|
let restore_awareness = || {
|
|
|
|
|
if !previous_awareness.is_null() {
|
|
|
|
|
SetThreadDpiAwarenessContext(previous_awareness);
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
if width <= 0 || height <= 0 {
|
|
|
|
|
restore_awareness();
|
|
|
|
|
return Err("Windows did not report a usable screen size.".into());
|
|
|
|
|
}
|
|
|
|
|
let screen = GetDC(std::ptr::null_mut());
|
|
|
|
|
if screen.is_null() {
|
|
|
|
|
restore_awareness();
|
|
|
|
|
return Err("Windows could not open the desktop surface.".into());
|
|
|
|
|
}
|
|
|
|
|
let memory = CreateCompatibleDC(screen);
|
|
|
|
|
let bitmap = CreateCompatibleBitmap(screen, width, height);
|
|
|
|
|
if memory.is_null() || bitmap.is_null() {
|
|
|
|
|
if !bitmap.is_null() {
|
|
|
|
|
DeleteObject(bitmap as HGDIOBJ);
|
|
|
|
|
}
|
|
|
|
|
if !memory.is_null() {
|
|
|
|
|
DeleteDC(memory);
|
|
|
|
|
}
|
|
|
|
|
ReleaseDC(std::ptr::null_mut(), screen);
|
|
|
|
|
restore_awareness();
|
|
|
|
|
return Err("Windows could not allocate a screenshot surface.".into());
|
|
|
|
|
}
|
|
|
|
|
let previous = SelectObject(memory, bitmap as HGDIOBJ);
|
|
|
|
|
let copied = BitBlt(
|
|
|
|
|
memory,
|
|
|
|
|
0,
|
|
|
|
|
0,
|
|
|
|
|
width,
|
|
|
|
|
height,
|
|
|
|
|
screen,
|
|
|
|
|
x,
|
|
|
|
|
y,
|
|
|
|
|
SRCCOPY | CAPTUREBLT,
|
|
|
|
|
);
|
|
|
|
|
let mut info = BITMAPINFO {
|
|
|
|
|
bmiHeader: BITMAPINFOHEADER {
|
|
|
|
|
biSize: std::mem::size_of::<BITMAPINFOHEADER>() as u32,
|
|
|
|
|
biWidth: width,
|
|
|
|
|
// Negative height asks GDI for top-down rows, matching PNG.
|
|
|
|
|
biHeight: -height,
|
|
|
|
|
biPlanes: 1,
|
|
|
|
|
biBitCount: 32,
|
|
|
|
|
biCompression: BI_RGB,
|
|
|
|
|
biSizeImage: 0,
|
|
|
|
|
biXPelsPerMeter: 0,
|
|
|
|
|
biYPelsPerMeter: 0,
|
|
|
|
|
biClrUsed: 0,
|
|
|
|
|
biClrImportant: 0,
|
|
|
|
|
},
|
|
|
|
|
bmiColors: [windows_sys::Win32::Graphics::Gdi::RGBQUAD {
|
|
|
|
|
rgbBlue: 0,
|
|
|
|
|
rgbGreen: 0,
|
|
|
|
|
rgbRed: 0,
|
|
|
|
|
rgbReserved: 0,
|
|
|
|
|
}],
|
|
|
|
|
};
|
|
|
|
|
let mut pixels = vec![0_u8; width as usize * height as usize * 4];
|
|
|
|
|
let rows = GetDIBits(
|
|
|
|
|
memory,
|
|
|
|
|
bitmap,
|
|
|
|
|
0,
|
|
|
|
|
height as u32,
|
|
|
|
|
pixels.as_mut_ptr().cast(),
|
|
|
|
|
&mut info,
|
|
|
|
|
DIB_RGB_COLORS,
|
|
|
|
|
);
|
|
|
|
|
SelectObject(memory, previous);
|
|
|
|
|
DeleteObject(bitmap as HGDIOBJ);
|
|
|
|
|
DeleteDC(memory);
|
|
|
|
|
ReleaseDC(std::ptr::null_mut(), screen);
|
|
|
|
|
|
|
|
|
|
if copied == 0 || rows == 0 {
|
|
|
|
|
restore_awareness();
|
|
|
|
|
return Err("Windows could not copy the screen surface.".into());
|
|
|
|
|
}
|
|
|
|
|
for pixel in pixels.chunks_exact_mut(4) {
|
|
|
|
|
pixel.swap(0, 2);
|
|
|
|
|
pixel[3] = 255;
|
|
|
|
|
}
|
|
|
|
|
let Some(image) = image::RgbaImage::from_raw(width as u32, height as u32, pixels) else {
|
|
|
|
|
restore_awareness();
|
|
|
|
|
return Err("Windows returned an invalid screenshot buffer.".into());
|
|
|
|
|
};
|
|
|
|
|
let result = image
|
|
|
|
|
.save_with_format(output, image::ImageFormat::Png)
|
|
|
|
|
.map_err(|error| format!("Could not save the screenshot: {error}"));
|
|
|
|
|
restore_awareness();
|
|
|
|
|
result
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2026-10-21 00:54:54 +00:00
|
|
|
fn screenshot_directory(app: &AppHandle) -> Result<PathBuf, String> {
|
|
|
|
|
settings::screenshot_dir(app)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pub fn begin_capture(app: &AppHandle, mode: &str) -> Result<CaptureSessionInfo, String> {
|
|
|
|
|
ensure_screen_capture_access()?;
|
|
|
|
|
for label in ["main", "radial", "editor"] {
|
|
|
|
|
if let Some(window) = app.get_webview_window(label) {
|
|
|
|
|
let _ = window.hide();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
std::thread::sleep(std::time::Duration::from_millis(90));
|
|
|
|
|
let monitor = monitor_at_cursor(app)?;
|
|
|
|
|
let source = capture_screen(app, &monitor)?;
|
|
|
|
|
let info = CaptureSessionInfo {
|
|
|
|
|
mode: mode.to_string(),
|
|
|
|
|
source: source.clone(),
|
|
|
|
|
};
|
|
|
|
|
let state = app.state::<AppState>();
|
|
|
|
|
*state.capture.lock().map_err(|error| error.to_string())? = Some(info.clone());
|
|
|
|
|
|
|
|
|
|
let window = app
|
|
|
|
|
.get_webview_window("capture")
|
|
|
|
|
.ok_or_else(|| "Capture window is unavailable.".to_string())?;
|
|
|
|
|
let scale = monitor.scale_factor();
|
|
|
|
|
window
|
|
|
|
|
.set_position(LogicalPosition::new(
|
|
|
|
|
monitor.position().x as f64 / scale,
|
|
|
|
|
monitor.position().y as f64 / scale,
|
|
|
|
|
))
|
|
|
|
|
.map_err(|error| error.to_string())?;
|
|
|
|
|
window
|
|
|
|
|
.set_size(LogicalSize::new(
|
|
|
|
|
monitor.size().width as f64 / scale,
|
|
|
|
|
monitor.size().height as f64 / scale,
|
|
|
|
|
))
|
|
|
|
|
.map_err(|error| error.to_string())?;
|
|
|
|
|
#[cfg(target_os = "macos")]
|
|
|
|
|
{
|
|
|
|
|
window
|
|
|
|
|
.set_simple_fullscreen(true)
|
|
|
|
|
.map_err(|error| error.to_string())?;
|
|
|
|
|
}
|
|
|
|
|
window.show().map_err(|error| error.to_string())?;
|
|
|
|
|
window.set_focus().map_err(|error| error.to_string())?;
|
|
|
|
|
window
|
|
|
|
|
.emit("capture://ready", info.clone())
|
|
|
|
|
.map_err(|error| error.to_string())?;
|
|
|
|
|
Ok(info)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pub fn crop_session(
|
|
|
|
|
app: &AppHandle,
|
|
|
|
|
state: &AppState,
|
|
|
|
|
rect: &NormalizedRect,
|
|
|
|
|
) -> Result<PathBuf, String> {
|
|
|
|
|
let session = state
|
|
|
|
|
.capture
|
|
|
|
|
.lock()
|
|
|
|
|
.map_err(|error| error.to_string())?
|
|
|
|
|
.clone()
|
|
|
|
|
.ok_or_else(|| "No capture session is active.".to_string())?;
|
|
|
|
|
let image = image::open(&session.source.path)
|
|
|
|
|
.map_err(|error| format!("Could not read the screenshot: {error}"))?;
|
|
|
|
|
let (width, height) = image.dimensions();
|
|
|
|
|
let x = (rect.x.clamp(0.0, 1.0) * width as f64).round() as u32;
|
|
|
|
|
let y = (rect.y.clamp(0.0, 1.0) * height as f64).round() as u32;
|
|
|
|
|
let crop_width = (rect.width.clamp(0.0, 1.0) * width as f64).round() as u32;
|
|
|
|
|
let crop_height = (rect.height.clamp(0.0, 1.0) * height as f64).round() as u32;
|
|
|
|
|
if crop_width < 2 || crop_height < 2 || x >= width || y >= height {
|
|
|
|
|
return Err("Select an area first.".into());
|
|
|
|
|
}
|
|
|
|
|
let cropped = image.crop_imm(x, y, crop_width.min(width - x), crop_height.min(height - y));
|
|
|
|
|
let directory = screenshot_directory(app)?;
|
|
|
|
|
let name = format!("Shift-{}.png", Local::now().format("%Y%m%d-%H%M%S"));
|
|
|
|
|
let output = directory.join(name);
|
|
|
|
|
cropped
|
|
|
|
|
.save_with_format(&output, image::ImageFormat::Png)
|
|
|
|
|
.map_err(|error| error.to_string())?;
|
|
|
|
|
Ok(output)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pub fn dismiss_capture(app: &AppHandle) {
|
|
|
|
|
let source = app
|
|
|
|
|
.try_state::<AppState>()
|
|
|
|
|
.and_then(|state| {
|
|
|
|
|
state
|
|
|
|
|
.capture
|
|
|
|
|
.lock()
|
|
|
|
|
.ok()
|
|
|
|
|
.and_then(|mut session| session.take())
|
|
|
|
|
})
|
|
|
|
|
.map(|session| session.source.path);
|
|
|
|
|
if let Some(window) = app.get_webview_window("capture") {
|
|
|
|
|
#[cfg(target_os = "macos")]
|
|
|
|
|
let _ = window.set_simple_fullscreen(false);
|
|
|
|
|
let _ = window.hide();
|
|
|
|
|
}
|
|
|
|
|
if let Some(path) = source {
|
|
|
|
|
let _ = fs::remove_file(path);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[tauri::command]
|
|
|
|
|
pub fn get_capture_session(
|
|
|
|
|
state: State<'_, AppState>,
|
|
|
|
|
) -> Result<Option<CaptureSessionInfo>, String> {
|
|
|
|
|
Ok(state
|
|
|
|
|
.capture
|
|
|
|
|
.lock()
|
|
|
|
|
.map_err(|error| error.to_string())?
|
|
|
|
|
.clone())
|
|
|
|
|
}
|
|
|
|
|
|
2026-10-25 04:24:05 +00:00
|
|
|
/// Capture work runs off the main thread: freezing a screen, decoding the grab
|
|
|
|
|
/// and writing the crop all take longer than a frame budget.
|
2026-10-21 00:54:54 +00:00
|
|
|
#[tauri::command]
|
2026-10-25 04:24:05 +00:00
|
|
|
pub async fn start_capture(app: AppHandle, mode: String) -> Result<CaptureSessionInfo, String> {
|
|
|
|
|
tauri::async_runtime::spawn_blocking(move || begin_capture(&app, &mode))
|
|
|
|
|
.await
|
|
|
|
|
.map_err(|error| error.to_string())?
|
2026-10-21 00:54:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[tauri::command]
|
|
|
|
|
pub fn cancel_capture(app: AppHandle) -> Result<(), String> {
|
|
|
|
|
dismiss_capture(&app);
|
|
|
|
|
if let Some(window) = app.get_webview_window("main") {
|
|
|
|
|
let _ = window.show();
|
|
|
|
|
let _ = window.set_focus();
|
|
|
|
|
}
|
|
|
|
|
Ok(())
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[tauri::command]
|
2026-10-25 04:24:05 +00:00
|
|
|
pub async fn capture_crop(app: AppHandle, rect: NormalizedRect) -> Result<String, String> {
|
|
|
|
|
tauri::async_runtime::spawn_blocking(move || {
|
|
|
|
|
let state = app.state::<AppState>();
|
|
|
|
|
finish_capture(&app, &state, &rect)
|
|
|
|
|
})
|
|
|
|
|
.await
|
|
|
|
|
.map_err(|error| error.to_string())?
|
2026-10-21 00:54:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fn finish_capture(
|
|
|
|
|
app: &AppHandle,
|
|
|
|
|
state: &AppState,
|
|
|
|
|
rect: &NormalizedRect,
|
|
|
|
|
) -> Result<String, String> {
|
|
|
|
|
let output = crop_session(app, state, rect)?;
|
|
|
|
|
{
|
|
|
|
|
use tauri_plugin_clipboard_manager::ClipboardExt;
|
|
|
|
|
if let Ok(image) = tauri::image::Image::from_path(&output) {
|
|
|
|
|
let _ = app.clipboard().write_image(&image);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
dismiss_capture(app);
|
release: 0.1.1 — update channel, settings/UI trims, macOS + Windows x64 only
Update path
- `src-tauri/src/update.rs`: manifest fetch, semver compare, optional ed25519
signature check against a key baked in at build time, then a size + SHA256
gate before an installer can run. `UpdateStatus` now reports the artifact key
it resolved so the UI can name what it will install.
- Settings → Updates panel shows the feed, the check/download state machine, and
the local OS, architecture and release artifact for this machine.
- `scripts/publish-release.sh` + `scripts/release-key.py` publish installers and a
signed `shift-update.json` onto an orphan `releases` branch.
Scope trims requested for this release
- Settings: the Radial rings tab is gone, so ring orders are read from
`settings.json` with no in-app editor for now.
- Main window: the update entry in the header bar is gone; updates live in
Settings → Updates only.
- Release targets are macOS universal and Windows x64. ARM64 and Linux stay
buildable and are no longer published; `docs/RELEASE.md` records the decision.
Gates: cargo fmt --check clean, `cargo test --lib` 142 passed / 2 ignored,
`pnpm check` clean, `pnpm test` 34 passed, `pnpm build` ok.
2026-10-25 19:06:46 +00:00
|
|
|
hand_off(app, &output);
|
|
|
|
|
crate::history::publish_result(
|
|
|
|
|
app,
|
2026-10-21 00:54:54 +00:00
|
|
|
ActionOutcome {
|
|
|
|
|
outputs: vec![output.to_string_lossy().to_string()],
|
|
|
|
|
message: "Screenshot saved.".into(),
|
|
|
|
|
},
|
|
|
|
|
);
|
|
|
|
|
Ok(output.to_string_lossy().to_string())
|
|
|
|
|
}
|
|
|
|
|
|
release: 0.1.1 — update channel, settings/UI trims, macOS + Windows x64 only
Update path
- `src-tauri/src/update.rs`: manifest fetch, semver compare, optional ed25519
signature check against a key baked in at build time, then a size + SHA256
gate before an installer can run. `UpdateStatus` now reports the artifact key
it resolved so the UI can name what it will install.
- Settings → Updates panel shows the feed, the check/download state machine, and
the local OS, architecture and release artifact for this machine.
- `scripts/publish-release.sh` + `scripts/release-key.py` publish installers and a
signed `shift-update.json` onto an orphan `releases` branch.
Scope trims requested for this release
- Settings: the Radial rings tab is gone, so ring orders are read from
`settings.json` with no in-app editor for now.
- Main window: the update entry in the header bar is gone; updates live in
Settings → Updates only.
- Release targets are macOS universal and Windows x64. ARM64 and Linux stay
buildable and are no longer published; `docs/RELEASE.md` records the decision.
Gates: cargo fmt --check clean, `cargo test --lib` 142 passed / 2 ignored,
`pnpm check` clean, `pnpm test` 34 passed, `pnpm build` ok.
2026-10-25 19:06:46 +00:00
|
|
|
/// Route a finished capture per the Capture-after setting. The card is allowed to
|
|
|
|
|
/// fail silently: a screenshot that saved is more important than an overlay that
|
|
|
|
|
/// could not be built, and the file is already on disk and copied by then.
|
|
|
|
|
fn hand_off(app: &AppHandle, output: &Path) {
|
|
|
|
|
match settings::load(app).capture_after {
|
|
|
|
|
settings::CaptureAfter::Editor => {
|
|
|
|
|
let _ = editor::show_editor(app, output);
|
|
|
|
|
}
|
|
|
|
|
settings::CaptureAfter::Card => {
|
|
|
|
|
if result_card::show(app, output).is_err() {
|
|
|
|
|
let _ = editor::show_editor(app, output);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2026-10-21 00:54:54 +00:00
|
|
|
pub fn capture_fullscreen_core(app: &AppHandle, state: &AppState) -> Result<String, String> {
|
|
|
|
|
ensure_screen_capture_access()?;
|
|
|
|
|
for label in ["main", "radial", "editor"] {
|
|
|
|
|
if let Some(window) = app.get_webview_window(label) {
|
|
|
|
|
let _ = window.hide();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
std::thread::sleep(std::time::Duration::from_millis(90));
|
|
|
|
|
let monitor = monitor_at_cursor(app)?;
|
|
|
|
|
let source = capture_screen(app, &monitor)?;
|
|
|
|
|
*state.capture.lock().map_err(|error| error.to_string())? = Some(CaptureSessionInfo {
|
|
|
|
|
mode: "screenshot".into(),
|
|
|
|
|
source,
|
|
|
|
|
});
|
|
|
|
|
finish_capture(
|
|
|
|
|
app,
|
|
|
|
|
state,
|
|
|
|
|
&NormalizedRect {
|
|
|
|
|
x: 0.0,
|
|
|
|
|
y: 0.0,
|
|
|
|
|
width: 1.0,
|
|
|
|
|
height: 1.0,
|
|
|
|
|
},
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[tauri::command]
|
2026-10-25 04:24:05 +00:00
|
|
|
pub async fn capture_fullscreen(app: AppHandle) -> Result<String, String> {
|
|
|
|
|
let result = tauri::async_runtime::spawn_blocking(move || {
|
|
|
|
|
let state = app.state::<AppState>();
|
|
|
|
|
let result = capture_fullscreen_core(&app, &state);
|
|
|
|
|
if result.is_err() {
|
|
|
|
|
if let Some(window) = app.get_webview_window("main") {
|
|
|
|
|
let _ = window.show();
|
|
|
|
|
let _ = window.set_focus();
|
|
|
|
|
}
|
2026-10-21 00:54:54 +00:00
|
|
|
}
|
2026-10-25 04:24:05 +00:00
|
|
|
result
|
|
|
|
|
})
|
|
|
|
|
.await
|
|
|
|
|
.map_err(|error| error.to_string())?;
|
2026-10-21 00:54:54 +00:00
|
|
|
result
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[tauri::command]
|
2026-10-25 04:24:05 +00:00
|
|
|
pub async fn copy_file_to(source: String, destination: String) -> Result<(), String> {
|
|
|
|
|
tauri::async_runtime::spawn_blocking(move || {
|
|
|
|
|
fs::copy(Path::new(&source), Path::new(&destination))
|
|
|
|
|
.map(|_| ())
|
|
|
|
|
.map_err(|error| error.to_string())
|
|
|
|
|
})
|
|
|
|
|
.await
|
|
|
|
|
.map_err(|error| error.to_string())?
|
2026-10-21 00:54:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[tauri::command]
|
2026-10-25 04:24:05 +00:00
|
|
|
pub async fn open_screen_recording_settings() -> Result<(), String> {
|
|
|
|
|
tauri::async_runtime::spawn_blocking(open_screen_recording_settings_sync)
|
|
|
|
|
.await
|
|
|
|
|
.map_err(|error| error.to_string())?
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fn open_screen_recording_settings_sync() -> Result<(), String> {
|
2026-10-21 00:54:54 +00:00
|
|
|
#[cfg(target_os = "macos")]
|
|
|
|
|
{
|
2026-10-25 04:24:05 +00:00
|
|
|
let status = crate::process::command("/usr/bin/open")
|
2026-10-21 00:54:54 +00:00
|
|
|
.arg("x-apple.systempreferences:com.apple.preference.security?Privacy_ScreenCapture")
|
|
|
|
|
.status()
|
|
|
|
|
.map_err(|error| error.to_string())?;
|
|
|
|
|
if status.success() {
|
|
|
|
|
return Ok(());
|
|
|
|
|
}
|
|
|
|
|
return Err("Could not open Screen Recording settings.".into());
|
|
|
|
|
}
|
|
|
|
|
#[cfg(not(target_os = "macos"))]
|
|
|
|
|
{
|
|
|
|
|
Err("Screen Recording settings are macOS-specific.".into())
|
|
|
|
|
}
|
|
|
|
|
}
|