Skip to content

Commit 83d54bc

Browse files
committed
Try to preserve refresh rate when switching display mode on Windows
1 parent 2b6e192 commit 83d54bc

File tree

2 files changed

+27
-1
lines changed

2 files changed

+27
-1
lines changed

doc/ReleaseNotes

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ This issue fixes several bugs that were still found in 1.9.2.
4848
* Fix exception when trying to pickle NodePathCollection objects
4949
* Fix error when trying to raise vectors to a power
5050
* GLSL: fix error when legacy matrix generator inputs are mat3
51+
* Now tries to preserve refresh rate when switching fullscreen on Windows
5152

5253
------------------------ RELEASE 1.9.2 ------------------------
5354

panda/src/windisplay/winGraphicsWindow.cxx

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2357,7 +2357,15 @@ hide_or_show_cursor(bool hide_cursor) {
23572357
bool WinGraphicsWindow::
23582358
find_acceptable_display_mode(DWORD dwWidth, DWORD dwHeight, DWORD bpp,
23592359
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+
23602367
int modenum = 0;
2368+
int saved_modenum = -1;
23612369

23622370
while (1) {
23632371
ZeroMemory(&dm, sizeof(dm));
@@ -2369,11 +2377,28 @@ find_acceptable_display_mode(DWORD dwWidth, DWORD dwHeight, DWORD bpp,
23692377

23702378
if ((dm.dmPelsWidth == dwWidth) && (dm.dmPelsHeight == dwHeight) &&
23712379
(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+
}
23732387
}
23742388
modenum++;
23752389
}
23762390

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+
23772402
return false;
23782403
}
23792404

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy