Skip to content

Commit 4cca63a

Browse files
committed
Display (Windows): detect preferred resolution & refresh rate
1 parent 21a3576 commit 4cca63a

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

src/detection/displayserver/displayserver_windows.c

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,12 +149,30 @@ static void detectDisplays(FFDisplayServerResult* ds)
149149
default: rotation = 0; break;
150150
}
151151

152+
DISPLAYCONFIG_TARGET_PREFERRED_MODE preferredMode = {
153+
.header = {
154+
.type = DISPLAYCONFIG_DEVICE_INFO_GET_TARGET_PREFERRED_MODE,
155+
.size = sizeof(preferredMode),
156+
.adapterId = path->targetInfo.adapterId,
157+
.id = path->targetInfo.id,
158+
}
159+
};
160+
double preferredRefreshRate = 0;
161+
if (DisplayConfigGetDeviceInfo(&preferredMode.header) == ERROR_SUCCESS)
162+
{
163+
DISPLAYCONFIG_RATIONAL freq = preferredMode.targetMode.targetVideoSignalInfo.vSyncFreq;
164+
preferredRefreshRate = freq.Numerator / (double) freq.Denominator;
165+
}
166+
152167
FFDisplayResult* display = ffdsAppendDisplay(ds,
153168
width,
154169
height,
155170
path->targetInfo.refreshRate.Numerator / (double) path->targetInfo.refreshRate.Denominator,
156171
(uint32_t) (monitorInfo->info.rcMonitor.right - monitorInfo->info.rcMonitor.left),
157172
(uint32_t) (monitorInfo->info.rcMonitor.bottom - monitorInfo->info.rcMonitor.top),
173+
preferredMode.width,
174+
preferredMode.height,
175+
preferredRefreshRate,
158176
rotation,
159177
&name,
160178
path->targetInfo.outputTechnology == DISPLAYCONFIG_OUTPUT_TECHNOLOGY_OTHER ? FF_DISPLAY_TYPE_UNKNOWN :

0 commit comments

Comments
 (0)