summaryrefslogtreecommitdiffstats
path: root/src/xx.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/xx.cpp')
-rw-r--r--src/xx.cpp43
1 files changed, 35 insertions, 8 deletions
diff --git a/src/xx.cpp b/src/xx.cpp
index 179d286..d4a4608 100644
--- a/src/xx.cpp
+++ b/src/xx.cpp
@@ -267,6 +267,7 @@ void ScreenSetup::initModes()
if (!a->getOutputModeForResolution(info->output, mode->width, mode->height).isEmpty())
continue;
XRRAddOutputMode(a->_display, info->id, mode->id);
+ qDebug() << "Adding mode" << mode->width << 'x' << mode->height << "to" << info->outputName;
}
}
#undef RES
@@ -274,6 +275,7 @@ void ScreenSetup::initModes()
for (auto res : wanted) {
unsigned int x = res & 0xffff;
unsigned int y = res >> 16;
+ qDebug() << "Creating missing wanted resolution of" << x << "x" << y;
createMode(x, y, 60, QString::asprintf("%ux%u", x, y));
}
if (!wanted.isEmpty()) { // Modes were added, update for final loop below
@@ -282,7 +284,8 @@ void ScreenSetup::initModes()
// Finally copy all those the projector supports to other outputs
for (auto key : a->_outputMap.keys()) {
OutputInfo *oi = a->_outputMap[key];
- if (oi->outputType == Projector::Yes) {
+ if (oi->outputType == Projector::Yes && oi->output->npreferred > 0) { // Only if has edid
+ qDebug() << "Copying" << oi->output->nmode << "modes to all from" << oi->outputName;
a->copyModesToAll(key, oi->output->nmode);
}
}
@@ -497,7 +500,10 @@ bool ScreenSetup::createMode(unsigned int resX, unsigned int resY, float refresh
}
RRMode xid = XRRCreateMode(a->_display, DefaultRootWindow(a->_display), &m);
- qDebug() << "Return value of create was" << xid;
+ if (xid <= 0) {
+ qDebug() << "Return value of create mode was" << xid << "(" << resX << 'x' << resY << ")";
+ return false;
+ }
// Immediately add to all screens
for (OutputInfo *info : a->_outputMap) {
XRRAddOutputMode(a->_display, info->id, xid);
@@ -591,21 +597,42 @@ ConfigBackup ScreenSetup::setCustom(const QList<QPair<QSize, QList<QString>>> &l
retval = createCrtcBackup();
auto screenSize = getTotalSizeHorz(sizes);
if (screenSize.isEmpty())
- return retval;
- int x = 0;
+ return retval;
+ // Make sure desired resolutions exist on outputs
+ bool reload = false;
+ for (auto e : list) {
+ if (e.second.isEmpty())
+ continue;
+ const QSize &res = e.first;
+ for (auto outputName : e.second) {
+ for (auto oi : a->_outputMap) {
+ if (oi->outputName != outputName)
+ continue;
+ // Now add resolution if not found
+ if (a->addResolutionToOutput(oi, res)) {
+ reload = true;
+ }
+ }
+ }
+ }
+ if (reload) {
+ updateScreenResources();
+ }
+ int x = 0;
for (auto e : list) {
if (e.second.isEmpty())
continue;
const QSize &res = e.first;
unsigned int w = 0;
+ // Find according output, apply resolution
for (auto outputName : e.second) {
for (auto oi : a->_outputMap) {
if (oi->outputName != outputName)
continue;
- auto *mode = a->setOutputResolution(cmd, oi, x, 0, res);
- if (mode != nullptr && mode->width > w) {
- w = mode->width;
- }
+ auto *mode = a->setOutputResolution(cmd, oi, x, 0, res);
+ if (mode != nullptr && mode->width > w) {
+ w = mode->width;
+ }
}
}
x += w;