diff --git a/src/ScreenOptionsMasterPrefs.cpp b/src/ScreenOptionsMasterPrefs.cpp index 2e6783fac1..dee5ad3910 100644 --- a/src/ScreenOptionsMasterPrefs.cpp +++ b/src/ScreenOptionsMasterPrefs.cpp @@ -248,12 +248,16 @@ static void ThemeChoices( vector &out ) *s = THEME->GetThemeDisplayName( *s ); } +static DisplayResolutions display_resolution_list; +static void cache_display_resolution_list() +{ + display_resolution_list.clear(); + DISPLAY->GetDisplayResolutions(display_resolution_list); +} + static void DisplayResolutionChoices( vector &out ) { - DisplayResolutions d; - DISPLAY->GetDisplayResolutions( d ); - - FOREACHS_CONST( DisplayResolution, d, iter ) + FOREACHS_CONST( DisplayResolution, display_resolution_list, iter ) { RString s = ssprintf("%dx%d", iter->iWidth, iter->iHeight); out.push_back( s ); @@ -574,18 +578,18 @@ inline res_t operator-(res_t lhs, res_t const &rhs) static void DisplayResolutionM( int &sel, bool ToSel, const ConfOption *pConfOption ) { - vector v; + static vector res_choices; - DisplayResolutions d; - DISPLAY->GetDisplayResolutions( d ); - - FOREACHS_CONST( DisplayResolution, d, iter ) + if(res_choices.empty()) { - v.push_back( res_t(iter->iWidth, iter->iHeight) ); + FOREACHS_CONST(DisplayResolution, display_resolution_list, iter) + { + res_choices.push_back(res_t(iter->iWidth, iter->iHeight)); + } } res_t sel_res( PREFSMAN->m_iDisplayWidth, PREFSMAN->m_iDisplayHeight ); - MoveMap( sel, sel_res, ToSel, &v[0], v.size() ); + MoveMap( sel, sel_res, ToSel, &res_choices[0], res_choices.size()); if( !ToSel ) { PREFSMAN->m_iDisplayWidth.Set( sel_res.w ); @@ -702,6 +706,8 @@ static void InitializeConfOptions() if( !g_ConfOptions.empty() ) return; + cache_display_resolution_list(); + // There are a couple ways of getting the current preference column or turning // a new choice in the interface into a new preference. The easiest is when // the interface choices are an exact mapping to the values the preference diff --git a/src/archutils/Win32/GraphicsWindow.cpp b/src/archutils/Win32/GraphicsWindow.cpp index 44314367e0..f2eb90c54e 100644 --- a/src/archutils/Win32/GraphicsWindow.cpp +++ b/src/archutils/Win32/GraphicsWindow.cpp @@ -519,10 +519,20 @@ void GraphicsWindow::GetDisplayResolutions( DisplayResolutions &out ) int i=0; while(EnumDisplaySettings(NULL, i++, &dm)) { - if(ChangeDisplaySettings(&dm, CDS_TEST)==DISP_CHANGE_SUCCESSFUL) + // Windows 8 and later don't support less than 32bpp, so don't even test + // for them. GetDisplayResolutions is only for resolutions anyway. -Kyz + if(dm.dmBitsPerPel < 32) { - DisplayResolution res = { dm.dmPelsWidth, dm.dmPelsHeight }; - out.insert( res ); + continue; + } + DisplayResolution res = { dm.dmPelsWidth, dm.dmPelsHeight }; + std::set::iterator entry= out.find(res); + if(entry == out.end()) + { + if(ChangeDisplaySettings(&dm, CDS_TEST)==DISP_CHANGE_SUCCESSFUL) + { + out.insert(res); + } } } }