summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimon Rettberg2020-03-09 15:41:35 +0100
committerSimon Rettberg2020-03-09 15:41:35 +0100
commit8be8f771637946812ff78decf6e19364cae6f6d2 (patch)
tree89ac962f287176fd6bbfd789a7f1eae41fc05884
parentAdd --resolutions and --mapping for manual setup (diff)
downloadbeamergui-8be8f771637946812ff78decf6e19364cae6f6d2.tar.gz
beamergui-8be8f771637946812ff78decf6e19364cae6f6d2.tar.xz
beamergui-8be8f771637946812ff78decf6e19364cae6f6d2.zip
Use actually applied resolution when calculating screen offsets
-rw-r--r--src/xprivate.cpp5
-rw-r--r--src/xprivate.h2
-rw-r--r--src/xx.cpp21
-rw-r--r--src/xx.h4
4 files changed, 22 insertions, 10 deletions
diff --git a/src/xprivate.cpp b/src/xprivate.cpp
index c8a45b2..7cb0949 100644
--- a/src/xprivate.cpp
+++ b/src/xprivate.cpp
@@ -638,13 +638,13 @@ QList<QSize> XPrivate::getTotalSize(const QList<OutputInfo*> &projectors, const
return modes;
}
-void 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)
{
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)
- return;
+ return nullptr;
qDebug() << "falling back to its default mode";
modes.append(oi->output->modes[0]);
}
@@ -656,4 +656,5 @@ void XPrivate::setOutputResolution(QStringList &args, OutputInfo *oi, int x, int
if (x == 0 && y == 0 && !args.contains(QLatin1String("--primary"))) {
args.append("--primary");
}
+ return best;
}
diff --git a/src/xprivate.h b/src/xprivate.h
index d0f2d53..0152fb1 100644
--- a/src/xprivate.h
+++ b/src/xprivate.h
@@ -53,7 +53,7 @@ public:
QList<RRMode> getOutputModeForResolution(const XRROutputInfo *output, unsigned int width, unsigned int height) const;
QList<RRMode> getOutputModeForResolution(const XRROutputInfo *output, const QSize &resolution) const;
RRCrtc getFreeCrtc(const XRROutputInfo* output) const;
- void setOutputResolution(QStringList &args, OutputInfo *oi, int x, int y, const QSize &size);
+ XRRModeInfo* setOutputResolution(QStringList &args, OutputInfo *oi, int x, int y, const QSize &size);
QList<QSize> getTotalSize(const QList<OutputInfo*> &projectors, const QList<OutputInfo*> &screens) const;
void copyModesToAll(RROutput id, int num);
diff --git a/src/xx.cpp b/src/xx.cpp
index 6e6286e..b8b1eab 100644
--- a/src/xx.cpp
+++ b/src/xx.cpp
@@ -402,13 +402,20 @@ ConfigBackup ScreenSetup::setDefaultMode(ScreenMode &mode)
int offset = 0;
for (int i = 0; i < outputSizes.size(); ++i) {
const QSize &size = outputSizes.at(i);
+ unsigned int w = 0;
if (i < projectors.size()) {
- a->setOutputResolution(cmd, projectors.at(i), offset, 0, size);
+ auto *mode = a->setOutputResolution(cmd, projectors.at(i), offset, 0, size);
+ if (mode != nullptr && mode->width > w) {
+ w = mode->width;
+ }
}
if (i < screens.size()) {
- a->setOutputResolution(cmd, screens.at(i), offset, 0, size);
+ auto *mode = a->setOutputResolution(cmd, screens.at(i), offset, 0, size);
+ if (mode != nullptr && mode->width > w) {
+ w = mode->width;
+ }
}
- offset += size.width();
+ offset += w;
}
retval._ok = runXrandr(cmd);
updateScreenResources(); // Re-Read
@@ -555,14 +562,18 @@ ConfigBackup ScreenSetup::setCustom(const QList<QPair<QSize, QList<QString>>> &l
if (e.second.isEmpty())
continue;
const QSize &res = e.first;
+ unsigned int w = 0;
for (auto outputName : e.second) {
for (auto oi : a->_outputMap) {
if (oi->outputName != outputName)
continue;
- a->setOutputResolution(cmd, oi, x, 0, res);
+ auto *mode = a->setOutputResolution(cmd, oi, x, 0, res);
+ if (mode != nullptr && mode->width > w) {
+ w = mode->width;
+ }
}
}
- x += res.width();
+ x += w;
}
retval._ok = runXrandr(cmd);
return retval;
diff --git a/src/xx.h b/src/xx.h
index c3e80e7..cf5a37a 100644
--- a/src/xx.h
+++ b/src/xx.h
@@ -69,7 +69,7 @@ public:
ScreenMode getCurrentMode();
bool hasScreenWithoutEdid();
ConfigBackup setResolutionsFromString(const QString &resolutions, const QString &mapping);
- ConfigBackup setDefaultMode(ScreenMode &mode);
+ ConfigBackup setDefaultMode(ScreenMode &mode);
bool createMode(unsigned int resX, unsigned int resY, float refresh, QString name);
ConfigBackup setCenteredClone();
ConfigBackup setClone(const QSize &resolution);
@@ -79,7 +79,7 @@ public:
int queryCurrentOutputCount() const;
QMap<QString, ScreenInfo> getScreenPositions() const;
const ResolutionVector &getVirtualResolutions() const;
- bool runXrandr(QStringList &cmd);
+ bool runXrandr(QStringList &cmd);
// Singleton
inline static ScreenSetup* inst() {