commit 2fe4ae0730109c5403da17b0546d4500712e96e7
parent af6ce89b698314c8c4e9c74d0b82ef7b2b37f1d4
Author: Greg Stoll <gstoll@mozilla.com>
Date: Mon, 6 Oct 2025 11:18:29 +0000
Bug 1947324 part 3 - use WinRT/Windows App SDK instead of WS_SYSMENU to collapse titlebar r=emilio
This essentially reverts bug 1934040, as that attempted to deal with
the problem of the wrong titlebar height with Mica on by not setting the
WS_SYSMENU style. However, this caused problems like this bug, where
taskbar windows couldn't be right-clicked on.
Now we accomplish the same thing by calling into the Windows App SDK to
set ExtendsContentIntoTitleBar and PreferredHeightOption appropriately.
This is done in WindowsUIUtils::SetIsTitlebarCollapsed(); the rest of this
change is almost entirely the revert of bug 1934040.
Differential Revision: https://phabricator.services.mozilla.com/D263604
Diffstat:
5 files changed, 351 insertions(+), 38 deletions(-)
diff --git a/mozglue/misc/PreXULSkeletonUI.h b/mozglue/misc/PreXULSkeletonUI.h
@@ -20,8 +20,8 @@ namespace mozilla {
// to not vary based off of any user settings for the initial toplevel window,
// so we're safe here for now.
static const DWORD kPreXULSkeletonUIWindowStyle =
- WS_OVERLAPPED | WS_CLIPCHILDREN | WS_DLGFRAME | WS_BORDER | WS_THICKFRAME |
- WS_MAXIMIZEBOX | WS_MINIMIZEBOX | WS_SYSMENU;
+ WS_CLIPCHILDREN | WS_DLGFRAME | WS_BORDER | WS_MAXIMIZEBOX |
+ WS_MINIMIZEBOX | WS_SIZEBOX | WS_SYSMENU;
static const DWORD kPreXULSkeletonUIWindowStyleEx = WS_EX_WINDOWEDGE;
struct CSSPixelSpan {
diff --git a/widget/windows/WindowsUIUtils.cpp b/widget/windows/WindowsUIUtils.cpp
@@ -37,6 +37,7 @@
#include "WinUtils.h"
mozilla::LazyLogModule gTabletModeLog("TabletMode");
+extern mozilla::LazyLogModule gWindowsLog;
/* mingw currently doesn't support windows.ui.viewmanagement.h, so we disable it
* until it's fixed. */
@@ -1080,3 +1081,334 @@ WindowsUIUtils::ShareUrl(const nsAString& aUrlToShare,
nsAutoString(aUrlToShare));
return NS_OK;
}
+
+// Definitions pulled from the Windows App SDK
+namespace winrt {
+namespace Microsoft {
+namespace UI {
+struct WindowId {
+ uint64_t value;
+};
+namespace Windowing {
+MIDL_INTERFACE("3C315C24-D540-5D72-B518-B226B83627CB")
+IAppWindowStatics : IInspectable {
+ virtual int32_t __stdcall Create(void**) noexcept = 0;
+ virtual int32_t __stdcall CreateWithPresenter(void*, void**) noexcept = 0;
+ virtual int32_t __stdcall CreateWithPresenterAndOwner(
+ void*, struct winrt::Microsoft::UI::WindowId, void**) noexcept = 0;
+ virtual int32_t __stdcall GetFromWindowId(
+ struct winrt::Microsoft::UI::WindowId, void**) noexcept = 0;
+};
+
+MIDL_INTERFACE("CFA788B3-643B-5C5E-AD4E-321D48A82ACD")
+IAppWindow : IInspectable {
+ virtual int32_t __stdcall get_Id(
+ struct struct_Microsoft_UI_WindowId*) noexcept = 0;
+ virtual int32_t __stdcall get_IsShownInSwitchers(bool*) noexcept = 0;
+ virtual int32_t __stdcall put_IsShownInSwitchers(bool) noexcept = 0;
+ virtual int32_t __stdcall get_IsVisible(bool*) noexcept = 0;
+ virtual int32_t __stdcall get_OwnerWindowId(
+ struct struct_Microsoft_UI_WindowId*) noexcept = 0;
+ virtual int32_t __stdcall get_Position(
+ struct struct_Windows_Graphics_PointInt32*) noexcept = 0;
+ virtual int32_t __stdcall get_Presenter(void**) noexcept = 0;
+ virtual int32_t __stdcall get_Size(
+ struct struct_Windows_Graphics_SizeInt32*) noexcept = 0;
+ virtual int32_t __stdcall get_Title(void**) noexcept = 0;
+ virtual int32_t __stdcall put_Title(void*) noexcept = 0;
+ virtual int32_t __stdcall get_TitleBar(void**) noexcept = 0;
+ virtual int32_t __stdcall Destroy() noexcept = 0;
+ virtual int32_t __stdcall Hide() noexcept = 0;
+ virtual int32_t __stdcall Move(
+ struct struct_Windows_Graphics_PointInt32) noexcept = 0;
+ virtual int32_t __stdcall MoveAndResize(
+ struct struct_Windows_Graphics_RectInt32) noexcept = 0;
+ virtual int32_t __stdcall MoveAndResizeRelativeToDisplayArea(
+ struct struct_Windows_Graphics_RectInt32, void*) noexcept = 0;
+ virtual int32_t __stdcall Resize(
+ struct struct_Windows_Graphics_SizeInt32) noexcept = 0;
+ virtual int32_t __stdcall SetIcon(void*) noexcept = 0;
+ virtual int32_t __stdcall SetIconWithIconId(
+ struct struct_Microsoft_UI_IconId) noexcept = 0;
+ virtual int32_t __stdcall SetPresenter(void*) noexcept = 0;
+ virtual int32_t __stdcall SetPresenterByKind(int32_t) noexcept = 0;
+ virtual int32_t __stdcall Show() noexcept = 0;
+ virtual int32_t __stdcall ShowWithActivation(bool) noexcept = 0;
+ virtual int32_t __stdcall add_Changed(void*, void**) noexcept = 0;
+ virtual int32_t __stdcall remove_Changed(void*) noexcept = 0;
+ virtual int32_t __stdcall add_Closing(void*, void**) noexcept = 0;
+ virtual int32_t __stdcall remove_Closing(void*) noexcept = 0;
+ virtual int32_t __stdcall add_Destroying(void*, void**) noexcept = 0;
+ virtual int32_t __stdcall remove_Destroying(void*) noexcept = 0;
+};
+
+MIDL_INTERFACE("5574EFA2-C91C-5700-A363-539C71A7AAF4")
+IAppWindowTitleBar : IInspectable {
+ virtual int32_t __stdcall get_BackgroundColor(void**) noexcept = 0;
+ virtual int32_t __stdcall put_BackgroundColor(void*) noexcept = 0;
+ virtual int32_t __stdcall get_ButtonBackgroundColor(void**) noexcept = 0;
+ virtual int32_t __stdcall put_ButtonBackgroundColor(void*) noexcept = 0;
+ virtual int32_t __stdcall get_ButtonForegroundColor(void**) noexcept = 0;
+ virtual int32_t __stdcall put_ButtonForegroundColor(void*) noexcept = 0;
+ virtual int32_t __stdcall get_ButtonHoverBackgroundColor(void**) noexcept = 0;
+ virtual int32_t __stdcall put_ButtonHoverBackgroundColor(void*) noexcept = 0;
+ virtual int32_t __stdcall get_ButtonHoverForegroundColor(void**) noexcept = 0;
+ virtual int32_t __stdcall put_ButtonHoverForegroundColor(void*) noexcept = 0;
+ virtual int32_t __stdcall get_ButtonInactiveBackgroundColor(
+ void**) noexcept = 0;
+ virtual int32_t __stdcall put_ButtonInactiveBackgroundColor(
+ void*) noexcept = 0;
+ virtual int32_t __stdcall get_ButtonInactiveForegroundColor(
+ void**) noexcept = 0;
+ virtual int32_t __stdcall put_ButtonInactiveForegroundColor(
+ void*) noexcept = 0;
+ virtual int32_t __stdcall get_ButtonPressedBackgroundColor(
+ void**) noexcept = 0;
+ virtual int32_t __stdcall put_ButtonPressedBackgroundColor(
+ void*) noexcept = 0;
+ virtual int32_t __stdcall get_ButtonPressedForegroundColor(
+ void**) noexcept = 0;
+ virtual int32_t __stdcall put_ButtonPressedForegroundColor(
+ void*) noexcept = 0;
+ virtual int32_t __stdcall get_ExtendsContentIntoTitleBar(bool*) noexcept = 0;
+ virtual int32_t __stdcall put_ExtendsContentIntoTitleBar(bool) noexcept = 0;
+ virtual int32_t __stdcall get_ForegroundColor(void**) noexcept = 0;
+ virtual int32_t __stdcall put_ForegroundColor(void*) noexcept = 0;
+ virtual int32_t __stdcall get_Height(int32_t*) noexcept = 0;
+ virtual int32_t __stdcall get_IconShowOptions(int32_t*) noexcept = 0;
+ virtual int32_t __stdcall put_IconShowOptions(int32_t) noexcept = 0;
+ virtual int32_t __stdcall get_InactiveBackgroundColor(void**) noexcept = 0;
+ virtual int32_t __stdcall put_InactiveBackgroundColor(void*) noexcept = 0;
+ virtual int32_t __stdcall get_InactiveForegroundColor(void**) noexcept = 0;
+ virtual int32_t __stdcall put_InactiveForegroundColor(void*) noexcept = 0;
+ virtual int32_t __stdcall get_LeftInset(int32_t*) noexcept = 0;
+ virtual int32_t __stdcall get_RightInset(int32_t*) noexcept = 0;
+ virtual int32_t __stdcall ResetToDefault() noexcept = 0;
+ virtual int32_t __stdcall SetDragRectangles(
+ uint32_t, struct struct_Windows_Graphics_RectInt32*) noexcept = 0;
+};
+
+MIDL_INTERFACE("86FAED38-748A-5B4B-9CCF-3BA0496C9041")
+IAppWindowTitleBar2 : IInspectable {
+ virtual int32_t __stdcall get_PreferredHeightOption(int32_t*) noexcept = 0;
+ virtual int32_t __stdcall put_PreferredHeightOption(int32_t) noexcept = 0;
+};
+
+enum TitleBarHeightOption : int32_t {
+ Standard = 0,
+ Tall = 1,
+ Collapsed = 2,
+};
+} // namespace Windowing
+} // namespace UI
+} // namespace Microsoft
+} // namespace winrt
+
+static StaticRefPtr<winrt::Microsoft::UI::Windowing::IAppWindowStatics>
+ sAppWindowStatics;
+using GetWindowIdFromWindowType = HRESULT(STDAPICALLTYPE*)(
+ HWND hwnd, struct winrt::Microsoft::UI::WindowId* windowId);
+static GetWindowIdFromWindowType sGetWindowIdFromWindowProc = nullptr;
+
+// Returns whether initialization succeeded
+bool InitializeWindowsAppSDKStatics() {
+ if (!sGetWindowIdFromWindowProc) {
+ HMODULE frameworkUdkModule =
+ ::LoadLibraryW(L"Microsoft.Internal.FrameworkUdk.dll");
+ if (!frameworkUdkModule) {
+ uint32_t lastError = static_cast<uint32_t>(::GetLastError());
+ MOZ_LOG(gWindowsLog, LogLevel::Error,
+ ("Skipping SetIsTitlebarCollapsed() because "
+ "Microsoft.Internal.FrameworkUdk.dll could not be loaded, "
+ "error=%" PRIu32,
+ lastError));
+ MOZ_ASSERT_UNREACHABLE(
+ "Microsoft.Internal.FrameworkUdk.dll could not be loaded");
+ return false;
+ }
+
+ sGetWindowIdFromWindowProc = (GetWindowIdFromWindowType)::GetProcAddress(
+ frameworkUdkModule, "Windowing_GetWindowIdFromWindow");
+ }
+ if (!sGetWindowIdFromWindowProc) {
+ MOZ_LOG(gWindowsLog, LogLevel::Error,
+ ("Skipping SetIsTitlebarCollapsed() because "
+ "GetWindowIdFromWindow could not be found in "
+ "Microsoft.Internal.FrameworkUdk.dll, error=%" PRIu32,
+ static_cast<uint32_t>(::GetLastError())));
+ MOZ_ASSERT_UNREACHABLE(
+ "GetWindowIdFromWindow could not be found in "
+ "Microsoft.Internal.FrameworkUdk.dll");
+ return false;
+ }
+ if (!sAppWindowStatics) {
+ HMODULE uiWindowingModule = ::LoadLibraryW(L"Microsoft.UI.Windowing.dll");
+ if (!uiWindowingModule) {
+ MOZ_LOG(gWindowsLog, LogLevel::Error,
+ ("Skipping SetIsTitlebarCollapsed() because "
+ "Microsoft.UI.Windowing.dll could not be loaded, error=%" PRIu32,
+ static_cast<uint32_t>(::GetLastError())));
+ MOZ_ASSERT_UNREACHABLE("Microsoft.UI.Windowing.dll could not be loaded");
+ return false;
+ }
+
+ using DllGetActivationFactoryType = HRESULT(WINAPI*)(
+ HSTRING activatableClassId, IActivationFactory * *factory);
+ auto dllGetActivationFactoryProc =
+ (DllGetActivationFactoryType)::GetProcAddress(
+ uiWindowingModule, "DllGetActivationFactory");
+ if (!dllGetActivationFactoryProc) {
+ MOZ_LOG(gWindowsLog, LogLevel::Error,
+ ("Skipping SetIsTitlebarCollapsed() because "
+ "DllGetActivationFactory could not be found in "
+ "Microsoft.UI.Windowing.dll, error=%" PRIu32,
+ static_cast<uint32_t>(::GetLastError())));
+ MOZ_ASSERT_UNREACHABLE(
+ "DllGetActivationFactory could not be found in "
+ "Microsoft.UI.Windowing.dll");
+ return false;
+ }
+ ComPtr<IActivationFactory> activationFactory;
+ HRESULT hr = dllGetActivationFactoryProc(
+ HStringReference(L"Microsoft.UI.Windowing.AppWindow").Get(),
+ activationFactory.GetAddressOf());
+ if (FAILED(hr)) {
+ MOZ_LOG(gWindowsLog, LogLevel::Error,
+ ("Skipping SetIsTitlebarCollapsed() because "
+ "DllGetActivationFactory failed, hr=%" PRIX32,
+ static_cast<uint32_t>(hr)));
+ MOZ_ASSERT_UNREACHABLE("DllGetActivationFactory failed");
+ return false;
+ }
+ RefPtr<winrt::Microsoft::UI::Windowing::IAppWindowStatics> appWindowStatics;
+ hr = activationFactory->QueryInterface(
+ __uuidof(winrt::Microsoft::UI::Windowing::IAppWindowStatics),
+ getter_AddRefs(appWindowStatics));
+ if (FAILED(hr) || !appWindowStatics) {
+ MOZ_LOG(gWindowsLog, LogLevel::Error,
+ ("Skipping SetIsTitlebarCollapsed() because "
+ "IAppWindowStatics could not be acquired, hr=%" PRIX32,
+ static_cast<uint32_t>(hr)));
+ MOZ_ASSERT_UNREACHABLE("IAppWindowStatics could not be acquired");
+ return false;
+ }
+ sAppWindowStatics = std::move(appWindowStatics);
+ }
+ if (!sAppWindowStatics) {
+ MOZ_LOG(gWindowsLog, LogLevel::Error,
+ ("Skipping SetIsTitlebarCollapsed() because "
+ "IAppWindowStatics could not be acquired"));
+ MOZ_ASSERT_UNREACHABLE("IAppWindowStatics could not be acquired");
+ return false;
+ }
+ return true;
+}
+
+void WindowsUIUtils::SetIsTitlebarCollapsed(HWND aWnd, bool aIsCollapsed) {
+ // 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;
+ }
+ if (!InitializeWindowsAppSDKStatics()) {
+ return;
+ }
+
+ // 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;
+ HRESULT hr = sGetWindowIdFromWindowProc(aWnd, &windowId);
+ if (FAILED(hr) || windowId.value == 0) {
+ MOZ_LOG(gWindowsLog, LogLevel::Error,
+ ("Skipping SetIsTitlebarCollapsed() because "
+ "GetWindowIdFromWindow failed, hr=0x%" PRIX32,
+ static_cast<uint32_t>(hr)));
+ MOZ_ASSERT_UNREACHABLE("GetWindowIdFromWindow failed");
+ return;
+ }
+
+ 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.
+ MOZ_LOG(gWindowsLog, LogLevel::Warning,
+ ("Skipping SetIsTitlebarCollapsed() because "
+ "IAppWindow could not be acquired from window id, hr=%" PRIX32,
+ static_cast<uint32_t>(hr)));
+ return;
+ }
+
+ RefPtr<IInspectable> inspectableTitleBar;
+ hr = appWindow->get_TitleBar(getter_AddRefs(inspectableTitleBar));
+ if (FAILED(hr) || !inspectableTitleBar) {
+ // 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,
+ ("Skipping SetIsTitlebarCollapsed() because "
+ "titlebar could not be acquired, hr=%" PRIX32,
+ 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;
+ }
+ hr = titleBar->put_ExtendsContentIntoTitleBar(aIsCollapsed);
+ if (FAILED(hr)) {
+ MOZ_LOG(gWindowsLog, LogLevel::Error,
+ ("Skipping SetIsTitlebarCollapsed() because "
+ "put_ExtendsContentIntoTitleBar failed, hr=%" PRIX32,
+ static_cast<uint32_t>(hr)));
+ MOZ_ASSERT_UNREACHABLE("put_ExtendsContentIntoTitleBar failed");
+ return;
+ }
+ if (aIsCollapsed) {
+ // PreferredHeightOption is only valid if ExtendsContentIntoTitleBar is true
+ RefPtr<winrt::Microsoft::UI::Windowing::IAppWindowTitleBar2> titleBar2;
+ hr = inspectableTitleBar->QueryInterface(
+ __uuidof(winrt::Microsoft::UI::Windowing::IAppWindowTitleBar2),
+ (void**)getter_AddRefs(titleBar2));
+ if (FAILED(hr) || !titleBar2) {
+ MOZ_LOG(gWindowsLog, LogLevel::Error,
+ ("Skipping SetIsTitlebarCollapsed() because "
+ "IAppWindowTitleBar2 could not be acquired, hr=%" PRIX32,
+ static_cast<uint32_t>(hr)));
+ MOZ_ASSERT_UNREACHABLE("IAppWindowTitleBar2 could not be acquired");
+ return;
+ }
+
+ hr = titleBar2->put_PreferredHeightOption(
+ winrt::Microsoft::UI::Windowing::TitleBarHeightOption::Collapsed);
+ if (FAILED(hr)) {
+ MOZ_LOG(gWindowsLog, LogLevel::Error,
+ ("Skipping SetIsTitlebarCollapsed() because "
+ "put_PreferredHeightOption failed, hr=%" PRIX32,
+ static_cast<uint32_t>(hr)));
+ MOZ_ASSERT_UNREACHABLE("put_PreferredHeightOption failed");
+ return;
+ }
+ }
+}
diff --git a/widget/windows/WindowsUIUtils.h b/widget/windows/WindowsUIUtils.h
@@ -12,6 +12,10 @@
#include "mozilla/Maybe.h"
#include "mozilla/MozPromise.h"
+// Avoid including windef.h to get this, which improves
+// build times.
+typedef struct HWND__* HWND;
+
using SharePromise =
mozilla::MozPromise<bool, nsresult, /* IsExclusive */ true>;
@@ -55,6 +59,7 @@ class WindowsUIUtils final : public nsIWindowsUIUtils {
static bool ComputeOverlayScrollbars();
static double ComputeTextScaleFactor();
static bool ComputeTransparencyEffects();
+ static void SetIsTitlebarCollapsed(HWND aWnd, bool aIsCollapsed);
protected:
~WindowsUIUtils();
diff --git a/widget/windows/moz.build b/widget/windows/moz.build
@@ -146,6 +146,13 @@ SOURCES += [
"TSFUtils.cpp",
]
+# Needs winrt exceptions since we're calling into the
+# Windows App SDK.
+SOURCES["WindowsUIUtils.cpp"].flags += [
+ "-Xclang",
+ "-fcxx-exceptions",
+]
+
if CONFIG["NS_PRINTING"]:
UNIFIED_SOURCES += [
"nsDeviceContextSpecWin.cpp",
diff --git a/widget/windows/nsWindow.cpp b/widget/windows/nsWindow.cpp
@@ -1091,9 +1091,6 @@ nsresult nsWindow::Create(nsIWidget* aParent, const LayoutDeviceIntRect& aRect,
DesktopIntRect::Round(LayoutDeviceRect(GetBounds()) / scale)
.ToUnknownRect());
- // Skeleton ui is disabled when custom titlebar is off, see bug 1673092.
- SetCustomTitlebar(true);
-
// Reset the WNDPROC for this window and its whole class, as we had
// to use our own WNDPROC when creating the the skeleton UI window.
::SetWindowLongPtrW(mWnd, GWLP_WNDPROC,
@@ -2845,42 +2842,14 @@ void nsWindow::SetCustomTitlebar(bool aCustomTitlebar) {
mCustomNonClient = aCustomTitlebar;
- const LONG_PTR style = GetWindowLongPtrW(mWnd, GWL_STYLE);
// Force a reflow of content based on the new client dimensions.
if (mCustomNonClient) {
- if (style & WS_SYSMENU) {
- // Remove the WS_SYSMENU style, so that DWM doesn't draw the caption
- // buttons. Note that we still need WS_MAXIMIZEBOX at least to
- // support Snap Layouts / Aero Snap.
- //
- // This behavior is not documented: per MSDN, WS_MAXIMIZEBOX simply
- // requires WS_SYSMENU, and is not valid without it. However, omitting it
- // doesn't seem to have negative side-effects on any version of Windows
- // tested (other than losing the default system menu handling, which we
- // implement ourselves in DisplaySystemMenu()).
- //
- // Since the system menu is lazily initialized (see [1]), we have to call
- // GetSystemMenu() here in order to get it created before it is too late.
- // An alternative would be to play with window styles later to force it
- // to be created, but that seems a bit more finicky.
- //
- // [1]: https://devblogs.microsoft.com/oldnewthing/20100528-00/?p=13893
- ::GetSystemMenu(mWnd, FALSE);
- ::SetWindowLongPtrW(mWnd, GWL_STYLE, style & ~WS_SYSMENU);
- }
UpdateNonClientMargins();
} else {
- if (WindowStyle() & WS_SYSMENU) {
- // Restore the WS_SYSMENU style if appropriate.
- ::SetWindowLongPtrW(mWnd, GWL_STYLE, style | WS_SYSMENU);
- // Reset the small icon as a workaround for a dwm bug, see bug 1935542.
- HICON icon =
- (HICON)::SendMessageW(mWnd, WM_SETICON, (WPARAM)ICON_SMALL, 0);
- ::SendMessageW(mWnd, WM_SETICON, (WPARAM)ICON_SMALL, (LPARAM)icon);
- }
mCustomNonClientMetrics = {};
ResetLayout();
}
+ WindowsUIUtils::SetIsTitlebarCollapsed(mWnd, mCustomNonClient);
}
void nsWindow::SetResizeMargin(mozilla::LayoutDeviceIntCoord aResizeMargin) {
@@ -4691,7 +4660,7 @@ static bool DisplaySystemMenu(HWND hWnd, nsSizeMode sizeMode, bool isRtl,
NS_ASSERTION(false, "Did the argument come from invalid IPC?");
break;
default:
- MOZ_ASSERT_UNREACHABLE("Unhnalded nsSizeMode value detected");
+ MOZ_ASSERT_UNREACHABLE("Unhandled nsSizeMode value detected");
break;
}
LPARAM cmd = TrackPopupMenu(hMenu,
@@ -5868,9 +5837,9 @@ bool nsWindow::ProcessMessageInternal(UINT msg, WPARAM& wParam, LPARAM& lParam,
if (filteredWParam == SC_KEYMENU && lParam == VK_SPACE) {
const auto sizeMode = mFrameState->GetSizeMode();
- // Handle the system menu manually when we're in full screen mode or
- // with custom titlebar so we can set the appropriate options.
- if (sizeMode == nsSizeMode_Fullscreen || mCustomNonClient) {
+ // Handle the system menu manually when we're in full screen mode
+ // so we can set the appropriate options.
+ if (sizeMode == nsSizeMode_Fullscreen) {
// Historically on fullscreen windows we've used this offset from the
// top left as our context menu position. Note that if the point we
// supply is offscreen, Windows will still try to put our menu in the