diff --git a/app/backend/systemproperties.cpp b/app/backend/systemproperties.cpp index 1e2720e4..10c64015 100644 --- a/app/backend/systemproperties.cpp +++ b/app/backend/systemproperties.cpp @@ -57,13 +57,8 @@ QRect SystemProperties::getNativeResolution(int displayIndex) void SystemProperties::querySdlVideoInfo() { - monitorDesktopResolutions.clear(); - monitorNativeResolutions.clear(); hasHardwareAcceleration = false; - // Never let the maximum drop below 60 FPS - maximumStreamingFrameRate = 60; - if (SDL_InitSubSystem(SDL_INIT_VIDEO) != 0) { SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "SDL_InitSubSystem(SDL_INIT_VIDEO) failed: %s", @@ -71,6 +66,48 @@ void SystemProperties::querySdlVideoInfo() return; } + // Update display related attributes (max FPS, native resolution, etc). + refreshDisplays(); + + SDL_Window* testWindow = SDL_CreateWindow("", 0, 0, 1280, 720, + SDL_WINDOW_HIDDEN | StreamUtils::getPlatformWindowFlags()); + if (!testWindow) { + SDL_LogWarn(SDL_LOG_CATEGORY_APPLICATION, + "Failed to create test window with platform flags: %s", + SDL_GetError()); + + testWindow = SDL_CreateWindow("", 0, 0, 1280, 720, SDL_WINDOW_HIDDEN); + if (!testWindow) { + SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, + "Failed to create window for hardware decode test: %s", + SDL_GetError()); + SDL_QuitSubSystem(SDL_INIT_VIDEO); + return; + } + } + + Session::getDecoderInfo(testWindow, hasHardwareAcceleration, rendererAlwaysFullScreen, maximumResolution); + + SDL_DestroyWindow(testWindow); + + SDL_QuitSubSystem(SDL_INIT_VIDEO); +} + +void SystemProperties::refreshDisplays() +{ + if (SDL_InitSubSystem(SDL_INIT_VIDEO) != 0) { + SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, + "SDL_InitSubSystem(SDL_INIT_VIDEO) failed: %s", + SDL_GetError()); + return; + } + + monitorDesktopResolutions.clear(); + monitorNativeResolutions.clear(); + + // Never let the maximum drop below 60 FPS + maximumStreamingFrameRate = 60; + SDL_DisplayMode bestMode; for (int displayIndex = 0; displayIndex < SDL_GetNumVideoDisplays(); displayIndex++) { SDL_DisplayMode desktopMode; @@ -120,26 +157,5 @@ void SystemProperties::querySdlVideoInfo() } } - SDL_Window* testWindow = SDL_CreateWindow("", 0, 0, 1280, 720, - SDL_WINDOW_HIDDEN | StreamUtils::getPlatformWindowFlags()); - if (!testWindow) { - SDL_LogWarn(SDL_LOG_CATEGORY_APPLICATION, - "Failed to create test window with platform flags: %s", - SDL_GetError()); - - testWindow = SDL_CreateWindow("", 0, 0, 1280, 720, SDL_WINDOW_HIDDEN); - if (!testWindow) { - SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, - "Failed to create window for hardware decode test: %s", - SDL_GetError()); - SDL_QuitSubSystem(SDL_INIT_VIDEO); - return; - } - } - - Session::getDecoderInfo(testWindow, hasHardwareAcceleration, rendererAlwaysFullScreen, maximumResolution); - - SDL_DestroyWindow(testWindow); - SDL_QuitSubSystem(SDL_INIT_VIDEO); } diff --git a/app/backend/systemproperties.h b/app/backend/systemproperties.h index 0a8b1a81..817ac750 100644 --- a/app/backend/systemproperties.h +++ b/app/backend/systemproperties.h @@ -23,6 +23,7 @@ public: Q_PROPERTY(QSize maximumResolution MEMBER maximumResolution CONSTANT) Q_PROPERTY(QString versionString MEMBER versionString CONSTANT) + Q_INVOKABLE void refreshDisplays(); Q_INVOKABLE QRect getDesktopResolution(int displayIndex); Q_INVOKABLE QRect getNativeResolution(int displayIndex); diff --git a/app/gui/SettingsView.qml b/app/gui/SettingsView.qml index bbb0dc2b..88c19efa 100644 --- a/app/gui/SettingsView.qml +++ b/app/gui/SettingsView.qml @@ -83,6 +83,9 @@ Flickable { // ignore setting the index at first, and actually set it when the component is loaded Component.onCompleted: { + // Refresh display data before using it to build the list + SystemProperties.refreshDisplays() + // Add native resolutions for all attached displays var done = false for (var displayIndex = 0; !done; displayIndex++) {