Fix unsolicited radial menu activation by retiring global drag detection

This commit is contained in:
nordik committed 2026-10-27 12:13:15 +01:00
1 parent 569f0324d6
commit e3c9581f3e
19 files changed
+112 -88

No files matched your search

-27
View File
@@ -5,8 +5,6 @@ using Windows.ApplicationModel;
internal static class Program
{
[DllImport("user32.dll")] static extern short GetAsyncKeyState(int key);
[DllImport("user32.dll")] static extern bool GetCursorPos(out Point point);
[DllImport("user32.dll")] static extern bool SetProcessDpiAwarenessContext(IntPtr context);
static readonly object OutputLock = new();
static void Write(object data) { lock (OutputLock) { Console.WriteLine(JsonSerializer.Serialize(data)); Console.Out.Flush(); } }
@@ -18,30 +16,6 @@ internal static class Program
Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException);
using var dispatch = new Control();
dispatch.CreateControl();
var timer = new System.Windows.Forms.Timer { Interval = 35 };
bool monitor = false, wasDown = false, dragging = false;
Point origin = default;
string[] dragFiles = [];
timer.Tick += (_, _) => {
bool down = (GetAsyncKeyState(1) & 0x8000) != 0;
GetCursorPos(out var point);
if (monitor && down && !wasDown) { origin = point; dragFiles = Selection(); }
if (monitor && down && !dragging &&
Math.Abs(point.X - origin.X) + Math.Abs(point.Y - origin.Y) > 24) {
var currentSelection = Selection();
if (currentSelection.Length > 0) dragFiles = currentSelection;
if (dragFiles.Length == 0) { wasDown = down; return; }
dragging = true;
Write(new { type = "drag", phase = "start", x = point.X, y = point.Y, files = dragFiles,
tools = (GetAsyncKeyState(18) & 0x8000) != 0 });
}
if (!down && wasDown && dragging) {
Write(new { type = "drag", phase = "drop", x = point.X, y = point.Y, files = dragFiles });
dragging = false; dragFiles = [];
}
wasDown = down;
};
timer.Start();
_ = Task.Run(() => {
string? line;
while ((line = Console.ReadLine()) != null) {
@@ -56,7 +30,6 @@ internal static class Program
object result;
switch (command) {
case "selection": result = Selection(); break;
case "monitor": monitor = value.GetProperty("enabled").GetBoolean(); result = monitor; break;
case "identity":
try { result = new { packaged = true, family = Package.Current.Id.FamilyName }; }
catch { result = new { packaged = false, family = "" }; }