Quantcast
Channel: Maemo Nokia N900 » meego keyboard quick n900
Viewing all articles
Browse latest Browse all 4

Writing QML-based input methods for Maliit

$
0
0

This week I pushed a simple QML-based virtual keyboard to our MeeGo Keyboard repository. It’s functional, but don’t expect too much. This functionality will most likely never arrive in MeeGo 1.2, sorry folks.

Getting Started

Let’s continue with the good parts instead: The required C++ code was kept to an absolute minimum and in fact it’s only needed to wrap the QML resources into a Qt/C++ plugin that can be loaded by our framework. If you want to write your own QML-based input method plugin for Maliit, then this is the required interface:

class MyQmlBasedInputMethodPlugin
    : public QObject, public MInputMethodQuickPlugin
{
    Q_OBJECT
    Q_INTERFACES(MInputMethodQuickPlugin MInputMethodPlugin)

public:
    MyQmlBasedInputMethodPlugin();

    //! reimpl
    virtual QString name() const;
    virtual QString qmlFileName() const;
    //! reimpl_end
};

The plugin’s name is used for a specific GConf key. Once set to that name, the framework will load this plugin as the currently active one:

$ gconftool-2 -s /meegotouch/inputmethods/plugins/onscreen -t string "WhateverNameYouCameUpWith"

qmlFileName returns the (absolute) file name (or URL) to your main QML file. The framework will set up the required QML environment and try to load this file.

QML components can interface with the application through a set of properties and slots, tied to a root context named MInputMethodQuick. It exposes the following read-only Qt properties:

  • int screenWidth,
  • int screenHeight,
  • int appOrientation (0, 90, 180, 270 with 0 being the typical landscape orientation and with 270 being the typical portrait orientation).

Additionally, QML components can invoke the following Qt slots:

  • setInputMethodArea(const QRect &area)
  • sendPreedit(const QString &text)
  • sendCommit(const QString &text)
  • pluginSwitchRequired(int switchDirection)

Please refer to the header file of MInputMethodQuick to access the full documentation (sorry, not available in MeeGo API docs).

Also, big thanks to Kimmo Surakka and Miika Silfverberg for all their help with this side project.

Self Compositing

9ef2bc9c03demos .png Writing QML based input methods for Maliit

Any QML plugin using MInputMethodQuickPlugin will support self compositing out of the box. That is, instead of letting the system compositor blend the application window and virtual keyboard window together into one, the virtual keyboard bypasses the system compositor and redirects the application’s window to itself. This usually improves raw FPS but also cuts down on latency. Try running the MeeGo Input Methods service like so:

$ meego-im-uiserver -use-self-composition

This should result in a noticable speedup for your QML plugin. Self compositing is tricky, as it requires a well-behaving window manager (and believe it or not, mcompositor is the only one available getting it nearly 100% right). Usually an additional parameter combination of -manual-redirection, -bypass-wm-hint and -software will do the trick. For MeeGo 1.3, we want to activate self compositing by default, so it’s good to know that your QML-based plugin will support this useful feature for free.

A QML-based virtual keyboard for Fremantle

8dd03bf56ddevel.png Writing QML based input methods for Maliit

As part of the exercise I also packaged MeeGo Keyboard Quick for Fremantle – it’s available from Maemo’s extras-devel repository. Be warned though, this is a rough tech demo and as such, fairly useless. A nice advantage of it is that it allowed me to package a MeeGo Input Methods version for Fremantle that is completely free of any MTF/libmeegotouch components.

How to testdrive:

  • Install meego-keyboard-quick (after you convinced yourself that you really know what you do – activating extras-devel can brick your N900!),

  • Install meego-im-demos

  • Open a terminal, start the MeeGo Input Methods service:

    $ meego-im-uiserver -bypass-wm-hint -software -graphicssystem raster

  • Open a second terminal, to run the meego-im-demos-plainqt application:

    $ export QT_IM_MODULE=MInputContext
    $ meego-im-demo-plainqt -fullscreen -software -graphicssystem raster

Instead of the test application, one should be able to use it in any other Qt application, as long as the MeeGo Input Methods service is running and the QT_IM_MODULE environment variable is set correctly.

To fight wrong expectations: I won't have the time to polish or to maintain this port, and from my first tests it would need undefined amounts of integration work to get it to run properly in Fremantle, starting with proper GTK+/Hildon support. If you are, however, interested in furthering this port, then please don't hesitate to contact us.

2011-05-12 18:00 UTC with score -3

Viewing all articles
Browse latest Browse all 4

Latest Images

Trending Articles





Latest Images