Qt: Fix Host::GetTopLevelWindowInfo() in nogui mode

This commit is contained in:
Stenzek 2022-12-30 14:51:40 +10:00 committed by refractionpcsx2
parent 4e5692e935
commit f83fc9ba27
2 changed files with 15 additions and 2 deletions

View File

@ -1295,7 +1295,12 @@ void MainWindow::checkForSettingChanges()
std::optional<WindowInfo> MainWindow::getWindowInfo()
{
if (isRenderingToMain())
return QtUtils::GetWindowInfoForWidget(this);
else if (QWidget* widget = getDisplayContainer())
return QtUtils::GetWindowInfoForWidget(widget);
else
return std::nullopt;
}
void Host::InvalidateSaveStateCache()

View File

@ -40,6 +40,8 @@
#include <array>
#include <map>
#include "common/Console.h"
#if defined(_WIN32)
#include "common/RedtapeWindows.h"
#elif !defined(APPLE)
@ -222,6 +224,12 @@ namespace QtUtils
std::optional<WindowInfo> GetWindowInfoForWidget(QWidget* widget)
{
if (!widget->isVisible())
{
Console.WriteLn("Returning null window info for widget because it is not visible.");
return std::nullopt;
}
WindowInfo wi;
// Windows and Apple are easy here since there's no display connection.
@ -248,7 +256,7 @@ namespace QtUtils
}
else
{
qCritical() << "Unknown PNI platform " << platform_name;
Console.WriteLn("Unknown PNI platform '%s'.", platform_name.toUtf8().constData());
return std::nullopt;
}
#endif