mirror of
https://github.com/zen-browser/desktop.git
synced 2026-03-29 20:01:52 +00:00
fix: Fixed windows titlebar not initializing correctly, b=closes #11479, closes #11475, closes #11470 and closes #11471, c=compact-mode
This commit is contained in:
@@ -1,19 +0,0 @@
|
||||
diff --git a/netwerk/protocol/http/nsHttpTransaction.cpp b/netwerk/protocol/http/nsHttpTransaction.cpp
|
||||
index daf10b9adb4b6a3c376edc5b0d8586e97483626a..415f64dbb2da5ea6da42f1ce29d6dc09cf86f713 100644
|
||||
--- a/netwerk/protocol/http/nsHttpTransaction.cpp
|
||||
+++ b/netwerk/protocol/http/nsHttpTransaction.cpp
|
||||
@@ -1332,6 +1332,14 @@ void nsHttpTransaction::Close(nsresult reason) {
|
||||
mDNSRequest = nullptr;
|
||||
}
|
||||
|
||||
+ // If an HTTP/3 backup timer is active and this transaction ends in error,
|
||||
+ // treat it as NS_ERROR_NET_RESET so the transaction will retry once.
|
||||
+ // NOTE: This is a temporary workaround; the proper fix belongs in
|
||||
+ // the Happy Eyeballs project.
|
||||
+ if (NS_FAILED(reason) && mHttp3BackupTimerCreated && mHttp3BackupTimer) {
|
||||
+ reason = NS_ERROR_NET_RESET;
|
||||
+ }
|
||||
+
|
||||
MaybeCancelFallbackTimer();
|
||||
|
||||
MOZ_ASSERT(OnSocketThread(), "not on socket thread");
|
||||
33
src/firefox-patches/147_windows_border_fix_3.patch
Normal file
33
src/firefox-patches/147_windows_border_fix_3.patch
Normal file
@@ -0,0 +1,33 @@
|
||||
From dd4460727998a53e9fa7372afba2a93a9546cec3 Mon Sep 17 00:00:00 2001
|
||||
From: =?UTF-8?q?Emilio=20Cobos=20=C3=81lvarez?= <emilio@crisal.io>
|
||||
Date: Fri, 28 Nov 2025 15:06:26 +0000
|
||||
Subject: [PATCH] Bug 2002986 - Use IAppWindowTitlebar::ResetToDefault() for
|
||||
non-collapsed titlebar. r=win-reviewers,gstoll
|
||||
|
||||
This seems to actually go to the default DWM stuff and is the documented
|
||||
way of doing so:
|
||||
|
||||
https://learn.microsoft.com/en-us/windows/apps/develop/title-bar#reset-the-title-bar
|
||||
|
||||
Differential Revision: https://phabricator.services.mozilla.com/D274413
|
||||
---
|
||||
widget/windows/WindowsUIUtils.cpp | 6 +++++-
|
||||
1 file changed, 5 insertions(+), 1 deletion(-)
|
||||
|
||||
diff --git a/widget/windows/WindowsUIUtils.cpp b/widget/windows/WindowsUIUtils.cpp
|
||||
index a5a6c893e7056..abaabfba69dfa 100644
|
||||
--- a/widget/windows/WindowsUIUtils.cpp
|
||||
+++ b/widget/windows/WindowsUIUtils.cpp
|
||||
@@ -1394,7 +1394,11 @@ void WindowsUIUtils::SetIsTitlebarCollapsed(HWND aWnd, bool aIsCollapsed) {
|
||||
MOZ_ASSERT_UNREACHABLE("IAppWindowTitleBar could not be acquired");
|
||||
return;
|
||||
}
|
||||
- hr = titleBar->put_ExtendsContentIntoTitleBar(aIsCollapsed);
|
||||
+ if (aIsCollapsed) {
|
||||
+ hr = titleBar->put_ExtendsContentIntoTitleBar(aIsCollapsed);
|
||||
+ } else {
|
||||
+ hr = titleBar->ResetToDefault();
|
||||
+ }
|
||||
if (FAILED(hr)) {
|
||||
MOZ_LOG(gWindowsLog, LogLevel::Error,
|
||||
("Skipping SetIsTitlebarCollapsed() because "
|
||||
221
src/firefox-patches/147_windows_border_fix_4.patch
Normal file
221
src/firefox-patches/147_windows_border_fix_4.patch
Normal file
@@ -0,0 +1,221 @@
|
||||
From bb40796bb2ff8be97e2adcdad78d9b9ea1d3ea18 Mon Sep 17 00:00:00 2001
|
||||
From: =?UTF-8?q?Emilio=20Cobos=20=C3=81lvarez?= <emilio@crisal.io>
|
||||
Date: Fri, 28 Nov 2025 15:27:41 +0000
|
||||
Subject: [PATCH] Bug 2002990 - Save some work on startup to associate a native
|
||||
window with the app sdk. r=gstoll,win-reviewers
|
||||
|
||||
We only need to grab its AppWindow for that to happen. Save some useless
|
||||
QI while at it.
|
||||
|
||||
I'm pretty sure bug 2002986 would also help here but this seems worth
|
||||
doing regardless.
|
||||
|
||||
Differential Revision: https://phabricator.services.mozilla.com/D274419
|
||||
---
|
||||
widget/windows/WindowsUIUtils.cpp | 126 ++++++++++++++----------------
|
||||
widget/windows/WindowsUIUtils.h | 1 +
|
||||
widget/windows/nsWindow.cpp | 2 +-
|
||||
3 files changed, 62 insertions(+), 67 deletions(-)
|
||||
|
||||
diff --git a/widget/windows/WindowsUIUtils.cpp b/widget/windows/WindowsUIUtils.cpp
|
||||
index abaabfba69dfa..1ad39b98c20e0 100644
|
||||
--- a/widget/windows/WindowsUIUtils.cpp
|
||||
+++ b/widget/windows/WindowsUIUtils.cpp
|
||||
@@ -1211,7 +1211,35 @@ using GetWindowIdFromWindowType = HRESULT(STDAPICALLTYPE*)(
|
||||
static GetWindowIdFromWindowType sGetWindowIdFromWindowProc = nullptr;
|
||||
|
||||
// Returns whether initialization succeeded
|
||||
-bool InitializeWindowsAppSDKStatics() {
|
||||
+[[nodiscard]] static bool InitializeWindowsAppSDKStatics() {
|
||||
+ MOZ_ASSERT(NS_IsMainThread());
|
||||
+ // This function is needed to avoid drawing the titlebar buttons
|
||||
+ // when the Windows mica backdrop is enabled. (bug 1934040)
|
||||
+ // If it isn't possible for mica to be enabled, we don't need to do anything.
|
||||
+ // The Windows App SDK that we use here doesn't support older versions of
|
||||
+ // Windows 10 that Firefox does.
|
||||
+ if (!widget::WinUtils::MicaAvailable()) {
|
||||
+ MOZ_LOG(
|
||||
+ gWindowsLog, LogLevel::Info,
|
||||
+ ("Skipping SetIsTitlebarCollapsed() because mica is not available"));
|
||||
+ return false;
|
||||
+ }
|
||||
+ // This pref is only false on certain test runs (most notably
|
||||
+ // opt-talos-xperf), the Windows App SDK fails calling
|
||||
+ // DCompositionCreateDevice3() with ERROR_ACCESS_DENIED, and the code assumes
|
||||
+ // it is going to succeed so it proceeds to crash deferencing null.
|
||||
+ //
|
||||
+ // We're not exactly sure why this is happening right now, but I'm pretty sure
|
||||
+ // it's specific to how we're running Firefox on those test runs, and
|
||||
+ // I don't think any users will run into this. So those tests pass the
|
||||
+ // --disable-windowsappsdk command line argument to avoid using
|
||||
+ // the Windows App SDK.
|
||||
+ if (!StaticPrefs::widget_windows_windowsappsdk_enabled()) {
|
||||
+ MOZ_LOG(gWindowsLog, LogLevel::Info,
|
||||
+ ("Skipping SetIsTitlebarCollapsed() because "
|
||||
+ "widget.windows.windowsappsdk.enabled is false"));
|
||||
+ return false;
|
||||
+ }
|
||||
if (!sGetWindowIdFromWindowProc) {
|
||||
HMODULE frameworkUdkModule =
|
||||
::LoadLibraryW(L"Microsoft.Internal.FrameworkUdk.dll");
|
||||
@@ -1303,51 +1331,14 @@ bool InitializeWindowsAppSDKStatics() {
|
||||
}
|
||||
return true;
|
||||
}
|
||||
-#endif
|
||||
|
||||
-void WindowsUIUtils::SetIsTitlebarCollapsed(HWND aWnd, bool aIsCollapsed) {
|
||||
-#ifndef __MINGW32__
|
||||
- // Used to avoid synchronization for loading libraries below
|
||||
- MOZ_ASSERT(NS_IsMainThread());
|
||||
- // This function is needed to avoid drawing the titlebar buttons
|
||||
- // when the Windows mica backdrop is enabled. (bug 1934040)
|
||||
- // If it isn't possible for mica to be enabled, we don't need to do anything.
|
||||
- // This also helps prevent problems because the Windows App SDK that we use
|
||||
- // here doesn't support older versions of Windows 10 that Firefox does.
|
||||
- if (!widget::WinUtils::MicaAvailable()) {
|
||||
- MOZ_LOG(
|
||||
- gWindowsLog, LogLevel::Info,
|
||||
- ("Skipping SetIsTitlebarCollapsed() because mica is not available"));
|
||||
- return;
|
||||
- }
|
||||
- // This pref is only false on certain test runs (most notably
|
||||
- // opt-talos-xperf), the Windows App SDK fails calling
|
||||
- // DCompositionCreateDevice3() with ERROR_ACCESS_DENIED, and the code assumes
|
||||
- // it is going to succeed so it proceeds to crash deferencing null.
|
||||
- //
|
||||
- // We're not exactly sure why this is happening right now, but I'm pretty sure
|
||||
- // it's specific to how we're running Firefox on those test runs, and
|
||||
- // I don't think any users will run into this. So those tests pass the
|
||||
- // --disable-windowsappsdk command line argument to avoid using
|
||||
- // the Windows App SDK.
|
||||
- if (!StaticPrefs::widget_windows_windowsappsdk_enabled()) {
|
||||
- MOZ_LOG(gWindowsLog, LogLevel::Info,
|
||||
- ("Skipping SetIsTitlebarCollapsed() because "
|
||||
- "widget.windows.windowsappsdk.enabled is false"));
|
||||
- return;
|
||||
- }
|
||||
+static RefPtr<winrt::Microsoft::UI::Windowing::IAppWindow>
|
||||
+GetAppWindowForWindow(HWND aWnd) {
|
||||
if (!InitializeWindowsAppSDKStatics()) {
|
||||
- return;
|
||||
+ return nullptr;
|
||||
}
|
||||
-
|
||||
- // The Microsoft documentation says that we should be checking
|
||||
- // AppWindowTitleBar::IsCustomizationSupported() before calling methods
|
||||
- // on the title bar. However, it also says that customization is fully
|
||||
- // supported since Windows App SDK v1.2 on Windows 11, and Mica is only
|
||||
- // available on Windows 11, so it should be safe to skip this check.
|
||||
-
|
||||
// Retrieve the WindowId that corresponds to hWnd.
|
||||
- struct winrt::Microsoft::UI::WindowId windowId;
|
||||
+ struct winrt::Microsoft::UI::WindowId windowId{0};
|
||||
HRESULT hr = sGetWindowIdFromWindowProc(aWnd, &windowId);
|
||||
if (FAILED(hr) || windowId.value == 0) {
|
||||
MOZ_LOG(gWindowsLog, LogLevel::Error,
|
||||
@@ -1355,25 +1346,40 @@ void WindowsUIUtils::SetIsTitlebarCollapsed(HWND aWnd, bool aIsCollapsed) {
|
||||
"GetWindowIdFromWindow failed, hr=0x%" PRIX32,
|
||||
static_cast<uint32_t>(hr)));
|
||||
MOZ_ASSERT_UNREACHABLE("GetWindowIdFromWindow failed");
|
||||
- return;
|
||||
+ return nullptr;
|
||||
}
|
||||
|
||||
RefPtr<winrt::Microsoft::UI::Windowing::IAppWindow> appWindow;
|
||||
- hr = (HRESULT)sAppWindowStatics->GetFromWindowId(windowId,
|
||||
- getter_AddRefs(appWindow));
|
||||
- if (FAILED(hr) || !appWindow) {
|
||||
- // Hedge our bets here and don't assert because it's possible this
|
||||
- // is a weird sort of window or something.
|
||||
+ sAppWindowStatics->GetFromWindowId(windowId, getter_AddRefs(appWindow));
|
||||
+ return appWindow;
|
||||
+}
|
||||
+#endif
|
||||
+
|
||||
+void WindowsUIUtils::AssociateWithWinAppSDK(HWND aWnd) {
|
||||
+#ifndef __MINGW32__
|
||||
+ RefPtr win = GetAppWindowForWindow(aWnd);
|
||||
+ (void)win;
|
||||
+#endif
|
||||
+}
|
||||
+
|
||||
+void WindowsUIUtils::SetIsTitlebarCollapsed(HWND aWnd, bool aIsCollapsed) {
|
||||
+#ifndef __MINGW32__
|
||||
+ // The Microsoft documentation says that we should be checking
|
||||
+ // AppWindowTitleBar::IsCustomizationSupported() before calling methods
|
||||
+ // on the title bar. However, it also says that customization is fully
|
||||
+ // supported since Windows App SDK v1.2 on Windows 11, and Mica is only
|
||||
+ // available on Windows 11, so it should be safe to skip this check.
|
||||
+ RefPtr appWindow = GetAppWindowForWindow(aWnd);
|
||||
+ if (!appWindow) {
|
||||
MOZ_LOG(gWindowsLog, LogLevel::Warning,
|
||||
("Skipping SetIsTitlebarCollapsed() because "
|
||||
- "IAppWindow could not be acquired from window id, hr=%" PRIX32,
|
||||
- static_cast<uint32_t>(hr)));
|
||||
+ "IAppWindow could not be acquired from window id"));
|
||||
return;
|
||||
}
|
||||
|
||||
- RefPtr<IInspectable> inspectableTitleBar;
|
||||
- hr = appWindow->get_TitleBar(getter_AddRefs(inspectableTitleBar));
|
||||
- if (FAILED(hr) || !inspectableTitleBar) {
|
||||
+ RefPtr<winrt::Microsoft::UI::Windowing::IAppWindowTitleBar> titleBar;
|
||||
+ HRESULT hr = appWindow->get_TitleBar(getter_AddRefs(titleBar));
|
||||
+ if (FAILED(hr) || !titleBar) {
|
||||
// Hedge our bets here and don't assert because it's possible this
|
||||
// is a weird sort of window or something.
|
||||
MOZ_LOG(gWindowsLog, LogLevel::Warning,
|
||||
@@ -1382,18 +1388,6 @@ void WindowsUIUtils::SetIsTitlebarCollapsed(HWND aWnd, bool aIsCollapsed) {
|
||||
static_cast<uint32_t>(hr)));
|
||||
return;
|
||||
}
|
||||
- RefPtr<winrt::Microsoft::UI::Windowing::IAppWindowTitleBar> titleBar;
|
||||
- hr = inspectableTitleBar->QueryInterface(
|
||||
- __uuidof(winrt::Microsoft::UI::Windowing::IAppWindowTitleBar),
|
||||
- (void**)getter_AddRefs(titleBar));
|
||||
- if (FAILED(hr) || !titleBar) {
|
||||
- MOZ_LOG(gWindowsLog, LogLevel::Error,
|
||||
- ("Skipping SetIsTitlebarCollapsed() because "
|
||||
- "IAppWindowTitleBar could not be acquired, hr=%" PRIX32,
|
||||
- static_cast<uint32_t>(hr)));
|
||||
- MOZ_ASSERT_UNREACHABLE("IAppWindowTitleBar could not be acquired");
|
||||
- return;
|
||||
- }
|
||||
if (aIsCollapsed) {
|
||||
hr = titleBar->put_ExtendsContentIntoTitleBar(aIsCollapsed);
|
||||
} else {
|
||||
@@ -1410,7 +1404,7 @@ void WindowsUIUtils::SetIsTitlebarCollapsed(HWND aWnd, bool aIsCollapsed) {
|
||||
if (aIsCollapsed) {
|
||||
// PreferredHeightOption is only valid if ExtendsContentIntoTitleBar is true
|
||||
RefPtr<winrt::Microsoft::UI::Windowing::IAppWindowTitleBar2> titleBar2;
|
||||
- hr = inspectableTitleBar->QueryInterface(
|
||||
+ hr = titleBar->QueryInterface(
|
||||
__uuidof(winrt::Microsoft::UI::Windowing::IAppWindowTitleBar2),
|
||||
(void**)getter_AddRefs(titleBar2));
|
||||
if (FAILED(hr) || !titleBar2) {
|
||||
diff --git a/widget/windows/WindowsUIUtils.h b/widget/windows/WindowsUIUtils.h
|
||||
index 17a5aac583758..0abd4dfe9875a 100644
|
||||
--- a/widget/windows/WindowsUIUtils.h
|
||||
+++ b/widget/windows/WindowsUIUtils.h
|
||||
@@ -59,6 +59,7 @@ class WindowsUIUtils final : public nsIWindowsUIUtils {
|
||||
static bool ComputeOverlayScrollbars();
|
||||
static double ComputeTextScaleFactor();
|
||||
static bool ComputeTransparencyEffects();
|
||||
+ static void AssociateWithWinAppSDK(HWND aWnd);
|
||||
static void SetIsTitlebarCollapsed(HWND aWnd, bool aIsCollapsed);
|
||||
|
||||
protected:
|
||||
diff --git a/widget/windows/nsWindow.cpp b/widget/windows/nsWindow.cpp
|
||||
index 19f5980a106fb..a2a288e793046 100644
|
||||
--- a/widget/windows/nsWindow.cpp
|
||||
+++ b/widget/windows/nsWindow.cpp
|
||||
@@ -1540,7 +1540,7 @@ bool nsWindow::AssociateWithNativeWindow() {
|
||||
// This is important because the SDKs WNDPROC might handle messages like
|
||||
// WM_NCCALCSIZE without calling into us, and that can cause sizing issues,
|
||||
// see bug 1993474.
|
||||
- WindowsUIUtils::SetIsTitlebarCollapsed(mWnd, mCustomNonClient);
|
||||
+ WindowsUIUtils::AssociateWithWinAppSDK(mWnd);
|
||||
}
|
||||
|
||||
// Connect the this pointer to the native window handle.
|
||||
@@ -52,13 +52,9 @@ window.gZenCompactModeManager = {
|
||||
this._canDebugLog = Services.prefs.getBoolPref('zen.view.compact.debug', false);
|
||||
|
||||
this.addContextMenu();
|
||||
this._resolvePreInit();
|
||||
},
|
||||
|
||||
async init() {
|
||||
await this._preInitPromise;
|
||||
delete this._resolvePreInit;
|
||||
delete this._preInitPromise;
|
||||
init() {
|
||||
this.addMouseActions();
|
||||
|
||||
const tabIsRightObserver = this._updateSidebarIsOnRight.bind(this);
|
||||
@@ -864,13 +860,10 @@ window.gZenCompactModeManager = {
|
||||
},
|
||||
};
|
||||
|
||||
(gZenCompactModeManager._preInitPromise = new Promise((resolve) => {
|
||||
gZenCompactModeManager._resolvePreInit = resolve;
|
||||
})),
|
||||
document.addEventListener(
|
||||
'MozBeforeInitialXULLayout',
|
||||
() => {
|
||||
gZenCompactModeManager.preInit();
|
||||
},
|
||||
{ once: true }
|
||||
);
|
||||
document.addEventListener(
|
||||
'MozBeforeInitialXULLayout',
|
||||
() => {
|
||||
gZenCompactModeManager.preInit();
|
||||
},
|
||||
{ once: true }
|
||||
);
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
"brandShortName": "Zen",
|
||||
"brandFullName": "Zen Browser",
|
||||
"release": {
|
||||
"displayVersion": "1.17.11b",
|
||||
"displayVersion": "1.17.12b",
|
||||
"github": {
|
||||
"repo": "zen-browser/desktop"
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user