summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/xprivate.cpp53
1 files changed, 44 insertions, 9 deletions
diff --git a/src/xprivate.cpp b/src/xprivate.cpp
index ba5b805..73b73ca 100644
--- a/src/xprivate.cpp
+++ b/src/xprivate.cpp
@@ -625,19 +625,54 @@ QList<QSize> XPrivate::getTotalSize(const QList<OutputInfo*> &projectors, const
const int max = qMax(screens.size(), projectors.size());
QList<QSize> modes;
for (int i = 0; i < max; ++i) {
- XRRModeInfo *mode = nullptr;
+ XRRModeInfo *modeP = nullptr, *modeS = nullptr;
+ if (i < projectors.size()) {
+ modeP = getPreferredMode(projectors.at(i));
+ if (modeP != nullptr) {
+ qDebug() << "Projector wants" << modeP->width << "x" << modeP->height;
+ }
+ }
if (i < screens.size()) {
- mode = getPreferredMode(screens.at(i));
- if (mode != nullptr) {
- qDebug() << "Screen wants" << mode->width << "x" << mode->height;
+ if (modeP != nullptr) {
+ QList<RRMode> list = getOutputModeForResolution(screens.at(i)->output, modeP->width, modeP->height);
+ if (!list.empty()) {
+ // 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 (i < projectors.size()) {
- mode = getPreferredMode(projectors.at(i), mode);
- if (mode != nullptr) {
- qDebug() << "Projector wants" << mode->width << "x" << mode->height;
+ if (modeS == nullptr) {
+ modeS = getPreferredMode(screens.at(i), modeP);
+ if (modeS != nullptr) {
+ qDebug() << "Screen wants" << modeS->width << "x" << modeS->height;
+ } else {
+ qDebug() << "Could not find any suitable resolution for screen";
+ }
}
}
+ XRRModeInfo *mode = modeP ? modeP : modeS;
if (mode != nullptr) {
QSize size(int(mode->width), int(mode->height));
modes.append(size);