Skip to content

Commit 8b10973

Browse files
committed
Revert "Fix Blink"
This reverts commit 70e7f82.
1 parent 09d66f5 commit 8b10973

File tree

2 files changed

+28
-46
lines changed

2 files changed

+28
-46
lines changed

Flow.Launcher/MainWindow.xaml.cs

Lines changed: 14 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,6 @@
3030
using Window = System.Windows.Window;
3131
using System.Linq;
3232
using System.Windows.Shapes;
33-
using ModernWpf.Controls.Primitives;
34-
using System.Runtime.InteropServices;
3533

3634
namespace Flow.Launcher
3735
{
@@ -827,44 +825,29 @@ private void OnLocationChanged(object sender, EventArgs e)
827825

828826
public void HideStartup()
829827
{
830-
IntPtr hwnd = new WindowInteropHelper(System.Windows.Application.Current.MainWindow).Handle;
831-
828+
//_viewModel.MainWindowOpacity = 0.2; /*Fix Render Blinking */
832829
if (_settings.HideOnStartup)
833830
{
834-
CloakWindow(System.Windows.Application.Current.MainWindow);
835-
836-
Dispatcher.BeginInvoke((Action)(() =>
837-
{
838-
_viewModel.Hide();
839-
System.Windows.Application.Current.MainWindow.Visibility = Visibility.Collapsed;
840-
}), DispatcherPriority.Background);
831+
// 📌 최초 실행 시 창이 깜빡이는 문제 방지 (완전히 숨긴 상태로 시작)
832+
//System.Windows.Application.Current.MainWindow.Visibility = Visibility.Hidden;
833+
834+
//Dispatcher.BeginInvoke((Action)(() =>
835+
//{
836+
// _viewModel.Hide();
837+
// System.Windows.Application.Current.MainWindow.Visibility = Visibility.Collapsed;
838+
//}), DispatcherPriority.Background);
839+
_viewModel.Hide();
841840
}
842841
else
843842
{
844-
UncloakWindow(System.Windows.Application.Current.MainWindow);
843+
// 📌 최초 실행 시 그림자 효과를 미리 적용하여 Show() 할 때 렌더링이 느려지지 않도록 함
844+
//ThemeManager.Instance.SetBlurForWindow();
845+
//ThemeManager.Instance.AutoDropShadow();
845846
_viewModel.Show();
847+
//_viewModel.MainWindowOpacity = 1;
846848
}
847849
}
848850

849-
private const int DWMWA_CLOAK = 13;
850-
851-
[DllImport("dwmapi.dll")]
852-
private static extern int DwmSetWindowAttribute(IntPtr hwnd, int dwAttribute, ref int pvAttribute, int cbAttribute);
853-
854-
public static void CloakWindow(Window window)
855-
{
856-
IntPtr hwnd = new WindowInteropHelper(window).Handle;
857-
int cloak = 1;
858-
DwmSetWindowAttribute(hwnd, DWMWA_CLOAK, ref cloak, sizeof(int));
859-
}
860-
861-
public static void UncloakWindow(Window window)
862-
{
863-
IntPtr hwnd = new WindowInteropHelper(window).Handle;
864-
int cloak = 0;
865-
DwmSetWindowAttribute(hwnd, DWMWA_CLOAK, ref cloak, sizeof(int));
866-
}
867-
868851
public Screen SelectedScreen()
869852
{
870853
Screen screen;

Flow.Launcher/ViewModel/MainViewModel.cs

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@
2828
using CommunityToolkit.Mvvm.DependencyInjection;
2929
using System.Windows.Threading;
3030
using System.Windows.Interop;
31-
using System.Runtime.InteropServices;
3231

3332
namespace Flow.Launcher.ViewModel
3433
{
@@ -1389,13 +1388,12 @@ public void Show()
13891388
{
13901389
IntPtr hWnd = new WindowInteropHelper(mainWindow).Handle;
13911390

1392-
// 📌 DWM Cloak 해제 (창을 정상적으로 표시)
1393-
int cloak = 0;
1394-
DwmSetWindowAttribute(hWnd, 13, ref cloak, sizeof(int));
1391+
// 📌 창을 보이도록 설정 (Cloak 사용 안 함)
1392+
//ShowWindow(hWnd, SW_SHOW);
13951393

13961394
// 📌 UI 요소 복원
13971395
mainWindow.ClockPanel.Visibility = Visibility.Visible;
1398-
mainWindow.ClockPanel.Opacity = 1;
1396+
//mainWindow.SearchIcon.Visibility = Visibility.Visible;
13991397
SearchIconVisibility = Visibility.Visible;
14001398
}
14011399

@@ -1421,24 +1419,21 @@ public async void Hide()
14211419

14221420
if (Application.Current.MainWindow is MainWindow mainWindow)
14231421
{
1424-
IntPtr hWnd = new WindowInteropHelper(mainWindow).Handle;
1425-
1426-
// 📌 UI 요소 숨기기
1422+
// 📌 아이콘과 시계 Opacity를 0으로 설정하고 Visibility.Hidden 적용
14271423
Application.Current.Dispatcher.Invoke(() =>
14281424
{
14291425
mainWindow.ClockPanel.Opacity = 0;
14301426
mainWindow.SearchIcon.Opacity = 0;
14311427
mainWindow.ClockPanel.Visibility = Visibility.Hidden;
1428+
//mainWindow.SearchIcon.Visibility = Visibility.Hidden;
14321429
SearchIconVisibility = Visibility.Hidden;
14331430

14341431
// 강제 UI 업데이트
14351432
mainWindow.ClockPanel.UpdateLayout();
14361433
mainWindow.SearchIcon.UpdateLayout();
14371434
}, DispatcherPriority.Render);
14381435

1439-
// 📌 DWM Cloak 적용 (창을 완전히 숨김)
1440-
int cloak = 1;
1441-
DwmSetWindowAttribute(hWnd, 13, ref cloak, sizeof(int));
1436+
//await Task.Delay(10); // UI 반영 대기
14421437
}
14431438

14441439
// 📌 텍스트 초기화 즉시 적용 + UI 강제 업데이트
@@ -1471,16 +1466,20 @@ public async void Hide()
14711466
break;
14721467
}
14731468

1469+
//if (Application.Current.MainWindow is MainWindow mainWindow2)
1470+
//{
1471+
// IntPtr hWnd = new WindowInteropHelper(mainWindow2).Handle;
1472+
1473+
// // 📌 Cloak을 사용하지 않고 일반적인 `ShowWindow(SW_HIDE)` 사용 → Mica/Acrylic 유지됨
1474+
// ShowWindow(hWnd, SW_HIDE);
1475+
//}
1476+
14741477
// WPF 속성 업데이트
14751478
MainWindowVisibilityStatus = false;
14761479
MainWindowVisibility = Visibility.Collapsed;
14771480
VisibilityChanged?.Invoke(this, new VisibilityChangedEventArgs { IsVisible = false });
14781481
}
14791482

1480-
// 📌 DWM API 추가 (P/Invoke)
1481-
[DllImport("dwmapi.dll")]
1482-
private static extern int DwmSetWindowAttribute(IntPtr hwnd, int dwAttribute, ref int pvAttribute, int cbAttribute);
1483-
14841483
/// <summary>
14851484
/// Checks if Flow Launcher should ignore any hotkeys
14861485
/// </summary>

0 commit comments

Comments
 (0)