Qt: Make ALT+F4 while fullscreen exit PCSX2

This commit is contained in:
Stenzek 2023-11-20 23:27:32 +10:00 committed by Connor McLaughlin
parent 0ebc1ce7b2
commit 0770249da1
2 changed files with 12 additions and 2 deletions

View File

@ -148,7 +148,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::IsVMValid())
// Treat a close event while fullscreen as an exit, that way ALT+F4 closes PCSX2,
// rather than just the game.
if (QtHost::IsVMValid() && !isActuallyFullscreen())
{
QMetaObject::invokeMethod(g_main_window, "requestShutdown", Q_ARG(bool, true),
Q_ARG(bool, true), Q_ARG(bool, false));
@ -170,12 +172,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<QWidget*>(parent());
return container ? container->isFullScreen() : isFullScreen();
}
void DisplayWidget::updateCenterPos()
{
#ifdef _WIN32

View File

@ -51,6 +51,7 @@ protected:
bool event(QEvent* event) override;
private:
bool isActuallyFullscreen() const;
void updateCenterPos();
QPoint m_relative_mouse_start_pos{};