From 401e2c325b06b7c12d3cf47b263d54d7b1190189 Mon Sep 17 00:00:00 2001 From: HarishwaranVijayakumar Date: Thu, 18 Sep 2025 13:59:55 +0530 Subject: [PATCH 1/8] Fix for MainDisplayInfoChanged event --- .../src/DeviceDisplay/DeviceDisplay.ios.cs | 110 ++++++++++++++++++ .../src/Types/DisplayInfo.shared.cs | 3 +- 2 files changed, 112 insertions(+), 1 deletion(-) diff --git a/src/Essentials/src/DeviceDisplay/DeviceDisplay.ios.cs b/src/Essentials/src/DeviceDisplay/DeviceDisplay.ios.cs index 7f8d73410ba6..a1fb249613aa 100644 --- a/src/Essentials/src/DeviceDisplay/DeviceDisplay.ios.cs +++ b/src/Essentials/src/DeviceDisplay/DeviceDisplay.ios.cs @@ -1,5 +1,6 @@ #nullable enable using System; +using System.Runtime.InteropServices; using Foundation; using UIKit; @@ -43,6 +44,38 @@ protected override void SetKeepScreenOn(bool keepScreenOn) } } #else +#if MACCATALYST + // Core Graphics P/Invoke declarations for Mac Catalyst + // Returns the display ID of the main display + [DllImport("/System/Library/Frameworks/CoreGraphics.framework/CoreGraphics")] + static extern uint CGMainDisplayID(); + + // Returns information about a display’s current configuration + [DllImport("/System/Library/Frameworks/CoreGraphics.framework/CoreGraphics")] + static extern IntPtr CGDisplayCopyDisplayMode(uint display); + + // Releases a Core Graphics display mode + [DllImport("/System/Library/Frameworks/CoreGraphics.framework/CoreGraphics")] + static extern void CGDisplayModeRelease(IntPtr mode); + + // Returns the width of the specified display mode + [DllImport("/System/Library/Frameworks/CoreGraphics.framework/CoreGraphics")] + static extern nuint CGDisplayModeGetWidth(IntPtr mode); + + // Returns the height of the specified display mode + [DllImport("/System/Library/Frameworks/CoreGraphics.framework/CoreGraphics")] + static extern nuint CGDisplayModeGetHeight(IntPtr mode); + + // Returns the refresh rate of the specified display mode + [DllImport("/System/Library/Frameworks/CoreGraphics.framework/CoreGraphics")] + static extern double CGDisplayModeGetRefreshRate(IntPtr mode); + + // Returns the rotation angle of a display in degrees + [DllImport("/System/Library/Frameworks/CoreGraphics.framework/CoreGraphics")] + static extern double CGDisplayRotation(uint display); + +#endif + protected override bool GetKeepScreenOn() => UIApplication.SharedApplication.IdleTimerDisabled; protected override void SetKeepScreenOn(bool keepScreenOn) => UIApplication.SharedApplication.IdleTimerDisabled = keepScreenOn; @@ -50,6 +83,75 @@ protected override void SetKeepScreenOn(bool keepScreenOn) protected override DisplayInfo GetMainDisplayInfo() { +#if MACCATALYST + // On Mac Catalyst, bypass UIScreen entirely and use Core Graphics APIs + // This gets fresh, non-cached screen information directly from the system + var displayId = CGMainDisplayID(); + var mode = CGDisplayCopyDisplayMode(displayId); + + if (mode == IntPtr.Zero) + { + System.Diagnostics.Debug.WriteLine("[DeviceDisplay] Failed to get display mode, falling back to UIScreen"); + return GetFallbackDisplayInfo(); + } + + var width = (double)CGDisplayModeGetWidth(mode); + var height = (double)CGDisplayModeGetHeight(mode); + var refreshRate = CGDisplayModeGetRefreshRate(mode); + + // Release the display mode to avoid memory leaks + CGDisplayModeRelease(mode); + + // Get rotation from Core Graphics + var rotationDegrees = CGDisplayRotation(displayId); + var rotation = ConvertRotationDegreesToDisplayRotation(rotationDegrees); + + // Get scale factor from UIScreen as a fallback (this is usually stable) + var scale = UIScreen.MainScreen.Scale; + + // For Mac Catalyst, calculate orientation based on actual dimensions and rotation + var orientation = CalculateOrientationFromDimensionsAndRotation(width, height, rotationDegrees); + + return new DisplayInfo( + width: width, + height: height, + density: scale, + orientation: orientation, + rotation: rotation, + rate: (float)refreshRate); +#else + // iOS implementation + return GetFallbackDisplayInfo(); +#endif + } + + static DisplayRotation ConvertRotationDegreesToDisplayRotation(double degrees) => + degrees switch + { + 0 => DisplayRotation.Rotation0, + 90 => DisplayRotation.Rotation90, + 180 => DisplayRotation.Rotation180, + 270 => DisplayRotation.Rotation270, + _ => DisplayRotation.Rotation0 + }; + + static DisplayOrientation CalculateOrientationFromDimensionsAndRotation(double width, double height, double rotationDegrees) + { + // For 90° and 270° rotations, the effective orientation is swapped + if (rotationDegrees == 90 || rotationDegrees == 270) + { + // Swap width and height for orientation calculation + return height >= width ? DisplayOrientation.Landscape : DisplayOrientation.Portrait; + } + else + { + // 0° and 180° rotations don't change the orientation + return width >= height ? DisplayOrientation.Landscape : DisplayOrientation.Portrait; + } + } + + DisplayInfo GetFallbackDisplayInfo() + { var bounds = UIScreen.MainScreen.Bounds; var scale = UIScreen.MainScreen.Scale; @@ -70,8 +172,16 @@ protected override DisplayInfo GetMainDisplayInfo() protected override void StartScreenMetricsListeners() { var notificationCenter = NSNotificationCenter.DefaultCenter; + +#if MACCATALYST + // On Mac Catalyst, use multiple notifications to cover all display changes + // NSApplicationDidChangeScreenParametersNotification - for resolution/refresh rate changes + observer = notificationCenter.AddObserver(new NSString("NSApplicationDidChangeScreenParametersNotification"), OnMainDisplayInfoChanged); +#else + // On iOS, use status bar orientation changes (deprecated but still works) var notification = UIApplication.DidChangeStatusBarOrientationNotification; observer = notificationCenter.AddObserver(notification, OnMainDisplayInfoChanged); +#endif } protected override void StopScreenMetricsListeners() diff --git a/src/Essentials/src/Types/DisplayInfo.shared.cs b/src/Essentials/src/Types/DisplayInfo.shared.cs index 2cfa915f7c01..00ec7ce1514f 100644 --- a/src/Essentials/src/Types/DisplayInfo.shared.cs +++ b/src/Essentials/src/Types/DisplayInfo.shared.cs @@ -113,7 +113,8 @@ public bool Equals(DisplayInfo other) => Height.Equals(other.Height) && Density.Equals(other.Density) && Orientation.Equals(other.Orientation) && - Rotation.Equals(other.Rotation); + Rotation.Equals(other.Rotation) && + RefreshRate.Equals(other.RefreshRate); /// /// Gets the hash code for this display info instance. From f7787ce797c45ec4c3b9a83e251b12ef256a5f6f Mon Sep 17 00:00:00 2001 From: HarishwaranVijayakumar Date: Mon, 22 Sep 2025 17:07:46 +0530 Subject: [PATCH 2/8] Modify to Constants --- .../src/DeviceDisplay/DeviceDisplay.ios.cs | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/Essentials/src/DeviceDisplay/DeviceDisplay.ios.cs b/src/Essentials/src/DeviceDisplay/DeviceDisplay.ios.cs index a1fb249613aa..7d42c7d227e4 100644 --- a/src/Essentials/src/DeviceDisplay/DeviceDisplay.ios.cs +++ b/src/Essentials/src/DeviceDisplay/DeviceDisplay.ios.cs @@ -3,6 +3,7 @@ using System.Runtime.InteropServices; using Foundation; using UIKit; +using ObjCRuntime; namespace Microsoft.Maui.Devices { @@ -47,31 +48,31 @@ protected override void SetKeepScreenOn(bool keepScreenOn) #if MACCATALYST // Core Graphics P/Invoke declarations for Mac Catalyst // Returns the display ID of the main display - [DllImport("/System/Library/Frameworks/CoreGraphics.framework/CoreGraphics")] + [DllImport(Constants.CoreGraphicsLibrary)] static extern uint CGMainDisplayID(); // Returns information about a display’s current configuration - [DllImport("/System/Library/Frameworks/CoreGraphics.framework/CoreGraphics")] + [DllImport(Constants.CoreGraphicsLibrary)] static extern IntPtr CGDisplayCopyDisplayMode(uint display); // Releases a Core Graphics display mode - [DllImport("/System/Library/Frameworks/CoreGraphics.framework/CoreGraphics")] + [DllImport(Constants.CoreGraphicsLibrary)] static extern void CGDisplayModeRelease(IntPtr mode); // Returns the width of the specified display mode - [DllImport("/System/Library/Frameworks/CoreGraphics.framework/CoreGraphics")] + [DllImport(Constants.CoreGraphicsLibrary)] static extern nuint CGDisplayModeGetWidth(IntPtr mode); // Returns the height of the specified display mode - [DllImport("/System/Library/Frameworks/CoreGraphics.framework/CoreGraphics")] + [DllImport(Constants.CoreGraphicsLibrary)] static extern nuint CGDisplayModeGetHeight(IntPtr mode); // Returns the refresh rate of the specified display mode - [DllImport("/System/Library/Frameworks/CoreGraphics.framework/CoreGraphics")] + [DllImport(Constants.CoreGraphicsLibrary)] static extern double CGDisplayModeGetRefreshRate(IntPtr mode); // Returns the rotation angle of a display in degrees - [DllImport("/System/Library/Frameworks/CoreGraphics.framework/CoreGraphics")] + [DllImport(Constants.CoreGraphicsLibrary)] static extern double CGDisplayRotation(uint display); #endif From 7e127dbd9db6b0824f5db2a835f14340ba4232e7 Mon Sep 17 00:00:00 2001 From: HarishwaranVijayakumar Date: Fri, 26 Sep 2025 13:19:39 +0530 Subject: [PATCH 3/8] Removing unwanted line --- src/Essentials/src/DeviceDisplay/DeviceDisplay.ios.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/src/Essentials/src/DeviceDisplay/DeviceDisplay.ios.cs b/src/Essentials/src/DeviceDisplay/DeviceDisplay.ios.cs index 7d42c7d227e4..ffab14df559b 100644 --- a/src/Essentials/src/DeviceDisplay/DeviceDisplay.ios.cs +++ b/src/Essentials/src/DeviceDisplay/DeviceDisplay.ios.cs @@ -92,7 +92,6 @@ protected override DisplayInfo GetMainDisplayInfo() if (mode == IntPtr.Zero) { - System.Diagnostics.Debug.WriteLine("[DeviceDisplay] Failed to get display mode, falling back to UIScreen"); return GetFallbackDisplayInfo(); } From 24578c5c23fef518a8d2721a54cfdad4c7d6abf8 Mon Sep 17 00:00:00 2001 From: HarishwaranVijayakumar Date: Wed, 1 Oct 2025 12:10:47 +0530 Subject: [PATCH 4/8] Modified the code and removed unwanted code --- .../src/DeviceDisplay/DeviceDisplay.ios.cs | 20 +------------------ 1 file changed, 1 insertion(+), 19 deletions(-) diff --git a/src/Essentials/src/DeviceDisplay/DeviceDisplay.ios.cs b/src/Essentials/src/DeviceDisplay/DeviceDisplay.ios.cs index ffab14df559b..644ad0084724 100644 --- a/src/Essentials/src/DeviceDisplay/DeviceDisplay.ios.cs +++ b/src/Essentials/src/DeviceDisplay/DeviceDisplay.ios.cs @@ -109,14 +109,11 @@ protected override DisplayInfo GetMainDisplayInfo() // Get scale factor from UIScreen as a fallback (this is usually stable) var scale = UIScreen.MainScreen.Scale; - // For Mac Catalyst, calculate orientation based on actual dimensions and rotation - var orientation = CalculateOrientationFromDimensionsAndRotation(width, height, rotationDegrees); - return new DisplayInfo( width: width, height: height, density: scale, - orientation: orientation, + orientation: DisplayOrientation.Portrait, rotation: rotation, rate: (float)refreshRate); #else @@ -135,21 +132,6 @@ static DisplayRotation ConvertRotationDegreesToDisplayRotation(double degrees) = _ => DisplayRotation.Rotation0 }; - static DisplayOrientation CalculateOrientationFromDimensionsAndRotation(double width, double height, double rotationDegrees) - { - // For 90° and 270° rotations, the effective orientation is swapped - if (rotationDegrees == 90 || rotationDegrees == 270) - { - // Swap width and height for orientation calculation - return height >= width ? DisplayOrientation.Landscape : DisplayOrientation.Portrait; - } - else - { - // 0° and 180° rotations don't change the orientation - return width >= height ? DisplayOrientation.Landscape : DisplayOrientation.Portrait; - } - } - DisplayInfo GetFallbackDisplayInfo() { var bounds = UIScreen.MainScreen.Bounds; From 8022ab02f336295aca9c26bda58b02ac1aada79d Mon Sep 17 00:00:00 2001 From: HarishwaranVijayakumar Date: Fri, 3 Oct 2025 18:28:48 +0530 Subject: [PATCH 5/8] Changed code to use const string --- src/Essentials/src/DeviceDisplay/DeviceDisplay.ios.cs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/Essentials/src/DeviceDisplay/DeviceDisplay.ios.cs b/src/Essentials/src/DeviceDisplay/DeviceDisplay.ios.cs index 644ad0084724..5ce93d2f4698 100644 --- a/src/Essentials/src/DeviceDisplay/DeviceDisplay.ios.cs +++ b/src/Essentials/src/DeviceDisplay/DeviceDisplay.ios.cs @@ -45,6 +45,10 @@ protected override void SetKeepScreenOn(bool keepScreenOn) } } #else +#if MACCATALYST + const string NSApplicationDidChangeScreenParametersNotification = "NSApplicationDidChangeScreenParametersNotification"; +#endif + #if MACCATALYST // Core Graphics P/Invoke declarations for Mac Catalyst // Returns the display ID of the main display @@ -158,7 +162,7 @@ protected override void StartScreenMetricsListeners() #if MACCATALYST // On Mac Catalyst, use multiple notifications to cover all display changes // NSApplicationDidChangeScreenParametersNotification - for resolution/refresh rate changes - observer = notificationCenter.AddObserver(new NSString("NSApplicationDidChangeScreenParametersNotification"), OnMainDisplayInfoChanged); + observer = notificationCenter.AddObserver(new NSString(NSApplicationDidChangeScreenParametersNotification), OnMainDisplayInfoChanged); #else // On iOS, use status bar orientation changes (deprecated but still works) var notification = UIApplication.DidChangeStatusBarOrientationNotification; From 7eb388be4c8c24b5b5b2532082a8c92df0a2cc81 Mon Sep 17 00:00:00 2001 From: HarishwaranVijayakumar Date: Thu, 26 Feb 2026 18:29:03 +0530 Subject: [PATCH 6/8] Address AI summary --- .../src/DeviceDisplay/DeviceDisplay.ios.cs | 56 +++++++++++-------- .../src/Types/DisplayInfo.shared.cs | 6 +- 2 files changed, 36 insertions(+), 26 deletions(-) diff --git a/src/Essentials/src/DeviceDisplay/DeviceDisplay.ios.cs b/src/Essentials/src/DeviceDisplay/DeviceDisplay.ios.cs index 5ce93d2f4698..c07df3b019b6 100644 --- a/src/Essentials/src/DeviceDisplay/DeviceDisplay.ios.cs +++ b/src/Essentials/src/DeviceDisplay/DeviceDisplay.ios.cs @@ -46,7 +46,8 @@ protected override void SetKeepScreenOn(bool keepScreenOn) } #else #if MACCATALYST - const string NSApplicationDidChangeScreenParametersNotification = "NSApplicationDidChangeScreenParametersNotification"; + static readonly NSString ScreenParametersChangedNotification = + new NSString("NSApplicationDidChangeScreenParametersNotification"); #endif #if MACCATALYST @@ -91,6 +92,8 @@ protected override DisplayInfo GetMainDisplayInfo() #if MACCATALYST // On Mac Catalyst, bypass UIScreen entirely and use Core Graphics APIs // This gets fresh, non-cached screen information directly from the system + // Note: CGMainDisplayID returns the primary display (with menu bar). + // In multi-monitor setups, this may not be the display the app window is on. var displayId = CGMainDisplayID(); var mode = CGDisplayCopyDisplayMode(displayId); @@ -99,27 +102,34 @@ protected override DisplayInfo GetMainDisplayInfo() return GetFallbackDisplayInfo(); } - var width = (double)CGDisplayModeGetWidth(mode); - var height = (double)CGDisplayModeGetHeight(mode); - var refreshRate = CGDisplayModeGetRefreshRate(mode); - - // Release the display mode to avoid memory leaks - CGDisplayModeRelease(mode); - - // Get rotation from Core Graphics - var rotationDegrees = CGDisplayRotation(displayId); - var rotation = ConvertRotationDegreesToDisplayRotation(rotationDegrees); - - // Get scale factor from UIScreen as a fallback (this is usually stable) - var scale = UIScreen.MainScreen.Scale; - - return new DisplayInfo( - width: width, - height: height, - density: scale, - orientation: DisplayOrientation.Portrait, - rotation: rotation, - rate: (float)refreshRate); + try + { + var width = (double)CGDisplayModeGetWidth(mode); + var height = (double)CGDisplayModeGetHeight(mode); + var refreshRate = CGDisplayModeGetRefreshRate(mode); + + // Get rotation from Core Graphics + var rotationDegrees = CGDisplayRotation(displayId); + var rotation = ConvertRotationDegreesToDisplayRotation(rotationDegrees); + + // Get scale factor from UIScreen as a fallback (this is usually stable) + var scale = UIScreen.MainScreen.Scale; + + return new DisplayInfo( + width: width, + height: height, + density: scale, + // Orientation is intentionally hardcoded to Portrait to match Xamarin's Mac Catalyst + // behavior. Deriving orientation from dimensions/rotation breaks existing tests and + // Mac desktop apps don't have a meaningful orientation concept. + orientation: DisplayOrientation.Portrait, + rotation: rotation, + rate: (float)refreshRate); + } + finally + { + CGDisplayModeRelease(mode); + } #else // iOS implementation return GetFallbackDisplayInfo(); @@ -162,7 +172,7 @@ protected override void StartScreenMetricsListeners() #if MACCATALYST // On Mac Catalyst, use multiple notifications to cover all display changes // NSApplicationDidChangeScreenParametersNotification - for resolution/refresh rate changes - observer = notificationCenter.AddObserver(new NSString(NSApplicationDidChangeScreenParametersNotification), OnMainDisplayInfoChanged); + observer = notificationCenter.AddObserver(ScreenParametersChangedNotification, OnMainDisplayInfoChanged); #else // On iOS, use status bar orientation changes (deprecated but still works) var notification = UIApplication.DidChangeStatusBarOrientationNotification; diff --git a/src/Essentials/src/Types/DisplayInfo.shared.cs b/src/Essentials/src/Types/DisplayInfo.shared.cs index 00ec7ce1514f..870555ca82dd 100644 --- a/src/Essentials/src/Types/DisplayInfo.shared.cs +++ b/src/Essentials/src/Types/DisplayInfo.shared.cs @@ -107,7 +107,7 @@ public override bool Equals(object obj) => /// /// object to compare with. /// if they are equal, otherwise . - /// Equality is established by comparing if , , , and are all equal. + /// Equality is established by comparing if , , , , and are all equal. public bool Equals(DisplayInfo other) => Width.Equals(other.Width) && Height.Equals(other.Height) && @@ -120,9 +120,9 @@ public bool Equals(DisplayInfo other) => /// Gets the hash code for this display info instance. /// /// The computed hash code for this device idiom or 0 when the device platform is . - /// The hash code is computed from , , , and . + /// The hash code is computed from , , , , and . public override int GetHashCode() => - (Height, Width, Density, Orientation, Rotation).GetHashCode(); + (Height, Width, Density, Orientation, Rotation, RefreshRate).GetHashCode(); /// /// Returns a string representation of the current values of this display info instance. From a5edd2f9512e05d61051e673cafd83113823ba08 Mon Sep 17 00:00:00 2001 From: HarishwaranVijayakumar Date: Wed, 1 Apr 2026 12:36:48 +0530 Subject: [PATCH 7/8] Remove refreshrate --- src/Essentials/src/Types/DisplayInfo.shared.cs | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/Essentials/src/Types/DisplayInfo.shared.cs b/src/Essentials/src/Types/DisplayInfo.shared.cs index 870555ca82dd..2cfa915f7c01 100644 --- a/src/Essentials/src/Types/DisplayInfo.shared.cs +++ b/src/Essentials/src/Types/DisplayInfo.shared.cs @@ -107,22 +107,21 @@ public override bool Equals(object obj) => /// /// object to compare with. /// if they are equal, otherwise . - /// Equality is established by comparing if , , , , and are all equal. + /// Equality is established by comparing if , , , and are all equal. public bool Equals(DisplayInfo other) => Width.Equals(other.Width) && Height.Equals(other.Height) && Density.Equals(other.Density) && Orientation.Equals(other.Orientation) && - Rotation.Equals(other.Rotation) && - RefreshRate.Equals(other.RefreshRate); + Rotation.Equals(other.Rotation); /// /// Gets the hash code for this display info instance. /// /// The computed hash code for this device idiom or 0 when the device platform is . - /// The hash code is computed from , , , , and . + /// The hash code is computed from , , , and . public override int GetHashCode() => - (Height, Width, Density, Orientation, Rotation, RefreshRate).GetHashCode(); + (Height, Width, Density, Orientation, Rotation).GetHashCode(); /// /// Returns a string representation of the current values of this display info instance. From 2acd1bf220d3522dab905c4e3b7f2987d654a128 Mon Sep 17 00:00:00 2001 From: HarishwaranVijayakumar Date: Tue, 26 May 2026 12:15:42 +0530 Subject: [PATCH 8/8] update fix --- .../src/DeviceDisplay/DeviceDisplay.ios.cs | 63 ++++++++----------- 1 file changed, 26 insertions(+), 37 deletions(-) diff --git a/src/Essentials/src/DeviceDisplay/DeviceDisplay.ios.cs b/src/Essentials/src/DeviceDisplay/DeviceDisplay.ios.cs index c07df3b019b6..27d2fb32a68b 100644 --- a/src/Essentials/src/DeviceDisplay/DeviceDisplay.ios.cs +++ b/src/Essentials/src/DeviceDisplay/DeviceDisplay.ios.cs @@ -10,7 +10,33 @@ namespace Microsoft.Maui.Devices partial class DeviceDisplayImplementation : IDeviceDisplay { NSObject? observer; + #if MACCATALYST + static readonly NSString ScreenParametersChangedNotification = + new NSString("NSApplicationDidChangeScreenParametersNotification"); + + // Core Graphics P/Invoke declarations for Mac Catalyst + [DllImport(Constants.CoreGraphicsLibrary)] + static extern uint CGMainDisplayID(); + + [DllImport(Constants.CoreGraphicsLibrary)] + static extern IntPtr CGDisplayCopyDisplayMode(uint display); + + [DllImport(Constants.CoreGraphicsLibrary)] + static extern void CGDisplayModeRelease(IntPtr mode); + + [DllImport(Constants.CoreGraphicsLibrary)] + static extern nuint CGDisplayModeGetWidth(IntPtr mode); + + [DllImport(Constants.CoreGraphicsLibrary)] + static extern nuint CGDisplayModeGetHeight(IntPtr mode); + + [DllImport(Constants.CoreGraphicsLibrary)] + static extern double CGDisplayModeGetRefreshRate(IntPtr mode); + + [DllImport(Constants.CoreGraphicsLibrary)] + static extern double CGDisplayRotation(uint display); + readonly object locker = new object(); NSObject? keepScreenOnActivity; @@ -45,43 +71,6 @@ protected override void SetKeepScreenOn(bool keepScreenOn) } } #else -#if MACCATALYST - static readonly NSString ScreenParametersChangedNotification = - new NSString("NSApplicationDidChangeScreenParametersNotification"); -#endif - -#if MACCATALYST - // Core Graphics P/Invoke declarations for Mac Catalyst - // Returns the display ID of the main display - [DllImport(Constants.CoreGraphicsLibrary)] - static extern uint CGMainDisplayID(); - - // Returns information about a display’s current configuration - [DllImport(Constants.CoreGraphicsLibrary)] - static extern IntPtr CGDisplayCopyDisplayMode(uint display); - - // Releases a Core Graphics display mode - [DllImport(Constants.CoreGraphicsLibrary)] - static extern void CGDisplayModeRelease(IntPtr mode); - - // Returns the width of the specified display mode - [DllImport(Constants.CoreGraphicsLibrary)] - static extern nuint CGDisplayModeGetWidth(IntPtr mode); - - // Returns the height of the specified display mode - [DllImport(Constants.CoreGraphicsLibrary)] - static extern nuint CGDisplayModeGetHeight(IntPtr mode); - - // Returns the refresh rate of the specified display mode - [DllImport(Constants.CoreGraphicsLibrary)] - static extern double CGDisplayModeGetRefreshRate(IntPtr mode); - - // Returns the rotation angle of a display in degrees - [DllImport(Constants.CoreGraphicsLibrary)] - static extern double CGDisplayRotation(uint display); - -#endif - protected override bool GetKeepScreenOn() => UIApplication.SharedApplication.IdleTimerDisabled; protected override void SetKeepScreenOn(bool keepScreenOn) => UIApplication.SharedApplication.IdleTimerDisabled = keepScreenOn;