From eca2e881d92c67c2bfee1bc5b77095267d690bb6 Mon Sep 17 00:00:00 2001 From: Tats Date: Sat, 26 Mar 2016 18:17:57 -0400 Subject: [PATCH] Manage properly fullscreen in OutputGLWindow: it was possible to have the window without the fullscreen, which caused issues in some circumstances. --- MainWindow.cpp | 2 +- OutputGLWindow.cpp | 30 +++++++++++------------------- OutputGLWindow.h | 3 +++ 3 files changed, 15 insertions(+), 20 deletions(-) diff --git a/MainWindow.cpp b/MainWindow.cpp index 47ec914..dcff1cc 100644 --- a/MainWindow.cpp +++ b/MainWindow.cpp @@ -1630,7 +1630,7 @@ void MainWindow::createActions() // Manage fullscreen/modal show of GL output window. connect(outputFullScreenAction, SIGNAL(toggled(bool)), outputWindow, SLOT(setFullScreen(bool))); // When closing the GL output window or hit ESC key, uncheck the action in menu. - connect(outputWindow, SIGNAL(closed()), outputFullScreenAction, SLOT(toggle())); +// connect(outputWindow, SIGNAL(closed()), outputFullScreenAction, SLOT(toggle())); connect(QApplication::desktop(), SIGNAL(screenCountChanged(int)), this, SLOT(updateOutputAction(int))); // Create hiden action for closing output window QAction *closeOutput = new QAction(tr("Close output"), this); diff --git a/OutputGLWindow.cpp b/OutputGLWindow.cpp index 2d56cb8..ca5e3da 100644 --- a/OutputGLWindow.cpp +++ b/OutputGLWindow.cpp @@ -78,33 +78,25 @@ void OutputGLWindow::setFullScreen(bool fullscreen) { if (fullscreen) { - // Check if user is on multiple screen - int screen = (QApplication::desktop()->screenCount() > 1 ? 1 : 0); - // Hide cursor - setCursorVisible(!fullscreen); - // Activate crosshair in fullscreen mode. - // should be only drawn if the controls should be shown - canvas->setDisplayCrosshair(fullscreen && canvas->getMainWindow()->displayControls()); + // Check if user is on multiple screen (always pre + int screen = _getPreferredScreen(); //Move window to second screen before fullscreening it. setGeometry(QApplication::desktop()->screenGeometry(screen)); - //The problem related to the full screen on linux seems to be resolved - // with Qt 5.5 at least on Debian but define macro anyway #ifdef Q_OS_LINUX + // The problem related to the full screen on linux seems to be resolved with Qt 5.5 on Debian. + // However this still seems to be needed on Ubuntu 15.10. + // Fix source: + // http://stackoverflow.com/questions/12645880/fullscreen-for-qdialog-from-within-mainwindow-only-working-sometimes setWindowFlags(Qt::Window); - setVisible(true); - setWindowState( windowState() ^ Qt::WindowFullScreen ); - show(); -#else - showFullScreen(); #endif + showFullScreen(); } else { -#ifdef Q_OS_LINUX - setWindowFlags( windowFlags() & ~Qt::Window ); -#else - showNormal(); -#endif + hide(); + } +} + void OutputGLWindow::setDisplayCrosshair(bool crosshair) { diff --git a/OutputGLWindow.h b/OutputGLWindow.h index 3ab0974..110c476 100644 --- a/OutputGLWindow.h +++ b/OutputGLWindow.h @@ -62,6 +62,9 @@ public: private: OutputGLCanvas* canvas; + int _getPreferredScreen() const { + return QApplication::desktop()->screenCount()-1; + } }; MM_END_NAMESPACE