summaryrefslogtreecommitdiffstats
path: root/src/xprivate.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/xprivate.cpp')
-rw-r--r--src/xprivate.cpp58
1 files changed, 8 insertions, 50 deletions
diff --git a/src/xprivate.cpp b/src/xprivate.cpp
index 3aea9b5..37ee5ef 100644
--- a/src/xprivate.cpp
+++ b/src/xprivate.cpp
@@ -518,30 +518,6 @@ void XPrivate::addMissingModesFromDtd(XRRScreenResources *res, RROutput outputId
}
/**
- * Copy first "num" modes from output to all other outputs if they
- * dont have a suitable mode yet.
- */
-void XPrivate::copyModesToAll(RROutput sourceId, int num)
-{
- const XRROutputInfo *outputInfo = _outputMap[sourceId]->output;
- for (int i = 0; i < num; ++i) {
- if (!_modeMap.contains(outputInfo->modes[i])) {
- qDebug() << "BUG: Mode" << outputInfo->modes[i] << "not found in copyModesToAll";
- continue;
- }
- const XRRModeInfo *mode = _modeMap[outputInfo->modes[i]];
- for (auto other : _outputMap.keys()) {
- if (other == sourceId)
- continue;
- const XRROutputInfo *otherInfo = _outputMap[other]->output;
- if (!getOutputModeForResolution(otherInfo, mode->width, mode->height).isEmpty())
- continue;
- XRRAddOutputMode(_display, other, outputInfo->modes[i]);
- }
- }
-}
-
-/**
* Get all known modes matching the given resolution.
* If multiple modes match the given resolution, the function will
* put the preferred resolution first, then all others sorted by
@@ -704,28 +680,6 @@ QList<QSize> XPrivate::getTotalSize(const QList<OutputInfo*> &projectors, const
// Screen supports same resolution as projector
modeS = _modeMap[list.first()];
qDebug() << "Screen supports same";
- } else {
- // Screen does not support same resolution
- // Usually that should not happen as we add the projector's mode(s) to the
- // other outputs, but that doesn't work on nvidia cards, so try to use another
- // suitable resolution there
- int x = 0, y = 0;
- if (modeP->width == 1280 && modeP->height == 800) {
- x = 1280;
- y = 720;
- } else if (modeP->width == 1920 && modeP->height == 1200) {
- x = 1920;
- y = 1080;
- }
- if (x != 0) {
- auto s = getOutputModeForResolution(screens.at(i)->output, x, y);
- auto p = getOutputModeForResolution(projectors.at(i)->output, x, y);
- if (!s.empty() && !p.empty()) {
- modeP = _modeMap[p.first()];
- modeS = _modeMap[s.first()];
- qDebug() << "Falling back to" << modeP->width << "x" << modeP->height << " because of screen incompatibility";
- }
- }
}
}
if (modeS == nullptr) {
@@ -749,21 +703,25 @@ QList<QSize> XPrivate::getTotalSize(const QList<OutputInfo*> &projectors, const
return modes;
}
-XRRModeInfo* XPrivate::setOutputResolution(QStringList &args, OutputInfo *oi, int x, int y, const QSize &size)
+XRRModeInfo* XPrivate::setOutputResolution(QStringList &args, OutputInfo *oi, int x, int y, const QSize &size, const QSize &scaleFrom)
{
QList<RRMode> modes = getOutputModeForResolution(oi->output, size);
if (modes.isEmpty()) {
qDebug() << "Cannot set" << oi->outputName << "to" << size << " since it's not supported";
- if (oi->output->nmode == 0)
+ auto *mp = getPreferredMode(oi);
+ if (mp == nullptr)
return nullptr;
- qDebug() << "falling back to its default mode";
- modes.append(oi->output->modes[0]);
+ modes.append(mp->id);
+ qDebug() << "falling back to its default mode" << mp->width << "x" << mp->height;
}
// modes list is known to be sorted by preferred resolution/rate, then sorted by highest to lowest rate
// so we just pick the first one for now, as the GUI doesn't offer picking the rate
XRRModeInfo *best = _modeMap[modes.first()];
args << "--output" << oi->outputName << "--mode" << best->name << "--rate" << QString::number(toVertRefresh(best), 'f', 2);
args << "--pos" << QString::asprintf("%dx%d", x, y);
+ if (!scaleFrom.isEmpty() && scaleFrom != QSize(best->width, best->height)) {
+ args << "--scale-from" << QString::asprintf("%dx%d", scaleFrom.width(), scaleFrom.height());
+ }
if (x == 0 && y == 0 && !args.contains(QLatin1String("--primary"))) {
args.append("--primary");
}