mirror of
https://github.com/zen-browser/desktop.git
synced 2026-08-12 17:55:19 +00:00
feat: Fixed closing windows on macos not returning to the original views, b=no-bug, c=no-component
This commit is contained in:
@@ -255,7 +255,7 @@ export class nsZenSessionManager {
|
||||
const windows = (state.windows || []).filter(
|
||||
(win) => !win.isPrivate && !win.isPopup && !win.isTaskbarTab && !win.isZenUnsynced
|
||||
);
|
||||
let windowToClone = windows[0] || {};
|
||||
let windowToClone = windows.length > 1 ? windows[windows.length - 2] : {};
|
||||
let newWindow = Cu.cloneInto(windowToClone, {});
|
||||
if (windows.length < 2) {
|
||||
// We only want to restore the sidebar object if we found
|
||||
@@ -286,7 +286,7 @@ export class nsZenSessionManager {
|
||||
firstWindow: true,
|
||||
});
|
||||
|
||||
resolvePromise();
|
||||
lazy.setTimeout(resolvePromise);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@ XPCOMUtils.defineLazyPreferenceGetter(lazy, 'gWindowSyncEnabled', 'zen.window-sy
|
||||
XPCOMUtils.defineLazyPreferenceGetter(lazy, 'gShouldLog', 'zen.window-sync.log', true);
|
||||
|
||||
const OBSERVING = ['browser-window-before-show'];
|
||||
const INSTANT_EVENTS = ['unload'];
|
||||
const INSTANT_EVENTS = ['SSWindowClosing'];
|
||||
const EVENTS = [
|
||||
'TabOpen',
|
||||
'TabClose',
|
||||
@@ -203,7 +203,7 @@ class nsZenWindowSync {
|
||||
*/
|
||||
#runOnAllWindows(aWindow, aCallback) {
|
||||
for (let window of this.#browserWindows) {
|
||||
if (window !== aWindow) {
|
||||
if (window !== aWindow && !window._zenClosingWindow) {
|
||||
let value = aCallback(window);
|
||||
if (value) {
|
||||
return value;
|
||||
@@ -224,7 +224,11 @@ class nsZenWindowSync {
|
||||
|
||||
handleEvent(aEvent) {
|
||||
const window = aEvent.currentTarget.ownerGlobal;
|
||||
if (!window.gZenStartup.isReady || window.gZenWorkspaces?.privateWindowOrDisabled) {
|
||||
if (
|
||||
!window.gZenStartup.isReady ||
|
||||
window.gZenWorkspaces?.privateWindowOrDisabled ||
|
||||
window._zenClosingWindow
|
||||
) {
|
||||
return;
|
||||
}
|
||||
if (INSTANT_EVENTS.includes(aEvent.type)) {
|
||||
@@ -658,6 +662,11 @@ class nsZenWindowSync {
|
||||
*/
|
||||
#onTabSwitchOrWindowFocus(aWindow, aPreviousTab = null) {
|
||||
const selectedTab = aWindow.gBrowser.selectedTab;
|
||||
// On some occasions, such as when closing a window, this
|
||||
// function might be called multiple times for the same tab.
|
||||
if (selectedTab === this.#lastSelectedTab) {
|
||||
return;
|
||||
}
|
||||
if (aPreviousTab?._zenContentsVisible) {
|
||||
const otherTabToShow = this.#getActiveTabFromOtherWindows(
|
||||
aWindow,
|
||||
@@ -853,8 +862,9 @@ class nsZenWindowSync {
|
||||
this.#onTabSwitchOrWindowFocus(aEvent.target.ownerGlobal, previousTab);
|
||||
}
|
||||
|
||||
on_unload(aEvent) {
|
||||
on_SSWindowClosing(aEvent) {
|
||||
const window = aEvent.target.ownerGlobal;
|
||||
window._zenClosingWindow = true;
|
||||
for (let eventName of EVENTS) {
|
||||
window.removeEventListener(eventName, this);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user