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

Add getMax to fetch maximum/native resolution #33

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

ghostwriternr
Copy link

Changes

Fetch max supported mode for each monitor

Newer versions of MacOS use a scaling factor (like 2x, which is the
default for newer MacBooks), leading to the default mode being half the
native resolution of the display. In such cases, it would be desirable
to fetch the maximum resolution supported by the display (native
resolution).

Add a getMax option to fetch this information.

Avoid de-reference in _compareCFDisplayModes

Currently, the _compareCFDisplayModes method uses CGDisplayModeRef*
as the first and second parameters, in alignment with the
CFComparatorFunction type alias declaration expecting an
UnsafeRawPointer. But CGDisplayModeRef is already a pointer to
CGDisplayMode and doesn't need a reference again to work as a
comparator. Doing so also introduces extra referencing and dereferencing
that can be avoided.

Currently, the _compareCFDisplayModes method uses CGDisplayModeRef* as
the first and second parameters, in alignment with the
CFComparatorFunction type alias declaration expecting an
UnsafeRawPointer. But CGDisplayModeRef is already a pointer to
CGDisplayMode and doesn't need a reference again to work as a
comparator. Doing so also introduces extra referencing and dereferencing
that can be avoided.

Update the method signature to pass CGDisplayModeRef directly.
Newer versions of MacOS use a scaling factor (like 2x, which is the
default for newer MacBooks), leading to the default mode being half the
native resolution of the display. In such cases, it would be desirable
to fetch the maximum resolution supported by the display (native
resolution).

Add a getMax option to fetch this information.
@ghostwriternr
Copy link
Author

ghostwriternr commented Jun 6, 2020

Quick note: I have little to no experience with C, much less Apple Dev tools. I have been using the neofetch script for years, which depends on this library, and has lately been showing incorrect resolutions due to Apple's latest changes. So rather than adding workarounds, I wanted to add support for this at the source, if possible.

Please do let me know if this could have been done in a better way, as well as major code improvements.

@ghostwriternr
Copy link
Author

@jhford gentle nudge to review when you can : )

@ghostwriternr
Copy link
Author

Bump.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant