Skip to content

armgit / Cap

Public Imported from GitHub
0

Open source Loom alternative. Beautiful, shareable screen recordings.

Hide window when recording starts

Ilya840cae6878f4
diff --git a/apps/desktop/src-tauri/src/main.rs b/apps/desktop/src-tauri/src/main.rs
index 9feb3a2fb..caa0009e4 100644
--- a/apps/desktop/src-tauri/src/main.rs
+++ b/apps/desktop/src-tauri/src/main.rs
@@ -163,7 +163,7 @@ fn main() {
};
let tray_menu = SystemTrayMenu::new()
- .add_item(CustomMenuItem::new("toggle-window", "Show Cap"))
+ .add_item(CustomMenuItem::new("show-window", "Show Cap"))
.add_native_item(tauri::SystemTrayMenuItem::Separator)
.add_item(
CustomMenuItem::new("quit".to_string(), "Quit")
@@ -237,8 +237,10 @@ fn main() {
.system_tray(tray)
.on_system_tray_event(move |app, event| match event {
SystemTrayEvent::MenuItemClick { id, .. } => match id.as_str() {
- "toggle-window" => {
-
+ "show-window" => {
+ let window = app.get_window("main").expect("Error while trying to get the main window.");
+ window.show().unwrap();
+ window.set_focus().unwrap();
}
"quit" => {
app.exit(0);
diff --git a/apps/desktop/src/components/windows/inner/Recorder.tsx b/apps/desktop/src/components/windows/inner/Recorder.tsx
index c8a96871b..7b3eb9864 100644
--- a/apps/desktop/src/components/windows/inner/Recorder.tsx
+++ b/apps/desktop/src/components/windows/inner/Recorder.tsx
@@ -17,7 +17,7 @@ import toast, { Toaster } from "react-hot-toast";
import { authFetch } from "@/utils/auth/helpers";
import { appDataDir, join } from "@tauri-apps/api/path";
import { open } from "@tauri-apps/api/shell";
-import { window } from "@tauri-apps/api";
+import * as Tauri from "@tauri-apps/api";
declare global {
interface Window {
@@ -146,7 +146,7 @@ export const Recorder = () => {
handleStopAllRecordings();
}
- const currentWindow = window.getCurrent();
+ const currentWindow = Tauri.window.getCurrent();
if (!currentWindow.isVisible) {
currentWindow.show();
}
@@ -180,6 +180,9 @@ export const Recorder = () => {
if (window.fathom !== undefined) {
window.fathom.trackEvent("start_recording");
}
+ Tauri.window.getAll().forEach((window) => {
+ window.hide();
+ });
await invoke("start_dual_recording", {
options: {
user_id: videoData.user_id,