[Xcb] Need to get pointer coordinates (with xcb-xinput)

Peter Harris pharris at opentext.com
Wed Mar 18 07:00:00 PDT 2009

Mike Semenyako wrote:
> Hi there,
> What I'm trying to do is get current pointer coordinates. Right now,
> I'm calling xcb_input_query_device_state, then
> xcb_input_query_device_state_reply which returns me a pointer to
> xcb_input_query_device_state_reply_t. And the problem is, I don't know
> what to do next. I need to get a pointer to xcb_input_valuator_state_t
> I suppose (to use in xcb_input_valuator_state_valuators) but there's
> no any function in xcb-xinput.h returning it.

> Can someone please help me out?

Unfortunately, xinput is a little bit bizarre, and doesn't quite fit the
X way of doing things.

The basic problem is that query_device_state returns a list of
"input_state". Trouble is, "input_state" can by any of "key_state",
"button_state", or "valuator_state", and they're all different sizes. So
"input_state" can't just be the obvious union, and xcb can't
automatically generate an easy iterator to use.

You probably need to use something like (pseudocode):
val = (xcb_input_valuator_state_t *)(reply + 1)
(with checking of val->class_id to make sure it really is 'valuator' and
not 'key' or 'button').

If you do write some helper functions to manage the xinput mess, we
would very much appreciate it if you would contribute them to xcb/util.
(The xcb/util library is where we currently have helper functions to
help deal with the ximage mess, for example. Unfortunately, no xinput
helpers yet).

 Peter Harris
               Open Text Connectivity Solutions Group
Peter Harris                    http://www.opentext.com/connectivity
Research and Development        Phone: +1 905 762 6001
pharris at opentext.com            Toll Free: 1 877 359 4866

More information about the Xcb mailing list