diff options
author | Pekka Gehör <pekka.gehor@qt.io> | 2022-06-22 12:59:47 +0300 |
---|---|---|
committer | Pekka Gehör <pekka.gehor@qt.io> | 2022-06-29 09:52:36 +0000 |
commit | 93ab6fa19bf438e96472d28fc2f3786d8b18fa4b (patch) | |
tree | bb1e924173056d2ddb5f7b7af3271774fa83609d /src/plugins/platforms/android | |
parent | fae993368cbdff9e7cb236618405d82291d39147 (diff) |
Android: Fix the offset of the EditPopupMenu
Fix the offset of the EditPopupMenu on application window.
Issue caused by a5bb7b3ca510c301baf84e1dd46d5aeeb4986eb2
Fixes: QTBUG-71900
Change-Id: I9161d59cc13b2fab487ec27d9ba0e38f9240d9bc
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
Diffstat (limited to 'src/plugins/platforms/android')
-rw-r--r-- | src/plugins/platforms/android/qandroidinputcontext.cpp | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/src/plugins/platforms/android/qandroidinputcontext.cpp b/src/plugins/platforms/android/qandroidinputcontext.cpp index 9a0e78c7ec..1a9f71eabd 100644 --- a/src/plugins/platforms/android/qandroidinputcontext.cpp +++ b/src/plugins/platforms/android/qandroidinputcontext.cpp @@ -647,14 +647,25 @@ void QAndroidInputContext::updateSelectionHandles() } auto curRect = im->cursorRectangle(); - QPoint cursorPoint(window->mapToGlobal(QPoint(curRect.x() + (curRect.width() / 2), curRect.y() + curRect.height()))); - QPoint editMenuPoint(cursorPoint.x(), cursorPoint.y()); + QPoint cursorPointGlobal = window->mapToGlobal(QPoint(curRect.x() + (curRect.width() / 2), curRect.y() + curRect.height())); + QPoint cursorPoint(curRect.center().x(), curRect.bottom()); + int x = curRect.x(); + int y = curRect.y(); + + // Use x and y for the editMenuPoint from the cursorPointGlobal when the cursor is in the Dialog + if (cursorPointGlobal != cursorPoint) { + x = cursorPointGlobal.x(); + y = cursorPointGlobal.y(); + } + + QPoint editMenuPoint(x, y); m_handleMode &= ShowEditPopup; m_handleMode |= ShowCursor; uint32_t buttons = EditContext::PasteButton; if (!query.value(Qt::ImSurroundingText).toString().isEmpty()) buttons |= EditContext::SelectAllButton; - QtAndroidInput::updateHandles(m_handleMode, editMenuPoint * pixelDensity, buttons, cursorPoint * pixelDensity); + QtAndroidInput::updateHandles(m_handleMode, editMenuPoint * pixelDensity, buttons, + cursorPointGlobal * pixelDensity); // The VK is hidden, reset the timer if (m_hideCursorHandleTimer.isActive()) m_hideCursorHandleTimer.start(); |