diff --git a/src/main.rs b/src/main.rs index afe2810..852bcc1 100644 --- a/src/main.rs +++ b/src/main.rs @@ -115,6 +115,12 @@ fn capture(cx: &mut App) { } state.capturing = true; let style = state.settings.style.clone(); + // Activating the app brings all of its windows forward, so close the ones a capture has no use for. + for window in cx.windows() { + if window.downcast::().is_some() || window.downcast::().is_some() { + window.update(cx, |_, window, _| window.remove_window()).ok(); + } + } // macOS only lets us take focus right after the user's key press. Take it now, so // focus comes back to us when screencapture exits and the editor opens in front. cx.activate(true); @@ -157,13 +163,7 @@ pub fn open_settings(cx: &mut App) { let handle = cx.open_window(options, |window, cx| { // Windows opens new windows behind the app in front. window.activate_window(); - let view = cx.new(|cx| SettingsView::new(window, cx)); - // Never leave the shortcut disabled because the window closed mid-recording. - window.on_window_should_close(cx, |_, cx| { - AppState::set_hotkey_enabled(true, cx); - true - }); - view + cx.new(|cx| SettingsView::new(window, cx)) }); cx.global_mut::().settings_window = handle.ok(); } diff --git a/src/settings.rs b/src/settings.rs index 5672c41..ae897f6 100644 --- a/src/settings.rs +++ b/src/settings.rs @@ -269,6 +269,8 @@ impl SettingsView { pub fn new(window: &mut Window, cx: &mut Context) -> Self { let focus = cx.focus_handle(); window.focus(&focus); + // However the window closes, never leave the shortcut disabled mid-recording. + cx.on_release(|_, cx| AppState::set_hotkey_enabled(true, cx)).detach(); Self { focus, tab: Tab::Appearance, recording: None, font_search: None, families: render::families(), preview: None } } diff --git a/src/welcome.rs b/src/welcome.rs index 87f8b7d..0739973 100644 --- a/src/welcome.rs +++ b/src/welcome.rs @@ -21,7 +21,7 @@ pub fn open(cx: &mut App) { .ok(); } -struct Welcome; +pub struct Welcome; impl Render for Welcome { fn render(&mut self, _: &mut Window, cx: &mut Context) -> impl IntoElement {