summaryrefslogtreecommitdiffstats
path: root/src/plugins/platforms/android/qandroidinputcontext.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Fix QRect calculation in inputItemRectangleDmitry Chmerev2017-01-111-4/+4
| | | | | | | | | | | | | Because of QRect's width and height are caluculated values, they got spoiled after x and y values setting. This bug affects, in particular, Android software keyboard appearance: it could overlap focused input field. Change-Id: I27ccca27111219818722951fe6f463388d76c702 Reviewed-by: Lars Knoll <lars.knoll@qt.io> Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com> Reviewed-by: BogDan Vatra <bogdan@kdab.com>
* Android: fix (partially) text deletion when the cursor is movedBogDan Vatra2016-12-131-0/+5
| | | | | | | | | | | | | | | | - wait until the handle location changes the cursor position - don't update cursor position if: * a batchEdit is in progress * the UpdateSelection is blocked - finish the composing before update the cursor - add the missing .java files There are still corner situations when the text gets deleted/moved, but those are pretty rare and they will be fix in another patch. Task-number: QTBUG-57507 Change-Id: I230d7f64625fb556e1be3069694a71e9bc91323a Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
* Plugins: optimize string usageAnton Kudryavtsev2016-10-181-6/+5
| | | | | | | | | | | | | Prefer QStringRef methods to avoid allocations. Use startsWith/endsWith rather than comparing substrings; and avoid substrings where references suffice. Use new QStringList::join(QL1S). Change-Id: I46c44aca96578633370006d613eb0ac13f7cfc03 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Android: Show the edit menu when things are selectedOlivier Goffart2016-08-211-1/+17
| | | | | Change-Id: I3647fa39469c87bcc08bb439546e5e61c535c71d Reviewed-by: BogDan Vatra <bogdan@kdab.com>
* Android selection handlesOlivier Goffart2016-08-181-23/+148
| | | | | | | | | This commits implement the cursor and selection handle in the platform plugin. Task-number: QTBUG-34867 Change-Id: Icb3fd9ddfd9f4152e2004078a92a3d9502e9113c Reviewed-by: BogDan Vatra <bogdan@kdab.com>
* Merge remote-tracking branch 'origin/5.7' into devLiang Qi2016-04-051-4/+9
|\ | | | | | | | | | | | | | | | | Conflicts: examples/corelib/ipc/ipc.pro src/plugins/platforms/xcb/qxcbbackingstore.cpp tests/auto/corelib/tools/qcommandlineparser/tst_qcommandlineparser.cpp Change-Id: Ia006e10ff1732fe78f90138c41f05b59b49486cf
| * Merge remote-tracking branch 'origin/5.6' into 5.7Simon Hausmann2016-03-231-4/+9
| |\ | | | | | | | | | Change-Id: I9a10e1f3c9506ec8554d8f59b6300825ac730939
| | * Android: Fix inputItemRectangle when using EnableHighDpiScalingBogDan Vatra2016-03-211-4/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When EnableHighDpiScaling is enabled, qGuiApp->inputMethod()- >inputItemRectangle() returns the position divided by pixel density, therefore all the controls positions must by multiplied by pixel density to translate them into screen coordinates. Task-number: QTBUG-52001 Change-Id: Iea92a912cfbab03a9497fc8cddc24bebd0db2192 Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@theqtcompany.com>
* | | Merge remote-tracking branch 'origin/5.7' into devLiang Qi2016-03-221-16/+16
|\| | | | | | | | | | | | | | | | | | | | | | | | | | | | | Conflicts: configure mkspecs/common/wince/qplatformdefs.h src/plugins/platforms/directfb/qdirectfbbackingstore.cpp src/plugins/platforms/xcb/qxcbbackingstore.cpp Change-Id: Ied4d31264a9afca9514b51a7eb1494c28712793c
| * | QtBase (remainder): use printf-style qWarning/qDebug where possible (I)Marc Mutz2016-03-121-16/+16
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The printf-style version of QDebug expands to a lot less code than the std::ostream-style version. Of course, you pay in type safety (but compilers warn about it these days), you cannot stream complex Qt types and streaming QStrings is awkward, but in many cases you actually improve on readability. But the main reason is that something that's not supposed to be executed under normal operation has no business bloating executable code size. This is not an attempt at converting all qWarnings() to printf-style, only the low-hanging fruit. In this first part, replace qWarning() << "" with qWarning("..."). Had to fix broken qImDebug() definition. Instead of defining it as a nullary macro in the QT_NO_DEBUG case and as a variadic macro in the other, define it in both cases, as is customary, as a non-function macro so that overload selection works without requiring variadic macro support of the compiler. Saves e.g. ~250b in text size in QtPrintSupport on optimized GCC 5.3 AMD64 builds. Change-Id: Ie30fe2f7942115d5dbf99fff1750ae0d477c379f Reviewed-by: Kai Koehne <kai.koehne@theqtcompany.com>
* | | QInputMethodEvent::Attribute: add ctor that doesn't take a QVariantMarc Mutz2016-02-201-8/+6
|/ / | | | | | | | | | | | | | | | | | | | | Many callers passed QVariant() as the last ctor argument. Micro-optimize by providing an overload that default- constructs the variant in-place. Change-Id: I9aab40c6e5a025c9a502c706e4cc7b10879ac418 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@theqtcompany.com> Reviewed-by: Takao Fujiwara <takao.fujiwara1@gmail.com> Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
* | Updated license headersJani Heikkinen2016-01-151-14/+20
| | | | | | | | | | | | | | | | | | | | | | From Qt 5.7 -> LGPL v2.1 isn't an option anymore, see http://blog.qt.io/blog/2016/01/13/new-agreement-with-the-kde-free-qt-foundation/ Updated license headers to use new LGPL header instead of LGPL21 one (in those files which will be under LGPL v3) Change-Id: I046ec3e47b1876cd7b4b0353a576b352e3a946d9 Reviewed-by: Lars Knoll <lars.knoll@theqtcompany.com>
* | Merge remote-tracking branch 'origin/5.6' into devSimon Hausmann2015-12-081-1/+1
|\| | | | | | | Change-Id: I2532c7f7db5e6cc3ef09753d886279816dd662b2
| * Android: Implement QInputMethod::keyboardRectangleOlivier Goffart2015-12-071-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | We can use getWindowVisibleDisplayFrame to know the height on the keyboard, and we can use getLocationOnScreen to find out how much the view is scrolled. Since onPreDraw is always called when the view is scrolled or when the keyboard appears or disapear, we can call the native functions from there. This is not working for floating keyboards. [ChangeLog][Android] Implemented QInputMethod::keyboardRectangle Task-number: QTBUG-40731 Change-Id: I7848eb34fece410b29a06bf0bbb2313112fffa68 Reviewed-by: Samuel Nevala <samuel.nevala@intopalo.com> Reviewed-by: BogDan Vatra <bogdan@kdab.com>
* | Use Q_UNLIKELY for every qFatal()/qCritical()Marc Mutz2015-11-291-10/+10
|/ | | | | | | | | | | | | | | | | | | | | If, after checking a condition, we issue a qFatal() or a qCritical(), by definition that check is unlikely to be true. Tell the compiler so it can move the error handling code out of the normal code path to increase the effective icache size. Moved conditional code around where possible so that we could always use Q_UNLIKELY, instead of having to revert to Q_LIKELY here and there. In some cases, simplified the expressions newly wrapped in Q_UNLIKELY as a drive-by. Change-Id: I67537d62b04bc6977d69254690c5ebbdf98bfd6d Reviewed-by: Konstantin Ritt <ritt.ks@gmail.com> Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
* Libraries: Fix single-character string literals.Friedemann Kleint2015-10-131-3/+3
| | | | | | | Use character literals where applicable. Change-Id: I8e198774c2247c1cc1d852a41b59b301199b7878 Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
* Android: Add support for EnterKeyKai Uwe Broulik2015-08-111-1/+3
| | | | | | | | | QAndroidInputContext now sends along the EnterKey type provided by the EnterKey input method query enabling the QtActivityDelegate to set the imeOptions for the TextView accordingly. Change-Id: Ic96077ab4b11cf6dec52283ecf66b2cabe7af665 Reviewed-by: BogDan Vatra <bogdan@kde.org>
* Compile fix for QT_DEBUG_ANDROID_IM_PROTOCOLPaul Olav Tvete2015-06-161-1/+1
| | | | | Change-Id: I45d1c1541f8c758995c988f52c5fa8bd4fa99177 Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@theqtcompany.com>
* Workaround for Google Keyboard strangenessPaul Olav Tvete2015-06-161-0/+5
| | | | | | | | | | | | | | | | When deleting selected text, Google Keyboard will call deleteSurroundingText() with a negative beforeLength. This does not make any sense, and not all our controls are able to handle the resulting input method events. This patch interprets a negative beforeLength as a positive afterLength. This works with the cases I have seen so far, but since the keyboard is not following the specification, there may be more weirdness later. Task-number: QTBUG-46637 Change-Id: I410832417f6fb21139c338355e8fcfa57b9e544c Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@theqtcompany.com>
* Workaround for Samsung keyboard bugPaul Olav Tvete2015-05-201-0/+2
| | | | | | | | | | Return null string instead of empty string when the selection is empty. It looks like Samsung just tests for selection == null when doing backspace. Task-number: QTBUG-45785 Change-Id: Id26ce707130777fcd0ab1a4cff08367bb2810f2f Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@theqtcompany.com>
* Update copyright headersJani Heikkinen2015-02-111-7/+7
| | | | | | | | | | | | | | | | | | Qt copyrights are now in The Qt Company, so we could update the source code headers accordingly. In the same go we should also fix the links to point to qt.io. Outdated header.LGPL removed (use header.LGPL21 instead) Old header.LGPL3 renamed to header.LGPL3-COMM to match actual licensing combination. New header.LGPL-COMM taken in the use file which were using old header.LGPL3 (src/plugins/platforms/android/extract.cpp) Added new header.LGPL3 containing Commercial + LGPLv3 + GPLv2 license combination Change-Id: I6f49b819a8a20cc4f88b794a8f6726d975e8ffbe Reviewed-by: Matti Paaso <matti.paaso@theqtcompany.com>
* Fix for HTC Pinyin input methodPaul Olav Tvete2014-11-241-0/+4
| | | | | | | | | | | HTC does not do beginBatchEdit/endBatchEdit when committing text. We implement the commit in two steps: first set the text, then move the cursor. To avoid sending an updateSelection for the intermediate state, we need to block updates when we set the text in the editor. Task-number: QTBUG-42300 Change-Id: Icd18700ecf1fba5acb9f8a78762555c1309b221b Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@theqtcompany.com>
* Android: deadlock avoidancePaul Olav Tvete2014-10-201-1/+10
| | | | | | | | | | | | | This change adds deadlock protection to all places where we lock one thread while waiting for the other to do something. If we detect that the other thread is going to block, we abort the operation. This could cause unexpected problems, such as painting errors, text input errors, or even crashes, but the alternative is a guaranteed deadlock. Task-number: QTBUG-41369 Change-Id: I2627a955cfafc4bce54eb9d0d38e19b768b06956 Reviewed-by: Christian Stromme <christian.stromme@digia.com>
* Delay showing keyboard until application is activePaul Olav Tvete2014-10-201-0/+12
| | | | | | | | | | Android starts asking lots of questions when the software keyboard pops up, so let's wait until the application is initialized. This works around a deadlock on startup. Task-number: QTBUG-41369 Change-Id: I1c79e32d08c7cc11748ec55efbff3bc25e40f4b2 Reviewed-by: Christian Stromme <christian.stromme@digia.com>
* Android: Thread fix/optimizationPaul Olav Tvete2014-10-101-3/+3
| | | | | | | | | Do the cheap test before sending an expensive query that might use a mutex. Task-number: QTBUG-41369 Change-Id: I78f03c84e5bbf0492f1b7ea18d1baa752a1beff2 Reviewed-by: Christian Stromme <christian.stromme@digia.com>
* Android: Hide vkb when IM disabled for focus objectEskil Abrahamsen Blomfeldt2014-10-031-4/+8
| | | | | | | | | | | | | | | | When the focus object changes to an object that does not have IM enabled, we should hide the keyboard instead of resetting it. This happens, for instance, if you change to a different tab in an application while a text input in the previous tab had focus. Previously the input panel would stay open and overlap part of the new tab. [ChangeLog][Android] Hide input panel when focus changes to an object that does not accept input. Change-Id: I4009d203559582fa02c15fdc1a3f009396af2531 Task-number: QTBUG-32399 Reviewed-by: Paul Olav Tvete <paul.tvete@digia.com>
* Android: Add findClass() function to the QJNIEnvironmentPrivate class.Christian Strømme2014-09-261-17/+15
| | | | | | | | | The static QJNIEnvironmentPrivate::findClass() function exposes the cache and the class finding code in qjni. Change-Id: I42043dc993cf9cace042faf763f2a647ba79d97f Reviewed-by: Paul Olav Tvete <paul.tvete@digia.com> Reviewed-by: BogDan Vatra <bogdan@kde.org>
* Update license headers and add new license filesMatti Paaso2014-09-241-18/+10
| | | | | | | | | - Renamed LICENSE.LGPL to LICENSE.LGPLv21 - Added LICENSE.LGPLv3 - Removed LICENSE.GPL Change-Id: Iec3406e3eb3f133be549092015cefe33d259a3f2 Reviewed-by: Iikka Eklund <iikka.eklund@digia.com>
* Android: fix inputmethod race conditionsPaul Olav Tvete2014-09-101-57/+57
| | | | | | | | | | | focusObjectInputMethodQuery() and sendInputMethodEvent() were not thread safe. Remove them, and replace with thread safe versions based on the same principle as queryFocusObjectThreadSafe(). Task-number: QTBUG-40995 Change-Id: Idb6f0c6d3963b7e8e73e029e83d0367088146ca8 Reviewed-by: Christian Stromme <christian.stromme@digia.com> Reviewed-by: BogDan Vatra <bogdan@kde.org>
* Avoid deadlock when suspending devicePaul Olav Tvete2014-09-051-2/+8
| | | | | | | | | | | | | Don't wait for the GUI thread when it's already waiting for us. An application that uses the virtual keyboard may get an inputmethod query just when it is being suspended. If the GUI thread is already blocking on a semaphore at that point, waiting for the android thread, we really do not want to wait for the GUI thread... Task-number: QTBUG-40955 Change-Id: Iea2cf0dd058a41a897d596c4bcf16f0508adb20b Reviewed-by: Christian Stromme <christian.stromme@digia.com>
* Android: Report current selection to the input methodPaul Olav Tvete2014-05-261-4/+16
| | | | | | | Task-number: QTBUG-39196 Change-Id: Ib798f1de83ccbe3830a746b6ddd435a0934c34cd Reviewed-by: J-P Nurmi <jpnurmi@digia.com> Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@digia.com>
* Android: text cursor position fixesPaul Olav Tvete2014-05-081-11/+44
| | | | | | | | | | | | | | | | The Android input method protocol specifies that finishComposingText() should not move the cursor. Since Qt likes to move the cursor to the end of the newly committed text, we have to explicitly move the cursor to where the preedit cursor used to be. Fortunately we already keep track of that. Also implement support for the newCursorPosition argument to commitText() since the function needed to be rewritten anyway. (It was calling finishComposingText().) Task-number: QTBUG-38794 Change-Id: Iff2c43bdbd3dda812ccdc71da63f3fa730474eef Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@digia.com>
* Android input method fixes for SwiftKeyPaul Olav Tvete2014-04-251-41/+141
| | | | | | | | | | | | | | | | | Try to conform to the input method protocol in the way that SwiftKey expects (and the way that the stock android components actually do). * Refactor cursor position logic * fix getExtractedText() so it includes preedit text * ignore the hintMaxChars parameter to getExtractedText(), since it looks like everybody else does * fix setComposingRegion when preedit is active * track the start of the preedit and the preedit cursor position, since the Qt input method query does not give us this information Change-Id: I2ed8797abacd97ca749ca152fab2a2d5446ef603 Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@digia.com>
* Android input method fixPaul Olav Tvete2014-04-181-1/+1
| | | | | | | | | | Let textBeforeCursor return the text immediately before the cursor, and not the text at the beginning of the paragraph, even if that is also technically before the cursor. (Apparently I do not know the difference between left and right.) Change-Id: I6043ebe53838e68880b6407dbb9e5370bc785c1b Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@digia.com>
* Android: Reset input method when focus changesPaul Olav Tvete2014-04-161-1/+13
| | | | | | | | | | | Qt Quick does not have the widgets workaround of explicitly hiding the input method on focus out. This fix copies what happens in the iOS port: Commit the current preedit and reset the IM when we see that the focus object changes. Task-number: QTBUG-38047 Change-Id: I30805265286dc650b3734e2a24807cdc8bfbcd16 Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@digia.com>
* Android: input method fixes for SwiftEdit keyboardPaul Olav Tvete2014-03-311-10/+42
| | | | | | | | | | | | * Report correct pre-edit information when calling updateSelection() on endBatchEdit() * Fix getExtractedText() to report the correct offset and cursor position, * Fix setSelection() to use the correct cursor position. Task-number: QTBUG-35689 Change-Id: I7e8427d0f5a18abf18ba2faf9d510756ddf6044b Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@digia.com>
* Android: implement batch editing for input methodsPaul Olav Tvete2014-03-281-6/+50
| | | | | | Task-number: QTBUG-37584 Change-Id: I59f063b2e4b6427a66f7b561cfae7193ceafa43c Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@digia.com>
* Android input method improvementsPaul Olav Tvete2014-03-181-16/+70
| | | | | | | | | | | | | | Use the new inputmethod query API. and get rid of the hack where we would move the cursor back and forwards to make sure that the Android software keyboard noticed that the cursor had moved. The android plugin now uses absolute positions instead of position within the paragraph for all cursor handling (provided that the control supports the new API). Task-number: QTBUG-37511 Change-Id: I03463dbbcb4acbfa41e2eab06889d021d50da01f Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@digia.com>
* Support multiple native surfaces on Android.BogDan Vatra2014-01-171-0/+762
Support for multiple native surfaces is needed by applications that need to mix raster windows with GL windows. Rework the raster and opengl implementation, get rid of eglfs and fbconvenience dependencies. Create a single android platform plugin. [ChangeLog][Android] Rework the raster and opengl implementation. [ChangeLog][Android] Create a single android platform plugin. Task-number: QTBUG-34650 Change-Id: I9b1ab51554823329dda8cfbf8fef27c38f917c7b Reviewed-by: Paul Olav Tvete <paul.tvete@digia.com>