Skip to content

Commit 53f54a2

Browse files
CantPressFyaira2
authored andcommitted
Fix: Fixed Main-Window focus overpowering opening of property windows from the sidebar.
1 parent 1a12af6 commit 53f54a2

File tree

3 files changed

+21
-3
lines changed

3 files changed

+21
-3
lines changed

src/Files.App/Actions/Open/OpenClassicPropertiesAction.cs

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
using System.Runtime.InteropServices;
55
using Windows.Win32;
66
using Windows.Win32.UI.Shell;
7+
using Windows.Win32.Foundation;
8+
using Windows.Win32.UI.WindowsAndMessaging;
79

810
namespace Files.App.Actions
911
{
@@ -53,12 +55,23 @@ private unsafe void ExecuteShellCommand(string itemPath)
5355
info.nShow = 5; // SW_SHOW
5456
info.fMask = 0x0000000C; // SEE_MASK_INVOKEIDLIST
5557

58+
// Prevent Main Window from coming to from when sidebar menu is opened.
59+
60+
MainWindow.Instance.SetCanWindowToFront(false);
61+
5662
fixed (char* cVerb = "properties", lpFile = itemPath)
5763
{
5864
info.lpVerb = cVerb;
5965
info.lpFile = lpFile;
6066

61-
PInvoke.ShellExecuteEx(ref info);
67+
try
68+
{
69+
PInvoke.ShellExecuteEx(ref info);
70+
}
71+
finally
72+
{
73+
MainWindow.Instance.SetCanWindowToFront(true);
74+
}
6275
}
6376
}
6477

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
cb1ca000ef2f03f1afc7bde9ed4fb2987669c89a58b63919e67574696091f60f
1+
6d8695f63ae17c1df079e8e207b3b8dec7ab5b34b17a79386c6bba77d8684027

src/Files.App/MainWindow.xaml.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,12 @@ async Task PerformNavigationAsync(string payload, string selectItem = null)
287287
if (rootFrame.Content is MainPage && MainPageViewModel.AppInstances.Any())
288288
{
289289
// Bring to foreground (#14730)
290-
Win32Helper.BringToForegroundEx(new(WindowHandle));
290+
291+
// Exception for Menus opened from the sidebar.
292+
if (CanWindowToFront)
293+
{
294+
Win32Helper.BringToForegroundEx(new(WindowHandle));
295+
}
291296

292297
var existingTabIndex = MainPageViewModel.AppInstances
293298
.Select((tabItem, idx) => new { tabItem, idx })

0 commit comments

Comments
 (0)