Qt 6.x
The Qt SDK
Loading...
Searching...
No Matches
qandroidinputcontext.cpp File Reference
#include <android/log.h>
#include "androiddeadlockprotector.h"
#include "androidjniinput.h"
#include "androidjnimain.h"
#include "qandroideventdispatcher.h"
#include "qandroidinputcontext.h"
#include "qandroidplatformintegration.h"
#include "private/qhighdpiscaling_p.h"
#include <QTextBoundaryFinder>
#include <QTextCharFormat>
#include <QtCore/QJniEnvironment>
#include <QtCore/QJniObject>
#include <qevent.h>
#include <qguiapplication.h>
#include <qinputmethod.h>
#include <qsharedpointer.h>
#include <qthread.h>
#include <qwindow.h>
#include <qpa/qplatformwindow.h>
+ Include dependency graph for qandroidinputcontext.cpp:

Go to the source code of this file.

Classes

class  QT_BEGIN_NAMESPACE::BatchEditLock
 

Namespaces

namespace  QT_BEGIN_NAMESPACE
 Combined button and popup list for selecting options.
 

Functions

static void runOnQtThread (const std::function< void()> &func)
 
static jboolean beginBatchEdit (JNIEnv *, jobject)
 
static jboolean endBatchEdit (JNIEnv *, jobject)
 
static jboolean commitText (JNIEnv *env, jobject, jstring text, jint newCursorPosition)
 
static jboolean deleteSurroundingText (JNIEnv *, jobject, jint leftLength, jint rightLength)
 
static jboolean finishComposingText (JNIEnv *, jobject)
 
static jint getCursorCapsMode (JNIEnv *, jobject, jint reqModes)
 
static jobject getExtractedText (JNIEnv *env, jobject, int hintMaxChars, int hintMaxLines, jint flags)
 
static jstring getSelectedText (JNIEnv *env, jobject, jint flags)
 
static jstring getTextAfterCursor (JNIEnv *env, jobject, jint length, jint flags)
 
static jstring getTextBeforeCursor (JNIEnv *env, jobject, jint length, jint flags)
 
static jboolean setComposingText (JNIEnv *env, jobject, jstring text, jint newCursorPosition)
 
static jboolean setComposingRegion (JNIEnv *, jobject, jint start, jint end)
 
static jboolean setSelection (JNIEnv *, jobject, jint start, jint end)
 
static jboolean selectAll (JNIEnv *, jobject)
 
static jboolean cut (JNIEnv *, jobject)
 
static jboolean copy (JNIEnv *, jobject)
 
static jboolean copyURL (JNIEnv *, jobject)
 
static jboolean paste (JNIEnv *, jobject)
 
static jboolean updateCursorPosition (JNIEnv *, jobject)
 
static QRect screenInputItemRectangle ()
 
static int getAbsoluteCursorPosition (const QSharedPointer< QInputMethodQueryEvent > &query)
 
static int getBlockPosition (const QSharedPointer< QInputMethodQueryEvent > &query)
 

Variables

static QAndroidInputContextm_androidInputContext = nullptr
 
static char const *const QtNativeInputConnectionClassName = "org/qtproject/qt/android/QtNativeInputConnection"
 
static char const *const QtExtractedTextClassName = "org/qtproject/qt/android/QtExtractedText"
 
static int m_selectHandleWidth = 0
 
static jclass m_extractedTextClass = 0
 
static jmethodID m_classConstructorMethodID = 0
 
static jfieldID m_partialEndOffsetFieldID = 0
 
static jfieldID m_partialStartOffsetFieldID = 0
 
static jfieldID m_selectionEndFieldID = 0
 
static jfieldID m_selectionStartFieldID = 0
 
static jfieldID m_startOffsetFieldID = 0
 
static jfieldID m_textFieldID = 0
 
static JNINativeMethod methods []
 

Function Documentation

◆ beginBatchEdit()

