diff --git a/Files.sln b/Files.sln index 87aeb70599c3..545b6009d7ef 100644 --- a/Files.sln +++ b/Files.sln @@ -49,7 +49,7 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Files.App.UITests", "tests\ EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Files.App.Controls", "src\Files.App.Controls\Files.App.Controls.csproj", "{83FF8729-CC76-43E2-976F-47F0A187FC7E}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Files.App.CsWin32", "src\Files.App.CsWin32\Files.App.CsWin32.csproj", "{4803E2CB-3E27-447D-94FC-45B5F96E4F7A}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Files.App.CsWin32", "src\Files.App.CsWin32\Files.App.CsWin32.csproj", "{4803E2CB-3E27-447D-94FC-45B5F96E4F7A}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -367,10 +367,10 @@ Global {6FA07816-DE0A-4D49-84E8-38E953A33C87}.Debug|x64.Build.0 = Debug|Any CPU {6FA07816-DE0A-4D49-84E8-38E953A33C87}.Debug|x86.ActiveCfg = Debug|Any CPU {6FA07816-DE0A-4D49-84E8-38E953A33C87}.Debug|x86.Build.0 = Debug|Any CPU - {6FA07816-DE0A-4D49-84E8-38E953A33C87}.Preview|arm64.ActiveCfg = Preview|Any CPU - {6FA07816-DE0A-4D49-84E8-38E953A33C87}.Preview|arm64.Build.0 = Preview|Any CPU - {6FA07816-DE0A-4D49-84E8-38E953A33C87}.Preview|x64.ActiveCfg = Preview|Any CPU - {6FA07816-DE0A-4D49-84E8-38E953A33C87}.Preview|x64.Build.0 = Preview|Any CPU + {6FA07816-DE0A-4D49-84E8-38E953A33C87}.Preview|arm64.ActiveCfg = Release|Any CPU + {6FA07816-DE0A-4D49-84E8-38E953A33C87}.Preview|arm64.Build.0 = Release|Any CPU + {6FA07816-DE0A-4D49-84E8-38E953A33C87}.Preview|x64.ActiveCfg = Release|Any CPU + {6FA07816-DE0A-4D49-84E8-38E953A33C87}.Preview|x64.Build.0 = Release|Any CPU {6FA07816-DE0A-4D49-84E8-38E953A33C87}.Preview|x86.ActiveCfg = Preview|Any CPU {6FA07816-DE0A-4D49-84E8-38E953A33C87}.Preview|x86.Build.0 = Preview|Any CPU {6FA07816-DE0A-4D49-84E8-38E953A33C87}.Release|arm64.ActiveCfg = Release|Any CPU @@ -462,51 +462,61 @@ Global {7756A1A4-17B5-4E6B-9B12-F19AA868A225}.Debug|x64.ActiveCfg = Debug|Win32 {7756A1A4-17B5-4E6B-9B12-F19AA868A225}.Debug|x64.Build.0 = Debug|Win32 {7756A1A4-17B5-4E6B-9B12-F19AA868A225}.Debug|x86.ActiveCfg = Debug|Win32 + {7756A1A4-17B5-4E6B-9B12-F19AA868A225}.Debug|x86.Build.0 = Debug|Win32 {7756A1A4-17B5-4E6B-9B12-F19AA868A225}.Preview|arm64.ActiveCfg = Preview|Win32 {7756A1A4-17B5-4E6B-9B12-F19AA868A225}.Preview|arm64.Build.0 = Preview|Win32 {7756A1A4-17B5-4E6B-9B12-F19AA868A225}.Preview|x64.ActiveCfg = Preview|Win32 {7756A1A4-17B5-4E6B-9B12-F19AA868A225}.Preview|x64.Build.0 = Preview|Win32 {7756A1A4-17B5-4E6B-9B12-F19AA868A225}.Preview|x86.ActiveCfg = Preview|Win32 + {7756A1A4-17B5-4E6B-9B12-F19AA868A225}.Preview|x86.Build.0 = Preview|Win32 {7756A1A4-17B5-4E6B-9B12-F19AA868A225}.Release|arm64.ActiveCfg = Release|Win32 {7756A1A4-17B5-4E6B-9B12-F19AA868A225}.Release|arm64.Build.0 = Release|Win32 {7756A1A4-17B5-4E6B-9B12-F19AA868A225}.Release|x64.ActiveCfg = Release|Win32 {7756A1A4-17B5-4E6B-9B12-F19AA868A225}.Release|x64.Build.0 = Release|Win32 {7756A1A4-17B5-4E6B-9B12-F19AA868A225}.Release|x86.ActiveCfg = Release|Win32 + {7756A1A4-17B5-4E6B-9B12-F19AA868A225}.Release|x86.Build.0 = Release|Win32 {7756A1A4-17B5-4E6B-9B12-F19AA868A225}.Stable|arm64.ActiveCfg = Stable|Win32 {7756A1A4-17B5-4E6B-9B12-F19AA868A225}.Stable|arm64.Build.0 = Stable|Win32 {7756A1A4-17B5-4E6B-9B12-F19AA868A225}.Stable|x64.ActiveCfg = Stable|Win32 {7756A1A4-17B5-4E6B-9B12-F19AA868A225}.Stable|x64.Build.0 = Stable|Win32 {7756A1A4-17B5-4E6B-9B12-F19AA868A225}.Stable|x86.ActiveCfg = Stable|Win32 + {7756A1A4-17B5-4E6B-9B12-F19AA868A225}.Stable|x86.Build.0 = Stable|Win32 {7756A1A4-17B5-4E6B-9B12-F19AA868A225}.Store|arm64.ActiveCfg = Store|Win32 {7756A1A4-17B5-4E6B-9B12-F19AA868A225}.Store|arm64.Build.0 = Store|Win32 {7756A1A4-17B5-4E6B-9B12-F19AA868A225}.Store|x64.ActiveCfg = Store|Win32 {7756A1A4-17B5-4E6B-9B12-F19AA868A225}.Store|x64.Build.0 = Store|Win32 {7756A1A4-17B5-4E6B-9B12-F19AA868A225}.Store|x86.ActiveCfg = Store|Win32 + {7756A1A4-17B5-4E6B-9B12-F19AA868A225}.Store|x86.Build.0 = Store|Win32 {B3FE3F3B-CECC-4918-B72B-5488C3774125}.Debug|arm64.ActiveCfg = Debug|Win32 {B3FE3F3B-CECC-4918-B72B-5488C3774125}.Debug|arm64.Build.0 = Debug|Win32 {B3FE3F3B-CECC-4918-B72B-5488C3774125}.Debug|x64.ActiveCfg = Debug|Win32 {B3FE3F3B-CECC-4918-B72B-5488C3774125}.Debug|x64.Build.0 = Debug|Win32 {B3FE3F3B-CECC-4918-B72B-5488C3774125}.Debug|x86.ActiveCfg = Debug|Win32 + {B3FE3F3B-CECC-4918-B72B-5488C3774125}.Debug|x86.Build.0 = Debug|Win32 {B3FE3F3B-CECC-4918-B72B-5488C3774125}.Preview|arm64.ActiveCfg = Preview|Win32 {B3FE3F3B-CECC-4918-B72B-5488C3774125}.Preview|arm64.Build.0 = Preview|Win32 {B3FE3F3B-CECC-4918-B72B-5488C3774125}.Preview|x64.ActiveCfg = Preview|Win32 {B3FE3F3B-CECC-4918-B72B-5488C3774125}.Preview|x64.Build.0 = Preview|Win32 {B3FE3F3B-CECC-4918-B72B-5488C3774125}.Preview|x86.ActiveCfg = Preview|Win32 + {B3FE3F3B-CECC-4918-B72B-5488C3774125}.Preview|x86.Build.0 = Preview|Win32 {B3FE3F3B-CECC-4918-B72B-5488C3774125}.Release|arm64.ActiveCfg = Release|Win32 {B3FE3F3B-CECC-4918-B72B-5488C3774125}.Release|arm64.Build.0 = Release|Win32 {B3FE3F3B-CECC-4918-B72B-5488C3774125}.Release|x64.ActiveCfg = Release|Win32 {B3FE3F3B-CECC-4918-B72B-5488C3774125}.Release|x64.Build.0 = Release|Win32 {B3FE3F3B-CECC-4918-B72B-5488C3774125}.Release|x86.ActiveCfg = Release|Win32 + {B3FE3F3B-CECC-4918-B72B-5488C3774125}.Release|x86.Build.0 = Release|Win32 {B3FE3F3B-CECC-4918-B72B-5488C3774125}.Stable|arm64.ActiveCfg = Stable|Win32 {B3FE3F3B-CECC-4918-B72B-5488C3774125}.Stable|arm64.Build.0 = Stable|Win32 {B3FE3F3B-CECC-4918-B72B-5488C3774125}.Stable|x64.ActiveCfg = Stable|Win32 {B3FE3F3B-CECC-4918-B72B-5488C3774125}.Stable|x64.Build.0 = Stable|Win32 {B3FE3F3B-CECC-4918-B72B-5488C3774125}.Stable|x86.ActiveCfg = Stable|Win32 + {B3FE3F3B-CECC-4918-B72B-5488C3774125}.Stable|x86.Build.0 = Stable|Win32 {B3FE3F3B-CECC-4918-B72B-5488C3774125}.Store|arm64.ActiveCfg = Store|Win32 {B3FE3F3B-CECC-4918-B72B-5488C3774125}.Store|arm64.Build.0 = Store|Win32 {B3FE3F3B-CECC-4918-B72B-5488C3774125}.Store|x64.ActiveCfg = Store|Win32 {B3FE3F3B-CECC-4918-B72B-5488C3774125}.Store|x64.Build.0 = Store|Win32 {B3FE3F3B-CECC-4918-B72B-5488C3774125}.Store|x86.ActiveCfg = Store|Win32 + {B3FE3F3B-CECC-4918-B72B-5488C3774125}.Store|x86.Build.0 = Store|Win32 {6F5B1C76-6FA1-49C0-9AF5-672BEDF6900B}.Debug|arm64.ActiveCfg = Debug|arm64 {6F5B1C76-6FA1-49C0-9AF5-672BEDF6900B}.Debug|arm64.Build.0 = Debug|arm64 {6F5B1C76-6FA1-49C0-9AF5-672BEDF6900B}.Debug|arm64.Deploy.0 = Debug|arm64 @@ -553,21 +563,35 @@ Global {6F5B1C76-6FA1-49C0-9AF5-672BEDF6900B}.Store|x86.Build.0 = Store|x86 {6F5B1C76-6FA1-49C0-9AF5-672BEDF6900B}.Store|x86.Deploy.0 = Store|x86 {83FF8729-CC76-43E2-976F-47F0A187FC7E}.Debug|arm64.ActiveCfg = Debug|arm64 + {83FF8729-CC76-43E2-976F-47F0A187FC7E}.Debug|arm64.Build.0 = Debug|arm64 {83FF8729-CC76-43E2-976F-47F0A187FC7E}.Debug|x64.ActiveCfg = Debug|x64 {83FF8729-CC76-43E2-976F-47F0A187FC7E}.Debug|x64.Build.0 = Debug|x64 {83FF8729-CC76-43E2-976F-47F0A187FC7E}.Debug|x86.ActiveCfg = Debug|x86 + {83FF8729-CC76-43E2-976F-47F0A187FC7E}.Debug|x86.Build.0 = Debug|x86 {83FF8729-CC76-43E2-976F-47F0A187FC7E}.Preview|arm64.ActiveCfg = Preview|arm64 + {83FF8729-CC76-43E2-976F-47F0A187FC7E}.Preview|arm64.Build.0 = Preview|arm64 {83FF8729-CC76-43E2-976F-47F0A187FC7E}.Preview|x64.ActiveCfg = Preview|x64 + {83FF8729-CC76-43E2-976F-47F0A187FC7E}.Preview|x64.Build.0 = Preview|x64 {83FF8729-CC76-43E2-976F-47F0A187FC7E}.Preview|x86.ActiveCfg = Preview|x86 + {83FF8729-CC76-43E2-976F-47F0A187FC7E}.Preview|x86.Build.0 = Preview|x86 {83FF8729-CC76-43E2-976F-47F0A187FC7E}.Release|arm64.ActiveCfg = Release|arm64 + {83FF8729-CC76-43E2-976F-47F0A187FC7E}.Release|arm64.Build.0 = Release|arm64 {83FF8729-CC76-43E2-976F-47F0A187FC7E}.Release|x64.ActiveCfg = Release|x64 + {83FF8729-CC76-43E2-976F-47F0A187FC7E}.Release|x64.Build.0 = Release|x64 {83FF8729-CC76-43E2-976F-47F0A187FC7E}.Release|x86.ActiveCfg = Release|x86 + {83FF8729-CC76-43E2-976F-47F0A187FC7E}.Release|x86.Build.0 = Release|x86 {83FF8729-CC76-43E2-976F-47F0A187FC7E}.Stable|arm64.ActiveCfg = Stable|arm64 + {83FF8729-CC76-43E2-976F-47F0A187FC7E}.Stable|arm64.Build.0 = Stable|arm64 {83FF8729-CC76-43E2-976F-47F0A187FC7E}.Stable|x64.ActiveCfg = Stable|x64 + {83FF8729-CC76-43E2-976F-47F0A187FC7E}.Stable|x64.Build.0 = Stable|x64 {83FF8729-CC76-43E2-976F-47F0A187FC7E}.Stable|x86.ActiveCfg = Stable|x86 + {83FF8729-CC76-43E2-976F-47F0A187FC7E}.Stable|x86.Build.0 = Stable|x86 {83FF8729-CC76-43E2-976F-47F0A187FC7E}.Store|arm64.ActiveCfg = Store|arm64 + {83FF8729-CC76-43E2-976F-47F0A187FC7E}.Store|arm64.Build.0 = Store|arm64 {83FF8729-CC76-43E2-976F-47F0A187FC7E}.Store|x64.ActiveCfg = Store|x64 + {83FF8729-CC76-43E2-976F-47F0A187FC7E}.Store|x64.Build.0 = Store|x64 {83FF8729-CC76-43E2-976F-47F0A187FC7E}.Store|x86.ActiveCfg = Store|x86 + {83FF8729-CC76-43E2-976F-47F0A187FC7E}.Store|x86.Build.0 = Store|x86 {4803E2CB-3E27-447D-94FC-45B5F96E4F7A}.Debug|arm64.ActiveCfg = Debug|arm64 {4803E2CB-3E27-447D-94FC-45B5F96E4F7A}.Debug|arm64.Build.0 = Debug|arm64 {4803E2CB-3E27-447D-94FC-45B5F96E4F7A}.Debug|x64.ActiveCfg = Debug|x64 @@ -626,4 +650,4 @@ Global GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {0E62043C-A7A1-4982-9EC9-4CDB2939B776} EndGlobalSection -EndGlobal \ No newline at end of file +EndGlobal diff --git a/global.json b/global.json index 62a1920fd79d..d0c27abb4cf8 100644 --- a/global.json +++ b/global.json @@ -1,5 +1,7 @@ { "sdk": { - "version": "8.0.303" + "version": "8.0.303", + "rollForward": "latestMajor", + "allowPrerelease": true } } diff --git a/src/Files.App (Package)/Files.Package.wapproj b/src/Files.App (Package)/Files.Package.wapproj index 9204d2109d85..7e04f27796d3 100644 --- a/src/Files.App (Package)/Files.Package.wapproj +++ b/src/Files.App (Package)/Files.Package.wapproj @@ -107,8 +107,8 @@ - - + + diff --git a/src/Files.App.BackgroundTasks/Files.App.BackgroundTasks.csproj b/src/Files.App.BackgroundTasks/Files.App.BackgroundTasks.csproj index 297b1bc9976c..2889223bb870 100644 --- a/src/Files.App.BackgroundTasks/Files.App.BackgroundTasks.csproj +++ b/src/Files.App.BackgroundTasks/Files.App.BackgroundTasks.csproj @@ -26,7 +26,7 @@ - + diff --git a/src/Files.App.Controls/Files.App.Controls.csproj b/src/Files.App.Controls/Files.App.Controls.csproj index 081f8b2e7e80..f05e50023d08 100644 --- a/src/Files.App.Controls/Files.App.Controls.csproj +++ b/src/Files.App.Controls/Files.App.Controls.csproj @@ -1,9 +1,10 @@ - + net8.0-windows10.0.22621.0 10.0.19041.0 + 10.0.22621.42 true 10.0.19041.0 enable @@ -16,9 +17,9 @@ - - - + + + diff --git a/src/Files.App.Controls/ThemedIcon/ThemedIcon.cs b/src/Files.App.Controls/ThemedIcon/ThemedIcon.cs index be5b0d031f22..ae9d5917a05e 100644 --- a/src/Files.App.Controls/ThemedIcon/ThemedIcon.cs +++ b/src/Files.App.Controls/ThemedIcon/ThemedIcon.cs @@ -6,11 +6,11 @@ using Microsoft.UI.Xaml.Media; using Microsoft.UI.Xaml.Markup; using Microsoft.UI.Xaml.Shapes; -using CommunityToolkit.WinUI.UI; using Microsoft.UI.Xaml.Controls.Primitives; using System.Linq; using System.Collections.Generic; using System.Reflection.Emit; +using System; namespace Files.App.Controls { @@ -371,6 +371,30 @@ private void UpdateIconColorTypeStates() layer.IconColorType = IconColorType; } } - } - } + } + + private T? FindAscendant() where T : notnull, DependencyObject + { + T val; + DependencyObject element = this; + while (true) + { + DependencyObject parent = VisualTreeHelper.GetParent(element); + if (parent is null) + { + return null; + } + + if (parent is T target) + { + val = target; + break; + } + + element = parent; + } + + return val; + } + } } diff --git a/src/Files.App.CsWin32/Files.App.CsWin32.csproj b/src/Files.App.CsWin32/Files.App.CsWin32.csproj index 096cca9f7150..a7ca80f9a1db 100644 --- a/src/Files.App.CsWin32/Files.App.CsWin32.csproj +++ b/src/Files.App.CsWin32/Files.App.CsWin32.csproj @@ -4,6 +4,7 @@ net8.0-windows10.0.22621.0 10.0.19041.0 + 10.0.22621.42 enable true Debug;Release;Stable;Preview;Store diff --git a/src/Files.App.Launcher/Files.App.Launcher.vcxproj b/src/Files.App.Launcher/Files.App.Launcher.vcxproj index d4a97cd06ccb..89dc32d0b823 100644 --- a/src/Files.App.Launcher/Files.App.Launcher.vcxproj +++ b/src/Files.App.Launcher/Files.App.Launcher.vcxproj @@ -1,7 +1,7 @@ - + Debug @@ -329,15 +329,15 @@ - - + + This project references a NuGet package that is not on this computer. To download those packages, use Restore NuGet Packages. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. - - - + + + - \ No newline at end of file + diff --git a/src/Files.App.Launcher/packages.config b/src/Files.App.Launcher/packages.config index 1b706ca9a10d..2ddc908f46b1 100644 --- a/src/Files.App.Launcher/packages.config +++ b/src/Files.App.Launcher/packages.config @@ -1,5 +1,5 @@  - - + + \ No newline at end of file diff --git a/src/Files.App.Server/Files.App.Server.csproj b/src/Files.App.Server/Files.App.Server.csproj index 5b11120b04f9..ba70ca2c0410 100644 --- a/src/Files.App.Server/Files.App.Server.csproj +++ b/src/Files.App.Server/Files.App.Server.csproj @@ -7,6 +7,7 @@ Language=en-US;af;ar;be-BY;bg;ca;cs-CZ;da;de-DE;el;en-GB;es-ES;es-419;fa-IR;fi-FI;fil-PH;fr-FR;he-IL;hi-IN;hr-HR;hu-HU;id-ID;it-IT;ja-JP;ka;km-KH;ko-KR;lt-LT;lv-LV;ms-MY;nb-NO;nl-NL;pl-PL;pt-BR;pt-PT;ro-RO;ru-RU;sk-SK;sq-AL;sr-Cyrl;sv-SE;ta;th-TH;tr-TR;uk-UA;vi;zh-Hans;zh-Hant net8.0-windows10.0.22621.0 10.0.19041.0 + 10.0.22621.42 enable enable Debug;Release;Stable;Preview;Store @@ -39,7 +40,7 @@ - + diff --git a/src/Files.App.Storage/Files.App.Storage.csproj b/src/Files.App.Storage/Files.App.Storage.csproj index c08d08cbe3f0..ba0695bc4df8 100644 --- a/src/Files.App.Storage/Files.App.Storage.csproj +++ b/src/Files.App.Storage/Files.App.Storage.csproj @@ -9,6 +9,7 @@ Debug;Release;Stable;Preview;Store x86;x64;arm64 win-x86;win-x64;win-arm64 + 10.0.22621.42 @@ -23,6 +24,10 @@ true + + + + diff --git a/src/Files.App/Data/Items/WindowEx.cs b/src/Files.App/Data/Items/WindowEx.cs index aab569a95854..c9e0cdea816d 100644 --- a/src/Files.App/Data/Items/WindowEx.cs +++ b/src/Files.App/Data/Items/WindowEx.cs @@ -54,20 +54,6 @@ public bool IsMaximizable if (AppWindow.Presenter is OverlappedPresenter overlapped) overlapped.IsMaximizable = value; - - if (value) - { - // WORKAROUND: - // https://github.com/microsoft/microsoft-ui-xaml/issues/8431 - // NOTE: - // Indicates to the Shell that the window should not be treated as full-screen - // not to mess up the taskbar when being full-screen mode. - // This property should only be set if the "Automatically hide the taskbar" in Windows 11, - // or "Automatically hide the taskbar in desktop mode" in Windows 10 is enabled. - // Setting this property when the setting is disabled will result in the taskbar overlapping the application. - if (AppLifecycleHelper.IsAutoHideTaskbarEnabled()) - Win32PInvoke.SetPropW(WindowHandle, "NonRudeHWND", new IntPtr(1)); - } } } diff --git a/src/Files.App/Files.App.csproj b/src/Files.App/Files.App.csproj index 4383f072b4a7..e951d2a06d23 100644 --- a/src/Files.App/Files.App.csproj +++ b/src/Files.App/Files.App.csproj @@ -9,6 +9,7 @@ Scale|DXFeatureLevel Language=en-US;af;ar;be-BY;bg;ca;cs-CZ;da;de-DE;el;en-GB;es-ES;es-419;fa-IR;fi-FI;fil-PH;fr-FR;he-IL;hi-IN;hr-HR;hu-HU;id-ID;it-IT;ja-JP;ka;km-KH;ko-KR;lt-LT;lv-LV;ms-MY;nb-NO;nl-NL;pl-PL;pt-BR;pt-PT;ro-RO;ru-RU;sk-SK;sq-AL;sr-Cyrl;sv-SE;ta;th-TH;tr-TR;uk-UA;vi;zh-Hans;zh-Hant 10.0.19041.0 + 10.0.22621.42 False SHA256 False @@ -67,31 +68,32 @@ - + - + - - + + + - - + + - - - + + + - + @@ -136,8 +138,8 @@ - - - + + + diff --git a/src/Files.App/Helpers/Application/AppLifecycleHelper.cs b/src/Files.App/Helpers/Application/AppLifecycleHelper.cs index 8c2926268ea5..9d4c5e03fdf8 100644 --- a/src/Files.App/Helpers/Application/AppLifecycleHelper.cs +++ b/src/Files.App/Helpers/Application/AppLifecycleHelper.cs @@ -12,7 +12,6 @@ using Sentry; using Sentry.Protocol; using System.IO; -using System.Security; using System.Text; using Windows.ApplicationModel; using Windows.Storage; @@ -347,30 +346,6 @@ public static void HandleAppUnhandledException(Exception? ex, bool showToastNoti Process.GetCurrentProcess().Kill(); } - /// - /// Checks if the taskbar is set to auto-hide. - /// - public static bool IsAutoHideTaskbarEnabled() - { - try - { - const string registryKey = @"Software\Microsoft\Windows\CurrentVersion\Explorer\StuckRects3"; - const string valueName = "Settings"; - - using var key = Microsoft.Win32.Registry.CurrentUser.OpenSubKey(registryKey); - - var value = key?.GetValue(valueName) as byte[]; - - // The least significant bit of the 9th byte controls the auto-hide setting - return value != null && ((value[8] & 0x01) == 1); - } - catch (SecurityException) - { - // Handle edge case where OpenSubKey results in SecurityException - return false; - } - } - /// /// Updates the visibility of the system tray icon /// diff --git a/src/Files.App/Helpers/Win32/Win32PInvoke.Methods.cs b/src/Files.App/Helpers/Win32/Win32PInvoke.Methods.cs index 092e07a69af4..d2b417786bce 100644 --- a/src/Files.App/Helpers/Win32/Win32PInvoke.Methods.cs +++ b/src/Files.App/Helpers/Win32/Win32PInvoke.Methods.cs @@ -465,7 +465,7 @@ public static partial bool IsElevationRequired( [MarshalAs(UnmanagedType.LPWStr)] string pszPath); [DllImport("shlwapi.dll", CallingConvention = CallingConvention.StdCall, PreserveSig = true, CharSet = CharSet.Unicode)] - public static extern HRESULT SHCreateStreamOnFileEx( + public static extern int SHCreateStreamOnFileEx( string pszFile, STGM grfMode, uint dwAttributes, @@ -475,7 +475,7 @@ out IntPtr ppstm ); [DllImport("shell32.dll", CallingConvention = CallingConvention.StdCall, PreserveSig = true, CharSet = CharSet.Unicode)] - public static extern HRESULT SHCreateItemFromParsingName( + public static extern int SHCreateItemFromParsingName( string pszPath, IntPtr pbc, ref Guid riid, @@ -483,7 +483,7 @@ out IntPtr ppv ); [DllImport("ole32.dll", CallingConvention = CallingConvention.StdCall)] - public static extern HRESULT CoCreateInstance( + public static extern int CoCreateInstance( ref Guid rclsid, IntPtr pUnkOuter, ClassContext dwClsContext, diff --git a/src/Files.App/Services/App/AppThemeModeService.cs b/src/Files.App/Services/App/AppThemeModeService.cs index 404797d42b57..82d1ac8d843b 100644 --- a/src/Files.App/Services/App/AppThemeModeService.cs +++ b/src/Files.App/Services/App/AppThemeModeService.cs @@ -2,7 +2,6 @@ // Licensed under the MIT License. See the LICENSE. using Microsoft.Extensions.Logging; -using Microsoft.UI; using Microsoft.UI.Windowing; using Microsoft.UI.Xaml; using Microsoft.UI.Xaml.Media; @@ -88,8 +87,8 @@ public void SetAppThemeMode(Window? window = null, AppWindowTitleBar? titleBar = if (titleBar is not null) { - titleBar.ButtonBackgroundColor = Colors.Transparent; - titleBar.ButtonInactiveBackgroundColor = Colors.Transparent; + titleBar.ButtonBackgroundColor = Microsoft.UI.Colors.Transparent; + titleBar.ButtonInactiveBackgroundColor = Microsoft.UI.Colors.Transparent; switch (rootTheme) { @@ -99,11 +98,11 @@ public void SetAppThemeMode(Window? window = null, AppWindowTitleBar? titleBar = break; case ElementTheme.Light: titleBar.ButtonHoverBackgroundColor = Color.FromArgb(51, 0, 0, 0); - titleBar.ButtonForegroundColor = Colors.Black; + titleBar.ButtonForegroundColor = Microsoft.UI.Colors.Black; break; case ElementTheme.Dark: titleBar.ButtonHoverBackgroundColor = Color.FromArgb(51, 255, 255, 255); - titleBar.ButtonForegroundColor = Colors.White; + titleBar.ButtonForegroundColor = Microsoft.UI.Colors.White; break; } } diff --git a/src/Files.App/Utils/Shell/PreviewHandler.cs b/src/Files.App/Utils/Shell/PreviewHandler.cs index 6cb5f4001798..c0b054cb5175 100644 --- a/src/Files.App/Utils/Shell/PreviewHandler.cs +++ b/src/Files.App/Utils/Shell/PreviewHandler.cs @@ -1,7 +1,5 @@ -using System; -using System.Collections.Generic; -using System.Runtime.InteropServices; -using System.Runtime.InteropServices.ComTypes; +using System.Runtime.InteropServices; +using System.Runtime.InteropServices.Marshalling; using Vanara.PInvoke; using Windows.UI; @@ -10,8 +8,22 @@ namespace Files.App.Utils.Shell /// /// Credits: https://github.com/GeeLaw/PreviewHost/ /// - public sealed class PreviewHandler : IDisposable + public sealed partial class PreviewHandler : IDisposable { + const int S_OK = 0; + const int S_FALSE = 1; + const int E_FAIL = unchecked((int)0x80004005); + const int E_SERVER_EXEC_FAILURE = unchecked((int)0x80080005); + + [StructLayout(LayoutKind.Sequential)] + public struct RECT(int left, int top, int right, int bottom) + { + public int Left = left; + public int Top = top; + public int Right = right; + public int Bottom = bottom; + } + #region IPreviewHandlerFrame support [StructLayout(LayoutKind.Sequential)] @@ -21,16 +33,17 @@ public struct PreviewHandlerFrameInfo public uint AcceleratorEntryCount; } - [ComImport, Guid("fec87aaf-35f9-447a-adb7-20234491401a"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] - public interface IPreviewHandlerFrame + [GeneratedComInterface, Guid("fec87aaf-35f9-447a-adb7-20234491401a"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] + public partial interface IPreviewHandlerFrame { [PreserveSig] - HRESULT GetWindowContext(out PreviewHandlerFrameInfo pinfo); + int GetWindowContext(out PreviewHandlerFrameInfo pinfo); [PreserveSig] - HRESULT TranslateAccelerator(ref MSG pmsg); + int TranslateAccelerator(nint pmsg); } - public sealed class PreviewHandlerFrame : IPreviewHandlerFrame, IDisposable + [GeneratedComClass] + public sealed partial class PreviewHandlerFrame : IPreviewHandlerFrame, IDisposable { bool disposed; nint hwnd; @@ -47,20 +60,20 @@ public void Dispose() disposed = true; } - public HRESULT GetWindowContext(out PreviewHandlerFrameInfo pinfo) + public int GetWindowContext(out PreviewHandlerFrameInfo pinfo) { pinfo.AcceleratorTableHandle = IntPtr.Zero; pinfo.AcceleratorEntryCount = 0; if (disposed) - return HRESULT.E_FAIL; - return HRESULT.S_OK; + return E_FAIL; + return S_OK; } - public HRESULT TranslateAccelerator(ref MSG pmsg) + public int TranslateAccelerator(nint pmsg) { if (disposed) - return HRESULT.E_FAIL; - return HRESULT.S_FALSE; + return E_FAIL; + return S_FALSE; } } @@ -68,33 +81,33 @@ public HRESULT TranslateAccelerator(ref MSG pmsg) #region IPreviewHandler major interfaces - [ComImport, Guid("8895b1c6-b41f-4c1c-a562-0d564250836f"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] - interface IPreviewHandler + [GeneratedComInterface, Guid("8895b1c6-b41f-4c1c-a562-0d564250836f"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] + internal partial interface IPreviewHandler { [PreserveSig] - HRESULT SetWindow(IntPtr hwnd, ref RECT prc); + int SetWindow(nint hwnd, in RECT prc); [PreserveSig] - HRESULT SetRect(ref RECT prc); + int SetRect(in RECT prc); [PreserveSig] - HRESULT DoPreview(); + int DoPreview(); [PreserveSig] - HRESULT Unload(); + int Unload(); [PreserveSig] - HRESULT SetFocus(); + int SetFocus(); [PreserveSig] - HRESULT QueryFocus(out IntPtr phwnd); + int QueryFocus(out nint phwnd); // TranslateAccelerator is not used here. } - [ComImport, Guid("196bf9a5-b346-4ef0-aa1e-5dcdb76768b1"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] - interface IPreviewHandlerVisuals + [GeneratedComInterface, Guid("196bf9a5-b346-4ef0-aa1e-5dcdb76768b1"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] + internal partial interface IPreviewHandlerVisuals { [PreserveSig] - HRESULT SetBackgroundColor(uint color); + int SetBackgroundColor(uint color); [PreserveSig] - HRESULT SetFont(ref LOGFONT plf); + int SetFont(nint plf); [PreserveSig] - HRESULT SetTextColor(uint color); + int SetTextColor(uint color); } static uint ColorRefFromColor(Color color) @@ -102,11 +115,11 @@ static uint ColorRefFromColor(Color color) return (((uint)color.B) << 16) | (((uint)color.G) << 8) | ((uint)color.R); } - [ComImport, Guid("fc4801a3-2ba9-11cf-a229-00aa003d7352"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] - interface IObjectWithSite + [GeneratedComInterface, Guid("fc4801a3-2ba9-11cf-a229-00aa003d7352"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] + internal partial interface IObjectWithSite { [PreserveSig] - HRESULT SetSite([In, MarshalAs(UnmanagedType.IUnknown)] object pUnkSite); + int SetSite(nint pUnkSite); // GetSite is not used. } @@ -115,11 +128,11 @@ interface IObjectWithSite bool disposed; bool init; bool shown; - PreviewHandlerFrame comSite; + PreviewHandlerFrame? comSite; nint hwnd; - IPreviewHandler previewHandler; - IPreviewHandlerVisuals visuals; - IntPtr pPreviewHandler; + IPreviewHandler? previewHandler; + IPreviewHandlerVisuals? visuals; + readonly ComWrappers comWrappers = new StrategyBasedComWrappers(); public PreviewHandler(Guid clsid, nint frame) { @@ -135,12 +148,7 @@ public PreviewHandler(Guid clsid, nint frame) } catch { - if (previewHandler != null) - Marshal.ReleaseComObject(previewHandler); previewHandler = null; - if (pPreviewHandler != IntPtr.Zero) - Marshal.Release(pPreviewHandler); - pPreviewHandler = IntPtr.Zero; comSite.Dispose(); comSite = null; throw; @@ -160,65 +168,80 @@ void SetupHandler(Guid clsid) // If we use Activator.CreateInstance(Type.GetTypeFromCLSID(...)), // CLR will allow in-process server, which defeats isolation and // creates strange bugs. - HRESULT hr = Win32PInvoke.CoCreateInstance(ref clsid, IntPtr.Zero, Win32PInvoke.ClassContext.LocalServer, ref iid, out pph); + int hr = Win32PInvoke.CoCreateInstance(ref clsid, IntPtr.Zero, Win32PInvoke.ClassContext.LocalServer, ref iid, out pph); // See https://blogs.msdn.microsoft.com/adioltean/2005/06/24/when-cocreateinstance-returns-0x80080005-co_e_server_exec_failure/ // CO_E_SERVER_EXEC_FAILURE also tends to happen when debugging in Visual Studio. // Moreover, to create the instance in a server at low integrity level, we need // to use another thread with low mandatory label. We keep it simple by creating // a same-integrity object. - //if (hr == HRESULT.CO_E_SERVER_EXEC_FAILURE) - // hr = CoCreateInstance(ref clsid, IntPtr.Zero, ClassContext.LocalServer, ref iid, out pph); - if ((int)hr < 0) - throw new COMException(cannotCreate, (int)hr); - pPreviewHandler = pph; - var previewHandlerObject = Marshal.GetUniqueObjectForIUnknown(pph); + if (hr == E_SERVER_EXEC_FAILURE) + hr = Win32PInvoke.CoCreateInstance(ref clsid, IntPtr.Zero, Win32PInvoke.ClassContext.LocalServer, ref iid, out pph); + if (hr < 0) + throw new COMException(cannotCreate, hr); + var previewHandlerObject = comWrappers.GetOrCreateObjectForComInstance(pph, CreateObjectFlags.UniqueInstance); previewHandler = previewHandlerObject as IPreviewHandler; + if (previewHandler == null) { - Marshal.ReleaseComObject(previewHandlerObject); throw new COMException(cannotCreate); } var objectWithSite = previewHandlerObject as IObjectWithSite; if (objectWithSite == null) throw new COMException(cannotCast); - hr = objectWithSite.SetSite(comSite); - if ((int)hr < 0) - throw new COMException(cannotSetSite, (int)hr); + hr = objectWithSite.SetSite(comWrappers.GetOrCreateComInterfaceForObject(comSite, CreateComInterfaceFlags.None)); + if (hr < 0) + throw new COMException(cannotSetSite, hr); visuals = previewHandlerObject as IPreviewHandlerVisuals; } #region Initialization interfaces + [GeneratedComInterface, Guid("0000000c-0000-0000-C000-000000000046"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] + public partial interface IStream + { + // ISequentialStream portion + void Read([MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 1), Out] byte[] pv, int cb, nint pcbRead); + void Write([MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 1)] byte[] pv, int cb, nint pcbWritten); - [ComImport, Guid("b824b49d-22ac-4161-ac8a-9916e8fa3f7f"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] - interface IInitializeWithStream + // IStream portion + void Seek(long dlibMove, int dwOrigin, nint plibNewPosition); + void SetSize(long libNewSize); + void CopyTo(IStream pstm, long cb, nint pcbRead, nint pcbWritten); + void Commit(int grfCommitFlags); + void Revert(); + void LockRegion(long libOffset, long cb, int dwLockType); + void UnlockRegion(long libOffset, long cb, int dwLockType); + } + + [GeneratedComInterface, Guid("b824b49d-22ac-4161-ac8a-9916e8fa3f7f"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] + internal partial interface IInitializeWithStream { [PreserveSig] - HRESULT Initialize(IStream psi, STGM grfMode); + int Initialize(IStream psi, STGM grfMode); } - [ComImport, Guid("b824b49d-22ac-4161-ac8a-9916e8fa3f7f"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] - interface IInitializeWithStreamNative + [GeneratedComInterface, Guid("b824b49d-22ac-4161-ac8a-9916e8fa3f7f"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] + internal partial interface IInitializeWithStreamNative { [PreserveSig] - HRESULT Initialize(IntPtr psi, STGM grfMode); + int Initialize(IntPtr psi, STGM grfMode); } static readonly Guid IInitializeWithStreamIid = Guid.ParseExact("b824b49d-22ac-4161-ac8a-9916e8fa3f7f", "d"); - [ComImport, Guid("b7d14566-0509-4cce-a71f-0a554233bd9b"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] - interface IInitializeWithFile + [GeneratedComInterface, Guid("b7d14566-0509-4cce-a71f-0a554233bd9b"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] + internal partial interface IInitializeWithFile { [PreserveSig] - HRESULT Initialize([MarshalAs(UnmanagedType.LPWStr)] string pszFilePath, STGM grfMode); + int Initialize([MarshalAs(UnmanagedType.LPWStr)] string pszFilePath, STGM grfMode); } static readonly Guid IInitializeWithFileIid = Guid.ParseExact("b7d14566-0509-4cce-a71f-0a554233bd9b", "d"); - [ComImport, Guid("7f73be3f-fb79-493c-a6c7-7ee14e245841"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] - interface IInitializeWithItem + [GeneratedComInterface, Guid("7f73be3f-fb79-493c-a6c7-7ee14e245841"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] + internal partial interface IInitializeWithItem { [PreserveSig] - HRESULT Initialize(IntPtr psi, STGM grfMode); + int Initialize(IntPtr psi, STGM grfMode); } static readonly Guid IInitializeWithItemIid = Guid.ParseExact("7f73be3f-fb79-493c-a6c7-7ee14e245841", "d"); @@ -243,8 +266,8 @@ public bool InitWithStream(IStream stream, STGM mode) var hr = iws.Initialize(stream, mode); if (hr == HRESULT.E_NOTIMPL) return false; - if ((int)hr < 0) - throw new COMException("IInitializeWithStream.Initialize failed.", (int)hr); + if (hr < 0) + throw new COMException("IInitializeWithStream.Initialize failed.", hr); init = true; return true; } @@ -269,8 +292,8 @@ public bool InitWithStream(IntPtr pStream, STGM mode) var hr = iws.Initialize(pStream, mode); if (hr == HRESULT.E_NOTIMPL) return false; - if ((int)hr < 0) - throw new COMException("IInitializeWithStream.Initialize failed.", (int)hr); + if (hr < 0) + throw new COMException("IInitializeWithStream.Initialize failed.", hr); init = true; return true; } @@ -295,8 +318,8 @@ public bool InitWithItem(IntPtr psi, STGM mode) var hr = iwi.Initialize(psi, mode); if (hr == HRESULT.E_NOTIMPL) return false; - if ((int)hr < 0) - throw new COMException("IInitializeWithItem.Initialize failed.", (int)hr); + if (hr < 0) + throw new COMException("IInitializeWithItem.Initialize failed.", hr); init = true; return true; } @@ -321,8 +344,8 @@ public bool InitWithFile(string path, STGM mode) var hr = iwf.Initialize(path, mode); if (hr == HRESULT.E_NOTIMPL) return false; - if ((int)hr < 0) - throw new COMException("IInitializeWithFile.Initialize failed.", (int)hr); + if (hr < 0) + throw new COMException("IInitializeWithFile.Initialize failed.", hr); init = true; return true; } @@ -401,7 +424,7 @@ public bool ResetWindow() if (!init) return false; var hr = previewHandler.SetWindow(hwnd, new()); - return (int)hr >= 0; + return hr >= 0; } /// @@ -414,7 +437,7 @@ public bool ResetBounds(RECT previewerBounds) if (!init) return false; var hr = previewHandler.SetRect(previewerBounds); - return (int)hr >= 0; + return hr >= 0; } /// @@ -425,7 +448,7 @@ public bool ResetBounds(RECT previewerBounds) public bool SetBackground(Color color) { var hr = visuals?.SetBackgroundColor(ColorRefFromColor(color)); - return hr.HasValue && (int)hr.Value >= 0; + return hr.HasValue && hr.Value >= 0; } /// @@ -436,7 +459,7 @@ public bool SetBackground(Color color) public bool SetForeground(Color color) { var hr = visuals?.SetTextColor(ColorRefFromColor(color)); - return hr.HasValue && (int)hr.Value >= 0; + return hr.HasValue && hr.Value >= 0; } /// @@ -444,10 +467,10 @@ public bool SetForeground(Color color) /// /// The LogFontW reference. /// Whether the call succeeds. - public bool SetFont(ref LOGFONT font) + public bool SetFont(nint font) { - var hr = visuals?.SetFont(ref font); - return hr.HasValue && (int)hr.Value >= 0; + var hr = visuals?.SetFont(font); + return hr.HasValue && hr.Value >= 0; } /// @@ -461,7 +484,7 @@ public void DoPreview() return; EnsureNotShown(); ResetWindow(); - previewHandler.DoPreview(); + previewHandler?.DoPreview(); shown = true; } @@ -475,35 +498,27 @@ public void Focus() if (!init) return; EnsureShown(); - previewHandler.SetFocus(); + previewHandler?.SetFocus(); } /// /// Tells the preview handler to query focus. /// /// The focused window. - public IntPtr QueryFocus() + public nint QueryFocus() { EnsureNotDisposed(); //EnsureInitialized(); if (!init) return IntPtr.Zero; EnsureShown(); - IntPtr result; + nint result; var hr = previewHandler.QueryFocus(out result); - if ((int)hr < 0) + if (hr < 0) return IntPtr.Zero; return result; } - /// - /// Unloads the preview and disposes the object. This method is idempotent. - /// - public void UnloadPreview() - { - Dispose(true); - } - void EnsureNotDisposed() { if (disposed) @@ -536,40 +551,21 @@ void EnsureNotShown() #region IDisposable pattern - void Dispose(bool disposing) + ~PreviewHandler() + { + Dispose(); + } + + public void Dispose() { if (disposed) return; disposed = true; init = false; - if (disposing) - { - previewHandler.Unload(); - comSite.Dispose(); - Marshal.ReleaseComObject(previewHandler); - } - else - { - // We're in the finalizer. - // Field previewHandler might have been finalized at this point. - // Get a new RCW. - var phObject = Marshal.GetUniqueObjectForIUnknown(pPreviewHandler); - var ph = phObject as IPreviewHandler; - if (ph != null) - ph.Unload(); - Marshal.ReleaseComObject(phObject); - } - Marshal.Release(pPreviewHandler); - } - ~PreviewHandler() - { - Dispose(false); - } + previewHandler?.Unload(); + comSite?.Dispose(); - void IDisposable.Dispose() - { - Dispose(true); GC.SuppressFinalize(this); } diff --git a/src/Files.App/Utils/Storage/Operations/FileOperationsHelpers.cs b/src/Files.App/Utils/Storage/Operations/FileOperationsHelpers.cs index ddd7c17ea8e4..7e128596400b 100644 --- a/src/Files.App/Utils/Storage/Operations/FileOperationsHelpers.cs +++ b/src/Files.App/Utils/Storage/Operations/FileOperationsHelpers.cs @@ -127,7 +127,7 @@ public static Task SetClipboard(string[] filesToCopy, DataPackageOperation opera { using var shi = new ShellItem(fileToDeletePath[i]); using var file = SafetyExtensions.IgnoreExceptions(() => GetFirstFile(shi)) ?? shi; - if ((uint?)file.Properties.GetValueOrDefault(PKEY_FilePlaceholderStatus) == PS_CLOUDFILE_PLACEHOLDER) + if (file.Properties.TryGetValue(PKEY_FilePlaceholderStatus, out var value) && (uint?)value == PS_CLOUDFILE_PLACEHOLDER) { // Online only files cannot be tried for deletion, so they are treated as to be permanently deleted. shellOperationResult.Items.Add(new ShellOperationItemResult() diff --git a/src/Files.App/Utils/Storage/Operations/FilesystemHelpers.cs b/src/Files.App/Utils/Storage/Operations/FilesystemHelpers.cs index 9c2a5d888e1f..db9826dfd610 100644 --- a/src/Files.App/Utils/Storage/Operations/FilesystemHelpers.cs +++ b/src/Files.App/Utils/Storage/Operations/FilesystemHelpers.cs @@ -8,6 +8,7 @@ using System.IO; using System.Runtime.InteropServices; using System.Runtime.InteropServices.ComTypes; +using Vanara.Extensions; using Vanara.PInvoke; using Vanara.Windows.Shell; using Windows.ApplicationModel.DataTransfer; diff --git a/src/Files.App/ViewModels/UserControls/Previews/ShellPreviewViewModel.cs b/src/Files.App/ViewModels/UserControls/Previews/ShellPreviewViewModel.cs index 1dd27cb8ad03..be665ee3108a 100644 --- a/src/Files.App/ViewModels/UserControls/Previews/ShellPreviewViewModel.cs +++ b/src/Files.App/ViewModels/UserControls/Previews/ShellPreviewViewModel.cs @@ -18,12 +18,14 @@ using WinRT; using static Vanara.PInvoke.ShlwApi; using static Vanara.PInvoke.User32; +using System.Runtime.InteropServices.Marshalling; + #pragma warning disable CS8305 // Type is for evaluation purposes only and is subject to change or removal in future updates. namespace Files.App.ViewModels.Previews { - public sealed class ShellPreviewViewModel : BasePreviewModel + public sealed partial class ShellPreviewViewModel : BasePreviewModel { private const string IPreviewHandlerIid = "{8895b1c6-b41f-4c1c-a562-0d564250836f}"; private static readonly Guid QueryAssociationsClsid = new Guid(0xa07034fd, 0x6caa, 0x4954, 0xac, 0x3f, 0x97, 0xa2, 0x72, 0x16, 0xf9, 0x8a); @@ -35,6 +37,13 @@ public sealed class ShellPreviewViewModel : BasePreviewModel HWND hwnd = HWND.NULL; bool isOfficePreview = false; + [GeneratedComInterface, Guid("EACDD04C-117E-4E17-88F4-D1B12B0E3D89"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] + public partial interface IDCompositionTarget + { + [PreserveSig] + int SetRoot(nint visual); + } + public ShellPreviewViewModel(ListedItem item) : base(item) { } @@ -115,7 +124,7 @@ private nint WndProc(HWND hwnd, uint msg, nint wParam, nint lParam) { if (currentHandler is not null) { - currentHandler.UnloadPreview(); + currentHandler.Dispose(); currentHandler = null; } } @@ -192,8 +201,8 @@ private unsafe bool ChildWindowToXaml(nint parent, UIElement presenter) var compositor = ElementCompositionPreview.GetElementVisual(presenter).Compositor; outputLink = ContentExternalOutputLink.Create(compositor); - var target = outputLink.As(); - target.SetRoot(pChildVisual); + var target = outputLink.As(); + target.SetRoot((nint)pChildVisual); outputLink.PlacementVisual.Size = new(0, 0); outputLink.PlacementVisual.Scale = new(1/(float)presenter.XamlRoot.RasterizationScale); @@ -201,8 +210,6 @@ private unsafe bool ChildWindowToXaml(nint parent, UIElement presenter) pDCompositionDevice->Commit(); - Marshal.ReleaseComObject(target); - pChildVisual->Release(); pControlSurface->Release(); pDCompositionDevice->Release(); pDXGIDevice->Release(); @@ -225,7 +232,7 @@ public void UnloadPreview() if (hwnd != HWND.NULL) DestroyWindow(hwnd); - //outputLink?.Dispose(); + outputLink?.Dispose(); outputLink = null; if (wCls is not null) diff --git a/src/Files.App/Views/Layouts/BaseLayoutPage.cs b/src/Files.App/Views/Layouts/BaseLayoutPage.cs index 4a78f5a34e13..64b4234db3fd 100644 --- a/src/Files.App/Views/Layouts/BaseLayoutPage.cs +++ b/src/Files.App/Views/Layouts/BaseLayoutPage.cs @@ -15,6 +15,7 @@ using System.IO; using System.Runtime.CompilerServices; using System.Runtime.InteropServices.ComTypes; +using Vanara.Extensions; using Vanara.PInvoke; using Windows.ApplicationModel.DataTransfer; using Windows.ApplicationModel.DataTransfer.DragDrop; diff --git a/src/Files.App/nupkgs/Microsoft.UI.winmd b/src/Files.App/nupkgs/Microsoft.UI.winmd index 82e094e3e8c4..ce9ff6630baa 100644 Binary files a/src/Files.App/nupkgs/Microsoft.UI.winmd and b/src/Files.App/nupkgs/Microsoft.UI.winmd differ diff --git a/tests/Files.App.UITests/Files.App.UITests.csproj b/tests/Files.App.UITests/Files.App.UITests.csproj index 9779a74497bb..cac7033df940 100644 --- a/tests/Files.App.UITests/Files.App.UITests.csproj +++ b/tests/Files.App.UITests/Files.App.UITests.csproj @@ -1,10 +1,11 @@ - + WinExe net8.0-windows10.0.22621.0 10.0.19041.0 + 10.0.22621.42 win-$(Platform).pubxml true true @@ -27,8 +28,9 @@ - - + + + diff --git a/tests/Files.InteractionTests/Files.InteractionTests.csproj b/tests/Files.InteractionTests/Files.InteractionTests.csproj index 8db0fac809c2..182d9b01be5b 100644 --- a/tests/Files.InteractionTests/Files.InteractionTests.csproj +++ b/tests/Files.InteractionTests/Files.InteractionTests.csproj @@ -19,10 +19,10 @@ - + - - + + diff --git a/tests/Files.InteractionTests/Helper/AxeHelper.cs b/tests/Files.InteractionTests/Helper/AxeHelper.cs index b56a0b41f025..299eb3701ef9 100644 --- a/tests/Files.InteractionTests/Helper/AxeHelper.cs +++ b/tests/Files.InteractionTests/Helper/AxeHelper.cs @@ -24,7 +24,8 @@ internal static void InitializeAxe() public static void AssertNoAccessibilityErrors() { - var testResult = AccessibilityScanner.Scan(null).WindowScanOutputs.SelectMany(output => output.Errors).Where(error => error.Rule.ID != RuleId.BoundingRectangleNotNull); + var testResult = AccessibilityScanner.Scan(null).WindowScanOutputs.SelectMany(output => output.Errors) + .Where(error => !(error.Rule.ID is RuleId.BoundingRectangleNotNull or RuleId.SiblingUniqueAndFocusable)); if (testResult.Count() != 0) { var mappedResult = testResult.Select(result => "Element " + result.Element.Properties["ControlType"] + " violated rule '" + result.Rule.Description + "'."); diff --git a/tests/Files.InteractionTests/Tests/FolderTests.cs b/tests/Files.InteractionTests/Tests/FolderTests.cs index 7bcf37afdaca..57f1f6071919 100644 --- a/tests/Files.InteractionTests/Tests/FolderTests.cs +++ b/tests/Files.InteractionTests/Tests/FolderTests.cs @@ -3,6 +3,7 @@ using OpenQA.Selenium; using OpenQA.Selenium.Interactions; +using System.Linq; using System.Threading; namespace Files.InteractionTests.Tests @@ -65,6 +66,8 @@ private void CreateFolderTest() // Check for accessibility issues in the new folder prompt AxeHelper.AssertNoAccessibilityErrors(); + SessionManager.Session.FindElementsByClassName("TextBox").Last().Click(); + // Type the folder name var action = new Actions(SessionManager.Session); action.SendKeys("New Folder").Perform(); @@ -137,6 +140,7 @@ private void DeleteFolderTest() var action = new Actions(SessionManager.Session); action.SendKeys(Keys.Enter).Perform(); + Thread.Sleep(3000); // Select the "Renamed Folder - Copy" folder and clicks the "delete" button on the toolbar TestHelper.InvokeButtonByName("Renamed Folder - Copy");