From 820652bd5e7a49f210fb138f855a2907a70ccbf1 Mon Sep 17 00:00:00 2001 From: "mr. m" Date: Sun, 18 May 2025 12:22:11 +0200 Subject: [PATCH] feat: Added support for swiping when scrolling on workspaces, b=(no-bug), c=workspaces --- .../content/widgets/arrowscrollbox-js.patch | 4 ++-- src/zen/workspaces/ZenWorkspace.mjs | 9 ++++++++- src/zen/workspaces/ZenWorkspaces.mjs | 16 ---------------- src/zen/workspaces/zen-workspaces.css | 4 ++-- 4 files changed, 12 insertions(+), 21 deletions(-) diff --git a/src/toolkit/content/widgets/arrowscrollbox-js.patch b/src/toolkit/content/widgets/arrowscrollbox-js.patch index 2094f349c..4330bcd02 100644 --- a/src/toolkit/content/widgets/arrowscrollbox-js.patch +++ b/src/toolkit/content/widgets/arrowscrollbox-js.patch @@ -1,5 +1,5 @@ diff --git a/toolkit/content/widgets/arrowscrollbox.js b/toolkit/content/widgets/arrowscrollbox.js -index f9191af09f1b7a1654aff62807e7dad573afc172..f94a8b3dc5871fba5d0dbed5d487d6e32a1ff29a 100644 +index f9191af09f1b7a1654aff62807e7dad573afc172..0b81a2bf5a0e1d745623f9b72fbe57254c1b16dd 100644 --- a/toolkit/content/widgets/arrowscrollbox.js +++ b/toolkit/content/widgets/arrowscrollbox.js @@ -98,6 +98,7 @@ @@ -15,7 +15,7 @@ index f9191af09f1b7a1654aff62807e7dad573afc172..f94a8b3dc5871fba5d0dbed5d487d6e3 on_wheel(event) { // Don't consume the event if we can't scroll. - if (!this.overflowing) { -+ if (!this.overflowing || this.id === 'tabbrowser-arrowscrollbox') { // we handle this on ZenStartup ++ if (!this.overflowing || this.id === 'tabbrowser-arrowscrollbox' || (event.deltaY == 0 && this.classList.contains('workspace-arrowscrollbox'))) { return; } diff --git a/src/zen/workspaces/ZenWorkspace.mjs b/src/zen/workspaces/ZenWorkspace.mjs index c02d32108..28bdf63e2 100644 --- a/src/zen/workspaces/ZenWorkspace.mjs +++ b/src/zen/workspaces/ZenWorkspace.mjs @@ -6,7 +6,7 @@ - + @@ -77,6 +77,13 @@ get: () => 36, }); + if ( + Services.prefs.getBoolPref('zen.workspaces.swipe-actions', false) && + gZenWorkspaces.workspaceEnabled + ) { + gZenWorkspaces.attachGestureHandlers(this); + } + // Add them manually since attribute inheritance doesn't work // for multiple layers of shadow DOM. this.tabsContainer.setAttribute('zen-workspace-id', this.id); diff --git a/src/zen/workspaces/ZenWorkspaces.mjs b/src/zen/workspaces/ZenWorkspaces.mjs index 0ae3a6e1f..04229e906 100644 --- a/src/zen/workspaces/ZenWorkspaces.mjs +++ b/src/zen/workspaces/ZenWorkspaces.mjs @@ -138,7 +138,6 @@ var gZenWorkspaces = new (class extends ZenMultiWindowFeature { Services.prefs.getBoolPref('zen.workspaces.swipe-actions', false) && this.workspaceEnabled ) { - this.initializeGestureHandlers(); this.initializeWorkspaceNavigation(); } @@ -576,21 +575,6 @@ var gZenWorkspaces = new (class extends ZenMultiWindowFeature { ); } - initializeGestureHandlers() { - const elements = [ - gNavToolbox, - // event handlers do not work on elements inside shadow DOM so we need to attach them directly - document.getElementById('tabbrowser-arrowscrollbox').shadowRoot.querySelector('scrollbox'), - ]; - - // Attach gesture handlers to each element - for (const element of elements) { - if (!element) continue; - - this.attachGestureHandlers(element); - } - } - attachGestureHandlers(element) { element.addEventListener('MozSwipeGestureMayStart', this._handleSwipeMayStart.bind(this), true); element.addEventListener('MozSwipeGestureStart', this._handleSwipeStart.bind(this), true); diff --git a/src/zen/workspaces/zen-workspaces.css b/src/zen/workspaces/zen-workspaces.css index fae13285c..13e40531b 100644 --- a/src/zen/workspaces/zen-workspaces.css +++ b/src/zen/workspaces/zen-workspaces.css @@ -541,7 +541,7 @@ zen-workspace { top: 0; left: 0; width: 100%; - height: 2px; + height: 1px; opacity: 0; pointer-events: none; transition: opacity 0.1s; @@ -554,7 +554,7 @@ zen-workspace { bottom: 0; left: 0; width: 100%; - height: 2px; + height: 1px; opacity: 0; pointer-events: none; transition: opacity 0.1s;