diff --git a/dxaml/xcp/components/imaging/SvgImageDecoder.cpp b/dxaml/xcp/components/imaging/SvgImageDecoder.cpp index 07c52dcda1..015c3dad56 100644 --- a/dxaml/xcp/components/imaging/SvgImageDecoder.cpp +++ b/dxaml/xcp/components/imaging/SvgImageDecoder.cpp @@ -20,6 +20,10 @@ #include #include #include +#include + +// Bug 50717750: [1.5 Servicing][WASDK] [GitHub] SVG not longer rendering +#define WINAPPSDK_CHANGEID_50717750 50717750 using namespace DirectUI; @@ -215,8 +219,16 @@ _Check_return_ HRESULT SvgImageDecoder::DecodeFrame( { if (!hasWidth && !hasHeight) { - // If neither width nor height was specified, then just match the viewBoxes. + // If neither width nor height was specified, then just match the viewBoxes... containerViewBox = originalViewBox; + + if (WinAppSdk::Containment::IsChangeEnabled()) + { + // ...but reset the origin of the view box for the outer SVG. The inner SVG will be positioned at + // the origin when it's stretched (1:1) in the outer SVG. + containerViewBox.x = 0; + containerViewBox.y = 0; + } } else { diff --git a/dxaml/xcp/components/unittest.props b/dxaml/xcp/components/unittest.props index a892b4bb4f..54b2375c37 100644 --- a/dxaml/xcp/components/unittest.props +++ b/dxaml/xcp/components/unittest.props @@ -74,6 +74,7 @@ onecoreuap.lib; ntdll.lib; dbghelp.lib; + $(FrameworkUdkLibPath)\Microsoft.Internal.FrameworkUdk.lib; api-ms-win-rtcore-ntuser-private-l1-*.dll; diff --git a/dxaml/xcp/core/dll/focusmgr.cpp b/dxaml/xcp/core/dll/focusmgr.cpp index 2a2e740da3..d7645414eb 100644 --- a/dxaml/xcp/core/dll/focusmgr.cpp +++ b/dxaml/xcp/core/dll/focusmgr.cpp @@ -17,8 +17,14 @@ #include #include +#include + #include "InitialFocusSIPSuspender.h" #include "FocusLockOverrideGuard.h" +#include + +// Bug 51401727: [1.5 Servicing][WASDK] [GitHub] Webview2: Window blur and focus events always fire when clicking the WebView +#define WINAPPSDK_CHANGEID_51401727 51401727 #define E_FOCUS_ASYNCOP_INPROGRESS 64L @@ -1780,6 +1786,26 @@ bool CFocusManager::ShouldSetWindowFocus(const FocusMovement& movement) const return false; } + if (WinAppSdk::Containment::IsChangeEnabled()) + { + // If focused element is hwnd-based component hosted inside the Xaml island (aka WebView2), don't set focus to the hwnd, + // to avoid Xaml stealing focus back after the user interacts with the component hwnd, and focus is already there. + if (m_pFocusedElement && m_pFocusedElement->GetTypeIndex() == KnownTypeIndex::Panel) + { + HWND componentHwnd = DXamlServices::GetComponentHwndForPeer(m_pFocusedElement); + if(componentHwnd) + { + HWND focusedHwnd = ::GetFocus(); + // Check if the componendHwnd has focus or its child has + // https://task.ms/49085931 - [API Gap] InputFocusController needs some sort of ContainsFocus API to detect when Focus is in nested Content (eg XAML and a WebView2) + if (componentHwnd == focusedHwnd || ::IsChild(componentHwnd, focusedHwnd)) + { + return false; + } + } + } + } + return true; } diff --git a/dxaml/xcp/core/inc/DXamlServices.h b/dxaml/xcp/core/inc/DXamlServices.h index 91fee89c1a..996bd0f1b8 100644 --- a/dxaml/xcp/core/inc/DXamlServices.h +++ b/dxaml/xcp/core/inc/DXamlServices.h @@ -51,5 +51,6 @@ namespace DirectUI wuc::ICoreWindow* GetCurrentCoreWindowNoRef(); bool HasCompositionTargetRenderedEventHandlers(); bool IsInBackgroundTask(); + HWND GetComponentHwndForPeer(_In_ CDependencyObject* pDO); } } diff --git a/dxaml/xcp/dxaml/lib/DXamlServices.cpp b/dxaml/xcp/dxaml/lib/DXamlServices.cpp index 4aa0fcd3e2..8afe8c2882 100644 --- a/dxaml/xcp/dxaml/lib/DXamlServices.cpp +++ b/dxaml/xcp/dxaml/lib/DXamlServices.cpp @@ -11,6 +11,8 @@ #include "JupiterControl.h" #include "JupiterWindow.h" +#include + #pragma warning(disable:4267) //'var' : conversion from 'size_t' to 'type', possible loss of data namespace DirectUI @@ -213,5 +215,22 @@ namespace DirectUI { return !!GetHandle()->IsInBackgroundTask(); } + + + HWND GetComponentHwndForPeer(_In_ CDependencyObject* pDO) + { + ctl::ComPtr peer; + DXamlCore::GetCurrent()->TryGetPeer(pDO, &peer); + if (peer) + { + ctl::ComPtr host; + HRESULT qiResult = ctl::iinspectable_cast(peer.Get())->QueryInterface(__uuidof(IHwndComponentHost), reinterpret_cast(host.ReleaseAndGetAddressOf())); + if (SUCCEEDED(qiResult) && host != nullptr) + { + return host->GetComponentHwnd(); + } + } + return nullptr; + } } } diff --git a/eng/Version.Details.xml b/eng/Version.Details.xml index 65c6f4550a..9e1039d0e9 100644 --- a/eng/Version.Details.xml +++ b/eng/Version.Details.xml @@ -2,22 +2,22 @@ - + https://dev.azure.com/microsoft/ProjectReunion/_git/WindowsAppSDK - a10039cc791b70b6b9b6a2703ba862e589d5989b + f2f6538eacbbe1632040c207cde16b5413fb07bf - + https://dev.azure.com/microsoft/LiftedIXP/_git/DCPP - d60cf9c7a3bfe26772925fcefefa35d51e924919 + 8ae48bdfe2603ad520a56f5bcd40e136c2026c0e - + https://dev.azure.com/microsoft/LiftedIXP/_git/DCPP - d60cf9c7a3bfe26772925fcefefa35d51e924919 + 8ae48bdfe2603ad520a56f5bcd40e136c2026c0e - + https://dev.azure.com/microsoft/WinUI/_git/Microsoft-WinUI-Sdk - 7febe557e6f0e1c3d30254648d58e7b73589a572 + 991614b101e9987684a5550327b0aac4c97347ff diff --git a/src/XamlCompiler/BuildTasks/Microsoft/Xaml/XamlCompiler/CodeGenerators/CSharpPagePass2.cs b/src/XamlCompiler/BuildTasks/Microsoft/Xaml/XamlCompiler/CodeGenerators/CSharpPagePass2.cs index 6dec9289cd..10cd4f1524 100644 --- a/src/XamlCompiler/BuildTasks/Microsoft/Xaml/XamlCompiler/CodeGenerators/CSharpPagePass2.cs +++ b/src/XamlCompiler/BuildTasks/Microsoft/Xaml/XamlCompiler/CodeGenerators/CSharpPagePass2.cs @@ -1504,13 +1504,20 @@ public void ProcessBindings(global::System.Object item, int itemIndex, int phase this.Write(";\r\n this.SetDataRoot(item);\r\n if (!" + "removedDataContextHandler)\r\n {\r\n " + - " removedDataContextHandler = true;\r\n "); + " removedDataContextHandler = true;\r\n var rootElemen" + + "t = "); this.Write(this.ToStringHelper.ToStringWithCulture(bindUniverse.RootElement.ReferenceExpression)); -this.Write(".DataContextChanged -= this.DataContextChangedHandler;\r\n }" + - "\r\n this.initialized = true;\r\n brea" + - "k;\r\n"); +this.Write(@"; + if (rootElement != null) + { + rootElement.DataContextChanged -= this.DataContextChangedHandler; + } + } + this.initialized = true; + break; +"); foreach(KeyValuePair> kvp in bindUniverse.PhaseAssignments.Where(kvp => kvp.Key != 0).OrderBy(kvp => kvp.Key)) { diff --git a/src/XamlCompiler/BuildTasks/Microsoft/Xaml/XamlCompiler/CodeGenerators/CSharpPagePass2.tt b/src/XamlCompiler/BuildTasks/Microsoft/Xaml/XamlCompiler/CodeGenerators/CSharpPagePass2.tt index ab442a1f8a..f49177d569 100644 --- a/src/XamlCompiler/BuildTasks/Microsoft/Xaml/XamlCompiler/CodeGenerators/CSharpPagePass2.tt +++ b/src/XamlCompiler/BuildTasks/Microsoft/Xaml/XamlCompiler/CodeGenerators/CSharpPagePass2.tt @@ -806,7 +806,11 @@ namespace <#=Model.CodeInfo.ClassName.Namespace#> if (!removedDataContextHandler) { removedDataContextHandler = true; - <#=bindUniverse.RootElement.ReferenceExpression#>.DataContextChanged -= this.DataContextChangedHandler; + var rootElement = <#=bindUniverse.RootElement.ReferenceExpression#>; + if (rootElement != null) + { + rootElement.DataContextChanged -= this.DataContextChangedHandler; + } } this.initialized = true; break; diff --git a/src/XamlCompiler/BuildTasks/Microsoft/Xaml/XamlCompiler/CodeGenerators/CppWinRT/CppWinRT_PageBinding.cs b/src/XamlCompiler/BuildTasks/Microsoft/Xaml/XamlCompiler/CodeGenerators/CppWinRT/CppWinRT_PageBinding.cs index 171b1e0ef7..c57240691c 100644 --- a/src/XamlCompiler/BuildTasks/Microsoft/Xaml/XamlCompiler/CodeGenerators/CppWinRT/CppWinRT_PageBinding.cs +++ b/src/XamlCompiler/BuildTasks/Microsoft/Xaml/XamlCompiler/CodeGenerators/CppWinRT/CppWinRT_PageBinding.cs @@ -180,11 +180,20 @@ void ProcessBindings(IInspectable const& item, int itemIndex, int phase, int32_t nextPhase = "); this.Write(this.ToStringHelper.ToStringWithCulture(bindUniverse.GetNextPhase(0))); this.Write(";\r\n SetDataRoot(item);\r\n if (_dataContextCh" + - "angedToken.value != 0)\r\n {\r\n "); + "angedToken.value != 0)\r\n {\r\n auto root" + + "Element = "); this.Write(this.ToStringHelper.ToStringWithCulture(bindUniverse.RootElement.ReferenceExpression)); - this.Write(".DataContextChanged(_dataContextChangedToken);\r\n _dataCont" + - "extChangedToken.value = 0;\r\n }\r\n _isInitia" + - "lized = true;\r\n }\r\n break;\r\n"); + this.Write(@"; + if (rootElement != nullptr) + { + rootElement.DataContextChanged(_dataContextChangedToken); + } + _dataContextChangedToken.value = 0; + } + _isInitialized = true; + } + break; +"); foreach(KeyValuePair> kvp in bindUniverse.PhaseAssignments.Where(kvp => kvp.Key != 0).OrderBy(kvp => kvp.Key)) { this.Write(" case "); this.Write(this.ToStringHelper.ToStringWithCulture(kvp.Key)); diff --git a/src/XamlCompiler/BuildTasks/Microsoft/Xaml/XamlCompiler/CodeGenerators/CppWinRT/CppWinRT_PageBinding.tt b/src/XamlCompiler/BuildTasks/Microsoft/Xaml/XamlCompiler/CodeGenerators/CppWinRT/CppWinRT_PageBinding.tt index 1884ac9452..082f340f04 100644 --- a/src/XamlCompiler/BuildTasks/Microsoft/Xaml/XamlCompiler/CodeGenerators/CppWinRT/CppWinRT_PageBinding.tt +++ b/src/XamlCompiler/BuildTasks/Microsoft/Xaml/XamlCompiler/CodeGenerators/CppWinRT/CppWinRT_PageBinding.tt @@ -143,7 +143,11 @@ SetDataRoot(item); if (_dataContextChangedToken.value != 0) { - <#=bindUniverse.RootElement.ReferenceExpression#>.DataContextChanged(_dataContextChangedToken); + auto rootElement = <#=bindUniverse.RootElement.ReferenceExpression#>; + if (rootElement != nullptr) + { + rootElement.DataContextChanged(_dataContextChangedToken); + } _dataContextChangedToken.value = 0; } _isInitialized = true;