static jboolean beginBatchEdit ( JNIEnv *  ,
jobject   
)
static

Definition at line 78 of file qandroidinputcontext.cpp.

References QAndroidInputContext::beginBatchEdit(), m_androidInputContext, qCDebug, and runOnQtThread().

+ Here is the call graph for this function:

◆ commitText()

static jboolean commitText ( JNIEnv *  env,
jobject  ,
jstring  text,
jint  newCursorPosition 
)
static

Definition at line 102 of file qandroidinputcontext.cpp.

References QAndroidInputContext::commitText(), m_androidInputContext, qCDebug, runOnQtThread(), str, and text.

+ Here is the call graph for this function:

◆ copy()

static jboolean copy ( JNIEnv *  ,
jobject   
)
static

Definition at line 271 of file qandroidinputcontext.cpp.

References QAndroidInputContext::copy(), m_androidInputContext, qCDebug, and runOnQtThread().

Referenced by QDirPrivate::QDirPrivate(), QKeySequencePrivate::QKeySequencePrivate(), QVariant::QVariant(), QtWaylandClient::QWaylandShmBackingStore::QWaylandShmBackingStore(), authenticationKey(), QNetworkInformationPrivate::backendNames(), QNetworkAccessAuthenticationManager::cacheCredentials(), QSharedPointer< T >::clear(), QQmlObjectModelPrivate::clear(), QDataWidgetMapper::clearMapping(), QTreeWidgetItem::clone(), QImage::colorTransformed(), QtMetaTypePrivate::construct(), QQmlValueType::construct(), QMetaType::construct(), QImage::copy(), QDistanceField::copy(), QPixmap::copy(), QStringHash< T >::copyAndReserve(), QWindowsDirect2DWindow::copyBackBuffer(), QtMetaTypePrivate::copyConstruct(), QMetaType::create(), QVariant::create(), QVariant::create(), QDateTimeEdit::dateTimeFromText(), QDBusMetaType::demarshall(), QtPrivate::QExplicitlySharedDataPointerV2< T >::detach(), QQmlJS::Dom::QmldirFile::doCopy(), QQmlJS::Dom::JsFile::doCopy(), QAndroidStyle::AndroidClipDrawable::draw(), QAndroidStyle::AndroidLayerDrawable::draw(), QQC2::QCommonStyle::drawComplexControl(), QQC2::QWindowsStyle::drawComplexControl(), QCommonStyle::drawComplexControl(), QAndroidStyle::AndroidSeekBarControl::drawControl(), QAndroidStyle::drawControl(), QRasterPaintEngine::drawImage(), QAndroidStyle::drawPrimitive(), QRasterPaintEngine::drawStaticTextItem(), QEmulationPaintEngine::drawTextItem(), QRasterPaintEngine::drawTiledPixmap(), QHash< Key, T >::emplace(), QHash< Key, T >::emplace(), QMultiHash< Key, T >::emplace(), QMultiHash< Key, T >::emplaceReplace(), QMap< Key, T >::equal_range(), QMultiMap< Key, T >::equal_range(), QMultiHash< Key, T >::equal_range(), QDecompressHelper::feed(), QEmulationPaintEngine::fill(), QList< T >::fill(), QCryptographicHashPrivate::State::finalizeUnchecked(), QMap< Key, T >::find(), QMultiMap< Key, T >::find(), QMultiHash< Key, T >::find(), QMultiMap< Key, T >::find(), QDateTimeEdit::fixup(), QWindowsDirect2DBackingStore::flush(), from_string(), QBaseIterator< Container >::initIterator(), QMap< Key, T >::insert(), QMultiMap< Key, T >::insert(), QMap< Key, T >::insert(), QMap< Key, T >::insert(), QMultiMap< Key, T >::insert(), QString::insert(), QtPrivate::QPodArrayOps< T >::insert(), QtPrivate::QGenericArrayOps< T >::insert(), QtPrivate::QMovableArrayOps< T >::insert(), QAbstractSpinBoxPrivate::interpret(), QMap< Key, T >::lowerBound(), QMultiMap< Key, T >::lowerBound(), makeCacheKey(), QTransform::map(), QTransform::map(), QV4::StringPrototype::method_padEnd(), QV4::StringPrototype::method_padStart(), QGlyphLayout::mid(), QtMetaTypePrivate::moveConstruct(), QString::normalized(), QList< T >::iterator::operator++(), QList< T >::const_iterator::operator++(), QList< T >::iterator::operator--(), QList< T >::const_iterator::operator--(), QAppleRefCounted< T, U, RetainFunction, ReleaseFunction >::operator=(), QColorSpace::operator=(), QEasingCurve::operator=(), QtPrivate::QExplicitlySharedDataPointerV2< T >::operator=(), QFutureInterface< T >::operator=(), QFutureInterfaceBase::operator=(), QJsonValue::operator=(), QPainterPath::operator=(), QSharedPointer< T >::operator=(), QSharedPointer< T >::operator=(), QSslDiffieHellmanParameters::operator=(), QStringHash< T >::operator=(), QWeakPointer< T >::operator=(), QHash< Key, T >::operator[](), QMultiHash< Key, T >::operator[](), QMap< Key, T >::operator[](), QDateTimeParser::parse(), QQuickTextInputPrivate::processKeyEvent(), QSocks5SocketEngine::read(), QtWaylandClient::QWaylandDisplay::registry_global(), QString::remove(), QString::remove(), QByteArray::remove(), removeStringImpl(), QMultiMap< Key, T >::replace(), QByteArray::replace(), QByteArray::replace(), replace_with_copy(), QTestCharBuffer::reset(), QSharedPointer< T >::reset(), QSharedPointer< T >::reset(), QFileSystemEngine::resolveEntryAndCreateLegacyEngine(), QCocoaMenuItem::resolveTargetAction(), QMainWindowLayoutState::restoreState(), PressDelayHandler::sendMouseEvent(), QCocoaDrag::setLastMouseEvent(), QCryptographicHashPrivate::State::sha3Finish(), QSslSocket::sslConfiguration(), QEmulationPaintEngine::stroke(), QMap< Key, T >::take(), QMultiMap< Key, T >::take(), QQuickSmoothedAnimation::transition(), QQuickSpringAnimation::transition(), QPolygonF::translated(), QPolygon::translated(), QPainterPath::translated(), QMultiHash< Key, T >::unite(), QMultiMap< Key, T >::unite(), QDateTimeEditPrivate::updateCache(), QQmlJS::Dom::OutWriter::updatedFile(), QQuickStochasticEngine::updateSprites(), QMap< Key, T >::upperBound(), QMultiMap< Key, T >::upperBound(), QHttpNetworkRequest::uri(), QSpinBoxPrivate::validateAndInterpret(), QDoubleSpinBoxPrivate::validateAndInterpret(), QSpinBox::valueFromText(), QDoubleSpinBox::valueFromText(), and QTextOdfWriter::writeAll().

+ Here is the call graph for this function:

◆ copyURL()

static jboolean copyURL ( JNIEnv *  ,
jobject   
)
static

Definition at line 282 of file qandroidinputcontext.cpp.

References QAndroidInputContext::copyURL(), m_androidInputContext, qCDebug, and runOnQtThread().

+ Here is the call graph for this function:

◆ cut()

static jboolean cut ( JNIEnv *  ,
jobject   
)
static

Definition at line 260 of file qandroidinputcontext.cpp.

References QAndroidInputContext::cut(), m_androidInputContext, qCDebug, and runOnQtThread().

Referenced by QUtcTimeZonePrivate::availableTimeZoneIds(), QUtcTimeZonePrivate::availableTimeZoneIds(), QmlLsp::QmlLintSuggestions::diagnose(), isEntryInIanaList(), loadTzTimeZones(), QCocoaMenuItem::resolveTargetAction(), and QTimeZonePrivate::windowsIdToDefaultIanaId().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ deleteSurroundingText()

static jboolean deleteSurroundingText ( JNIEnv *  ,
jobject  ,
jint  leftLength,
jint  rightLength 
)
static

Definition at line 118 of file qandroidinputcontext.cpp.

References QAndroidInputContext::deleteSurroundingText(), m_androidInputContext, qCDebug, and runOnQtThread().

