Skip to content

Commit

Permalink
Clear the system menu when we refrigerate a window (#16225)
Browse files Browse the repository at this point in the history
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 d8c7719)
Service-Card-Id: 90928408
Service-Version: 1.19
  • Loading branch information
zadjii-msft authored and DHowett committed Oct 26, 2023
1 parent c2fde69 commit 188a2ae
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/cascadia/WindowsTerminal/AppHost.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -484,7 +484,7 @@ void AppHost::_revokeWindowCallbacks()
// I suspect WinUI wouldn't like that very much. As such unregister all event handlers first.
_revokers = {};
_showHideWindowThrottler.reset();

_stopFrameTimer();
_revokeWindowCallbacks();

// DO NOT CLOSE THE WINDOW
Expand Down
8 changes: 8 additions & 0 deletions src/cascadia/WindowsTerminal/IslandWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ void IslandWindow::Refrigerate() noexcept
// This pointer will get re-set in _warmInitialize
SetWindowLongPtr(_window.get(), GWLP_USERDATA, 0);

_resetSystemMenu();

_pfnCreateCallback = nullptr;
_pfnSnapDimensionCallback = nullptr;

Expand Down Expand Up @@ -1917,6 +1919,12 @@ void IslandWindow::RemoveFromSystemMenu(const winrt::hstring& itemLabel)
_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)
{
const BOOL attribute = v ? TRUE : FALSE;
Expand Down
1 change: 1 addition & 0 deletions src/cascadia/WindowsTerminal/IslandWindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@ class IslandWindow :

std::unordered_map<UINT, SystemMenuItemInfo> _systemMenuItems;
UINT _systemMenuNextItemId;
void _resetSystemMenu();

private:
// This minimum width allows for width the tabs fit
Expand Down

0 comments on commit 188a2ae

Please sign in to comment.