From 6d35a5a3f8dc0231c498f4489e3003b8ca7e5f3a Mon Sep 17 00:00:00 2001 From: Craig Watson Date: Sun, 18 Sep 2016 14:35:31 -0400 Subject: [PATCH] Correct screen indexing in some cases Several issues remain with multi-screen mode on Linux. The behavior is inconsistent from one desktop evironment to the next, making it hard to work around these problems. Among the known issues at this stage: On Ubuntu 14.04, a call to QWidget::setGeometry requires the widget to be hidden on KDE, but visible on MATE, for the geometry changes to take effect. Despite the widget's geometry being updated by this call, the windows aren't necessarily moved. Meaning that the control and display widgets will tend to be displayed on the same monitor, even though their positions are correctly set to different areas on the extended screen. In the current state, this behavior is observed on MATE. Unity works fine and KDE only has transient positioning issues (for example, swapping control and display windows in multi-screen mode leads to both windows being placed on the same monitor, until multi-screen mode is turned off then on again). # Please enter the commit message for your changes. Lines starting # with '#' will be ignored, and an empty message aborts the commit. # On branch dev # Your branch is ahead of 'origin/dev' by 29 commits. # (use "git push" to publish your local commits) # # Changes to be committed: # modified: src/core/UBApplicationController.cpp # modified: src/core/UBDisplayManager.cpp # modified: src/core/UBDisplayManager.h # # Changes not staged for commit: # modified: release_scripts/linux/build.sh # modified: release_scripts/linux/package.sh # # Untracked files: # release_scripts/linux/generateDependencies.sh # --- src/core/UBApplicationController.cpp | 2 +- src/core/UBDisplayManager.cpp | 26 +++++++++++--------------- src/core/UBDisplayManager.h | 2 ++ 3 files changed, 14 insertions(+), 16 deletions(-) diff --git a/src/core/UBApplicationController.cpp b/src/core/UBApplicationController.cpp index 48d670ad..37582e53 100644 --- a/src/core/UBApplicationController.cpp +++ b/src/core/UBApplicationController.cpp @@ -113,7 +113,7 @@ UBApplicationController::UBApplicationController(UBBoardView *pControlView, mBlackScene = new UBGraphicsScene(0); // deleted by UBApplicationController::destructor mBlackScene->setBackground(true, false); - if (mDisplayManager->numScreens() >= 2) + if (mDisplayManager->numScreens() >= 2 && mDisplayManager->useMultiScreen()) { mMirror = new UBScreenMirror(); } diff --git a/src/core/UBDisplayManager.cpp b/src/core/UBDisplayManager.cpp index 5576becd..77538458 100644 --- a/src/core/UBDisplayManager.cpp +++ b/src/core/UBDisplayManager.cpp @@ -73,7 +73,7 @@ void UBDisplayManager::initScreenIndexes() if (screenCount > 0) { mControlScreenIndex = mDesktop->primaryScreen(); - if (mDesktop->screenCount() > 1 && UBSettings::settings()->swapControlAndDisplayScreens->get().toBool()) + if (screenCount > 1 && UBSettings::settings()->swapControlAndDisplayScreens->get().toBool()) { mControlScreenIndex = mControlScreenIndex^1; } @@ -85,7 +85,7 @@ void UBDisplayManager::initScreenIndexes() mControlScreenIndex = -1; } - if (screenCount > 1) + if (screenCount > 1 && mUseMultiScreen) { mDisplayScreenIndex = mControlScreenIndex != 0 ? 0 : 1; mScreenIndexesRoles << Display; @@ -118,21 +118,17 @@ UBDisplayManager::~UBDisplayManager() int UBDisplayManager::numScreens() { - if (mUseMultiScreen) { - int screenCount = mDesktop->screenCount(); - // Some window managers report two screens when the two monitors are in "cloned" mode; this hack ensures - // that we consider this as just one screen. On most desktops, at least one of the following conditions is - // a good indicator of the displays being in cloned or extended mode. + int screenCount = mDesktop->screenCount(); + // Some window managers report two screens when the two monitors are in "cloned" mode; this hack ensures + // that we consider this as just one screen. On most desktops, at least one of the following conditions is + // a good indicator of the displays being in cloned or extended mode. #ifdef Q_OS_LINUX - if (screenCount > 1 - && (mDesktop->screenNumber(mDesktop->screen(0)) == mDesktop->screenNumber(mDesktop->screen(1)) - || mDesktop->screenGeometry(0) == mDesktop->screenGeometry(1))) - return 1; -#endif - return screenCount; - } - else + if (screenCount > 1 + && (mDesktop->screenNumber(mDesktop->screen(0)) == mDesktop->screenNumber(mDesktop->screen(1)) + || mDesktop->screenGeometry(0) == mDesktop->screenGeometry(1))) return 1; +#endif + return screenCount; } diff --git a/src/core/UBDisplayManager.h b/src/core/UBDisplayManager.h index 0c96cb80..eee2aef8 100644 --- a/src/core/UBDisplayManager.h +++ b/src/core/UBDisplayManager.h @@ -76,6 +76,8 @@ class UBDisplayManager : public QObject None = 0, Control, Display, Previous1, Previous2, Previous3, Previous4, Previous5 }; + bool useMultiScreen() { return mUseMultiScreen; } + void setUseMultiScreen(bool pUse); int controleScreenIndex()