Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[feature request] CoreGraphics: implement CGDisplayMode / CGDisplayModeGetRefreshRate #9958

Open
janusw opened this issue Oct 25, 2020 · 1 comment
Assignees
Labels
enhancement The issue or pull request is an enhancement good first issue This is a good first issue for someone to start working with our code macOS Issues affecting Xamarin.Mac missing-api-bindings
Milestone

Comments

@janusw
Copy link

janusw commented Oct 25, 2020

It seems that CoreGraphics support is incomplete in Xamarin.Mac. Searching for CGDisplayModeGetRefreshRate in the github repo only gives me one hit:

https://github.com/xamarin/xamarin-macios/blob/main/tests/xtro-sharpie/macOS-CoreGraphics.ignore: !missing-pinvoke! CGDisplayModeGetRefreshRate is not bound

Background: I want to determine the screen refresh rate on MacOS via the Xamarin APIs. CoreGraphics has a function to accomplish that: CGDisplayModeGetRefreshRate. In Swift this is part of the class CGDisplayMode.

@chamons chamons added the enhancement The issue or pull request is an enhancement label Oct 26, 2020
@chamons chamons added this to the Future milestone Oct 26, 2020
@chamons chamons added the macOS Issues affecting Xamarin.Mac label Oct 26, 2020
@chamons
Copy link
Contributor

chamons commented Oct 26, 2020

I looked at implementing this, but as Xamarin.Mac is currently disabled in Main until Xcode 12.2 land (due to last minute removal of bound APIs by Apple) it isn't a good time to land it.

Here my untested diff:

https://git.io/JT6EB

mattleibow added a commit to janusw/Essentials that referenced this issue Jan 19, 2021
mattleibow added a commit to xamarin/Essentials that referenced this issue Jan 25, 2021
* DisplayInfo: add a property 'RefreshRate' (#1443)
* Samples: show RefreshRate on DeviceInfoPage (#1443)
* Add documentation for DisplayInfo.RefreshRate (#1443)
* Add the logic to read the macos refresh rate
  Based on xamarin-macios issue: xamarin/xamarin-macios#9958
  Copied code from: https://gist.github.com/chamons/1eae64a2e5e10cbaf18b140e92ec4ca3
* Try to guess the Hz, but fall back to 60
  This is not the most correct way, but is probably good enough. If there are any better ways in future, we can just add them in or replace this logic.

Co-authored-by: Matthew Leibowitz <mattleibow@live.com>
@rolfbjarne rolfbjarne added good first issue This is a good first issue for someone to start working with our code missing-api-bindings labels Oct 6, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement The issue or pull request is an enhancement good first issue This is a good first issue for someone to start working with our code macOS Issues affecting Xamarin.Mac missing-api-bindings
Projects
None yet
Development

No branches or pull requests

4 participants