Skip to content

Commit 99b35a3

Browse files
authored
Merge pull request #544 from pc223/fix-setting-freezes-after-lock-screen
Fix (workaround) for the settings-window freezes after lock screen (Win+L)
2 parents bb84c74 + 020ced4 commit 99b35a3

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

Flow.Launcher/SettingWindow.xaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
Height="600" Width="900"
1919
MinWidth="850"
2020
MinHeight="500"
21+
Loaded="OnLoaded"
2122
Closed="OnClosed"
2223
d:DataContext="{d:DesignInstance vm:SettingWindowViewModel}">
2324
<Window.InputBindings>

Flow.Launcher/SettingWindow.xaml.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
using System.IO;
33
using System.Windows;
44
using System.Windows.Input;
5+
using System.Windows.Interop;
56
using System.Windows.Navigation;
67
using Microsoft.Win32;
78
using NHotkey;
@@ -35,6 +36,14 @@ public SettingWindow(IPublicAPI api, SettingWindowViewModel viewModel)
3536
}
3637

3738
#region General
39+
private void OnLoaded(object sender, RoutedEventArgs e)
40+
{
41+
// Fix (workaround) for the window freezes after lock screen (Win+L)
42+
// https://stackoverflow.com/questions/4951058/software-rendering-mode-wpf
43+
HwndSource hwndSource = PresentationSource.FromVisual(this) as HwndSource;
44+
HwndTarget hwndTarget = hwndSource.CompositionTarget;
45+
hwndTarget.RenderMode = RenderMode.SoftwareOnly;
46+
}
3847

3948
private void OnAutoStartupChecked(object sender, RoutedEventArgs e)
4049
{

0 commit comments

Comments
 (0)