Estimated read time: 2 minutes
In from viewing only to a living document, I wrote about how tile invalidation can handle updates in the Android app in case what should be displayed on the screen changes. A next step in this TDF-funded project is to handle more than blinking text: keyboard and mouse/touch events from the user.
First let me enumerate over the issues we had to face:
-
Gtk, Android and LibreOffice’s VCL use different key codes for the same physical keys. We solved this by mapping the special keys manually on the Gtk/Android side (using the C++ and Java UNO binding), and for the rest, we simply use the unicode representation of the keys.
-
Special keys: while "return" was easy to map, getting "backspace" to work was more challenging. It worked fine on the Gtk side, but on Android we had to make sure that the whole sfx2 dispatching framework works properly, only then could map the backspace key to the correct UNO command, which is
.uno:SwBackspace
in case of Writer. -
Mouse handling: VCL sends pixel coordinates to the editing windows, they then calculate the offset of the editing area (think about toolbars and menus that have to be excluded), and then converts the pixel values to document coordinates. In case of tiled editing, we always work with document coordinates in logical units (twips), so we had to add the possibility to send the coordinates in document ones. This allows core not knowing where the user exactly is (in case the tiles are already ready, swiping can be handled without any LOK calls), and also allows Android not knowing the implementation details of the desktop app (where menus and toolbars would be).
-
Cursor caret overlay: we wanted to be sure that it’s not necessary to re-render the affected tiles each time the cursor blinks, so we added a LOK API to send the rectangle (its width is nearly zero) of the cursor to Android, and then it can handle the blinking cursor itself in a transparent overlay. This overlay will be useful for presenting selections as well.
As usual the commits of me and Tomaž Vajngerl are in master, so you can try this right now, or wait till tomorrow and get the Android daily build. However, if you are just interested how this looks like, here are some demos:
-
Keyboard handling in gtktiledviewer:
-
Same on Android, including newlines and backspace handling:
-
Mouse handling in gtktiledviewer:
-
Same on Android, including the transparent selection overlay that can efficiently blink the cursor:
That’s it for now — next on our list are selections, so you can delete and overwrite more easily. :-)