mirror of
https://github.com/fastfetch-cli/fastfetch.git
synced 2026-11-06 05:04:17 +01:00
Monitor (macOS): detect maximum refresh rate
This commit is contained in:
@@ -5,6 +5,7 @@ typedef struct FFMonitorResult
|
||||
FFstrbuf name;
|
||||
uint32_t width; // native / maximum resolution, in pixels
|
||||
uint32_t height; // native / maximum resolution, in pixels
|
||||
double refreshRate;// maximum refresh rate in native resolution, in Hz
|
||||
uint32_t physicalWidth; // in mm
|
||||
uint32_t physicalHeight; // in mm
|
||||
bool hdrCompatible;
|
||||
|
||||
@@ -102,6 +102,19 @@ const char* ffDetectMonitor(FFlist* results)
|
||||
detectHdrSupportWithNSScreen(display);
|
||||
monitor->serial = CGDisplaySerialNumber((CGDirectDisplayID) display->id);
|
||||
|
||||
FF_CFTYPE_AUTO_RELEASE CFArrayRef modes = CGDisplayCopyAllDisplayModes((CGDirectDisplayID) display->id, NULL);
|
||||
double maxRefreshRate = 0;
|
||||
for (uint32_t j = 0; j < CFArrayGetCount(modes); ++j)
|
||||
{
|
||||
CGDisplayModeRef mode = (CGDisplayModeRef) CFArrayGetValueAtIndex(modes, j);
|
||||
if (CGDisplayModeGetWidth(mode) == (uint32_t) width && CGDisplayModeGetHeight(mode) == (uint32_t) height)
|
||||
{
|
||||
double refreshRate = CGDisplayModeGetRefreshRate(mode);
|
||||
if (refreshRate > maxRefreshRate) maxRefreshRate = refreshRate;
|
||||
}
|
||||
}
|
||||
monitor->refreshRate = maxRefreshRate;
|
||||
|
||||
int64_t year, week;
|
||||
if (ffCfDictGetInt64(displayInfo, CFSTR("DisplayYearManufacture"), &year) == NULL)
|
||||
monitor->manufactureYear = (uint16_t) year;
|
||||
|
||||
@@ -61,6 +61,7 @@ const char* ffDetectMonitor(FFlist* results)
|
||||
ffEdidGetPhysicalSize(edidData, &display->physicalWidth, &display->physicalHeight);
|
||||
ffEdidGetSerialAndManufactureDate(edidData, &display->serial, &display->manufactureYear, &display->manufactureWeek);
|
||||
display->hdrCompatible = ffEdidGetHdrCompatible(edidData, (uint32_t) edidLength);
|
||||
display->refreshRate = 0;
|
||||
}
|
||||
|
||||
ffStrbufSubstrBefore(&drmDir, drmDirLength);
|
||||
|
||||
@@ -49,6 +49,7 @@ const char* ffDetectMonitor(FFlist* results)
|
||||
ffStrbufInit(&display->name);
|
||||
ffEdidGetName(edidData, &display->name);
|
||||
ffEdidGetPhysicalSize(edidData, &display->physicalWidth, &display->physicalHeight);
|
||||
display->refreshRate = 0;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user