From d9417a9aa993a823de76ebaa933a9872dff74739 Mon Sep 17 00:00:00 2001 From: "mr. M" Date: Sat, 4 Jan 2025 21:45:30 +0100 Subject: [PATCH] Refactor tab handling and URL bar behavior for improved visibility and interaction in Zen mode --- .../content/zen-styles/zen-compact-mode.css | 2 +- .../tabbrowser/content/tabs-js.patch | 32 ++++++++++++++++++- .../urlbar/UrlbarInput-sys-mjs.patch | 18 +++++++---- 3 files changed, 43 insertions(+), 9 deletions(-) diff --git a/src/browser/base/content/zen-styles/zen-compact-mode.css b/src/browser/base/content/zen-styles/zen-compact-mode.css index d87f0f1ec..7970e3bcd 100644 --- a/src/browser/base/content/zen-styles/zen-compact-mode.css +++ b/src/browser/base/content/zen-styles/zen-compact-mode.css @@ -212,7 +212,7 @@ & #zen-appcontent-navbar-container:focus-within, & #zen-appcontent-navbar-container[zen-user-show], & #zen-appcontent-navbar-container[has-popup-menu], - & #zen-appcontent-navbar-container:has(*[panelopen='true'], [open='true']) { + & #zen-appcontent-navbar-container:has(*:is([panelopen='true'], [open='true']):not(.zen-compact-mode-ignore)) { opacity: 1; border-top-width: 1px; diff --git a/src/browser/components/tabbrowser/content/tabs-js.patch b/src/browser/components/tabbrowser/content/tabs-js.patch index 9f4dbc947..d7b754e4a 100644 --- a/src/browser/components/tabbrowser/content/tabs-js.patch +++ b/src/browser/components/tabbrowser/content/tabs-js.patch @@ -1,5 +1,5 @@ diff --git a/browser/components/tabbrowser/content/tabs.js b/browser/components/tabbrowser/content/tabs.js -index f7c39fe804182e2bdf53045ba3b6a5ba17079fc3..84359791101c500ed354da8d0b4bf3c7e8be4563 100644 +index f7c39fe804182e2bdf53045ba3b6a5ba17079fc3..8b594d9d13b60c51c6f9306e28178e75b5f49782 100644 --- a/browser/components/tabbrowser/content/tabs.js +++ b/browser/components/tabbrowser/content/tabs.js @@ -649,7 +649,7 @@ @@ -11,6 +11,15 @@ index f7c39fe804182e2bdf53045ba3b6a5ba17079fc3..84359791101c500ed354da8d0b4bf3c7 let tabsPerRow = 0; let position = 0; for (let pinnedTab of pinnedTabs) { +@@ -997,7 +997,7 @@ + } + } else { + let pinned = draggedTab.pinned; +- let numPinned = gBrowser.pinnedTabCount; ++ let numPinned = gBrowser._numVisiblePinTabs; + let tabs = this.visibleTabs.slice( + pinned ? 0 : numPinned, + pinned ? numPinned : undefined @@ -1076,7 +1076,7 @@ let postTransitionCleanup = () => { tab.removeAttribute("tabdrop-samewindow"); @@ -67,6 +76,15 @@ index f7c39fe804182e2bdf53045ba3b6a5ba17079fc3..84359791101c500ed354da8d0b4bf3c7 ); } +@@ -1778,7 +1780,7 @@ + let rect = ele => { + return window.windowUtils.getBoundsWithoutFlushing(ele); + }; +- let tab = this.visibleTabs[gBrowser.pinnedTabCount]; ++ let tab = this.visibleTabs[gBrowser._numVisiblePinTabs]; + if (tab && rect(tab).width <= this._tabClipWidth) { + this.setAttribute("closebuttons", "activetab"); + } else { @@ -1790,10 +1792,12 @@ _handleTabSelect(aInstant) { @@ -158,6 +176,18 @@ index f7c39fe804182e2bdf53045ba3b6a5ba17079fc3..84359791101c500ed354da8d0b4bf3c7 return; } +@@ -2622,9 +2626,9 @@ + function newIndex(aTab, index) { + // Don't allow mixing pinned and unpinned tabs. + if (aTab.pinned) { +- return Math.min(index, gBrowser.pinnedTabCount - 1); ++ return Math.min(index, gBrowser._numVisiblePinTabs - 1); + } +- return Math.max(index, gBrowser.pinnedTabCount); ++ return Math.max(index, gBrowser._numVisiblePinTabs); + } + } + @@ -2726,12 +2730,14 @@ selectedTab = { left: selectedTab.left, diff --git a/src/browser/components/urlbar/UrlbarInput-sys-mjs.patch b/src/browser/components/urlbar/UrlbarInput-sys-mjs.patch index fe5db0871..699763ba2 100644 --- a/src/browser/components/urlbar/UrlbarInput-sys-mjs.patch +++ b/src/browser/components/urlbar/UrlbarInput-sys-mjs.patch @@ -1,8 +1,8 @@ diff --git a/browser/components/urlbar/UrlbarInput.sys.mjs b/browser/components/urlbar/UrlbarInput.sys.mjs -index c504c9afc43785b5f003bb1f9f1dfbddef38d78b..b08cb1d9fee5f76070c70ea928209b15b6146cb3 100644 +index 3ab07e5864b3bb200608e7f619645f92ade129fe..12fe08c48d5ca9f00253e0aa6ebbc867ff471c83 100644 --- a/browser/components/urlbar/UrlbarInput.sys.mjs +++ b/browser/components/urlbar/UrlbarInput.sys.mjs -@@ -65,6 +65,13 @@ XPCOMUtils.defineLazyPreferenceGetter( +@@ -67,6 +67,13 @@ XPCOMUtils.defineLazyPreferenceGetter( false ); @@ -16,17 +16,21 @@ index c504c9afc43785b5f003bb1f9f1dfbddef38d78b..b08cb1d9fee5f76070c70ea928209b15 const DEFAULT_FORM_HISTORY_NAME = "searchbar-history"; const SEARCH_BUTTON_CLASS = "urlbar-search-button"; -@@ -2154,6 +2161,9 @@ export class UrlbarInput { +@@ -2152,6 +2159,13 @@ export class UrlbarInput { this.setAttribute("breakout-extend", "true"); + if (lazy.ZEN_URLBAR_BEHAVIOR == 'float' || (lazy.ZEN_URLBAR_BEHAVIOR == 'floating-on-type' && !this.focusedViaMousedown)) { + this.setAttribute("zen-floating-urlbar", "true"); -+ } else this.removeAttribute("zen-floating-urlbar"); ++ this.classList.add("zen-floating-urlbar"); ++ } else { ++ this.removeAttribute("zen-floating-urlbar"); ++ this.classList.remove("zen-floating-urlbar"); ++ } // Enable the animation only after the first extend call to ensure it // doesn't run when opening a new window. if (!this.hasAttribute("breakout-extend-animate")) { -@@ -3901,6 +3911,11 @@ export class UrlbarInput { +@@ -3875,6 +3889,11 @@ export class UrlbarInput { } _on_click(event) { @@ -38,7 +42,7 @@ index c504c9afc43785b5f003bb1f9f1dfbddef38d78b..b08cb1d9fee5f76070c70ea928209b15 if ( event.target == this.inputField || event.target == this._inputContainer || -@@ -4012,9 +4027,12 @@ export class UrlbarInput { +@@ -3986,9 +4005,12 @@ export class UrlbarInput { } _on_mousedown(event) { @@ -52,7 +56,7 @@ index c504c9afc43785b5f003bb1f9f1dfbddef38d78b..b08cb1d9fee5f76070c70ea928209b15 if ( event.target != this.inputField && -@@ -4024,8 +4042,8 @@ export class UrlbarInput { +@@ -3998,8 +4020,8 @@ export class UrlbarInput { break; }