fix batch: missing cancel_export, overlay lifecycle, audio safety, gif encoding, UI polish
- add cancel_export command with AtomicBool flag - shut down overlay clickthrough poll thread on app exit - move set_overlay_clickthrough after capture starts (not before) - add fps filter to capture pipeline to avoid bloated intermediate files - add scale.max(0.1) floor in gif balanced mode - warn when gif encode can't meet target after retries - increase update apply script timeout and add retry loop - add SAFETY comments to all 21 unsafe blocks in audio.rs - remove dead output_path variable in capture.rs - remove no-op gif_colors.min() call in encode retry - add error toast dismiss button with 8-second auto-dismiss - remove test fps values (1,2,5,10) from idle screen - add duplicate hotkey validation in settings - change picker window to 2560x1440 - add gitignore exception for src-tauri/gen/schemas/
This commit is contained in:
+23
-7
@@ -43,6 +43,7 @@ pub struct AppState {
|
||||
pub session: Mutex<Option<SessionState>>,
|
||||
pub picker: Mutex<Option<window_picker::PickerSession>>,
|
||||
pub overlay_poll_shutdown: Arc<AtomicBool>,
|
||||
pub export_cancel: Arc<AtomicBool>,
|
||||
pub overlay_aspect_ratio: Mutex<Option<f64>>,
|
||||
}
|
||||
|
||||
@@ -364,6 +365,8 @@ fn start_capture(
|
||||
)
|
||||
.map_err(|e| format!("{e:#}"))?;
|
||||
|
||||
set_overlay_clickthrough(&app, true);
|
||||
|
||||
let audio_session = if cfg.capture.capture_audio {
|
||||
let audio_path = audio_segment_path(&state.app_dir, 1);
|
||||
match audio::start(audio_path) {
|
||||
@@ -378,8 +381,6 @@ fn start_capture(
|
||||
None
|
||||
};
|
||||
|
||||
set_overlay_clickthrough(&app, true);
|
||||
|
||||
let (a_sr, a_ch) = audio_session
|
||||
.as_ref()
|
||||
.map(|s| (Some(s.sample_rate), Some(s.channels)))
|
||||
@@ -1313,6 +1314,11 @@ fn open_url(url: String) -> Result<(), String> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
fn cancel_export(state: State<'_, AppState>) {
|
||||
state.export_cancel.store(true, Ordering::SeqCst);
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
fn export(app: AppHandle, state: State<'_, AppState>, request: ExportRequest) -> Result<ExportResult, String> {
|
||||
let cfg = lock(&state.config).clone();
|
||||
@@ -1418,6 +1424,7 @@ fn export(app: AppHandle, state: State<'_, AppState>, request: ExportRequest) ->
|
||||
}
|
||||
});
|
||||
|
||||
state.export_cancel.store(false, Ordering::SeqCst);
|
||||
encode::transcode(&ffmpeg, &req_with_progress).map_err(|e| format!("{e:#}"))?;
|
||||
|
||||
let size_bytes = std::fs::metadata(&out_path)
|
||||
@@ -1438,8 +1445,8 @@ pub fn run() {
|
||||
if let Err(e) = std::fs::create_dir_all(&webview_dir) {
|
||||
tracing::warn!("creating webview data dir failed: {e}");
|
||||
} else {
|
||||
// SAFETY: must be called before any other code accesses environment;
|
||||
// here it's the first thing after dir resolution, before Tauri reads.
|
||||
// SAFETY: Must be called before Tauri reads the environment. No other threads exist yet.
|
||||
// set_var is deprecated in Rust 2024 edition; migrate when upgrading toolchain.
|
||||
unsafe {
|
||||
std::env::set_var("WEBVIEW2_USER_DATA_FOLDER", &webview_dir);
|
||||
}
|
||||
@@ -1460,10 +1467,11 @@ pub fn run() {
|
||||
session: Mutex::new(None),
|
||||
picker: Mutex::new(None),
|
||||
overlay_poll_shutdown: Arc::new(AtomicBool::new(false)),
|
||||
export_cancel: Arc::new(AtomicBool::new(false)),
|
||||
overlay_aspect_ratio: Mutex::new(None),
|
||||
};
|
||||
|
||||
tauri::Builder::default()
|
||||
let app = tauri::Builder::default()
|
||||
.plugin(tauri_plugin_dialog::init())
|
||||
.plugin(
|
||||
tauri_plugin_global_shortcut::Builder::new()
|
||||
@@ -1569,7 +1577,15 @@ pub fn run() {
|
||||
open_window_picker,
|
||||
close_window_picker,
|
||||
get_overlay_rect,
|
||||
cancel_export,
|
||||
])
|
||||
.run(tauri::generate_context!())
|
||||
.expect("error while running ByteSize")
|
||||
.build(tauri::generate_context!())
|
||||
.expect("error while building ByteSize");
|
||||
app.run(|_app: &AppHandle, event| {
|
||||
if let tauri::RunEvent::Exit = event {
|
||||
if let Some(st) = _app.try_state::<AppState>() {
|
||||
st.overlay_poll_shutdown.store(true, Ordering::SeqCst);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user