Skip to content

armgit / Filee

Public Imported from GitHub
0

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.

Donut: one flip per press of the flip key in drag mode (#504)

cre8ive-marketing05b6f905095a
diff --git a/src/Filee.App/Controls/DonutMenu.Flip.cs b/src/Filee.App/Controls/DonutMenu.Flip.cs
index 75b50522..baed700b 100644
--- a/src/Filee.App/Controls/DonutMenu.Flip.cs
+++ b/src/Filee.App/Controls/DonutMenu.Flip.cs
@@ -62,6 +62,12 @@ public sealed partial class DonutMenu
public string? FlipKey { get => GetValue(FlipKeyProperty); set => SetValue(FlipKeyProperty, value); }
public bool FlipWithWheel { get => GetValue(FlipWithWheelProperty); set => SetValue(FlipWithWheelProperty, value); }
+ /// <summary>
+ /// Drag mode: the global hook flips on the flip key (RadialController), so the window's own key press doesn't flip
+ /// too. macOS can give the donut's window the keyboard during a drag, and one press then flipped twice (#504).
+ /// </summary>
+ public bool FlipKeyFromHook { get; set; }
+
/// <summary>
/// A wheel event at <paramref name="nowMs"/> (milliseconds, any clock): flips on the first one of a turn of the wheel
/// and ignores the rest of it (<see cref="WheelQuietMs"/>). Returns true when it flipped.
diff --git a/src/Filee.App/Controls/DonutMenu.Groups.cs b/src/Filee.App/Controls/DonutMenu.Groups.cs
index f76dc516..9922ae98 100644
--- a/src/Filee.App/Controls/DonutMenu.Groups.cs
+++ b/src/Filee.App/Controls/DonutMenu.Groups.cs
@@ -212,7 +212,8 @@ public sealed partial class DonutMenu
string.Equals(KeyNames.ToHookName(key), flipKey, StringComparison.OrdinalIgnoreCase))
{
// Also when there is nothing to flip to: the key never does something else (Tab: move the focus).
- Flip();
+ if (!FlipKeyFromHook)
+ Flip();
return true;
}
if (!HandleKeyCore(key))
diff --git a/src/Filee.App/Services/RadialController.cs b/src/Filee.App/Services/RadialController.cs
index 03dd99bc..a4dbb3dd 100644
--- a/src/Filee.App/Services/RadialController.cs
+++ b/src/Filee.App/Services/RadialController.cs
@@ -508,7 +508,13 @@ public sealed class RadialController(
/// Has the global hook report the flip key and the wheel only while a drag-mode donut shows files that could flip;
/// they are left alone otherwise (see <see cref="TriggerService.WatchFlipKey"/>).
/// </summary>
- private void WatchFlipKey() => triggers.WatchFlipKey = FlipsFromHook;
+ private void WatchFlipKey()
+ {
+ triggers.WatchFlipKey = FlipsFromHook;
+ // One source per press: the hook in drag mode, the window in click mode (#504).
+ if (_window is not null)
+ _window.DonutControl.FlipKeyFromHook = FlipsFromHook;
+ }
/// <summary>A drag-mode donut shows files and nothing was dropped yet: the hook's flip key and wheel flip it.</summary>
private bool FlipsFromHook => _visible && !_dropped && !viewModel.IsClickMode && viewModel.HasFiles;
diff --git a/tests/Filee.App.Tests/DonutFlipTests.cs b/tests/Filee.App.Tests/DonutFlipTests.cs
index fc27b259..f7e81852 100644
--- a/tests/Filee.App.Tests/DonutFlipTests.cs
+++ b/tests/Filee.App.Tests/DonutFlipTests.cs
@@ -323,6 +323,9 @@ public class DonutFlipTests
Assert.True(triggers.WatchFlipKey);
provider.PostKey(EventType.KeyPressed, KeyCode.VcTab, EventMask.LeftCtrl);
+ // #504: macOS can hand the donut's window the same press as well; it must not flip a second time.
+ window.KeyPress(Key.Tab, RawInputModifiers.Control, PhysicalKey.Tab, null);
+ Dispatcher.UIThread.RunJobs();
Assert.True(TriggerServiceLifecycleTests.Settle(() => vm.IsBackFace));
Assert.Equal(ImageBack, vm.Items.Select(i => i.Id));
provider.PostKey(EventType.KeyReleased, KeyCode.VcTab, EventMask.LeftCtrl);