diff options
author | Simon Rettberg | 2021-02-16 16:55:54 +0100 |
---|---|---|
committer | Simon Rettberg | 2021-02-16 16:55:54 +0100 |
commit | cf50c34ad5a5e3c4be2148353ed7dadb99349297 (patch) | |
tree | 3c3f74899a20017c01f5eaecb72693e3430e2283 | |
parent | --dump: Fall back to screen size if list is empty (diff) | |
download | beamergui-cf50c34ad5a5e3c4be2148353ed7dadb99349297.tar.gz beamergui-cf50c34ad5a5e3c4be2148353ed7dadb99349297.tar.xz beamergui-cf50c34ad5a5e3c4be2148353ed7dadb99349297.zip |
More fallback special case workaroud stuff
On NVIDIA cards, you cannot add new resolutions to outputs
via xrandr. So given that we want to set up clone mode, and
assuming the projector's native resolution is 1280x800 it
might happen that the connected screen doesn't have that resolution
in its list. This meant that the screen would use its native
resolution instead and still work in clone mode, which is
suboptimal. Now we try to at least fall back to the according 16:9
resolution in case the projector wants a 16:10 one and the screen
doesn't suport it, as 16:9 has a higher chance of being supported by
the screen.
-rw-r--r-- | src/xprivate.cpp | 53 |
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); |