Qt: Windows no longer spawn in the top left on first launch
Jeffrey Pfau jeffrey@endrift.com
Mon, 17 Aug 2015 23:03:20 -0700
2 files changed,
11 insertions(+),
5 deletions(-)
M
src/platform/qt/Window.cpp
→
src/platform/qt/Window.cpp
@@ -5,6 +5,7 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */ #include "Window.h" +#include <QDesktopWidget> #include <QKeyEvent> #include <QKeySequence> #include <QMenuBar>@@ -87,11 +88,6 @@ m_screenWidget->setSizeHint(m_display->minimumSize() * 2);
m_screenWidget->setPixmap(m_logo); m_screenWidget->setLockAspectRatio(m_logo.width(), m_logo.height()); setCentralWidget(m_screenWidget); - - QVariant windowPos = m_config->getQtOption("windowPos"); - if (!windowPos.isNull()) { - move(windowPos.toPoint()); - } connect(m_controller, SIGNAL(gameStarted(GBAThread*)), this, SLOT(gameStarted(GBAThread*))); connect(m_controller, SIGNAL(gameStarted(GBAThread*)), &m_inputController, SLOT(suspendScreensaver()));@@ -465,6 +461,14 @@ }
void Window::showEvent(QShowEvent* event) { resizeFrame(m_screenWidget->sizeHint().width(), m_screenWidget->sizeHint().height()); + QVariant windowPos = m_config->getQtOption("windowPos"); + if (!windowPos.isNull()) { + move(windowPos.toPoint()); + } else { + QRect rect = frameGeometry(); + rect.moveCenter(QApplication::desktop()->availableGeometry().center()); + move(rect.topLeft()); + } } void Window::closeEvent(QCloseEvent* event) {