diff --git a/src/cascadia/TerminalApp/MinMaxCloseControl.cpp b/src/cascadia/TerminalApp/MinMaxCloseControl.cpp index 233c1dae5..03b4f4113 100644 --- a/src/cascadia/TerminalApp/MinMaxCloseControl.cpp +++ b/src/cascadia/TerminalApp/MinMaxCloseControl.cpp @@ -148,6 +148,15 @@ namespace winrt::TerminalApp::implementation // - button: the button that was hovered void MinMaxCloseControl::HoverButton(CaptionButton button) { + // Keep track of the button that's been pressed. we get a mouse move + // message when we open the tooltip. If we move the mouse on top of this + // button, that we've already pressed, then no need to move to the + // "hovered" state, we should stay in the pressed state. + if (_lastPressedButton && _lastPressedButton.value() == button) + { + return; + } + switch (button) { case CaptionButton::Minimize: @@ -207,6 +216,7 @@ namespace winrt::TerminalApp::implementation VisualStateManager::GoToState(CloseButton(), L"Pressed", false); break; } + _lastPressedButton = button; } // Method Description: @@ -222,5 +232,7 @@ namespace winrt::TerminalApp::implementation _closeToolTipForButton(MinimizeButton()); _closeToolTipForButton(MaximizeButton()); _closeToolTipForButton(CloseButton()); + + _lastPressedButton = std::nullopt; } } diff --git a/src/cascadia/TerminalApp/MinMaxCloseControl.h b/src/cascadia/TerminalApp/MinMaxCloseControl.h index c4da0f86a..0c336f256 100644 --- a/src/cascadia/TerminalApp/MinMaxCloseControl.h +++ b/src/cascadia/TerminalApp/MinMaxCloseControl.h @@ -34,6 +34,7 @@ namespace winrt::TerminalApp::implementation TYPED_EVENT(CloseClick, TerminalApp::MinMaxCloseControl, winrt::Windows::UI::Xaml::RoutedEventArgs); std::shared_ptr> _displayToolTip{ nullptr }; + std::optional _lastPressedButton{ std::nullopt }; }; } diff --git a/src/cascadia/TerminalApp/TitlebarControl.cpp b/src/cascadia/TerminalApp/TitlebarControl.cpp index 2f4c1ccb9..4f3da96b5 100644 --- a/src/cascadia/TerminalApp/TitlebarControl.cpp +++ b/src/cascadia/TerminalApp/TitlebarControl.cpp @@ -25,6 +25,8 @@ namespace winrt::TerminalApp::implementation double TitlebarControl::CaptionButtonWidth() { + // Divide by three, since we know there are only three buttons. When + // Windows 12 comes along and adds another, we can update this /s static double width{ MinMaxCloseControl().ActualWidth() / 3.0 }; return width; }