Tag Archives: GTK+

Text Input Method Support in Wayland

Over the last years, we at Openismus have worked on input methods for mobile devices (see for example the Maliit input method framework). During that work we noticed that there are several problems caused by the toolkit-level interface between the input method system and the applications (beside having to implement interfaces for every toolkit, like GtkIMContext and QInputContext). One of this problems is synchronizing events happening to the focus window and the virtual keyboard window. Therefore good platform integration of input methods such as virtual keyboards requires additional window management policies, as the window manager has to gain knowledge about input methods. The compositing window manager on Nokia’s N9 serves as an example for the amount of required integration. It also taught us about what can go wrong and that Xorg induced latency is a hard problem to solve (see Compositing in Maliit). There is also the XIM X extension which integrated input methods on the X level, but its limitations and complexity puts it as a second choice compared to the toolkit interfaces mentioned above (especially since it does not manage to solve there problems).

The move from Xorg to Wayland offers the possibility to move the input method system from the toolkit level down to the display server, as discussed in our Wayland Input Method System Proposal. Last week, Openismus let me work on a small prototype technical demo for Weston (the Wayland reference compositor) which implements some of the ideas in that proposal. This should be useful for testing the idea of having the input method system integrated in Wayland.

New Wayland interfaces

Standalone input method system with text and input method protocols

The prototype defines three interfaces. The first is the text_model, which is used to communicate from the application/toolkit side with the input method system. It provides the input method system with all required information about the active text, such as selection, surrounding text and cursor index. The application receives events over this interface, such as preedit and commit, from the input method system. For the prototype, I implemented an example editor client, which uses the text model to send the surrounding text to the input method system and receives commit events.

The second interface is the input_method interface which is used to communicate between the input method and Wayland. For the prototype we use a really simple keyboard client which just sends commit events when pressing one of the keys.

The third interface is used to register the keyboard surface as an input panel on the shell. I added the input_panel interface to the desktop shell protocol. This allows the shell to stack the keyboard surface into the right layer (for the prototype I used the panel layer). Additionally, the prototype adds support to the shell to show the keyboard only when a text model is active.

Demos


The screen cast shows the prototype in action, but for those with a working Wayland installation, it should also be possible to just compile and run the prototype.

Outlook

The prototype is the outcome of less than a week of coding, but it already uses some of the concepts we learned while working on Maliit. It should serve as a baseline for further Wayland input method system integration, even if many basic items are missing. For instance, there is no integration with hardware keyboard events, nor keyboard focus (which is handled by wl_seat in Wayland). Nevertheless I will polish my patches a bit and send them to the Wayland mailing list for integration into Weston, so that they can be used for more work on input methods in Wayland/Weston. My colleague Michael will present this work at aKademy in two weeks, which will be a good opportunity to discuss the possibilities of such an input method system in Wayland.

Openismus, Clutter Tutorial and Tool Palette

As announced by Murray I have started working at Openismus. Two of the tasks I did in the first week:

Clutter Tutorial

I updated the source code examples of the Clutter tutorial written by Murray to make them run with the current unstable development version of Clutter. I never used Clutter before but it is a really nice library and the tutorial helps a lot to understand Clutter concepts like Timelines and Behaviours. (Patch to update the examples).

Tool Palette

There is a generic tool palette container developed by Openismus. I continued Mathias’ work by adding new features such as support for scroll to group (show as much items of a group as possible when expanding) or RTL language support:

There is a bug open in GTK+ which allows to use some additional layout options for tool items. It would allow something like an enhanced BOTH_HORIZ style:

or vertical, aligned text in the TEXT style:

The EggToolPalette is already usable. The source code is avaiable: svn co http://svn.gnome.org/svn/libegg/trunk libegg

Viewvc: http://svn.gnome.org/viewvc/libegg/trunk/libegg/toolpalette/

Use

  • egg_tool_palette_new () to create a new tool palette
  • egg_tool_item_group_new (“Name”) to create a named item group
  • gtk_container_add (GTK_CONTAINER (palette), group) to insert the item group into the palette
  • and egg_tool_item_group_insert (EGG_TOOL_ITEM_GROUP (group), item, -1) to insert a GtkToolItem into the item group

The testtoolpalette.c example shows some more features (like drag and drop support).

A Default GtkWindow with Menu and Toolbars

I don’t like such applications on my N810:

The application could be ported to use a HildonWindow if compiled for the maemo platform. But it would be much easier if there were an abstract GTK+ widget which would allow it to add a menu and toolbars to a window in a (platform specific) default layout.

I imagine something like:

With this proposal, it would also be possible to implement a Mac-style MenuBar without a GtkMenuBar hack.

See Bug 533003.

p.s. I don’t like the name GtkMainWindow. Maybe something like GtkDefaultWindow or GtkSimpleWindow would be better.

Scrollable widgets in GTK+

In GTK+ 2 there are scrollable widgets like GtkTreeView, GtkTextView or GtkViewport but no GtkScrollable interface. Instead a scrollable widget is defined by a “set_scroll_adjustments” signal, which id is written to the GtkWidgetClass::set_scroll_adjustments_signal class variable.

If a scrollable widget is added to a GtkScrolledWindow the set_scroll_adjustments_signal is called and the hadjustment and vadjustment from the GtkScrolledWindow are passed as parameters to the scrollable widget. The scrollable widget than replaces its own adjustments with the ones it got from the GtkScrolledWindow. If the scrollable widget is removed from the GtkScrolledWindow it recreates its own adjustments.

This model seems to be simple, but all scrollable widgets need (and set) specific values for GtkAdjustment::lower, ::upper, ::page_increment and ::page_size and the adjustments are required by the size-allocate function. So the adjustments should actually be owned by the scrollable widget and not by the GtkScrolledWindow.

For GTK+ 3 I propose a simple GtkScrollable interface with a readable hadjustment and vadjustment property. If a widget which implements GtkScrollable is added to a GtkScrolledWindow the GtkScrolledWindow should use its adjustments.

See Bug 468689 and the attached patch.