mirror of
https://github.com/zen-browser/desktop.git
synced 2025-10-05 09:26:34 +00:00
Fixed common issues with workspaces and the new empty tab
This commit is contained in:
@@ -631,6 +631,7 @@ class ZenViewSplitter extends ZenDOMOperatedFeature {
|
|||||||
* @param {string} gridType - The type of grid layout.
|
* @param {string} gridType - The type of grid layout.
|
||||||
*/
|
*/
|
||||||
splitTabs(tabs, gridType) {
|
splitTabs(tabs, gridType) {
|
||||||
|
tabs = tabs.filter((tab) => !tab.hasAttribute("zen-empty-tab"));
|
||||||
if (tabs.length < 2) {
|
if (tabs.length < 2) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@@ -50,10 +50,12 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
function openWelcomeTab() {
|
function openWelcomeTab() {
|
||||||
|
const currentSelectedTab = window.gBrowser.selectedTab;
|
||||||
const tab = window.gBrowser.addTrustedTab('https://zen-browser.app/welcome', {
|
const tab = window.gBrowser.addTrustedTab('https://zen-browser.app/welcome', {
|
||||||
inBackground: true,
|
inBackground: true,
|
||||||
});
|
});
|
||||||
gBrowser.selectedTab = tab;
|
gBrowser.selectedTab = tab;
|
||||||
|
gBrowser.removeTab(currentSelectedTab);
|
||||||
}
|
}
|
||||||
|
|
||||||
class ZenWelcomePages {
|
class ZenWelcomePages {
|
||||||
@@ -425,6 +427,8 @@
|
|||||||
});
|
});
|
||||||
gZenPinnedTabManager.addToEssentials(createdTab);
|
gZenPinnedTabManager.addToEssentials(createdTab);
|
||||||
}
|
}
|
||||||
|
openInitialPinTab();
|
||||||
|
openWelcomeTab();
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -513,8 +517,6 @@
|
|||||||
centerWindowOnScreen();
|
centerWindowOnScreen();
|
||||||
initializeZenWelcome();
|
initializeZenWelcome();
|
||||||
animateInitialStage();
|
animateInitialStage();
|
||||||
openInitialPinTab();
|
|
||||||
openWelcomeTab();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
startZenWelcome();
|
startZenWelcome();
|
||||||
|
@@ -115,19 +115,16 @@ var ZenWorkspaces = new (class extends ZenMultiWindowFeature {
|
|||||||
}
|
}
|
||||||
|
|
||||||
selectEmptyTab() {
|
selectEmptyTab() {
|
||||||
if (this._emptyTab) {
|
if (this._emptyTab && Services.prefs.getBoolPref('zen.urlbar.replace-newtab')) {
|
||||||
if (!Services.prefs.getBoolPref('zen.urlbar.replace-newtab')) {
|
gBrowser.selectedTab = this._emptyTab;
|
||||||
|
return this._emptyTab;
|
||||||
|
}
|
||||||
let tab = gZenUIManager.openAndChangeToTab(Services.prefs.getStringPref('browser.startup.homepage'));
|
let tab = gZenUIManager.openAndChangeToTab(Services.prefs.getStringPref('browser.startup.homepage'));
|
||||||
if (window.uuid) {
|
if (window.uuid) {
|
||||||
tab.setAttribute('zen-workspace-id', this.activeWorkspace);
|
tab.setAttribute('zen-workspace-id', this.activeWorkspace);
|
||||||
}
|
}
|
||||||
return tab;
|
return tab;
|
||||||
}
|
}
|
||||||
gBrowser.selectedTab = this._emptyTab;
|
|
||||||
return this._emptyTab;
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
async delayedStartup() {
|
async delayedStartup() {
|
||||||
if (!this.workspaceEnabled) {
|
if (!this.workspaceEnabled) {
|
||||||
@@ -176,15 +173,11 @@ var ZenWorkspaces = new (class extends ZenMultiWindowFeature {
|
|||||||
}
|
}
|
||||||
|
|
||||||
get tabboxChildren() {
|
get tabboxChildren() {
|
||||||
const childs = Array.from(this.tabboxChildrenWithoutEmpty);
|
return Array.from(this.activeWorkspaceStrip?.children || []);
|
||||||
if (this._emptyTab) {
|
|
||||||
childs.unshift(this._emptyTab);
|
|
||||||
}
|
|
||||||
return childs;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
get tabboxChildrenWithoutEmpty() {
|
get tabboxChildrenWithoutEmpty() {
|
||||||
return this.activeWorkspaceStrip?.children || [];
|
return this.tabboxChildren.filter((child) => !child.hasAttribute('zen-empty-tab'));
|
||||||
}
|
}
|
||||||
|
|
||||||
get pinnedTabsContainer() {
|
get pinnedTabsContainer() {
|
||||||
@@ -1494,11 +1487,11 @@ var ZenWorkspaces = new (class extends ZenMultiWindowFeature {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// First pass: Handle tab visibility and workspace ID assignment
|
// First pass: Handle tab visibility and workspace ID assignment
|
||||||
this._processTabVisibility(window.uuid, containerId, workspaces);
|
const prevTabUsed = this._processTabVisibility(window.uuid, containerId, workspaces);
|
||||||
|
|
||||||
// Second pass: Handle tab selection
|
// Second pass: Handle tab selection
|
||||||
this.tabContainer._invalidateCachedTabs();
|
this.tabContainer._invalidateCachedTabs();
|
||||||
const tabToSelect = await this._handleTabSelection(window, onInit, containerId, workspaces, previousWorkspace.uuid);
|
const tabToSelect = await this._handleTabSelection(window, onInit, containerId, workspaces, previousWorkspace.uuid, prevTabUsed);
|
||||||
|
|
||||||
// Update UI and state
|
// Update UI and state
|
||||||
await this._updateWorkspaceState(window, onInit, tabToSelect);
|
await this._updateWorkspaceState(window, onInit, tabToSelect);
|
||||||
@@ -1616,16 +1609,19 @@ var ZenWorkspaces = new (class extends ZenMultiWindowFeature {
|
|||||||
// If there's no more visible tabs, make a new tab visible
|
// If there's no more visible tabs, make a new tab visible
|
||||||
// or if ALL the visible tabs are essentials or we have our selected
|
// or if ALL the visible tabs are essentials or we have our selected
|
||||||
// tab hidden, select a new tab
|
// tab hidden, select a new tab
|
||||||
|
let prevTabUsed = null;
|
||||||
if (
|
if (
|
||||||
hiddenTabs.length === visibleTabs.length ||
|
hiddenTabs.length === visibleTabs.length ||
|
||||||
visibleTabs.every((tab) => tab.getAttribute('zen-essential') === 'true') ||
|
visibleTabs.every((tab) => tab.getAttribute('zen-essential') === 'true') ||
|
||||||
hiddenTabs.includes(gBrowser.selectedTab)
|
hiddenTabs.includes(gBrowser.selectedTab)
|
||||||
) {
|
) {
|
||||||
|
prevTabUsed = gBrowser.selectedTab;
|
||||||
this.selectEmptyTab();
|
this.selectEmptyTab();
|
||||||
}
|
}
|
||||||
for (const tab of hiddenTabs) {
|
for (const tab of hiddenTabs) {
|
||||||
gBrowser.hideTab(tab, undefined, true);
|
gBrowser.hideTab(tab, undefined, true);
|
||||||
}
|
}
|
||||||
|
return prevTabUsed;
|
||||||
}
|
}
|
||||||
|
|
||||||
_shouldShowTab(tab, workspaceUuid, containerId, workspaces) {
|
_shouldShowTab(tab, workspaceUuid, containerId, workspaces) {
|
||||||
@@ -1664,8 +1660,8 @@ var ZenWorkspaces = new (class extends ZenMultiWindowFeature {
|
|||||||
return tabWorkspaceId === workspaceUuid;
|
return tabWorkspaceId === workspaceUuid;
|
||||||
}
|
}
|
||||||
|
|
||||||
async _handleTabSelection(window, onInit, containerId, workspaces, previousWorkspaceId) {
|
async _handleTabSelection(window, onInit, containerId, workspaces, previousWorkspaceId, prevTabUsed) {
|
||||||
const currentSelectedTab = gBrowser.selectedTab;
|
const currentSelectedTab = prevTabUsed || gBrowser.selectedTab;
|
||||||
const oldWorkspaceId = previousWorkspaceId;
|
const oldWorkspaceId = previousWorkspaceId;
|
||||||
const lastSelectedTab = this._lastSelectedWorkspaceTabs[window.uuid];
|
const lastSelectedTab = this._lastSelectedWorkspaceTabs[window.uuid];
|
||||||
|
|
||||||
@@ -1739,6 +1735,14 @@ var ZenWorkspaces = new (class extends ZenMultiWindowFeature {
|
|||||||
|
|
||||||
// Update workspace indicator
|
// Update workspace indicator
|
||||||
await this.updateWorkspaceIndicator(window, this.workspaceIndicator);
|
await this.updateWorkspaceIndicator(window, this.workspaceIndicator);
|
||||||
|
|
||||||
|
// Fix ctrl+tab behavior. Note, we dont call it with "await" because we dont want to wait for it
|
||||||
|
this._fixCtrlTabBehavior();
|
||||||
|
}
|
||||||
|
|
||||||
|
async _fixCtrlTabBehavior() {
|
||||||
|
ctrlTab.uninit();
|
||||||
|
ctrlTab.readPref();
|
||||||
}
|
}
|
||||||
|
|
||||||
_invalidateBookmarkContainers() {
|
_invalidateBookmarkContainers() {
|
||||||
@@ -1912,6 +1916,7 @@ var ZenWorkspaces = new (class extends ZenMultiWindowFeature {
|
|||||||
const contaienr = document.querySelector(
|
const contaienr = document.querySelector(
|
||||||
`#vertical-pinned-tabs-container .zen-workspace-tabs-section[zen-workspace-id="${workspaceId}"]`
|
`#vertical-pinned-tabs-container .zen-workspace-tabs-section[zen-workspace-id="${workspaceId}"]`
|
||||||
);
|
);
|
||||||
|
console.log(tab)
|
||||||
contaienr.insertBefore(tab, contaienr.firstChild);
|
contaienr.insertBefore(tab, contaienr.firstChild);
|
||||||
changed = true;
|
changed = true;
|
||||||
}
|
}
|
||||||
@@ -1981,6 +1986,10 @@ var ZenWorkspaces = new (class extends ZenMultiWindowFeature {
|
|||||||
this._contextMenuId = null;
|
this._contextMenuId = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
findTabToBlur(tab) {
|
||||||
|
return (tab.hasAttribute('zen-essential') && this._emptyTab) ? this._emptyTab : tab;
|
||||||
|
}
|
||||||
|
|
||||||
async setDefaultWorkspace() {
|
async setDefaultWorkspace() {
|
||||||
await ZenWorkspacesStorage.setDefaultWorkspace(this._contextMenuId);
|
await ZenWorkspacesStorage.setDefaultWorkspace(this._contextMenuId);
|
||||||
await this._propagateWorkspaceData();
|
await this._propagateWorkspaceData();
|
||||||
@@ -2157,7 +2166,7 @@ var ZenWorkspaces = new (class extends ZenMultiWindowFeature {
|
|||||||
// Session restore functions
|
// Session restore functions
|
||||||
get allStoredTabs() {
|
get allStoredTabs() {
|
||||||
if (!this._hasInitializedTabsStrip) {
|
if (!this._hasInitializedTabsStrip) {
|
||||||
const children = Array.from(this.tabboxChildren);
|
const children = this.tabboxChildren;
|
||||||
children.pop(); // Remove the last child which is the new tab button
|
children.pop(); // Remove the last child which is the new tab button
|
||||||
return children;
|
return children;
|
||||||
}
|
}
|
||||||
|
@@ -0,0 +1,13 @@
|
|||||||
|
diff --git a/browser/components/tabbrowser/content/browser-ctrlTab.js b/browser/components/tabbrowser/content/browser-ctrlTab.js
|
||||||
|
index e5d16e605b7edf11fc9f52b93e415087b76398f1..feb7ccfc0562efda56177a75454a9f83a332e8d1 100644
|
||||||
|
--- a/browser/components/tabbrowser/content/browser-ctrlTab.js
|
||||||
|
+++ b/browser/components/tabbrowser/content/browser-ctrlTab.js
|
||||||
|
@@ -761,7 +761,7 @@ var ctrlTab = {
|
||||||
|
_initRecentlyUsedTabs() {
|
||||||
|
this._recentlyUsedTabs = Array.prototype.filter.call(
|
||||||
|
gBrowser.tabs,
|
||||||
|
- tab => !tab.closing && !tab.hidden
|
||||||
|
+ tab => !tab.closing && !tab.hidden && !tab.hasAttribute("zen-empty-tab")
|
||||||
|
);
|
||||||
|
this._sortRecentlyUsedTabs();
|
||||||
|
},
|
@@ -1,5 +1,5 @@
|
|||||||
diff --git a/browser/components/tabbrowser/content/tabbrowser.js b/browser/components/tabbrowser/content/tabbrowser.js
|
diff --git a/browser/components/tabbrowser/content/tabbrowser.js b/browser/components/tabbrowser/content/tabbrowser.js
|
||||||
index ff90a70bdad6c94ec4b90027ff102972d0eb28e5..cb4a77fa5992b9890dfc55cb3c3c558d07912bb1 100644
|
index ff90a70bdad6c94ec4b90027ff102972d0eb28e5..5ae4351d7438c0e03c0a24551c910d43a2c676bd 100644
|
||||||
--- a/browser/components/tabbrowser/content/tabbrowser.js
|
--- a/browser/components/tabbrowser/content/tabbrowser.js
|
||||||
+++ b/browser/components/tabbrowser/content/tabbrowser.js
|
+++ b/browser/components/tabbrowser/content/tabbrowser.js
|
||||||
@@ -406,11 +406,52 @@
|
@@ -406,11 +406,52 @@
|
||||||
@@ -365,6 +365,24 @@ index ff90a70bdad6c94ec4b90027ff102972d0eb28e5..cb4a77fa5992b9890dfc55cb3c3c558d
|
|||||||
if (!this._windowIsClosing) {
|
if (!this._windowIsClosing) {
|
||||||
if (wasPinned) {
|
if (wasPinned) {
|
||||||
this.tabContainer._positionPinnedTabs();
|
this.tabContainer._positionPinnedTabs();
|
||||||
|
@@ -5025,7 +5132,7 @@
|
||||||
|
!excludeTabs.has(aTab.owner) &&
|
||||||
|
Services.prefs.getBoolPref("browser.tabs.selectOwnerOnClose")
|
||||||
|
) {
|
||||||
|
- return aTab.owner;
|
||||||
|
+ return ZenWorkspaces.findTabToBlur(aTab.owner);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Try to find a remaining tab that comes after the given tab
|
||||||
|
@@ -5047,7 +5154,7 @@
|
||||||
|
}
|
||||||
|
|
||||||
|
if (tab) {
|
||||||
|
- return tab;
|
||||||
|
+ return ZenWorkspaces.findTabToBlur(tab);
|
||||||
|
}
|
||||||
|
|
||||||
|
// If no qualifying visible tab was found, see if there is a tab in
|
||||||
@@ -5465,10 +5572,10 @@
|
@@ -5465,10 +5572,10 @@
|
||||||
SessionStore.deleteCustomTabValue(aTab, "hiddenBy");
|
SessionStore.deleteCustomTabValue(aTab, "hiddenBy");
|
||||||
}
|
}
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
diff --git a/browser/components/tabbrowser/content/tabs.js b/browser/components/tabbrowser/content/tabs.js
|
diff --git a/browser/components/tabbrowser/content/tabs.js b/browser/components/tabbrowser/content/tabs.js
|
||||||
index 8aeb244ffca9f48661805f5b7d860b5896055562..b2e3b6c9c37eb1a070bbea72d629f9f72676f5bf 100644
|
index 8aeb244ffca9f48661805f5b7d860b5896055562..c96e563a31b4c32c855cc2d250d702361b427f88 100644
|
||||||
--- a/browser/components/tabbrowser/content/tabs.js
|
--- a/browser/components/tabbrowser/content/tabs.js
|
||||||
+++ b/browser/components/tabbrowser/content/tabs.js
|
+++ b/browser/components/tabbrowser/content/tabs.js
|
||||||
@@ -94,7 +94,7 @@
|
@@ -94,7 +94,7 @@
|
||||||
@@ -151,6 +151,15 @@ index 8aeb244ffca9f48661805f5b7d860b5896055562..b2e3b6c9c37eb1a070bbea72d629f9f7
|
|||||||
return children.filter(node => node.tagName == "tab-group");
|
return children.filter(node => node.tagName == "tab-group");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -1540,7 +1568,7 @@
|
||||||
|
*/
|
||||||
|
get visibleTabs() {
|
||||||
|
if (!this.#visibleTabs) {
|
||||||
|
- this.#visibleTabs = this.openTabs.filter(tab => tab.visible);
|
||||||
|
+ this.#visibleTabs = this.openTabs.filter(tab => tab.visible && !tab.hasAttribute("zen-empty-tab"));
|
||||||
|
}
|
||||||
|
return this.#visibleTabs;
|
||||||
|
}
|
||||||
@@ -1574,10 +1602,8 @@
|
@@ -1574,10 +1602,8 @@
|
||||||
return this.#focusableItems;
|
return this.#focusableItems;
|
||||||
}
|
}
|
||||||
@@ -160,7 +169,7 @@ index 8aeb244ffca9f48661805f5b7d860b5896055562..b2e3b6c9c37eb1a070bbea72d629f9f7
|
|||||||
- );
|
- );
|
||||||
- let children = Array.from(this.arrowScrollbox.children);
|
- let children = Array.from(this.arrowScrollbox.children);
|
||||||
+ let verticalPinnedTabsContainer = this.verticalPinnedTabsContainer;
|
+ let verticalPinnedTabsContainer = this.verticalPinnedTabsContainer;
|
||||||
+ let children = Array.from(ZenWorkspaces.tabboxChildrenWithoutEmpty);
|
+ let children = ZenWorkspaces.tabboxChildrenWithoutEmpty;
|
||||||
|
|
||||||
let focusableItems = [];
|
let focusableItems = [];
|
||||||
for (let child of children) {
|
for (let child of children) {
|
||||||
|
Reference in New Issue
Block a user