Clear the system menu when we refrigerate a window (#16225)

As in the title. Also fixes a crash for refrigeration with the rainbow
border.

Closes #16211

Tested by manually forcing us into Windows 10 mode (to refrigerate the
window). That immediately repros the bug, which was simple enough to
fix.

(cherry picked from commit d8c7719bfb)
Service-Card-Id: 90928407
Service-Version: 1.18
This commit is contained in:
Mike Griese
2023-10-24 13:28:59 -05:00
committed by Dustin L. Howett
parent 8261d52f56
commit dc0cbf8275
3 changed files with 10 additions and 1 deletions

View File

@@ -470,7 +470,7 @@ void AppHost::_revokeWindowCallbacks()
// I suspect WinUI wouldn't like that very much. As such unregister all event handlers first. // I suspect WinUI wouldn't like that very much. As such unregister all event handlers first.
_revokers = {}; _revokers = {};
_showHideWindowThrottler.reset(); _showHideWindowThrottler.reset();
_stopFrameTimer();
_revokeWindowCallbacks(); _revokeWindowCallbacks();
// DO NOT CLOSE THE WINDOW // DO NOT CLOSE THE WINDOW

View File

@@ -73,6 +73,8 @@ void IslandWindow::Refrigerate() noexcept
// This pointer will get re-set in _warmInitialize // This pointer will get re-set in _warmInitialize
SetWindowLongPtr(_window.get(), GWLP_USERDATA, 0); SetWindowLongPtr(_window.get(), GWLP_USERDATA, 0);
_resetSystemMenu();
_pfnCreateCallback = nullptr; _pfnCreateCallback = nullptr;
_pfnSnapDimensionCallback = nullptr; _pfnSnapDimensionCallback = nullptr;
@@ -1917,6 +1919,12 @@ void IslandWindow::RemoveFromSystemMenu(const winrt::hstring& itemLabel)
_systemMenuItems.erase(it->first); _systemMenuItems.erase(it->first);
} }
void IslandWindow::_resetSystemMenu()
{
// GetSystemMenu(..., true) will revert the menu to the default state.
GetSystemMenu(_window.get(), TRUE);
}
void IslandWindow::UseDarkTheme(const bool v) void IslandWindow::UseDarkTheme(const bool v)
{ {
const BOOL attribute = v ? TRUE : FALSE; const BOOL attribute = v ? TRUE : FALSE;

View File

@@ -159,6 +159,7 @@ protected:
std::unordered_map<UINT, SystemMenuItemInfo> _systemMenuItems; std::unordered_map<UINT, SystemMenuItemInfo> _systemMenuItems;
UINT _systemMenuNextItemId; UINT _systemMenuNextItemId;
void _resetSystemMenu();
private: private:
// This minimum width allows for width the tabs fit // This minimum width allows for width the tabs fit