From e7420aa7e9859241f7498803e68608889a3ff2c8 Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Fri, 7 Aug 2020 11:21:50 +0200 Subject: Fix center mode (-c) --- src/xx.cpp | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/src/xx.cpp b/src/xx.cpp index 570f79d..1e529ae 100644 --- a/src/xx.cpp +++ b/src/xx.cpp @@ -540,20 +540,25 @@ ConfigBackup ScreenSetup::setCenteredClone() break; } QStringList cmd; - QSize screenSize; // Currently unused + QSize screenSize; for (auto oi : a->_outputMap) { auto mode = a->getPreferredMode(oi, fallback); - if (mode != nullptr) { - if (int(mode->width) > screenSize.width()) { - screenSize.setWidth(int(mode->width)); - } - if (int(mode->height) > screenSize.height()) { - screenSize.setHeight(int(mode->height)); - } - const int x = (screenSize.width() - int(mode->width)) / 2; - const int y = (screenSize.height() - int(mode->height)) / 2; - a->setOutputResolution(cmd, oi, x, y, QSize(int(mode->width), int(mode->height))); + if (mode == nullptr) + continue; + if (int(mode->width) > screenSize.width()) { + screenSize.setWidth(int(mode->width)); } + if (int(mode->height) > screenSize.height()) { + screenSize.setHeight(int(mode->height)); + } + } + for (auto oi : a->_outputMap) { + auto mode = a->getPreferredMode(oi, fallback); + if (mode == nullptr) + continue; + const int x = (screenSize.width() - int(mode->width)) / 2; + const int y = (screenSize.height() - int(mode->height)) / 2; + a->setOutputResolution(cmd, oi, x, y, QSize(int(mode->width), int(mode->height))); } retval._ok = runXrandr(cmd); return retval; -- cgit v1.2.3-55-g7522