Skip to content

Commit f5cfc76

Browse files
committed
- Add Custom Show
- Changed SoundPlay location
1 parent 84f064e commit f5cfc76

File tree

2 files changed

+31
-12
lines changed

2 files changed

+31
-12
lines changed

Flow.Launcher/MainWindow.xaml.cs

+4-12
Original file line numberDiff line numberDiff line change
@@ -175,11 +175,6 @@ private async void OnLoaded(object sender, RoutedEventArgs _)
175175
{
176176
if (_viewModel.MainWindowVisibilityStatus)
177177
{
178-
if (_settings.UseSound)
179-
{
180-
SoundPlay();
181-
}
182-
183178
UpdatePosition(false);
184179
_viewModel.ResetPreview();
185180
Activate();
@@ -269,7 +264,6 @@ private async void OnClosing(object sender, CancelEventArgs e)
269264
Environment.Exit(0);
270265
}
271266

272-
// Win32 API 함수 정의
273267
[DllImport("wtsapi32.dll", SetLastError = true)]
274268
private static extern bool WTSRegisterSessionNotification(IntPtr hWnd, int dwFlags);
275269

@@ -469,26 +463,24 @@ private IntPtr WndProc(IntPtr hwnd, int msg, IntPtr wParam, IntPtr lParam, ref b
469463

470464
handled = true;
471465
}
472-
// Windows 잠금(Win+L) 이벤트 처리
466+
// Windows (Win+L) Event
473467
else if (msg == WM_WTSSESSION_CHANGE)
474468
{
475469
int reason = wParam.ToInt32();
476470
if (reason == WTS_SESSION_LOCK)
477471
{
478-
// Windows 잠금 발생 시 메시지 박스 표시
479472
Application.Current.Dispatcher.Invoke(() =>
480473
{
481-
_viewModel.Show();
474+
_viewModel.SystemWakeUpShow();
482475
});
483476

484477
handled = true;
485478
}
486479
else if (reason == WTS_SESSION_UNLOCK)
487480
{
488-
// Windows 잠금 해제 시 메시지 박스 표시 (선택적)
489481
Application.Current.Dispatcher.Invoke(() =>
490482
{
491-
_viewModel.Show();
483+
_viewModel.SystemWakeUpShow();
492484
});
493485

494486
handled = true;
@@ -515,7 +507,7 @@ private void InitSoundEffects()
515507
}
516508
}
517509

518-
private void SoundPlay()
510+
public void SoundPlay()
519511
{
520512
if (_settings.WMPInstalled)
521513
{

Flow.Launcher/ViewModel/MainViewModel.cs

+27
Original file line numberDiff line numberDiff line change
@@ -1352,12 +1352,39 @@ public void ToggleFlowLauncher()
13521352
}
13531353
}
13541354

1355+
public void SystemWakeUpShow()
1356+
{
1357+
Application.Current.Dispatcher.Invoke(() =>
1358+
{
1359+
if (Application.Current.MainWindow is MainWindow mainWindow)
1360+
{
1361+
// 📌 Remove DWM Cloak (Make the window visible normally)
1362+
Win32Helper.DWMSetCloakForWindow(mainWindow, false);
1363+
1364+
// 📌 Restore UI elements
1365+
mainWindow.ClockPanel.Visibility = Visibility.Visible;
1366+
//mainWindow.SearchIcon.Visibility = Visibility.Visible;
1367+
SearchIconVisibility = Visibility.Visible;
1368+
}
1369+
1370+
// Update WPF properties
1371+
MainWindowOpacity = 0.01;
1372+
MainWindowVisibility = Visibility.Visible;
1373+
MainWindowVisibilityStatus = true;
1374+
VisibilityChanged?.Invoke(this, new VisibilityChangedEventArgs { IsVisible = true });
1375+
Hide();
1376+
});
1377+
}
13551378
public void Show()
13561379
{
13571380
Application.Current.Dispatcher.Invoke(() =>
13581381
{
13591382
if (Application.Current.MainWindow is MainWindow mainWindow)
13601383
{
1384+
if (Settings.UseSound)
1385+
{
1386+
mainWindow.SoundPlay();
1387+
}
13611388
// 📌 Remove DWM Cloak (Make the window visible normally)
13621389
Win32Helper.DWMSetCloakForWindow(mainWindow, false);
13631390

0 commit comments

Comments
 (0)