Skip to content

Commit 1ca17aa

Browse files
committed
Code cleanup
1 parent 8b10973 commit 1ca17aa

File tree

3 files changed

+21
-22
lines changed

3 files changed

+21
-22
lines changed

Flow.Launcher.Infrastructure/Win32Helper.cs

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,21 @@ public static bool IsBackdropSupported()
1616
{
1717
// Windows 11 (22000) 이상에서만 Mica 및 Acrylic 효과 지원
1818
return RuntimeInformation.IsOSPlatform(OSPlatform.Windows) &&
19-
Environment.OSVersion.Version.Build >= 22000;
19+
Environment.OSVersion.Version.Build >= 22000;
20+
}
21+
22+
public static unsafe bool DWMSetCloakForWindow(Window window, bool cloak)
23+
{
24+
var windowHelper = new WindowInteropHelper(window);
25+
windowHelper.EnsureHandle();
26+
27+
var cloaked = cloak ? 1 : 0;
28+
29+
return PInvoke.DwmSetWindowAttribute(
30+
new(windowHelper.Handle),
31+
DWMWINDOWATTRIBUTE.DWMWA_CLOAK,
32+
&cloaked,
33+
(uint)Marshal.SizeOf<int>()).Succeeded;
2034
}
2135

2236
public static unsafe bool DWMSetBackdropForWindow(Window window, BackdropTypes backdrop)

Flow.Launcher/MainWindow.xaml.cs

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -186,12 +186,11 @@ private async void OnLoaded(object sender, RoutedEventArgs _)
186186
InitializeColorScheme();
187187
WindowsInteropHelper.DisableControlBox(this);
188188
InitProgressbarAnimation();
189-
// Move the window out of screen because setting backdrop will cause flicker with a rectangle
190-
Left = Top = -10000;
191-
await ThemeManager.Instance.RefreshFrameAsync();
192189
// Initialize call twice to work around multi-display alignment issue- https://github.com/Flow-Launcher/Flow.Launcher/issues/2910
193190
InitializePosition();
194191
InitializePosition();
192+
// Refresh frame
193+
await ThemeManager.Instance.RefreshFrameAsync();
195194
PreviewReset();
196195
// Since the default main window visibility is visible, so we need set focus during startup
197196
QueryTextBox.Focus();
@@ -825,26 +824,13 @@ private void OnLocationChanged(object sender, EventArgs e)
825824

826825
public void HideStartup()
827826
{
828-
//_viewModel.MainWindowOpacity = 0.2; /*Fix Render Blinking */
829827
if (_settings.HideOnStartup)
830828
{
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);
839829
_viewModel.Hide();
840830
}
841831
else
842832
{
843-
// 📌 최초 실행 시 그림자 효과를 미리 적용하여 Show() 할 때 렌더링이 느려지지 않도록 함
844-
//ThemeManager.Instance.SetBlurForWindow();
845-
//ThemeManager.Instance.AutoDropShadow();
846833
_viewModel.Show();
847-
//_viewModel.MainWindowOpacity = 1;
848834
}
849835
}
850836

Flow.Launcher/ViewModel/MainViewModel.cs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1386,10 +1386,8 @@ public void Show()
13861386
{
13871387
if (Application.Current.MainWindow is MainWindow mainWindow)
13881388
{
1389-
IntPtr hWnd = new WindowInteropHelper(mainWindow).Handle;
1390-
1391-
// 📌 창을 보이도록 설정 (Cloak 사용 안 함)
1392-
//ShowWindow(hWnd, SW_SHOW);
1389+
// 📌 DWM Cloak 해제 (창을 정상적으로 표시)
1390+
Win32Helper.DWMSetCloakForWindow(mainWindow, false);
13931391

13941392
// 📌 UI 요소 복원
13951393
mainWindow.ClockPanel.Visibility = Visibility.Visible;
@@ -1433,7 +1431,8 @@ public async void Hide()
14331431
mainWindow.SearchIcon.UpdateLayout();
14341432
}, DispatcherPriority.Render);
14351433

1436-
//await Task.Delay(10); // UI 반영 대기
1434+
// 📌 DWM Cloak 적용 (창을 완전히 숨김)
1435+
Win32Helper.DWMSetCloakForWindow(mainWindow, true);
14371436
}
14381437

14391438
// 📌 텍스트 초기화 즉시 적용 + UI 강제 업데이트

0 commit comments

Comments
 (0)