Re: Problem with extension input events from several devices



Fernando Pereira <fjp@netc.pt> writes:

> I'm having a problem using extension input events from several devices
> simultaneously:
> 
> I'm writing a 3D modeler using gtk+ and OpenGL, and I'm using two input
> devices: a mouse (pointer device) and a trackball (XInput extension
> device).
> 
> I'm using the mouse to draw on top of a 3D surface, and the trackball is
> being
> used to rotate the surface.
> 
> In the past I created a similar solution using Xt/Xaw, but now that I
> moved to
> gtk+/gnome, I'm having this problem:
> 
> Every time I enable the extension input events from the trackball, I
> stop receiving events from the pointer device (mouse):
> 
> Sample code:
> 
> gtk_widget_set_extension_events( drawing_area, GDK_EXTENSION_EVENTS_ALL
> );
> gdk_input_set_mode( trackball_dev, GDK_MODE_WINDOW );
> 
> 
> However, every time I disable events from the trackball, the mouse
> starts sending events again:
> 
> gdk_input_set_mode( trackball_dev, GDK_MODE_DISABLED );
> 
> Is there any way of receinving events from both devices simultaniously ?
> 
> Is this a bug in gtk+ input event processing ?

I wouldn't really consider this a bug; it's more of a limitation
in the way that the GTK+ XInput support was designed. It was
designed for devices such as graphics tablets that replace
the core pointer instead of supplementing it.

The typical setup of such devices is that they control the
core pointer in addition to reporting extension devices.
In order to avoid getting double sets of events, when one
of the enabled XInput devices reports being in proximity,
GTK+ disables reporting of events from the core pointer.  

If you want to patch GTK+, it isn't hard to get around
this - simply change gdk/gdkinputxfree.h:gdk_input_check_proximity
to do nothing.

I'm making some changes to the XInput support for GTK+-2.0,
so I probably can add some sort of hook to support applications
such as yours, perhaps a function call like:

 gboolean
 gdk_device_set_controls_core_pointer (GdkDevice *device, 
                                       gboolean   controls_core);   

It seems that you also would want a separate mode such as 
GDK_MODE_RAW, since it probably is not useful to have the
trackball's reported coordinates scaled to the dimensions   
of the window.

Regards,
                                        Owen





[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]