From d519ba3d595b26a6a6ec91a4b27b3ccb25e64442 Mon Sep 17 00:00:00 2001 From: Connor McLaughlin Date: Sat, 17 Jul 2021 22:58:31 +1000 Subject: [PATCH] Qt: Fix race condition when switching to fullscreen Stops the window opening in the corner of the screen occasionally in Wayland. --- src/duckstation-qt/mainwindow.cpp | 4 ++++ src/duckstation-qt/qthostinterface.cpp | 2 -- src/duckstation-qt/qthostinterface.h | 2 +- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/duckstation-qt/mainwindow.cpp b/src/duckstation-qt/mainwindow.cpp index 2d74a731b..969bedd07 100644 --- a/src/duckstation-qt/mainwindow.cpp +++ b/src/duckstation-qt/mainwindow.cpp @@ -160,6 +160,8 @@ QtDisplayWidget* MainWindow::createDisplay(QThread* worker_thread, bool fullscre // we need the surface visible.. this might be able to be replaced with something else QCoreApplication::processEvents(QEventLoop::ExcludeUserInputEvents); + m_host_interface->connectDisplaySignals(m_display_widget); + std::optional wi = m_display_widget->getWindowInfo(); if (!wi.has_value()) { @@ -262,6 +264,8 @@ QtDisplayWidget* MainWindow::updateDisplay(QThread* worker_thread, bool fullscre // we need the surface visible.. this might be able to be replaced with something else QCoreApplication::processEvents(QEventLoop::ExcludeUserInputEvents); + m_host_interface->connectDisplaySignals(m_display_widget); + std::optional wi = m_display_widget->getWindowInfo(); if (!wi.has_value()) { diff --git a/src/duckstation-qt/qthostinterface.cpp b/src/duckstation-qt/qthostinterface.cpp index c74c79435..cbffe375c 100644 --- a/src/duckstation-qt/qthostinterface.cpp +++ b/src/duckstation-qt/qthostinterface.cpp @@ -578,7 +578,6 @@ bool QtHostInterface::AcquireHostDisplay() return false; } - connectDisplaySignals(display_widget); m_is_exclusive_fullscreen = m_display->IsFullscreen(); return true; } @@ -641,7 +640,6 @@ void QtHostInterface::updateDisplayState() if (!display_widget || !m_display->MakeRenderContextCurrent()) Panic("Failed to make device context current after updating"); - connectDisplaySignals(display_widget); m_is_exclusive_fullscreen = m_display->IsFullscreen(); OnHostDisplayResized(); diff --git a/src/duckstation-qt/qthostinterface.h b/src/duckstation-qt/qthostinterface.h index a18d8fb63..bfedecbb9 100644 --- a/src/duckstation-qt/qthostinterface.h +++ b/src/duckstation-qt/qthostinterface.h @@ -90,6 +90,7 @@ public: ALWAYS_INLINE MainWindow* getMainWindow() const { return m_main_window; } void setMainWindow(MainWindow* window); HostDisplay* createHostDisplay(); + void connectDisplaySignals(QtDisplayWidget* widget); void populateLoadStateMenu(const char* game_code, QMenu* menu); void populateSaveStateMenu(const char* game_code, QMenu* menu); @@ -269,7 +270,6 @@ private: void shutdownOnThread(); void installTranslator(); void renderDisplay(); - void connectDisplaySignals(QtDisplayWidget* widget); void checkRenderToMainState(); void updateDisplayState(); void queueSettingsSave();