Free, open-source file converter. Convert 263 formats offline by drag & drop — images, PDF, Word, Excel, PowerPoint, HWP/HWPX, video, audio, e-books and archives. No upload, no Office needed.
C# audio-converteravaloniabatch-conversionconvertercsharpdocument-converterdocx-to-pdfdotnetdrag-and-dropfile-conversionfile-converterheic-converterhwphwpximage-converterlinuxmacospdf-convertervideo-converterwindows
The invisible drag donut no longer stays over the desktop catching clicks
KnifeLemon75c7cf8f72bb
diff --git a/src/Filee.App/Controls/DonutMenu.Progress.cs b/src/Filee.App/Controls/DonutMenu.Progress.csindex 638d695d..fb0fd851 100644--- a/src/Filee.App/Controls/DonutMenu.Progress.cs+++ b/src/Filee.App/Controls/DonutMenu.Progress.cs@@ -65,6 +65,12 @@ public sealed partial class DonutMenu/// <summary>True while the donut shows a conversion's progress instead of presets.</summary>public bool IsInProgressMode => _progressMode;+ /// <summary>The finished ring is still holding its badge or fading out, and hides the window when it is done.</summary>+ public bool IsFinishingProgress => _progressMode && _progressDone is not null;++ /// <summary>Drops the progress ring (and its pending "done" callback) for a new gesture.</summary>+ public void LeaveProgressMode() => ResetProgress();+/// <summary>Outcome badge currently visible (null while running). For tests.</summary>internal DonutProgressOutcome? ShownOutcome => _outcome;diff --git a/src/Filee.App/Services/RadialController.cs b/src/Filee.App/Services/RadialController.csindex 5154c7b3..cf6525dc 100644--- a/src/Filee.App/Services/RadialController.cs+++ b/src/Filee.App/Services/RadialController.cs@@ -45,9 +45,18 @@ public sealed class RadialController(private JobViewModel? _progressJob; // job currently shown by the ring (null once finished / handed off)private JobViewModel? _lastRingJob; // for "click the ✓ to open the folder"private IDisposable? _handOffTimer;+ private int _dragGeneration;++ /// <summary>+ /// How long a drag that never brought files may keep the invisible window up, in case the button release is+ /// missed (the system dropped the input hook, a UAC prompt took the desktop): the window catches clicks.+ /// </summary>+ private static readonly TimeSpan EmptyDragLimit = TimeSpan.FromSeconds(10);public bool IsVisible => _visible;+ internal RadialWindow? Window => _window;+/// <summary>/// Drag gesture started at the given physical screen point. The window is placed under the cursor but stays/// invisible until files are dragged into it (FilesEntered); a gesture without files (text, a rubber-band@@ -57,10 +66,19 @@ public sealed class RadialController({ReleaseProgressToToast();var window = EnsureWindow();+ // A ring from an earlier conversion (finished or handed to the toast) must not keep this gesture's window up.+ window.DonutControl.LeaveProgressMode();_dropped = false;viewModel.ResetForDrag();window.DonutControl.AllowContextEdit = false;PlaceAndShow(window, x, y, activate: false);++ var generation = ++_dragGeneration;+ DispatcherTimer.RunOnce(() =>+ {+ if (generation == _dragGeneration && _visible && !viewModel.HasFiles && !viewModel.IsClickMode)+ Close(animate: false);+ }, EmptyDragLimit);}/// <summary>Opens the donut for known files (click mode).</summary>@@ -82,6 +100,12 @@ public sealed class RadialController({if (!_visible || viewModel.IsClickMode)return;+ // Nothing was brought to the donut: the window is invisible but catches clicks, so go right away.+ if (!viewModel.HasFiles && !_window!.DonutControl.IsInProgressMode)+ {+ Close(animate: false);+ return;+ }// A drop on the donut arrives around the same time as the button release; give it a moment.DispatcherTimer.RunOnce(() =>{@@ -98,8 +122,14 @@ public sealed class RadialController({// Esc / click elsewhere while the ring is showing: let the toast carry on (a finishing ✓ just fades).if (_progressJob is not null)+ {HandOffToToast();- return;+ return;+ }+ if (_window.DonutControl.IsFinishingProgress)+ return;+ // A ring left over after it finished: nothing is showing any more, so close like any donut.+ _window.DonutControl.LeaveProgressMode();}_visible = false;var window = _window;diff --git a/src/Filee.App/Services/SingleInstance.cs b/src/Filee.App/Services/SingleInstance.csindex 7c890056..64285de3 100644--- a/src/Filee.App/Services/SingleInstance.cs+++ b/src/Filee.App/Services/SingleInstance.cs@@ -87,6 +87,7 @@ public sealed class SingleInstance : IDisposable{using var client = new NamedPipeClientStream(".", _name, PipeDirection.Out, PipeOptions.CurrentUserOnly);client.Connect((int)Math.Clamp(left.TotalMilliseconds, 100, 1000));+ Filee.Platform.Windows.Foreground.AllowOtherProcess(); // its donut takes the focus (Esc, click away)JsonSerializer.Serialize(client, args, AppJsonContext.Default.StringArray);return true;}diff --git a/src/Filee.Platform.Windows/Foreground.cs b/src/Filee.Platform.Windows/Foreground.csnew file mode 100644index 00000000..48964e98--- /dev/null+++ b/src/Filee.Platform.Windows/Foreground.cs@@ -0,0 +1,15 @@+// Windows lets only the process the user is working with bring a window to the front. A second Filee started from+// Explorer's menu or Send To has that right and passes the files to the running Filee; without handing the right on,+// the donut it opens can't take the focus, so Esc and clicking elsewhere don't close it.++namespace Filee.Platform.Windows;++public static class Foreground+{+ /// <summary>Lets another process (the running Filee) bring its window to the front. No-op off Windows.</summary>+ public static void AllowOtherProcess()+ {+ if (OperatingSystem.IsWindows())+ NativeMethods.AllowSetForegroundWindow(NativeMethods.ASFW_ANY);+ }+}diff --git a/src/Filee.Platform.Windows/NativeMethods.cs b/src/Filee.Platform.Windows/NativeMethods.csindex 40f061f0..b4521c18 100644--- a/src/Filee.Platform.Windows/NativeMethods.cs+++ b/src/Filee.Platform.Windows/NativeMethods.cs@@ -26,6 +26,12 @@ internal static partial class NativeMethods[LibraryImport("user32.dll")]public static partial nint GetForegroundWindow();+ public const uint ASFW_ANY = uint.MaxValue;++ [LibraryImport("user32.dll")]+ [return: MarshalAs(UnmanagedType.Bool)]+ public static partial bool AllowSetForegroundWindow(uint processId);+public const nint HWND_TOPMOST = -1;public const uint SWP_NOSIZE = 0x0001, SWP_NOMOVE = 0x0002, SWP_NOACTIVATE = 0x0010, SWP_NOOWNERZORDER = 0x0200;diff --git a/tests/Filee.App.Tests/RadialControllerTests.cs b/tests/Filee.App.Tests/RadialControllerTests.csnew file mode 100644index 00000000..ede64667--- /dev/null+++ b/tests/Filee.App.Tests/RadialControllerTests.cs@@ -0,0 +1,60 @@+// The drag-wait donut is an invisible, topmost window that catches clicks so a drag can reach it: it must close when+// the gesture ends without files, even after a conversion left the ring behind (issue: desktop icons stopped reacting+// to clicks until Filee quit).++using Avalonia.Headless.XUnit;+using Filee.App.Controls;+using Filee.App.Services;++namespace Filee.App.Tests;++public class RadialControllerTests+{+ /// <summary>A conversion ran through the donut and its ring finished: progress mode stays on, nothing is pending.</summary>+ private static void FinishARing(DonutMenu donut)+ {+ donut.BeginProgress();+ Motion.Set(false);+ try+ {+ donut.HandOffProgress(() => { });+ }+ finally+ {+ Motion.Set(true);+ }+ Assert.True(donut.IsInProgressMode);+ Assert.False(donut.IsFinishingProgress);+ }++ [AvaloniaFact]+ public void A_drag_without_files_after_a_conversion_closes_the_invisible_window()+ {+ TestServices.EnsureInitialized("en");+ var radial = AppHost.Get<RadialController>();+ radial.ShowForDrag(400, 400);+ FinishARing(radial.Window!.DonutControl);++ // A later Ctrl+drag that brings no files: a rubber-band selection on the desktop, a folder.+ radial.ShowForDrag(600, 500);+ Assert.False(radial.Window.DonutControl.IsInProgressMode);+ radial.OnDragGestureEnded();++ Assert.False(radial.IsVisible);+ Assert.False(radial.Window.IsVisible);+ }++ [AvaloniaFact]+ public void Esc_closes_a_donut_whose_ring_already_finished()+ {+ TestServices.EnsureInitialized("en");+ var radial = AppHost.Get<RadialController>();+ radial.ShowForDrag(400, 400);+ FinishARing(radial.Window!.DonutControl);++ radial.Close(animate: false);++ Assert.False(radial.IsVisible);+ Assert.False(radial.Window.IsVisible);+ }+}