From 351404deb5d625db7cac66b222e04853a6a077b8 Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Tue, 11 Aug 2020 15:07:57 +0200 Subject: Fix center mode (again) --- src/xx.cpp | 45 ++++++++++++++++++++------------------------- 1 file 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 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) { -- cgit v1.2.3-55-g7522