diff options
author | Simon Rettberg | 2020-08-06 17:46:38 +0200 |
---|---|---|
committer | Simon Rettberg | 2020-08-06 17:46:38 +0200 |
commit | b2414a2b5a3cbf89958e50f8c8c4a1a377e93b4c (patch) | |
tree | c06050065a4b89f71a9afb18f9381bd2a8971fca | |
parent | Sort output list alphabetically when assigning resolutions (diff) | |
download | beamergui-b2414a2b5a3cbf89958e50f8c8c4a1a377e93b4c.tar.gz beamergui-b2414a2b5a3cbf89958e50f8c8c4a1a377e93b4c.tar.xz beamergui-b2414a2b5a3cbf89958e50f8c8c4a1a377e93b4c.zip |
Retry with lower resolution if auto-setup fails
-rw-r--r-- | src/xx.cpp | 71 |
1 files changed, 47 insertions, 24 deletions
@@ -399,31 +399,54 @@ ConfigBackup ScreenSetup::setDefaultMode(ScreenMode &mode) mode = ScreenMode::Advanced; // Dunno lol return retval; } - QSize screenSize = getTotalSizeHorz(outputSizes); - QStringList cmd; - retval = createCrtcBackup(); - - qDebug() << "Virtual screen size:" << screenSize << "with" << outputSizes.size() << "different screens."; - - int offset = 0; - for (int i = 0; i < outputSizes.size(); ++i) { - const QSize &size = outputSizes.at(i); - unsigned int w = 0; - if (i < projectors.size()) { - auto *mode = a->setOutputResolution(cmd, projectors.at(i), offset, 0, size); - if (mode != nullptr && mode->width > w) { - w = mode->width; - } - } - if (i < screens.size()) { - auto *mode = a->setOutputResolution(cmd, screens.at(i), offset, 0, size); - if (mode != nullptr && mode->width > w) { - w = mode->width; - } - } - offset += w; + for (;;) { + QSize screenSize = getTotalSizeHorz(outputSizes); + QStringList cmd; + retval = createCrtcBackup(); + + qDebug() << "Virtual screen size:" << screenSize << "with" << outputSizes.size() << "different screens."; + + int offset = 0; + for (int i = 0; i < outputSizes.size(); ++i) { + const QSize &size = outputSizes.at(i); + unsigned int w = 0; + if (i < projectors.size()) { + auto *mode = a->setOutputResolution(cmd, projectors.at(i), offset, 0, size); + if (mode != nullptr && mode->width > w) { + w = mode->width; + } + } + if (i < screens.size()) { + auto *mode = a->setOutputResolution(cmd, screens.at(i), offset, 0, size); + if (mode != nullptr && mode->width > w) { + w = mode->width; + } + } + offset += w; + } + retval._ok = runXrandr(cmd); + if (retval._ok) + break; + // If xrandr failed, try again while capping the resolution of any screen to FullHD + bool keepGoing = false; + for (QSize &geo : outputSizes) { + if (geo.width() > 1920) { + keepGoing = true; + geo.setWidth(1920); + } + if (geo.height() > 1200) { + keepGoing = true; + geo.setHeight(1080); + } + } + // If we didn't clamp resolutions, but have more than one output group, remove last and retry + if (!keepGoing && outputSizes.size() > 1) { + keepGoing = true; + outputSizes.removeLast(); + } + if (!keepGoing) + break; // No more options } - retval._ok = runXrandr(cmd); updateScreenResources(); // Re-Read if (outputSizes.size() == 1) { // One output size, at least 2 outputs in total -- clone mode |