diff options
author | Jarkko Koivikko <jarkko.koivikko@code-q.fi> | 2023-02-05 20:42:08 +0200 |
---|---|---|
committer | Jarkko Koivikko <jarkko.koivikko@code-q.fi> | 2023-03-24 19:39:45 +0200 |
commit | c1c9d37a4f01c51558299318f38a0fb0fec83aa3 (patch) | |
tree | 5841cfe2d74fdb9c9171990cc8900b36bca91099 /src/virtualkeyboard/desktopinputselectioncontrol.cpp | |
parent | 43140ac27358c9cc285e464a1c1c7df813d2f942 (diff) |
Fix DesktopInputSelectionControl
Previously, the desktop selection handles were not functioning
correctly. They were displayed at the wrong location and were not
always appearing when needed. This issue has been resolved, ensuring
the selection handles are now working as intended.
Pick-to: 6.5
Change-Id: Ic546361285a88c06bf3d28cd545c2bda17ddadac
Reviewed-by: Inho Lee <inho.lee@qt.io>
Diffstat (limited to 'src/virtualkeyboard/desktopinputselectioncontrol.cpp')
-rw-r--r-- | src/virtualkeyboard/desktopinputselectioncontrol.cpp | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/src/virtualkeyboard/desktopinputselectioncontrol.cpp b/src/virtualkeyboard/desktopinputselectioncontrol.cpp index 1c99b583..0fc5d646 100644 --- a/src/virtualkeyboard/desktopinputselectioncontrol.cpp +++ b/src/virtualkeyboard/desktopinputselectioncontrol.cpp @@ -180,6 +180,8 @@ void DesktopInputSelectionControl::setEnabled(bool enable) connect(m_inputContext, &QVirtualKeyboardInputContext::cursorRectangleChanged, this, &DesktopInputSelectionControl::updateCursorHandlePosition); connect(m_inputContext, &QVirtualKeyboardInputContext::anchorRectIntersectsClipRectChanged, this, &DesktopInputSelectionControl::updateVisibility); connect(m_inputContext, &QVirtualKeyboardInputContext::cursorRectIntersectsClipRectChanged, this, &DesktopInputSelectionControl::updateVisibility); + updateAnchorHandlePosition(); + updateCursorHandlePosition(); if (focusWindow) focusWindow->installEventFilter(this); } else { @@ -230,8 +232,8 @@ bool DesktopInputSelectionControl::eventFilter(QObject *object, QEvent *event) for (int i = 0; i <= CursorHandle; ++i) { SelectionHandleInfo &h = handles[i]; - QPoint curHandleCenter = focusWindow->mapToGlobal(h.rect.center()); // ### map to desktoppanel - const QPoint delta = mousePos - curHandleCenter; + QPoint curHandleTopCenter = focusWindow->mapToGlobal(QPoint(h.rect.x() + qRound((qreal)h.rect.width() / 2), h.rect.top())); // ### map to desktoppanel + const QPoint delta = mousePos - curHandleTopCenter; h.delta = delta; h.squaredDistance = QPoint::dotProduct(delta, delta); } @@ -243,7 +245,7 @@ bool DesktopInputSelectionControl::eventFilter(QObject *object, QEvent *event) const QPoint windowPos = focusWindow->mapFromGlobal(mousePos); if (m_anchorHandleVisible && handles[closestHandle].rect.contains(windowPos)) { m_currentDragHandle = closestHandle; - m_distanceBetweenMouseAndCursor = handles[closestHandle].delta - QPoint(0, m_handleWindowSize.height()/2 + 4); + m_distanceBetweenMouseAndCursor = handles[closestHandle].delta; m_handleState = HandleIsHeld; m_handleDragStartedPosition = mousePos; const QRect otherRect = handles[1 - closestHandle].rect; |