Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::<welcome::Welcome>().is_some() || window.downcast::<SettingsView>().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);
Expand Down Expand Up @@ -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::<AppState>().settings_window = handle.ok();
}
Expand Down
2 changes: 2 additions & 0 deletions src/settings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,8 @@ impl SettingsView {
pub fn new(window: &mut Window, cx: &mut Context<Self>) -> 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 }
}

Expand Down
2 changes: 1 addition & 1 deletion src/welcome.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Self>) -> impl IntoElement {
Expand Down
Loading