Skip to content

Commit 6c36665

Browse files
committed
Fix: Fixed an issue where function does not work after closing window to background
1 parent 1aa2cd6 commit 6c36665

File tree

2 files changed

+2
-15
lines changed

2 files changed

+2
-15
lines changed

Diff for: src/Files.App/App.xaml.cs

-5
Original file line numberDiff line numberDiff line change
@@ -157,8 +157,6 @@ async Task ActivateAsync()
157157
}
158158

159159
await AppLifecycleHelper.InitializeAppComponentsAsync();
160-
161-
MainWindow.Instance.HookWindowMessageReceivedEvent();
162160
}
163161
}
164162

@@ -198,9 +196,6 @@ private void Window_Activated(object sender, WindowActivatedEventArgs args)
198196
/// </remarks>
199197
private async void Window_Closed(object sender, WindowEventArgs args)
200198
{
201-
// Unhook events for the window
202-
MainWindow.Instance.UnhookWindowMessageReceivedEvent();
203-
204199
// Save application state and stop any background activity
205200
IUserSettingsService userSettingsService = Ioc.Default.GetRequiredService<IUserSettingsService>();
206201
StatusCenterViewModel statusCenterViewModel = Ioc.Default.GetRequiredService<StatusCenterViewModel>();

Diff for: src/Files.App/MainWindow.xaml.cs

+2-10
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ public MainWindow()
3636
AppWindow.TitleBar.ButtonPressedBackgroundColor = Colors.Transparent;
3737
AppWindow.TitleBar.ButtonHoverBackgroundColor = Colors.Transparent;
3838
AppWindow.SetIcon(AppLifecycleHelper.AppIconPath);
39+
40+
WinUIEx.WindowManager.Get(this).WindowMessageReceived += WindowManager_WindowMessageReceived;
3941
}
4042

4143
public void ShowSplashScreen()
@@ -351,16 +353,6 @@ public bool SetCanWindowToFront(bool canWindowToFront)
351353
return false;
352354
}
353355

354-
public void HookWindowMessageReceivedEvent()
355-
{
356-
WinUIEx.WindowManager.Get(this).WindowMessageReceived += WindowManager_WindowMessageReceived;
357-
}
358-
359-
public void UnhookWindowMessageReceivedEvent()
360-
{
361-
WinUIEx.WindowManager.Get(this).WindowMessageReceived -= WindowManager_WindowMessageReceived;
362-
}
363-
364356
private const int WM_WINDOWPOSCHANGING = 0x0046;
365357
private void WindowManager_WindowMessageReceived(object? sender, WinUIEx.Messaging.WindowMessageEventArgs e)
366358
{

0 commit comments

Comments
 (0)