diff --git a/application/state/useWindowControls.ts b/application/state/useWindowControls.ts index defe3c8aa..0c4487c7e 100644 --- a/application/state/useWindowControls.ts +++ b/application/state/useWindowControls.ts @@ -40,6 +40,16 @@ export const useWindowControls = () => { return bridge?.windowIsMaximized?.(); }, []); + const isFullscreen = useCallback(async () => { + const bridge = netcattyBridge.get(); + return bridge?.windowIsFullscreen?.() ?? false; + }, []); + + const onFullscreenChanged = useCallback((cb: (isFullscreen: boolean) => void) => { + const bridge = netcattyBridge.get(); + return bridge?.onWindowFullScreenChanged?.(cb) ?? (() => {}); + }, []); + return { notifyRendererReady, closeSettingsWindow, @@ -48,6 +58,7 @@ export const useWindowControls = () => { maximize, close, isMaximized, + isFullscreen, + onFullscreenChanged, }; }; - diff --git a/components/TopTabs.tsx b/components/TopTabs.tsx index ac6ed5d22..3d6c47321 100644 --- a/components/TopTabs.tsx +++ b/components/TopTabs.tsx @@ -132,7 +132,7 @@ const TopTabsInner: React.FC = ({ }) => { const { t } = useI18n(); // Subscribe to activeTabId from external store - const { maximize } = useWindowControls(); + const { maximize, isFullscreen, onFullscreenChanged } = useWindowControls(); const activeTabId = useActiveTabId(); const isVaultActive = activeTabId === 'vault'; const isSftpActive = activeTabId === 'sftp'; @@ -142,6 +142,20 @@ const TopTabsInner: React.FC = ({ const [dropIndicator, setDropIndicator] = useState<{ tabId: string; position: 'before' | 'after' } | null>(null); const [isDraggingForReorder, setIsDraggingForReorder] = useState(false); const draggedTabIdRef = useRef(null); + const [isWindowFullscreen, setIsWindowFullscreen] = useState(false); + + useEffect(() => { + if (!isMacClient) return; + let cancelled = false; + isFullscreen().then((value) => { + if (!cancelled) setIsWindowFullscreen(!!value); + }); + const unsubscribe = onFullscreenChanged((value) => setIsWindowFullscreen(!!value)); + return () => { + cancelled = true; + unsubscribe(); + }; + }, [isFullscreen, isMacClient, onFullscreenChanged]); // Refs for scrollable tab container const tabsContainerRef = useRef(null); @@ -512,7 +526,7 @@ const TopTabsInner: React.FC = ({
{/* Fixed left tabs: Vaults and SFTP */}
diff --git a/electron/bridges/windowManager.cjs b/electron/bridges/windowManager.cjs index f2cbb6a1c..afac9303c 100644 --- a/electron/bridges/windowManager.cjs +++ b/electron/bridges/windowManager.cjs @@ -323,6 +323,14 @@ async function createWindow(electronModule, options) { mainWindow = win; + win.on("enter-full-screen", () => { + win.webContents?.send("netcatty:window:fullscreen-changed", true); + }); + + win.on("leave-full-screen", () => { + win.webContents?.send("netcatty:window:fullscreen-changed", false); + }); + // Ensure native background matches frontend background, even before first paint. try { win.setBackgroundColor(backgroundColor); @@ -399,6 +407,14 @@ async function openSettingsWindow(electronModule, options) { settingsWindow = win; + win.on("enter-full-screen", () => { + win.webContents?.send("netcatty:window:fullscreen-changed", true); + }); + + win.on("leave-full-screen", () => { + win.webContents?.send("netcatty:window:fullscreen-changed", false); + }); + // Ensure native background matches frontend background, even before first paint. try { win.setBackgroundColor(backgroundColor); @@ -497,6 +513,14 @@ function registerWindowHandlers(ipcMain, nativeTheme) { return false; }); + ipcMain.handle("netcatty:window:isFullscreen", (event) => { + const win = getWindowForIpcEvent(event); + if (win && !win.isDestroyed()) { + return win.isFullScreen(); + } + return false; + }); + ipcMain.handle("netcatty:setTheme", (_event, theme) => { currentTheme = theme; nativeTheme.themeSource = theme; diff --git a/electron/preload.cjs b/electron/preload.cjs index 09dbd82c4..0c8a6eef0 100644 --- a/electron/preload.cjs +++ b/electron/preload.cjs @@ -8,6 +8,7 @@ const transferErrorListeners = new Map(); const chainProgressListeners = new Map(); const authFailedListeners = new Map(); const languageChangeListeners = new Set(); +const fullscreenChangeListeners = new Set(); ipcRenderer.on("netcatty:data", (_event, payload) => { const set = dataListeners.get(payload.sessionId); @@ -59,6 +60,16 @@ ipcRenderer.on("netcatty:languageChanged", (_event, language) => { }); }); +ipcRenderer.on("netcatty:window:fullscreen-changed", (_event, isFullscreen) => { + fullscreenChangeListeners.forEach((cb) => { + try { + cb(isFullscreen); + } catch (err) { + console.error("Fullscreen changed callback failed", err); + } + }); +}); + // Authentication failed events @@ -343,6 +354,11 @@ const api = { windowMaximize: () => ipcRenderer.invoke("netcatty:window:maximize"), windowClose: () => ipcRenderer.invoke("netcatty:window:close"), windowIsMaximized: () => ipcRenderer.invoke("netcatty:window:isMaximized"), + windowIsFullscreen: () => ipcRenderer.invoke("netcatty:window:isFullscreen"), + onWindowFullScreenChanged: (cb) => { + fullscreenChangeListeners.add(cb); + return () => fullscreenChangeListeners.delete(cb); + }, // Settings window openSettingsWindow: () => ipcRenderer.invoke("netcatty:settings:open"), diff --git a/global.d.ts b/global.d.ts index 8887d37f6..7375633ad 100644 --- a/global.d.ts +++ b/global.d.ts @@ -227,6 +227,8 @@ interface NetcattyBridge { windowMaximize?(): Promise; windowClose?(): Promise; windowIsMaximized?(): Promise; + windowIsFullscreen?(): Promise; + onWindowFullScreenChanged?(cb: (isFullscreen: boolean) => void): () => void; // Settings window openSettingsWindow?(): Promise; diff --git a/public/icon.png b/public/icon.png index 0a1c1dd3b..55834e4bd 100644 Binary files a/public/icon.png and b/public/icon.png differ diff --git a/public/logo.svg b/public/logo.svg index 502abcc57..368d7ea6b 100644 --- a/public/logo.svg +++ b/public/logo.svg @@ -1 +1,38 @@ - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +