From 68052de8a0f4bcb095fb700c314ec405f7238218 Mon Sep 17 00:00:00 2001 From: James Rowe Date: Tue, 24 Sep 2019 21:28:57 -0600 Subject: [PATCH] Workaround Qt bug that causes events to forward to the parent incorrectly --- src/citra_qt/bootmanager.cpp | 35 ++++++++++++++++++++++++++--------- src/citra_qt/bootmanager.h | 3 ++- 2 files changed, 28 insertions(+), 10 deletions(-) diff --git a/src/citra_qt/bootmanager.cpp b/src/citra_qt/bootmanager.cpp index 2d790556d6..a593c2a175 100644 --- a/src/citra_qt/bootmanager.cpp +++ b/src/citra_qt/bootmanager.cpp @@ -80,8 +80,9 @@ void EmuThread::run() { MicroProfileOnThreadExit(); #endif } -OpenGLWindow::OpenGLWindow(QWindow* parent, QOpenGLContext* shared_context) - : QWindow(parent), context(new QOpenGLContext(shared_context->parent())) { +OpenGLWindow::OpenGLWindow(QWindow* parent, QWidget* event_handler, QOpenGLContext* shared_context) + : QWindow(parent), event_handler(event_handler), + context(new QOpenGLContext(shared_context->parent())) { context->setShareContext(shared_context); context->setScreen(this->screen()); context->setFormat(shared_context->format()); @@ -91,11 +92,6 @@ OpenGLWindow::OpenGLWindow(QWindow* parent, QOpenGLContext* shared_context) // TODO: One of these flags might be interesting: WA_OpaquePaintEvent, WA_NoBackground, // WA_DontShowOnScreen, WA_DeleteOnClose - - // We set the WindowTransparnentForInput flag to let qt pass the processing through this QWindow - // through the event stack up to the parent QWidget and then up to the GRenderWindow grandparent - // that handles the event - setFlags(Qt::WindowTransparentForInput); } OpenGLWindow::~OpenGLWindow() { @@ -116,6 +112,27 @@ bool OpenGLWindow::event(QEvent* event) { case QEvent::UpdateRequest: Present(); return true; + case QEvent::MouseButtonPress: + case QEvent::MouseButtonRelease: + case QEvent::MouseButtonDblClick: + case QEvent::MouseMove: + case QEvent::FocusIn: + case QEvent::FocusOut: + case QEvent::FocusAboutToChange: + case QEvent::Enter: + case QEvent::Leave: + case QEvent::Wheel: + case QEvent::TabletMove: + case QEvent::TabletPress: + case QEvent::TabletRelease: + case QEvent::TabletEnterProximity: + case QEvent::TabletLeaveProximity: + case QEvent::TouchBegin: + case QEvent::TouchUpdate: + case QEvent::TouchEnd: + case QEvent::InputMethodQuery: + case QEvent::TouchCancel: + return QCoreApplication::sendEvent(event_handler, event); default: return QWindow::event(event); } @@ -308,8 +325,8 @@ void GRenderWindow::InitRenderTarget() { delete child_widget; } - child_window = - new OpenGLWindow(QWidget::window()->windowHandle(), QOpenGLContext::globalShareContext()); + child_window = new OpenGLWindow(QWidget::window()->windowHandle(), this, + QOpenGLContext::globalShareContext()); child_window->create(); child_widget = createWindowContainer(child_window, this); child_widget->resize(Core::kScreenTopWidth, Core::kScreenTopHeight + Core::kScreenBottomHeight); diff --git a/src/citra_qt/bootmanager.h b/src/citra_qt/bootmanager.h index c88037029f..44ed0f0599 100644 --- a/src/citra_qt/bootmanager.h +++ b/src/citra_qt/bootmanager.h @@ -121,7 +121,7 @@ signals: class OpenGLWindow : public QWindow { Q_OBJECT public: - explicit OpenGLWindow(QWindow* parent, QOpenGLContext* shared_context); + explicit OpenGLWindow(QWindow* parent, QWidget* event_handler, QOpenGLContext* shared_context); ~OpenGLWindow(); @@ -134,6 +134,7 @@ protected: private: QOpenGLContext* context; + QWidget* event_handler; }; class GRenderWindow : public QWidget, public Frontend::EmuWindow {