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
22 changes: 22 additions & 0 deletions src/CoreGraphics/CGDisplay.cs
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,28 @@ public static int GetShieldingWindowID (int display)
public static int ShieldingWindowLevel {
get { return CGShieldingWindowLevel (); }
}

[DllImport (Constants.CoreGraphicsLibrary)]
extern static IntPtr CGDisplayCopyDisplayMode (uint display);

[DllImport (Constants.CoreGraphicsLibrary)]
extern static void CGDisplayModeRelease (IntPtr mode);

[DllImport (Constants.CoreGraphicsLibrary)]
extern static double CGDisplayModeGetRefreshRate (IntPtr mode);

/// <summary>Get the refresh rate for the specified display.</summary>
/// <param name="display">The identifier for the display.</param>
/// <returns>The display rate, in hertz, of the specified display, or <see langword="null" /> in case of failure.</returns>
public static double? GetRefreshRate (int display)
{
var mode = CGDisplayCopyDisplayMode ((uint) display);
if (mode == IntPtr.Zero)
return null;
var refreshRate = CGDisplayModeGetRefreshRate (mode);
CGDisplayModeRelease (mode);
return refreshRate;
}
#endif
}
}
Expand Down
28 changes: 28 additions & 0 deletions tests/monotouch-test/CoreGraphics/CGDisplayTest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

using System;

using Foundation;
using ObjCRuntime;
using CoreGraphics;

using NUnit.Framework;

#if __MONOMAC__ || __MACCATALYST__

namespace MonoTouchFixtures.CoreGraphics {

[TestFixture]
[Preserve (AllMembers = true)]
public class CGDisplayTest {

[Test]
public void GetRefreshRate ()
{
Assert.That (CGDisplay.GetRefreshRate (CGDisplay.MainDisplayID), Is.Not.EqualTo (0), "RefreshRate");
}
}
}

#endif // __MONOMAC__ || __MACCATALYST__
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@
!missing-pinvoke! CGDirectDisplayCopyCurrentMetalDevice is not bound
!missing-pinvoke! CGDisplayCopyAllDisplayModes is not bound
!missing-pinvoke! CGDisplayCopyColorSpace is not bound
!missing-pinvoke! CGDisplayCopyDisplayMode is not bound
!missing-pinvoke! CGDisplayFade is not bound
!missing-pinvoke! CGDisplayGetDrawingContext is not bound
!missing-pinvoke! CGDisplayIsActive is not bound
Expand All @@ -54,10 +53,8 @@
!missing-pinvoke! CGDisplayModeGetIOFlags is not bound
!missing-pinvoke! CGDisplayModeGetPixelHeight is not bound
!missing-pinvoke! CGDisplayModeGetPixelWidth is not bound
!missing-pinvoke! CGDisplayModeGetRefreshRate is not bound
!missing-pinvoke! CGDisplayModeGetWidth is not bound
!missing-pinvoke! CGDisplayModeIsUsableForDesktopGUI is not bound
!missing-pinvoke! CGDisplayModeRelease is not bound
!missing-pinvoke! CGDisplayModeRetain is not bound
!missing-pinvoke! CGDisplayModelNumber is not bound
!missing-pinvoke! CGDisplayPrimaryDisplay is not bound
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
!missing-pinvoke! CGDirectDisplayCopyCurrentMetalDevice is not bound
!missing-pinvoke! CGDisplayCopyAllDisplayModes is not bound
!missing-pinvoke! CGDisplayCopyColorSpace is not bound
!missing-pinvoke! CGDisplayCopyDisplayMode is not bound
!missing-pinvoke! CGDisplayFade is not bound
!missing-pinvoke! CGDisplayGetDrawingContext is not bound
!missing-pinvoke! CGDisplayIsActive is not bound
Expand All @@ -53,11 +52,9 @@
!missing-pinvoke! CGDisplayModeGetIOFlags is not bound
!missing-pinvoke! CGDisplayModeGetPixelHeight is not bound
!missing-pinvoke! CGDisplayModeGetPixelWidth is not bound
!missing-pinvoke! CGDisplayModeGetRefreshRate is not bound
!missing-pinvoke! CGDisplayModeGetWidth is not bound
!missing-pinvoke! CGDisplayModeIsUsableForDesktopGUI is not bound
!missing-pinvoke! CGDisplayModelNumber is not bound
!missing-pinvoke! CGDisplayModeRelease is not bound
!missing-pinvoke! CGDisplayModeRetain is not bound
!missing-pinvoke! CGDisplayPrimaryDisplay is not bound
!missing-pinvoke! CGDisplayRegisterReconfigurationCallback is not bound
Expand Down
Loading