Skip to content

Instantly share code, notes, and snippets.

@chamons

chamons/foo.diff Secret

Created October 26, 2020 20:54
Show Gist options
  • Save chamons/1eae64a2e5e10cbaf18b140e92ec4ca3 to your computer and use it in GitHub Desktop.
Save chamons/1eae64a2e5e10cbaf18b140e92ec4ca3 to your computer and use it in GitHub Desktop.
diff --git a/src/CoreGraphics/CGDisplay.cs b/src/CoreGraphics/CGDisplay.cs
index 6bfad44f8..8fdef17be 100644
--- a/src/CoreGraphics/CGDisplay.cs
+++ b/src/CoreGraphics/CGDisplay.cs
@@ -167,6 +167,23 @@ namespace CoreGraphics
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);
+
+ public static double RefreshRate (int display)
+ {
+ IntPtr mode = CGDisplayCopyDisplayMode((uint)display);
+ double refreshRate = CGDisplayModeGetRefreshRate (mode);
+ CGDisplayModeRelease (mode);
+ return refreshRate;
+ }
#endif
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment