Why are there keyboards and pointers? Why not just an input device?

Peter Hutterer peter.hutterer at who-t.net
Sun Oct 9 20:45:07 PDT 2011

[re-adding xorg-devel]

On Fri, Oct 07, 2011 at 09:47:08AM +0200, Michal Suchanek wrote:
> On 7 October 2011 00:07, Peter Hutterer <peter.hutterer at who-t.net> wrote:
> > On Thu, Oct 06, 2011 at 01:41:07PM +0200, Michal Suchanek wrote:
> >> maybe this is a stupid question but why do we have keyboard and mice
> >> attached as different kinds of devices?
> >>
> >> Since mouse events can be mapped even to plain keyboards and many mice
> >> have keys or buttons that would like to pretend to be keys what is the
> >> benefit?
> >
> > the core protocol forces a pointer/keyboard distinction. And the input
> > extension does so too (since 1.4, I think). So you need to keep this
> > distinction around for backwards-compat anyway.
> I don't think so. Even if there are separate functions for keyboards
> and pointers if any input device can be used as argument to either
> it's completely compatible. The fact that now they can't causes the
> problems and even server crashes when you try to generate events of
> one kind on the device of other kind.

I've fixed _a lot_ of these crashes. Yes, they shouldn't be there to begin
with but we have a client-facing API that enforces a pointer/keyboard
distinction. You could probably introduce a new internal MD type and make the
pointer/keyboard distinction even more abstracted but you'd also have to be
completely backwards-compatible.

> > The really tricky bit to handle is to handle pointer/keyboard grabs on
> > devices, especially combined devices that are both mouse+keyboard. you still
> > need both grabs to work independently from the view of the core protocol.
> This sounds like an event mask which is used in many other parts of
> the protocol already.

the event mask is the least of your worries. it's grab synchronisation
between pointer and keyboard, especially when one grab is sync, one is

> > during the MPX work a few years ago I actually tried to remove the
> > distinction to just have one master devices that slaves are attached to.
> > well, didn't work out too well, it was a lot of work and eventually I gave
> > up.
> With this distinction in place it is very hard to make anything work
> as proper *input* device, not a mere mouse or mere keyboard to the
> point that people give up.

changing this assumption is a lot of work. You're free to implement it of
course but as I said above - I had to give up and I got quite far.

> >> The obvious drawback is it crashes the X server a lot.
> >
> > that's a bug, can usually be worked around.
> And another one is going to crop up shortly, no doubt.

Yes, that's likely.


More information about the xorg-devel mailing list