commit 84504d1bb6af26fbc84d8eff7aa33c4d7cf3e921
parent 8a038d2e7f57d358eec4f38bc3c72c2b9213475a
Author: Greg Stoll <gstoll@mozilla.com>
Date: Thu, 16 Oct 2025 21:28:54 +0000
Bug 1994825 - add a pref to restore the old behavior of not considering virtual desktops in getTopWindow() r=win-reviewers,handyman
Some users have asked for this.
Differential Revision: https://phabricator.services.mozilla.com/D268951
Diffstat:
2 files changed, 16 insertions(+), 1 deletion(-)
diff --git a/browser/modules/BrowserWindowTracker.sys.mjs b/browser/modules/BrowserWindowTracker.sys.mjs
@@ -23,6 +23,12 @@ ChromeUtils.defineESModuleGetters(lazy, {
PrivateBrowsingUtils: "resource://gre/modules/PrivateBrowsingUtils.sys.mjs",
});
+XPCOMUtils.defineLazyPreferenceGetter(
+ lazy,
+ "gPreferWindowsOnCurrentVirtualDesktop",
+ "widget.prefer_windows_on_current_virtual_desktop"
+);
+
// Constants
const TAB_EVENTS = ["TabBrowserInserted", "TabSelect"];
const WINDOW_EVENTS = ["activate", "unload"];
@@ -209,7 +215,7 @@ export const BrowserWindowTracker = {
) {
// On Windows, windows on a different virtual desktop (what Windows calls
// workspaces) are cloaked.
- if (win.isCloaked) {
+ if (win.isCloaked && lazy.gPreferWindowsOnCurrentVirtualDesktop) {
// Even if we allow from an inactive workspace, prefer windows that
// are not cloaked, so that we don't switch workspaces unnecessarily.
if (!cloakedWin && options.allowFromInactiveWorkspace) {
diff --git a/modules/libpref/init/StaticPrefList.yaml b/modules/libpref/init/StaticPrefList.yaml
@@ -18836,6 +18836,15 @@
value: false
mirror: always
+# When looking for a recent window (for example, when a link is clicked
+# on from an external application), whether to prefer windows on the
+# current virtual desktop (aka workspace). For now this only applies on Windows.
+# See bug 1994825
+- name: widget.prefer_windows_on_current_virtual_desktop
+ type: RelaxedAtomicBool
+ value: true
+ mirror: always
+
#ifdef XP_MACOSX
# Whether to shift by the menubar height on fullscreen mode.