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.

macOS: Option+drag opens the donut over Finder; FILEE_TRACE_GESTURES logs what a gesture sees

KnifeLemonbc158a29dc47
diff --git a/src/Filee.App/Services/Triggers/TriggerService.cs b/src/Filee.App/Services/Triggers/TriggerService.cs
index 0f50b684..01049918 100644
--- a/src/Filee.App/Services/Triggers/TriggerService.cs
+++ b/src/Filee.App/Services/Triggers/TriggerService.cs
@@ -22,6 +22,9 @@ public sealed class TriggerService : IDisposable
private EventLoopGlobalHook? _hook;
private HashSet<string> _excluded = new(StringComparer.OrdinalIgnoreCase);
+ /// <summary>FILEE_TRACE_GESTURES=1 logs each mouse press and scope decision, to find why a gesture doesn't fire.</summary>
+ private static readonly bool Trace = Environment.GetEnvironmentVariable("FILEE_TRACE_GESTURES") == "1";
+
public TriggerService(IPlatformServices platform, ILogger<TriggerService> log)
{
_platform = platform;
@@ -89,7 +92,12 @@ public sealed class TriggerService : IDisposable
_hook = new EventLoopGlobalHook();
_hook.HookEnabled += (_, _) => { _log.LogInformation("Global input hook started"); NotifyStatus(); };
_hook.HookDisabled += (_, _) => { _log.LogInformation("Global input hook stopped"); NotifyStatus(); };
- _hook.MousePressed += (_, e) => _detector.MouseDown(Map(e.Data.Button), e.Data.X, e.Data.Y, Map(e.RawEvent.Mask));
+ _hook.MousePressed += (_, e) =>
+ {
+ if (Trace)
+ _log.LogInformation("Trace: press {Button} at {X},{Y}, mask {Mask} = {Modifiers}", e.Data.Button, e.Data.X, e.Data.Y, e.RawEvent.Mask, Map(e.RawEvent.Mask));
+ _detector.MouseDown(Map(e.Data.Button), e.Data.X, e.Data.Y, Map(e.RawEvent.Mask));
+ };
_hook.MouseReleased += (_, e) => _detector.MouseUp(Map(e.Data.Button), e.Data.X, e.Data.Y);
_hook.MouseDragged += (_, e) => OnMove(e);
_hook.MouseMoved += (_, e) => OnMove(e);
@@ -125,6 +133,8 @@ public sealed class TriggerService : IDisposable
private bool InScope(TriggerGesture gesture, int x, int y)
{
var process = _platform.ProcessNameAt(x, y);
+ if (Trace)
+ _log.LogInformation("Trace: {Gesture} at {X},{Y} over {Process}", gesture.Kind, x, y, process ?? "(none)");
if (process is not null && (string.Equals(process, _ownProcess, StringComparison.OrdinalIgnoreCase) || _excluded.Contains(process)))
return false;
return gesture.Scope == TriggerScope.Anywhere || _platform.IsFileManagerAt(x, y);
diff --git a/src/Filee.Platform.MacOS/NativeMethods.cs b/src/Filee.Platform.MacOS/NativeMethods.cs
index 7e4b907a..3a7af6cd 100644
--- a/src/Filee.Platform.MacOS/NativeMethods.cs
+++ b/src/Filee.Platform.MacOS/NativeMethods.cs
@@ -15,6 +15,7 @@ internal static class NativeMethods
private static readonly nint BoundsKey = CFStringCreateWithCString(0, "kCGWindowBounds", 0x08000100);
private static readonly nint PidKey = CFStringCreateWithCString(0, "kCGWindowOwnerPID", 0x08000100);
private static readonly nint AlphaKey = CFStringCreateWithCString(0, "kCGWindowAlpha", 0x08000100);
+ private static readonly nint LayerKey = CFStringCreateWithCString(0, "kCGWindowLayer", 0x08000100);
internal static string? ProcessNameAt(int x, int y)
{
@@ -32,6 +33,11 @@ internal static class NativeMethods
// Quartz and Avalonia's macOS desktop coordinates use top-left points, including on Retina displays.
if (x < bounds.X || y < bounds.Y || x >= bounds.X + bounds.Width || y >= bounds.Y + bounds.Height)
continue;
+ // Only app windows (layer 0) and the desktop (below 0): the Dock, the menu bar and other system
+ // overlays sit above (the Dock keeps a transparent window over the whole screen).
+ var layerValue = CFDictionaryGetValue(window, LayerKey);
+ if (layerValue != 0 && CFNumberGetInt(layerValue, 3, out var layer) && layer > 0)
+ continue;
var alphaValue = CFDictionaryGetValue(window, AlphaKey);
if (alphaValue != 0 && CFNumberGetDouble(alphaValue, 6, out var alpha) && alpha <= 0)
continue;