forked from ZenBrowserMirrors/zen-desktop
feat: Only dispatch elements to the tab browser if we are on the active workspace, b=(no-bug), c=workspaces
This commit is contained in:
parent
b03cdba607
commit
be55a26a94
2 changed files with 44 additions and 12 deletions
|
@ -57,9 +57,9 @@
|
||||||
false
|
false
|
||||||
);
|
);
|
||||||
|
|
||||||
this.scrollbox.addEventListener('wheel', gBrowser.tabContainer, true);
|
this.scrollbox.addEventListener('wheel', this, true);
|
||||||
this.scrollbox.addEventListener('underflow', gBrowser.tabContainer);
|
this.scrollbox.addEventListener('underflow', this);
|
||||||
this.scrollbox.addEventListener('overflow', gBrowser.tabContainer);
|
this.scrollbox.addEventListener('overflow', this);
|
||||||
|
|
||||||
this.scrollbox._getScrollableElements = () => {
|
this.scrollbox._getScrollableElements = () => {
|
||||||
const children = [...this.pinnedTabsContainer.children, ...this.tabsContainer.children];
|
const children = [...this.pinnedTabsContainer.children, ...this.tabsContainer.children];
|
||||||
|
@ -122,6 +122,8 @@
|
||||||
this.tabsContainer.setAttribute('zen-workspace-id', this.id);
|
this.tabsContainer.setAttribute('zen-workspace-id', this.id);
|
||||||
this.pinnedTabsContainer.setAttribute('zen-workspace-id', this.id);
|
this.pinnedTabsContainer.setAttribute('zen-workspace-id', this.id);
|
||||||
|
|
||||||
|
this.#updateOverflow();
|
||||||
|
|
||||||
this.dispatchEvent(
|
this.dispatchEvent(
|
||||||
new CustomEvent('ZenWorkspaceAttached', {
|
new CustomEvent('ZenWorkspaceAttached', {
|
||||||
bubbles: true,
|
bubbles: true,
|
||||||
|
@ -130,6 +132,42 @@
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get active() {
|
||||||
|
return this.hasAttribute('active');
|
||||||
|
}
|
||||||
|
|
||||||
|
set active(value) {
|
||||||
|
if (value) {
|
||||||
|
this.setAttribute('active', 'true');
|
||||||
|
} else {
|
||||||
|
this.removeAttribute('active');
|
||||||
|
}
|
||||||
|
this.#updateOverflow();
|
||||||
|
}
|
||||||
|
|
||||||
|
#updateOverflow() {
|
||||||
|
if (!this.scrollbox) return;
|
||||||
|
if (this.overflows) {
|
||||||
|
this.#dispatchEventFromScrollbox('overflow');
|
||||||
|
} else {
|
||||||
|
this.#dispatchEventFromScrollbox('underflow');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#dispatchEventFromScrollbox(type) {
|
||||||
|
this.scrollbox.dispatchEvent(new CustomEvent(type, {}));
|
||||||
|
}
|
||||||
|
|
||||||
|
get overflows() {
|
||||||
|
return this.scrollbox.overflowing;
|
||||||
|
}
|
||||||
|
|
||||||
|
handleEvent(event) {
|
||||||
|
if (this.active) {
|
||||||
|
gBrowser.tabContainer.handleEvent(event);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
customElements.define('zen-workspace', ZenWorkspace);
|
customElements.define('zen-workspace', ZenWorkspace);
|
||||||
|
|
|
@ -446,7 +446,7 @@ var gZenWorkspaces = new (class extends ZenMultiWindowFeature {
|
||||||
const container = document.getElementById('tabbrowser-arrowscrollbox');
|
const container = document.getElementById('tabbrowser-arrowscrollbox');
|
||||||
workspaceWrapper.id = workspace.uuid;
|
workspaceWrapper.id = workspace.uuid;
|
||||||
if (this.activeWorkspace === workspace.uuid) {
|
if (this.activeWorkspace === workspace.uuid) {
|
||||||
workspaceWrapper.setAttribute('active', 'true');
|
workspaceWrapper.active = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
await new Promise((resolve) => {
|
await new Promise((resolve) => {
|
||||||
|
@ -1911,11 +1911,7 @@ var gZenWorkspaces = new (class extends ZenMultiWindowFeature {
|
||||||
// Refresh tab cache
|
// Refresh tab cache
|
||||||
for (const otherWorkspace of workspaces.workspaces) {
|
for (const otherWorkspace of workspaces.workspaces) {
|
||||||
const container = this.workspaceElement(otherWorkspace.uuid);
|
const container = this.workspaceElement(otherWorkspace.uuid);
|
||||||
if (otherWorkspace.uuid === workspace.uuid) {
|
container.active = otherWorkspace.uuid === workspace.uuid;
|
||||||
container.setAttribute('active', 'true');
|
|
||||||
} else {
|
|
||||||
container.removeAttribute('active');
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
gBrowser.verticalPinnedTabsContainer =
|
gBrowser.verticalPinnedTabsContainer =
|
||||||
this.pinnedTabsContainer || gBrowser.verticalPinnedTabsContainer;
|
this.pinnedTabsContainer || gBrowser.verticalPinnedTabsContainer;
|
||||||
|
@ -2172,13 +2168,11 @@ var gZenWorkspaces = new (class extends ZenMultiWindowFeature {
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
element.active = offset === 0;
|
||||||
if (offset === 0) {
|
if (offset === 0) {
|
||||||
element.setAttribute('active', 'true');
|
|
||||||
if (tabToSelect != gBrowser.selectedTab && !onInit) {
|
if (tabToSelect != gBrowser.selectedTab && !onInit) {
|
||||||
gBrowser.selectedTab = tabToSelect;
|
gBrowser.selectedTab = tabToSelect;
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
element.removeAttribute('active');
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (this.containerSpecificEssentials && previousWorkspace) {
|
if (this.containerSpecificEssentials && previousWorkspace) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue