Skip to content

Commit

Permalink
Syncing content from committish 6e5ee01fe694bcc02764b566a989faf7e907b063
Browse files Browse the repository at this point in the history
  • Loading branch information
reunion-maestro-bot committed May 1, 2024
1 parent b91b3ce commit 2a60e27
Show file tree
Hide file tree
Showing 17 changed files with 237 additions and 19 deletions.
27 changes: 26 additions & 1 deletion controls/dev/Lights/MaterialHelper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@
#include "RevealHoverLight.h"
#include "ResourceAccessor.h"
#include "LifetimeHandler.h"
#include <FrameworkUdk/Containment.h>

// Bug 50308952: [1.5 servicing] Add workaround to WinUI for UISettings RPC_E_WRONG_THREAD issue that is being hit by Photos app
#define WINAPPSDK_CHANGEID_50308952 50308952

/* static */
bool MaterialHelperBase::SimulateDisabledByPolicy()
Expand Down Expand Up @@ -422,7 +426,28 @@ void MaterialHelper::UpdatePolicyStatus(bool onUIThread)
auto callback = [strongThis, this]() {
const bool isEnergySaverMode = m_energySaverStatusChangedRevokerValid ? winrt::PowerManager::EnergySaverStatus() == winrt::EnergySaverStatus::On : true;
const bool areEffectsFast = m_compositionCapabilities ? (m_compositionCapabilities.AreEffectsFast() || m_ignoreAreEffectsFast) : false;
const bool advancedEffectsEnabled = m_uiSettings ? m_uiSettings.AdvancedEffectsEnabled() : true;

bool advancedEffectsEnabled = false;
if (WinAppSdk::Containment::IsChangeEnabled<WINAPPSDK_CHANGEID_50308952>())
{
// We are hitting an issue in Photos where UISettings::AdvancedEffectsEnabled is returning RPC_E_WRONG_THREAD.
// We work around this issue by;
// 1. Use a fresh instance of UISettings instead of the cached m_uiSettings.
// 2. Ignore RPC_E_WRONG_THREAD and use a fallback value.
try
{
winrt::UISettings uiSettings;
advancedEffectsEnabled = uiSettings.AdvancedEffectsEnabled();
}
catch (winrt::hresult_error e)
{
if (e.to_abi() != RPC_E_WRONG_THREAD) { throw; }
}
}
else
{
advancedEffectsEnabled = m_uiSettings ? m_uiSettings.AdvancedEffectsEnabled() : true;
}

bool isDisabledByPolicy = m_simulateDisabledByPolicy || (isEnergySaverMode || !areEffectsFast || !advancedEffectsEnabled);

Expand Down
15 changes: 14 additions & 1 deletion controls/dev/Repeater/ViewManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@
#include "ViewManager.h"
#include "ItemsRepeater.h"
#include "RepeaterTestHooks.h"
#include <FrameworkUdk/Containment.h>

// Bug 50344748: [1.5 Servicing][WASDK] 1-up viewer opens behind Collections (looks like nothing's happened, but the viewer is actually hidden behind the Collections window)
#define WINAPPSDK_CHANGEID_50344748 50344748

ViewManager::ViewManager(ItemsRepeater* owner) :
m_owner(owner),
Expand Down Expand Up @@ -221,7 +225,16 @@ void ViewManager::MoveFocusFromClearedIndex(int clearedIndex)

// If the last focused element has focus, use its focus state, if not use programmatic.
focusState = focusState == winrt::FocusState::Unfocused ? winrt::FocusState::Programmatic : focusState;
focusCandidate.Focus(focusState);

if (WinAppSdk::Containment::IsChangeEnabled<WINAPPSDK_CHANGEID_50344748>())
{
// Since this focus change is due to the focused element getting recycled, don't activate the window.
focusCandidate.as<winrt::IUIElementPrivate>().FocusNoActivate(focusState);
}
else
{
focusCandidate.Focus(focusState);
}

m_lastFocusedElement.set(focusedChild);
// Add pin to hold the focused element.
Expand Down
2 changes: 1 addition & 1 deletion controls/dev/dll/Microsoft.UI.Xaml.Common.targets
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
<Enumclass>false</Enumclass>
</Midl>
<Link>
<AdditionalDependencies>user32.lib;mincore.lib;dxguid.lib;dcomp.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalDependencies>user32.lib;mincore.lib;dxguid.lib;dcomp.lib;$(FrameworkUdkLibPath)\Microsoft.Internal.FrameworkUdk.lib;%(AdditionalDependencies)</AdditionalDependencies>
<!-- Microsoft.winmd will contain the definition of both public, preview and private types. -->
<WindowsMetadataFile>$(OutDir)$(ProjectWinMDName)</WindowsMetadataFile>
<GenerateMapFile>true</GenerateMapFile>
Expand Down
49 changes: 43 additions & 6 deletions dxaml/xcp/components/elements/UIElementLayout.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@
#include <uielementcollection.h>
#include <LayoutManager.h>
#include "LayoutCycleDebugSettings.h"
#include <FrameworkUdk/Containment.h>

// Bug 50119529: [1.5 servicing] BreadcrumbBar ellipsis flyout doesn't render all items if the window is small
#define WINAPPSDK_CHANGEID_50119529 50119529

void ComputeUnidimensionalEffectiveViewport(
_In_ const std::vector<CUIElement::UnidimensionalViewportInformation>& viewports,
Expand Down Expand Up @@ -370,7 +374,7 @@ void CUIElement::InvalidateViewportInternal()
__debugbreak();
}
}

SetIsViewportDirty(TRUE);
PropagateOnViewportDirtyPath();
}
Expand Down Expand Up @@ -438,11 +442,23 @@ _Check_return_ HRESULT CUIElement::EffectiveViewportWalk(
if (currentChild->GetIsViewportDirtyOrOnViewportDirtyPath()
|| (newDirtyFound && currentChild->GetWantsViewportOrContributesToViewport()))
{
IFC_RETURN(currentChild->EffectiveViewportWalk(
newDirtyFound,
transformsToViewports,
horizontalViewports,
verticalViewports));
if (WinAppSdk::Containment::IsChangeEnabled<WINAPPSDK_CHANGEID_50119529>())
{
IFC_RETURN(EffectiveViewportWalkToChild(
currentChild,
newDirtyFound,
transformsToViewports,
horizontalViewports,
verticalViewports));
}
else
{
IFC_RETURN(currentChild->EffectiveViewportWalk(
newDirtyFound,
transformsToViewports,
horizontalViewports,
verticalViewports));
}
}

// If at least one of the children still has the viewport
Expand All @@ -457,11 +473,32 @@ _Check_return_ HRESULT CUIElement::EffectiveViewportWalk(
// traversing the rest of the visual tree.
if (addedViewports)
{
// This one is a little tricky. CXamlIslandRoot::EffectiveViewportWalkCore will push two viewports without
// pushing a transform, so we technically can't blindly pop all three vectors. But given CXamlIslandRoot is
// always the first element to push anything, the transform vector will be empty anyway when we get back up
// to CXamlIslandRoot to pop things.
transformsToViewports.pop_back();

horizontalViewports.pop_back();
verticalViewports.pop_back();
}
}

return S_OK;
}

_Check_return_ HRESULT CUIElement::EffectiveViewportWalkToChild(
_In_ CUIElement* child,
const bool dirtyFound,
_In_ std::vector<TransformToPreviousViewport>& transformsToViewports,
_In_ std::vector<UnidimensionalViewportInformation>& horizontalViewports,
_In_ std::vector<UnidimensionalViewportInformation>& verticalViewports)
{
IFC_RETURN(child->EffectiveViewportWalk(
dirtyFound,
transformsToViewports,
horizontalViewports,
verticalViewports));

return S_OK;
}
1 change: 1 addition & 0 deletions dxaml/xcp/components/metadata/inc/Indexes.g.h
Original file line number Diff line number Diff line change
Expand Up @@ -3193,6 +3193,7 @@ enum class KnownMethodIndex: UINT16
UIElement_PopulatePropertyInfoOverride,
UIElement_InternalGetIsEnabled,
UIElement_InternalPutIsEnabled,
UIElement_FocusNoActivate,
VisualStateManager_GoToState,
VisualStateManager_GoToStateCore,
VisualStateManager_RaiseCurrentStateChanging,
Expand Down
5 changes: 4 additions & 1 deletion dxaml/xcp/components/unittest-uielement.props
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,10 @@

<ItemDefinitionGroup>
<Link>
<AdditionalDependencies>%(AdditionalDependencies) dwmapi.lib;</AdditionalDependencies>
<AdditionalDependencies>
%(AdditionalDependencies) dwmapi.lib;
$(FrameworkUdkLibPath)\Microsoft.Internal.FrameworkUdk.lib;
</AdditionalDependencies>
<AdditionalLibraryDirectories>%(AdditionalLibraryDirectories);$(VC_LibraryPath_VC_Desktop_CurrentPlatform_spectre);</AdditionalLibraryDirectories>
</Link>
</ItemDefinitionGroup>
Expand Down
72 changes: 70 additions & 2 deletions dxaml/xcp/core/core/elements/Popup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5282,8 +5282,7 @@ _Check_return_ HRESULT CPopupRoot::GetTopmostPopupInLightDismissChain(_Out_ CDep

//static
// If the element is an open popup, return that popup
_Check_return_ HRESULT
CPopupRoot::GetOpenPopupForElement(
_Check_return_ HRESULT CPopupRoot::GetOpenPopupForElement(
_In_ CUIElement *pElement,
_Outptr_result_maybenull_ CPopup **ppPopup)
{
Expand Down Expand Up @@ -5440,3 +5439,72 @@ bool CPopupRoot::ComputeDepthInOpenPopups()

return false;
}

_Check_return_ HRESULT CPopupRoot::EffectiveViewportWalkToChild(
_In_ CUIElement* child,
const bool dirtyFound,
_In_ std::vector<TransformToPreviousViewport>& transformsToViewports,
_In_ std::vector<UnidimensionalViewportInformation>& horizontalViewports,
_In_ std::vector<UnidimensionalViewportInformation>& verticalViewports)
{
// We expect the popup root at the tree, so there should be at most one viewport (from the main Xaml island) that we've discovered so far.
ASSERT(horizontalViewports.size() == verticalViewports.size());
ASSERT(transformsToViewports.size() <= 1);
ASSERT(horizontalViewports.size() <= 1);

bool poppedViewport = false;
UnidimensionalViewportInformation poppedHorizontalViewport(0, 0);
UnidimensionalViewportInformation poppedVerticalViewport(0, 0);

bool poppedTransform = false;
TransformToPreviousViewport poppedTransformToViewport(nullptr, nullptr);

//
// Windowed popups aren't limited to the bounds of the main Xaml island. If we walk through a windowed popup during
// the viewport walk, make sure we clear out the implicit viewport from the main Xaml island bounds.
//
xref_ptr<CPopup> popup;
IFC_RETURN(GetOpenPopupForElement(child, popup.ReleaseAndGetAddressOf()));
if (popup & popup->IsWindowed())
{
if (horizontalViewports.size() == 1)
{
poppedHorizontalViewport = horizontalViewports[0];
horizontalViewports.pop_back();

poppedVerticalViewport = verticalViewports[0];
verticalViewports.pop_back();

poppedViewport = true;
}

if (transformsToViewports.size() == 1)
{
poppedTransformToViewport = transformsToViewports[0];
transformsToViewports.pop_back();

poppedTransform = true;
}
}

IFC_RETURN(child->EffectiveViewportWalk(
dirtyFound,
transformsToViewports,
horizontalViewports,
verticalViewports));

if (poppedViewport)
{
ASSERT(horizontalViewports.size() == 0);
horizontalViewports.push_back(poppedHorizontalViewport);
verticalViewports.push_back(poppedVerticalViewport);
}

if (poppedTransform)
{
ASSERT(transformsToViewports.size() == 0);
transformsToViewports.push_back(poppedTransformToViewport);
}

return S_OK;
}
7 changes: 7 additions & 0 deletions dxaml/xcp/core/inc/Popup.h
Original file line number Diff line number Diff line change
Expand Up @@ -719,6 +719,13 @@ class CPopupRoot final : public CPanel
_In_ const D2DRenderParams& printParams
) override;

_Check_return_ HRESULT EffectiveViewportWalkToChild(
_In_ CUIElement* child,
const bool dirtyFound,
_In_ std::vector<TransformToPreviousViewport>& transformsToViewports,
_In_ std::vector<UnidimensionalViewportInformation>& horizontalViewports,
_In_ std::vector<UnidimensionalViewportInformation>& verticalViewports) override;

public:

KnownTypeIndex GetTypeIndex() const override
Expand Down
9 changes: 8 additions & 1 deletion dxaml/xcp/core/inc/uielement.h
Original file line number Diff line number Diff line change
Expand Up @@ -1670,6 +1670,13 @@ class CUIElement : public CDependencyObject
_In_ std::vector<UnidimensionalViewportInformation>& verticalViewports,
_Out_ bool& addedViewports);

virtual _Check_return_ HRESULT EffectiveViewportWalkToChild(
_In_ CUIElement* child,
const bool dirtyFound,
_In_ std::vector<TransformToPreviousViewport>& transformsToViewports,
_In_ std::vector<UnidimensionalViewportInformation>& horizontalViewports,
_In_ std::vector<UnidimensionalViewportInformation>& verticalViewports);

private:
typedef XINT32 (&RoundCeilOrFloorFn)(_In_ XDOUBLE x);
float LayoutRoundHelper(const float value, _In_ RoundCeilOrFloorFn operationFn);
Expand Down Expand Up @@ -2419,7 +2426,7 @@ class CUIElement : public CDependencyObject

_Check_return_ HRESULT GetContentInnerBounds(
_Out_ XRECTF_RB* pBounds
);
);

_Check_return_ HRESULT GetOuterBounds(
_In_opt_ HitTestParams *hitTestParams,
Expand Down
7 changes: 7 additions & 0 deletions dxaml/xcp/dxaml/idl/winrt/main/microsoft.ui.xaml.private.idl
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,13 @@ namespace Microsoft.UI.Xaml
String XbfHash;
};

[contract(Microsoft.UI.Xaml.PrivateApiContract, 1)]
[webhosthidden]
interface IUIElementPrivate
{
Boolean FocusNoActivate(Microsoft.UI.Xaml.FocusState value);
};

[contract(Microsoft.UI.Xaml.PrivateApiContract, 1)]
[webhosthidden]
interface IUIElementStaticsPrivate
Expand Down
11 changes: 11 additions & 0 deletions dxaml/xcp/dxaml/lib/UIElement_Partial.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2903,6 +2903,17 @@ _Check_return_ HRESULT UIElement::FocusImpl(
return S_OK;
}

_Check_return_ HRESULT UIElement::FocusNoActivateImpl(
_In_ xaml::FocusState value,
_Out_ BOOLEAN* returnValue)
{
// Use InputActivationBehavior::RequestActivation to match legacy default.
IFC_RETURN(FocusWithDirection(value, DirectUI::FocusNavigationDirection::None, InputActivationBehavior::NoActivate, returnValue));
return S_OK;
}



_Check_return_ HRESULT UIElement::FocusWithDirection(
_In_ xaml::FocusState value,
_In_ DirectUI::FocusNavigationDirection focusNavigationDirection,
Expand Down
4 changes: 4 additions & 0 deletions dxaml/xcp/dxaml/lib/UIElement_Partial.h
Original file line number Diff line number Diff line change
Expand Up @@ -443,6 +443,10 @@ namespace DirectUI
_In_ xaml::FocusState value,
_Out_ BOOLEAN* returnValue);

_Check_return_ HRESULT FocusNoActivateImpl(
_In_ xaml::FocusState value,
_Out_ BOOLEAN* returnValue);

_Check_return_ HRESULT FocusWithDirection(
_In_ xaml::FocusState value,
_In_ DirectUI::FocusNavigationDirection focusNavigationDirection,
Expand Down
1 change: 1 addition & 0 deletions dxaml/xcp/dxaml/lib/synonyms.g.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ namespace DirectUISynonyms
typedef ABI::Microsoft::UI::Xaml::IInteractionBaseOverrides IInteractionBaseOverrides;
typedef ABI::Microsoft::UI::Xaml::IRectHelperStaticsPrivate IRectHelperStaticsPrivate;
typedef ABI::Microsoft::UI::Xaml::ISourceInfoPrivate ISourceInfoPrivate;
typedef ABI::Microsoft::UI::Xaml::IUIElementPrivate IUIElementPrivate;
typedef ABI::Microsoft::UI::Xaml::IUIElementStaticsPrivate IUIElementStaticsPrivate;
typedef ABI::Microsoft::UI::Xaml::IWindowPrivate IWindowPrivate;
typedef ABI::Microsoft::UI::Xaml::IXamlServiceProvider IXamlServiceProvider;
Expand Down
23 changes: 23 additions & 0 deletions dxaml/xcp/dxaml/lib/winrtgeneratedclasses/UIElement.g.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,10 @@ HRESULT DirectUI::UIElementGenerated::QueryInterfaceImpl(_In_ REFIID iid, _Outpt
{
*ppObject = static_cast<ABI::Microsoft::UI::Composition::IVisualElement2*>(this);
}
else if (InlineIsEqualGUID(iid, __uuidof(ABI::Microsoft::UI::Xaml::IUIElementPrivate)))
{
*ppObject = static_cast<ABI::Microsoft::UI::Xaml::IUIElementPrivate*>(this);
}
#if WI_IS_FEATURE_PRESENT(Feature_Xaml2018)
else if (InlineIsEqualGUID(iid, __uuidof(ABI::Microsoft::UI::Xaml::IUIElementFeature_Xaml2018)) && Feature_Xaml2018::IsEnabled())
{
Expand Down Expand Up @@ -4254,6 +4258,25 @@ IFACEMETHODIMP DirectUI::UIElementGenerated::Focus(_In_ ABI::Microsoft::UI::Xaml
}
RRETURN(hr);
}
IFACEMETHODIMP DirectUI::UIElementGenerated::FocusNoActivate(_In_ ABI::Microsoft::UI::Xaml::FocusState value, _Out_ BOOLEAN* pResult)
{
HRESULT hr = S_OK;
if (EventEnabledApiFunctionCallStart())
{
XamlTelemetry::PublicApiCall(true, reinterpret_cast<uint64_t>(this), "UIElement_FocusNoActivate", 0);
}
ARG_VALIDRETURNPOINTER(pResult);
*pResult={};
IFC(CheckThread());
IFC(DefaultStrictApiCheck(this));
IFC(static_cast<UIElement*>(this)->FocusNoActivateImpl(value, pResult));
Cleanup:
if (EventEnabledApiFunctionCallStop())
{
XamlTelemetry::PublicApiCall(false, reinterpret_cast<uint64_t>(this), "UIElement_FocusNoActivate", hr);
}
RRETURN(hr);
}
IFACEMETHODIMP DirectUI::UIElementGenerated::GetChildrenInTabFocusOrder(_Outptr_ ABI::Windows::Foundation::Collections::IIterable<ABI::Microsoft::UI::Xaml::DependencyObject*>** ppReturnValue)
{
HRESULT hr = S_OK;
Expand Down
Loading

0 comments on commit 2a60e27

Please sign in to comment.