Skip to content

Comments

Add getMax to fetch maximum/native resolution#33

Open
ghostwriternr wants to merge 2 commits intojhford:masterfrom
ghostwriternr:add-max
Open

Add getMax to fetch maximum/native resolution#33
ghostwriternr wants to merge 2 commits intojhford:masterfrom
ghostwriternr:add-max

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