Manually dismiss popups when the window moves, or the SUI scrolls (#10922)
## Summary of the Pull Request BODGY! This solution was suggested in https://github.com/microsoft/microsoft-ui-xaml/issues/4554#issuecomment-887815332. When the window moves, or when a ScrollViewer scrolls, dismiss any popups that are visible. This happens automagically when an app is a real XAML app, but it doesn't work for XAML Islands. ## References * upstream at https://github.com/microsoft/microsoft-ui-xaml/issues/4554 ## PR Checklist * [x] Closes #9320 * [x] I work here * [ ] Tests added/passed * [ ] Requires documentation to be updated ## Detailed Description of the Pull Request / Additional comments Unfortunately, we've got a bunch of scroll viewers in our SUI. So I did something bodgyx2 to make our life a little easier. `DismissAllPopups` can be used to dismiss all popups for a particular UI element. However, we've got a bunch of pages with scroll viewers that may or may not have popups in them. Rather than define the same exact body for all their `ViewChanging` events, the `HasScrollViewer` struct will just do it for you! Inside the `HasScrollViewer` stuct, we can't get at the `XamlRoot()` that our subclass implements. I mean, _we_ can, but when XAML does it's codegen, _XAML_ won't be able to figure it out. Fortunately for us, we don't need to! The sender is a UIElement, so we can just get _their_ `XamlRoot()`. So, you can fix this for any SUI page with just a simple ```diff - <ScrollViewer> + <ScrollViewer ViewChanging="ViewChanging"> ``` ```diff - struct AddProfile : AddProfileT<AddProfile> + struct AddProfile : public HasScrollViewer<AddProfile>, AddProfileT<AddProfile> ``` ## Validation Steps Performed * the window doesn't close when you move it * the popups _do_ close when you move the window * the popups close when you scroll any SUI page
This commit is contained in:
parent
5d36e5d2df
commit
29be8564f6
|
@ -107,7 +107,7 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation
|
||||||
WINRT_PROPERTY(Model::CascadiaSettings, Settings, nullptr)
|
WINRT_PROPERTY(Model::CascadiaSettings, Settings, nullptr)
|
||||||
};
|
};
|
||||||
|
|
||||||
struct Actions : ActionsT<Actions>
|
struct Actions : public HasScrollViewer<Actions>, ActionsT<Actions>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Actions();
|
Actions();
|
||||||
|
|
|
@ -374,7 +374,7 @@
|
||||||
</ResourceDictionary>
|
</ResourceDictionary>
|
||||||
</Page.Resources>
|
</Page.Resources>
|
||||||
|
|
||||||
<ScrollViewer>
|
<ScrollViewer ViewChanging="ViewChanging">
|
||||||
<StackPanel MaxWidth="600"
|
<StackPanel MaxWidth="600"
|
||||||
Spacing="8"
|
Spacing="8"
|
||||||
Style="{StaticResource SettingsStackStyle}">
|
Style="{StaticResource SettingsStackStyle}">
|
||||||
|
|
|
@ -43,7 +43,7 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation
|
||||||
WINRT_CALLBACK(AddNew, AddNewArgs);
|
WINRT_CALLBACK(AddNew, AddNewArgs);
|
||||||
};
|
};
|
||||||
|
|
||||||
struct AddProfile : AddProfileT<AddProfile>
|
struct AddProfile : public HasScrollViewer<AddProfile>, AddProfileT<AddProfile>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
AddProfile();
|
AddProfile();
|
||||||
|
|
|
@ -21,7 +21,7 @@
|
||||||
</ResourceDictionary>
|
</ResourceDictionary>
|
||||||
</Page.Resources>
|
</Page.Resources>
|
||||||
|
|
||||||
<ScrollViewer>
|
<ScrollViewer ViewChanging="ViewChanging">
|
||||||
<StackPanel Style="{StaticResource SettingsStackStyle}">
|
<StackPanel Style="{StaticResource SettingsStackStyle}">
|
||||||
<Button x:Uid="AddProfile_AddNewButton"
|
<Button x:Uid="AddProfile_AddNewButton"
|
||||||
AutomationProperties.AutomationId="AddProfile_AddNewButton"
|
AutomationProperties.AutomationId="AddProfile_AddNewButton"
|
||||||
|
|
|
@ -20,7 +20,7 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation
|
||||||
WINRT_PROPERTY(winrt::hstring, LastSelectedScheme, L"");
|
WINRT_PROPERTY(winrt::hstring, LastSelectedScheme, L"");
|
||||||
};
|
};
|
||||||
|
|
||||||
struct ColorSchemes : ColorSchemesT<ColorSchemes>
|
struct ColorSchemes : public HasScrollViewer<ColorSchemes>, ColorSchemesT<ColorSchemes>
|
||||||
{
|
{
|
||||||
ColorSchemes();
|
ColorSchemes();
|
||||||
|
|
||||||
|
|
|
@ -93,7 +93,7 @@
|
||||||
</ResourceDictionary>
|
</ResourceDictionary>
|
||||||
</Page.Resources>
|
</Page.Resources>
|
||||||
|
|
||||||
<ScrollViewer>
|
<ScrollViewer ViewChanging="ViewChanging">
|
||||||
<StackPanel Margin="{StaticResource StandardIndentMargin}"
|
<StackPanel Margin="{StaticResource StandardIndentMargin}"
|
||||||
Spacing="24">
|
Spacing="24">
|
||||||
|
|
||||||
|
|
|
@ -18,7 +18,7 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation
|
||||||
WINRT_PROPERTY(Model::GlobalAppSettings, Globals, nullptr)
|
WINRT_PROPERTY(Model::GlobalAppSettings, Globals, nullptr)
|
||||||
};
|
};
|
||||||
|
|
||||||
struct GlobalAppearance : GlobalAppearanceT<GlobalAppearance>
|
struct GlobalAppearance : public HasScrollViewer<GlobalAppearance>, GlobalAppearanceT<GlobalAppearance>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
GlobalAppearance();
|
GlobalAppearance();
|
||||||
|
|
|
@ -24,7 +24,7 @@
|
||||||
</ResourceDictionary>
|
</ResourceDictionary>
|
||||||
</Page.Resources>
|
</Page.Resources>
|
||||||
|
|
||||||
<ScrollViewer>
|
<ScrollViewer ViewChanging="ViewChanging">
|
||||||
<StackPanel Style="{StaticResource SettingsStackStyle}">
|
<StackPanel Style="{StaticResource SettingsStackStyle}">
|
||||||
<!-- Language -->
|
<!-- Language -->
|
||||||
<local:SettingContainer x:Uid="Globals_Language"
|
<local:SettingContainer x:Uid="Globals_Language"
|
||||||
|
|
|
@ -18,7 +18,7 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation
|
||||||
WINRT_PROPERTY(Model::GlobalAppSettings, Globals, nullptr)
|
WINRT_PROPERTY(Model::GlobalAppSettings, Globals, nullptr)
|
||||||
};
|
};
|
||||||
|
|
||||||
struct Interaction : InteractionT<Interaction>
|
struct Interaction : public HasScrollViewer<Interaction>, InteractionT<Interaction>
|
||||||
{
|
{
|
||||||
Interaction();
|
Interaction();
|
||||||
|
|
||||||
|
|
|
@ -24,7 +24,7 @@
|
||||||
</ResourceDictionary>
|
</ResourceDictionary>
|
||||||
</Page.Resources>
|
</Page.Resources>
|
||||||
|
|
||||||
<ScrollViewer>
|
<ScrollViewer ViewChanging="ViewChanging">
|
||||||
<StackPanel Style="{StaticResource SettingsStackStyle}">
|
<StackPanel Style="{StaticResource SettingsStackStyle}">
|
||||||
<!-- Copy On Select -->
|
<!-- Copy On Select -->
|
||||||
<local:SettingContainer x:Uid="Globals_CopyOnSelect"
|
<local:SettingContainer x:Uid="Globals_CopyOnSelect"
|
||||||
|
|
|
@ -18,7 +18,7 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation
|
||||||
WINRT_PROPERTY(Model::CascadiaSettings, Settings, nullptr)
|
WINRT_PROPERTY(Model::CascadiaSettings, Settings, nullptr)
|
||||||
};
|
};
|
||||||
|
|
||||||
struct Launch : LaunchT<Launch>
|
struct Launch : public HasScrollViewer<Launch>, LaunchT<Launch>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Launch();
|
Launch();
|
||||||
|
|
|
@ -33,7 +33,7 @@
|
||||||
</ResourceDictionary>
|
</ResourceDictionary>
|
||||||
</Page.Resources>
|
</Page.Resources>
|
||||||
|
|
||||||
<ScrollViewer>
|
<ScrollViewer ViewChanging="ViewChanging">
|
||||||
<StackPanel>
|
<StackPanel>
|
||||||
<StackPanel Style="{StaticResource SettingsStackStyle}">
|
<StackPanel Style="{StaticResource SettingsStackStyle}">
|
||||||
<!-- Default Profile -->
|
<!-- Default Profile -->
|
||||||
|
|
|
@ -153,7 +153,7 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation
|
||||||
Windows::Foundation::Collections::IMapView<hstring, Model::ColorScheme> _Schemes;
|
Windows::Foundation::Collections::IMapView<hstring, Model::ColorScheme> _Schemes;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct Profiles : ProfilesT<Profiles>
|
struct Profiles : public HasScrollViewer<Profiles>, ProfilesT<Profiles>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Profiles();
|
Profiles();
|
||||||
|
|
|
@ -56,7 +56,7 @@
|
||||||
SelectionChanged="Pivot_SelectionChanged">
|
SelectionChanged="Pivot_SelectionChanged">
|
||||||
<!-- General Tab -->
|
<!-- General Tab -->
|
||||||
<PivotItem x:Uid="Profile_General">
|
<PivotItem x:Uid="Profile_General">
|
||||||
<ScrollViewer>
|
<ScrollViewer ViewChanging="ViewChanging">
|
||||||
<StackPanel Style="{StaticResource PivotStackStyle}">
|
<StackPanel Style="{StaticResource PivotStackStyle}">
|
||||||
|
|
||||||
<!-- Name -->
|
<!-- Name -->
|
||||||
|
@ -225,7 +225,7 @@
|
||||||
|
|
||||||
<!-- Appearance Tab -->
|
<!-- Appearance Tab -->
|
||||||
<PivotItem x:Uid="Profile_Appearance">
|
<PivotItem x:Uid="Profile_Appearance">
|
||||||
<ScrollViewer>
|
<ScrollViewer ViewChanging="ViewChanging">
|
||||||
<StackPanel>
|
<StackPanel>
|
||||||
<!-- Control Preview -->
|
<!-- Control Preview -->
|
||||||
<Border x:Name="ControlPreview"
|
<Border x:Name="ControlPreview"
|
||||||
|
@ -397,7 +397,7 @@
|
||||||
|
|
||||||
<!-- Advanced Tab -->
|
<!-- Advanced Tab -->
|
||||||
<PivotItem x:Uid="Profile_Advanced">
|
<PivotItem x:Uid="Profile_Advanced">
|
||||||
<ScrollViewer>
|
<ScrollViewer ViewChanging="ViewChanging">
|
||||||
<StackPanel Style="{StaticResource PivotStackStyle}">
|
<StackPanel Style="{StaticResource PivotStackStyle}">
|
||||||
<!-- Suppress Application Title -->
|
<!-- Suppress Application Title -->
|
||||||
<local:SettingContainer x:Uid="Profile_SuppressApplicationTitle"
|
<local:SettingContainer x:Uid="Profile_SuppressApplicationTitle"
|
||||||
|
|
|
@ -32,7 +32,7 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation
|
||||||
TYPED_EVENT(OpenJson, Windows::Foundation::IInspectable, Model::SettingsTarget);
|
TYPED_EVENT(OpenJson, Windows::Foundation::IInspectable, Model::SettingsTarget);
|
||||||
};
|
};
|
||||||
|
|
||||||
struct ReadOnlyActions : ReadOnlyActionsT<ReadOnlyActions>
|
struct ReadOnlyActions : public HasScrollViewer<ReadOnlyActions>, ReadOnlyActionsT<ReadOnlyActions>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
ReadOnlyActions();
|
ReadOnlyActions();
|
||||||
|
|
|
@ -182,7 +182,7 @@
|
||||||
</ResourceDictionary>
|
</ResourceDictionary>
|
||||||
</Page.Resources>
|
</Page.Resources>
|
||||||
|
|
||||||
<ScrollViewer>
|
<ScrollViewer ViewChanging="ViewChanging">
|
||||||
<StackPanel Style="{StaticResource SettingsStackStyle}">
|
<StackPanel Style="{StaticResource SettingsStackStyle}">
|
||||||
<TextBlock x:Uid="Globals_KeybindingsDisclaimer"
|
<TextBlock x:Uid="Globals_KeybindingsDisclaimer"
|
||||||
Style="{StaticResource DisclaimerStyle}" />
|
Style="{StaticResource DisclaimerStyle}" />
|
||||||
|
|
|
@ -18,7 +18,7 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation
|
||||||
WINRT_PROPERTY(Model::GlobalAppSettings, Globals, nullptr)
|
WINRT_PROPERTY(Model::GlobalAppSettings, Globals, nullptr)
|
||||||
};
|
};
|
||||||
|
|
||||||
struct Rendering : RenderingT<Rendering>
|
struct Rendering : public HasScrollViewer<Rendering>, RenderingT<Rendering>
|
||||||
{
|
{
|
||||||
Rendering();
|
Rendering();
|
||||||
|
|
||||||
|
|
|
@ -18,7 +18,7 @@
|
||||||
</ResourceDictionary>
|
</ResourceDictionary>
|
||||||
</Page.Resources>
|
</Page.Resources>
|
||||||
|
|
||||||
<ScrollViewer>
|
<ScrollViewer ViewChanging="ViewChanging">
|
||||||
<StackPanel Style="{StaticResource SettingsStackStyle}">
|
<StackPanel Style="{StaticResource SettingsStackStyle}">
|
||||||
<TextBlock x:Uid="Globals_RenderingDisclaimer"
|
<TextBlock x:Uid="Globals_RenderingDisclaimer"
|
||||||
Style="{StaticResource DisclaimerStyle}" />
|
Style="{StaticResource DisclaimerStyle}" />
|
||||||
|
|
|
@ -138,3 +138,41 @@ namespace winrt::Microsoft::Terminal::Settings
|
||||||
winrt::hstring GetSelectedItemTag(winrt::Windows::Foundation::IInspectable const& comboBoxAsInspectable);
|
winrt::hstring GetSelectedItemTag(winrt::Windows::Foundation::IInspectable const& comboBoxAsInspectable);
|
||||||
winrt::hstring LocalizedNameForEnumName(const std::wstring_view sectionAndType, const std::wstring_view enumValue, const std::wstring_view propertyType);
|
winrt::hstring LocalizedNameForEnumName(const std::wstring_view sectionAndType, const std::wstring_view enumValue, const std::wstring_view propertyType);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// BODGY!
|
||||||
|
//
|
||||||
|
// The following function and struct are a workaround for GH#9320.
|
||||||
|
//
|
||||||
|
// DismissAllPopups can be used to dismiss all popups for a particular UI
|
||||||
|
// element. However, we've got a bunch of pages with scroll viewers that may or
|
||||||
|
// may not have popups in them. Rather than define the same exact body for all
|
||||||
|
// their ViewChanging events, the HasScrollViewer struct will just do it for
|
||||||
|
// you!
|
||||||
|
inline void DismissAllPopups(winrt::Windows::UI::Xaml::XamlRoot const& xamlRoot)
|
||||||
|
{
|
||||||
|
const auto popups{ winrt::Windows::UI::Xaml::Media::VisualTreeHelper::GetOpenPopupsForXamlRoot(xamlRoot) };
|
||||||
|
for (const auto& p : popups)
|
||||||
|
{
|
||||||
|
p.IsOpen(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
struct HasScrollViewer
|
||||||
|
{
|
||||||
|
// When the ScrollViewer scrolls, dismiss any popups we might have.
|
||||||
|
void ViewChanging(winrt::Windows::Foundation::IInspectable const& sender,
|
||||||
|
const winrt::Windows::UI::Xaml::Controls::ScrollViewerViewChangingEventArgs& /*e*/)
|
||||||
|
{
|
||||||
|
// Inside this struct, we can't get at the XamlRoot() that our subclass
|
||||||
|
// implements. I mean, _we_ can, but when XAML does it's code
|
||||||
|
// generation, _XAML_ won't be able to figure it out.
|
||||||
|
//
|
||||||
|
// Fortunately for us, we don't need to! The sender is a UIElement, so
|
||||||
|
// we can just get _their_ XamlRoot().
|
||||||
|
if (const auto& uielem{ sender.try_as<winrt::Windows::UI::Xaml::UIElement>() })
|
||||||
|
{
|
||||||
|
DismissAllPopups(uielem.XamlRoot());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
|
@ -79,6 +79,7 @@ AppHost::AppHost() noexcept :
|
||||||
std::placeholders::_2));
|
std::placeholders::_2));
|
||||||
_window->MouseScrolled({ this, &AppHost::_WindowMouseWheeled });
|
_window->MouseScrolled({ this, &AppHost::_WindowMouseWheeled });
|
||||||
_window->WindowActivated({ this, &AppHost::_WindowActivated });
|
_window->WindowActivated({ this, &AppHost::_WindowActivated });
|
||||||
|
_window->WindowMoved({ this, &AppHost::_WindowMoved });
|
||||||
_window->HotkeyPressed({ this, &AppHost::_GlobalHotkeyPressed });
|
_window->HotkeyPressed({ this, &AppHost::_GlobalHotkeyPressed });
|
||||||
_window->SetAlwaysOnTop(_logic.GetInitialAlwaysOnTop());
|
_window->SetAlwaysOnTop(_logic.GetInitialAlwaysOnTop());
|
||||||
_window->MakeWindow();
|
_window->MakeWindow();
|
||||||
|
@ -1095,3 +1096,29 @@ winrt::fire_and_forget AppHost::_HideTrayIconRequested()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Method Description:
|
||||||
|
// - BODGY workaround for GH#9320. When the window moves, dismiss all the popups
|
||||||
|
// in the UI tree. Xaml Islands unfortunately doesn't do this for us, see
|
||||||
|
// microsoft/microsoft-ui-xaml#4554
|
||||||
|
// Arguments:
|
||||||
|
// - <none>
|
||||||
|
// Return Value:
|
||||||
|
// - <none>
|
||||||
|
void AppHost::_WindowMoved()
|
||||||
|
{
|
||||||
|
if (_logic)
|
||||||
|
{
|
||||||
|
const auto root{ _logic.GetRoot() };
|
||||||
|
|
||||||
|
// This is basically DismissAllPopups which is also in
|
||||||
|
// TerminalSettingsEditor/Utils.h
|
||||||
|
// There isn't a good place that's shared between these two files, but
|
||||||
|
// it's only 5 LOC so whatever.
|
||||||
|
const auto popups{ Media::VisualTreeHelper::GetOpenPopupsForXamlRoot(root.XamlRoot()) };
|
||||||
|
for (const auto& p : popups)
|
||||||
|
{
|
||||||
|
p.IsOpen(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -48,6 +48,7 @@ private:
|
||||||
const winrt::Windows::Foundation::IInspectable& arg);
|
const winrt::Windows::Foundation::IInspectable& arg);
|
||||||
void _WindowMouseWheeled(const til::point coord, const int32_t delta);
|
void _WindowMouseWheeled(const til::point coord, const int32_t delta);
|
||||||
winrt::fire_and_forget _WindowActivated();
|
winrt::fire_and_forget _WindowActivated();
|
||||||
|
void _WindowMoved();
|
||||||
|
|
||||||
void _DispatchCommandline(winrt::Windows::Foundation::IInspectable sender,
|
void _DispatchCommandline(winrt::Windows::Foundation::IInspectable sender,
|
||||||
winrt::Microsoft::Terminal::Remoting::CommandlineArgs args);
|
winrt::Microsoft::Terminal::Remoting::CommandlineArgs args);
|
||||||
|
|
|
@ -465,6 +465,11 @@ long IslandWindow::_calculateTotalSize(const bool isWidth, const long clientSize
|
||||||
{
|
{
|
||||||
return _OnMoving(wparam, lparam);
|
return _OnMoving(wparam, lparam);
|
||||||
}
|
}
|
||||||
|
case WM_MOVE:
|
||||||
|
{
|
||||||
|
_WindowMovedHandlers();
|
||||||
|
break;
|
||||||
|
}
|
||||||
case WM_CLOSE:
|
case WM_CLOSE:
|
||||||
{
|
{
|
||||||
// If the user wants to close the app by clicking 'X' button,
|
// If the user wants to close the app by clicking 'X' button,
|
||||||
|
|
|
@ -1,135 +1,138 @@
|
||||||
// Copyright (c) Microsoft Corporation.
|
// Copyright (c) Microsoft Corporation.
|
||||||
// Licensed under the MIT license.
|
// Licensed under the MIT license.
|
||||||
|
|
||||||
#include "pch.h"
|
#include "pch.h"
|
||||||
#include "BaseWindow.h"
|
#include "BaseWindow.h"
|
||||||
#include <winrt/TerminalApp.h>
|
#include <winrt/TerminalApp.h>
|
||||||
#include "../../cascadia/inc/cppwinrt_utils.h"
|
#include "../../cascadia/inc/cppwinrt_utils.h"
|
||||||
|
|
||||||
class IslandWindow :
|
class IslandWindow :
|
||||||
public BaseWindow<IslandWindow>
|
public BaseWindow<IslandWindow>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
IslandWindow() noexcept;
|
IslandWindow() noexcept;
|
||||||
virtual ~IslandWindow() override;
|
virtual ~IslandWindow() override;
|
||||||
|
|
||||||
virtual void MakeWindow() noexcept;
|
virtual void MakeWindow() noexcept;
|
||||||
void Close();
|
void Close();
|
||||||
virtual void OnSize(const UINT width, const UINT height);
|
virtual void OnSize(const UINT width, const UINT height);
|
||||||
|
|
||||||
[[nodiscard]] virtual LRESULT MessageHandler(UINT const message, WPARAM const wparam, LPARAM const lparam) noexcept override;
|
[[nodiscard]] virtual LRESULT MessageHandler(UINT const message, WPARAM const wparam, LPARAM const lparam) noexcept override;
|
||||||
void OnResize(const UINT width, const UINT height) override;
|
void OnResize(const UINT width, const UINT height) override;
|
||||||
void OnMinimize() override;
|
void OnMinimize() override;
|
||||||
void OnRestore() override;
|
void OnRestore() override;
|
||||||
virtual void OnAppInitialized();
|
virtual void OnAppInitialized();
|
||||||
virtual void SetContent(winrt::Windows::UI::Xaml::UIElement content);
|
virtual void SetContent(winrt::Windows::UI::Xaml::UIElement content);
|
||||||
virtual void OnApplicationThemeChanged(const winrt::Windows::UI::Xaml::ElementTheme& requestedTheme);
|
virtual void OnApplicationThemeChanged(const winrt::Windows::UI::Xaml::ElementTheme& requestedTheme);
|
||||||
virtual RECT GetNonClientFrame(const UINT dpi) const noexcept;
|
virtual RECT GetNonClientFrame(const UINT dpi) const noexcept;
|
||||||
virtual SIZE GetTotalNonClientExclusiveSize(const UINT dpi) const noexcept;
|
virtual SIZE GetTotalNonClientExclusiveSize(const UINT dpi) const noexcept;
|
||||||
|
|
||||||
virtual void Initialize();
|
virtual void Initialize();
|
||||||
|
|
||||||
void SetCreateCallback(std::function<void(const HWND, const RECT, winrt::Microsoft::Terminal::Settings::Model::LaunchMode& launchMode)> pfn) noexcept;
|
void SetCreateCallback(std::function<void(const HWND, const RECT, winrt::Microsoft::Terminal::Settings::Model::LaunchMode& launchMode)> pfn) noexcept;
|
||||||
void SetSnapDimensionCallback(std::function<float(bool widthOrHeight, float dimension)> pfn) noexcept;
|
void SetSnapDimensionCallback(std::function<float(bool widthOrHeight, float dimension)> pfn) noexcept;
|
||||||
|
|
||||||
void FocusModeChanged(const bool focusMode);
|
void FocusModeChanged(const bool focusMode);
|
||||||
void FullscreenChanged(const bool fullscreen);
|
void FullscreenChanged(const bool fullscreen);
|
||||||
void SetAlwaysOnTop(const bool alwaysOnTop);
|
void SetAlwaysOnTop(const bool alwaysOnTop);
|
||||||
|
|
||||||
void FlashTaskbar();
|
void FlashTaskbar();
|
||||||
void SetTaskbarProgress(const size_t state, const size_t progress);
|
void SetTaskbarProgress(const size_t state, const size_t progress);
|
||||||
|
|
||||||
void UnregisterHotKey(const int index) noexcept;
|
void UnregisterHotKey(const int index) noexcept;
|
||||||
bool RegisterHotKey(const int index, const winrt::Microsoft::Terminal::Control::KeyChord& hotkey) noexcept;
|
bool RegisterHotKey(const int index, const winrt::Microsoft::Terminal::Control::KeyChord& hotkey) noexcept;
|
||||||
|
|
||||||
winrt::fire_and_forget SummonWindow(winrt::Microsoft::Terminal::Remoting::SummonWindowBehavior args);
|
winrt::fire_and_forget SummonWindow(winrt::Microsoft::Terminal::Remoting::SummonWindowBehavior args);
|
||||||
|
|
||||||
bool IsQuakeWindow() const noexcept;
|
bool IsQuakeWindow() const noexcept;
|
||||||
void IsQuakeWindow(bool isQuakeWindow) noexcept;
|
void IsQuakeWindow(bool isQuakeWindow) noexcept;
|
||||||
|
|
||||||
void HideWindow();
|
void HideWindow();
|
||||||
|
|
||||||
void SetMinimizeToTrayBehavior(bool minimizeToTray) noexcept;
|
void SetMinimizeToTrayBehavior(bool minimizeToTray) noexcept;
|
||||||
|
|
||||||
DECLARE_EVENT(DragRegionClicked, _DragRegionClickedHandlers, winrt::delegate<>);
|
DECLARE_EVENT(DragRegionClicked, _DragRegionClickedHandlers, winrt::delegate<>);
|
||||||
DECLARE_EVENT(WindowCloseButtonClicked, _windowCloseButtonClickedHandler, winrt::delegate<>);
|
DECLARE_EVENT(WindowCloseButtonClicked, _windowCloseButtonClickedHandler, winrt::delegate<>);
|
||||||
WINRT_CALLBACK(MouseScrolled, winrt::delegate<void(til::point, int32_t)>);
|
WINRT_CALLBACK(MouseScrolled, winrt::delegate<void(til::point, int32_t)>);
|
||||||
WINRT_CALLBACK(WindowActivated, winrt::delegate<void()>);
|
WINRT_CALLBACK(WindowActivated, winrt::delegate<void()>);
|
||||||
WINRT_CALLBACK(HotkeyPressed, winrt::delegate<void(long)>);
|
WINRT_CALLBACK(HotkeyPressed, winrt::delegate<void(long)>);
|
||||||
WINRT_CALLBACK(NotifyTrayIconPressed, winrt::delegate<void()>);
|
WINRT_CALLBACK(NotifyTrayIconPressed, winrt::delegate<void()>);
|
||||||
WINRT_CALLBACK(NotifyShowTrayContextMenu, winrt::delegate<void(til::point)>);
|
WINRT_CALLBACK(NotifyWindowHidden, winrt::delegate<void()>);
|
||||||
WINRT_CALLBACK(NotifyTrayMenuItemSelected, winrt::delegate<void(HMENU, UINT)>);
|
WINRT_CALLBACK(NotifyShowTrayContextMenu, winrt::delegate<void(til::point)>);
|
||||||
WINRT_CALLBACK(NotifyReAddTrayIcon, winrt::delegate<void()>);
|
WINRT_CALLBACK(NotifyTrayMenuItemSelected, winrt::delegate<void(HMENU, UINT)>);
|
||||||
|
WINRT_CALLBACK(NotifyReAddTrayIcon, winrt::delegate<void()>);
|
||||||
protected:
|
|
||||||
void ForceResize()
|
WINRT_CALLBACK(WindowMoved, winrt::delegate<void()>);
|
||||||
{
|
|
||||||
// Do a quick resize to force the island to paint
|
protected:
|
||||||
const auto size = GetPhysicalSize();
|
void ForceResize()
|
||||||
OnSize(size.cx, size.cy);
|
{
|
||||||
}
|
// Do a quick resize to force the island to paint
|
||||||
|
const auto size = GetPhysicalSize();
|
||||||
HWND _interopWindowHandle;
|
OnSize(size.cx, size.cy);
|
||||||
|
}
|
||||||
winrt::Windows::UI::Xaml::Hosting::DesktopWindowXamlSource _source;
|
|
||||||
winrt::Windows::UI::Xaml::Controls::Grid _rootGrid;
|
HWND _interopWindowHandle;
|
||||||
wil::com_ptr<ITaskbarList3> _taskbar;
|
|
||||||
|
winrt::Windows::UI::Xaml::Hosting::DesktopWindowXamlSource _source;
|
||||||
std::function<void(const HWND, const RECT, winrt::Microsoft::Terminal::Settings::Model::LaunchMode& launchMode)> _pfnCreateCallback;
|
winrt::Windows::UI::Xaml::Controls::Grid _rootGrid;
|
||||||
std::function<float(bool, float)> _pfnSnapDimensionCallback;
|
wil::com_ptr<ITaskbarList3> _taskbar;
|
||||||
|
|
||||||
void _HandleCreateWindow(const WPARAM wParam, const LPARAM lParam) noexcept;
|
std::function<void(const HWND, const RECT, winrt::Microsoft::Terminal::Settings::Model::LaunchMode& launchMode)> _pfnCreateCallback;
|
||||||
[[nodiscard]] LRESULT _OnSizing(const WPARAM wParam, const LPARAM lParam);
|
std::function<float(bool, float)> _pfnSnapDimensionCallback;
|
||||||
[[nodiscard]] LRESULT _OnMoving(const WPARAM wParam, const LPARAM lParam);
|
|
||||||
|
void _HandleCreateWindow(const WPARAM wParam, const LPARAM lParam) noexcept;
|
||||||
bool _borderless{ false };
|
[[nodiscard]] LRESULT _OnSizing(const WPARAM wParam, const LPARAM lParam);
|
||||||
bool _alwaysOnTop{ false };
|
[[nodiscard]] LRESULT _OnMoving(const WPARAM wParam, const LPARAM lParam);
|
||||||
bool _fullscreen{ false };
|
|
||||||
bool _fWasMaximizedBeforeFullscreen{ false };
|
bool _borderless{ false };
|
||||||
RECT _rcWindowBeforeFullscreen{};
|
bool _alwaysOnTop{ false };
|
||||||
RECT _rcWorkBeforeFullscreen{};
|
bool _fullscreen{ false };
|
||||||
UINT _dpiBeforeFullscreen{ 96 };
|
bool _fWasMaximizedBeforeFullscreen{ false };
|
||||||
|
RECT _rcWindowBeforeFullscreen{};
|
||||||
virtual void _SetIsBorderless(const bool borderlessEnabled);
|
RECT _rcWorkBeforeFullscreen{};
|
||||||
virtual void _SetIsFullscreen(const bool fullscreenEnabled);
|
UINT _dpiBeforeFullscreen{ 96 };
|
||||||
void _RestoreFullscreenPosition(const RECT rcWork);
|
|
||||||
void _SetFullscreenPosition(const RECT rcMonitor, const RECT rcWork);
|
virtual void _SetIsBorderless(const bool borderlessEnabled);
|
||||||
|
virtual void _SetIsFullscreen(const bool fullscreenEnabled);
|
||||||
LONG _getDesiredWindowStyle() const;
|
void _RestoreFullscreenPosition(const RECT rcWork);
|
||||||
|
void _SetFullscreenPosition(const RECT rcMonitor, const RECT rcWork);
|
||||||
void _OnGetMinMaxInfo(const WPARAM wParam, const LPARAM lParam);
|
|
||||||
long _calculateTotalSize(const bool isWidth, const long clientSize, const long nonClientSize);
|
LONG _getDesiredWindowStyle() const;
|
||||||
|
|
||||||
void _globalActivateWindow(const uint32_t dropdownDuration,
|
void _OnGetMinMaxInfo(const WPARAM wParam, const LPARAM lParam);
|
||||||
const winrt::Microsoft::Terminal::Remoting::MonitorBehavior toMonitor);
|
long _calculateTotalSize(const bool isWidth, const long clientSize, const long nonClientSize);
|
||||||
void _dropdownWindow(const uint32_t dropdownDuration,
|
|
||||||
const winrt::Microsoft::Terminal::Remoting::MonitorBehavior toMonitor);
|
void _globalActivateWindow(const uint32_t dropdownDuration,
|
||||||
void _slideUpWindow(const uint32_t dropdownDuration);
|
const winrt::Microsoft::Terminal::Remoting::MonitorBehavior toMonitor);
|
||||||
void _doSlideAnimation(const uint32_t dropdownDuration, const bool down);
|
void _dropdownWindow(const uint32_t dropdownDuration,
|
||||||
void _globalDismissWindow(const uint32_t dropdownDuration);
|
const winrt::Microsoft::Terminal::Remoting::MonitorBehavior toMonitor);
|
||||||
|
void _slideUpWindow(const uint32_t dropdownDuration);
|
||||||
static MONITORINFO _getMonitorForCursor();
|
void _doSlideAnimation(const uint32_t dropdownDuration, const bool down);
|
||||||
static MONITORINFO _getMonitorForWindow(HWND foregroundWindow);
|
void _globalDismissWindow(const uint32_t dropdownDuration);
|
||||||
void _moveToMonitor(HWND foregroundWindow, const winrt::Microsoft::Terminal::Remoting::MonitorBehavior toMonitor);
|
|
||||||
void _moveToMonitorOfMouse();
|
static MONITORINFO _getMonitorForCursor();
|
||||||
void _moveToMonitorOf(HWND foregroundWindow);
|
static MONITORINFO _getMonitorForWindow(HWND foregroundWindow);
|
||||||
void _moveToMonitor(const MONITORINFO activeMonitor);
|
void _moveToMonitor(HWND foregroundWindow, const winrt::Microsoft::Terminal::Remoting::MonitorBehavior toMonitor);
|
||||||
|
void _moveToMonitorOfMouse();
|
||||||
bool _isQuakeWindow{ false };
|
void _moveToMonitorOf(HWND foregroundWindow);
|
||||||
|
void _moveToMonitor(const MONITORINFO activeMonitor);
|
||||||
void _enterQuakeMode();
|
|
||||||
til::rectangle _getQuakeModeSize(HMONITOR hmon);
|
bool _isQuakeWindow{ false };
|
||||||
|
|
||||||
void _summonWindowRoutineBody(winrt::Microsoft::Terminal::Remoting::SummonWindowBehavior args);
|
void _enterQuakeMode();
|
||||||
|
til::rectangle _getQuakeModeSize(HMONITOR hmon);
|
||||||
bool _minimizeToTray{ false };
|
|
||||||
|
void _summonWindowRoutineBody(winrt::Microsoft::Terminal::Remoting::SummonWindowBehavior args);
|
||||||
private:
|
|
||||||
// This minimum width allows for width the tabs fit
|
bool _minimizeToTray{ false };
|
||||||
static constexpr long minimumWidth = 460L;
|
|
||||||
|
private:
|
||||||
// We run with no height requirement for client area,
|
// This minimum width allows for width the tabs fit
|
||||||
// though the total height will take into account the non-client area
|
static constexpr long minimumWidth = 460L;
|
||||||
// and the requirements of components hosted in the client area
|
|
||||||
static constexpr long minimumHeight = 0L;
|
// We run with no height requirement for client area,
|
||||||
};
|
// though the total height will take into account the non-client area
|
||||||
|
// and the requirements of components hosted in the client area
|
||||||
|
static constexpr long minimumHeight = 0L;
|
||||||
|
};
|
||||||
|
|
|
@ -60,8 +60,10 @@ Abstract:
|
||||||
// * Controls for grid
|
// * Controls for grid
|
||||||
// * Media for ScaleTransform
|
// * Media for ScaleTransform
|
||||||
// * ApplicationModel for finding the path to wt.exe
|
// * ApplicationModel for finding the path to wt.exe
|
||||||
|
// * Primitives for Popup (used by GetOpenPopupsForXamlRoot)
|
||||||
#include <winrt/Windows.UI.Core.h>
|
#include <winrt/Windows.UI.Core.h>
|
||||||
#include <winrt/Windows.UI.Xaml.Controls.h>
|
#include <winrt/Windows.UI.Xaml.Controls.h>
|
||||||
|
#include <winrt/Windows.UI.Xaml.Controls.Primitives.h>
|
||||||
#include <winrt/Windows.ui.xaml.media.h>
|
#include <winrt/Windows.ui.xaml.media.h>
|
||||||
#include <winrt/Windows.ApplicationModel.h>
|
#include <winrt/Windows.ApplicationModel.h>
|
||||||
#include <winrt/Windows.ApplicationModel.Resources.Core.h>
|
#include <winrt/Windows.ApplicationModel.Resources.Core.h>
|
||||||
|
|
Loading…
Reference in a new issue