Qt: Fix race condition when switching to fullscreen

Stops the window opening in the corner of the screen occasionally in Wayland.
This commit is contained in:
Connor McLaughlin 2021-07-17 22:58:31 +10:00
parent d6c4c2dda9
commit d519ba3d59
3 changed files with 5 additions and 3 deletions

View File

@ -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<WindowInfo> 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<WindowInfo> wi = m_display_widget->getWindowInfo();
if (!wi.has_value())
{

View File

@ -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();

View File

@ -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();