## 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
98 lines
5 KiB
C++
98 lines
5 KiB
C++
// Copyright (c) Microsoft Corporation.
|
|
// Licensed under the MIT license.
|
|
|
|
#include "pch.h"
|
|
#include "NonClientIslandWindow.h"
|
|
#include "TrayIcon.h"
|
|
|
|
class AppHost
|
|
{
|
|
public:
|
|
AppHost() noexcept;
|
|
virtual ~AppHost();
|
|
|
|
void AppTitleChanged(const winrt::Windows::Foundation::IInspectable& sender, winrt::hstring newTitle);
|
|
void LastTabClosed(const winrt::Windows::Foundation::IInspectable& sender, const winrt::TerminalApp::LastTabClosedEventArgs& args);
|
|
void Initialize();
|
|
bool OnDirectKeyEvent(const uint32_t vkey, const uint8_t scanCode, const bool down);
|
|
void SetTaskbarProgress(const winrt::Windows::Foundation::IInspectable& sender, const winrt::Windows::Foundation::IInspectable& args);
|
|
|
|
bool HasWindow();
|
|
|
|
private:
|
|
std::unique_ptr<IslandWindow> _window;
|
|
winrt::TerminalApp::App _app;
|
|
winrt::TerminalApp::AppLogic _logic;
|
|
winrt::Microsoft::Terminal::Remoting::WindowManager _windowManager{ nullptr };
|
|
|
|
std::vector<winrt::Microsoft::Terminal::Settings::Model::GlobalSummonArgs> _hotkeys;
|
|
winrt::com_ptr<IVirtualDesktopManager> _desktopManager{ nullptr };
|
|
|
|
bool _shouldCreateWindow{ false };
|
|
bool _useNonClientArea{ false };
|
|
|
|
void _HandleCommandlineArgs();
|
|
|
|
void _HandleCreateWindow(const HWND hwnd, RECT proposedRect, winrt::Microsoft::Terminal::Settings::Model::LaunchMode& launchMode);
|
|
void _UpdateTitleBarContent(const winrt::Windows::Foundation::IInspectable& sender,
|
|
const winrt::Windows::UI::Xaml::UIElement& arg);
|
|
void _UpdateTheme(const winrt::Windows::Foundation::IInspectable&,
|
|
const winrt::Windows::UI::Xaml::ElementTheme& arg);
|
|
void _FocusModeChanged(const winrt::Windows::Foundation::IInspectable& sender,
|
|
const winrt::Windows::Foundation::IInspectable& arg);
|
|
void _FullscreenChanged(const winrt::Windows::Foundation::IInspectable& sender,
|
|
const winrt::Windows::Foundation::IInspectable& arg);
|
|
void _AlwaysOnTopChanged(const winrt::Windows::Foundation::IInspectable& sender,
|
|
const winrt::Windows::Foundation::IInspectable& arg);
|
|
void _RaiseVisualBell(const winrt::Windows::Foundation::IInspectable& sender,
|
|
const winrt::Windows::Foundation::IInspectable& arg);
|
|
void _WindowMouseWheeled(const til::point coord, const int32_t delta);
|
|
winrt::fire_and_forget _WindowActivated();
|
|
void _WindowMoved();
|
|
|
|
void _DispatchCommandline(winrt::Windows::Foundation::IInspectable sender,
|
|
winrt::Microsoft::Terminal::Remoting::CommandlineArgs args);
|
|
|
|
void _FindTargetWindow(const winrt::Windows::Foundation::IInspectable& sender,
|
|
const winrt::Microsoft::Terminal::Remoting::FindTargetWindowArgs& args);
|
|
|
|
void _BecomeMonarch(const winrt::Windows::Foundation::IInspectable& sender,
|
|
const winrt::Windows::Foundation::IInspectable& args);
|
|
void _GlobalHotkeyPressed(const long hotkeyIndex);
|
|
void _HandleSummon(const winrt::Windows::Foundation::IInspectable& sender,
|
|
const winrt::Microsoft::Terminal::Remoting::SummonWindowBehavior& args);
|
|
|
|
winrt::fire_and_forget _IdentifyWindowsRequested(const winrt::Windows::Foundation::IInspectable sender,
|
|
const winrt::Windows::Foundation::IInspectable args);
|
|
void _DisplayWindowId(const winrt::Windows::Foundation::IInspectable& sender,
|
|
const winrt::Windows::Foundation::IInspectable& args);
|
|
winrt::fire_and_forget _RenameWindowRequested(const winrt::Windows::Foundation::IInspectable sender,
|
|
const winrt::TerminalApp::RenameWindowRequestedArgs args);
|
|
|
|
GUID _CurrentDesktopGuid();
|
|
|
|
bool _LazyLoadDesktopManager();
|
|
|
|
void _listenForInboundConnections();
|
|
winrt::fire_and_forget _setupGlobalHotkeys();
|
|
winrt::fire_and_forget _createNewTerminalWindow(winrt::Microsoft::Terminal::Settings::Model::GlobalSummonArgs args);
|
|
void _HandleSettingsChanged(const winrt::Windows::Foundation::IInspectable& sender,
|
|
const winrt::Windows::Foundation::IInspectable& args);
|
|
|
|
void _IsQuakeWindowChanged(const winrt::Windows::Foundation::IInspectable& sender,
|
|
const winrt::Windows::Foundation::IInspectable& args);
|
|
|
|
void _SummonWindowRequested(const winrt::Windows::Foundation::IInspectable& sender,
|
|
const winrt::Windows::Foundation::IInspectable& args);
|
|
|
|
void _CreateTrayIcon();
|
|
void _DestroyTrayIcon();
|
|
winrt::fire_and_forget _ShowTrayIconRequested();
|
|
winrt::fire_and_forget _HideTrayIconRequested();
|
|
std::unique_ptr<TrayIcon> _trayIcon;
|
|
winrt::event_token _ReAddTrayIconToken;
|
|
winrt::event_token _TrayIconPressedToken;
|
|
winrt::event_token _ShowTrayContextMenuToken;
|
|
winrt::event_token _TrayMenuItemSelectedToken;
|
|
};
|