From 57c4eb6d11327dd1a5dc1da3edbb01755bc129ee Mon Sep 17 00:00:00 2001 From: egotting Date: Fri, 29 May 2026 00:16:06 -0300 Subject: [PATCH 1/5] fix: avoid calculating WheelChange when actual height is zero --- Flow.Launcher.Test/Flow.Launcher.Test.csproj | 1 + Flow.Launcher.Test/MouseWheelTest.cs | 36 +++++++++++++++++++ .../Controls/CustomScrollViewerEx.cs | 18 +++++++--- 3 files changed, 50 insertions(+), 5 deletions(-) create mode 100644 Flow.Launcher.Test/MouseWheelTest.cs diff --git a/Flow.Launcher.Test/Flow.Launcher.Test.csproj b/Flow.Launcher.Test/Flow.Launcher.Test.csproj index 11ccff05b05..9ade234c79f 100644 --- a/Flow.Launcher.Test/Flow.Launcher.Test.csproj +++ b/Flow.Launcher.Test/Flow.Launcher.Test.csproj @@ -39,6 +39,7 @@ + diff --git a/Flow.Launcher.Test/MouseWheelTest.cs b/Flow.Launcher.Test/MouseWheelTest.cs new file mode 100644 index 00000000000..eb827293bb6 --- /dev/null +++ b/Flow.Launcher.Test/MouseWheelTest.cs @@ -0,0 +1,36 @@ +using System; +using System.Reflection; +using System.Windows; +using System.Windows.Input; +using System.Windows.Interop; +using Flow.Launcher.Resources.Controls; +using NUnit.Framework; + +namespace Flow.Launcher.Test; + +[TestFixture] +public class MouseWheelTest +{ + [Test] + [RequiresThread(System.Threading.ApartmentState.STA)] + public void Test_Scroll_MouseWheel() + { + var scrollView = new CustomScrollViewerEx(); + + var mouseDevice = Mouse.PrimaryDevice; + var e = new MouseWheelEventArgs(mouseDevice, Environment.TickCount, 120) + { + RoutedEvent = UIElement.MouseWheelEvent + }; + + var onMouseWheelMethod = typeof(CustomScrollViewerEx).GetMethod( + "OnMouseWheel", + BindingFlags.NonPublic | BindingFlags.Instance + ); + + Assert.DoesNotThrow(() => + { + onMouseWheelMethod.Invoke(scrollView, new object[] { e }); + }); + } +} diff --git a/Flow.Launcher/Resources/Controls/CustomScrollViewerEx.cs b/Flow.Launcher/Resources/Controls/CustomScrollViewerEx.cs index 78985108ce2..b729d7c6fdf 100644 --- a/Flow.Launcher/Resources/Controls/CustomScrollViewerEx.cs +++ b/Flow.Launcher/Resources/Controls/CustomScrollViewerEx.cs @@ -17,7 +17,8 @@ public class CustomScrollViewerEx : ScrollViewer public CustomScrollViewerEx() { Loaded += OnLoaded; - var valueSource = DependencyPropertyHelper.GetValueSource(this, AutoPanningMode.IsEnabledProperty).BaseValueSource; + var valueSource = DependencyPropertyHelper.GetValueSource(this, AutoPanningMode.IsEnabledProperty) + .BaseValueSource; if (valueSource == BaseValueSource.Default) { AutoPanningMode.SetIsEnabled(this, true); @@ -45,9 +46,9 @@ public Orientation Orientation public static readonly DependencyProperty AutoHideScrollBarsProperty = ScrollViewerHelper.AutoHideScrollBarsProperty - .AddOwner( - typeof(CustomScrollViewerEx), - new PropertyMetadata(true, OnAutoHideScrollBarsChanged)); + .AddOwner( + typeof(CustomScrollViewerEx), + new PropertyMetadata(true, OnAutoHideScrollBarsChanged)); public bool AutoHideScrollBars { @@ -96,6 +97,9 @@ protected override void OnMouseWheel(MouseWheelEventArgs e) e.Handled = true; } + if (ActualHeight <= 0) + return; + var WheelChange = e.Delta * (ViewportHeight / 1.5) / ActualHeight; var newOffset = LastVerticalLocation - WheelChange; @@ -126,6 +130,9 @@ protected override void OnMouseWheel(MouseWheelEventArgs e) e.Handled = true; } + if (ActualHeight <= 0) + return; + var WheelChange = e.Delta * (ViewportWidth / 1.5) / ActualWidth; var newOffset = LastHorizontalLocation - WheelChange; @@ -196,7 +203,8 @@ public bool ChangeView(double? horizontalOffset, double? verticalOffset, float? /// A value between MinZoomFactor and MaxZoomFactor that specifies the required target ZoomFactor. /// to disable zoom/pan animations while changing the view; otherwise, . The default is false. /// if the view is changed; otherwise, . - public bool ChangeView(double? horizontalOffset, double? verticalOffset, float? zoomFactor, bool disableAnimation) + public bool ChangeView(double? horizontalOffset, double? verticalOffset, float? zoomFactor, + bool disableAnimation) { if (disableAnimation) { From 4fa1f3d75380aa18ddaf2d7767996dbb137667ed Mon Sep 17 00:00:00 2001 From: egotting Date: Fri, 29 May 2026 00:35:30 -0300 Subject: [PATCH 2/5] fix: adjustment --- Flow.Launcher/Resources/Controls/CustomScrollViewerEx.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Flow.Launcher/Resources/Controls/CustomScrollViewerEx.cs b/Flow.Launcher/Resources/Controls/CustomScrollViewerEx.cs index b729d7c6fdf..5d769f13161 100644 --- a/Flow.Launcher/Resources/Controls/CustomScrollViewerEx.cs +++ b/Flow.Launcher/Resources/Controls/CustomScrollViewerEx.cs @@ -130,7 +130,7 @@ protected override void OnMouseWheel(MouseWheelEventArgs e) e.Handled = true; } - if (ActualHeight <= 0) + if (ActualWidth <= 0) return; var WheelChange = e.Delta * (ViewportWidth / 1.5) / ActualWidth; From fc0fd3c7fa345a10430d7e825b2230420dba7bbb Mon Sep 17 00:00:00 2001 From: Carlos Henrique <104780505+4yinn@users.noreply.github.com> Date: Sun, 31 May 2026 20:57:30 -0300 Subject: [PATCH 3/5] Update Flow.Launcher/Resources/Controls/CustomScrollViewerEx.cs Co-authored-by: cubic-dev-ai[bot] <191113872+cubic-dev-ai[bot]@users.noreply.github.com> --- Flow.Launcher/Resources/Controls/CustomScrollViewerEx.cs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Flow.Launcher/Resources/Controls/CustomScrollViewerEx.cs b/Flow.Launcher/Resources/Controls/CustomScrollViewerEx.cs index 5d769f13161..337f5ccd5c4 100644 --- a/Flow.Launcher/Resources/Controls/CustomScrollViewerEx.cs +++ b/Flow.Launcher/Resources/Controls/CustomScrollViewerEx.cs @@ -131,7 +131,10 @@ protected override void OnMouseWheel(MouseWheelEventArgs e) } if (ActualWidth <= 0) + { + ScrollViewerBehavior.SetIsAnimating(this, false); return; + } var WheelChange = e.Delta * (ViewportWidth / 1.5) / ActualWidth; var newOffset = LastHorizontalLocation - WheelChange; From ff7d7f787c40783270ac11f5b41fddc746383047 Mon Sep 17 00:00:00 2001 From: egotting Date: Sun, 31 May 2026 21:10:22 -0300 Subject: [PATCH 4/5] change location check to ActualHeight validation --- .../Resources/Controls/CustomScrollViewerEx.cs | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/Flow.Launcher/Resources/Controls/CustomScrollViewerEx.cs b/Flow.Launcher/Resources/Controls/CustomScrollViewerEx.cs index 337f5ccd5c4..3c859fba98b 100644 --- a/Flow.Launcher/Resources/Controls/CustomScrollViewerEx.cs +++ b/Flow.Launcher/Resources/Controls/CustomScrollViewerEx.cs @@ -87,6 +87,9 @@ protected override void OnInitialized(EventArgs e) /// protected override void OnMouseWheel(MouseWheelEventArgs e) { + if (ActualHeight <= 0) + return; + var Direction = GetDirection(); ScrollViewerBehavior.SetIsAnimating(this, true); @@ -97,9 +100,6 @@ protected override void OnMouseWheel(MouseWheelEventArgs e) e.Handled = true; } - if (ActualHeight <= 0) - return; - var WheelChange = e.Delta * (ViewportHeight / 1.5) / ActualHeight; var newOffset = LastVerticalLocation - WheelChange; @@ -130,12 +130,6 @@ protected override void OnMouseWheel(MouseWheelEventArgs e) e.Handled = true; } - if (ActualWidth <= 0) - { - ScrollViewerBehavior.SetIsAnimating(this, false); - return; - } - var WheelChange = e.Delta * (ViewportWidth / 1.5) / ActualWidth; var newOffset = LastHorizontalLocation - WheelChange; From a372971bcd799bcefd320ae2fcec46dbf4ef14c3 Mon Sep 17 00:00:00 2001 From: Jack251970 <1160210343@qq.com> Date: Tue, 2 Jun 2026 11:25:55 +0800 Subject: [PATCH 5/5] Code cleanup --- .../Resources/Controls/CustomScrollViewerEx.cs | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/Flow.Launcher/Resources/Controls/CustomScrollViewerEx.cs b/Flow.Launcher/Resources/Controls/CustomScrollViewerEx.cs index 3c859fba98b..fbc85e223cb 100644 --- a/Flow.Launcher/Resources/Controls/CustomScrollViewerEx.cs +++ b/Flow.Launcher/Resources/Controls/CustomScrollViewerEx.cs @@ -17,8 +17,7 @@ public class CustomScrollViewerEx : ScrollViewer public CustomScrollViewerEx() { Loaded += OnLoaded; - var valueSource = DependencyPropertyHelper.GetValueSource(this, AutoPanningMode.IsEnabledProperty) - .BaseValueSource; + var valueSource = DependencyPropertyHelper.GetValueSource(this, AutoPanningMode.IsEnabledProperty).BaseValueSource; if (valueSource == BaseValueSource.Default) { AutoPanningMode.SetIsEnabled(this, true); @@ -45,10 +44,9 @@ public Orientation Orientation #region AutoHideScrollBars public static readonly DependencyProperty AutoHideScrollBarsProperty = - ScrollViewerHelper.AutoHideScrollBarsProperty - .AddOwner( - typeof(CustomScrollViewerEx), - new PropertyMetadata(true, OnAutoHideScrollBarsChanged)); + ScrollViewerHelper.AutoHideScrollBarsProperty.AddOwner( + typeof(CustomScrollViewerEx), + new PropertyMetadata(true, OnAutoHideScrollBarsChanged)); public bool AutoHideScrollBars { @@ -200,8 +198,7 @@ public bool ChangeView(double? horizontalOffset, double? verticalOffset, float? /// A value between MinZoomFactor and MaxZoomFactor that specifies the required target ZoomFactor. /// to disable zoom/pan animations while changing the view; otherwise, . The default is false. /// if the view is changed; otherwise, . - public bool ChangeView(double? horizontalOffset, double? verticalOffset, float? zoomFactor, - bool disableAnimation) + public bool ChangeView(double? horizontalOffset, double? verticalOffset, float? zoomFactor, bool disableAnimation) { if (disableAnimation) {