Remove GetPhysicalHandle from PhysicalMonitorHandleManager

Eliminated the GetPhysicalHandle method, which handled monitor handle lookup by Id or direct handle. This refactors PhysicalMonitorHandleManager to no longer provide handle retrieval logic.
This commit is contained in:
Yu Leng
2025-12-10 19:09:58 +08:00
parent 6aa7e2cdf6
commit 762a6bce0c

View File

@@ -5,7 +5,6 @@
using System;
using System.Collections.Generic;
using ManagedCommon;
using PowerDisplay.Common.Models;
using PowerDisplay.Common.Utils;
using static PowerDisplay.Common.Drivers.PInvoke;
@@ -20,27 +19,6 @@ namespace PowerDisplay.Common.Drivers.DDC
private readonly LockedDictionary<string, IntPtr> _monitorIdToHandleMap = new();
private bool _disposed;
/// <summary>
/// Get physical handle for monitor using its unique Id
/// </summary>
public IntPtr GetPhysicalHandle(Monitor monitor)
{
// Primary lookup: use monitor Id
if (!string.IsNullOrEmpty(monitor.Id) &&
_monitorIdToHandleMap.TryGetValue(monitor.Id, out var handle))
{
return handle;
}
// Fallback: use direct handle from monitor object
if (monitor.Handle != IntPtr.Zero)
{
return monitor.Handle;
}
return IntPtr.Zero;
}
/// <summary>
/// Update the handle mapping with new handles
/// </summary>