Commit Graph

365 Commits

Author SHA1 Message Date
Peter Hutterer
908ab3d580 dix: set raw event values before adding up relative values (#46976)
Regression introduced in 4e52cc0ef4

Raw event values are values as-is from the driver, modified only be
transformation or acceleration. 4e52cc caused the mask to be updated from
relative to absolute coordinates which then got written into the raw events.

Move the raw event update into the respective branches for absolute/relative
events.

X.Org Bug 46976 <http://bugs.freedesktop.org/show_bug.cgi?id=46976>

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Chase Douglas <chase.douglas@canonical.com>
Reviewed-by: Daniel Stone <daniel@fooishbar.org>
Tested-by: Sven Arvidsson <sa@whiz.se>
Reviewed-by: Simon Thum <simon.thum@gmx.de>
2012-03-22 11:33:21 +10:00
Peter Hutterer
9c3bd3ae65 dix: fix compiler warning "unused variable 'scr'"
getevents.c: In function 'updateSlaveDeviceCoords':
getevents.c:326:15: warning: unused variable 'scr' [-Wunused-variable]

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2012-03-22 11:33:21 +10:00
Peter Hutterer
eb84c154ed dix: when rescaling from master, rescale from desktop dimensions (#46657)
master->last.valuators[] is in desktop dimensions, so use those as
rescale axis ranges, not the screen. Otherwise, a rescale on any screen
not the top-left will cause out-of-bounds coordinates which will always
map to the bottom-right screen, causing the device to be stuck on that
screen.

X.Org Bug 46657 <http://bugs.freedesktop.org/show_bug.cgi?id=46657>

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Chase Douglas <chase.douglas@canonical.com>
2012-03-22 11:33:20 +10:00
Keith Packard
9838b7032e Introduce a consistent coding style
This is strictly the application of the script 'x-indent-all.sh'
from util/modular. Compared to the patch that Daniel posted in
January, I've added a few indent flags:

	-bap
	-psl
	-T PrivatePtr
	-T pmWait
	-T _XFUNCPROTOBEGIN
	-T _XFUNCPROTOEND
	-T _X_EXPORT

The typedefs were needed to make the output of sdksyms.sh match the
previous output, otherwise, the code is formatted badly enough that
sdksyms.sh generates incorrect output.

The generated code was compared with the previous version and found to
be essentially identical -- "assert" line numbers and BUILD_TIME were
the only differences found.

The comparison was done with this script:

dir1=$1
dir2=$2

for dir in $dir1 $dir2; do
	(cd $dir && find . -name '*.o' | while read file; do
		dir=`dirname $file`
		base=`basename $file .o`
		dump=$dir/$base.dump
		objdump -d $file > $dump
	done)
done

find $dir1 -name '*.dump' | while read dump; do
	otherdump=`echo $dump | sed "s;$dir1;$dir2;"`
	diff -u $dump $otherdump
done

Signed-off-by: Keith Packard <keithp@keithp.com>
Acked-by: Daniel Stone <daniel@fooishbar.org>
Acked-by: Alan Coopersmith <alan.coopersmith@oracle.com>
2012-03-21 13:54:42 -07:00
Peter Hutterer
2416ee4a01 dix: avoid NULL-pointer dereference on button-only devices (#38313)
And for such devices simply take the last.valuators[] which must be valid at
all times anyway. UpdateSlaveDeviceCoords takes care of that.

X.Org Bug 38313 <http://bugs.freedesktop.org/show_bug.cgi?id=38313>

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Chase Douglas <chase.douglas@canonical.com>
2012-02-27 13:01:45 +10:00
Peter Hutterer
6f28388187 dix: reset last.scroll when resetting the valuator (#45611)
last.scroll remained on the last-submitted scrolling value but last.valuator
was changed whenever the slave device changed. The first scrolling delta
after a switch was then calculated as (last.scroll - new abs value), causing
erroneous scrolling events.

Test case:
- synaptics with a scrolling method enabled, other device with 3+ axes (e.g.
  wacom)
- scroll on touchpad
- use other device
- scroll on touchpad

The second scroll caused erroneous button press/release events.

X.Org Bug 45611 <http://bugs.freedesktop.org/show_bug.cgi?id=45611>

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Chase Douglas <chase.douglas@canonical.com>
2012-02-14 21:47:30 +10:00
Chase Douglas
e1085a0da0 Don't set X and Y valuators for indirect touch events
For expediency, it made sense to always have the X and Y axes set for
direct touch device event propagation. The last X and Y values are
stored internally. However, indirect device touch event propagation
does not depend on the touch's X and Y values. Thus, we don't need to
set the values for every indirect touch event.

On top of this, the previous X and Y values aren't stored for indirect
touches, so without this change the axes get erroneously set to 0.

Signed-off-by: Chase Douglas <chase.douglas@canonical.com>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2012-01-24 13:27:30 +10:00
Chase Douglas
9b1e18f42a Only update pointer motion data for pointer emulated touch events
Signed-off-by: Chase Douglas <chase.douglas@canonical.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2012-01-24 13:26:36 +10:00
Chase Douglas
f00e5b02f5 Only scale direct device touch coordinates
Indirect touch devices provide valuator values in pure device
coordinates. They also don't need to be fixed up for screen crossings.

Signed-off-by: Chase Douglas <chase.douglas@canonical.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2012-01-24 13:26:36 +10:00
Peter Hutterer
223ba8b46e dix: fix wrong condition checking for attached slave (#44003)
We need to update the master if the device is not a master _and_ it is not
floating.

X.Org Bug 44003 <http://bugs.freedesktop.org/show_bug.cgi?id=44003>

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Chase Douglas <chase.douglas@canonical.com>
2012-01-06 08:06:05 +10:00
Peter Hutterer
8080d785b2 dix: remove requirement for client_id be the first element
Leftover code from an earlier version of GetTouchEvents.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Chase Douglas <chase.douglas@canonical.com>
2011-12-21 14:16:37 +10:00
Peter Hutterer
f3df3ad668 dix: handle DIX-submitted touch events
The DIX needs to submit touch events for e.g. TouchEnd after an
acceptance/rejection. These have the TOUCH_CLIENT_ID flag set.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Chase Douglas <chase.douglas@canonical.com>
2011-12-21 12:38:32 +10:00
Daniel Stone
9ce8463a33 dix: generate touchpoints from driver-submitted data
The touchpoints are generated, enqueued but not processed since we don't
handle them in the event processing yet.

Co-authored-by: Peter Hutterer <peter.hutterer@who-t.net>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Chase Douglas <chase.douglas@canonical.com>
2011-12-20 13:06:32 +10:00
Daniel Stone
bec51f5ec6 dix: add GetTouchOwnership event API
No callers yet. This API is not to be used by drivers, it's an API for the
DIX which will create ownership events mainly on touch acceptance/rejection.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Chase Douglas <chase.douglas@canonical.com>
2011-12-20 13:01:03 +10:00
Daniel Stone
098b837440 Add the touch input API stubs
xf86PostTouchEvent is the driver API to submit touch events to the server.
This API doesn't do anything yet though but now we can at least bump the
API.

For valuators, drivers should use the existing xf86InitValuatorAxisStruct
function.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Chase Douglas <chase.douglas@canonical.com>
2011-12-19 09:08:36 +10:00
Peter Hutterer
3390d3fc03 Xi: process raw touch events
No-one can generated them yet, but if they could, we'd be processing them
like there was no tomorrow.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Chase Douglas <chase.douglas@canonical.com>
2011-12-16 11:18:47 +10:00
Peter Hutterer
190a6f45ee dix: split positionSprite into scale_to_desktop and positionSprite
For future touch points, we need positionSprite to calculate the coordinates
but we don't want to actually change the cursor position for non-emulating
touches.

No functional changes at this point.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Jamey Sharp <jamey@minilop.net>
Reviewed-by: Chase Douglas <chase.douglas@canonical.com>
2011-12-16 11:18:40 +10:00
Peter Hutterer
10a8c428fa dix: move storing last.valuators into a helper function
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Chase Douglas <chase.douglas@canonical.com>
2011-12-13 13:24:57 +10:00
Peter Hutterer
11840595a1 dix: Don't let a driver without a ProximityClassRec post events
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Jeremy Huddleston <jeremyhu@apple.com>
2011-11-09 13:26:47 +10:00
Keith Packard
d91aa0e660 Merge remote-tracking branch 'whot/two-screen-coordinates' 2011-11-02 21:20:07 -07:00
Peter Hutterer
1f4af6c12f dix: accept a NULL master for CreateClassesChangedEvent
If a floating device changes, the master is NULL but we must still create a
DCE for it.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Daniel Stone <daniel@fooishbar.org>
2011-10-25 14:06:41 +10:00
Peter Hutterer
e9dee21fa3 dix: pass the flags into the CreateClassesChangedEvent
No effective functional changes, prep work for future patches.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Daniel Stone <daniel@fooishbar.org>
2011-10-25 14:06:41 +10:00
Peter Hutterer
8473e441b0 dix: add ScrollInfo to DeviceChangedEvents
3304bbff9b added smooth scrolling support for
pointer events and for XIQueryDevice but didn't add the matching parts to
XIDeviceChangedEvents.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Daniel Stone <daniel@fooishbar.org>
2011-10-25 14:06:41 +10:00
Peter Hutterer
2cb63180fa dix: mark motion events as emulated if we're scrolling from button press
The protocol requires that the emulated event is marked as such. So if a
driver with smooth scrolling axis sends legacy button events, the motion
event must be marked as emulated.

Pass the real type to emulate_scroll_button_events and create the events
accordingly. For real button press or relase events, only that event must be
generated since a release event will follow or a press event has already
occured, respectively. (This fixes a bug where we'd get two release events
for each legacy button event)

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Daniel Stone <daniel@fooishbar.org>
2011-10-18 09:15:54 +10:00
Peter Hutterer
401150d7dc input: change pointer screen crossing behaviour for multiple ScreenRecs
miPointerSetPosition traditionally took coordinates on a per-screen basis,
triggering a screen switch when these went out-of-bounds. For absolute
devices, this prevented screen crossing in the negative x/y direction.

This patch changes the event generation patch to handle screen coordinates
in a desktop range (i.e. all screens together). Screen switches are
triggered when these coordinates are not on the current screen.

This unifies the pointer behaviour of single ScreenRec multihead and
multiple ScreenRecs multihead in that the cursor by default moves about the
whole screen rather than be confined to one single screen. The
transformation matrix may then be used to actually confine the cursor to the
screen again.

Note: fill_pointer_events has to deal with several different coordinate
systems. Make sure you read the comment before trying to understand the code.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2011-10-13 11:34:43 +10:00
Peter Hutterer
6bd0eff40f dix: extend rescaleValuatorAxis to take a minimum default
Allow rescaling to non-zero based axis ranges as default (for when screen
offsets are non-zero). Currently unused.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2011-10-13 11:34:17 +10:00
Peter Hutterer
32b289e46c dix: move MD last.valuator update into fill_pointer_events
Don't update the MD where it's not expected, positionSprite should really
just do that - position the sprite.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Daniel Stone <daniel@fooishbar.org>
2011-10-11 12:07:00 +10:00
Peter Hutterer
3b36fd1b49 mi: switch miPointerSetPosition to take doubles
Don't switch between doubles and ints in the caller, instead take doubles in
miPointerSetPosition and do the conversion there. For full feature we should
change everything down from here for doubles too.

Functional change: previously we'd restore the remainder regardless of
screen switching/confinement (despite what the comment said). Now,
screen changing or cursor constraints will cause the remainder be clipped
off. This should happen for cursor constraints but arguably not for screen
crossing.

This also corrects a currently wrong comment about miPointerSetPosition's
input coordinates.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Daniel Stone <daniel@fooishbar.org>
2011-10-11 12:06:56 +10:00
Peter Hutterer
81cfe44b1e mi: return the screen from miPointerSetPosition
miPointerSetPosition may switch screens. Always return the screen the sprite
is on instead of relying on callers to call miPointerGetScreen().

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Jamey Sharp <jamey@minilop.net>
Reviewed-by: Daniel Stone <daniel@fooishbar.org>
2011-10-11 12:06:53 +10:00
Peter Hutterer
88dfe5366d dix: drop screen argument from positionSprite
We can just get this in the function, no effective functional changes.

Also return the screen to the caller. Though we don't use it yet, we will in
a follow-up patch.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Jamey Sharp <jamey@minilop.net>
Reviewed-by: Daniel Stone <daniel@fooishbar.org>
2011-10-11 12:06:50 +10:00
Peter Hutterer
967bc25da2 dix: move screen- to device coordinate scaling to separate function
No functional changes.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Jamey Sharp <jamey@minilop.net>
Reviewed-by: Daniel Stone <daniel@fooishbar.org>
2011-10-11 12:06:48 +10:00
Peter Hutterer
b059e06e19 dix: don't allow keyboard devices to submit motion or button events.
GPE unconditionally dereferences pDev->valuator if a mask is present. This
shouldn't really happen but if it does, don't crash, just ignore the events
with an error.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Jamey Sharp <jamey@minilop.net>
Reviewed-by: Daniel Stone <daniel@fooishbar.org>
2011-10-11 12:06:42 +10:00
Peter Hutterer
bccff53318 dix: moveRelative modifies parameter in-place, say so.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Jamey Sharp <jamey@minilop.net>
Reviewed-by: Daniel Stone <daniel@fooishbar.org>
2011-10-11 12:06:38 +10:00
Peter Hutterer
b966362ccf dix: rename moveAbsolute to clipAbsolute
Let's be honest about what it does.

moveRelative accumulates delta _and_ clips in some cases, so that one can
keep it's name.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Jamey Sharp <jamey@minilop.net>
Reviewed-by: Daniel Stone <daniel@fooishbar.org>
2011-10-11 12:06:34 +10:00
Peter Hutterer
959d18c376 dix: fix missing verb in comment
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Jamey Sharp <jamey@minilop.net>
Reviewed-by: Daniel Stone <daniel@fooishbar.org>
2011-10-11 12:06:29 +10:00
Peter Hutterer
7074ec87bd dix: document transformAbsolute
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Jamey Sharp <jamey@minilop.net>
Reviewed-by: Daniel Stone <daniel@fooishbar.org>
2011-10-11 12:06:27 +10:00
Max Schwarz
765ef69295 dix: fix inverted handling of legacy scroll button events
This bug led to inverted scrolling axes with drivers that support smooth
scrolling axes but send legacy button events.

Signed-off-by: Max Schwarz <Max@x-quadraht.de>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2011-10-06 10:55:16 +10:00
Peter Hutterer
535b3789be dix: warn about keyboard events with valuator masks
We don't actually handle the mask correctly. They're clipped and dropped
into the event but that's about it. I don't think we did since 1.4, let's
warn the user if this happens.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Daniel Stone <daniel@fooishbar.org>
2011-10-04 13:00:23 +10:00
Peter Hutterer
9537afb13f dix: fill out root_x/y for keyboard events
Switching screens relies on rootx/y to be set to the correct value. Note:
though we technically take a mask for GetKeyboardEvents we don't actually
handle it properly to move the pointer as required (and generate motion
events if needed).

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Daniel Stone <daniel@fooishbar.org>
2011-10-04 13:00:21 +10:00
Peter Hutterer
3304bbff9b Input: Add smooth-scrolling support to GetPointerEvents
For scroll wheel support, we used to send buttons 4/5 and 6/7 for
horizontal/vertical positive/negative scroll events.  For touchpads, we
really want more fine-grained scroll values.  GetPointerEvents now
accepts both old-school scroll button presses, and new-style scroll axis
events, while emitting both types of events to support both old and new
clients.

This works with the new XIScrollClass to mark axes as scrolling axes.
Drivers mark any valuators that send scroll events with SetScrollValuator.
(Currently missing: the XIDeviceChangeEvent being sent when a driver changes
a scroll axis at run-time. This can be added later.)

Note: the SCROLL_TYPE enums are intentionally different values to the XI2
proto values to avoid copy/overlapping range bugs.

Co-authored-by: Daniel Stone <daniel@fooishbar.org>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Daniel Stone <daniel@fooishbar.org>
2011-09-30 09:24:18 +10:00
Daniel Stone
5ac1f885f5 Input: Add POINTER_EMULATED flag to GetPointerEvents
POINTER_EMULATED merely sets XIPointerEmulated in the generated
DeviceEvent.

Signed-off-by: Daniel Stone <daniel@fooishbar.org>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
2011-09-29 12:26:43 +10:00
Daniel Stone
d8e42decba Input: Split GetPointerEvents body into a helper function
For smooth-scrolling support, we want GetPointerEvents to generate
multiple events, so split the body of the function out into a helper
function in order to call it multiple times.

Signed-off-by: Daniel Stone <daniel@fooishbar.org>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
2011-09-29 12:26:43 +10:00
Daniel Stone
bc8aad2376 Input: Set last valuators in GetPointerEvents only
Previously, various pieces of code, including acceleration, used to drop
the values into DeviceIntRec::last.valuators.  Remove all this and only
do it in GetPointerEvents after all transformation, acceleration and
clipping, so we're guaranteed to always have the correct values.

Signed-off-by: Daniel Stone <daniel@fooishbar.org>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
2011-09-29 12:26:42 +10:00
Daniel Stone
94c19a0a72 Input: Convert DeviceIntRec::last to use doubles
Change the last real user of a split integer/fractional co-ordinate
system, DeviceIntRec's last->{valuators,remainder} to just have one set
of doubles.

Signed-off-by: Daniel Stone <daniel@fooishbar.org>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
2011-09-29 12:26:34 +10:00
Daniel Stone
2d9beeb217 Input: Make DeviceEvent use doubles internally
Change the DeviceEvent InternalEvent to use doubles for its valuators,
instead of data and data_frac.

Signed-off-by: Daniel Stone <daniel@fooishbar.org>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
2011-09-29 12:24:34 +10:00
Daniel Stone
626f487b97 Input: Make RawDeviceEvent use doubles internally
Change RawDeviceEvent to use doubles for valuators internally, rather
than data(_raw) and data(_raw)_frac.

Signed-off-by: Daniel Stone <daniel@fooishbar.org>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
2011-09-29 12:24:34 +10:00
Daniel Stone
3b7fb0f68d Input: Modify mask in-place in positionSprite
Instead of taking pointers to x and y values to modify in
positionSprite, just modify the mask (as well as dev->last) in place.

Signed-off-by: Daniel Stone <daniel@fooishbar.org>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
2011-09-29 12:24:34 +10:00
Daniel Stone
629a575261 Input: Convert positionSprite and GetPointerEvents to double
Use doubles internally in both of these functions, eliminating most of
the remaining int co-ordinate usage.

Signed-off-by: Daniel Stone <daniel@fooishbar.org>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
2011-09-29 12:24:34 +10:00
Daniel Stone
51437995a5 Input: Don't call positionSprite for non-pointer devices
If the device doesn't have any valuators, or if it has less than two of
them, don't bother calling positionSprite.  Users with one-dimensional
pointing devices may be upset.

Signed-off-by: Daniel Stone <daniel@fooishbar.org>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
2011-09-29 12:24:34 +10:00
Daniel Stone
4c364a312d Input: Convert rescaleValuatorAxis to double
Instead of passing fractional pointers around everywhere, just pass
doubles instead.  Much easier.

Signed-off-by: Daniel Stone <daniel@fooishbar.org>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
2011-09-29 12:24:34 +10:00
Daniel Stone
5680fa41ea Input: Remove x and y from moveAbsolute/moveRelative
Both these functions modify the mask and
pDev->last.{valuators,remainder} in-place now, so there's no need to
pass in pointers to local x and y values.

Signed-off-by: Daniel Stone <daniel@fooishbar.org>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
2011-09-29 12:24:34 +10:00
Daniel Stone
0882b788da Input: Convert acceleration code to using ValuatorMask
Instead of passing a set of int* to the acceleration code, pass it a
mask instead, which avoids an unfortunate loss of precision.

Signed-off-by: Daniel Stone <daniel@fooishbar.org>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Simon Thum <simon.thum@gmx.de>
2011-09-29 12:24:34 +10:00
Daniel Stone
e1df51421b Input: Set fractional member in set_raw_valuators
RawDeviceEvents have space for fractional valuator members, so might as
well start using them.

Signed-off-by: Daniel Stone <daniel@fooishbar.org>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
2011-09-29 12:23:51 +10:00
Daniel Stone
cdf202250e Input: Convert transformAbsolute to work on doubles
Change transformAbsolute to use doubles internally.

Signed-off-by: Daniel Stone <daniel@fooishbar.org>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
2011-09-29 12:23:51 +10:00
Daniel Stone
3463078f96 Input: Convert clipAxis, moveAbsolute and moveRelative to double
Change all these three to use doubles internally, though the outputs of
moveAbsolute and moveRelative are still truncated to int.

Signed-off-by: Daniel Stone <daniel@fooishbar.org>
2011-09-29 12:23:51 +10:00
Daniel Stone
4e52cc0ef4 Input: Prepare moveRelative for conversion to double
Shuffle some code around in moveRelative to make the conversion to
double easier later.

Signed-off-by: Daniel Stone <daniel@fooishbar.org>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
2011-09-29 12:23:51 +10:00
Daniel Stone
80fdf9ca33 Input: Prepare moveAbsolute for conversion to double
Shuffle some code around to make moving to double easier later.

Signed-off-by: Daniel Stone <daniel@fooishbar.org>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
2011-09-29 12:23:51 +10:00
Daniel Stone
6a6b4eb05c Input: Store clipped absolute axes in the mask
Change moveAbsolute to be more symmetric with moveRelative by storing a
clipped axis value back in the mask, rather than just in
dev->last.valuators.

Signed-off-by: Daniel Stone <daniel@fooishbar.org>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
2011-09-29 12:23:51 +10:00
Peter Hutterer
3a077f246e input: provide a single function to init DeviceEvents to 0
getevents.c already had that function, but XKB was manually initializing it,
causing bugs when the event structure was updated in one place but not the
other.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2011-08-22 15:56:52 +10:00
Peter Hutterer
4b376ddeb4 dix: fix compiler warnings ("foo" set but not used)
devices.c: In function 'AttachDevice':
devices.c:2409:18: warning: variable 'oldmaster' set but not used
[-Wunused-but-set-variable]

events.c: In function 'ConfineToShape':
events.c:683:15: warning: variable 'pSprite' set but not used
[-Wunused-but-set-variable]

events.c: In function 'ProcGrabPointer':
events.c:4759:15: warning: variable 'time' set but not used
[-Wunused-but-set-variable]

getevents.c: In function 'GetMotionHistory':
getevents.c:425:9: warning: variable 'dflt' set but not used
[-Wunused-but-set-variable]

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Daniel Stone <daniel@fooishbar.org>
2011-08-22 15:56:52 +10:00
Daniel Stone
e084ac30b3 Input: Reset SD remainder when copying co-ords from MD
In updateSlaveDeviceCoords, pDev->last.valuators was being copied from
the master, but pDev->last.remainder wasn't.  Make sure we copy both, to
avoid minor inconsistencies.

Signed-off-by: Daniel Stone <daniel@fooishbar.org>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2011-07-01 08:46:28 +10:00
Peter Hutterer
23a7832789 input: add POINTER_NORAW to avoid generation of raw events (#30068)
RawEvents are supposed to be events coming from the driver. When warping the
pointer, this should not generate a raw event.

X.Org Bug 30068 <http://bugs.freedesktop.org/show_bug.cgi?id=30068>

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Daniel Stone <daniel@fooishbar.org>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2011-07-01 08:46:28 +10:00
Peter Hutterer
0d140567ba dix: fix crashers with floating device.
dc57f89959 accidentally reversed the
conditions.

in dix/events.c we try to detach floating devices. This leads to a
NULL-dereference on GetMaster()->id.

in dix/getevents.c we try to get the master device for the floating slave
and dereference it.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Jeremy Huddleston <jeremyhu@apple.com>
2011-06-07 15:17:55 +10:00
Peter Hutterer
b75cdb5bf7 dix: drop x/y back into the right valuators after transformation.
If the matrix is used for rotation, the coordinates affected may change.
e.g. a valuator mask of (x, nil) becomes [x, lasty] and is rotated to
[lasty, x]. Since the second value was unset, we would not drop x back into
the mask, resulting in a loss of movement.

Thus, drop any value that changed after applying the matrix into the
valuators. Thus, the example above becomes
(x, nil) → [x, lasty] → [lasty, x] → (lasty, x)

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Simon Thum <simon.thum@gmx.de>
2011-06-03 14:43:05 +10:00
Peter Hutterer
fe4b818700 dix: don't pass x/y to transformAbsolute
We passed in the mask, but didn't do anything with it. Move the logic to
take the axes out of the valuator masks into transformAbsolute.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Simon Thum <simon.thum@gmx.de>
2011-06-03 14:43:05 +10:00
Peter Hutterer
20fb07f436 input: remove DDX event list handling
The current approach to event posting required the DDX to request the event
list (allocated by the DIX) and then pass that list into QueuePointerEvent
and friends.

Remove this step and use the DIX event list directly. This means that
QueuePointerEvent is not reentrant but it wasn't before anyway.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Jeremy Huddleston <jeremyhu@apple.com>
2011-05-11 14:27:36 +10:00
Peter Hutterer
8670c46bdf input: replace EventListPtr with InternalEvent array
EventListPtr is a relic from pre-1.6, when we had protocol events in the
event queue and thus events of varying size.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Jeremy Huddleston <jeremyhu@apple.com>
2011-05-11 14:27:36 +10:00
Peter Hutterer
e7150db535 input: Provide Queue{Button|Keyboard|Proximity}Event helpers
Don't require every caller to use GPE + mieqEnqueue, provide matching
Queue...Event functions instead.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Jeremy Huddleston <jeremyhu@apple.com>
2011-05-11 14:27:33 +10:00
Chase Douglas
65b54548dc Input: Pass co-ordinates by reference to transformAbsolute
With the upcoming XI 2.1 touch work, the co-ordinate values will need to
be passed by reference, rather than modified in-place.

Signed-off-by: Chase Douglas <chase.douglas@canonical.com>
Reviewed-by: Daniel Stone <daniel@fooishbar.org>
2011-05-03 01:46:35 +01:00
Nicolas Kaiser
86c0c8b9c5 dix: remove duplicated includes
Remove duplicated includes.

Signed-off-by: Nicolas Kaiser <nikai@nikai.net>
Reviewed-by: Matthieu Herrb <matthieu.herrb@laas.fr>
2011-04-24 19:46:06 -07:00
Peter Hutterer
071a6ac4d0 input: remove GetKeyboardValuatorEvents, this is now unnecessary.
GetKeyboardValuatorEvents handles NULL valuator masks already, so the
GetKeyboardEvents wrapper is not needed. Rename GKVE to GKE.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Jeremy Huddleston <jeremyhu@apple.com>
Reviewed-by: Daniel Stone <daniel@fooishbar.org>
2011-04-18 13:05:46 +10:00
Chase Douglas
b28a1af55c Fix unset valuator handling for XI 1.x valuator events again
Set the valuator values for unset masked absolute valuators in the
internal device event. This ensures the values will always be correct in
getValuatorEvents even if the device has been removed.

Signed-off-by: Chase Douglas <chase.douglas@canonical.com>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2011-04-07 12:45:55 +10:00
Keith Packard
0ac4931753 Merge remote-tracking branch 'ajax/xserver-next' 2011-03-14 13:06:41 -07:00
Peter Hutterer
769531b9cc Add mode field to pointer movement hooks.
Preparation work for pointer barriers.

Reviewed-by: Adam Jackson <ajax@redhat.com>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2011-03-14 13:25:14 -04:00
Adam Jackson
7b5e562ea7 input: warning fix
getevents.c:770:5: warning: suggest parentheses around '&&' within '||'

Introduced with dc57f89959e549403f8488eb9f23425bd7118b22:

-    if(dev->u.master && dev->valuator) {
+    if(dev->valuator && IsMaster(dev) || !IsFloating(dev)) {

So I'm assuming the two terms around the || are meant to be a unit.

Signed-off-by: Adam Jackson <ajax@redhat.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2011-03-09 10:53:32 +10:00
Simon Thum
a4b8526185 dix: update pointer acceleration code to use ValuatorMask
Signed-off-by: Simon Thum <simon.thum@gmx.de>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2011-03-02 14:54:03 +10:00
Peter Hutterer
dc57f89959 Switch to use IsFloating()
This is not a straightforward search/replacement due to a long-standing
issue.

dev->u.master is the same field as dev->u.lastSlave. Thus, if dev is a master
device, a check for dev->u.master may give us false positives and false
negatives.
The switch to IsFloating() spells out these cases and modifies the
conditions accordingly to cover both cases.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Benjamin Tissoires <tissoire@cena.fr>
2011-02-22 14:35:44 +10:00
Peter Hutterer
d63c979c7f dix: replace direct master access with GetMaster and temp. device.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Benjamin Tissoires <tissoire@cena.fr>
2011-02-22 14:35:44 +10:00
Peter Hutterer
0d440a1c6e dix: allow for button-only input devices (#21457)
Add a few checks for the existence of a valuator class on the device to
avoid null-pointer dereferences for button events from devices without a
valuator class.

X.Org Bug 21457 <http://bugs.freedesktop.org/show_bug.cgi?id=21457>

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Chase Douglas <chase.douglas@canonical.com>
Reviewed-by: Daniel Stone <daniel@fooishbar.org>
2010-12-10 10:57:55 +10:00
Peter Hutterer
aba8133c9c dix: clear up an overly convoluted if statement.
No functional changes, just improves readability. This statement had things
added to/removed from it for a few server releases while the input event
queue was revamped. What made sense once is now mainly confusing.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Chase Douglas <chase.douglas@canonical.com>
2010-12-09 10:03:26 +10:00
Ferry Huberts
b16964910d dix: do not use bit-wise operators on the boolean result of BitIsOn
Performing bit-wise operations on a boolean amounts to mixing types,
is confusing and basically incorrect; one should only perform
logical operations on booleans.

Performing such operations relies on the implementation detail
that a boolean is in fact an integer and that its value FALSE
is implemented as zero.

Signed-off-by: Ferry Huberts <ferry.huberts@pelagic.nl>
Reviewed-by: Matt Turner <mattst88@gmail.com>
Reviewed-by: Keith Packard <keithp@keithp.com>
Signed-off-by: Keith Packard <keithp@keithp.com>
2010-11-30 13:25:47 -08:00
Peter Hutterer
23e3d1f233 dix: remove now unnecessary !! before BitIsOn()
The macro has been changed to do this already, no need for double
not-not-ing.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Keith Packard <keithp@keithp.com>
2010-11-26 11:05:50 +10:00
Peter Hutterer
639600fa7e dix: add a fixme about a corner-case that should probably be fixed.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Jeremy Huddleston <jeremyhu@apple.com>
2010-11-24 08:47:00 +10:00
Peter Hutterer
0aca9e8424 dix: fix typo, set the second valuator with the y-axis data.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Tested-by: Jeremy Huddleston <jeremyhu@apple.com>
Reviewed-by: Jeremy Huddleston <jeremyhu@apple.com>
2010-11-24 08:47:00 +10:00
Peter Hutterer
45131bb67f dix: GetProximityEvents needs to check up to the last valuator
valuator_mask_size() returns the highest valuator set as opposed to the
number of set bits (which obviously changes as we unset valuators).

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Jeremy Huddleston <jeremyhu@apple.com>
2010-11-24 08:47:00 +10:00
Peter Hutterer
6f12934d4e dix: replace a manual valuator check with valuator_get_mode().
This check was missing the OutOfProximity mask and resulted in the wrong
bits being set in InternalEvents.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Jeremy Huddleston <jeremyhu@apple.com>
2010-11-24 08:47:00 +10:00
Simon Thum
ebe3ddaf28 dix: fix up valuators passed to acceleration code.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Simon Thum <simon.thum@gmx.de>
Reviewed-by: Chase Douglas <chase.douglas@canonical.com>
2010-11-24 08:47:00 +10:00
Chase Douglas
31737fff08 Fix transformAbsolute
transformAbsolute must use old values if valuator mask doesn't have new
ones, and it must only set new values if there was a change.

Signed-off-by: Chase Douglas <chase.douglas@canonical.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2010-11-19 11:11:04 +10:00
Chase Douglas
463841f45a Fix GPE Y axis scaling
Signed-off-by: Chase Douglas <chase.douglas@canonical.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2010-11-19 11:11:04 +10:00
Peter Hutterer
88cb61e1e5 Merge branch 'master' of git+ssh://git.freedesktop.org/git/xorg/xserver into input-api
Conflicts:
	dix/getevents.c
	hw/xfree86/common/xf86Xinput.h

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2010-11-11 12:54:46 +10:00
Peter Hutterer
58554f1c64 Convert some leftover axes->mode access to valuator_get_mode()
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Chase Douglas <chase.douglas@canonical.com>
2010-10-25 10:37:46 +10:00
Peter Hutterer
b5ef88c911 dix: clip absolute axes depending on their mode.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Chase Douglas <chase.douglas@canonical.com>
2010-10-22 16:18:59 +10:00
Peter Hutterer
ea567b675f dix: populate motion history only if the mode matches the first axis.
XI1 doesn't cater for mixed mode devices, so bail out on the first valuator
that has a different mode.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Chase Douglas <chase.douglas@canonical.com>
2010-10-22 16:18:59 +10:00
Peter Hutterer
6f6f460c24 dix: send proximity events if one or more axes are Absolute.
We only skip relative events for proximity, not absolute ones. Now with
mixed mode, just unset those axes that are relative.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Chase Douglas <chase.douglas@canonical.com>
2010-10-22 15:18:33 +10:00
Chase Douglas
65c0fc81eb Add support for per-axis valuator modes (Relative/Absolute)
The XI2 protocol supports per-axis modes, but the server so far does
not. This change adds support in the server.

A complication is the fact that XI1 does not support per-axis modes.
The solution provided here is to set a per-device mode that defines the
mode of at least the first two valuators (X and Y). Note that initializing
the first two axes to a different mode than the device mode will fail.

For XI1 events, any axes following the first two that have the same mode
will be sent to clients, up to the first axis that has a different mode.
Thus, if a device has relative, then absolute, then relative mode axes,
only the first block of relative axes will be sent over XI1.

Since the XI2 protocol supports per-axis modes, all axes are sent to the
client.

Signed-off-by: Chase Douglas <chase.douglas@canonical.com>
2010-10-22 13:37:57 +10:00
Peter Hutterer
0418a39e71 dix: get rid of the now-superfluous valuator arrays in GPE and friends.
The valuators are stored inside the mask, use it from there. are stored
inside the mask, use it from there. are stored inside the mask, use it from
there. are stored inside the mask, use it from there.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Chase Douglas <chase.douglas@canonical.com>
2010-10-22 11:02:53 +10:00
Peter Hutterer
675f4a8525 Abstract valuator masks through a set of APIs.
This commit introduces an abstraction API for handling masked valuators. The
intent is that drivers just allocate a mask, set the data and pass the mask
to the server. The actual storage type of the mask is hidden from the
drivers.

The new calls for drivers are:
    valuator_mask_new()     /* to allocate a valuator mask */
    valuator_mask_zero()    /* to reset a mask to zero */
    valuator_mask_set()     /* to set a valuator value */

The new interface to the server is
    xf86PostMotionEventM()
    xf86PostButtonEventM()
    xf86PostKeyboardEventM()
    xf86PostProximityEventM()

all taking a mask instead of the valuator array.

The ValuatorMask is currently defined for MAX_VALUATORS fixed size due to
memory allocation restrictions in SIGIO handlers.

For easier review, a lot of the code still uses separate valuator arrays.
This will be fixed in a later patch.

This patch was initially written by Chase Douglas.

Signed-off-by: Chase Douglas <chase.douglas@canonical.com>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Chase Douglas <chase.douglas@canonical.com>
2010-10-22 11:02:48 +10:00
Joe Shaw
e354ccac36 fix a sign problem with valuator data.
Without this patch, any negative valuator value is wrong when returned
from XQueryDeviceState().  This is a regression from at least xserver
1.4.

Valuator data is set in dix/getevents.c:set_valuators() by copying
signed int values into an unsigned int field
DeviceEvent.valuators.data.

That data is converted into a double with an implicit cast by
assignment to axisVal[i] in Xi/exevents.c:UpdateDeviceState().

That double is converted back to a signed int in
queryst.c:ProcXQueryDeviceState().  If the original value in
set_valuators() is negative, the double value will be > 2^31 and the
conversion back to a signed int is undefined.  (Although I
consistently see the value -2^31.)

Fix this by changing the definition of DeviceEvent.valuators.data from
uint32_t to int32_t.

Signed-off-by: Joe Shaw <joeshaw@litl.com>
Reviewed-by: Chase Douglas <chase.douglas@canonical.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2010-10-18 10:16:23 +10:00
Peter Hutterer
424b856e8e dix: update comments for GetPointerEvents and friends
All these now generate InternalEvents, point this out. Remove XKB/XI
references, that's just confusing. This comment referred to the old-style
event generation code from server 1.4 to including 1.6 but is now just
confusing to newcomers.

Remove comment about SwitchCoreKeyboard() for the same reason.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Chase Douglas <chase.douglas@canonical.com>
2010-10-18 07:59:55 +10:00
Peter Hutterer
79ea9ef399 input: constify valuators passed in by input drivers.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Keith Packard <keithp@keithp.com>
Reviewed-by: Tiago Vignatti <tiago.vignatti@nokia.com>
2010-09-06 12:44:10 +10:00