Overview
MPX stands for Multi-pointer X, It is available in Xserver 1.7 (released in October 2009), This page describes the status of MPX/XInput 2.0 support in GTK+
Experimental Git Repository
http://git.gnome.org/cgit/gtk+?h=xi2
to download and start hacking:
$ git clone git://git.gnome.org/gtk+/ $ cd gtk $ git checkout -b xi2 $ git pull origin xi2
General changes
GdkDeviceManager has been added. It's a per display object that provides functions for querying the available devices and signals for keeping track of device hierarchy changes.
GdkDevice is now an abstract type, its class has several vmethods for grabbing, ungrabbing, querying state, warping, ...
All internals in GdkDisplay and GdkWindow have been made multipointer aware: double/triple click, grabs, pointer hooks, GdkPointerWindowInfo, events selection, window cursor.
- By default, all devices' enter/leave events are compressed so windows just get 1 pair, if gdk_window_set_support_multidevice (window, TRUE) is called, each device will generate its own pair of events.
GtkDeviceGroup and ::multidevice-event is the part I'm most doubtful of, since it depends on future Xorg decisions about blob events. but makes multipointer interaction quite easy, there are some tests in gtk+/tests/multidevice/.
- It could also perhaps be moved to Gdk
- The concept of grab ownership has been added, a device grab could optionally block other devices' events for the grab window or for the whole application. The most restrictive grabs in effect shadow the others.
X11 internal changes
There are several GdkDevice and GdkDeviceManager implementations, for core X events, XInput 1.x and XInput 2.x.
- The XI1 device manager is a subclass of the core one.
- The XI2 one is fully standalone, no core events will be selected if XI2 is used.
GdkEventTranslator is a new interface to translate X events to GdkEvents, both GdkDisplay and GdkDeviceManager X11 implementations implement this
GdkDisplay takes care of events relative to windows (configure/expose/map/unmap/...)
GdkDeviceManager* take care of events coming from input devices
- All this replaces all event handling code in gdkevents-x11.c and gdkinput-*.c. Code has been kept mostly as is when refactoring, all utility and misc functions have been moved wherever it made most sense.
GdkEventSource replaces GdkDisplaySource, it will use all attached GdkEventTranslators on X events.
Backwards compatibility
- All pure GTK+ applications should work equally with a single pointer, and reasonably well with multiple pointers, multidevice awareness would obviously need changes in apps.
Since core devices' events may also have pressure/tilt/etc info, gimp and inkscape work with tablets out of the box
Emacs-gtk won't receive any events anywhere but in GTK+ widgets (mostly menus), They seem to create GtkWidget and GdkWindows, but rely on them receiving core device X events, which isn't true anymore with XI2.
- Metacity will behave weirdly with drag and drop, they use X API for grabs (XGrabPointer), which interacts badly when the Gdk machinery doesn't listen for core device X events.
Missing stuff
GtkWidgets still need updating to use newer API, this is my next item to do
Non-x11 backends need readapting to _gdk_windowing_* API changes and to provide a GdkDeviceManager implementation
- gtk_grab_add() could also need per-device replacement
- some internals in gtk/ could need readapting yet
- synthesized events in gtk/ need checking now that there are extra fields in some events.
- per-pointer tooltips and multiple keyboard foci? do we want to get that far?
- Drag-and-drop still needs adapting
API Additions
GdkDevice gdk_device_list_axes gdk_device_get_display gdk_device_get_device_type gdk_device_grab gdk_device_ungrab GdkGrabOwnership GdkDeviceManager gdk_device_manager_get_display gdk_device_manager_get_devices GdkDisplay GdkDisplayDeviceHooks gdk_display_set_device_hooks gdk_display_get_device_manager gdk_display_get_device_state gdk_display_get_window_at_device_position gdk_display_warp_device gdk_display_device_is_grabbed GdkEvent gdk_event_get_device GdkWindow: gdk_window_set_device_cursor () gdk_window_get_device_cursor() gdk_window_get_device_position gdk_window_set_device_events gdk_window_get_device_events gdk_window_set_support_multidevice gdk_window_get_support_multidevice
API Deprecations
gdk_pointer_grab gdk_keyboard_grab gdk_display_pointer_ungrab gdk_display_keyboard_ungrab gdk_display_pointer_is_grabbed gdk_pointer_ungrab gdk_keyboard_ungrab gdk_pointer_is_grabbed gdk_input_set_extension_events GdkDisplay: gdk_display_set_pointer_hooks gdk_set_pointer_hooks gdk_display_get_pointer gdk_display_get_window_at_pointer gdk_display_warp_pointer gdk_display_get_core_pointer gdk_devices_list gdk_device_get_core_pointer GdkWindow: gdk_window_get_pointer gdk_window_at_pointer
Other Links
http://www.x.org/wiki/Development/Documentation/MPX
