Allow all projects to access MonitorInfo & CursorInfo

This commit is contained in:
Jack251970 2025-07-23 13:44:31 +08:00
parent cbbd09b8a5
commit 4f423c47cd
4 changed files with 16 additions and 13 deletions

View file

@ -34,14 +34,6 @@ WINDOW_STYLE
SetLastError
WINDOW_EX_STYLE
GetSystemMetrics
EnumDisplayMonitors
MonitorFromWindow
GetMonitorInfo
MONITORINFOEXW
GetCursorPos
MonitorFromPoint
WM_ENTERSIZEMOVE
WM_EXITSIZEMOVE
WM_NCLBUTTONDBLCLK

View file

@ -5,4 +5,12 @@ GetWindowTextLength
WM_KEYDOWN
WM_KEYUP
WM_SYSKEYDOWN
WM_SYSKEYUP
WM_SYSKEYUP
GetSystemMetrics
EnumDisplayMonitors
MonitorFromWindow
GetMonitorInfo
MONITORINFOEXW
GetCursorPos
MonitorFromPoint

View file

@ -2,7 +2,7 @@
using System.Runtime.InteropServices;
using Windows.Win32;
namespace Flow.Launcher.Infrastructure;
namespace Flow.Launcher.Plugin.SharedModels;
/// <summary>
/// Contains full information about a cursor.
@ -12,6 +12,9 @@ namespace Flow.Launcher.Infrastructure;
/// </remarks>
public class CursorInfo
{
/// <summary>
/// Gets the current position of the cursor in screen coordinates.
/// </summary>
public static Point Position
{
get

View file

@ -7,7 +7,7 @@ using Windows.Win32.Foundation;
using Windows.Win32.Graphics.Gdi;
using Windows.Win32.UI.WindowsAndMessaging;
namespace Flow.Launcher.Infrastructure;
namespace Flow.Launcher.Plugin.SharedModels;
/// <summary>
/// Contains full information about a display monitor.
@ -75,7 +75,7 @@ public class MonitorInfo
/// <returns>The primary display monitor, or null if no monitor is found.</returns>
public static unsafe MonitorInfo GetPrimaryDisplayMonitor()
{
var primaryMonitor = PInvoke.MonitorFromWindow(new HWND(IntPtr.Zero), MONITOR_FROM_FLAGS.MONITOR_DEFAULTTOPRIMARY);
var primaryMonitor = PInvoke.MonitorFromWindow(new HWND(nint.Zero), MONITOR_FROM_FLAGS.MONITOR_DEFAULTTOPRIMARY);
MonitorInfo primaryMonitorInfo = null;
var callback = new MONITORENUMPROC((monitor, deviceContext, rect, data) =>
{
@ -163,7 +163,7 @@ public class MonitorInfo
/// <summary>
/// Gets if the monitor is the primary display monitor.
/// </summary>
public bool IsPrimary => _monitor == PInvoke.MonitorFromWindow(new(IntPtr.Zero), MONITOR_FROM_FLAGS.MONITOR_DEFAULTTOPRIMARY);
public bool IsPrimary => _monitor == PInvoke.MonitorFromWindow(new(nint.Zero), MONITOR_FROM_FLAGS.MONITOR_DEFAULTTOPRIMARY);
/// <inheritdoc />
public override string ToString() => $"{Name} {Bounds.Width}x{Bounds.Height}";