dix: check the xi2mask, not the grab type for touch listeners

grab->type is only non-zero for passive grabs. We're checking an active grab
here, so we need to check if the touch mask is set on the grab.

Test case: grab the device, then start two simultaneous touches. The
grabbing client won't see the second touchpoints because grab->type is 0
and the second touch is not an emulating pointer.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
(cherry picked from commit 4fb686d6a6777950f0e0d55b848cd2af4cbad372)
dix: set the valuator mask to ensure XI 1.x events have data

XI 1.x only allows for first + num valuators, so if a device sends data for
valuators 0 and 2+ only (i.e. valuator 1 is missing) we still need to get
the data for that from somewhere.
XI 1.x uses the hack of an unset valuator mask to get the right coordinates,
i.e. we set the value but don't set the mask for it so XI2 events have the
right mask.

For an absolute device in relative mode, this broke in b28a1af55cf, the
value was now always 0. This wasn't visible on the cursor, only in an XI 1.x
client. The GIMP e.g. sees jumps to x/0 every few events.

Drop the condition introduced in b28a1af55cf, data in valuators is always
absolute, regardless of the mode.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
(cherry picked from commit 3d8756631070c440cefa31b35fea3d407f187810)
Xi: Allow clients to ask for 2.3 and then 2.2 without failing

This allows different sub-systems within the same application to
request different Xi versions without either getting old behaviour
everywhere or simply failing with a BadValue.

Signed-off-by: Keith Packard <keithp@keithp.com>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
(cherry picked from commit 4360514d1cc8e3132f93f56172d291074e8c770f)
test: fix XIQueryVersion check for new behaviour

As of 4360514d1cc8e3132f93f56172d291074e8c770f, XIQueryVersion supports
requesting versions 2.2+ in random order, only 2.0 and 2.1 are restricted.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
(cherry picked from commit a5abf790183798ad8aa2c29c056df3647777cfbd)
Revert "test: fix XIQueryVersion check for new behaviour"

This reverts commit cdcb708678c4785cd7b026b90e316691176e5244.
Xi: Clamp XIClient maximal version to XIVersion

Do not allow setting client version to an arbitrary value >= XIVersion.
Fixes a test error with test/xi2/protocol-xiqueryversion.c, introduced by
commit 4360514d1c "Xi: Allow clients to ask for 2.3 and then 2.2 without failing"

Signed-off-by: Maarten Lankhorst <maarten.lankhorst@canonical.com>
Reviewed-by: Keith Packard <keithp@keithp.com>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
(cherry picked from commit 500e844a24962c9e70abb3d614f1973013b2de73)
test/xi2: fix protocol-xiqueryversion test

The old code was broken and allowed setting client version >= XIVersion,
this was fixed in the previous patch, but updating the value for XIVersion
broke the tests, so fix the tests too.

Signed-off-by: Maarten Lankhorst <maarten.lankhorst@canonical.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
(cherry picked from commit b6e5c4669e0db391966deb397e8c975ec7f0124d)
bump rev number from 1.14.2.901 to 1.14.2.902
kdrive: fix build error on gcc 4.8 for out-of-bounds array access

I'm getting a error building xorg-server-1.14.1.902 with thelatest snapshot
of gcc-4.8:

input.c:225:43: error: array subscript is above array bounds
[-Werror=array-bounds]

This is because kdNumInputFds can become equal to KD_MAX_INPUT_FDS in
KdRegisterFd(). This means that in KdUnregisterFd(), kdInputFds[j + 1] can
be beyond the end of the array.

Signed-off-by: Chris Clayton <chris2553@googlemail.com>
Reviewed-by: Keith Packard <keithp@keithp.com>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
bump version from 1.14.2.902 to 1.14.3