11using System ;
22using System . ComponentModel ;
3- using System . Diagnostics ;
43using System . Linq ;
54using System . Media ;
65using System . Threading . Tasks ;
@@ -76,7 +75,7 @@ public MainWindow()
7675 DataContext = _viewModel ;
7776
7877 InitializeComponent ( ) ;
79- UpdatePosition ( true ) ;
78+ UpdatePosition ( ) ;
8079
8180 InitSoundEffects ( ) ;
8281 DataObject . AddPastingHandler ( QueryTextBox , QueryTextBox_OnPaste ) ;
@@ -112,7 +111,7 @@ private async void OnLoaded(object sender, RoutedEventArgs _)
112111 }
113112
114113 // Hide window if need
115- UpdatePosition ( true ) ;
114+ UpdatePosition ( ) ;
116115 if ( _settings . HideOnStartup )
117116 {
118117 _viewModel . Hide ( ) ;
@@ -139,7 +138,7 @@ private async void OnLoaded(object sender, RoutedEventArgs _)
139138 InitProgressbarAnimation ( ) ;
140139
141140 // Force update position
142- UpdatePosition ( true ) ;
141+ UpdatePosition ( ) ;
143142
144143 // Refresh frame
145144 await Ioc . Default . GetRequiredService < Theme > ( ) . RefreshFrameAsync ( ) ;
@@ -167,7 +166,7 @@ private async void OnLoaded(object sender, RoutedEventArgs _)
167166 SoundPlay ( ) ;
168167 }
169168
170- UpdatePosition ( false ) ;
169+ UpdatePosition ( ) ;
171170 _viewModel . ResetPreview ( ) ;
172171 Activate ( ) ;
173172 QueryTextBox . Focus ( ) ;
@@ -269,7 +268,6 @@ private void OnClosed(object sender, EventArgs e)
269268
270269 private void OnLocationChanged ( object sender , EventArgs e )
271270 {
272-
273271 if ( _settings . SearchWindowScreen == SearchWindowScreens . RememberLastLaunchLocation )
274272 {
275273 _settings . WindowLeft = Left ;
@@ -281,17 +279,18 @@ private async void OnDeactivated(object sender, EventArgs e)
281279 {
282280 _settings . WindowLeft = Left ;
283281 _settings . WindowTop = Top ;
282+
284283 ClockPanel . Opacity = 0 ;
285284 SearchIcon . Opacity = 0 ;
286- //This condition stops extra hide call when animator is on,
285+
286+ // This condition stops extra hide call when animator is on,
287287 // which causes the toggling to occasional hide instead of show.
288288 if ( _viewModel . MainWindowVisibilityStatus )
289289 {
290290 // Need time to initialize the main query window animation.
291291 // This also stops the mainwindow from flickering occasionally after Settings window is opened
292292 // and always after Settings window is closed.
293293 if ( _settings . UseAnimation )
294-
295294 await Task . Delay ( 100 ) ;
296295
297296 if ( _settings . HideWhenDeactivated && ! _viewModel . ExternalPreviewVisible )
@@ -589,13 +588,8 @@ private void UpdateNotifyIconText()
589588
590589 #region Window Position
591590
592- private void UpdatePosition ( bool force )
591+ private void UpdatePosition ( )
593592 {
594- if ( ! force )
595- {
596- return ;
597- }
598-
599593 // Initialize call twice to work around multi-display alignment issue- https://github.com/Flow-Launcher/Flow.Launcher/issues/2910
600594 InitializePosition ( ) ;
601595 InitializePosition ( ) ;
@@ -770,20 +764,16 @@ private void InitProgressbarAnimation()
770764 public void WindowAnimation ( )
771765 {
772766 _isArrowKeyPressed = true ;
773- UpdatePosition ( false ) ;
774- if ( _settings . UseAnimation )
775- {
776- ClockPanel . Opacity = 0 ;
777- SearchIcon . Opacity = 0 ;
778- }
779- else
780- {
781- ClockPanel . Opacity = 1 ;
782- SearchIcon . Opacity = 1 ;
783- }
767+
768+ UpdatePosition ( ) ;
769+
770+ var opacity = _settings . UseAnimation ? 0.0 : 1.0 ;
771+ ClockPanel . Opacity = opacity ;
772+ SearchIcon . Opacity = opacity ;
773+
784774 var clocksb = new Storyboard ( ) ;
785775 var iconsb = new Storyboard ( ) ;
786- CircleEase easing = new CircleEase { EasingMode = EasingMode . EaseInOut } ;
776+ var easing = new CircleEase { EasingMode = EasingMode . EaseInOut } ;
787777
788778 var animationLength = _settings . AnimationSpeed switch
789779 {
@@ -811,7 +801,7 @@ public void WindowAnimation()
811801 FillBehavior = FillBehavior . HoldEnd
812802 } ;
813803
814- double TargetIconOpacity = GetOpacityFromStyle ( SearchIcon . Style , 1.0 ) ;
804+ var TargetIconOpacity = GetOpacityFromStyle ( SearchIcon . Style , 1.0 ) ;
815805
816806 var IconOpacity = new DoubleAnimation
817807 {
@@ -822,7 +812,7 @@ public void WindowAnimation()
822812 FillBehavior = FillBehavior . HoldEnd
823813 } ;
824814
825- double rightMargin = GetThicknessFromStyle ( ClockPanel . Style , new Thickness ( 0 , 0 , DefaultRightMargin , 0 ) ) . Right ;
815+ var rightMargin = GetThicknessFromStyle ( ClockPanel . Style , new Thickness ( 0 , 0 , DefaultRightMargin , 0 ) ) . Right ;
826816
827817 var thicknessAnimation = new ThicknessAnimation
828818 {
0 commit comments