// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. namespace Microsoft.Maui.Platform.Linux.Services; /// /// Represents information about a display monitor. /// public record MonitorInfo { /// /// Gets the unique identifier for this monitor (XRandR output ID). /// public ulong Id { get; init; } /// /// Gets the monitor name (e.g., "HDMI-1", "DP-2", "eDP-1"). /// public string Name { get; init; } = string.Empty; /// /// Gets whether this is the primary monitor. /// public bool IsPrimary { get; init; } /// /// Gets the X position of the monitor in the virtual desktop. /// public int X { get; init; } /// /// Gets the Y position of the monitor in the virtual desktop. /// public int Y { get; init; } /// /// Gets the width in pixels. /// public int Width { get; init; } /// /// Gets the height in pixels. /// public int Height { get; init; } /// /// Gets the physical width in millimeters. /// public int PhysicalWidthMm { get; init; } /// /// Gets the physical height in millimeters. /// public int PhysicalHeightMm { get; init; } /// /// Gets the refresh rate in Hz. /// public double RefreshRate { get; init; } /// /// Gets the horizontal DPI. /// public double DpiX { get { if (PhysicalWidthMm <= 0) return 96.0; return Width / (PhysicalWidthMm / 25.4); } } /// /// Gets the vertical DPI. /// public double DpiY { get { if (PhysicalHeightMm <= 0) return 96.0; return Height / (PhysicalHeightMm / 25.4); } } /// /// Gets the average DPI. /// public double Dpi => (DpiX + DpiY) / 2.0; /// /// Gets the scale factor based on DPI (1.0 = 96 DPI). /// public double ScaleFactor => Dpi / 96.0; /// /// Gets the bounds rectangle. /// public (int X, int Y, int Width, int Height) Bounds => (X, Y, Width, Height); public override string ToString() { return $"{Name}: {Width}x{Height}+{X}+{Y} @ {RefreshRate:F1}Hz ({Dpi:F0} DPI){(IsPrimary ? " [Primary]" : "")}"; } }