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
|
\brief QPlatformInputContext::setSelectionOnFocusObject
|
||||||
* \param anchorPos Beginning of selection in currently active window coordinates
|
\param anchorPos Beginning of selection in currently active window native coordinates
|
||||||
* \param cursorPos End of selection in currently active window coordinates
|
\param cursorPos End of selection in currently active window native coordinates
|
||||||
*/
|
*/
|
||||||
void QPlatformInputContext::setSelectionOnFocusObject(const QPointF &anchorPos, const QPointF &cursorPos)
|
void QPlatformInputContext::setSelectionOnFocusObject(const QPointF &nativeAnchorPos, const QPointF &nativeCursorPos)
|
||||||
{
|
{
|
||||||
QObject *focus = qApp->focusObject();
|
QObject *focus = qApp->focusObject();
|
||||||
if (!focus)
|
if (!focus)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
QWindow *window = qApp->focusWindow();
|
||||||
|
const QPointF &anchorPos = QHighDpi::fromNativePixels(nativeAnchorPos, window);
|
||||||
|
const QPointF &cursorPos = QHighDpi::fromNativePixels(nativeCursorPos, window);
|
||||||
|
|
||||||
QInputMethod *im = QGuiApplication::inputMethod();
|
QInputMethod *im = QGuiApplication::inputMethod();
|
||||||
const QTransform mapToLocal = im->inputItemTransform().inverted();
|
const QTransform mapToLocal = im->inputItemTransform().inverted();
|
||||||
bool success;
|
bool success;
|
||||||
|
@ -824,12 +824,7 @@ void QAndroidInputContext::longPress(int x, int y)
|
|||||||
BatchEditLock batchEditLock(this);
|
BatchEditLock batchEditLock(this);
|
||||||
|
|
||||||
focusObjectStopComposing();
|
focusObjectStopComposing();
|
||||||
|
const QPointF touchPoint(x, y);
|
||||||
const double pixelDensity =
|
|
||||||
QGuiApplication::focusWindow()
|
|
||||||
? QHighDpiScaling::factor(QGuiApplication::focusWindow())
|
|
||||||
: QHighDpiScaling::factor(QtAndroid::androidPlatformIntegration()->screen());
|
|
||||||
const QPointF touchPoint(x / pixelDensity, y / pixelDensity);
|
|
||||||
setSelectionOnFocusObject(touchPoint, touchPoint);
|
setSelectionOnFocusObject(touchPoint, touchPoint);
|
||||||
|
|
||||||
QInputMethodQueryEvent query(Qt::ImCursorPosition | Qt::ImAnchorPosition | Qt::ImTextBeforeCursor | Qt::ImTextAfterCursor);
|
QInputMethodQueryEvent query(Qt::ImCursorPosition | Qt::ImAnchorPosition | Qt::ImTextBeforeCursor | Qt::ImTextAfterCursor);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user