Open source Loom alternative. Beautiful, shareable screen recordings.
Rust appcapcossloommacnextjsnextjs15open-sourceossreactrecordrustscreen-capturescreen-recorderscreenshotsolidjstauritauri-apptypescriptvite
Focus aware Windows titlebar
Ilya780942dd872e
diff --git a/apps/desktop/src/components/titlebar/controls/CaptionControlsWindows11.tsx b/apps/desktop/src/components/titlebar/controls/CaptionControlsWindows11.tsxindex 20c970532..bff87474c 100644--- a/apps/desktop/src/components/titlebar/controls/CaptionControlsWindows11.tsx+++ b/apps/desktop/src/components/titlebar/controls/CaptionControlsWindows11.tsx@@ -1,4 +1,4 @@-import { type ComponentProps, type JSX, Show, splitProps } from "solid-js";+import { type ComponentProps, createSignal, type JSX, onCleanup, onMount, Show, splitProps } from "solid-js";import { WindowControlButton as ControlButton } from "./WindowControlButton";import { getCurrentWindow } from "@tauri-apps/api/window";import titlebarState from "~/utils/titlebar-state";@@ -6,18 +6,32 @@ import { cx } from "cva";export default function (props: ComponentProps<"div">) {const [local, otherProps] = splitProps(props, ["class"]);- const window = getCurrentWindow();+ const currentWindow = getCurrentWindow();+ const [focused, setFocus] = createSignal(true);++ let unlisten: () => void | undefined;+ onMount(async () => {+ unlisten = await currentWindow.onFocusChanged(({ payload: focused }) => setFocus(focused));+ });+ onCleanup(() => unlisten?.());return (<div- class={`h-full align-baseline cursor-default rounded-none select-none *:outline-none *:transition-all *:duration-200 ${local.class}`}+ class={cx(+ "h-full align-baseline cursor-default rounded-none select-none *:outline-none *:transition-all *:duration-200",+ local.class,+ focused() ? "*:text-black-transparent-80" : "*:text-black-transparent-40"+ )}+ style={{+ "font-family": "Segoe Fluent Icons', 'Segoe MDL2 Assets"+ }}{...otherProps}><ControlButtondisabled={!titlebarState.minimizable}- onClick={titlebarState.minimizable ? window.minimize : undefined}+ onClick={titlebarState.minimizable ? currentWindow.minimize : undefined}class={cx(- "max-h-20 w-[46px] rounded-none bg-transparent text-black-transparent-80",+ "max-h-20 w-[46px] rounded-none bg-transparent","hover:bg-[#0000000D] dark:hover:bg-[#FFFFFF0D] active:bg-[#00000008] dark:active:bg-[#e9e9e908]","disabled:hover:bg-transparent dark:disabled:hover:bg-transparent disabled:text-black-transparent-40",)}@@ -30,12 +44,12 @@ export default function (props: ComponentProps<"div">) {onClick={titlebarState.maximizable? titlebarState.maximized- ? window.unmaximize- : window.maximize+ ? currentWindow.unmaximize+ : currentWindow.maximize: undefined}class={cx(- "max-h-20 w-[46px] rounded-none bg-transparent text-black-transparent-80",+ "max-h-20 w-[46px] rounded-none bg-transparent","hover:bg-[#0000000D] dark:hover:bg-[#FFFFFF0D] active:bg-[#00000008] dark:active:bg-[#e9e9e908]","disabled:hover:bg-transparent dark:disabled:hover:bg-transparent disabled:text-black-transparent-40",)}@@ -48,10 +62,10 @@ export default function (props: ComponentProps<"div">) {</ControlButton></Show><ControlButton- onClick={titlebarState.closable ? window.close : undefined}+ onClick={titlebarState.closable ? currentWindow.close : undefined}disabled={!titlebarState.closable}class={cx(- "max-h-20 w-[46px] rounded-none bg-transparent text-black-transparent-80 hover:text-gray-50",+ "max-h-20 w-[46px] rounded-none bg-transparent hover:text-gray-50","hover:bg-[#c42b1c] dark:hover:bg-[#c42b1c active:bg-[#c42b1c]/90 dark:active:bg-[#c42b1c]/90","disabled:hover:bg-transparent dark:disabled:hover:bg-transparent disabled:text-black-transparent-40",)}