Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 16 additions & 2 deletions Helpers/DisplayDeviceHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,22 @@ public static ScaleFactor GetScaleFactorFromWindow(nint hwnd)

public static string GetMonitorColorProfileFromWindow(Window window)
{
var hMonitor = MonitorFromWindow(new WindowInteropHelper(window).EnsureHandle(), MonitorDefaults.TONEAREST);
return GetMonitorColorProfile(hMonitor);
try
{
var hMonitor = MonitorFromWindow(new WindowInteropHelper(window).EnsureHandle(), MonitorDefaults.TONEAREST);
Copy link

Copilot AI Feb 7, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Replace this call with a call to managed code if possible.

Copilot uses AI. Check for mistakes.
return GetMonitorColorProfile(hMonitor);
}
catch (COMException ex) when (ex.HResult == unchecked((int)0x80263001))
{
// Desktop composition is disabled (e.g., during eGPU reconnection)
ProcessHelper.WriteLog("Failed to get color profile: Desktop composition is disabled. This is expected during display reconfiguration.");
return null;
Comment on lines +85 to +89
Copy link

Copilot AI Feb 7, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The HRESULT check uses a magic number and ex.HResult. For readability and to make the intent explicit (DWM_E_COMPOSITIONDISABLED = 0x80263001), consider introducing a named constant (or enum) and using COMException.ErrorCode in the filter instead of HResult.

Copilot uses AI. Check for mistakes.
}
catch (Exception ex)
{
ProcessHelper.WriteLog($"Failed to get monitor color profile: {ex}");
return null;
}
}

public static string GetMonitorColorProfile(nint hMonitor)
Expand Down
Loading