Skip to content

Commit 4f423c4

Browse files
committed
Allow all projects to access MonitorInfo & CursorInfo
1 parent cbbd09b commit 4f423c4

File tree

4 files changed

+16
-13
lines changed

4 files changed

+16
-13
lines changed

Flow.Launcher.Infrastructure/NativeMethods.txt

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -34,14 +34,6 @@ WINDOW_STYLE
3434
SetLastError
3535
WINDOW_EX_STYLE
3636

37-
GetSystemMetrics
38-
EnumDisplayMonitors
39-
MonitorFromWindow
40-
GetMonitorInfo
41-
MONITORINFOEXW
42-
GetCursorPos
43-
MonitorFromPoint
44-
4537
WM_ENTERSIZEMOVE
4638
WM_EXITSIZEMOVE
4739
WM_NCLBUTTONDBLCLK

Flow.Launcher.Plugin/NativeMethods.txt

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,12 @@ GetWindowTextLength
55
WM_KEYDOWN
66
WM_KEYUP
77
WM_SYSKEYDOWN
8-
WM_SYSKEYUP
8+
WM_SYSKEYUP
9+
10+
GetSystemMetrics
11+
EnumDisplayMonitors
12+
MonitorFromWindow
13+
GetMonitorInfo
14+
MONITORINFOEXW
15+
GetCursorPos
16+
MonitorFromPoint

Flow.Launcher.Infrastructure/CursorInfo.cs renamed to Flow.Launcher.Plugin/SharedModels/CursorInfo.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
using System.Runtime.InteropServices;
33
using Windows.Win32;
44

5-
namespace Flow.Launcher.Infrastructure;
5+
namespace Flow.Launcher.Plugin.SharedModels;
66

77
/// <summary>
88
/// Contains full information about a cursor.
@@ -12,6 +12,9 @@ namespace Flow.Launcher.Infrastructure;
1212
/// </remarks>
1313
public class CursorInfo
1414
{
15+
/// <summary>
16+
/// Gets the current position of the cursor in screen coordinates.
17+
/// </summary>
1518
public static Point Position
1619
{
1720
get

Flow.Launcher.Infrastructure/MonitorInfo.cs renamed to Flow.Launcher.Plugin/SharedModels/MonitorInfo.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
using Windows.Win32.Graphics.Gdi;
88
using Windows.Win32.UI.WindowsAndMessaging;
99

10-
namespace Flow.Launcher.Infrastructure;
10+
namespace Flow.Launcher.Plugin.SharedModels;
1111

1212
/// <summary>
1313
/// Contains full information about a display monitor.
@@ -75,7 +75,7 @@ public static unsafe MonitorInfo GetNearestDisplayMonitor(nint hwnd)
7575
/// <returns>The primary display monitor, or null if no monitor is found.</returns>
7676
public static unsafe MonitorInfo GetPrimaryDisplayMonitor()
7777
{
78-
var primaryMonitor = PInvoke.MonitorFromWindow(new HWND(IntPtr.Zero), MONITOR_FROM_FLAGS.MONITOR_DEFAULTTOPRIMARY);
78+
var primaryMonitor = PInvoke.MonitorFromWindow(new HWND(nint.Zero), MONITOR_FROM_FLAGS.MONITOR_DEFAULTTOPRIMARY);
7979
MonitorInfo primaryMonitorInfo = null;
8080
var callback = new MONITORENUMPROC((monitor, deviceContext, rect, data) =>
8181
{
@@ -163,7 +163,7 @@ internal unsafe MonitorInfo(HMONITOR monitor, RECT* rect)
163163
/// <summary>
164164
/// Gets if the monitor is the primary display monitor.
165165
/// </summary>
166-
public bool IsPrimary => _monitor == PInvoke.MonitorFromWindow(new(IntPtr.Zero), MONITOR_FROM_FLAGS.MONITOR_DEFAULTTOPRIMARY);
166+
public bool IsPrimary => _monitor == PInvoke.MonitorFromWindow(new(nint.Zero), MONITOR_FROM_FLAGS.MONITOR_DEFAULTTOPRIMARY);
167167

168168
/// <inheritdoc />
169169
public override string ToString() => $"{Name} {Bounds.Width}x{Bounds.Height}";

0 commit comments

Comments
 (0)