Skip to content

armgit / Cap

Public Imported from GitHub
0

Open source Loom alternative. Beautiful, shareable screen recordings.

fix(desktop-gpui): bring the screenshot editor to the front from a shortcut

Richie McIlroycebea076f23d
diff --git a/apps/desktop-gpui/src/app_windows.rs b/apps/desktop-gpui/src/app_windows.rs
index b3dfa6a11..d36d08c22 100644
--- a/apps/desktop-gpui/src/app_windows.rs
+++ b/apps/desktop-gpui/src/app_windows.rs
@@ -6524,10 +6524,11 @@ pub fn open_screenshot_editor(path: PathBuf, cx: &mut App) {
.update(cx, |_, window, _| platform::native_window(window))
.ok()
.flatten();
- cx.spawn(async move |_| {
+ cx.spawn(async move |cx| {
if let Some(native) = &native {
platform::show_native(native);
}
+ cx.update(|cx| bring_screenshot_editor_forward(handle, cx));
})
.detach();
hide_main_window(cx);
@@ -6594,10 +6595,25 @@ pub fn open_screenshot_editor(path: PathBuf, cx: &mut App) {
.ok();
hide_main_window(cx);
+ // A global shortcut fires while another app is frontmost, and a window
+ // opened by an inactive app lands behind that app's windows: the editor
+ // only showed up once Cap was clicked.
+ cx.defer(move |cx| bring_screenshot_editor_forward(handle, cx));
prewarm_shared_wgpu_device(cx);
screenshot_editor::load_screenshot_project(key, handle, cx);
}
+fn bring_screenshot_editor_forward(handle: WindowHandle<ScreenshotEditorWindow>, cx: &mut App) {
+ cx.activate(true);
+ handle
+ .update(cx, |_, window, cx| {
+ window.activate_window();
+ platform::kick_display_link(window);
+ cx.notify();
+ })
+ .ok();
+}
+
/// The screenshot editor's Delete finished: drop the window (its pending
/// write is for a bundle that no longer exists), refresh every surface that
/// lists screenshots, and run the ordinary closed bookkeeping.