@@ -901,6 +901,12 @@ pub struct RequestOpenRecordingPicker {
901901 pub target_mode : Option < RecordingTargetMode > ,
902902}
903903
904+ #[ derive( Deserialize , specta:: Type , Serialize , tauri_specta:: Event , Debug , Clone ) ]
905+ pub struct RequestSetTargetMode {
906+ pub target_mode : Option < RecordingTargetMode > ,
907+ pub display_id : Option < String > ,
908+ }
909+
904910#[ derive( Deserialize , specta:: Type , Serialize , tauri_specta:: Event , Debug , Clone ) ]
905911pub struct RequestOpenSettings {
906912 page : String ,
@@ -2533,6 +2539,39 @@ async fn update_auth_plan(app: AppHandle) {
25332539 AuthStore :: update_auth_plan ( & app) . await . ok ( ) ;
25342540}
25352541
2542+ pub async fn open_target_picker (
2543+ app : & tauri:: AppHandle ,
2544+ target_mode : recording_settings:: RecordingTargetMode ,
2545+ ) {
2546+ use tauri:: Manager ;
2547+
2548+ if let Some ( window) = CapWindowId :: Main . get ( app) {
2549+ window. hide ( ) . ok ( ) ;
2550+ }
2551+
2552+ let prewarmed = app. state :: < target_select_overlay:: PrewarmedOverlays > ( ) ;
2553+ let state = app. state :: < target_select_overlay:: WindowFocusManager > ( ) ;
2554+ let display_id = scap_targets:: Display :: get_containing_cursor ( ) . map ( |d| d. id ( ) . to_string ( ) ) ;
2555+
2556+ let _ = target_select_overlay:: open_target_select_overlays (
2557+ app. clone ( ) ,
2558+ state,
2559+ prewarmed,
2560+ None ,
2561+ display_id. clone ( ) ,
2562+ Some ( target_mode) ,
2563+ )
2564+ . await ;
2565+
2566+ tokio:: time:: sleep ( std:: time:: Duration :: from_millis ( 100 ) ) . await ;
2567+
2568+ let _ = RequestSetTargetMode {
2569+ target_mode : Some ( target_mode) ,
2570+ display_id,
2571+ }
2572+ . emit ( app) ;
2573+ }
2574+
25362575type FilteredRegistry = tracing_subscriber:: layer:: Layered <
25372576 tracing_subscriber:: filter:: FilterFn < fn ( m : & tracing:: Metadata ) -> bool > ,
25382577 tracing_subscriber:: Registry ,
@@ -2650,6 +2689,7 @@ pub async fn run(recording_logging_handle: LoggingHandle, logs_dir: PathBuf) {
26502689 captions:: check_model_exists,
26512690 captions:: delete_whisper_model,
26522691 captions:: export_captions_srt,
2692+ target_select_overlay:: prewarm_target_select_overlays,
26532693 target_select_overlay:: open_target_select_overlays,
26542694 target_select_overlay:: close_target_select_overlays,
26552695 target_select_overlay:: update_camera_overlay_bounds,
@@ -2673,6 +2713,7 @@ pub async fn run(recording_logging_handle: LoggingHandle, logs_dir: PathBuf) {
26732713 RecordingStopped ,
26742714 RequestStartRecording ,
26752715 RequestOpenRecordingPicker ,
2716+ RequestSetTargetMode ,
26762717 RequestOpenSettings ,
26772718 RequestScreenCapturePrewarm ,
26782719 NewNotification ,
@@ -2820,6 +2861,7 @@ pub async fn run(recording_logging_handle: LoggingHandle, logs_dir: PathBuf) {
28202861 general_settings:: init ( & app) ;
28212862 fake_window:: init ( & app) ;
28222863 app. manage ( target_select_overlay:: WindowFocusManager :: default ( ) ) ;
2864+ app. manage ( target_select_overlay:: PrewarmedOverlays :: default ( ) ) ;
28232865 app. manage ( EditorWindowIds :: default ( ) ) ;
28242866 app. manage ( ScreenshotEditorWindowIds :: default ( ) ) ;
28252867 #[ cfg( target_os = "macos" ) ]
@@ -2831,6 +2873,19 @@ pub async fn run(recording_logging_handle: LoggingHandle, logs_dir: PathBuf) {
28312873
28322874 gpu_context:: prewarm_gpu ( ) ;
28332875
2876+ tokio:: spawn ( {
2877+ let app = app. clone ( ) ;
2878+ async move {
2879+ tokio:: time:: sleep ( std:: time:: Duration :: from_millis ( 500 ) ) . await ;
2880+ let prewarmed = app. state :: < target_select_overlay:: PrewarmedOverlays > ( ) ;
2881+ let _ = target_select_overlay:: prewarm_target_select_overlays (
2882+ app. clone ( ) ,
2883+ prewarmed,
2884+ )
2885+ . await ;
2886+ }
2887+ } ) ;
2888+
28342889 tokio:: spawn ( {
28352890 let camera_feed = camera_feed. clone ( ) ;
28362891 let app = app. clone ( ) ;
@@ -2988,11 +3043,15 @@ pub async fn run(recording_logging_handle: LoggingHandle, logs_dir: PathBuf) {
29883043 } ) ;
29893044
29903045 RequestOpenRecordingPicker :: listen_any_spawn ( & app, async |event, app| {
2991- let _ = ShowCapWindow :: Main {
2992- init_target_mode : event. target_mode ,
3046+ if let Some ( target_mode) = event. target_mode {
3047+ open_target_picker ( & app, target_mode) . await ;
3048+ } else {
3049+ let _ = ShowCapWindow :: Main {
3050+ init_target_mode : None ,
3051+ }
3052+ . show ( & app)
3053+ . await ;
29933054 }
2994- . show ( & app)
2995- . await ;
29963055 } ) ;
29973056
29983057 RequestOpenSettings :: listen_any_spawn ( & app, async |payload, app| {
0 commit comments