mirror of
https://github.com/Lime3DS/Lime3DS.git
synced 2024-11-02 08:25:07 +01:00
Workaround Qt bug that causes events to forward to the parent incorrectly
This commit is contained in:
parent
586b8e8b46
commit
68052de8a0
@ -80,8 +80,9 @@ void EmuThread::run() {
|
|||||||
MicroProfileOnThreadExit();
|
MicroProfileOnThreadExit();
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
OpenGLWindow::OpenGLWindow(QWindow* parent, QOpenGLContext* shared_context)
|
OpenGLWindow::OpenGLWindow(QWindow* parent, QWidget* event_handler, QOpenGLContext* shared_context)
|
||||||
: QWindow(parent), context(new QOpenGLContext(shared_context->parent())) {
|
: QWindow(parent), event_handler(event_handler),
|
||||||
|
context(new QOpenGLContext(shared_context->parent())) {
|
||||||
context->setShareContext(shared_context);
|
context->setShareContext(shared_context);
|
||||||
context->setScreen(this->screen());
|
context->setScreen(this->screen());
|
||||||
context->setFormat(shared_context->format());
|
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,
|
// TODO: One of these flags might be interesting: WA_OpaquePaintEvent, WA_NoBackground,
|
||||||
// WA_DontShowOnScreen, WA_DeleteOnClose
|
// 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() {
|
OpenGLWindow::~OpenGLWindow() {
|
||||||
@ -116,6 +112,27 @@ bool OpenGLWindow::event(QEvent* event) {
|
|||||||
case QEvent::UpdateRequest:
|
case QEvent::UpdateRequest:
|
||||||
Present();
|
Present();
|
||||||
return true;
|
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:
|
default:
|
||||||
return QWindow::event(event);
|
return QWindow::event(event);
|
||||||
}
|
}
|
||||||
@ -308,8 +325,8 @@ void GRenderWindow::InitRenderTarget() {
|
|||||||
delete child_widget;
|
delete child_widget;
|
||||||
}
|
}
|
||||||
|
|
||||||
child_window =
|
child_window = new OpenGLWindow(QWidget::window()->windowHandle(), this,
|
||||||
new OpenGLWindow(QWidget::window()->windowHandle(), QOpenGLContext::globalShareContext());
|
QOpenGLContext::globalShareContext());
|
||||||
child_window->create();
|
child_window->create();
|
||||||
child_widget = createWindowContainer(child_window, this);
|
child_widget = createWindowContainer(child_window, this);
|
||||||
child_widget->resize(Core::kScreenTopWidth, Core::kScreenTopHeight + Core::kScreenBottomHeight);
|
child_widget->resize(Core::kScreenTopWidth, Core::kScreenTopHeight + Core::kScreenBottomHeight);
|
||||||
|
@ -121,7 +121,7 @@ signals:
|
|||||||
class OpenGLWindow : public QWindow {
|
class OpenGLWindow : public QWindow {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
explicit OpenGLWindow(QWindow* parent, QOpenGLContext* shared_context);
|
explicit OpenGLWindow(QWindow* parent, QWidget* event_handler, QOpenGLContext* shared_context);
|
||||||
|
|
||||||
~OpenGLWindow();
|
~OpenGLWindow();
|
||||||
|
|
||||||
@ -134,6 +134,7 @@ protected:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
QOpenGLContext* context;
|
QOpenGLContext* context;
|
||||||
|
QWidget* event_handler;
|
||||||
};
|
};
|
||||||
|
|
||||||
class GRenderWindow : public QWidget, public Frontend::EmuWindow {
|
class GRenderWindow : public QWidget, public Frontend::EmuWindow {
|
||||||
|
Loading…
Reference in New Issue
Block a user