[frontend] Detect windowHandle properly when GRenderWindow is not native.

This commit is contained in:
weakboson 2025-07-24 14:00:43 +08:00
parent b6a5462faf
commit 78c138d35f

View file

@ -284,8 +284,8 @@ struct NullRenderWidget : public RenderWidget {
GRenderWindow::GRenderWindow(GMainWindow* parent, EmuThread* emu_thread_,
std::shared_ptr<InputCommon::InputSubsystem> input_subsystem_,
Core::System& system_)
: QWidget(parent),
emu_thread(emu_thread_), input_subsystem{std::move(input_subsystem_)}, system{system_} {
: QWidget(parent), emu_thread(emu_thread_), input_subsystem{std::move(input_subsystem_)},
system{system_} {
setWindowTitle(QStringLiteral("eden %1 | %2-%3")
.arg(QString::fromUtf8(Common::g_build_name),
QString::fromUtf8(Common::g_scm_branch),
@ -1122,9 +1122,21 @@ void GRenderWindow::OnEmulationStopping() {
void GRenderWindow::showEvent(QShowEvent* event) {
QWidget::showEvent(event);
// windowHandle() is not initialized until the Window is shown, so we connect it here.
connect(windowHandle(), &QWindow::screenChanged, this, &GRenderWindow::OnFramebufferSizeChanged,
Qt::UniqueConnection);
QWindow* window = windowHandle();
if (!window) {
QWidget* nativeParent = nativeParentWidget();
if (nativeParent) {
window = nativeParent->windowHandle();
}
}
if (!window) {
LOG_ERROR(Frontend, "Failed to acquire QWindow pointer of GRenderWindow. ScreenChanged "
"signal not connected.");
} else {
// windowHandle() is not initialized until the Window is shown, so we connect it here.
connect(window, &QWindow::screenChanged, this, &GRenderWindow::OnFramebufferSizeChanged,
Qt::UniqueConnection);
}
}
bool GRenderWindow::eventFilter(QObject* object, QEvent* event) {