From 1f899737d9825f60e6713fed4ff6d368dda32e56 Mon Sep 17 00:00:00 2001 From: Jeffrey Pfau Date: Mon, 17 Aug 2015 23:03:20 -0700 Subject: [PATCH] Qt: Windows no longer spawn in the top left on first launch --- CHANGES | 2 ++ src/platform/qt/Window.cpp | 14 +++++++++----- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/CHANGES b/CHANGES index 5096fba14..d314caf1c 100644 --- a/CHANGES +++ b/CHANGES @@ -1,4 +1,6 @@ 0.4.0: (Future) +Bugfixes: + - Qt: Windows no longer spawn in the top left on first launch Misc: - Qt: Window size command line options are now supported - Qt: Increase usability of key mapper diff --git a/src/platform/qt/Window.cpp b/src/platform/qt/Window.cpp index 6307fdf12..721cec6a8 100644 --- a/src/platform/qt/Window.cpp +++ b/src/platform/qt/Window.cpp @@ -5,6 +5,7 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ #include "Window.h" +#include #include #include #include @@ -88,11 +89,6 @@ Window::Window(ConfigController* config, int playerId, QWidget* parent) 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())); connect(m_controller, SIGNAL(gameStopped(GBAThread*)), m_display, SLOT(stopDrawing())); @@ -465,6 +461,14 @@ void Window::resizeEvent(QResizeEvent* event) { 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) {