From 3e9a0e2c71c39aa85b79b2839fed4ec2d580e71e Mon Sep 17 00:00:00 2001 From: DB p Date: Sun, 23 Feb 2025 06:10:41 +0900 Subject: [PATCH 001/106] Added basic structure for fluent window --- Flow.Launcher.Core/Resource/Theme.cs | 151 ++++++++++++++++++++ Flow.Launcher.Infrastructure/Win32Helper.cs | 22 +++ Flow.Launcher/MainWindow.xaml | 10 +- Flow.Launcher/MainWindow.xaml.cs | 4 +- 4 files changed, 181 insertions(+), 6 deletions(-) diff --git a/Flow.Launcher.Core/Resource/Theme.cs b/Flow.Launcher.Core/Resource/Theme.cs index 2c2feeae171..ed975aa9dc2 100644 --- a/Flow.Launcher.Core/Resource/Theme.cs +++ b/Flow.Launcher.Core/Resource/Theme.cs @@ -12,6 +12,9 @@ using Flow.Launcher.Infrastructure.Logger; using Flow.Launcher.Infrastructure.UserSettings; using System.Windows.Shell; +using static Flow.Launcher.Core.Resource.Theme.ParameterTypes; +using System.Runtime.InteropServices; +using System.Windows.Interop; namespace Flow.Launcher.Core.Resource { @@ -59,6 +62,153 @@ public Theme() _oldTheme = Path.GetFileNameWithoutExtension(_oldResource.Source.AbsolutePath); } + #region Blur Handling + public class ParameterTypes + { + + [Flags] + public enum DWMWINDOWATTRIBUTE + { + DWMWA_USE_IMMERSIVE_DARK_MODE = 20, + DWMWA_SYSTEMBACKDROP_TYPE = 38, + DWMWA_TRANSITIONS_FORCEDISABLED = 3, + DWMWA_BORDER_COLOR + } + + [StructLayout(LayoutKind.Sequential)] + public struct MARGINS + { + public int cxLeftWidth; // width of left border that retains its size + public int cxRightWidth; // width of right border that retains its size + public int cyTopHeight; // height of top border that retains its size + public int cyBottomHeight; // height of bottom border that retains its size + }; + } + + public static class Methods + { + [DllImport("DwmApi.dll")] + static extern int DwmExtendFrameIntoClientArea( + IntPtr hwnd, + ref ParameterTypes.MARGINS pMarInset); + + [DllImport("dwmapi.dll")] + static extern int DwmSetWindowAttribute(IntPtr hwnd, ParameterTypes.DWMWINDOWATTRIBUTE dwAttribute, ref int pvAttribute, int cbAttribute); + + public static int ExtendFrame(IntPtr hwnd, ParameterTypes.MARGINS margins) + => DwmExtendFrameIntoClientArea(hwnd, ref margins); + + public static int SetWindowAttribute(IntPtr hwnd, ParameterTypes.DWMWINDOWATTRIBUTE attribute, int parameter) + => DwmSetWindowAttribute(hwnd, attribute, ref parameter, Marshal.SizeOf()); + } + + Window mainWindow = Application.Current.MainWindow; + + public void RefreshFrame() + { + IntPtr mainWindowPtr = new WindowInteropHelper(mainWindow).Handle; + HwndSource mainWindowSrc = HwndSource.FromHwnd(mainWindowPtr); + //mainWindowSrc.CompositionTarget.BackgroundColor = Color.FromArgb(0, 255, 181, 178); + + ParameterTypes.MARGINS margins = new ParameterTypes.MARGINS(); + margins.cxLeftWidth = -1; + margins.cxRightWidth = -1; + margins.cyTopHeight = -1; + margins.cyBottomHeight = -1; + Methods.ExtendFrame(mainWindowSrc.Handle, margins); + + // Remove OS minimizing/maximizing animation + Methods.SetWindowAttribute(new WindowInteropHelper(mainWindow).Handle, DWMWINDOWATTRIBUTE.DWMWA_TRANSITIONS_FORCEDISABLED, 3); + //Methods.SetWindowAttribute(new WindowInteropHelper(mainWindow).Handle, DWMWINDOWATTRIBUTE.DWMWA_BORDER_COLOR, 0x00FF0000); + Methods.SetWindowAttribute(new WindowInteropHelper(mainWindow).Handle, DWMWINDOWATTRIBUTE.DWMWA_SYSTEMBACKDROP_TYPE, 3); + SetBlurForWindow(); + } + + + + /// + /// Sets the blur for a window via SetWindowCompositionAttribute + /// + public void SetBlurForWindow() + { + //SetWindowAccent(); + var dict = GetThemeResourceDictionary(Settings.Theme); + var windowBorderStyle = dict["WindowBorderStyle"] as Style; + if (BlurEnabled) + { + windowBorderStyle.Setters.Remove(windowBorderStyle.Setters.OfType().FirstOrDefault(x => x.Property.Name == "Background")); + windowBorderStyle.Setters.Add(new Setter(Border.BackgroundProperty, new SolidColorBrush(Colors.Transparent))); + //mainWindow.WindowStyle = WindowStyle.SingleBorderWindow; + Methods.SetWindowAttribute(new WindowInteropHelper(mainWindow).Handle, DWMWINDOWATTRIBUTE.DWMWA_SYSTEMBACKDROP_TYPE, 3); + BlurColor(BlurMode()); + } + else + { + mainWindow.WindowStyle = WindowStyle.None; + if (windowBorderStyle.Setters.OfType().FirstOrDefault(x => x.Property.Name == "Background") != null) + { + windowBorderStyle.Setters.Add(windowBorderStyle.Setters.OfType().FirstOrDefault(x => x.Property.Name == "Background")); + } + Methods.SetWindowAttribute(new WindowInteropHelper(mainWindow).Handle, DWMWINDOWATTRIBUTE.DWMWA_SYSTEMBACKDROP_TYPE, 1); + } + UpdateResourceDictionary(dict); + } + + public void BlurColor(string Color) + { + if (Color == "Light") + { + Methods.SetWindowAttribute(new WindowInteropHelper(mainWindow).Handle, DWMWINDOWATTRIBUTE.DWMWA_USE_IMMERSIVE_DARK_MODE, 0); + } + else if (Color == "Dark") + { + Methods.SetWindowAttribute(new WindowInteropHelper(mainWindow).Handle, DWMWINDOWATTRIBUTE.DWMWA_USE_IMMERSIVE_DARK_MODE, 1); + } + else /* Case of "Auto" Blur Type Theme */ + { + //if (_isDarkTheme()) + //{ + // Methods.SetWindowAttribute(new WindowInteropHelper(mainWindow).Handle, DWMWINDOWATTRIBUTE.DWMWA_USE_IMMERSIVE_DARK_MODE, 1); + //} + //else + //{ + // Methods.SetWindowAttribute(new WindowInteropHelper(mainWindow).Handle, DWMWINDOWATTRIBUTE.DWMWA_USE_IMMERSIVE_DARK_MODE, 0); + //} + Methods.SetWindowAttribute(new WindowInteropHelper(mainWindow).Handle, DWMWINDOWATTRIBUTE.DWMWA_USE_IMMERSIVE_DARK_MODE, 1); + } + + } + public bool IsBlurTheme() + { + if (Environment.OSVersion.Version >= new Version(6, 2)) + { + var resource = Application.Current.TryFindResource("ThemeBlurEnabled"); + + if (resource is bool) + return (bool)resource; + + return false; + } + + return false; + } + public string BlurMode() + { + if (Environment.OSVersion.Version >= new Version(6, 2)) + { + var resource = Application.Current.TryFindResource("BlurMode"); + + if (resource is string) + return (string)resource; + + return null; + } + + return null; + } + + #endregion + private void MakeSureThemeDirectoriesExist() { foreach (var dir in _themeDirectories.Where(dir => !Directory.Exists(dir))) @@ -103,6 +253,7 @@ public bool ChangeTheme(string theme) AddDropShadowEffectToCurrentTheme(); Win32Helper.SetBlurForWindow(Application.Current.MainWindow, BlurEnabled); + //Win32Helper.SetMicaForWindow(Application.Current.MainWindow, BlurEnabled); } catch (DirectoryNotFoundException) { diff --git a/Flow.Launcher.Infrastructure/Win32Helper.cs b/Flow.Launcher.Infrastructure/Win32Helper.cs index 867fef4f509..856748537e5 100644 --- a/Flow.Launcher.Infrastructure/Win32Helper.cs +++ b/Flow.Launcher.Infrastructure/Win32Helper.cs @@ -7,6 +7,28 @@ namespace Flow.Launcher.Infrastructure { public static class Win32Helper { + private enum DwmSystemBackdropType + { + DWMSBT_AUTO = 0, + DWMSBT_NONE = 1, + DWMSBT_MICA = 2, + DWMSBT_ACRYLIC = 3, + DWMSBT_TABBED = 4 + } + + private const int DWMWA_SYSTEMBACKDROP_TYPE = 38; + + [DllImport("dwmapi.dll")] + private static extern int DwmSetWindowAttribute(IntPtr hwnd, int dwAttribute, ref DwmSystemBackdropType pvAttribute, int cbAttribute); + + public static void SetMicaForWindow(Window window, bool enableMica) + { + var windowHelper = new WindowInteropHelper(window); + windowHelper.EnsureHandle(); + + DwmSystemBackdropType backdropType = enableMica ? DwmSystemBackdropType.DWMSBT_MICA : DwmSystemBackdropType.DWMSBT_NONE; + DwmSetWindowAttribute(windowHelper.Handle, DWMWA_SYSTEMBACKDROP_TYPE, ref backdropType, sizeof(int)); + } #region Blur Handling /* diff --git a/Flow.Launcher/MainWindow.xaml b/Flow.Launcher/MainWindow.xaml index 10fc3583b8b..22594217f52 100644 --- a/Flow.Launcher/MainWindow.xaml +++ b/Flow.Launcher/MainWindow.xaml @@ -15,12 +15,11 @@ MinHeight="30" d:DataContext="{d:DesignInstance Type=vm:MainViewModel}" AllowDrop="True" - AllowsTransparency="True" - Background="Transparent" + AllowsTransparency="False" + Background="#DB213C95" Closing="OnClosing" Deactivated="OnDeactivated" Icon="Images/app.png" - SourceInitialized="OnSourceInitialized" Initialized="OnInitialized" Left="{Binding Settings.WindowLeft, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" Loaded="OnLoaded" @@ -31,10 +30,11 @@ ResizeMode="CanResize" ShowInTaskbar="False" SizeToContent="Height" + SourceInitialized="OnSourceInitialized" Topmost="True" Visibility="{Binding MainWindowVisibility, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" WindowStartupLocation="Manual" - WindowStyle="None" + WindowStyle="SingleBorderWindow" mc:Ignorable="d"> @@ -213,7 +213,7 @@ Modifiers="{Binding CycleHistoryDownHotkey, Converter={StaticResource StringToKeyBindingConverter}, ConverterParameter='modifiers'}" /> - + diff --git a/Flow.Launcher/MainWindow.xaml.cs b/Flow.Launcher/MainWindow.xaml.cs index 41dc68fd924..abb959ad8fa 100644 --- a/Flow.Launcher/MainWindow.xaml.cs +++ b/Flow.Launcher/MainWindow.xaml.cs @@ -60,7 +60,6 @@ public MainWindow(Settings settings, MainViewModel mainVM) InitializePosition(); InitSoundEffects(); - DataObject.AddPastingHandler(QueryTextBox, OnPaste); this.Loaded += (_, _) => @@ -182,6 +181,9 @@ private void OnInitialized(object sender, EventArgs e) private void OnLoaded(object sender, RoutedEventArgs _) { + // Remove OS minimizing/maximizing animation + ThemeManager.Instance.RefreshFrame(); + // MouseEventHandler PreviewMouseMove += MainPreviewMouseMove; CheckFirstLaunch(); From 270f5b3ca07f4fe51079295a48f4948f46674dd2 Mon Sep 17 00:00:00 2001 From: DB p Date: Sun, 23 Feb 2025 09:48:33 +0900 Subject: [PATCH 002/106] Base Structure for fluent window --- Flow.Launcher.Core/Resource/Theme.cs | 52 ++++++++++++++----- Flow.Launcher/MainWindow.xaml | 4 +- Flow.Launcher/MainWindow.xaml.cs | 3 +- .../ViewModels/SettingsPaneThemeViewModel.cs | 1 + Flow.Launcher/Themes/BlurBlack.xaml | 2 +- Flow.Launcher/Themes/Win11Light.xaml | 4 +- 6 files changed, 48 insertions(+), 18 deletions(-) diff --git a/Flow.Launcher.Core/Resource/Theme.cs b/Flow.Launcher.Core/Resource/Theme.cs index ed975aa9dc2..3ebcd65c738 100644 --- a/Flow.Launcher.Core/Resource/Theme.cs +++ b/Flow.Launcher.Core/Resource/Theme.cs @@ -15,6 +15,7 @@ using static Flow.Launcher.Core.Resource.Theme.ParameterTypes; using System.Runtime.InteropServices; using System.Windows.Interop; +using System.Diagnostics; namespace Flow.Launcher.Core.Resource { @@ -119,8 +120,9 @@ public void RefreshFrame() // Remove OS minimizing/maximizing animation Methods.SetWindowAttribute(new WindowInteropHelper(mainWindow).Handle, DWMWINDOWATTRIBUTE.DWMWA_TRANSITIONS_FORCEDISABLED, 3); + //Methods.SetWindowAttribute(new WindowInteropHelper(mainWindow).Handle, DWMWINDOWATTRIBUTE.DWMWA_BORDER_COLOR, 0x00FF0000); - Methods.SetWindowAttribute(new WindowInteropHelper(mainWindow).Handle, DWMWINDOWATTRIBUTE.DWMWA_SYSTEMBACKDROP_TYPE, 3); + //Methods.SetWindowAttribute(new WindowInteropHelper(mainWindow).Handle, DWMWINDOWATTRIBUTE.DWMWA_SYSTEMBACKDROP_TYPE, 3); SetBlurForWindow(); } @@ -131,24 +133,26 @@ public void RefreshFrame() /// public void SetBlurForWindow() { + //SetWindowAccent(); var dict = GetThemeResourceDictionary(Settings.Theme); var windowBorderStyle = dict["WindowBorderStyle"] as Style; + Methods.SetWindowAttribute(new WindowInteropHelper(mainWindow).Handle, DWMWINDOWATTRIBUTE.DWMWA_SYSTEMBACKDROP_TYPE, 3); if (BlurEnabled) { + //mainWindow.WindowStyle = WindowStyle.SingleBorderWindow; + BlurColor(BlurMode()); windowBorderStyle.Setters.Remove(windowBorderStyle.Setters.OfType().FirstOrDefault(x => x.Property.Name == "Background")); windowBorderStyle.Setters.Add(new Setter(Border.BackgroundProperty, new SolidColorBrush(Colors.Transparent))); - //mainWindow.WindowStyle = WindowStyle.SingleBorderWindow; Methods.SetWindowAttribute(new WindowInteropHelper(mainWindow).Handle, DWMWINDOWATTRIBUTE.DWMWA_SYSTEMBACKDROP_TYPE, 3); - BlurColor(BlurMode()); } else { - mainWindow.WindowStyle = WindowStyle.None; - if (windowBorderStyle.Setters.OfType().FirstOrDefault(x => x.Property.Name == "Background") != null) - { - windowBorderStyle.Setters.Add(windowBorderStyle.Setters.OfType().FirstOrDefault(x => x.Property.Name == "Background")); - } + //mainWindow.WindowStyle = WindowStyle.None; + //if (windowBorderStyle.Setters.OfType().FirstOrDefault(x => x.Property.Name == "Background") != null) + //{ + // windowBorderStyle.Setters.Add(windowBorderStyle.Setters.OfType().FirstOrDefault(x => x.Property.Name == "Background")); + //} Methods.SetWindowAttribute(new WindowInteropHelper(mainWindow).Handle, DWMWINDOWATTRIBUTE.DWMWA_SYSTEMBACKDROP_TYPE, 1); } UpdateResourceDictionary(dict); @@ -156,28 +160,34 @@ public void SetBlurForWindow() public void BlurColor(string Color) { + if (Color == "Light") { + //mainWindow.Background = new SolidColorBrush(defaultBGcolor.Value); Methods.SetWindowAttribute(new WindowInteropHelper(mainWindow).Handle, DWMWINDOWATTRIBUTE.DWMWA_USE_IMMERSIVE_DARK_MODE, 0); } else if (Color == "Dark") { + //mainWindow.Background = new SolidColorBrush(darkBGcolor.Value); Methods.SetWindowAttribute(new WindowInteropHelper(mainWindow).Handle, DWMWINDOWATTRIBUTE.DWMWA_USE_IMMERSIVE_DARK_MODE, 1); } else /* Case of "Auto" Blur Type Theme */ { //if (_isDarkTheme()) //{ + // mainWindow.Background = new SolidColorBrush(darkBGcolor.Value); // Methods.SetWindowAttribute(new WindowInteropHelper(mainWindow).Handle, DWMWINDOWATTRIBUTE.DWMWA_USE_IMMERSIVE_DARK_MODE, 1); //} //else //{ + // mainWindow.Background = new SolidColorBrush(defaultBGcolor.Value); // Methods.SetWindowAttribute(new WindowInteropHelper(mainWindow).Handle, DWMWINDOWATTRIBUTE.DWMWA_USE_IMMERSIVE_DARK_MODE, 0); //} - Methods.SetWindowAttribute(new WindowInteropHelper(mainWindow).Handle, DWMWINDOWATTRIBUTE.DWMWA_USE_IMMERSIVE_DARK_MODE, 1); - } + //mainWindow.Background = new SolidColorBrush(Colors.Red); + Methods.SetWindowAttribute(new WindowInteropHelper(mainWindow).Handle, DWMWINDOWATTRIBUTE.DWMWA_USE_IMMERSIVE_DARK_MODE, 1); } } + public bool IsBlurTheme() { if (Environment.OSVersion.Version >= new Version(6, 2)) @@ -207,6 +217,24 @@ public string BlurMode() return null; } + //public SolidColorBrush BGColor(string colorBgKey) + //{ + // var defaultBG = Application.Current.TryFindResource("DefaultBG"); + // var darkBG = Application.Current.TryFindResource("DarkBG"); + + // if (colorBgKey == "") + // { + // var resource = Application.Current.TryFindResource("BlurMode"); + + // if (resource is string) + // return (SolidColorBrush)resource; + + // return new SolidColorBrush(Colors.DarkGray); + // } + + // return null; + //} + #endregion private void MakeSureThemeDirectoriesExist() @@ -252,8 +280,8 @@ public bool ChangeTheme(string theme) if (Settings.UseDropShadowEffect && !BlurEnabled) AddDropShadowEffectToCurrentTheme(); - Win32Helper.SetBlurForWindow(Application.Current.MainWindow, BlurEnabled); - //Win32Helper.SetMicaForWindow(Application.Current.MainWindow, BlurEnabled); + //Win32Helper.SetBlurForWindow(Application.Current.MainWindow, BlurEnabled); + SetBlurForWindow(); } catch (DirectoryNotFoundException) { diff --git a/Flow.Launcher/MainWindow.xaml b/Flow.Launcher/MainWindow.xaml index 22594217f52..d99787a8d6b 100644 --- a/Flow.Launcher/MainWindow.xaml +++ b/Flow.Launcher/MainWindow.xaml @@ -16,7 +16,7 @@ d:DataContext="{d:DesignInstance Type=vm:MainViewModel}" AllowDrop="True" AllowsTransparency="False" - Background="#DB213C95" + Background="#E12E2E2E" Closing="OnClosing" Deactivated="OnDeactivated" Icon="Images/app.png" @@ -213,7 +213,7 @@ Modifiers="{Binding CycleHistoryDownHotkey, Converter={StaticResource StringToKeyBindingConverter}, ConverterParameter='modifiers'}" /> - + diff --git a/Flow.Launcher/MainWindow.xaml.cs b/Flow.Launcher/MainWindow.xaml.cs index abb959ad8fa..8270150c24a 100644 --- a/Flow.Launcher/MainWindow.xaml.cs +++ b/Flow.Launcher/MainWindow.xaml.cs @@ -61,7 +61,6 @@ public MainWindow(Settings settings, MainViewModel mainVM) InitSoundEffects(); DataObject.AddPastingHandler(QueryTextBox, OnPaste); - this.Loaded += (_, _) => { var handle = new WindowInteropHelper(this).Handle; @@ -107,6 +106,7 @@ private IntPtr WndProc(IntPtr hwnd, int msg, IntPtr wParam, IntPtr lParam, ref b return IntPtr.Zero; } + private void OnResizeEnd() { int shadowMargin = 0; @@ -181,7 +181,6 @@ private void OnInitialized(object sender, EventArgs e) private void OnLoaded(object sender, RoutedEventArgs _) { - // Remove OS minimizing/maximizing animation ThemeManager.Instance.RefreshFrame(); // MouseEventHandler diff --git a/Flow.Launcher/SettingPages/ViewModels/SettingsPaneThemeViewModel.cs b/Flow.Launcher/SettingPages/ViewModels/SettingsPaneThemeViewModel.cs index 8d8ccb78041..ab2419d9937 100644 --- a/Flow.Launcher/SettingPages/ViewModels/SettingsPaneThemeViewModel.cs +++ b/Flow.Launcher/SettingPages/ViewModels/SettingsPaneThemeViewModel.cs @@ -39,6 +39,7 @@ public Theme.ThemeData SelectedTheme if (ThemeManager.Instance.BlurEnabled && Settings.UseDropShadowEffect) DropShadowEffect = false; + ThemeManager.Instance.RefreshFrame(); } } diff --git a/Flow.Launcher/Themes/BlurBlack.xaml b/Flow.Launcher/Themes/BlurBlack.xaml index 5d0fc2c3c63..63fb836091a 100644 --- a/Flow.Launcher/Themes/BlurBlack.xaml +++ b/Flow.Launcher/Themes/BlurBlack.xaml @@ -10,8 +10,8 @@ - True + Auto diff --git a/Flow.Launcher/Themes/Win11Light.xaml b/Flow.Launcher/Themes/Win11Light.xaml index 4fe3c0495c4..52758171a68 100644 --- a/Flow.Launcher/Themes/Win11Light.xaml +++ b/Flow.Launcher/Themes/Win11Light.xaml @@ -1,7 +1,7 @@ + True + Auto @@ -96,7 +88,7 @@ TargetType="{x:Type Rectangle}"> - + @@ -174,7 +166,7 @@ x:Key="ClockPanel" BasedOn="{StaticResource ClockPanel}" TargetType="{x:Type StackPanel}"> - + diff --git a/Flow.Launcher/Themes/Win11Light.xaml b/Flow.Launcher/Themes/Win11Light.xaml index ba162fe9cd2..5ba82f12ecc 100644 --- a/Flow.Launcher/Themes/Win11Light.xaml +++ b/Flow.Launcher/Themes/Win11Light.xaml @@ -14,6 +14,7 @@ True Auto + ROUND #BFFAFAFA #DD202020 diff --git a/Flow.Launcher/Themes/BlurWhite.xaml b/Flow.Launcher/Themes/BlurWhite.xaml index ed290d0c8af..29fe38a9cd9 100644 --- a/Flow.Launcher/Themes/BlurWhite.xaml +++ b/Flow.Launcher/Themes/BlurWhite.xaml @@ -11,8 +11,10 @@ True - light + Light + DoNotRound #BFFAFAFA + #BFFAFAFA diff --git a/Flow.Launcher/Themes/Pink.xaml b/Flow.Launcher/Themes/Pink.xaml index d6f9813d001..a8b04d64025 100644 --- a/Flow.Launcher/Themes/Pink.xaml +++ b/Flow.Launcher/Themes/Pink.xaml @@ -1,7 +1,15 @@ - + + True + Light + RoundSmall + #DDFEC7D7 + #DDFEC7D7 0 0 0 0 From 2710de1fbcc20d82a3b58d471add4029e1947eac Mon Sep 17 00:00:00 2001 From: DB p Date: Thu, 6 Mar 2025 21:19:09 +0900 Subject: [PATCH 027/106] Fix Search Icon Opacity --- Flow.Launcher/MainWindow.xaml.cs | 24 ++++++++++++++++++++++-- Flow.Launcher/Themes/Base.xaml | 23 +++++++++++++++++++++++ 2 files changed, 45 insertions(+), 2 deletions(-) diff --git a/Flow.Launcher/MainWindow.xaml.cs b/Flow.Launcher/MainWindow.xaml.cs index 19f928621d0..fc8a9f19281 100644 --- a/Flow.Launcher/MainWindow.xaml.cs +++ b/Flow.Launcher/MainWindow.xaml.cs @@ -566,11 +566,14 @@ public void WindowAnimator() FillBehavior = FillBehavior.HoldEnd }; - double TargetIconOpacity = SearchIcon.Opacity; + double TargetIconOpacity = GetOpacityFromStyle(SearchIcon, SearchIcon.Style, 1.0); // 스타일에서 Opacity 가져오기 + + System.Diagnostics.Debug.WriteLine("스타일에서 가져온 투명도: " + TargetIconOpacity); + var IconOpacity = new DoubleAnimation { From = 0, - To = 1, + To = TargetIconOpacity, EasingFunction = easing, Duration = TimeSpan.FromMilliseconds(animationLength), FillBehavior = FillBehavior.HoldEnd @@ -626,6 +629,23 @@ public void WindowAnimator() windowsb.Begin(FlowMainWindow); } + private double GetOpacityFromStyle(UIElement element, Style style, double defaultOpacity = 1.0) + { + if (style == null) + return defaultOpacity; + + foreach (Setter setter in style.Setters) + { + if (setter.Property == UIElement.OpacityProperty) + { + return setter.Value is double opacity ? opacity : defaultOpacity; + } + } + + return defaultOpacity; + } + + private bool _isClockPanelAnimating = false; // 애니메이션 실행 중인지 여부 private void UpdateClockPanelVisibility() diff --git a/Flow.Launcher/Themes/Base.xaml b/Flow.Launcher/Themes/Base.xaml index 44850e94ea5..9df935b8d7a 100644 --- a/Flow.Launcher/Themes/Base.xaml +++ b/Flow.Launcher/Themes/Base.xaml @@ -165,6 +165,29 @@ BasedOn="{StaticResource BaseClockPanel}" TargetType="{x:Type StackPanel}"> + + From 46cdb2a2731f3489ccf5f6978c94d9757cbe25b5 Mon Sep 17 00:00:00 2001 From: DB p Date: Sat, 8 Mar 2025 16:12:57 +0900 Subject: [PATCH 028/106] Fix Blink issue when hidestartup mode (hide on) --- Flow.Launcher.Core/Resource/Theme.cs | 8 ++++-- Flow.Launcher/MainWindow.xaml.cs | 13 ++++++++- Flow.Launcher/Themes/Pink.xaml | 6 ++-- Flow.Launcher/ViewModel/MainViewModel.cs | 35 ++++++++++++------------ 4 files changed, 37 insertions(+), 25 deletions(-) diff --git a/Flow.Launcher.Core/Resource/Theme.cs b/Flow.Launcher.Core/Resource/Theme.cs index edf1da05e8b..c4e56e813d3 100644 --- a/Flow.Launcher.Core/Resource/Theme.cs +++ b/Flow.Launcher.Core/Resource/Theme.cs @@ -140,6 +140,7 @@ public void RefreshFrame() if (mainWindowSrc == null) return; + ParameterTypes.MARGINS margins = new ParameterTypes.MARGINS(); margins.cxLeftWidth = -1; margins.cxRightWidth = -1; @@ -153,8 +154,7 @@ public void RefreshFrame() //Methods.SetWindowAttribute(new WindowInteropHelper(mainWindow).Handle, DWMWINDOWATTRIBUTE.DWMWA_BORDER_COLOR, 0x00FF0000); //Methods.SetWindowAttribute(new WindowInteropHelper(mainWindow).Handle, DWMWINDOWATTRIBUTE.DWMWA_SYSTEMBACKDROP_TYPE, 3); - // The timing of adding the shadow effect should vary depending on whether the theme is transparent. - if (BlurEnabled) + // The timing of adding the shadow effect should vary depending on whether the theme is transparent. if (BlurEnabled) { AutoDropShadow(); } @@ -164,6 +164,7 @@ public void RefreshFrame() { AutoDropShadow(); } + } public void AutoDropShadow() @@ -248,6 +249,7 @@ public void SetBlurForWindow() var windowBorderStyle = dict["WindowBorderStyle"] as Style; if (windowBorderStyle == null) return; + //Methods.SetWindowAttribute(new WindowInteropHelper(mainWindow).Handle, DWMWINDOWATTRIBUTE.DWMWA_SYSTEMBACKDROP_TYPE, 3); if (BlurEnabled) { @@ -255,9 +257,9 @@ public void SetBlurForWindow() //BlurColor(BlurMode()); Debug.WriteLine("~~~~~~~~~~~~~~~~~~~~"); Debug.WriteLine(BlurMode()); + Methods.SetWindowAttribute(new WindowInteropHelper(mainWindow).Handle, DWMWINDOWATTRIBUTE.DWMWA_SYSTEMBACKDROP_TYPE, 3); windowBorderStyle.Setters.Remove(windowBorderStyle.Setters.OfType().FirstOrDefault(x => x.Property.Name == "Background")); windowBorderStyle.Setters.Add(new Setter(Border.BackgroundProperty, new SolidColorBrush(Colors.Transparent))); - Methods.SetWindowAttribute(new WindowInteropHelper(mainWindow).Handle, DWMWINDOWATTRIBUTE.DWMWA_SYSTEMBACKDROP_TYPE, 3); //SetWindowCornerPreference("Round"); } else diff --git a/Flow.Launcher/MainWindow.xaml.cs b/Flow.Launcher/MainWindow.xaml.cs index fc8a9f19281..4757b1fb43b 100644 --- a/Flow.Launcher/MainWindow.xaml.cs +++ b/Flow.Launcher/MainWindow.xaml.cs @@ -815,12 +815,23 @@ private void OnLocationChanged(object sender, EventArgs e) public void HideStartup() { UpdatePosition(); + if (_settings.HideOnStartup) { - _viewModel.Hide(); + // 📌 최초 실행 시 창이 깜빡이는 문제 방지 (완전히 숨긴 상태로 시작) + System.Windows.Application.Current.MainWindow.Visibility = Visibility.Hidden; + + Dispatcher.BeginInvoke((Action)(() => + { + _viewModel.Hide(); + System.Windows.Application.Current.MainWindow.Visibility = Visibility.Collapsed; + }), DispatcherPriority.Background); } else { + // 📌 최초 실행 시 그림자 효과를 미리 적용하여 Show() 할 때 렌더링이 느려지지 않도록 함 + ThemeManager.Instance.SetBlurForWindow(); + //ThemeManager.Instance.AutoDropShadow(); _viewModel.Show(); } } diff --git a/Flow.Launcher/Themes/Pink.xaml b/Flow.Launcher/Themes/Pink.xaml index a8b04d64025..3d8792a080a 100644 --- a/Flow.Launcher/Themes/Pink.xaml +++ b/Flow.Launcher/Themes/Pink.xaml @@ -8,8 +8,8 @@ True Light RoundSmall - #DDFEC7D7 - #DDFEC7D7 + #4BFEC7D7 + #53FEC7D7 0 0 0 0 diff --git a/Flow.Launcher/ViewModel/MainViewModel.cs b/Flow.Launcher/ViewModel/MainViewModel.cs index 3249fd2217e..6b225ae06a5 100644 --- a/Flow.Launcher/ViewModel/MainViewModel.cs +++ b/Flow.Launcher/ViewModel/MainViewModel.cs @@ -1402,22 +1402,22 @@ public void Show() { IntPtr hWnd = new WindowInteropHelper(mainWindow).Handle; - // 📌 창을 먼저 보이게 설정 - ShowWindow(hWnd, SW_SHOW); + // 📌 창을 보이도록 설정 (Cloak 사용 안 함) + //ShowWindow(hWnd, SW_SHOW); + + // 📌 UI 요소 복원 mainWindow.ClockPanel.Visibility = Visibility.Visible; mainWindow.SearchIcon.Visibility = Visibility.Visible; - // 📌 DWM Cloak 해제 (즉시 표시) - int cloak = 0; - DwmSetWindowAttribute(hWnd, DWMWA_CLOAK, ref cloak, sizeof(int)); } // WPF 속성 업데이트 - //MainWindowOpacity = 1; + MainWindowVisibility = Visibility.Visible; MainWindowVisibilityStatus = true; VisibilityChanged?.Invoke(this, new VisibilityChangedEventArgs { IsVisible = true }); }); } + public async void Hide() { lastHistoryIndex = 1; @@ -1432,7 +1432,7 @@ public async void Hide() if (Application.Current.MainWindow is MainWindow mainWindow) { - // 📌 아이콘과 시계 Opacity를 0으로 강제 설정하고 Visibility.Hidden 적용 (쿼리 상태와 관계없이 실행) + // 📌 아이콘과 시계 Opacity를 0으로 설정하고 Visibility.Hidden 적용 Application.Current.Dispatcher.Invoke(() => { mainWindow.ClockPanel.Opacity = 0; @@ -1445,7 +1445,7 @@ public async void Hide() mainWindow.SearchIcon.UpdateLayout(); }, DispatcherPriority.Render); - await Task.Delay(10); // UI 반영 대기 + //await Task.Delay(10); // UI 반영 대기 } // 📌 텍스트 초기화 즉시 적용 + UI 강제 업데이트 @@ -1478,23 +1478,22 @@ public async void Hide() break; } - if (Application.Current.MainWindow is MainWindow mainWindow2) - { - IntPtr hWnd = new WindowInteropHelper(mainWindow2).Handle; + //if (Application.Current.MainWindow is MainWindow mainWindow2) + //{ + // IntPtr hWnd = new WindowInteropHelper(mainWindow2).Handle; - // 📌 DWM Cloak 활성화 - int cloak = 1; - DwmSetWindowAttribute(hWnd, DWMWA_CLOAK, ref cloak, sizeof(int)); - - // 📌 창을 완전히 숨김 (잔상 방지) - ShowWindow(hWnd, SW_HIDE); - } + // // 📌 Cloak을 사용하지 않고 일반적인 `ShowWindow(SW_HIDE)` 사용 → Mica/Acrylic 유지됨 + // ShowWindow(hWnd, SW_HIDE); + //} // WPF 속성 업데이트 MainWindowVisibilityStatus = false; + MainWindowVisibility = Visibility.Collapsed; VisibilityChanged?.Invoke(this, new VisibilityChangedEventArgs { IsVisible = false }); } + + /// /// Checks if Flow Launcher should ignore any hotkeys /// From 01d081d74057bb22fc43036876cca4a8542fbe15 Mon Sep 17 00:00:00 2001 From: DB p Date: Sat, 8 Mar 2025 18:30:17 +0900 Subject: [PATCH 029/106] Revert Startup Blinking --- Flow.Launcher.Core/Resource/Theme.cs | 3 ++- Flow.Launcher/MainWindow.xaml.cs | 17 +++++++++-------- Flow.Launcher/Themes/Pink.xaml | 2 +- 3 files changed, 12 insertions(+), 10 deletions(-) diff --git a/Flow.Launcher.Core/Resource/Theme.cs b/Flow.Launcher.Core/Resource/Theme.cs index c4e56e813d3..3fb4ea1d6a2 100644 --- a/Flow.Launcher.Core/Resource/Theme.cs +++ b/Flow.Launcher.Core/Resource/Theme.cs @@ -154,7 +154,8 @@ public void RefreshFrame() //Methods.SetWindowAttribute(new WindowInteropHelper(mainWindow).Handle, DWMWINDOWATTRIBUTE.DWMWA_BORDER_COLOR, 0x00FF0000); //Methods.SetWindowAttribute(new WindowInteropHelper(mainWindow).Handle, DWMWINDOWATTRIBUTE.DWMWA_SYSTEMBACKDROP_TYPE, 3); - // The timing of adding the shadow effect should vary depending on whether the theme is transparent. if (BlurEnabled) + // The timing of adding the shadow effect should vary depending on whether the theme is transparent. + if (BlurEnabled) { AutoDropShadow(); } diff --git a/Flow.Launcher/MainWindow.xaml.cs b/Flow.Launcher/MainWindow.xaml.cs index 4757b1fb43b..75c851ab3b9 100644 --- a/Flow.Launcher/MainWindow.xaml.cs +++ b/Flow.Launcher/MainWindow.xaml.cs @@ -819,18 +819,19 @@ public void HideStartup() if (_settings.HideOnStartup) { // 📌 최초 실행 시 창이 깜빡이는 문제 방지 (완전히 숨긴 상태로 시작) - System.Windows.Application.Current.MainWindow.Visibility = Visibility.Hidden; - - Dispatcher.BeginInvoke((Action)(() => - { - _viewModel.Hide(); - System.Windows.Application.Current.MainWindow.Visibility = Visibility.Collapsed; - }), DispatcherPriority.Background); + //System.Windows.Application.Current.MainWindow.Visibility = Visibility.Hidden; + + //Dispatcher.BeginInvoke((Action)(() => + //{ + // _viewModel.Hide(); + // System.Windows.Application.Current.MainWindow.Visibility = Visibility.Collapsed; + //}), DispatcherPriority.Background); + _viewModel.Hide(); } else { // 📌 최초 실행 시 그림자 효과를 미리 적용하여 Show() 할 때 렌더링이 느려지지 않도록 함 - ThemeManager.Instance.SetBlurForWindow(); + //ThemeManager.Instance.SetBlurForWindow(); //ThemeManager.Instance.AutoDropShadow(); _viewModel.Show(); } diff --git a/Flow.Launcher/Themes/Pink.xaml b/Flow.Launcher/Themes/Pink.xaml index 3d8792a080a..90592bb99ff 100644 --- a/Flow.Launcher/Themes/Pink.xaml +++ b/Flow.Launcher/Themes/Pink.xaml @@ -8,7 +8,7 @@ True Light RoundSmall - #4BFEC7D7 + #B6C8C7FE #53FEC7D7 0 0 0 0 + From aeb3f22f7d56417d70f4936d9e207ff597009762 Mon Sep 17 00:00:00 2001 From: DB p Date: Sat, 15 Mar 2025 15:02:07 +0900 Subject: [PATCH 057/106] - rollback pin theme to legacy --- Flow.Launcher/Themes/Pink.xaml | 75 +++++++++++++++------------------- 1 file changed, 32 insertions(+), 43 deletions(-) diff --git a/Flow.Launcher/Themes/Pink.xaml b/Flow.Launcher/Themes/Pink.xaml index 90592bb99ff..d7de4e2467d 100644 --- a/Flow.Launcher/Themes/Pink.xaml +++ b/Flow.Launcher/Themes/Pink.xaml @@ -1,55 +1,46 @@ - + - True - Light - RoundSmall - #B6C8C7FE - #53FEC7D7 - 0 0 0 0 + 0 0 0 4 - #0e172c + #cc1081 \ No newline at end of file From 53d647f2d06bd31233cac3308969c8cce414da67 Mon Sep 17 00:00:00 2001 From: DB p Date: Sun, 16 Mar 2025 10:15:38 +0900 Subject: [PATCH 058/106] Adjust Themes for fluent --- Flow.Launcher/Resources/Dark.xaml | 16 ++++++++-------- Flow.Launcher/Resources/Light.xaml | 14 +++++++------- Flow.Launcher/Themes/BlurBlack Darker.xaml | 4 ++-- Flow.Launcher/Themes/BlurBlack.xaml | 4 ++-- Flow.Launcher/Themes/BlurWhite.xaml | 20 ++++++++++++++------ Flow.Launcher/Themes/Circle System.xaml | 9 +++++---- Flow.Launcher/Themes/Darker.xaml | 6 ++++-- Flow.Launcher/Themes/Win10System.xaml | 4 ++-- 8 files changed, 44 insertions(+), 33 deletions(-) diff --git a/Flow.Launcher/Resources/Dark.xaml b/Flow.Launcher/Resources/Dark.xaml index ed031c939e0..25cc8e878e3 100644 --- a/Flow.Launcher/Resources/Dark.xaml +++ b/Flow.Launcher/Resources/Dark.xaml @@ -7,17 +7,17 @@ xmlns:sys="clr-namespace:System;assembly=mscorlib"> - + - - - - + + + + - - - + + + #198F8F8F diff --git a/Flow.Launcher/Resources/Light.xaml b/Flow.Launcher/Resources/Light.xaml index 8fe84588f5e..b9f65ce9650 100644 --- a/Flow.Launcher/Resources/Light.xaml +++ b/Flow.Launcher/Resources/Light.xaml @@ -7,18 +7,18 @@ xmlns:sys="clr-namespace:System;assembly=mscorlib"> - + - - + + - - - - #198F8F8F + + + + #0C000000 diff --git a/Flow.Launcher/Themes/BlurBlack Darker.xaml b/Flow.Launcher/Themes/BlurBlack Darker.xaml index 99cd9af0e4f..4cd8408fab2 100644 --- a/Flow.Launcher/Themes/BlurBlack Darker.xaml +++ b/Flow.Launcher/Themes/BlurBlack Darker.xaml @@ -143,8 +143,8 @@ BasedOn="{StaticResource BaseSearchIconStyle}" TargetType="{x:Type Path}"> - - + + + @@ -79,7 +87,7 @@ x:Key="ItemSubTitleStyle" BasedOn="{StaticResource BaseItemSubTitleStyle}" TargetType="{x:Type TextBlock}"> - + + Opacity="0.6" + Color="#33000000" /> @@ -79,7 +80,7 @@ x:Key="SeparatorStyle" BasedOn="{StaticResource BaseSeparatorStyle}" TargetType="{x:Type Rectangle}"> - + diff --git a/Flow.Launcher/Themes/Darker.xaml b/Flow.Launcher/Themes/Darker.xaml index d1abbe9789f..7d2614be897 100644 --- a/Flow.Launcher/Themes/Darker.xaml +++ b/Flow.Launcher/Themes/Darker.xaml @@ -29,7 +29,9 @@ @@ -123,7 +125,7 @@ Date: Sun, 16 Mar 2025 12:04:11 +0900 Subject: [PATCH 061/106] - Fix Logic for dwmBG - Remove Cornertypes in themes --- Flow.Launcher.Core/Resource/Theme.cs | 19 ++++++++++++++----- .../ViewModels/SettingsPaneThemeViewModel.cs | 4 +--- Flow.Launcher/Themes/BlurBlack Darker.xaml | 1 - Flow.Launcher/Themes/BlurBlack.xaml | 1 - Flow.Launcher/Themes/BlurWhite.xaml | 1 - Flow.Launcher/Themes/Circle System.xaml | 1 - 6 files changed, 15 insertions(+), 12 deletions(-) diff --git a/Flow.Launcher.Core/Resource/Theme.cs b/Flow.Launcher.Core/Resource/Theme.cs index 0dd1d5bbb9b..1ae755bd1ba 100644 --- a/Flow.Launcher.Core/Resource/Theme.cs +++ b/Flow.Launcher.Core/Resource/Theme.cs @@ -396,19 +396,26 @@ public void ColorizeWindow(string Mode) // Final decision on whether to use dark mode bool useDarkMode = false; - if (colorScheme == "Dark" || systemBG == "Dark") + // If systemBG is not "Auto", prioritize it over ColorScheme and set the mode based on systemBG value + if (systemBG == "Dark") { useDarkMode = true; // Dark } - else if (colorScheme == "Light" || systemBG == "Light") + else if (systemBG == "Light") { useDarkMode = false; // Light } - else if (colorScheme == "System" || systemBG == "Auto") + else if (systemBG == "Auto") { - useDarkMode = isSystemDark; // Auto + // If systemBG is "Auto", decide based on ColorScheme + if (colorScheme == "Dark") + useDarkMode = true; + else if (colorScheme == "Light") + useDarkMode = false; + else + useDarkMode = isSystemDark; // Auto (based on system setting) } - + // Apply DWM Dark Mode Methods.SetWindowAttribute(new WindowInteropHelper(mainWindow).Handle, DWMWINDOWATTRIBUTE.DWMWA_USE_IMMERSIVE_DARK_MODE, useDarkMode ? 1 : 0); @@ -458,6 +465,8 @@ public void ColorizeWindow(string Mode) }, DispatcherPriority.Normal); } + + public bool IsBlurTheme() { if (Environment.OSVersion.Version >= new Version(6, 2)) diff --git a/Flow.Launcher/SettingPages/ViewModels/SettingsPaneThemeViewModel.cs b/Flow.Launcher/SettingPages/ViewModels/SettingsPaneThemeViewModel.cs index dc9beec1cdf..87f5ed9229a 100644 --- a/Flow.Launcher/SettingPages/ViewModels/SettingsPaneThemeViewModel.cs +++ b/Flow.Launcher/SettingPages/ViewModels/SettingsPaneThemeViewModel.cs @@ -134,10 +134,8 @@ public string ColorScheme Constant.System => null, _ => ThemeManagerForColorSchemeSwitch.Current.ApplicationTheme }; - - ThemeManager.Instance.RefreshFrame(); - Settings.ColorScheme = value; + ThemeManager.Instance.RefreshFrame(); } } diff --git a/Flow.Launcher/Themes/BlurBlack Darker.xaml b/Flow.Launcher/Themes/BlurBlack Darker.xaml index 4cd8408fab2..9f7e6f5b0bb 100644 --- a/Flow.Launcher/Themes/BlurBlack Darker.xaml +++ b/Flow.Launcher/Themes/BlurBlack Darker.xaml @@ -13,7 +13,6 @@ True Dark - DoNotRound #C7000000 #C7000000 diff --git a/Flow.Launcher/Themes/BlurBlack.xaml b/Flow.Launcher/Themes/BlurBlack.xaml index 0e2f0e245ea..c45827074e1 100644 --- a/Flow.Launcher/Themes/BlurBlack.xaml +++ b/Flow.Launcher/Themes/BlurBlack.xaml @@ -12,7 +12,6 @@ True Dark - DoNotRound #B0000000 #B6000000 diff --git a/Flow.Launcher/Themes/BlurWhite.xaml b/Flow.Launcher/Themes/BlurWhite.xaml index e5f310c5a84..8bf1f06e2ac 100644 --- a/Flow.Launcher/Themes/BlurWhite.xaml +++ b/Flow.Launcher/Themes/BlurWhite.xaml @@ -12,7 +12,6 @@ True Light - DoNotRound #BFFAFAFA #BFFAFAFA