diff options
author | Simon Rettberg | 2019-01-02 18:08:31 +0100 |
---|---|---|
committer | Simon Rettberg | 2019-01-02 18:08:31 +0100 |
commit | 191b44a3b202626d0a96202a3be75050375b625d (patch) | |
tree | 6736ce60f121c3161011703de354a2008cdbc7e7 | |
parent | Don't skip over the 4 descriptors in base EDID block (diff) | |
download | beamergui-191b44a3b202626d0a96202a3be75050375b625d.tar.gz beamergui-191b44a3b202626d0a96202a3be75050375b625d.tar.xz beamergui-191b44a3b202626d0a96202a3be75050375b625d.zip |
Also handle special EDID case for init GUI
-rw-r--r-- | src/xprivate.cpp | 6 | ||||
-rw-r--r-- | src/xprivate.h | 2 | ||||
-rw-r--r-- | src/xx.cpp | 15 | ||||
-rw-r--r-- | src/xx.h | 3 |
4 files changed, 17 insertions, 9 deletions
diff --git a/src/xprivate.cpp b/src/xprivate.cpp index 2cba1b0..de0440d 100644 --- a/src/xprivate.cpp +++ b/src/xprivate.cpp @@ -512,7 +512,7 @@ next:; return None; } -XRRModeInfo* XPrivate::getPreferredMode(OutputInfo *oi, XRRModeInfo *fallback) const +XRRModeInfo* XPrivate::getPreferredMode(const OutputInfo *oi, XRRModeInfo *fallback) const { if (oi->output->nmode == 0) { qDebug() << "getPreferredMode: Output" << oi->outputName << "has no modes!?"; @@ -523,6 +523,10 @@ XRRModeInfo* XPrivate::getPreferredMode(OutputInfo *oi, XRRModeInfo *fallback) c // I can only guess this is a safety measure for old/bad OS or gfx cards // So, determine the aspect ratio by looking at the physical size and if it's ultrawide, look for a // more fitting resolution in the list of supported ones + // UPDATE: Further digging using edid-decode suggests that Xorg parses EDID data improperly, most notably + // not preferring the resolution given in the first DTD block in the base section (first 128b) but rather + // going for the first DTD in the CTA extension block. (This is just a guess since I didn't check the + // Xorg source code.) if (oi->output->mm_height > 0) { float ar = float(oi->output->mm_width) / float(oi->output->mm_height); if (ar >= 1.999f) { // Consider 18:9+ as ultrawide diff --git a/src/xprivate.h b/src/xprivate.h index 3bc6067..c7ef29b 100644 --- a/src/xprivate.h +++ b/src/xprivate.h @@ -50,7 +50,7 @@ public: void addMissingModesFromExtBlock(XRRScreenResources *res, RROutput outputId, unsigned char *data); void addMissingModesFromDtd(XRRScreenResources *res, RROutput outputId, unsigned char *data); void disconnectAllCrtcs(); - XRRModeInfo* getPreferredMode(OutputInfo *oi, XRRModeInfo *fallback = nullptr) const; + XRRModeInfo* getPreferredMode(const OutputInfo *oi, XRRModeInfo *fallback = nullptr) const; void setScreenSize(const QSize &size); RRMode getOutputModeForResolution(const XRROutputInfo *output, unsigned int width, unsigned int height) const; RRMode getOutputModeForResolution(const XRROutputInfo *output, const QSize &resolution) const; @@ -137,7 +137,7 @@ static QWeakPointer<BackupInternalInternal> currentBackup; */ -static ScreenInfo initScreenInfo(const OutputInfo *oi, const ModeMap &om) +ScreenInfo ScreenSetup::initScreenInfo(const OutputInfo *oi) const { ScreenInfo si; si.position = oi->position; @@ -148,17 +148,18 @@ static ScreenInfo initScreenInfo(const OutputInfo *oi, const ModeMap &om) si.currentResolution = QSize(QSize(int(oi->mode->width), int(oi->mode->height))); } for (int i = 0; i < oi->output->nmode; ++i) { - if (om.contains(oi->output->modes[i])) { - auto m = om.value(oi->output->modes[i]); + if (a->_outputMap.contains(oi->output->modes[i])) { + auto m = a->_outputMap.value(oi->output->modes[i])->mode; const QSize size(int(m->width), int(m->height)); if (!si.modes.contains(size)) { si.modes.append(size); } - if (i == 0 && oi->output->npreferred > 0) { - si.preferredResolution = size; - } } } + auto pref = a->getPreferredMode(oi); + if (pref != nullptr) { + si.preferredResolution = QSize(int(pref->width), int(pref->height)); + } return si; } @@ -240,7 +241,7 @@ QMap<QString, ScreenInfo> ScreenSetup::getScreenPositions() const { QMap<QString, ScreenInfo> ret; for (auto oi : a->_outputMap) { - ret.insert(oi->outputName, initScreenInfo(oi, a->_modeMap)); + ret.insert(oi->outputName, initScreenInfo(oi)); } return ret; } @@ -57,6 +57,8 @@ public: void revert(); }; +struct OutputInfo; + class ScreenSetup : public QObject { Q_OBJECT @@ -85,6 +87,7 @@ public: private: ScreenSetup(); ~ScreenSetup(); + ScreenInfo initScreenInfo(const OutputInfo *oi) const; ConfigBackup createCrtcBackup(); static ScreenSetup * _instance; |