Skip to content
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion src/ConsoleMode/ConsoleMode.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
<ItemGroup>
<EmbeddedResource Include="..\..\assets\icon.ico" LogicalName="ConsoleMode.Assets.icon.ico" />
<EmbeddedResource Include="Assets\OtherApps\*.png" LogicalName="ConsoleMode.Assets.OtherApps.%(Filename)%(Extension)" />
<EmbeddedResource Include="..\..\artifacts\tools\*.exe" LogicalName="ConsoleMode.Tools.%(Filename)%(Extension)" />
<EmbeddedResource Include="..\..\artifacts\tools\rtss-cli*.exe" LogicalName="ConsoleMode.Tools.%(Filename)%(Extension)" />
<EmbeddedResource Include="Resources\Strings.pt-BR.json" WithCulture="false" LogicalName="ConsoleMode.Localization.Strings.pt-BR.json" />
<EmbeddedResource Include="Resources\Strings.en-US.json" WithCulture="false" LogicalName="ConsoleMode.Localization.Strings.en-US.json" />
<EmbeddedResource Include="Resources\Strings.es-ES.json" WithCulture="false" LogicalName="ConsoleMode.Localization.Strings.es-ES.json" />
Expand Down
9 changes: 9 additions & 0 deletions src/ConsoleMode/Native/NativeDisplays.cs
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,15 @@ private static (string Friendly, string DevicePath) GetTargetName(LUID adapterId
: ("", "");
}

/// <summary>Windows' own primary flag (MONITORINFOF_PRIMARY); position (0,0) is ambiguous when screens are cloned.</summary>
public static bool IsPrimary(string gdiName)
{
var hMonitor = FindHMonitor(gdiName);
if (hMonitor == 0) return false;
var info = new MONITORINFOEX { cbSize = Marshal.SizeOf<MONITORINFOEX>() };
return GetMonitorInfo(hMonitor, ref info) && (info.dwFlags & 1) != 0;
}

private static nint FindHMonitor(string gdiName)
{
nint found = 0;
Expand Down
2 changes: 1 addition & 1 deletion src/ConsoleMode/Services/DisplayBackend.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public List<MonitorInfo> ListMonitors()
Height = height,
Frequency = current?.Frequency > 0 ? current.Frequency.ToString() : "",
Colors = current?.BitsPerPel > 0 ? current.BitsPerPel.ToString() : "",
IsPrimary = m.IsActive && m.PositionX == 0 && m.PositionY == 0,
IsPrimary = m.IsActive && NativeDisplays.IsPrimary(m.GdiName),
IsActive = m.IsActive,
IsDisconnected = !m.IsActive,
MonitorName = !string.IsNullOrWhiteSpace(m.FriendlyName) ? m.FriendlyName : edid.Name,
Expand Down
Loading