From 53f54a2a38e3c3fa73510eb7db8b959b30e66a05 Mon Sep 17 00:00:00 2001 From: CantPressF <55562533+CantPressF@users.noreply.github.com> Date: Mon, 6 Oct 2025 18:27:55 -0400 Subject: [PATCH] Fix: Fixed Main-Window focus overpowering opening of property windows from the sidebar. --- .../Actions/Open/OpenClassicPropertiesAction.cs | 15 ++++++++++++++- .../FilesOpenDialog/Files.App.Launcher.exe.sha256 | 2 +- src/Files.App/MainWindow.xaml.cs | 7 ++++++- 3 files changed, 21 insertions(+), 3 deletions(-) diff --git a/src/Files.App/Actions/Open/OpenClassicPropertiesAction.cs b/src/Files.App/Actions/Open/OpenClassicPropertiesAction.cs index d3d3c40a9964..be2316b69929 100644 --- a/src/Files.App/Actions/Open/OpenClassicPropertiesAction.cs +++ b/src/Files.App/Actions/Open/OpenClassicPropertiesAction.cs @@ -4,6 +4,8 @@ using System.Runtime.InteropServices; using Windows.Win32; using Windows.Win32.UI.Shell; +using Windows.Win32.Foundation; +using Windows.Win32.UI.WindowsAndMessaging; namespace Files.App.Actions { @@ -53,12 +55,23 @@ private unsafe void ExecuteShellCommand(string itemPath) info.nShow = 5; // SW_SHOW info.fMask = 0x0000000C; // SEE_MASK_INVOKEIDLIST + // Prevent Main Window from coming to from when sidebar menu is opened. + + MainWindow.Instance.SetCanWindowToFront(false); + fixed (char* cVerb = "properties", lpFile = itemPath) { info.lpVerb = cVerb; info.lpFile = lpFile; - PInvoke.ShellExecuteEx(ref info); + try + { + PInvoke.ShellExecuteEx(ref info); + } + finally + { + MainWindow.Instance.SetCanWindowToFront(true); + } } } diff --git a/src/Files.App/Assets/FilesOpenDialog/Files.App.Launcher.exe.sha256 b/src/Files.App/Assets/FilesOpenDialog/Files.App.Launcher.exe.sha256 index 11864831640e..d095345e1aa6 100644 --- a/src/Files.App/Assets/FilesOpenDialog/Files.App.Launcher.exe.sha256 +++ b/src/Files.App/Assets/FilesOpenDialog/Files.App.Launcher.exe.sha256 @@ -1 +1 @@ -cb1ca000ef2f03f1afc7bde9ed4fb2987669c89a58b63919e67574696091f60f +6d8695f63ae17c1df079e8e207b3b8dec7ab5b34b17a79386c6bba77d8684027 diff --git a/src/Files.App/MainWindow.xaml.cs b/src/Files.App/MainWindow.xaml.cs index a4d7b352c0c9..11d8234169c6 100644 --- a/src/Files.App/MainWindow.xaml.cs +++ b/src/Files.App/MainWindow.xaml.cs @@ -287,7 +287,12 @@ async Task PerformNavigationAsync(string payload, string selectItem = null) if (rootFrame.Content is MainPage && MainPageViewModel.AppInstances.Any()) { // Bring to foreground (#14730) - Win32Helper.BringToForegroundEx(new(WindowHandle)); + + // Exception for Menus opened from the sidebar. + if (CanWindowToFront) + { + Win32Helper.BringToForegroundEx(new(WindowHandle)); + } var existingTabIndex = MainPageViewModel.AppInstances .Select((tabItem, idx) => new { tabItem, idx })