From c3a43cba3ed48464f6472503940365a88c3b644f Mon Sep 17 00:00:00 2001 From: _Kerman Date: Sat, 2 May 2026 23:15:23 +0800 Subject: [PATCH] Add preference to show/hide browser toolbar --- .../Core/iTermBrowserViewController.swift | 22 +++++++++++-------- sources/Settings/Profiles/ITAddressBookMgr.h | 1 + sources/Settings/iTermProfilePreferences.m | 2 ++ 3 files changed, 16 insertions(+), 9 deletions(-) diff --git a/sources/Browser/Core/iTermBrowserViewController.swift b/sources/Browser/Core/iTermBrowserViewController.swift index b700c0df00..c512ecf761 100644 --- a/sources/Browser/Core/iTermBrowserViewController.swift +++ b/sources/Browser/Core/iTermBrowserViewController.swift @@ -844,19 +844,23 @@ extension iTermBrowserViewController { private func layoutSubviews() { let bounds = view.bounds - + // Background view - full coverage backgroundView.frame = bounds - - // Toolbar - top, full width, 44pt height - toolbar.frame = NSRect(x: 0, y: bounds.height - 44, - width: bounds.width, height: 44) - - // WebView - below toolbar + + let showToolbar = profileObserver.value(KEY_BROWSER_SHOW_TOOLBAR) == true + let toolbarHeight: CGFloat = showToolbar ? 44 : 0 + toolbar.isHidden = !showToolbar + + // Toolbar - top, full width + toolbar.frame = NSRect(x: 0, y: bounds.height - toolbarHeight, + width: bounds.width, height: toolbarHeight) + + // WebView - below toolbar (full height when toolbar is hidden) browserManager.webView.frame = NSRect(x: 0, y: 0, width: bounds.width, - height: bounds.height - 44) - + height: bounds.height - toolbarHeight) + // Shade view - full coverage shadeView.frame = bounds } diff --git a/sources/Settings/Profiles/ITAddressBookMgr.h b/sources/Settings/Profiles/ITAddressBookMgr.h index 43ab3f2b5f..d508ab7fba 100644 --- a/sources/Settings/Profiles/ITAddressBookMgr.h +++ b/sources/Settings/Profiles/ITAddressBookMgr.h @@ -195,6 +195,7 @@ // Web #define KEY_BROWSER_ZOOM @"Browser Zoom" // 100 = 100% #define KEY_BROWSER_DEV_NULL @"Dev Null Mode" +#define KEY_BROWSER_SHOW_TOOLBAR @"Browser Show Toolbar" // bool #define KEY_BROWSER_EXTENSIONS_ROOT @"Browser Extensions Root" #define KEY_BROWSER_EXTENSION_ACTIVE_IDS @"Browser Extension Active IDs" #define KEY_INSTANT_REPLAY @"Instant Replay" diff --git a/sources/Settings/iTermProfilePreferences.m b/sources/Settings/iTermProfilePreferences.m index 50225a66d0..efb5e3bb28 100644 --- a/sources/Settings/iTermProfilePreferences.m +++ b/sources/Settings/iTermProfilePreferences.m @@ -358,6 +358,7 @@ + (iTermProfilePreferencesKeyFuncs)keyFuncs { KEY_DYNAMIC_PROFILE_REWRITABLE, KEY_DYNAMIC_PROFILE, KEY_BROWSER_DEV_NULL, + KEY_BROWSER_SHOW_TOOLBAR, KEY_INSTANT_REPLAY, ]; NSArray *number = @[ @@ -1169,6 +1170,7 @@ + (NSDictionary *)defaultValueMap { KEY_BROWSER_ZOOM: @100, KEY_BROWSER_DEV_NULL: @NO, + KEY_BROWSER_SHOW_TOOLBAR: @YES, KEY_BROWSER_EXTENSIONS_ROOT: [NSNull null], KEY_BROWSER_EXTENSION_ACTIVE_IDS: @[], KEY_WIDTH: @1000,