{ let (display_width, display_height) = largest_monitor_size(); let (physical_width, physical_height) = largest_monitor_physical_size(); { let mut state = state.borrow_mut(); state.set_breakout_display_size(display_width, display_height); state.set_breakout_limit_size(physical_width, physical_height); } let view = build_launcher_view(app, server_addr.as_ref(), &catalog.borrow(), &state.borrow()); let window = view.window.clone(); let (launcher_width, launcher_height) = launcher_default_size(display_width, display_height); window.set_default_size(launcher_width, launcher_height); let server_entry = view.server_entry.clone(); let camera_combo = view.camera_combo.clone(); let camera_quality_combo = view.camera_quality_combo.clone(); let microphone_combo = view.microphone_combo.clone(); let speaker_combo = view.speaker_combo.clone(); let keyboard_combo = view.keyboard_combo.clone(); let mouse_combo = view.mouse_combo.clone(); let widgets = view.widgets.clone(); let preview = view.preview.clone(); let popouts = Rc::clone(&view.popouts); let diagnostics_popout = Rc::clone(&view.diagnostics_popout); let log_popout = Rc::clone(&view.log_popout); let shutdown_cleaned = Rc::new(Cell::new(false)); let camera_quality_syncing = Rc::new(Cell::new(false)); { let shutdown_cleaned = Rc::clone(&shutdown_cleaned); let app = app.clone(); let child_proc = Rc::clone(&child_proc); let tests = Rc::clone(&tests); let preview = preview.clone(); let widgets = widgets.clone(); let popouts = Rc::clone(&popouts); let diagnostics_popout = Rc::clone(&diagnostics_popout); let log_popout = Rc::clone(&log_popout); window.connect_close_request(move |_| { if !shutdown_cleaned.replace(true) { shutdown_launcher_runtime( &child_proc, &tests, preview.as_deref(), &widgets, &popouts, &diagnostics_popout, &log_popout, ); } let app = app.clone(); glib::idle_add_local_once(move || { app.quit(); }); glib::Propagation::Stop }); } { let shutdown_cleaned = Rc::clone(&shutdown_cleaned); let child_proc = Rc::clone(&child_proc); let tests = Rc::clone(&tests); let preview = preview.clone(); let widgets = widgets.clone(); let popouts = Rc::clone(&popouts); let diagnostics_popout = Rc::clone(&diagnostics_popout); let log_popout = Rc::clone(&log_popout); app.connect_shutdown(move |_| { if !shutdown_cleaned.replace(true) { shutdown_launcher_runtime( &child_proc, &tests, preview.as_deref(), &widgets, &popouts, &diagnostics_popout, &log_popout, ); } }); } { let mut tests = tests.borrow_mut(); if let Err(err) = tests.bind_camera_preview( &view.device_stage.camera_preview, &view.device_stage.camera_status, ) { widgets .status_label .set_text(&format!("Camera preview setup failed: {err}")); } if let Err(err) = tests.set_camera_selection(state.borrow().devices.camera.as_deref()) { widgets .status_label .set_text(&format!("Camera staging setup failed: {err}")); } if let Err(err) = tests.set_camera_quality(state.borrow().camera_quality) { widgets .status_label .set_text(&format!("Camera quality staging setup failed: {err}")); } } refresh_launcher_ui(&widgets, &state.borrow(), child_proc.borrow().is_some()); refresh_test_buttons(&widgets, &mut tests.borrow_mut()); let (power_tx, power_rx) = std::sync::mpsc::channel::(); let power_request_in_flight = Rc::new(Cell::new(false)); let (calibration_tx, calibration_rx) = std::sync::mpsc::channel::(); let calibration_request_in_flight = Rc::new(Cell::new(false)); let (upstream_sync_tx, upstream_sync_rx) = std::sync::mpsc::channel::(); let upstream_sync_request_in_flight = Rc::new(Cell::new(false)); let (relay_tx, relay_rx) = std::sync::mpsc::channel::(); let relay_request_in_flight = Rc::new(Cell::new(false)); let (caps_tx, caps_rx) = std::sync::mpsc::channel::(); let caps_request_in_flight = Rc::new(Cell::new(false)); let diagnostics_network = Rc::new(RefCell::new(NetworkTelemetry::default())); let diagnostics_process = Rc::new(RefCell::new(ProcessCpuSampler::new())); let disconnect_cooldown_until = Rc::new(Cell::new(None)); let next_power_probe = Rc::new(Cell::new(Instant::now() + Duration::from_millis(500))); let next_calibration_probe = Rc::new(Cell::new(Instant::now() + Duration::from_millis(650))); let next_upstream_sync_probe = Rc::new(Cell::new(Instant::now() + Duration::from_millis(750))); let next_diagnostics_probe = Rc::new(Cell::new(Instant::now() + Duration::from_millis(250))); let next_diagnostics_sample = Rc::new(Cell::new(Instant::now() + Duration::from_secs(1))); let preview_session_active = Rc::new(Cell::new(false)); let (clipboard_tx, clipboard_rx) = std::sync::mpsc::channel::(); let (log_tx, log_rx) = std::sync::mpsc::channel::(); if let Some(preview) = preview.as_ref() { preview.set_log_sink(log_tx.clone()); sync_preview_profiles(preview, &widgets, &popouts, &state.borrow()); } ActivationContext { window, launcher_size: (launcher_width, launcher_height), server_entry, camera_combo, camera_quality_combo, microphone_combo, speaker_combo, keyboard_combo, mouse_combo, widgets, preview, popouts, diagnostics_popout, log_popout, camera_quality_syncing, power_tx, power_rx, power_request_in_flight, calibration_tx, calibration_rx, calibration_request_in_flight, upstream_sync_tx, upstream_sync_rx, upstream_sync_request_in_flight, relay_tx, relay_rx, relay_request_in_flight, caps_tx, caps_rx, caps_request_in_flight, diagnostics_network, diagnostics_process, disconnect_cooldown_until, next_power_probe, next_calibration_probe, next_upstream_sync_probe, next_diagnostics_probe, next_diagnostics_sample, preview_session_active, clipboard_tx, clipboard_rx, log_tx, log_rx, } }