diff --git a/src/duckstation-qt/displaywidget.cpp b/src/duckstation-qt/displaywidget.cpp index 10b8ce714..8fee7f9df 100644 --- a/src/duckstation-qt/displaywidget.cpp +++ b/src/duckstation-qt/displaywidget.cpp @@ -135,7 +135,9 @@ void DisplayWidget::handleCloseEvent(QCloseEvent* event) { // Closing the separate widget will either cancel the close, or trigger shutdown. // In the latter case, it's going to destroy us, so don't let Qt do it first. - if (QtHost::IsSystemValid()) + // Treat a close event while fullscreen as an exit, that way ALT+F4 closes DuckStation, + // rather than just the game. + if (QtHost::IsSystemValid() && !isActuallyFullscreen()) { QMetaObject::invokeMethod(g_main_window, "requestShutdown", Q_ARG(bool, true), Q_ARG(bool, true), Q_ARG(bool, false)); @@ -156,12 +158,19 @@ void DisplayWidget::destroy() // See Qt documentation, entire application is in full screen state, and the main // window will get reopened fullscreen instead of windowed if we don't close the // fullscreen window first. - if (isFullScreen()) + if (isActuallyFullscreen()) close(); #endif deleteLater(); } +bool DisplayWidget::isActuallyFullscreen() const +{ + // I hate you QtWayland... have to check the parent, not ourselves. + QWidget* container = qobject_cast(parent()); + return container ? container->isFullScreen() : isFullScreen(); +} + void DisplayWidget::updateCenterPos() { #ifdef _WIN32 diff --git a/src/duckstation-qt/displaywidget.h b/src/duckstation-qt/displaywidget.h index 8f26e6c04..be357fe9b 100644 --- a/src/duckstation-qt/displaywidget.h +++ b/src/duckstation-qt/displaywidget.h @@ -46,6 +46,7 @@ protected: bool event(QEvent* event) override; private: + bool isActuallyFullscreen() const; void updateCenterPos(); QPoint m_relative_mouse_start_pos{};