summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimon Rettberg2019-01-02 18:08:31 +0100
committerSimon Rettberg2019-01-02 18:08:31 +0100
commit191b44a3b202626d0a96202a3be75050375b625d (patch)
tree6736ce60f121c3161011703de354a2008cdbc7e7
parentDon't skip over the 4 descriptors in base EDID block (diff)
downloadbeamergui-191b44a3b202626d0a96202a3be75050375b625d.tar.gz
beamergui-191b44a3b202626d0a96202a3be75050375b625d.tar.xz
beamergui-191b44a3b202626d0a96202a3be75050375b625d.zip
Also handle special EDID case for init GUI
-rw-r--r--src/xprivate.cpp6
-rw-r--r--src/xprivate.h2
-rw-r--r--src/xx.cpp15
-rw-r--r--src/xx.h3
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;
diff --git a/src/xx.cpp b/src/xx.cpp
index 80cb1b1..4b8f3ee 100644
--- a/src/xx.cpp
+++ b/src/xx.cpp
@@ -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;
}
diff --git a/src/xx.h b/src/xx.h
index 7346c4a..8bd151e 100644
--- a/src/xx.h
+++ b/src/xx.h
@@ -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;