summaryrefslogtreecommitdiffstats
path: root/src/plugins/platforms/ios/qiostextinputoverlay.mm
diff options
context:
space:
mode:
authorMorten Sørvig <morten.sorvig@qt.io>2021-01-26 12:51:11 +0100
committerMorten Sørvig <morten.sorvig@qt.io>2021-02-01 22:44:51 +0100
commitb23f5621d7e5275dbb3f96f6b46f691c8b19a13d (patch)
tree984b4e100d73dc3c54bec295442f5899a29d533a /src/plugins/platforms/ios/qiostextinputoverlay.mm
parentdafe9e23638c4fe272044fae91380a225e19193a (diff)
iOS: Use new QPlatformInputContext geometry API
This enables support for QT_SCALE_FACTOR on iOS. Fixes: QTBUG-74978 Change-Id: Ibcf0741c178e44802065e472e096a5f4c7d6f3cf Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
Diffstat (limited to 'src/plugins/platforms/ios/qiostextinputoverlay.mm')
-rw-r--r--src/plugins/platforms/ios/qiostextinputoverlay.mm31
1 files changed, 15 insertions, 16 deletions
diff --git a/src/plugins/platforms/ios/qiostextinputoverlay.mm b/src/plugins/platforms/ios/qiostextinputoverlay.mm
index 15be19c6bc..e7f9e5aa79 100644
--- a/src/plugins/platforms/ios/qiostextinputoverlay.mm
+++ b/src/plugins/platforms/ios/qiostextinputoverlay.mm
@@ -146,8 +146,9 @@ static void executeBlockWithoutAnimation(Block block)
if (visible) {
// Note that the contents of the edit menu is decided by
// first responder, which is normally QIOSTextResponder.
- QRectF cr = qApp->inputMethod()->cursorRectangle();
- QRectF ar = qApp->inputMethod()->anchorRectangle();
+ QRectF cr = QPlatformInputContext::cursorRectangle();
+ QRectF ar = QPlatformInputContext::anchorRectangle();
+
CGRect targetRect = cr.united(ar).toCGRect();
UIView *focusView = reinterpret_cast<UIView *>(qApp->focusWindow()->winId());
[[UIMenuController sharedMenuController] setTargetRect:targetRect inView:focusView];
@@ -627,13 +628,13 @@ static void executeBlockWithoutAnimation(Block block)
- (BOOL)acceptTouchesBegan:(QPointF)touchPoint
{
- QRectF inputRect = QGuiApplication::inputMethod()->inputItemClipRectangle();
+ QRectF inputRect = QPlatformInputContext::inputItemRectangle();
return !hasSelection() && inputRect.contains(touchPoint);
}
- (void)updateFocalPoint:(QPointF)touchPoint
{
- platformInputContext()->setSelectionOnFocusObject(touchPoint, touchPoint);
+ QPlatformInputContext::setSelectionOnFocusObject(touchPoint, touchPoint);
self.focalPoint = touchPoint;
}
@@ -783,8 +784,8 @@ static void executeBlockWithoutAnimation(Block block)
// Accept the touch if it "overlaps" with any of the handles
const int handleRadius = 50;
- QPointF cursorCenter = qApp->inputMethod()->cursorRectangle().center();
- QPointF anchorCenter = qApp->inputMethod()->anchorRectangle().center();
+ QPointF cursorCenter = QPlatformInputContext::cursorRectangle().center();
+ QPointF anchorCenter = QPlatformInputContext::anchorRectangle().center();
QPointF cursorOffset = QPointF(cursorCenter.x() - touchPoint.x(), cursorCenter.y() - touchPoint.y());
QPointF anchorOffset = QPointF(anchorCenter.x() - touchPoint.x(), anchorCenter.y() - touchPoint.y());
double cursorDist = hypot(cursorOffset.x(), cursorOffset.y());
@@ -812,8 +813,7 @@ static void executeBlockWithoutAnimation(Block block)
// Get the text position under the touch
SelectionPair selection = querySelection();
- const QTransform mapToLocal = QGuiApplication::inputMethod()->inputItemTransform().inverted();
- int touchTextPos = QInputMethod::queryFocusObject(Qt::ImCursorPosition, touchPoint * mapToLocal).toInt();
+ int touchTextPos = QPlatformInputContext::queryFocusObject(Qt::ImCursorPosition, touchPoint).toInt();
// Ensure that the handels cannot be dragged past each other
if (_dragOnCursor)
@@ -830,8 +830,8 @@ static void executeBlockWithoutAnimation(Block block)
// Move loupe to new position
QRectF handleRect = _dragOnCursor ?
- qApp->inputMethod()->cursorRectangle() :
- qApp->inputMethod()->anchorRectangle();
+ QPlatformInputContext::cursorRectangle() :
+ QPlatformInputContext::anchorRectangle();
self.focalPoint = QPointF(touchPoint.x(), handleRect.center().y());
}
@@ -858,9 +858,9 @@ static void executeBlockWithoutAnimation(Block block)
}
// Adjust handles and input rect to match the new selection
- QRectF inputRect = QGuiApplication::inputMethod()->inputItemClipRectangle();
- CGRect cursorRect = QGuiApplication::inputMethod()->cursorRectangle().toCGRect();
- CGRect anchorRect = QGuiApplication::inputMethod()->anchorRectangle().toCGRect();
+ QRectF inputRect = QPlatformInputContext::inputItemClipRectangle();
+ CGRect cursorRect = QPlatformInputContext::cursorRectangle().toCGRect();
+ CGRect anchorRect = QPlatformInputContext::anchorRectangle().toCGRect();
if (!_multiLine) {
// Resize the layer a bit bigger to ensure that the handles are
@@ -924,7 +924,7 @@ static void executeBlockWithoutAnimation(Block block)
{
[super touchesBegan:touches withEvent:event];
- QRectF inputRect = QGuiApplication::inputMethod()->inputItemClipRectangle();
+ QRectF inputRect = QPlatformInputContext::inputItemClipRectangle();
QPointF touchPos = QPointF::fromCGPoint([static_cast<UITouch *>([touches anyObject]) locationInView:_focusView]);
const bool touchInsideInputArea = inputRect.contains(touchPos);
@@ -969,8 +969,7 @@ static void executeBlockWithoutAnimation(Block block)
_menuShouldBeVisible = false;
} else {
QPointF touchPos = QPointF::fromCGPoint([static_cast<UITouch *>([touches anyObject]) locationInView:_focusView]);
- const QTransform mapToLocal = QGuiApplication::inputMethod()->inputItemTransform().inverted();
- int cursorPosOnRelease = QInputMethod::queryFocusObject(Qt::ImCursorPosition, touchPos * mapToLocal).toInt();
+ int cursorPosOnRelease = QPlatformInputContext::queryFocusObject(Qt::ImCursorPosition, touchPos).toInt();
if (cursorPosOnRelease == _cursorPosOnPress) {
_menuShouldBeVisible = true;