+ Here is the call graph for this function:

◆ endBatchEdit()

static jboolean endBatchEdit ( JNIEnv *  ,
jobject   
)
static

Definition at line 89 of file qandroidinputcontext.cpp.

References QAndroidInputContext::endBatchEdit(), m_androidInputContext, qCDebug, and runOnQtThread().

+ Here is the call graph for this function:

◆ finishComposingText()

static jboolean finishComposingText ( JNIEnv *  ,
jobject   
)
static

Definition at line 129 of file qandroidinputcontext.cpp.

References QAndroidInputContext::finishComposingText(), m_androidInputContext, qCDebug, and runOnQtThread().

+ Here is the call graph for this function:

◆ getAbsoluteCursorPosition()

static int getAbsoluteCursorPosition ( const QSharedPointer< QInputMethodQueryEvent > &  query)
inlinestatic

Definition at line 462 of file qandroidinputcontext.cpp.

References Qt::ImAbsolutePosition, Qt::ImCursorPosition, QVariant::isValid(), QVariant::toInt(), and QVariant::value().

Referenced by QAndroidInputContext::deleteSurroundingText(), QAndroidInputContext::getExtractedText(), QAndroidInputContext::setComposingText(), and QAndroidInputContext::updateCursorPosition().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getBlockPosition()

static int getBlockPosition ( const QSharedPointer< QInputMethodQueryEvent > &  query)
inlinestatic

Definition at line 469 of file qandroidinputcontext.cpp.

References Qt::ImAbsolutePosition, Qt::ImCursorPosition, QVariant::isValid(), QVariant::toInt(), and QVariant::value().

Referenced by QAndroidInputContext::deleteSurroundingText(), QAndroidInputContext::getExtractedText(), QAndroidInputContext::setComposingRegion(), QAndroidInputContext::setComposingText(), QAndroidInputContext::setSelection(), QAndroidInputContext::touchDown(), and QAndroidInputContext::updateCursorPosition().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getCursorCapsMode()

static jint getCursorCapsMode ( JNIEnv *  ,
jobject  ,
jint  reqModes 
)
static

Definition at line 140 of file qandroidinputcontext.cpp.

References QAndroidInputContext::getCursorCapsMode(), m_androidInputContext, and runOnQtThread().

+ Here is the call graph for this function:

◆ getExtractedText()

◆ getSelectedText()

static jstring getSelectedText ( JNIEnv *  env,
jobject  ,
jint  flags 
)
static

Definition at line 174 of file qandroidinputcontext.cpp.

References QString::constData(), QAndroidInputContext::getSelectedText(), QString::isEmpty(), QString::length(), m_androidInputContext, qCDebug, runOnQtThread(), and text.

+ Here is the call graph for this function:

◆ getTextAfterCursor()

static jstring getTextAfterCursor ( JNIEnv *  env,
jobject  ,
jint  length,
jint  flags 
)
static

Definition at line 187 of file qandroidinputcontext.cpp.

References QString::constData(), QAndroidInputContext::getTextAfterCursor(), QString::length(), m_androidInputContext, qCDebug, runOnQtThread(), and text.

+ Here is the call graph for this function:

◆ getTextBeforeCursor()

static jstring getTextBeforeCursor ( JNIEnv *  env,
jobject  ,
jint  length,
jint  flags 
)
static

Definition at line 198 of file qandroidinputcontext.cpp.

References QString::constData(), QAndroidInputContext::getTextBeforeCursor(), QString::length(), m_androidInputContext, qCDebug, runOnQtThread(), and text.

+ Here is the call graph for this function:

◆ paste()

static jboolean paste ( JNIEnv *  ,
jobject   
)
static

Definition at line 293 of file qandroidinputcontext.cpp.

References m_androidInputContext, QAndroidInputContext::paste(), qCDebug, and runOnQtThread().

Referenced by QQuickTextInputPrivate::processKeyEvent(), qt_mac_get_pasteboardString(), and QCocoaMenuItem::resolveTargetAction().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ runOnQtThread()

static void runOnQtThread ( const std::function< void()> &  func)
static

Definition at line 70 of file qandroidinputcontext.cpp.

References AndroidDeadlockProtector::acquire(), Qt::BlockingQueuedConnection, QMetaObject::invokeMethod(), m_androidInputContext, and Q_ARG.

Referenced by beginBatchEdit(), commitText(), copy(), copyURL(), cut(), deleteSurroundingText(), endBatchEdit(), finishComposingText(), getCursorCapsMode(), getExtractedText(), getSelectedText(), getTextAfterCursor(), getTextBeforeCursor(), paste(), selectAll(), setComposingRegion(), setComposingText(), setSelection(), and updateCursorPosition().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ screenInputItemRectangle()

static QRect screenInputItemRectangle ( )
static

Definition at line 338 of file qandroidinputcontext.cpp.

References QPlatformInputContext::inputItemRectangle(), qGuiApp, QRect::size(), QRect::topLeft(), QRectF::toRect(), and window().

Referenced by QAndroidInputContext::longPress(), QAndroidInputContext::showInputPanel(), and QAndroidInputContext::touchDown().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ selectAll()

static jboolean selectAll ( JNIEnv *  ,
jobject   
)
static

Definition at line 249 of file qandroidinputcontext.cpp.

References m_androidInputContext, qCDebug, runOnQtThread(), and QAndroidInputContext::selectAll().

Referenced by QCocoaMenuItem::resolveTargetAction().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setComposingRegion()

static jboolean setComposingRegion ( JNIEnv *  ,
jobject  ,
jint  start,
jint  end 
)
static

Definition at line 225 of file qandroidinputcontext.cpp.

References m_androidInputContext, qCDebug, runOnQtThread(), and QAndroidInputContext::setComposingRegion().

+ Here is the call graph for this function:

◆ setComposingText()

static jboolean setComposingText ( JNIEnv *  env,
jobject  ,
jstring  text,
jint  newCursorPosition 
)
static

Definition at line 209 of file qandroidinputcontext.cpp.

References m_androidInputContext, qCDebug, runOnQtThread(), QAndroidInputContext::setComposingText(), str, and text.

+ Here is the call graph for this function:

◆ setSelection()

static jboolean setSelection ( JNIEnv *  ,
jobject  ,
jint  start,
jint  end 
)
static

Definition at line 237 of file qandroidinputcontext.cpp.

References m_androidInputContext, qCDebug, runOnQtThread(), and QAndroidInputContext::setSelection().

+ Here is the call graph for this function:

◆ updateCursorPosition()

static jboolean updateCursorPosition ( JNIEnv *  ,
jobject   
)
static

Definition at line 304 of file qandroidinputcontext.cpp.

References m_androidInputContext, qCDebug, runOnQtThread(), and QAndroidInputContext::updateCursorPosition().

+ Here is the call graph for this function:

Variable Documentation

◆ m_androidInputContext

◆ m_classConstructorMethodID

jmethodID m_classConstructorMethodID = 0
static

◆ m_extractedTextClass

jclass m_extractedTextClass = 0
static

◆ m_partialEndOffsetFieldID

jfieldID m_partialEndOffsetFieldID = 0
static

◆ m_partialStartOffsetFieldID

jfieldID m_partialStartOffsetFieldID = 0
static

◆ m_selectHandleWidth

int m_selectHandleWidth = 0
static

◆ m_selectionEndFieldID

