@@ -2357,7 +2357,15 @@ hide_or_show_cursor(bool hide_cursor) {
2357
2357
bool WinGraphicsWindow::
2358
2358
find_acceptable_display_mode (DWORD dwWidth, DWORD dwHeight, DWORD bpp,
2359
2359
DEVMODE &dm) {
2360
+
2361
+ // Get the current mode. We'll try to match the refresh rate.
2362
+ DEVMODE cur_dm;
2363
+ ZeroMemory (&cur_dm, sizeof (cur_dm));
2364
+ cur_dm.dmSize = sizeof (cur_dm);
2365
+ EnumDisplaySettings (NULL , ENUM_CURRENT_SETTINGS, &cur_dm);
2366
+
2360
2367
int modenum = 0 ;
2368
+ int saved_modenum = -1 ;
2361
2369
2362
2370
while (1 ) {
2363
2371
ZeroMemory (&dm, sizeof (dm));
@@ -2369,11 +2377,28 @@ find_acceptable_display_mode(DWORD dwWidth, DWORD dwHeight, DWORD bpp,
2369
2377
2370
2378
if ((dm.dmPelsWidth == dwWidth) && (dm.dmPelsHeight == dwHeight) &&
2371
2379
(dm.dmBitsPerPel == bpp)) {
2372
- return true ;
2380
+ // If this also matches in refresh rate, we're done here. Otherwise,
2381
+ // save this as a second choice for later.
2382
+ if (dm.dmDisplayFrequency == cur_dm.dmDisplayFrequency ) {
2383
+ return true ;
2384
+ } else if (saved_modenum == -1 ) {
2385
+ saved_modenum = modenum;
2386
+ }
2373
2387
}
2374
2388
modenum++;
2375
2389
}
2376
2390
2391
+ // Failed to find an exact match, but we do have a match that didn't match
2392
+ // the refresh rate.
2393
+ if (saved_modenum != -1 ) {
2394
+ ZeroMemory (&dm, sizeof (dm));
2395
+ dm.dmSize = sizeof (dm);
2396
+
2397
+ if (EnumDisplaySettings (NULL , saved_modenum, &dm)) {
2398
+ return true ;
2399
+ }
2400
+ }
2401
+
2377
2402
return false ;
2378
2403
}
2379
2404
0 commit comments