diff options
author | Volker Hilsheimer <volker.hilsheimer@qt.io> | 2021-10-16 10:37:13 +0200 |
---|---|---|
committer | Volker Hilsheimer <volker.hilsheimer@qt.io> | 2021-10-18 15:07:08 +0200 |
commit | 5564f1c96322d7c3f884d2e6f9b3a95e3134fb9f (patch) | |
tree | eb64c42400ebda8deea28505ad217cf91622b1ab /src | |
parent | efc48c96f11d0012ef98dc3aaaffa6ee2f585a02 (diff) |
Only reparent the InputPanel when necessary
The input panel needs to work also while a modal popup is open. Since
the concept of modality does not exist in Qt Quick, and is implemented
with an event-eating overlay, 4e8b3dd45ae4cc66a1b77cce901f80406b2a0f69
introduced the automatic reparenting of the integrated input panel so
that it a sibling of the overlay, with a higher z-value.
This effectively changed the parent item, and had negative side effects
to mechanisms such as anchoring.
This change only reparents the input panel if there is an overlay (using
the mechanism also used by the Qt Quick Control class QQuickOverlay)
that is visible when the input item changes, and sets the z-value to be
one above the overlay's. The prevents modal blocking during the overlay
session. When the input item changes again and the overlay is no longer
visible, then the parent and z value get reset.
This improves the situation, but is still not ideal, as during modal
sessions the anchoring of the input panel will still not work as
expected.
Add a test case that verifies that clicks go through to the keyboard
while a modal dialog is open.
Fixes: QTBUG-97075
Task-number: QTBUG-56918
Task-number: QTBUG-92881
Pick-to: 6.2 5.15
Change-Id: I7a5bcfebe7b69780234737a2311e08b2a6f60a4e
Reviewed-by: Jarkko Koivikko <jarkko.koivikko@code-q.fi>
Diffstat (limited to 'src')
-rw-r--r-- | src/virtualkeyboard/qvirtualkeyboardinputcontext_p.cpp | 21 | ||||
-rw-r--r-- | src/virtualkeyboard/qvirtualkeyboardinputcontext_p.h | 2 |
2 files changed, 19 insertions, 4 deletions
diff --git a/src/virtualkeyboard/qvirtualkeyboardinputcontext_p.cpp b/src/virtualkeyboard/qvirtualkeyboardinputcontext_p.cpp index 646dd6f6..4324ffe7 100644 --- a/src/virtualkeyboard/qvirtualkeyboardinputcontext_p.cpp +++ b/src/virtualkeyboard/qvirtualkeyboardinputcontext_p.cpp @@ -224,8 +224,6 @@ void QVirtualKeyboardInputContextPrivate::registerInputPanel(QObject *inputPanel VIRTUALKEYBOARD_DEBUG() << "QVirtualKeyboardInputContextPrivate::registerInputPanel():" << inputPanel; Q_ASSERT(!this->inputPanel); this->inputPanel = inputPanel; - if (QQuickItem *item = qobject_cast<QQuickItem *>(inputPanel)) - item->setZ(10000); } void QVirtualKeyboardInputContextPrivate::hideInputPanel() @@ -284,8 +282,23 @@ void QVirtualKeyboardInputContextPrivate::onInputItemChanged() high z-order will make sure it gets events also during a modal session. */ if (isDesktopPanel.isValid() && !isDesktopPanel.toBool()) { - if (QQuickWindow *quickWindow = quickItem->window()) - vkbPanel->setParentItem(quickWindow->contentItem()); + if (QQuickWindow *quickWindow = quickItem->window()) { + QQuickItem *overlay = quickWindow->property("_q_QQuickOverlay").value<QQuickItem*>(); + if (overlay && overlay->isVisible()) { + if (vkbPanel->parentItem() != overlay->parentItem()) { + inputPanelParentItem = vkbPanel->parentItem(); + inputPanelZ = vkbPanel->z(); + vkbPanel->setParentItem(overlay->parentItem()); + vkbPanel->setZ(overlay->z() + 1); + } + } else { + if (QQuickItem *oldParentItem = qobject_cast<QQuickItem *>(inputPanelParentItem.data())) { + vkbPanel->setParentItem(oldParentItem); + vkbPanel->setZ(inputPanelZ); + inputPanelParentItem = nullptr; + } + } + } } } } diff --git a/src/virtualkeyboard/qvirtualkeyboardinputcontext_p.h b/src/virtualkeyboard/qvirtualkeyboardinputcontext_p.h index 4d871f9b..ab2698d5 100644 --- a/src/virtualkeyboard/qvirtualkeyboardinputcontext_p.h +++ b/src/virtualkeyboard/qvirtualkeyboardinputcontext_p.h @@ -158,6 +158,8 @@ private: QVirtualKeyboardInputEngine *inputEngine; QtVirtualKeyboard::ShiftHandler *_shiftHandler; QPointer<QObject> inputPanel; + QPointer<QObject> inputPanelParentItem; + qreal inputPanelZ = .0; QRectF keyboardRect; QRectF previewRect; bool _previewVisible; |