jfieldID m_selectionEndFieldID = 0
static

◆ m_selectionStartFieldID

jfieldID m_selectionStartFieldID = 0
static

◆ m_startOffsetFieldID

jfieldID m_startOffsetFieldID = 0
static

◆ m_textFieldID

jfieldID m_textFieldID = 0
static

◆ methods

JNINativeMethod methods[]
static
Initial value:
= {
{"beginBatchEdit", "()Z", (void *)beginBatchEdit},
{"endBatchEdit", "()Z", (void *)endBatchEdit},
{"commitText", "(Ljava/lang/String;I)Z", (void *)commitText},
{"deleteSurroundingText", "(II)Z", (void *)deleteSurroundingText},
{"finishComposingText", "()Z", (void *)finishComposingText},
{"getCursorCapsMode", "(I)I", (void *)getCursorCapsMode},
{"getExtractedText", "(III)Lorg/qtproject/qt/android/QtExtractedText;", (void *)getExtractedText},
{"getSelectedText", "(I)Ljava/lang/String;", (void *)getSelectedText},
{"getTextAfterCursor", "(II)Ljava/lang/String;", (void *)getTextAfterCursor},
{"getTextBeforeCursor", "(II)Ljava/lang/String;", (void *)getTextBeforeCursor},
{"setComposingText", "(Ljava/lang/String;I)Z", (void *)setComposingText},
{"setComposingRegion", "(II)Z", (void *)setComposingRegion},
{"setSelection", "(II)Z", (void *)setSelection},
{"selectAll", "()Z", (void *)selectAll},
{"cut", "()Z", (void *)cut},
{"copy", "()Z", (void *)copy},
{"copyURL", "()Z", (void *)copyURL},
{"paste", "()Z", (void *)paste},
{"updateCursorPosition", "()Z", (void *)updateCursorPosition}
}
static jboolean cut(JNIEnv *, jobject)
static jint getCursorCapsMode(JNIEnv *, jobject, jint reqModes)
static jboolean finishComposingText(JNIEnv *, jobject)
static jobject getExtractedText(JNIEnv *env, jobject, int hintMaxChars, int hintMaxLines, jint flags)
static jboolean copy(JNIEnv *, jobject)
static jstring getTextBeforeCursor(JNIEnv *env, jobject, jint length, jint flags)
static jboolean copyURL(JNIEnv *, jobject)
static jboolean commitText(JNIEnv *env, jobject, jstring text, jint newCursorPosition)
static jboolean paste(JNIEnv *, jobject)
static jboolean beginBatchEdit(JNIEnv *, jobject)
static jstring getSelectedText(JNIEnv *env, jobject, jint flags)
static jboolean setComposingRegion(JNIEnv *, jobject, jint start, jint end)
static jboolean deleteSurroundingText(JNIEnv *, jobject, jint leftLength, jint rightLength)
static jboolean setComposingText(JNIEnv *env, jobject, jstring text, jint newCursorPosition)
static jboolean updateCursorPosition(JNIEnv *, jobject)
static jstring getTextAfterCursor(JNIEnv *env, jobject, jint length, jint flags)
static jboolean endBatchEdit(JNIEnv *, jobject)
static jboolean setSelection(JNIEnv *, jobject, jint start, jint end)
static jboolean selectAll(JNIEnv *, jobject)

Definition at line 316 of file qandroidinputcontext.cpp.

◆ QtExtractedTextClassName

char const* const QtExtractedTextClassName = "org/qtproject/qt/android/QtExtractedText"
static

Definition at line 59 of file qandroidinputcontext.cpp.

Referenced by QAndroidInputContext::QAndroidInputContext().

◆ QtNativeInputConnectionClassName

char const* const QtNativeInputConnectionClassName = "org/qtproject/qt/android/QtNativeInputConnection"
static

Definition at line 58 of file qandroidinputcontext.cpp.

Referenced by QAndroidInputContext::QAndroidInputContext().