Remove CursorInfo class

This commit is contained in:
Jack251970 2025-07-23 13:52:31 +08:00
parent 3cfe122c7b
commit 3cd7c3ce00
2 changed files with 6 additions and 32 deletions

View file

@ -1,29 +0,0 @@
using System.Drawing;
using System.Runtime.InteropServices;
using Windows.Win32;
namespace Flow.Launcher.Plugin.SharedModels;
/// <summary>
/// Contains full information about a cursor.
/// </summary>
/// <remarks>
/// Use this class to replace the System.Windows.Forms.Cursor class which can cause possible System.PlatformNotSupportedException.
/// </remarks>
public class CursorInfo
{
/// <summary>
/// Gets the current position of the cursor in screen coordinates.
/// </summary>
public static Point Position
{
get
{
if (!PInvoke.GetCursorPos(out var pt))
{
Marshal.ThrowExceptionForHR(Marshal.GetLastWin32Error());
}
return pt;
}
}
}

View file

@ -1,5 +1,4 @@
using System;
using System.Collections.Generic;
using System.Collections.Generic;
using System.Runtime.InteropServices;
using System.Windows;
using Windows.Win32;
@ -102,7 +101,11 @@ public class MonitorInfo
/// <returns>The display monitor that contains the cursor, or null if no monitor is found.</returns>
public static unsafe MonitorInfo GetCursorDisplayMonitor()
{
var cursorMonitor = PInvoke.MonitorFromPoint(CursorInfo.Position, MONITOR_FROM_FLAGS.MONITOR_DEFAULTTONEAREST);
if (!PInvoke.GetCursorPos(out var pt))
{
Marshal.ThrowExceptionForHR(Marshal.GetLastWin32Error());
}
var cursorMonitor = PInvoke.MonitorFromPoint(pt, MONITOR_FROM_FLAGS.MONITOR_DEFAULTTONEAREST);
MonitorInfo cursorMonitorInfo = null;
var callback = new MONITORENUMPROC((monitor, deviceContext, rect, data) =>
{