diff --git a/src/browser/components/search/SearchUIUtils-sys-mjs.patch b/src/browser/components/search/SearchUIUtils-sys-mjs.patch new file mode 100644 index 000000000..8715d4c07 --- /dev/null +++ b/src/browser/components/search/SearchUIUtils-sys-mjs.patch @@ -0,0 +1,13 @@ +diff --git a/browser/components/search/SearchUIUtils.sys.mjs b/browser/components/search/SearchUIUtils.sys.mjs +index ecebaad93acfc9eb7dfd9d9f56fec2e1a4abe392..8bb1348b3258dbc518d23ec39181a81f87fc8c1e 100644 +--- a/browser/components/search/SearchUIUtils.sys.mjs ++++ b/browser/components/search/SearchUIUtils.sys.mjs +@@ -403,7 +403,7 @@ export var SearchUIUtils = { + triggeringSearchEngine: engine.name, + }, + }); +- ++ window.gZenGlanceManager?.onSearchSelectCommand(where); + return { engine, url: submission.uri }; + }, + diff --git a/src/zen/common/ZenSessionStore.mjs b/src/zen/common/ZenSessionStore.mjs index e73cd50c9..03ed3490b 100644 --- a/src/zen/common/ZenSessionStore.mjs +++ b/src/zen/common/ZenSessionStore.mjs @@ -75,8 +75,8 @@ await gZenGlanceManager.openGlance( { url: undefined, - x: browserRect.width / 2, - y: browserRect.height / 2, + clientX: browserRect.width / 2, + clientY: browserRect.height / 2, width: 0, height: 0, }, diff --git a/src/zen/common/ZenUIManager.mjs b/src/zen/common/ZenUIManager.mjs index aa2bb9cad..84ea7e986 100644 --- a/src/zen/common/ZenUIManager.mjs +++ b/src/zen/common/ZenUIManager.mjs @@ -7,6 +7,8 @@ var gZenUIManager = { _hasLoadedDOM: false, testingEnabled: Services.prefs.getBoolPref('zen.testing.enabled', false), + _lastClickPosition: null, + _toastTimeouts: [], init() { @@ -34,6 +36,8 @@ var gZenUIManager = { gURLBar._zenTrimURL = this.urlbarTrim.bind(this); + document.addEventListener('mousedown', this.handleMouseDown.bind(this), true); + ChromeUtils.defineLazyGetter(this, 'motion', () => { return ChromeUtils.importESModule('chrome://browser/content/zen-vendor/motion.min.mjs', { global: 'current', @@ -65,6 +69,13 @@ var gZenUIManager = { gZenMediaController.init(); }, + handleMouseDown(event) { + this._lastClickPosition = { + clientX: event.clientX, + clientY: event.clientY, + }; + }, + updateTabsToolbar() { const kUrlbarHeight = 440; gURLBar.textbox.style.setProperty( diff --git a/src/zen/downloads/ZenDownloadAnimation.mjs b/src/zen/downloads/ZenDownloadAnimation.mjs index cc7eed9fb..be1e83463 100644 --- a/src/zen/downloads/ZenDownloadAnimation.mjs +++ b/src/zen/downloads/ZenDownloadAnimation.mjs @@ -14,24 +14,10 @@ }); class ZenDownloadAnimation extends ZenDOMOperatedFeature { - #lastClickPosition = null; - async init() { - this.#setupClickListener(); await this.#setupDownloadListeners(); } - #setupClickListener() { - document.addEventListener('mousedown', this.#handleClick.bind(this), true); - } - - #handleClick(event) { - this.#lastClickPosition = { - clientX: event.clientX, - clientY: event.clientY, - }; - } - async #setupDownloadListeners() { try { const list = await Downloads.getList(Downloads.ALL); @@ -53,14 +39,14 @@ return; } - if (!this.#lastClickPosition) { + if (!gZenUIManager._lastClickPosition) { console.warn( `[${ZenDownloadAnimation.name}] No recent click position available for animation` ); return; } - this.#animateDownload(this.#lastClickPosition); + this.#animateDownload(gZenUIManager._lastClickPosition); } #animateDownload(startPosition) { diff --git a/src/zen/glance/ZenGlanceManager.mjs b/src/zen/glance/ZenGlanceManager.mjs index 70d58ea2d..a20bc1ed7 100644 --- a/src/zen/glance/ZenGlanceManager.mjs +++ b/src/zen/glance/ZenGlanceManager.mjs @@ -154,8 +154,8 @@ this.animatingOpen = true; this._animating = true; - const initialX = data.x; - const initialY = data.y; + const initialX = data.clientX; + const initialY = data.clientY; const initialWidth = data.width; const initialHeight = data.height; @@ -597,8 +597,10 @@ this.openGlance( { url: undefined, - x: browserRect.width / 2, - y: browserRect.height / 2, + ...(gZenUIManager._lastClickPosition || { + clientX: browserRect.width / 2, + clientY: browserRect.height / 2, + }), width: 0, height: 0, }, @@ -639,7 +641,12 @@ .classList.remove('zen-glance-background'); this.#currentParentTab._visuallySelected = false; this.hideSidebarButtons(); + if (forSplit) { + this.finishOpeningGlance(); + return; + } if (gReduceMotion || forSplit) { + gZenViewSplitter.deactivateCurrentSplitView(); this.finishOpeningGlance(); return; } @@ -654,6 +661,7 @@ type: 'spring', } ); + gZenViewSplitter.deactivateCurrentSplitView(); this.finishOpeningGlance(); } @@ -678,8 +686,8 @@ const rect = event.target.getBoundingClientRect(); const data = { url: event.target._placesNode.uri, - x: rect.left, - y: rect.top, + clientX: rect.left, + clientY: rect.top, width: rect.width, height: rect.height, }; @@ -737,6 +745,32 @@ } return false; } + + onSearchSelectCommand(where) { + if (where !== 'tab') { + return; + } + const currentTab = gBrowser.selectedTab; + const parentTab = currentTab.owner; + if (!parentTab) { + return; + } + // Open a new glance if the current tab is a glance tab + const browserRect = gBrowser.tabbox.getBoundingClientRect(); + this.openGlance( + { + url: undefined, + ...(gZenUIManager._lastClickPosition || { + clientX: browserRect.width / 2, + clientY: browserRect.height / 2, + }), + width: 0, + height: 0, + }, + currentTab, + parentTab + ); + } } window.gZenGlanceManager = new ZenGlanceManager(); diff --git a/src/zen/glance/actors/ZenGlanceChild.sys.mjs b/src/zen/glance/actors/ZenGlanceChild.sys.mjs index 24bb208e4..3625d514c 100644 --- a/src/zen/glance/actors/ZenGlanceChild.sys.mjs +++ b/src/zen/glance/actors/ZenGlanceChild.sys.mjs @@ -74,8 +74,8 @@ export class ZenGlanceChild extends JSWindowActorChild { const rect = target.getBoundingClientRect(); this.sendAsyncMessage('ZenGlance:OpenGlance', { url, - x: rect.left, - y: rect.top, + clientX: rect.left, + clientY: rect.top, width: rect.width, height: rect.height, }); diff --git a/src/zen/split-view/ZenViewSplitter.mjs b/src/zen/split-view/ZenViewSplitter.mjs index e9a8d8d5f..8b0e83a51 100644 --- a/src/zen/split-view/ZenViewSplitter.mjs +++ b/src/zen/split-view/ZenViewSplitter.mjs @@ -159,6 +159,11 @@ class ZenViewSplitter extends ZenDOMOperatedFeature { const tab = event.target; if (tab.group?.hasAttribute('split-view-group')) { gBrowser.explicitUnloadTabs(tab.group.tabs); + for (const t of tab.group.tabs) { + if (t.glanceTab) { + gBrowser.explicitUnloadTabs([t.glanceTab]); + } + } } } diff --git a/src/zen/tests/glance/head.js b/src/zen/tests/glance/head.js index ec872e017..c3604d540 100644 --- a/src/zen/tests/glance/head.js +++ b/src/zen/tests/glance/head.js @@ -9,8 +9,8 @@ function openGlanceOnTab(callback, close = true) { gZenGlanceManager .openGlance({ url: 'https://example.com', - x: 0, - y: 0, + clientX: 0, + clientY: 0, width: 0, height: 0, })