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
Address review: opt-in, KDE only, cursor estimate, KPackage
IPedrax891d1cf8dfa4
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.mdindex cf43777b..c5e7cebd 100644--- a/CONTRIBUTING.md+++ b/CONTRIBUTING.md@@ -49,9 +49,10 @@ machine that built it. Check a package withXrandr, Xi, Xtst, Xt, XkbCommon, ICE and SM) and CJK fonts for document comparisons. File actions are installed forThunar, Nautilus, Nemo and Dolphin. The first enabled keyboard shortcut uses Thunar's native custom action;close Thunar before changing or pausing that shortcut and reopen it afterwards. Global selected-file queries- and hold gestures are not supported. Wayland can use file actions, the drop zone, watch folders and CLI. On KDE Plasma the drag gesture also runs- there when the user is in the `input` group (libuiohook's libinput back end) and `installer/linux/kwin/filee-donut.js`- is loaded (it moves the donut window, titled "Filee Donut", to the cursor); see `installer/linux/INSTALL.txt`.+ and hold gestures are not supported. Wayland can use file actions, the drop zone, watch folders and CLI.+ On KDE Plasma 6 the drag gesture can also run there, experimentally and only with `FILEE_WAYLAND_GESTURES=1`. It needs+ the user in the `input` group (libuiohook's libinput back end) and the KWin script in `installer/linux/kwin`, which+ moves the donut window (titled "Filee Donut") to the cursor. See `installer/linux/INSTALL.txt`.- **macOS:** grant Filee Accessibility permission for gestures and Finder Automation permission for selection.Keep the development `.app` at a stable path while testing these permissions. Finder integration is a QuickAction under Services; auto-start uses a per-user LaunchAgent.diff --git a/build/build-portable.ps1 b/build/build-portable.ps1index e4b217de..380a8c6a 100644--- a/build/build-portable.ps1+++ b/build/build-portable.ps1@@ -137,7 +137,7 @@ else {Copy-Item -LiteralPath (Join-Path $root 'installer/linux/install.sh') -Destination $packageCopy-Item -LiteralPath (Join-Path $root 'installer/linux/uninstall.sh') -Destination $packageCopy-Item -LiteralPath (Join-Path $root 'installer/linux/INSTALL.txt') -Destination $package- Copy-Item -LiteralPath (Join-Path $root 'installer/linux/kwin/filee-donut.js') -Destination $package+ Copy-Item -LiteralPath (Join-Path $root 'installer/linux/kwin') -Destination $package -Recurse}Invoke-Checked 'Installer permissions' { chmod +x (Join-Path $package 'install.sh') (Join-Path $package 'uninstall.sh') }$temporaryArchive = "$archive.$([Guid]::NewGuid().ToString('N')).partial"diff --git a/installer/linux/INSTALL.txt b/installer/linux/INSTALL.txtindex b03d4ef2..2852fddb 100644--- a/installer/linux/INSTALL.txt+++ b/installer/linux/INSTALL.txt@@ -24,17 +24,32 @@ X11 supports the global gesture toolbar; it needs libXtst and libXt (libxtst6,libxt6). A native Wayland session has additional input restrictions; use thedrop window and file-manager actions, or the experimental setup below.-Wayland gesture (experimental, KDE Plasma): Filee reads the mouse and keyboard-from /dev/input, which needs the input group, and a KWin script moves the donut-to the cursor because Wayland apps cannot place windows. Members of the input-group can read all keyboard and mouse input, so enable this only if you accept-that. Add yourself, then sign out and in:- sudo usermod -aG input "$USER"-Then load the script (it lasts until you sign out):- qdbus6 org.kde.KWin /Scripting loadScript "$HOME/.local/share/filee/application/filee-donut.js" filee-donut- qdbus6 org.kde.KWin /Scripting start-Wayland cannot say which window is under the cursor, so any Ctrl+drag opens the-invisible donut window; it only shows when files are dragged onto it.+Wayland gesture (experimental, KDE Plasma 6 only, off by default): Filee reads+the mouse and keyboard from /dev/input through libinput, and a KWin script moves+the donut to the cursor because Wayland apps cannot place windows. It needs+libinput, libudev and libwayland-client (libinput10, libudev1 and+libwayland-client0 on Ubuntu). To turn it on:+1. Start Filee with FILEE_WAYLAND_GESTURES=1 in its environment, for example+ with the line FILEE_WAYLAND_GESTURES=1 in ~/.config/environment.d/filee.conf+ (takes effect after you sign in again).+2. Add yourself to the input group, then sign out and in. Members of that group+ can read all keyboard and mouse input from any program they run, so enable+ this only if you accept that. You may already be in it for other tools.+ sudo usermod -aG input "$USER"+3. Install the KWin script and enable it, so it loads at every login (you can+ also enable "Filee donut at the cursor" in System Settings > Window+ Management > KWin Scripts):+ kpackagetool6 --type=KWin/Script --install "${XDG_DATA_HOME:-$HOME/.local/share}/filee/application/kwin/filee-donut"+ kwriteconfig6 --file kwinrc --group Plugins --key filee-donutEnabled true+ qdbus6 org.kde.KWin /KWin reconfigure+Limits: Wayland cannot say which window is under the cursor, so a Ctrl+drag in+any app opens an invisible donut window. It only shows when files are dragged+onto it, but it rejects drops that are not files, so Ctrl+drag to copy text in an+editor or browser can have its drop swallowed near the start point. If that gets+in the way, change the modifier on the Triggers page, for example to Ctrl+Shift.+The excluded apps list does not apply on Wayland. Without the KWin script the+donut opens in the wrong place.+Packages are built and smoke-tested on Ubuntu 24.04 and started on Ubuntu 22.04by the automated builds.diff --git a/installer/linux/kwin/filee-donut.js b/installer/linux/kwin/filee-donut/contents/code/main.jssimilarity index 57%rename from installer/linux/kwin/filee-donut.jsrename to installer/linux/kwin/filee-donut/contents/code/main.jsindex 1547ffe6..0ea0250d 100644--- a/installer/linux/kwin/filee-donut.js+++ b/installer/linux/kwin/filee-donut/contents/code/main.js@@ -1,8 +1,10 @@-// KWin script for the experimental Wayland gesture: Wayland gives Filee no cursor position and no say over where its-// window opens, so this moves the donut ("Filee Donut") to the cursor whenever it is mapped.-// Load for this session: qdbus6 org.kde.KWin /Scripting loadScript <this file> filee-donut-// qdbus6 org.kde.KWin /Scripting start-// Remove: qdbus6 org.kde.KWin /Scripting unloadScript filee-donut+// KWin script (Plasma 6) for the experimental Wayland gesture. Wayland gives Filee no cursor position and no say+// over where its window opens, so this moves the donut window (class "Filee", title "Filee Donut") to the cursor+// whenever it is mapped. Install it with kpackagetool6 and enable it; see installer/linux/INSTALL.txt.++function isDonut(w) {+ return String(w.resourceClass).toLowerCase() === "filee" && w.caption === "Filee Donut";+}function centreOnCursor(w) {var p = workspace.cursorPos;@@ -15,7 +17,7 @@ function centreOnCursor(w) {}workspace.windowAdded.connect(function (w) {- if (w.caption !== "Filee Donut") {+ if (!isDonut(w)) {return;}// Filee also positions the window itself (twice, to cope with DPI changes), so win the last few moves.diff --git a/installer/linux/kwin/filee-donut/metadata.json b/installer/linux/kwin/filee-donut/metadata.jsonnew file mode 100644index 00000000..757fa717--- /dev/null+++ b/installer/linux/kwin/filee-donut/metadata.json@@ -0,0 +1,12 @@+{+ "KPlugin": {+ "Id": "filee-donut",+ "Name": "Filee donut at the cursor",+ "Description": "Moves Filee's donut window to the cursor, which Wayland apps cannot do themselves.",+ "License": "MIT",+ "Version": "1.0"+ },+ "X-Plasma-API": "javascript",+ "X-Plasma-MainScript": "code/main.js",+ "KPackageStructure": "KWin/Script"+}diff --git a/src/Filee.App/Assets/i18n/en.json b/src/Filee.App/Assets/i18n/en.jsonindex 7a0f9ab5..6ef0c623 100644--- a/src/Filee.App/Assets/i18n/en.json+++ b/src/Filee.App/Assets/i18n/en.json@@ -251,6 +251,7 @@"triggers.macos_permissions": "Allow Filee in System Settings > Privacy & Security > Accessibility.\nFinder also asks for Automation permission the first time you use a selection shortcut.","triggers.linux_x11": "Drag gestures work on X11.\nWith file manager integration on, the first keyboard shortcut runs Thunar's Filee action (reopen Thunar after changing it).\nHold gestures and shortcuts in other file managers aren't available. Use the Filee menu or the drop zone.","triggers.linux_wayland": "Gestures that follow the cursor aren't available on Wayland.\nUse an X11 session, or convert with the file manager menu and the drop zone.\nThunar can use the first keyboard shortcut after it restarts.",+ "triggers.linux_wayland_experimental": "Gestures on Wayland are experimental and only work on KDE Plasma.\nFilee reads the mouse from /dev/input and a KWin script places the donut at the cursor (see INSTALL.txt). Ctrl+drag in other apps can be interrupted; use another modifier such as Ctrl+Shift if it gets in the way.","triggers.open_accessibility": "Open Accessibility settings","triggers.retry_hook": "Retry gestures","triggers.hook_running": "Global input detection is running.",diff --git a/src/Filee.App/Assets/i18n/ko.json b/src/Filee.App/Assets/i18n/ko.jsonindex 923542c3..4a540f59 100644--- a/src/Filee.App/Assets/i18n/ko.json+++ b/src/Filee.App/Assets/i18n/ko.json@@ -251,6 +251,7 @@"triggers.macos_permissions": "시스템 설정 > 개인정보 보호 및 보안 > 손쉬운 사용에서 Filee를 허용해 주세요.\n선택 파일 단축키를 처음 쓸 때 Finder 자동화 권한도 요청해요.","triggers.linux_x11": "드래그 제스처는 X11에서 작동해요.\n파일 관리자 연동을 켜면 첫 번째 키보드 단축키가 Thunar의 Filee 동작에 연결돼요(바꾼 뒤 Thunar를 다시 열어 주세요).\n길게 누르기와 다른 파일 관리자의 단축키는 지원하지 않아요. Filee 메뉴나 드롭 영역을 써 주세요.","triggers.linux_wayland": "Wayland에서는 커서를 따라가는 제스처를 쓸 수 없어요.\nX11 세션을 쓰거나, 파일 관리자 메뉴와 드롭 영역으로 변환해 주세요.\nThunar는 다시 시작하면 첫 번째 키보드 단축키를 쓸 수 있어요.",+ "triggers.linux_wayland_experimental": "Gestures on Wayland are experimental and only work on KDE Plasma.\nFilee reads the mouse from /dev/input and a KWin script places the donut at the cursor (see INSTALL.txt). Ctrl+drag in other apps can be interrupted; use another modifier such as Ctrl+Shift if it gets in the way.","triggers.open_accessibility": "손쉬운 사용 설정 열기","triggers.retry_hook": "제스처 다시 시도","triggers.hook_running": "전역 입력을 감지하고 있어요.",diff --git a/src/Filee.App/Assets/i18n/pl.json b/src/Filee.App/Assets/i18n/pl.jsonindex ec2d5a7e..4009b3d0 100644--- a/src/Filee.App/Assets/i18n/pl.json+++ b/src/Filee.App/Assets/i18n/pl.json@@ -251,6 +251,7 @@"triggers.macos_permissions": "Zezwól Filee w Ustawienia systemowe > Prywatność i ochrona > Dostępność.\nFinder poprosi też o uprawnienie Automatyzacji przy pierwszym użyciu skrótu zaznaczenia.","triggers.linux_x11": "Gesty przeciągania działają w X11.\nPrzy włączonej integracji z menedżerem plików pierwszy skrót klawiszowy uruchamia akcję Filee w Thunarze (po zmianie otwórz Thunara ponownie).\nGesty przytrzymania i skróty w innych menedżerach plików są niedostępne. Użyj menu Filee lub strefy upuszczania.","triggers.linux_wayland": "Gesty podążające za kursorem są niedostępne w Waylandzie.\nUżyj sesji X11 albo konwertuj przez menu menedżera plików i strefę upuszczania.\nThunar może używać pierwszego skrótu klawiszowego po ponownym uruchomieniu.",+ "triggers.linux_wayland_experimental": "Gestures on Wayland are experimental and only work on KDE Plasma.\nFilee reads the mouse from /dev/input and a KWin script places the donut at the cursor (see INSTALL.txt). Ctrl+drag in other apps can be interrupted; use another modifier such as Ctrl+Shift if it gets in the way.","triggers.open_accessibility": "Otwórz ustawienia Dostępności","triggers.retry_hook": "Ponów gesty","triggers.hook_running": "Globalne wykrywanie wejścia działa.",diff --git a/src/Filee.App/Assets/i18n/zh-CN.json b/src/Filee.App/Assets/i18n/zh-CN.jsonindex 5f1f8504..fec5063e 100644--- a/src/Filee.App/Assets/i18n/zh-CN.json+++ b/src/Filee.App/Assets/i18n/zh-CN.json@@ -251,6 +251,7 @@"triggers.macos_permissions": "请在系统设置 > 隐私与安全性 > 辅助功能中允许 Filee。\n首次使用选择文件的快捷键时,Finder 还会请求自动化权限。","triggers.linux_x11": "拖动手势需要 X11。\n启用文件管理器集成后,第一个键盘快捷键会运行 Thunar 的 Filee 操作(修改后请重新打开 Thunar)。\n不支持长按手势和其他文件管理器的快捷键,请使用 Filee 菜单或拖放区域。","triggers.linux_wayland": "Wayland 下无法使用跟随光标的手势。\n请使用 X11 会话,或通过文件管理器菜单和拖放区域转换。\nThunar 重启后可以使用第一个键盘快捷键。",+ "triggers.linux_wayland_experimental": "Gestures on Wayland are experimental and only work on KDE Plasma.\nFilee reads the mouse from /dev/input and a KWin script places the donut at the cursor (see INSTALL.txt). Ctrl+drag in other apps can be interrupted; use another modifier such as Ctrl+Shift if it gets in the way.","triggers.open_accessibility": "打开辅助功能设置","triggers.retry_hook": "重试手势","triggers.hook_running": "正在检测全局输入。",diff --git a/src/Filee.App/Services/Triggers/TriggerService.cs b/src/Filee.App/Services/Triggers/TriggerService.csindex f4a78dce..6e193cf3 100644--- a/src/Filee.App/Services/Triggers/TriggerService.cs+++ b/src/Filee.App/Services/Triggers/TriggerService.cs@@ -113,10 +113,14 @@ public sealed class TriggerService : IDisposable{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));- _relX = _relY = 0; // Wayland reports presses at (0, 0), so relative motion is counted from the press- _detector.MouseDown(Map(e.Data.Button), e.Data.X, e.Data.Y, Map(e.RawEvent.Mask));+ var (x, y) = ButtonPoint(e);+ _detector.MouseDown(Map(e.Data.Button), x, y, Map(e.RawEvent.Mask));+ };+ _hook.MouseReleased += (_, e) =>+ {+ var (x, y) = ButtonPoint(e);+ _detector.MouseUp(Map(e.Data.Button), x, y);};- _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);_hook.MouseDraggedRelative += (_, e) => OnRelativeMove(e);@@ -167,25 +171,30 @@ public sealed class TriggerService : IDisposableinternal static bool IsMissingLinuxBackend(Exception exception) =>exception is HookException { Result: UioHookResult.ErrorLinuxLoadBackend };+ // Wayland (experimental): presses carry no position and a mouse only moves relatively, while tablets and virtual+ // machines still send absolute moves. So a running estimate is kept: absolute moves set it, relative moves add to+ // it, and presses start from it. It is only good for the drag threshold and drifts over a long hover. Placing the+ // donut at the real cursor is a KWin script's job (installer/linux/kwin), and LastCursor is left alone because+ // the estimate is not a screen position.+ private int _estX, _estY;++ private (int X, int Y) ButtonPoint(MouseHookEventArgs e) =>+ _platform.PressCarriesPosition ? (e.Data.X, e.Data.Y) : (_estX, _estY);+private void OnMove(MouseHookEventArgs e){+ (_estX, _estY) = (e.Data.X, e.Data.Y);LastCursor = (e.Data.X, e.Data.Y);_detector.MouseMove(e.Data.X, e.Data.Y, Map(e.RawEvent.Mask), HeldButton(e.RawEvent.Mask));}- // Wayland (experimental). A mouse only gives relative motion there, so the detector gets the distance- // moved since the last press (enough for the drag threshold). Placing the donut at the real cursor is a KWin- // script's job (installer/linux/kwin/filee-donut.js), and a long hover drifts until the next press resets it.- private int _relX, _relY;-private void OnRelativeMove(MouseHookEventArgs e){- _relX += e.Data.X;- _relY += e.Data.Y;+ _estX += e.Data.X;+ _estY += e.Data.Y;if (Trace && HeldButton(e.RawEvent.Mask) != TriggerMouseButton.None)- _log.LogInformation("Trace: relative move {Dx},{Dy} -> {X},{Y}, mask {Mask}", e.Data.X, e.Data.Y, _relX, _relY, e.RawEvent.Mask);- LastCursor = (_relX, _relY);- _detector.MouseMove(_relX, _relY, Map(e.RawEvent.Mask), HeldButton(e.RawEvent.Mask));+ _log.LogInformation("Trace: relative move {Dx},{Dy} -> {X},{Y}, mask {Mask}", e.Data.X, e.Data.Y, _estX, _estY, e.RawEvent.Mask);+ _detector.MouseMove(_estX, _estY, Map(e.RawEvent.Mask), HeldButton(e.RawEvent.Mask));}private bool InScope(TriggerGesture gesture, int x, int y)diff --git a/src/Filee.App/ViewModels/Pages/TriggersPageViewModel.cs b/src/Filee.App/ViewModels/Pages/TriggersPageViewModel.csindex b5ad96d5..1ef4d66b 100644--- a/src/Filee.App/ViewModels/Pages/TriggersPageViewModel.cs+++ b/src/Filee.App/ViewModels/Pages/TriggersPageViewModel.cs@@ -173,7 +173,8 @@ public sealed partial class TriggersPageViewModel : ObservableObject, IDisposablpublic string? PlatformNotice => _platform switch{MacOSPlatformServices => _loc["triggers.macos_permissions"],- LinuxPlatformServices when OperatingSystem.IsLinux() && LinuxPlatformServices.IsWaylandSession => _loc["triggers.linux_wayland"],+ LinuxPlatformServices linux when OperatingSystem.IsLinux() && LinuxPlatformServices.IsWaylandSession =>+ _loc[linux.SupportsGlobalPointerGestures ? "triggers.linux_wayland_experimental" : "triggers.linux_wayland"],LinuxPlatformServices => _loc["triggers.linux_x11"],_ => null,};diff --git a/src/Filee.Core/Platform/IPlatformServices.cs b/src/Filee.Core/Platform/IPlatformServices.csindex 5a1b0d9f..ac8ae397 100644--- a/src/Filee.Core/Platform/IPlatformServices.cs+++ b/src/Filee.Core/Platform/IPlatformServices.cs@@ -6,6 +6,12 @@ public interface IPlatformServicesbool SupportsGlobalPointerGestures => true;bool SupportsSelectionShortcut => true;+ /// <summary>+ /// False where mouse presses arrive without a position (Wayland reports them at (0, 0)), so the gesture has to+ /// start from the last known cursor estimate instead.+ /// </summary>+ bool PressCarriesPosition => true;+/// <summary>True if the window at the screen point belongs to the file manager or desktop. Coordinates are pixels on Windows/Linux and desktop points on macOS.</summary>bool IsFileManagerAt(int x, int y);diff --git a/src/Filee.Platform.Linux/LinuxPlatformServices.cs b/src/Filee.Platform.Linux/LinuxPlatformServices.csindex 11c5de3b..b09f22c2 100644--- a/src/Filee.Platform.Linux/LinuxPlatformServices.cs+++ b/src/Filee.Platform.Linux/LinuxPlatformServices.cs@@ -21,9 +21,13 @@ public sealed class LinuxPlatformServices : IPlatformServicesstring.Equals(Environment.GetEnvironmentVariable("XDG_SESSION_TYPE"), "wayland", StringComparison.OrdinalIgnoreCase)|| !string.IsNullOrEmpty(Environment.GetEnvironmentVariable("WAYLAND_DISPLAY"));- // Wayland (experimental). libuiohook's libinput backend reads /dev/input, so it only works once the- // user is in the `input` group. The cursor it reports is estimated from relative motion and can drift.- private static readonly bool WaylandInputReadable = IsWaylandSession && CanReadInputDevices();+ // Wayland gestures (experimental) are opt-in: FILEE_WAYLAND_GESTURES=1 on KDE Plasma. libuiohook's libinput backend+ // reads /dev/input, so /dev/input is only probed once the switch is set, and it works once the user is in the+ // `input` group. Presses carry no position and a mouse only moves relatively there; a KWin script places the donut.+ private static readonly bool WaylandGestures = IsWaylandSession+ && Environment.GetEnvironmentVariable("FILEE_WAYLAND_GESTURES") == "1"+ && (Environment.GetEnvironmentVariable("XDG_CURRENT_DESKTOP") ?? "").Split(':').Contains("KDE", StringComparer.OrdinalIgnoreCase)+ && CanReadInputDevices();private static bool CanReadInputDevices(){@@ -32,27 +36,28 @@ public sealed class LinuxPlatformServices : IPlatformServicesforeach (var device in Directory.EnumerateFiles("/dev/input", "event*")){try { using var _ = File.OpenRead(device); return true; }- catch (UnauthorizedAccessException) { }+ catch (Exception ex) when (ex is UnauthorizedAccessException or IOException) { }}}- catch (IOException) { }+ catch (Exception ex) when (ex is UnauthorizedAccessException or IOException) { }return false;}- public bool SupportsGlobalPointerGestures => X11WindowSystem.IsAvailable || WaylandInputReadable;+ public bool SupportsGlobalPointerGestures => X11WindowSystem.IsAvailable || WaylandGestures;+ public bool PressCarriesPosition => !WaylandGestures;public bool SupportsSelectionShortcut => false;public string SelectionShortcutUnavailableReason =>"Linux file managers do not expose a shared selected-file API. Use the Filee context action or its Thunar shortcut.";public string? GlobalPointerGesturesUnavailableReason => SupportsGlobalPointerGestures ? null : IsWaylandSession- ? "On Wayland the cursor-following gesture reads /dev/input: add your user to the 'input' group and sign in again. File actions and the drop zone work without it."+ ? "The cursor-following gesture requires an X11 desktop session. File actions and the drop zone remain available on Wayland.": "The cursor-following gesture requires an X11 display.";public string ThunarShortcutRestartRequired =>"Close Thunar before changing its shortcut, then reopen it to load the Filee action and shortcut.";// Wayland can't say which window is under the cursor, so any Ctrl+drag may open the (invisible) donut window;- // it only shows when files are dragged in. A KWin script could answer this properly.+ // it only shows when files are dragged in, and excluded apps can't be told apart there either.public bool IsFileManagerAt(int x, int y) =>- WaylandInputReadable || ProcessNameAt(x, y) is { } name && FileManagers.Contains(name);+ WaylandGestures || ProcessNameAt(x, y) is { } name && FileManagers.Contains(name);public string? ProcessNameAt(int x, int y) => X11WindowSystem.ProcessNameAt(x, y);public IReadOnlyList<string> RunningAppNames() => IPlatformServices.AppNames(X11WindowSystem.ClientProcessNames());diff --git a/tests/Filee.App.Tests/TriggerServiceLifecycleTests.cs b/tests/Filee.App.Tests/TriggerServiceLifecycleTests.csindex 31b72e30..8982d3d2 100644--- a/tests/Filee.App.Tests/TriggerServiceLifecycleTests.cs+++ b/tests/Filee.App.Tests/TriggerServiceLifecycleTests.cs@@ -85,31 +85,74 @@ public sealed class TriggerServiceLifecycleTests}}+ private const EventMask Held = EventMask.LeftCtrl | EventMask.Button1;++ [AvaloniaFact]+ public void Wayland_relative_motion_adds_to_the_cursor_estimate_that_presses_start_from()+ {+ // Wayland reports presses at (0, 0) and a mouse only moves relatively; LastCursor must not take the estimate.+ var (provider, service, started) = StartGesture(wayland: true);++ provider.PostMouse(EventType.MouseMovedRelative, 500, 400, EventMask.None); // estimate before the press+ provider.PostMouse(EventType.MousePressed, 0, 0, Held);+ provider.PostMouse(EventType.MouseDraggedRelative, 3, 0, Held); // under the drag threshold+ provider.PostMouse(EventType.MouseDraggedRelative, 3, 1, Held); // 6 from the press: over it++ var e = WaitForStart(started);+ Assert.Equal((506, 401), (e.X, e.Y));+ Assert.Equal((0, 0), service.LastCursor);+ }++ [AvaloniaFact]+ public void Wayland_absolute_pointer_moves_set_the_estimate()+ {+ // Tablets and virtual machines still send absolute moves, while their presses arrive at (0, 0).+ var (provider, service, started) = StartGesture(wayland: true);++ provider.PostMouse(EventType.MouseMoved, 100, 200, EventMask.None);+ provider.PostMouse(EventType.MousePressed, 0, 0, Held);+ provider.PostMouse(EventType.MouseDragged, 101, 200, Held); // 1 from the press: must not start+ provider.PostMouse(EventType.MouseDragged, 110, 200, Held);++ var e = WaitForStart(started);+ Assert.Equal((110, 200), (e.X, e.Y));+ Assert.Equal((110, 200), service.LastCursor);+ }+[AvaloniaFact]- public void Relative_motion_since_the_press_starts_a_drag_gesture()+ public void Off_Wayland_presses_and_the_cursor_keep_their_coordinates()+ {+ var (provider, service, started) = StartGesture(wayland: false);++ provider.PostMouse(EventType.MousePressed, 50, 60, Held);+ provider.PostMouse(EventType.MouseDragged, 60, 60, Held);++ var e = WaitForStart(started);+ Assert.Equal((60, 60), (e.X, e.Y));+ Assert.Equal((60, 60), service.LastCursor);+ }++ private static (DelayedProvider Provider, TriggerService Service, Func<GestureEventArgs?> Started) StartGesture(bool wayland){- // Wayland reports presses at (0, 0) and mouse motion only as deltas, so the drag distance is summed from the press.var provider = new DelayedProvider();provider.AllowExit.Set();- using var service = Create(provider, () => { });+ var service = Create(provider, () => { }, wayland);service.Apply(new AppSettings());GestureEventArgs? started = null;service.DragStarted += (_, e) => started = e;service.Start();Assert.True(SpinWait.SpinUntil(() => provider.Runs == 1, 2000));+ return (provider, service, () => started);+ }- const EventMask held = EventMask.LeftCtrl | EventMask.Button1;- provider.PostMouse(EventType.MouseMovedRelative, 500, 500, EventMask.None); // before the press: must not count- provider.PostMouse(EventType.MousePressed, 0, 0, held);- provider.PostMouse(EventType.MouseDraggedRelative, 3, 0, held); // under the drag threshold- provider.PostMouse(EventType.MouseDraggedRelative, 3, 1, held); // 6 in total: over it-- Assert.True(SpinWait.SpinUntil(() => { Dispatcher.UIThread.RunJobs(); return started is not null; }, 2000));- Assert.Equal((6, 1), (started!.X, started.Y));+ private static GestureEventArgs WaitForStart(Func<GestureEventArgs?> started)+ {+ Assert.True(SpinWait.SpinUntil(() => { Dispatcher.UIThread.RunJobs(); return started() is not null; }, 2000));+ return started()!;}- private static TriggerService Create(DelayedProvider provider, Action key) =>- new(new NullPlatformServicesForHooks(), NullLogger<TriggerService>.Instance, () =>+ private static TriggerService Create(DelayedProvider provider, Action key, bool wayland = false) =>+ new(new NullPlatformServicesForHooks { PressCarriesPosition = !wayland }, NullLogger<TriggerService>.Instance, () =>{var hook = new EventLoopGlobalHook(provider, useBackgroundThreadForEventLoop: true);hook.KeyPressed += (_, _) => key();@@ -176,6 +219,7 @@ public sealed class TriggerServiceLifecycleTestsprivate sealed class NullPlatformServicesForHooks : IPlatformServices{+ public bool PressCarriesPosition { get; init; } = true;public bool IsFileManagerAt(int x, int y) => true;public string? ProcessNameAt(int x, int y) => "explorer";public IReadOnlyList<string> GetFileManagerSelection() => [];