Skip to content

Commit e3a1489

Browse files
authored
Merge pull request #3388 from onesounds/050326-FixClockAndIconDisplay
Fix Clock/Search Icon show logic
2 parents 7c009d4 + 89c3cb1 commit e3a1489

File tree

5 files changed

+102
-81
lines changed

5 files changed

+102
-81
lines changed

Flow.Launcher/MainWindow.xaml.cs

+21-35
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,6 @@ public partial class MainWindow : IDisposable
5858

5959
// Window Animation
6060
private const double DefaultRightMargin = 66; //* this value from base.xaml
61-
private bool _animating;
6261
private bool _isClockPanelAnimating = false;
6362

6463
// IDisposable
@@ -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();
@@ -234,7 +233,7 @@ private async void OnLoaded(object sender, RoutedEventArgs _)
234233

235234
// Detect History.Visibility changes
236235
DependencyPropertyDescriptor
237-
.FromProperty(VisibilityProperty, typeof(StackPanel)) // History는 StackPanel이라고 가정
236+
.FromProperty(VisibilityProperty, typeof(StackPanel))
238237
.AddValueChanged(History, (s, e) => UpdateClockPanelVisibility());
239238
}
240239

@@ -269,8 +268,6 @@ private void OnClosed(object sender, EventArgs e)
269268

270269
private void OnLocationChanged(object sender, EventArgs e)
271270
{
272-
if (_animating) return;
273-
274271
if (_settings.SearchWindowScreen == SearchWindowScreens.RememberLastLaunchLocation)
275272
{
276273
_settings.WindowLeft = Left;
@@ -282,17 +279,18 @@ private async void OnDeactivated(object sender, EventArgs e)
282279
{
283280
_settings.WindowLeft = Left;
284281
_settings.WindowTop = Top;
282+
285283
ClockPanel.Opacity = 0;
286284
SearchIcon.Opacity = 0;
287-
//This condition stops extra hide call when animator is on,
285+
286+
// This condition stops extra hide call when animator is on,
288287
// which causes the toggling to occasional hide instead of show.
289288
if (_viewModel.MainWindowVisibilityStatus)
290289
{
291290
// Need time to initialize the main query window animation.
292291
// This also stops the mainwindow from flickering occasionally after Settings window is opened
293292
// and always after Settings window is closed.
294293
if (_settings.UseAnimation)
295-
296294
await Task.Delay(100);
297295

298296
if (_settings.HideWhenDeactivated && !_viewModel.ExternalPreviewVisible)
@@ -590,13 +588,8 @@ private void UpdateNotifyIconText()
590588

591589
#region Window Position
592590

593-
private void UpdatePosition(bool force)
591+
private void UpdatePosition()
594592
{
595-
if (_animating && !force)
596-
{
597-
return;
598-
}
599-
600593
// Initialize call twice to work around multi-display alignment issue- https://github.com/Flow-Launcher/Flow.Launcher/issues/2910
601594
InitializePosition();
602595
InitializePosition();
@@ -770,19 +763,17 @@ private void InitProgressbarAnimation()
770763

771764
private void WindowAnimation()
772765
{
773-
if (_animating)
774-
return;
775-
776766
_isArrowKeyPressed = true;
777-
_animating = true;
778-
UpdatePosition(false);
779767

780-
ClockPanel.Opacity = 0;
781-
SearchIcon.Opacity = 0;
782-
768+
UpdatePosition();
769+
770+
var opacity = _settings.UseAnimation ? 0.0 : 1.0;
771+
ClockPanel.Opacity = opacity;
772+
SearchIcon.Opacity = opacity;
773+
783774
var clocksb = new Storyboard();
784775
var iconsb = new Storyboard();
785-
CircleEase easing = new CircleEase { EasingMode = EasingMode.EaseInOut };
776+
var easing = new CircleEase { EasingMode = EasingMode.EaseInOut };
786777

787778
var animationLength = _settings.AnimationSpeed switch
788779
{
@@ -810,7 +801,7 @@ private void WindowAnimation()
810801
FillBehavior = FillBehavior.HoldEnd
811802
};
812803

813-
double TargetIconOpacity = GetOpacityFromStyle(SearchIcon.Style, 1.0);
804+
var TargetIconOpacity = GetOpacityFromStyle(SearchIcon.Style, 1.0);
814805

815806
var IconOpacity = new DoubleAnimation
816807
{
@@ -821,7 +812,7 @@ private void WindowAnimation()
821812
FillBehavior = FillBehavior.HoldEnd
822813
};
823814

824-
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;
825816

826817
var thicknessAnimation = new ThicknessAnimation
827818
{
@@ -848,16 +839,11 @@ private void WindowAnimation()
848839
clocksb.Children.Add(ClockOpacity);
849840
iconsb.Children.Add(IconMotion);
850841
iconsb.Children.Add(IconOpacity);
851-
852-
clocksb.Completed += (_, _) => _animating = false;
842+
853843
_settings.WindowLeft = Left;
854844
_isArrowKeyPressed = false;
855-
856-
if (QueryTextBox.Text.Length == 0)
857-
{
858-
clocksb.Begin(ClockPanel);
859-
}
860-
845+
846+
clocksb.Begin(ClockPanel);
861847
iconsb.Begin(SearchIcon);
862848
}
863849

Flow.Launcher/Resources/Dark.xaml

+2
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,8 @@
115115
<SolidColorBrush x:Key="InfoBarWarningIcon" Color="#FCE100" />
116116
<SolidColorBrush x:Key="InfoBarWarningBG" Color="#433519" />
117117
<SolidColorBrush x:Key="InfoBarBD" Color="#19000000" />
118+
119+
<SolidColorBrush x:Key="MouseOverWindowCloseButtonForegroundBrush" Color="#ffffff" />
118120

119121
<SolidColorBrush x:Key="ButtonOutBorder" Color="Transparent" />
120122
<SolidColorBrush x:Key="ButtonInsideBorder" Color="#3f3f3f" />

Flow.Launcher/Resources/Light.xaml

+1
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@
107107
<SolidColorBrush x:Key="InfoBarWarningBG" Color="#FFF4CE" />
108108
<SolidColorBrush x:Key="InfoBarBD" Color="#0F000000" />
109109

110+
<SolidColorBrush x:Key="MouseOverWindowCloseButtonForegroundBrush" Color="#ffffff" />
110111

111112
<SolidColorBrush x:Key="ButtonOutBorder" Color="#e5e5e5" />
112113
<SolidColorBrush x:Key="ButtonInsideBorder" Color="#d3d3d3" />

Flow.Launcher/SettingWindow.xaml

+3
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818
Loaded="OnLoaded"
1919
MouseDown="window_MouseDown"
2020
ResizeMode="CanResize"
21+
SnapsToDevicePixels="True"
22+
UseLayoutRounding="True"
2123
StateChanged="Window_StateChanged"
2224
Top="{Binding SettingWindowTop, Mode=TwoWay}"
2325
WindowStartupLocation="Manual"
@@ -54,6 +56,7 @@
5456
Width="16"
5557
Height="16"
5658
Margin="10 4 4 4"
59+
RenderOptions.BitmapScalingMode="HighQuality"
5760
Source="/Images/app.png" />
5861
<TextBlock
5962
Grid.Row="0"

0 commit comments

Comments
 (0)