diff options
author | Liang Qi <liang.qi@qt.io> | 2018-01-19 10:49:56 +0100 |
---|---|---|
committer | Liang Qi <liang.qi@qt.io> | 2018-01-24 09:34:11 +0100 |
commit | 2570b801c74832a3c83a8b56ad0f76812969e190 (patch) | |
tree | c4bd64d8e6b15b507f51f550ba13a0c062528d65 /src/quickwidgets | |
parent | 1b96186d1418adcba85fdbfd794da2d2f6ea122d (diff) | |
parent | 706a6647db695cdeb854ef1bf956ded56b498f78 (diff) |
Merge remote-tracking branch 'origin/5.9' into 5.10
Conflicts:
.qmake.conf
src/qml/compiler/qv4codegen.cpp
src/qml/compiler/qv4compileddata_p.h
src/qml/debugger/qqmlprofiler_p.h
src/qml/jsruntime/qv4engine.cpp
src/qml/memory/qv4mm.cpp
src/qml/qml/qqmlcomponent.cpp
src/qml/qml/qqmlobjectcreator.cpp
src/qml/qml/qqmlobjectcreator_p.h
src/qml/types/qqmldelegatemodel.cpp
src/quick/items/qquickitem_p.h
src/quick/items/qquickwindow.cpp
tests/auto/quick/touchmouse/BLACKLIST
tests/benchmarks/qml/holistic/tst_holistic.cpp
Change-Id: I520f349ab4b048dd337d9647113564fc257865c2
Diffstat (limited to 'src/quickwidgets')
-rw-r--r-- | src/quickwidgets/qquickwidget.cpp | 53 |
1 files changed, 42 insertions, 11 deletions
diff --git a/src/quickwidgets/qquickwidget.cpp b/src/quickwidgets/qquickwidget.cpp index a64fabcfc2..94f00f7d36 100644 --- a/src/quickwidgets/qquickwidget.cpp +++ b/src/quickwidgets/qquickwidget.cpp @@ -935,7 +935,7 @@ void QQuickWidget::createFramebufferObject() } QOpenGLContext *shareWindowContext = QWidgetPrivate::get(window())->shareContext(); - if (shareWindowContext && context->shareContext() != shareWindowContext) { + if (shareWindowContext && context->shareContext() != shareWindowContext && !qGuiApp->testAttribute(Qt::AA_ShareOpenGLContexts)) { context->setShareContext(shareWindowContext); context->setScreen(shareWindowContext->screen()); if (!context->create()) @@ -1247,11 +1247,11 @@ void QQuickWidget::mouseMoveEvent(QMouseEvent *e) Q_QUICK_INPUT_PROFILE(QQuickProfiler::Mouse, QQuickProfiler::InputMouseMove, e->localPos().x(), e->localPos().y()); - // Use the constructor taking localPos and screenPos. That puts localPos into the - // event's localPos and windowPos, and screenPos into the event's screenPos. This way - // the windowPos in e is ignored and is replaced by localPos. This is necessary - // because QQuickWindow thinks of itself as a top-level window always. - QMouseEvent mappedEvent(e->type(), e->localPos(), e->windowPos(), e->screenPos(), + // Put localPos into the event's localPos and windowPos, and screenPos into the + // event's screenPos. This way the windowPos in e is ignored and is replaced by + // localPos. This is necessary because QQuickWindow thinks of itself as a + // top-level window always. + QMouseEvent mappedEvent(e->type(), e->localPos(), e->localPos(), e->screenPos(), e->button(), e->buttons(), e->modifiers(), e->source()); QCoreApplication::sendEvent(d->offscreenWindow, &mappedEvent); e->setAccepted(mappedEvent.isAccepted()); @@ -1266,11 +1266,11 @@ void QQuickWidget::mouseDoubleClickEvent(QMouseEvent *e) // As the second mouse press is suppressed in widget windows we emulate it here for QML. // See QTBUG-25831 - QMouseEvent pressEvent(QEvent::MouseButtonPress, e->localPos(), e->windowPos(), e->screenPos(), + QMouseEvent pressEvent(QEvent::MouseButtonPress, e->localPos(), e->localPos(), e->screenPos(), e->button(), e->buttons(), e->modifiers(), e->source()); QCoreApplication::sendEvent(d->offscreenWindow, &pressEvent); e->setAccepted(pressEvent.isAccepted()); - QMouseEvent mappedEvent(e->type(), e->localPos(), e->windowPos(), e->screenPos(), + QMouseEvent mappedEvent(e->type(), e->localPos(), e->localPos(), e->screenPos(), e->button(), e->buttons(), e->modifiers(), e->source()); QCoreApplication::sendEvent(d->offscreenWindow, &mappedEvent); } @@ -1331,7 +1331,7 @@ void QQuickWidget::mousePressEvent(QMouseEvent *e) Q_QUICK_INPUT_PROFILE(QQuickProfiler::Mouse, QQuickProfiler::InputMousePress, e->button(), e->buttons()); - QMouseEvent mappedEvent(e->type(), e->localPos(), e->windowPos(), e->screenPos(), + QMouseEvent mappedEvent(e->type(), e->localPos(), e->localPos(), e->screenPos(), e->button(), e->buttons(), e->modifiers(), e->source()); QCoreApplication::sendEvent(d->offscreenWindow, &mappedEvent); e->setAccepted(mappedEvent.isAccepted()); @@ -1344,7 +1344,7 @@ void QQuickWidget::mouseReleaseEvent(QMouseEvent *e) Q_QUICK_INPUT_PROFILE(QQuickProfiler::Mouse, QQuickProfiler::InputMouseRelease, e->button(), e->buttons()); - QMouseEvent mappedEvent(e->type(), e->localPos(), e->windowPos(), e->screenPos(), + QMouseEvent mappedEvent(e->type(), e->localPos(), e->localPos(), e->screenPos(), e->button(), e->buttons(), e->modifiers(), e->source()); QCoreApplication::sendEvent(d->offscreenWindow, &mappedEvent); e->setAccepted(mappedEvent.isAccepted()); @@ -1395,6 +1395,28 @@ static Qt::WindowState resolveWindowState(Qt::WindowStates states) return Qt::WindowNoState; } +static void remapInputMethodQueryEvent(QObject *object, QInputMethodQueryEvent *e) +{ + auto item = qobject_cast<QQuickItem *>(object); + if (!item) + return; + + // Remap all QRectF values. + for (auto query : {Qt::ImCursorRectangle, Qt::ImAnchorRectangle, Qt::ImInputItemClipRectangle}) { + if (e->queries() & query) { + auto value = e->value(query); + if (value.canConvert<QRectF>()) + e->setValue(query, item->mapRectToScene(value.toRectF())); + } + } + // Remap all QPointF values. + if (e->queries() & Qt::ImCursorPosition) { + auto value = e->value(Qt::ImCursorPosition); + if (value.canConvert<QPointF>()) + e->setValue(Qt::ImCursorPosition, item->mapToScene(value.toPointF())); + } +} + /*! \reimp */ bool QQuickWidget::event(QEvent *e) { @@ -1411,8 +1433,17 @@ bool QQuickWidget::event(QEvent *e) return QCoreApplication::sendEvent(d->offscreenWindow, e); case QEvent::InputMethod: - case QEvent::InputMethodQuery: return QCoreApplication::sendEvent(d->offscreenWindow->focusObject(), e); + case QEvent::InputMethodQuery: + { + bool eventResult = QCoreApplication::sendEvent(d->offscreenWindow->focusObject(), e); + // The result in focusObject are based on offscreenWindow. But + // the inputMethodTransform won't get updated because the focus + // is on QQuickWidget. We need to remap the value based on the + // widget. + remapInputMethodQueryEvent(d->offscreenWindow->focusObject(), static_cast<QInputMethodQueryEvent *>(e)); + return eventResult; + } case QEvent::WindowChangeInternal: d->handleWindowChange(); |