From d4dfc1c820b3987a8eb53785a1500d66c031b1de Mon Sep 17 00:00:00 2001 From: Peiman Nourani Date: Tue, 3 Dec 2024 18:38:01 +0330 Subject: [PATCH] Hide window controls in macOS fullscreen mode (#134) --- src-web/components/HeaderSize.tsx | 6 ++++-- src-web/components/WindowControls.tsx | 5 +++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src-web/components/HeaderSize.tsx b/src-web/components/HeaderSize.tsx index 0a5745ca..3d010693 100644 --- a/src-web/components/HeaderSize.tsx +++ b/src-web/components/HeaderSize.tsx @@ -2,6 +2,7 @@ import classNames from 'classnames'; import type { HTMLAttributes, ReactNode } from 'react'; import React from 'react'; import { useSettings } from '../hooks/useSettings'; +import { useOsInfo } from '../hooks/useOsInfo'; import { useStoplightsVisible } from '../hooks/useStoplightsVisible'; import { WINDOW_CONTROLS_WIDTH, WindowControls } from './WindowControls'; @@ -23,6 +24,7 @@ export function HeaderSize({ onlyXWindowControl, children, }: HeaderSizeProps) { + const osInfo = useOsInfo(); const settings = useSettings(); const stoplightsVisible = useStoplightsVisible(); return ( @@ -36,7 +38,7 @@ export function HeaderSize({ ...(size === 'lg' ? { height: HEADER_SIZE_LG } : {}), ...(stoplightsVisible || ignoreControlsSpacing ? { paddingRight: '2px' } - : { paddingLeft: '2px', paddingRight: WINDOW_CONTROLS_WIDTH }), + : { paddingLeft: '2px', paddingRight: osInfo.osType !== 'macos' ? WINDOW_CONTROLS_WIDTH : '2px' }), }} className={classNames( className, @@ -48,7 +50,7 @@ export function HeaderSize({
{children}
- + ); } diff --git a/src-web/components/WindowControls.tsx b/src-web/components/WindowControls.tsx index 365e944c..0ed21717 100644 --- a/src-web/components/WindowControls.tsx +++ b/src-web/components/WindowControls.tsx @@ -8,18 +8,19 @@ import { HStack } from './core/Stacks'; interface Props { className?: string; onlyX?: boolean; + macos?: boolean; } export const WINDOW_CONTROLS_WIDTH = '10.5rem'; -export function WindowControls({ className, onlyX }: Props) { +export function WindowControls({ className, onlyX, macos }: Props) { const [maximized, setMaximized] = useState(false); const stoplightsVisible = useStoplightsVisible(); if (stoplightsVisible) { return null; } - return ( + return !macos && (