Skip to content

Commit 66556cb

Browse files
gave92yaira2
andauthored
Fix: Fixed an issue where the window wasn't refocused if minimized on launch (#15247)
Co-authored-by: Yair <[email protected]>
1 parent b352841 commit 66556cb

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

src/Files.App/MainWindow.xaml.cs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,11 @@
11
// Copyright (c) 2024 Files Community
22
// Licensed under the MIT License. See the LICENSE.
33

4-
using Files.App.UserControls.TabBar;
54
using Microsoft.UI;
65
using Microsoft.UI.Windowing;
7-
using Microsoft.UI.Xaml;
86
using Microsoft.UI.Xaml.Controls;
97
using Microsoft.UI.Xaml.Media.Animation;
108
using Microsoft.UI.Xaml.Navigation;
11-
using System.IO;
12-
using Windows.ApplicationModel;
139
using Windows.ApplicationModel.Activation;
1410
using Windows.Storage;
1511
using WinUIEx;
@@ -207,6 +203,9 @@ public async Task InitializeApplicationAsync(object activatedEventArgs)
207203
AppWindow.Show();
208204
Activate();
209205
}
206+
207+
if (Windows.Win32.PInvoke.IsIconic(new(WindowHandle)))
208+
Instance.Restore(); // Restore window if minimized
210209
}
211210

212211
public Frame EnsureWindowIsInitialized()

src/Files.App/NativeMethods.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ AttachThreadInput
3939
SetWindowPos
4040
SetFocus
4141
SetActiveWindow
42+
IsIconic
4243
CopyFileFromApp
4344
MoveFileFromApp
4445
DeleteFileFromApp

0 commit comments

Comments
 (0)