diff --git a/src/duckstation-qt/mainwindow.cpp b/src/duckstation-qt/mainwindow.cpp index 701b3727e..14c5af45f 100644 --- a/src/duckstation-qt/mainwindow.cpp +++ b/src/duckstation-qt/mainwindow.cpp @@ -2645,11 +2645,14 @@ void MainWindow::checkForSettingChanges() updateWindowState(); } -void MainWindow::getWindowInfo(WindowInfo* wi) +std::optional MainWindow::getWindowInfo() { - std::optional opt_wi(QtUtils::GetWindowInfoForWidget(this)); - if (opt_wi.has_value()) - *wi = opt_wi.value(); + if (!m_display_widget || isRenderingToMain()) + return QtUtils::GetWindowInfoForWidget(this); + else if (QWidget* widget = getDisplayContainer()) + return QtUtils::GetWindowInfoForWidget(widget); + else + return std::nullopt; } void MainWindow::onCheckForUpdatesActionTriggered() diff --git a/src/duckstation-qt/mainwindow.h b/src/duckstation-qt/mainwindow.h index 07e4b6cd0..cc98935a3 100644 --- a/src/duckstation-qt/mainwindow.h +++ b/src/duckstation-qt/mainwindow.h @@ -104,7 +104,7 @@ public Q_SLOTS: bool requestShutdown(bool allow_confirm = true, bool allow_save_to_state = true, bool save_state = true); void requestExit(bool allow_confirm = true); void checkForSettingChanges(); - void getWindowInfo(WindowInfo* wi); + std::optional getWindowInfo(); void checkForUpdates(bool display_message); diff --git a/src/duckstation-qt/qthost.cpp b/src/duckstation-qt/qthost.cpp index 002d2bd27..a2039160d 100644 --- a/src/duckstation-qt/qthost.cpp +++ b/src/duckstation-qt/qthost.cpp @@ -118,6 +118,7 @@ EmuThread::~EmuThread() = default; void QtHost::RegisterTypes() { // Register any standard types we need elsewhere + qRegisterMetaType>("std::optional()"); qRegisterMetaType>(); qRegisterMetaType>("std::function"); qRegisterMetaType>(); @@ -1632,11 +1633,8 @@ void Host::RequestExit(bool allow_confirm) std::optional Host::GetTopLevelWindowInfo() { - // Normally we'd just feed the std::optional all the way through here. But that won't work because of some bug - // in Qt 6.1, and we can't upgrade that because of raging/abusive Win7 users... to anyone still using that dead - // OS, this is a passive-aggressive "screw you". - WindowInfo ret; - QMetaObject::invokeMethod(g_main_window, "getWindowInfo", Qt::BlockingQueuedConnection, Q_ARG(WindowInfo*, &ret)); + std::optional ret; + QMetaObject::invokeMethod(g_main_window, &MainWindow::getWindowInfo, Qt::BlockingQueuedConnection, &ret); return ret; }