1010using System . Windows ;
1111using System . Windows . Input ;
1212using System . Windows . Media ;
13- using System . Windows . Threading ;
1413using CommunityToolkit . Mvvm . DependencyInjection ;
1514using CommunityToolkit . Mvvm . Input ;
1615using Flow . Launcher . Core . Plugin ;
@@ -645,22 +644,22 @@ private async Task ChangeQueryTextAsync(string queryText, bool isReQuery = false
645644 return ;
646645 }
647646
648- BackToQueryResults ( ) ;
647+ BackToQueryResults ( ) ;
649648
650- if ( QueryText != queryText )
651- {
652- // re-query is done in QueryText's setter method
653- QueryText = queryText ;
654- // set to false so the subsequent set true triggers
655- // PropertyChanged and MoveQueryTextToEnd is called
656- QueryTextCursorMovedToEnd = false ;
657- }
658- else if ( isReQuery )
659- {
660- await QueryAsync ( isReQuery : true ) ;
661- }
649+ if ( QueryText != queryText )
650+ {
651+ // re-query is done in QueryText's setter method
652+ QueryText = queryText ;
653+ // set to false so the subsequent set true triggers
654+ // PropertyChanged and MoveQueryTextToEnd is called
655+ QueryTextCursorMovedToEnd = false ;
656+ }
657+ else if ( isReQuery )
658+ {
659+ await QueryAsync ( isReQuery : true ) ;
660+ }
662661
663- QueryTextCursorMovedToEnd = true ;
662+ QueryTextCursorMovedToEnd = true ;
664663 }
665664
666665 public bool LastQuerySelected { get ; set ; }
@@ -1448,43 +1447,10 @@ public bool ShouldIgnoreHotkeys()
14481447
14491448#pragma warning disable VSTHRD100 // Avoid async void methods
14501449
1451- public async void Show ( )
1450+ public void Show ( )
14521451 {
1453- await Application . Current . Dispatcher . InvokeAsync ( ( ) =>
1454- {
1455- if ( Application . Current . MainWindow is MainWindow mainWindow )
1456- {
1457- // 📌 Remove DWM Cloak (Make the window visible normally)
1458- Win32Helper . DWMSetCloakForWindow ( mainWindow , false ) ;
1459-
1460- // Clock and SearchIcon hide when show situation
1461- var opacity = Settings . UseAnimation ? 0.0 : 1.0 ;
1462- mainWindow . ClockPanel . Opacity = opacity ;
1463- mainWindow . SearchIcon . Opacity = opacity ;
1464-
1465- // QueryText sometimes is null when it is just initialized
1466- if ( QueryText != null && QueryText . Length != 0 )
1467- {
1468- mainWindow . ClockPanel . Visibility = Visibility . Collapsed ;
1469- }
1470- else
1471- {
1472- mainWindow . ClockPanel . Visibility = Visibility . Visible ;
1473- }
1474-
1475- if ( PluginIconSource != null )
1476- {
1477- mainWindow . SearchIcon . Opacity = 0 ;
1478- }
1479- else
1480- {
1481- SearchIconVisibility = Visibility . Visible ;
1482- }
1483-
1484- // 📌 Restore UI elements
1485- //mainWindow.SearchIcon.Visibility = Visibility.Visible;
1486- }
1487- } , DispatcherPriority . Render ) ;
1452+ // 📌 Remove DWM Cloak (Make the window visible normally)
1453+ Win32Helper . DWMSetCloakForWindow ( Application . Current . MainWindow , false ) ;
14881454
14891455 // Update WPF properties
14901456 MainWindowVisibility = Visibility . Visible ;
@@ -1500,6 +1466,9 @@ await Application.Current.Dispatcher.InvokeAsync(() =>
15001466
15011467 public async void Hide ( )
15021468 {
1469+ // 📌 Apply DWM Cloak (Completely hide the window)
1470+ Win32Helper . DWMSetCloakForWindow ( Application . Current . MainWindow , true ) ;
1471+
15031472 lastHistoryIndex = 1 ;
15041473
15051474 if ( ExternalPreviewVisible )
@@ -1534,26 +1503,6 @@ public async void Hide()
15341503 break ;
15351504 }
15361505
1537- await Application . Current . Dispatcher . InvokeAsync ( ( ) =>
1538- {
1539- if ( Application . Current . MainWindow is MainWindow mainWindow )
1540- {
1541- // 📌 Set Opacity of icon and clock to 0 and apply Visibility.Hidden
1542- var opacity = Settings . UseAnimation ? 0.0 : 1.0 ;
1543- mainWindow . ClockPanel . Opacity = opacity ;
1544- mainWindow . SearchIcon . Opacity = opacity ;
1545- mainWindow . ClockPanel . Visibility = Visibility . Hidden ;
1546- SearchIconVisibility = Visibility . Hidden ;
1547-
1548- // Force UI update
1549- mainWindow . ClockPanel . UpdateLayout ( ) ;
1550- mainWindow . SearchIcon . UpdateLayout ( ) ;
1551-
1552- // 📌 Apply DWM Cloak (Completely hide the window)
1553- Win32Helper . DWMSetCloakForWindow ( mainWindow , true ) ;
1554- }
1555- } ) ;
1556-
15571506 if ( StartWithEnglishMode )
15581507 {
15591508 Win32Helper . RestorePreviousKeyboardLayout ( ) ;
0 commit comments