From 46cdb2a2731f3489ccf5f6978c94d9757cbe25b5 Mon Sep 17 00:00:00 2001 From: DB p Date: Sat, 8 Mar 2025 16:12:57 +0900 Subject: [PATCH] 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 edf1da05e..c4e56e813 100644 --- a/Flow.Launcher.Core/Resource/Theme.cs +++ b/Flow.Launcher.Core/Resource/Theme.cs @@ -140,6 +140,7 @@ namespace Flow.Launcher.Core.Resource if (mainWindowSrc == null) return; + ParameterTypes.MARGINS margins = new ParameterTypes.MARGINS(); margins.cxLeftWidth = -1; margins.cxRightWidth = -1; @@ -153,8 +154,7 @@ namespace Flow.Launcher.Core.Resource //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 @@ namespace Flow.Launcher.Core.Resource { AutoDropShadow(); } + } public void AutoDropShadow() @@ -248,6 +249,7 @@ namespace Flow.Launcher.Core.Resource 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 @@ namespace Flow.Launcher.Core.Resource //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 fc8a9f192..4757b1fb4 100644 --- a/Flow.Launcher/MainWindow.xaml.cs +++ b/Flow.Launcher/MainWindow.xaml.cs @@ -815,12 +815,23 @@ namespace Flow.Launcher 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 a8b04d640..3d8792a08 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 3249fd221..6b225ae06 100644 --- a/Flow.Launcher/ViewModel/MainViewModel.cs +++ b/Flow.Launcher/ViewModel/MainViewModel.cs @@ -1402,22 +1402,22 @@ namespace Flow.Launcher.ViewModel { 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 @@ namespace Flow.Launcher.ViewModel 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 @@ namespace Flow.Launcher.ViewModel mainWindow.SearchIcon.UpdateLayout(); }, DispatcherPriority.Render); - await Task.Delay(10); // UI 반영 λŒ€κΈ° + //await Task.Delay(10); // UI 반영 λŒ€κΈ° } // πŸ“Œ ν…μŠ€νŠΈ μ΄ˆκΈ°ν™” μ¦‰μ‹œ 적용 + UI κ°•μ œ μ—…λ°μ΄νŠΈ @@ -1478,23 +1478,22 @@ namespace Flow.Launcher.ViewModel 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 ///