From 020ced45d084e96fd5feb431fce5a1d95f328738 Mon Sep 17 00:00:00 2001 From: pc223 <10551242+pc223@users.noreply.github.com> Date: Sat, 3 Jul 2021 00:40:20 +0700 Subject: [PATCH] Fix (workaround) for the window freezes after lock screen (Win+L) Co-authored-by: taooceros --- Flow.Launcher/SettingWindow.xaml | 1 + Flow.Launcher/SettingWindow.xaml.cs | 9 +++++++++ 2 files changed, 10 insertions(+) diff --git a/Flow.Launcher/SettingWindow.xaml b/Flow.Launcher/SettingWindow.xaml index 566ecd61ac3..9513cf41c29 100644 --- a/Flow.Launcher/SettingWindow.xaml +++ b/Flow.Launcher/SettingWindow.xaml @@ -18,6 +18,7 @@ Height="600" Width="900" MinWidth="850" MinHeight="500" + Loaded="OnLoaded" Closed="OnClosed" d:DataContext="{d:DesignInstance vm:SettingWindowViewModel}"> diff --git a/Flow.Launcher/SettingWindow.xaml.cs b/Flow.Launcher/SettingWindow.xaml.cs index a922b4d67b4..2823e4ddd8b 100644 --- a/Flow.Launcher/SettingWindow.xaml.cs +++ b/Flow.Launcher/SettingWindow.xaml.cs @@ -2,6 +2,7 @@ using System.IO; using System.Windows; using System.Windows.Input; +using System.Windows.Interop; using System.Windows.Navigation; using Microsoft.Win32; using NHotkey; @@ -35,6 +36,14 @@ public SettingWindow(IPublicAPI api, SettingWindowViewModel viewModel) } #region General + private void OnLoaded(object sender, RoutedEventArgs e) + { + // Fix (workaround) for the window freezes after lock screen (Win+L) + // https://stackoverflow.com/questions/4951058/software-rendering-mode-wpf + HwndSource hwndSource = PresentationSource.FromVisual(this) as HwndSource; + HwndTarget hwndTarget = hwndSource.CompositionTarget; + hwndTarget.RenderMode = RenderMode.SoftwareOnly; + } private void OnAutoStartupChecked(object sender, RoutedEventArgs e) {