mirror of
https://github.com/RetroDECK/Duckstation.git
synced 2024-11-22 22:05:38 +00:00
Qt: Make ALT+F4 while fullscreen exit DuckStation
This commit is contained in:
parent
a705884342
commit
cca901c4c6
|
@ -135,7 +135,9 @@ void DisplayWidget::handleCloseEvent(QCloseEvent* event)
|
||||||
{
|
{
|
||||||
// Closing the separate widget will either cancel the close, or trigger shutdown.
|
// 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.
|
// 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),
|
QMetaObject::invokeMethod(g_main_window, "requestShutdown", Q_ARG(bool, true), Q_ARG(bool, true),
|
||||||
Q_ARG(bool, false));
|
Q_ARG(bool, false));
|
||||||
|
@ -156,12 +158,19 @@ void DisplayWidget::destroy()
|
||||||
// See Qt documentation, entire application is in full screen state, and the main
|
// 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
|
// window will get reopened fullscreen instead of windowed if we don't close the
|
||||||
// fullscreen window first.
|
// fullscreen window first.
|
||||||
if (isFullScreen())
|
if (isActuallyFullscreen())
|
||||||
close();
|
close();
|
||||||
#endif
|
#endif
|
||||||
deleteLater();
|
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()
|
void DisplayWidget::updateCenterPos()
|
||||||
{
|
{
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
|
|
|
@ -46,6 +46,7 @@ protected:
|
||||||
bool event(QEvent* event) override;
|
bool event(QEvent* event) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
bool isActuallyFullscreen() const;
|
||||||
void updateCenterPos();
|
void updateCenterPos();
|
||||||
|
|
||||||
QPoint m_relative_mouse_start_pos{};
|
QPoint m_relative_mouse_start_pos{};
|
||||||
|
|
Loading…
Reference in a new issue