## 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
91 lines
2.7 KiB
C
91 lines
2.7 KiB
C
/*++
|
|
Copyright (c) Microsoft Corporation
|
|
Licensed under the MIT license.
|
|
|
|
Module Name:
|
|
- pch.h
|
|
|
|
Abstract:
|
|
- Contains external headers to include in the precompile phase of console build process.
|
|
- Avoid including internal project headers. Instead include them only in the classes that need them (helps with test project building).
|
|
--*/
|
|
|
|
#pragma once
|
|
|
|
// Ignore checked iterators warning from VC compiler.
|
|
#define _SCL_SECURE_NO_WARNINGS
|
|
|
|
// Block minwindef.h min/max macros to prevent <algorithm> conflict
|
|
#define NOMINMAX
|
|
|
|
#define WIN32_LEAN_AND_MEAN
|
|
#define NOMCX
|
|
#define NOHELP
|
|
#define NOCOMM
|
|
|
|
#include <unknwn.h>
|
|
|
|
#define NT_SUCCESS(Status) (((NTSTATUS)(Status)) >= 0)
|
|
|
|
#include <windows.h>
|
|
#include <UIAutomation.h>
|
|
#include <cstdlib>
|
|
#include <cstring>
|
|
#include <shellscalingapi.h>
|
|
#include <windowsx.h>
|
|
#include <ShObjIdl.h>
|
|
|
|
// Manually include til after we include Windows.Foundation to give it winrt superpowers
|
|
#define BLOCK_TIL
|
|
#include "../inc/LibraryIncludes.h"
|
|
|
|
// This is inexplicable, but for whatever reason, cppwinrt conflicts with the
|
|
// SDK definition of this function, so the only fix is to undef it.
|
|
// from WinBase.h
|
|
// Windows::UI::Xaml::Media::Animation::IStoryboard::GetCurrentTime
|
|
#ifdef GetCurrentTime
|
|
#undef GetCurrentTime
|
|
#endif
|
|
|
|
#include <wil/cppwinrt.h>
|
|
|
|
// Needed just for XamlIslands to work at all:
|
|
#include <winrt/Windows.system.h>
|
|
#include <winrt/Windows.Foundation.Collections.h>
|
|
#include <winrt/Windows.UI.Xaml.Hosting.h>
|
|
#include <windows.ui.xaml.hosting.desktopwindowxamlsource.h>
|
|
|
|
// Additional headers for various xaml features. We need:
|
|
// * Core so we can resume_foreground with CoreDispatcher
|
|
// * Controls for grid
|
|
// * Media for ScaleTransform
|
|
// * ApplicationModel for finding the path to wt.exe
|
|
// * Primitives for Popup (used by GetOpenPopupsForXamlRoot)
|
|
#include <winrt/Windows.UI.Core.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.ApplicationModel.h>
|
|
#include <winrt/Windows.ApplicationModel.Resources.Core.h>
|
|
|
|
#include <winrt/TerminalApp.h>
|
|
#include <winrt/Microsoft.Terminal.Settings.Model.h>
|
|
#include <winrt/Microsoft.Terminal.Remoting.h>
|
|
#include <winrt/Microsoft.Terminal.Control.h>
|
|
|
|
#include <wil/resource.h>
|
|
#include <wil/win32_helpers.h>
|
|
|
|
// Including TraceLogging essentials for the binary
|
|
#include <TraceLoggingProvider.h>
|
|
#include <winmeta.h>
|
|
TRACELOGGING_DECLARE_PROVIDER(g_hWindowsTerminalProvider);
|
|
#include <telemetry/ProjectTelemetry.h>
|
|
#include <TraceLoggingActivity.h>
|
|
|
|
// For commandline argument processing
|
|
#include <shellapi.h>
|
|
#include <processenv.h>
|
|
#include <WinUser.h>
|
|
#include "til.h"
|