Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
qandroidinputcontext.cpp File Reference

(46502f9705634f02626ee1057975463d1c0ae1f8)

#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 void reportFullscreenMode (JNIEnv *, jobject, jboolean enabled)
 
static jboolean fullscreenMode (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 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 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 m_androidInputContext, qCDebug, and runOnQtThread().

Referenced by QDirPrivate::QDirPrivate(), QKeySequencePrivate::QKeySequencePrivate(), QVariant::QVariant(), QtWaylandClient::QWaylandShmBackingStore::QWaylandShmBackingStore(), QtPrivate::SlotObjSharedPtr::SlotObjSharedPtr(), 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(), QFileSystemEngine::createLegacyEngine(), QDateTimeEdit::dateTimeFromText(), QDBusMetaType::demarshall(), 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(), QDecompressHelper::feed(), QEmulationPaintEngine::fill(), QList< T >::fill(), QCryptographicHashPrivate::State::finalizeUnchecked(), QMap< Key, T >::find(), QMultiMap< Key, T >::find(), QMultiMap< Key, T >::find(), QDateTimeEdit::fixup(), QWindowsDirect2DBackingStore::flush(), from_string(), QVariant::fromMetaType(), QMenuBarPrivate::handleReparent(), 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(), QAbstractSpinBoxPrivate::interpret(), QMap< Key, T >::lowerBound(), QMultiMap< Key, T >::lowerBound(), makeCacheKey(), QTransform::map(), QTransform::map(), QV4::StringPrototype::method_padEnd(), QV4::StringPrototype::method_padStart(), 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=(), QFutureInterface< T >::operator=(), QFutureInterfaceBase::operator=(), QJsonValue::operator=(), QPainterPath::operator=(), QSharedPointer< T >::operator=(), QSharedPointer< T >::operator=(), QSslDiffieHellmanParameters::operator=(), QStringHash< T >::operator=(), QWeakPointer< T >::operator=(), QtPrivate::SlotObjSharedPtr::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(), QAbstractItemView::reset(), QTestCharBuffer::reset(), QSharedPointer< T >::reset(), QSharedPointer< T >::reset(), QCocoaMenuItem::resolveTargetAction(), QMainWindowLayoutState::restoreState(), PressDelayHandler::sendMouseEvent(), QCocoaDrag::setLastMouseEvent(), QCryptographicHashPrivate::State::sha3Finish(), QMdiArea::showEvent(), 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(), 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 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 m_androidInputContext, qCDebug, and runOnQtThread().

Referenced by QUtcTimeZonePrivate::QUtcTimeZonePrivate(), QUtcTimeZonePrivate::availableTimeZoneIds(), QUtcTimeZonePrivate::availableTimeZoneIds(), QMimeType::comment(), isEntryInIanaList(), loadTzTimeZones(), QmlLsp::messageToDiagnostic_helper(), 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 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 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 m_androidInputContext, qCDebug, and runOnQtThread().

+ Here is the call graph for this function:

◆ fullscreenMode()

static jboolean fullscreenMode ( JNIEnv * ,
jobject  )
static

Definition at line 323 of file qandroidinputcontext.cpp.

References m_androidInputContext.

◆ getAbsoluteCursorPosition()

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

Definition at line 477 of file qandroidinputcontext.cpp.

References Qt::ImAbsolutePosition, Qt::ImCursorPosition, 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 484 of file qandroidinputcontext.cpp.

References Qt::ImAbsolutePosition, Qt::ImCursorPosition, 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 m_androidInputContext, and runOnQtThread().

+ Here is the call graph for this function:

◆ getExtractedText()

static jobject getExtractedText ( JNIEnv * env,
jobject ,
int hintMaxChars,
int hintMaxLines,
jint flags )
static

Definition at line 150 of file qandroidinputcontext.cpp.

References QString::fromLatin1(), m_androidInputContext, m_classConstructorMethodID, m_extractedTextClass, m_partialEndOffsetFieldID, m_partialStartOffsetFieldID, m_selectionEndFieldID, m_selectionStartFieldID, m_startOffsetFieldID, m_textFieldID, QString::number(), qCDebug, and runOnQtThread().

+ Here is the call graph for this function:

◆ getSelectedText()

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

Definition at line 174 of file qandroidinputcontext.cpp.

References QString::constData(), 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(), 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(), 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, 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:

◆ reportFullscreenMode()

static void reportFullscreenMode ( JNIEnv * ,
jobject ,
jboolean enabled )
static

Definition at line 315 of file qandroidinputcontext.cpp.

References m_androidInputContext, and runOnQtThread().

+ Here is the call graph for this function:

◆ runOnQtThread()

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

Definition at line 70 of file qandroidinputcontext.cpp.

References 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(), reportFullscreenMode(), 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 352 of file qandroidinputcontext.cpp.

References QPlatformInputContext::inputItemRectangle(), qGuiApp, 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, and runOnQtThread().

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, and runOnQtThread().

+ 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(), 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, and runOnQtThread().

+ 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, and runOnQtThread().

+ 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},
{"reportFullscreenMode", "(Z)V", (void *)reportFullscreenMode},
{"fullscreenMode", "()Z", (void *)fullscreenMode}
}
static jboolean cut(JNIEnv *, jobject)
static jint getCursorCapsMode(JNIEnv *, jobject, jint reqModes)
static jboolean fullscreenMode(JNIEnv *, jobject)
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 void reportFullscreenMode(JNIEnv *, jobject, jboolean enabled)
static jboolean endBatchEdit(JNIEnv *, jobject)
static jboolean setSelection(JNIEnv *, jobject, jint start, jint end)
static jboolean selectAll(JNIEnv *, jobject)

Definition at line 328 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().