Make setSelectionOnFocusObject() take native pixels
Change the setSelectionOnFocusObject() to take geometry arguments in native pixels, in order to be consistent with other QPlatformInputContext API. Calling code which pass non-native geometry must be updated (in practice only the Android platform plugin). Change-Id: I1c61b8cf583afe607567d6056ca7ff23cc3de3f3 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
This commit is contained in:
parent
8ad66a1488
commit
dc3446c1e3
@ -271,16 +271,20 @@ void QPlatformInputContextPrivate::setInputMethodAccepted(bool accepted)
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief QPlatformInputContext::setSelectionOnFocusObject
|
||||
* \param anchorPos Beginning of selection in currently active window coordinates
|
||||
* \param cursorPos End of selection in currently active window coordinates
|
||||
*/
|
||||
void QPlatformInputContext::setSelectionOnFocusObject(const QPointF &anchorPos, const QPointF &cursorPos)
|
||||
\brief QPlatformInputContext::setSelectionOnFocusObject
|
||||
\param anchorPos Beginning of selection in currently active window native coordinates
|
||||
\param cursorPos End of selection in currently active window native coordinates
|
||||
*/
|
||||
void QPlatformInputContext::setSelectionOnFocusObject(const QPointF &nativeAnchorPos, const QPointF &nativeCursorPos)
|
||||
{
|
||||
QObject *focus = qApp->focusObject();
|
||||
if (!focus)
|
||||
return;
|
||||
|
||||
QWindow *window = qApp->focusWindow();
|
||||
const QPointF &anchorPos = QHighDpi::fromNativePixels(nativeAnchorPos, window);
|
||||
const QPointF &cursorPos = QHighDpi::fromNativePixels(nativeCursorPos, window);
|
||||
|
||||
QInputMethod *im = QGuiApplication::inputMethod();
|
||||
const QTransform mapToLocal = im->inputItemTransform().inverted();
|
||||
bool success;
|
||||
|
@ -824,12 +824,7 @@ void QAndroidInputContext::longPress(int x, int y)
|
||||
BatchEditLock batchEditLock(this);
|
||||
|
||||
focusObjectStopComposing();
|
||||
|
||||
const double pixelDensity =
|
||||
QGuiApplication::focusWindow()
|
||||
? QHighDpiScaling::factor(QGuiApplication::focusWindow())
|
||||
: QHighDpiScaling::factor(QtAndroid::androidPlatformIntegration()->screen());
|
||||
const QPointF touchPoint(x / pixelDensity, y / pixelDensity);
|
||||
const QPointF touchPoint(x, y);
|
||||
setSelectionOnFocusObject(touchPoint, touchPoint);
|
||||
|
||||
QInputMethodQueryEvent query(Qt::ImCursorPosition | Qt::ImAnchorPosition | Qt::ImTextBeforeCursor | Qt::ImTextAfterCursor);
|
||||
|
Loading…
x
Reference in New Issue
Block a user