summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimon Rettberg2020-08-11 15:07:57 +0200
committerSimon Rettberg2020-08-11 15:07:57 +0200
commit351404deb5d625db7cac66b222e04853a6a077b8 (patch)
treebd461bbd31b36bc019f46699630bc7ce7018aa07
parentFix center mode (-c) (diff)
downloadbeamergui-351404deb5d625db7cac66b222e04853a6a077b8.tar.gz
beamergui-351404deb5d625db7cac66b222e04853a6a077b8.tar.xz
beamergui-351404deb5d625db7cac66b222e04853a6a077b8.zip
Fix center mode (again)
-rw-r--r--src/xx.cpp45
1 files changed, 20 insertions, 25 deletions
diff --git a/src/xx.cpp b/src/xx.cpp
index 1e529ae..aa2f2e0 100644
--- a/src/xx.cpp
+++ b/src/xx.cpp
@@ -508,37 +508,32 @@ ScreenSetup::~ScreenSetup()
ConfigBackup ScreenSetup::setCenteredClone()
{
ConfigBackup retval = createCrtcBackup();
- XRRModeInfo *fallback = nullptr;
+ XRRModeInfo *fallback = nullptr;
for (auto m : a->_modeMap) {
if (m->width == 1024 && m->height == 768) {
fallback = m;
break;
}
}
- // See if we even need to do anything
- for (int i = 0; i < 2; ++i) {
- int withPref = 0;
- QSet<RRMode> known;
- for (auto oi : a->_outputMap) {
- if (oi->output->npreferred == 0) {
- if (oi->mode != nullptr) {
- known.insert(oi->mode->id);
- }
- } else {
- withPref++;
- known.insert(oi->output->modes[0]);
- }
- }
- if (withPref == 0 && i == 0) {
- QThread::msleep(100);
- updateScreenResources();
- retval = createCrtcBackup();
- continue;
- }
- if (known.count() < 2)
- return retval;
- break;
- }
+ // See if we even need to do anything
+ bool ok = true;
+ unsigned int lX = UINT_MAX, lY = 0;
+ for (auto oi : a->_outputMap) {
+ if (oi->crtc == nullptr)
+ continue;
+ if (oi->crtc->x != 0 || oi->crtc->y != 0) {
+ ok = false; // A screen that's not at origin
+ break;
+ }
+ if (lX != UINT_MAX && (oi->crtc->width != lX || oi->crtc->height != lY)) {
+ ok = false; // Different size than previous screen
+ break;
+ }
+ lX = oi->crtc->width;
+ lY = oi->crtc->height;
+ }
+ if (ok)
+ return retval;
QStringList cmd;
QSize screenSize;
for (auto oi : a->_outputMap) {