Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/Files.App/Helpers/Interop/InteropHelpers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ public static class InteropHelpers
[DllImport("kernel32.dll")]
public static extern bool SetEvent(IntPtr hEvent);

[DllImport("user32.dll", SetLastError = true)]
public static extern void SwitchToThisWindow(IntPtr hWnd, bool altTab);

[DllImport("ole32.dll")]
public static extern uint CoWaitForMultipleObjects(uint dwFlags, uint dwMilliseconds, ulong nHandles, IntPtr[] pHandles, out uint dwIndex);

Expand Down
6 changes: 6 additions & 0 deletions src/Files.App/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ public async Task InitializeApplicationAsync(object activatedEventArgs)
}
else if (!(string.IsNullOrEmpty(launchArgs.Arguments) && MainPageViewModel.AppInstances.Count > 0))
{
InteropHelpers.SwitchToThisWindow(WindowHandle, true);
await mainPageViewModel.AddNewTabByPathAsync(typeof(PaneHolderPage), launchArgs.Arguments);
}
else
Expand Down Expand Up @@ -173,6 +174,8 @@ public async Task InitializeApplicationAsync(object activatedEventArgs)
rootFrame.Navigate(typeof(MainPage), fileArgs.Files.First().Path, new SuppressNavigationTransitionInfo());
index = 1;
}
else
InteropHelpers.SwitchToThisWindow(WindowHandle, true);
for (; index < fileArgs.Files.Count; index++)
{
await mainPageViewModel.AddNewTabByPathAsync(typeof(PaneHolderPage), fileArgs.Files[index].Path);
Expand Down Expand Up @@ -235,7 +238,10 @@ async Task PerformNavigationAsync(string payload, string selectItem = null)
};

if (rootFrame.Content is MainPage && MainPageViewModel.AppInstances.Any())
{
InteropHelpers.SwitchToThisWindow(WindowHandle, true);
await mainPageViewModel.AddNewTabByParamAsync(typeof(PaneHolderPage), paneNavigationArgs);
}
else
rootFrame.Navigate(typeof(MainPage), paneNavigationArgs, new SuppressNavigationTransitionInfo());
}
Expand Down