Skip to content
Open
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
19 changes: 19 additions & 0 deletions apps/desktop/src-tauri/src/platform/macos/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,25 @@ pub fn set_window_level(window: tauri::Window, level: objc2_app_kit::NSWindowLev
});
}

pub fn set_window_visible_on_all_workspaces(window: tauri::Window) {
use objc2_app_kit::NSWindowCollectionBehavior;

let c_window = window.clone();
_ = window.run_on_main_thread(move || unsafe {
let ns_win = c_window
.ns_window()
.expect("Failed to get native window handle")
as *const objc2_app_kit::NSWindow;
let current_behavior = (*ns_win).collectionBehavior();
(*ns_win).setCollectionBehavior(
current_behavior
| NSWindowCollectionBehavior::CanJoinAllSpaces
| NSWindowCollectionBehavior::FullScreenAuxiliary
| NSWindowCollectionBehavior::Stationary,
);
});
}

// pub fn get_ns_window_number(ns_window: *mut c_void) -> isize {
// let ns_window = ns_window as *const objc2_app_kit::NSWindow;

Expand Down
37 changes: 21 additions & 16 deletions apps/desktop/src-tauri/src/windows.rs
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ impl CapWindowId {
Self::Main => (300.0, 360.0),
Self::Editor { .. } => (1275.0, 800.0),
Self::ScreenshotEditor { .. } => (800.0, 600.0),
Self::Settings => (600.0, 450.0),
Self::Settings => (600.0, 470.0),
Self::Camera => (200.0, 200.0),
Self::Upgrade => (950.0, 850.0),
Self::ModeSelect => (900.0, 500.0),
Expand Down Expand Up @@ -317,7 +317,12 @@ impl ShowCapWindow {

if new_recording_flow {
#[cfg(target_os = "macos")]
crate::platform::set_window_level(window.as_ref().window(), 50);
{
crate::platform::set_window_level(window.as_ref().window(), 50);
crate::platform::set_window_visible_on_all_workspaces(
window.as_ref().window(),
);
}
}

#[cfg(target_os = "macos")]
Expand Down Expand Up @@ -412,6 +417,7 @@ impl ShowCapWindow {
#[cfg(target_os = "macos")]
{
crate::platform::set_window_level(window.as_ref().window(), 45);
crate::platform::set_window_visible_on_all_workspaces(window.as_ref().window());
}

window
Expand Down Expand Up @@ -585,16 +591,9 @@ impl ShowCapWindow {
#[cfg(target_os = "macos")]
{
crate::platform::set_window_level(window.as_ref().window(), 60);

_ = window.run_on_main_thread({
let window = window.as_ref().window();
move || unsafe {
let win = window.ns_window().unwrap() as *const objc2_app_kit::NSWindow;
(*win).setCollectionBehavior(
(*win).collectionBehavior() | objc2_app_kit::NSWindowCollectionBehavior::FullScreenAuxiliary,
);
}
});
crate::platform::set_window_visible_on_all_workspaces(
window.as_ref().window(),
);
}

window
Expand Down Expand Up @@ -640,6 +639,7 @@ impl ShowCapWindow {
#[cfg(target_os = "macos")]
{
crate::platform::set_window_level(window.as_ref().window(), 900);
crate::platform::set_window_visible_on_all_workspaces(window.as_ref().window());
}

window
Expand All @@ -655,6 +655,7 @@ impl ShowCapWindow {
.shadow(false)
.resizable(false)
.always_on_top(true)
.visible_on_all_workspaces(true)
.content_protected(should_protect)
.skip_taskbar(true)
.closable(true)
Expand Down Expand Up @@ -682,10 +683,13 @@ impl ShowCapWindow {
let window = window_builder.build()?;

#[cfg(target_os = "macos")]
crate::platform::set_window_level(
window.as_ref().window(),
objc2_app_kit::NSPopUpMenuWindowLevel,
);
{
crate::platform::set_window_level(
window.as_ref().window(),
objc2_app_kit::NSPopUpMenuWindowLevel,
);
crate::platform::set_window_visible_on_all_workspaces(window.as_ref().window());
}

// Hide the main window if the target monitor is the same
if let Some(main_window) = CapWindowId::Main.get(app)
Expand Down Expand Up @@ -731,6 +735,7 @@ impl ShowCapWindow {
#[cfg(target_os = "macos")]
{
crate::platform::set_window_level(window.as_ref().window(), 1000);
crate::platform::set_window_visible_on_all_workspaces(window.as_ref().window());
}

fake_window::spawn_fake_window_listener(app.clone(), window.clone());
Expand Down
6 changes: 4 additions & 2 deletions apps/desktop/src/routes/(window-chrome)/(main).tsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,12 @@ function Page() {
const currentRecording = createCurrentRecordingQuery();
const generalSettings = generalSettingsStore.createQuery();

// We do this on focus so the window doesn't get revealed when toggling the setting
const navigate = useNavigate();
createEventListener(window, "focus", () => {
if (generalSettings.data?.enableNewRecordingFlow === true)
if (
window.location.pathname === "/" &&
generalSettings.data?.enableNewRecordingFlow === true
)
navigate("/new-main");
});

Expand Down
6 changes: 5 additions & 1 deletion apps/desktop/src/routes/(window-chrome)/new-main/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,11 @@ export default function () {

const navigate = useNavigate();
createEventListener(window, "focus", () => {
if (generalSettings.data?.enableNewRecordingFlow === false) navigate("/");
if (
window.location.pathname === "/new-main" &&
generalSettings.data?.enableNewRecordingFlow === false
)
navigate("/");
});

return (
Expand Down
28 changes: 14 additions & 14 deletions apps/desktop/src/routes/(window-chrome)/settings/general.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -153,9 +153,9 @@ function AppearanceSection(props: {
return (
<div class="flex flex-col gap-4">
<div class="flex flex-col pb-4 border-b border-gray-2">
<h2 class="text-lg font-medium text-gray-12">General</h2>
<h2 class="text-lg font-medium text-gray-12">General Settings</h2>
<p class="text-sm text-gray-10">
General settings of your Cap application.
Customize how Cap looks, feels, and behaves.
</p>
</div>
<div
Expand Down Expand Up @@ -419,18 +419,6 @@ function Inner(props: { initialStore: GeneralSettingsStore | null }) {
}}
/>

<SettingGroup
title="Cap Pro"
titleStyling="bg-blue-500 py-1.5 mb-4 text-white text-xs px-2 rounded-lg"
>
<ToggleSettingItem
label="Automatically open shareable links"
description="Whether Cap should automatically open instant recordings in your browser"
value={!settings.disableAutoOpenLinks}
onChange={(v) => handleChange("disableAutoOpenLinks", !v)}
/>
</SettingGroup>

{ostype === "macos" && (
<SettingGroup title="App">
<ToggleSettingItem
Expand Down Expand Up @@ -574,6 +562,18 @@ function Inner(props: { initialStore: GeneralSettingsStore | null }) {
/>
</SettingGroup>

<SettingGroup
title="Cap Pro Specific"
titleStyling="bg-blue-500 py-1.5 mb-4 text-white text-xs px-2 rounded-lg"
>
<ToggleSettingItem
label="Automatically open shareable links"
description="Whether Cap should automatically open instant recordings in your browser"
value={!settings.disableAutoOpenLinks}
onChange={(v) => handleChange("disableAutoOpenLinks", !v)}
/>
</SettingGroup>

<DefaultProjectNameCard
onChange={(value) =>
handleChange("defaultProjectNameTemplate", value)
Expand Down
5 changes: 4 additions & 1 deletion apps/desktop/src/routes/in-progress-recording.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -527,7 +527,10 @@ export default function () {
};

return (
<div class="flex h-full w-full flex-col justify-end px-3 pb-3">
<div
class="flex h-full w-full flex-col justify-end px-3 pb-3"
onContextMenu={(e) => e.preventDefault()}
>
<div ref={setInteractiveAreaRef} class="flex w-full flex-col gap-2">
<Show when={hasRecordingIssue() && issuePanelVisible()}>
<div class="flex w-full flex-row items-start gap-3 rounded-2xl border border-red-8 bg-gray-1 px-4 py-3 text-[12px] leading-snug text-red-11 shadow-lg">
Expand Down
Loading