From 1964aa6ccefec28e9e229048260d5591a7c347bd Mon Sep 17 00:00:00 2001 From: Heiko <61519853+htcfreek@users.noreply.github.com> Date: Mon, 25 Sep 2023 14:17:25 +0200 Subject: [PATCH 1/4] [PTRun][Settings plugin]Fix search for updates in windows 11 (#28735) --- .../WindowsSettings.json | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/modules/launcher/Plugins/Microsoft.PowerToys.Run.Plugin.WindowsSettings/WindowsSettings.json b/src/modules/launcher/Plugins/Microsoft.PowerToys.Run.Plugin.WindowsSettings/WindowsSettings.json index c7a1a8e950..2695b7c1d2 100644 --- a/src/modules/launcher/Plugins/Microsoft.PowerToys.Run.Plugin.WindowsSettings/WindowsSettings.json +++ b/src/modules/launcher/Plugins/Microsoft.PowerToys.Run.Plugin.WindowsSettings/WindowsSettings.json @@ -1240,7 +1240,15 @@ "Name": "WindowsUpdateCheckForUpdates", "Areas": [ "AreaUpdateAndSecurity" ], "Type": "AppSettingsApp", - "Command": "ms-settings:windowsupdate-action" + "Command": "ms-settings:windowsupdate-action", + "DeprecatedInBuild": 22000 + }, + { + "Name": "WindowsUpdateCheckForUpdates", + "Areas": [ "AreaUpdateAndSecurity" ], + "Type": "AppSettingsApp", + "Command": "ms-settings:windowsupdate", + "IntroducedInBuild": 22000 }, { "Name": "WindowsUpdateAdvancedOptions", From d8ffa36bc609344b881a49ef6a9c4a908d67e0d4 Mon Sep 17 00:00:00 2001 From: Stefan Markovic <57057282+stefansjfw@users.noreply.github.com> Date: Mon, 25 Sep 2023 15:24:25 +0200 Subject: [PATCH 2/4] Escape > with > and quotes with " in style attribute (#28762) --- .../previewpane/common/Utilities/SvgPreviewHandlerHelper.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/modules/previewpane/common/Utilities/SvgPreviewHandlerHelper.cs b/src/modules/previewpane/common/Utilities/SvgPreviewHandlerHelper.cs index 5cb346d70e..d9623b8490 100644 --- a/src/modules/previewpane/common/Utilities/SvgPreviewHandlerHelper.cs +++ b/src/modules/previewpane/common/Utilities/SvgPreviewHandlerHelper.cs @@ -210,7 +210,7 @@ namespace Common.Utilities // max-width and max-height not supported. Extra CSS is needed for it to work. string scaling = $"max-width: {width} ; max-height: {height} ;"; - scaling += $" _height:expression(this.scrollHeight > {heightR} ? \" {height}\" : \"auto\"); _width:expression(this.scrollWidth > {widthR} ? \"{width}\" : \"auto\");"; + scaling += $" _height:expression(this.scrollHeight > {heightR} ? " {height}" : "auto"); _width:expression(this.scrollWidth > {widthR} ? "{width}" : "auto");"; string newStyle = $"style=\"{scaling}{centering}{oldStyle}\""; int insertAt = stringSvgData.IndexOf(">", StringComparison.InvariantCultureIgnoreCase); From 28bd0686cc27f643287fda9780002472e57780f1 Mon Sep 17 00:00:00 2001 From: Jaime Bernardo Date: Mon, 25 Sep 2023 16:06:55 +0100 Subject: [PATCH 3/4] [CropAndLock]Fix crash on reparent SetPosition fail (#28763) --- .../CropAndLock/CropAndLock/ReparentCropAndLockWindow.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/modules/CropAndLock/CropAndLock/ReparentCropAndLockWindow.cpp b/src/modules/CropAndLock/CropAndLock/ReparentCropAndLockWindow.cpp index cdf9fb3eb0..83087502c8 100644 --- a/src/modules/CropAndLock/CropAndLock/ReparentCropAndLockWindow.cpp +++ b/src/modules/CropAndLock/CropAndLock/ReparentCropAndLockWindow.cpp @@ -131,7 +131,10 @@ void ReparentCropAndLockWindow::CropAndLock(HWND windowToCrop, RECT cropRect) SetWindowLongPtrW(m_currentTarget, GWL_STYLE, targetStyle); auto x = -cropRect.left; auto y = -cropRect.top; - winrt::check_bool(SetWindowPos(m_currentTarget, nullptr, x, y, 0, 0, SWP_NOSIZE | SWP_FRAMECHANGED | SWP_NOZORDER)); + if (0 == SetWindowPos(m_currentTarget, nullptr, x, y, 0, 0, SWP_NOSIZE | SWP_FRAMECHANGED | SWP_NOZORDER)) + { + MessageBoxW(nullptr, L"CropAndLock couldn't properly reparent the target window. It might not handle reparenting well.", L"CropAndLock", MB_ICONERROR); + } } void ReparentCropAndLockWindow::Hide() From a1e0bd51617b2bea189cb16324eecd0e13fa7b86 Mon Sep 17 00:00:00 2001 From: Jaime Bernardo Date: Mon, 25 Sep 2023 16:23:30 +0100 Subject: [PATCH 4/4] [Peek]Fix IsDevFilePreview and white flash (#28734) --- .../Controls/BrowserControl.xaml.cs | 32 ++++++++++++++++--- .../WebBrowserPreviewer.cs | 2 ++ 2 files changed, 29 insertions(+), 5 deletions(-) diff --git a/src/modules/peek/Peek.FilePreviewer/Controls/BrowserControl.xaml.cs b/src/modules/peek/Peek.FilePreviewer/Controls/BrowserControl.xaml.cs index 1fbe78a166..61efadd7fc 100644 --- a/src/modules/peek/Peek.FilePreviewer/Controls/BrowserControl.xaml.cs +++ b/src/modules/peek/Peek.FilePreviewer/Controls/BrowserControl.xaml.cs @@ -24,7 +24,7 @@ namespace Peek.FilePreviewer.Controls /// private Uri? _navigatedUri; - private Color originalBackgroundColor; + private Color? _originalBackgroundColor; public delegate void NavigationCompletedHandler(WebView2? sender, CoreWebView2NavigationCompletedEventArgs? args); @@ -52,6 +52,7 @@ namespace Peek.FilePreviewer.Controls typeof(BrowserControl), new PropertyMetadata(null, new PropertyChangedCallback((d, e) => ((BrowserControl)d).OnIsDevFilePreviewChanged()))); + // Will actually be true for Markdown files as well. public bool IsDevFilePreview { get @@ -101,6 +102,11 @@ namespace Peek.FilePreviewer.Controls private void SourcePropertyChanged() { OpenUriDialog.Hide(); + + // Setting the background color to transparent. + // This ensures that non-HTML files are displayed with a transparent background. + PreviewBrowser.DefaultBackgroundColor = Color.FromArgb(0, 0, 0, 0); + Navigate(); } @@ -113,6 +119,10 @@ namespace Peek.FilePreviewer.Controls { PreviewBrowser.CoreWebView2.SetVirtualHostNameToFolderMapping(Microsoft.PowerToys.FilePreviewCommon.MonacoHelper.VirtualHostName, Microsoft.PowerToys.FilePreviewCommon.MonacoHelper.MonacoDirectory, CoreWebView2HostResourceAccessKind.Allow); } + else + { + PreviewBrowser.CoreWebView2.ClearVirtualHostNameToFolderMapping(Microsoft.PowerToys.FilePreviewCommon.MonacoHelper.VirtualHostName); + } } } @@ -123,7 +133,10 @@ namespace Peek.FilePreviewer.Controls await PreviewBrowser.EnsureCoreWebView2Async(); // Storing the original background color so it can be reset later for specific file types like HTML. - originalBackgroundColor = PreviewBrowser.DefaultBackgroundColor; + if (!_originalBackgroundColor.HasValue) + { + _originalBackgroundColor = PreviewBrowser.DefaultBackgroundColor; + } // Setting the background color to transparent when initially loading the WebView2 component. // This ensures that non-HTML files are displayed with a transparent background. @@ -142,6 +155,10 @@ namespace Peek.FilePreviewer.Controls { PreviewBrowser.CoreWebView2.SetVirtualHostNameToFolderMapping(Microsoft.PowerToys.FilePreviewCommon.MonacoHelper.VirtualHostName, Microsoft.PowerToys.FilePreviewCommon.MonacoHelper.MonacoDirectory, CoreWebView2HostResourceAccessKind.Allow); } + else + { + PreviewBrowser.CoreWebView2.ClearVirtualHostNameToFolderMapping(Microsoft.PowerToys.FilePreviewCommon.MonacoHelper.VirtualHostName); + } PreviewBrowser.CoreWebView2.DOMContentLoaded += CoreWebView2_DOMContentLoaded; PreviewBrowser.CoreWebView2.NewWindowRequested += CoreWebView2_NewWindowRequested; @@ -158,11 +175,16 @@ namespace Peek.FilePreviewer.Controls { // If the file being previewed is HTML or HTM, reset the background color to its original state. // This is done to ensure that HTML and HTM files are displayed as intended, with their own background settings. - if (Source?.ToString().EndsWith(".html", StringComparison.OrdinalIgnoreCase) == true || - Source?.ToString().EndsWith(".htm", StringComparison.OrdinalIgnoreCase) == true) + // This shouldn't be done for dev file previewer. + if (!IsDevFilePreview && + (Source?.ToString().EndsWith(".html", StringComparison.OrdinalIgnoreCase) == true || + Source?.ToString().EndsWith(".htm", StringComparison.OrdinalIgnoreCase) == true)) { // Reset to default behavior for HTML files - PreviewBrowser.DefaultBackgroundColor = originalBackgroundColor; + if (_originalBackgroundColor.HasValue) + { + PreviewBrowser.DefaultBackgroundColor = _originalBackgroundColor.Value; + } } DOMContentLoaded?.Invoke(sender, args); diff --git a/src/modules/peek/Peek.FilePreviewer/Previewers/WebBrowserPreviewer/WebBrowserPreviewer.cs b/src/modules/peek/Peek.FilePreviewer/Previewers/WebBrowserPreviewer/WebBrowserPreviewer.cs index d3403b4c22..f13bad1d39 100644 --- a/src/modules/peek/Peek.FilePreviewer/Previewers/WebBrowserPreviewer/WebBrowserPreviewer.cs +++ b/src/modules/peek/Peek.FilePreviewer/Previewers/WebBrowserPreviewer/WebBrowserPreviewer.cs @@ -118,6 +118,8 @@ namespace Peek.FilePreviewer.Previewers } else { + // Simple html file to preview. Shouldn't do things like enabling scripts or using a virtual mapped directory. + IsDevFilePreview = false; Preview = new Uri(File.Path); } });