Commit Graph

365 Commits

Author SHA1 Message Date
Povilas Kanapickas 100a2ad6da dix: Implement gesture event submission code path 2021-05-30 13:26:40 +03:00
Olivier Fourdan b5e1f13681 dix: Add POINTER_RAWONLY flag
This add a new flag POINTER_RAWONLY for GetPointerEvents() which does
pretty much the opposite of POINTER_NORAW.

Basically, this tells GetPointerEvents() that we only want the
DeviceChanged events and any raw events for this motion but no actual
motion events.

This is preliminary work for Xwayland to be able to use relative motion
events for raw events. Xwayland would use absolute events for raw
events, but some X11 clients (wrongly) assume raw events to be always
relative.

To allow such clients to work with Xwayland, it needs to switch to
relative raw events (if those are available from the Wayland
compositor).

However, Xwayland cannot use relative motion events for actual pointer
location because that would cause a drift over time, the pointer being
actually controlled by the Wayland compositor.

So Xwayland needs to be able to send only relative raw events, hence
this API.

Bump the ABI_XINPUT_VERSION minor version to reflect that API addition.

v2: Actually avoid sending motion events (Peter)
v3: Keep sending raw emulated events with RAWONLY (Peter)

Suggested-by: Peter Hutterer <peter.hutterer@who-t.net>
Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
Related: https://gitlab.freedesktop.org/xorg/xserver/-/issues/1130
2021-02-15 09:42:00 +01:00
Alan Coopersmith 23e83724df Fix spelling/wording issues
Most (but not all) of these were found by using
  codespell --builtin clear,rare,usage,informal,code,names
but not everything reported by that was fixed.

Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
2020-07-05 13:07:33 -07:00
Adam Jackson e0e051a392 dtrace: s/#if/#ifdef/ for XSERVER_DTRACE
No functional change, matches meson style.
2019-08-27 17:38:59 -04:00
Peter Hutterer d7b1753d44 dix: leave last.valuators alone on slave switch
Terms:
dev->last.valuator[] is the last value given to us by the driver
dev->valuator.axisVal[] is the last value sent to the client
dev->last.scroll[] is the abs value of the scroll axis as given by the driver,
        used for button emulation calculation (and the remainder)

This function updates the device's last.valuator state based on the current
master axis state. This way, relative motion continues fluidly when switching
between devices. Before mouse 2 comes into effect, it's valuator state is
updated to wherever the pointer currently is so the relative event applies on
top of that.

This can only work for x/y axes, all other axes aren't guaranteed to have the
same meaning and/or may not be present:
- xtest device: no valuator 2
- mouse: valuator 2 is horizontal scroll axis
- tablet: valuator 2 is pressure

Scaling the current value from the pressure range into the range for
horizontal scrolling makes no sense. And it causes scroll jumps:

- scroll down, last.valuator == axisVal == 20
- xdotool click 1, the XTest device doesn't have that valuator
- scroll up
  - updateSlaveDeviceCoords reset last.valuator to 0 (axisVal == 20)
  - DeviceClassesChangedEvent includes value 20 for the axis
  - event is processed, last.value changes from 0 to -1
  - axisVal is updated to -1, causing a jump of -21

The same applies when we switch from tablet to mouse wheel if the pressure
value is 0 on proximity out (basically guaranteed). So let's drop this code
altogether and only leave the scaling for the relative x/y motion.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2019-03-29 03:44:29 +00:00
Adam Jackson 6f0903ddc9 dix: Hush an almost certainly bogus warning
../dix/getevents.c: In function ‘transformAbsolute’:
../dix/getevents.c:1195:28: warning: ‘oy’ may be used uninitialized in this function [-Wmaybe-uninitialized]
     struct pixman_f_vector p = {.v = {*x, *y, 1} };
                            ^
../dix/getevents.c🔢22: note: ‘oy’ was declared here
     double x, y, ox, oy;
                      ^~

This one is truly special. Even though both ox and oy are set and read
along the same paths, only oy is marked for this warning! Initializing
just oy = 0.0 fixes it entirely, but let's not make a weird thing
weirder.

Signed-off-by: Adam Jackson <ajax@redhat.com>
Acked-by: Keith Packard <keithp@keithp.com>
2018-04-05 14:18:52 -04:00
Rui Matos 5611585b87 xwayland: Don't send KeyRelease events on wl_keyboard::leave
Commits 816015648f and
fee0827a9a made it so that
wl_keyboard::enter doesn't result in X clients getting KeyPress events
while still updating our internal xkb state to be in sync with the
host compositor.

wl_keyboard::leave needs to be handled in the same way as its
semantics from an X client POV should be the same as an X grab getting
triggered, i.e. X clients shouldn't get KeyRelease events for keys
that are still down at that point.

This patch uses LeaveNotify for these events on wl_keyboard::leave and
changes the current use of KeymapNotify to EnterNotify instead just to
keep some symmetry between both cases.

On ProcessDeviceEvent() we still need to deactivate X grabs if needed
for KeyReleases.

Signed-off-by: Rui Matos <tiagomatos@gmail.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2016-11-29 18:44:54 +10:00
Daniel Stone 816015648f Input: Add focus-in event source
Add a new event source type for keypress events synthesised from focus
notifications (e.g. KeymapNotify from the parent server, when running
nested). This is used to keep the keys-down array in sync with the host
server's, without sending actual keypress events to clients.

Signed-off-by: Daniel Stone <daniels@collabora.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-11-24 11:36:34 +10:00
Daniel Stone c3788394e9 Input: Add DeviceEventSource enum
Add a flag to DeviceEvents, giving the source of the event. Currently
this only supports a 'normal' flag, but will be used later to add a
'focus-in' flag, noting events synthesised from key/button arrays on
focus-in notifications.

Signed-off-by: Daniel Stone <daniels@collabora.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-11-24 11:36:32 +10:00
Peter Hutterer 1e95a7df5f dix: put warning in for scroll increments of 0
If the increment is 0 but this is a scroll axis, it's definitely a bug.
Nonetheless, it has happened, so put a warning in and a return statement
that we avoid the infinite loop and hopefully be able to reproduce later.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Keith Packard <keithp@keithp.com>
2015-09-23 10:51:45 -04:00
Peter Hutterer da10d0cb42 dix: hook up the unaccelerated valuator masks
If present, access the unaccelerated valuator mask values for DGA and XI2 raw
events.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
2015-05-20 12:44:58 +10:00
Peter Hutterer f485a1af64 Drop valuator mask argument from GetKeyboardEvents
Nothing was using it and if anyone had they would've gotten a warning and
noticed that it doesn't actually work. Drop this, it has been unused for years.

Input ABI 22

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Daniel Stone <daniel@fooishbar.org>
2015-03-13 12:31:21 +10:00
Alan Coopersmith 9e002dfcd7 Get rid of const warnings in XSERVER_INPUT_EVENT dtrace probe calls
Use typedefs to work around dtrace dropping const qualifiers from probe
arguments when generating Xserver-dtrace.h.   Add new probes.h header to
avoid having to replicate these typedefs in every file with dtrace probes.

Gets rid of these warnings from gcc 4.8:
 getevents.c:1096:9:
  warning: passing argument 6 of '__dtrace_Xserver___input__event' discards
  'const' qualifier from pointer target type [enabled by default]
 getevents.c:1096:9:
  warning: passing argument 7 of '__dtrace_Xserver___input__event' disards
  'const' qualifier from pointer target type [enabled by default]
 getevents.c:1651:9:
  warning: passing argument 6 of '__dtrace_Xserver___input__event' disards
  'const' qualifier from pointer target type [enabled by default]
 getevents.c:1651:9:
  warning: passing argument 7 of '__dtrace_Xserver___input__event' disards
  'const' qualifier from pointer target type [enabled by default]
 getevents.c:1791:9:
  warning: passing argument 6 of '__dtrace_Xserver___input__event' disards
  'const' qualifier from pointer target type [enabled by default]
 getevents.c:1791:9:
  warning: passing argument 7 of '__dtrace_Xserver___input__event' disards
  'const' qualifier from pointer target type [enabled by default]
 getevents.c:1921:9:
  warning: passing argument 6 of '__dtrace_Xserver___input__event' disards
  'const' qualifier from pointer target type [enabled by default]
 getevents.c:1921:9:
  warning: passing argument 7 of '__dtrace_Xserver___input__event' disards
  'const' qualifier from pointer target type [enabled by default]

Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-02-10 18:14:44 -08:00
Peter Hutterer ee21be1324 dix: offset touch root coordinates by ScreenRec origins (#86655)
For two ScreenRecs abs pointer positioning was working fine, but touch events
stuck to the lower/right edge on any screen but the one with a 0/0 origin.
Cause is a missing offset by the screen coordinates, causing the root
coordinates in the event to desktop-wide, not screen-wide.

Offset properly, just like we do for pointer events.

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

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-01-05 09:53:47 +10:00
Keith Packard 65dd1ba7b3 dix: Untwist transformAbsolute logic, eliminate uninitialized value warnings
tranformAbsolute has a pretty simple job, that of running the X/Y
values from a device through the transformation matrix. The tricky bit
comes when the current device state doesn't include one of the
values. In that case, the last delivered value is back-converted to
device space and used instead.

The logic was twisted though, confusing GCC's uninitialized value
detection logic and emitting warnings.

This has been fixed by changing the code to:

 1) Detect whether the ValuatorMask includes X/Y values
 2) If either are missing, back-convert the current values into ox/oy
 3) When X/Y are present, set ox/oy to the current value
 4) Transform
 5) Store X/Y values if changed or if they were set before.

Signed-off-by: Keith Packard <keithp@keithp.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
2014-10-28 20:56:37 -07:00
Peter Hutterer 9a19bf06b5 Revert "dix: fix up coordinate scaling when external monitors are present"
This reverts commit d90b5f8301.

Reverting for two reasons:
* the scaling does not work on devices that don't advertise resolution, and
  the default resolution used (100 units/mm) is higher than most devices,
  resulting in a significant slowdown of the touchpads.
* the scaling is still affected by resolution changing. The patch worked
  before acceleration but since it maps into resolution-dependent dx/dy
  coordinates the acceleration may distort the movement after the fact. So the
  same input data generates different movements depending on the resolution.
  This can't easily be fixed for all affected devices as synaptics has its own
  velocity calculation method whereas wacom doesn't. So anything in the server
  won't work for both at the same time.

Revert this for now, until a more integrated solution can be implemented.
2014-07-14 15:05:58 +10:00
Peter Hutterer d90b5f8301 dix: fix up coordinate scaling when external monitors are present
The goal of all this is to get an x/y motion reflecting the motion
on the device, i.e. a circle on the device is a circle on the screen.

This is currently done by scaling the y coordinate depending on the screen
ratio vs device ratio. Depending on that ratio the movement on the y axis may
be accelerated (ratio < 1) or slowed (ratio > 1). This leads to the weird
effect that changing the screen ratio by plugging a new monitor changes the
speed of the touchpad.

Use a different algorithm: calculate the physical movement on the device, map
that to the same-ish distance on the screen, then convert that back into a
device-specific vector. This way we get the same mapping regardless of the
current screen dimensions.

Since the pointer accel code doesn't take device resolution into account, make
sure we apply our crazy mapping before we accelerate. This way we accelerate
resolution-independent.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
2014-06-23 11:04:55 +10:00
Peter Hutterer 87ca80a719 dix: prevent a driver from initializing or submitting buttons > MAX_BUTTONS
The server internally relies on arrays with a MAX_BUTTONS maximum size (which
is the max the core protocol can transport). Make sure a driver adheres to
that.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Daniel Stone <daniel@fooishbar.org>
2014-02-04 11:38:00 +10:00
Keith Packard d89b42bda4 Clean up warnings in DIX
As usual, mostly const char changes. However, filter_device_events had
a potentially uninitialized value, 'raw', which I added a bunch of
checks for. I suspect most of those are 'can't happen', but it's hard
to see that inside the function.

Signed-off-by: Keith Packard <keithp@keithp.com>
Reviewed-by: Adam Jackson <ajax@redhat.com>
2014-01-12 10:14:49 -08:00
Peter Hutterer 3d87566310 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 b28a1af55c, 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 b28a1af55c, data in valuators is always
absolute, regardless of the mode.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2013-07-25 12:57:41 +10:00
Peter Hutterer 21ea7ebb6a dix: scale y back instead of x up when pre-scaling coordinates
The peculiar way we handle coordinates results in relative coordinates on
absolute devices being added to the last value, then that value is mapped to
the screen (taking the device dimensions into account). From that mapped
value we get the final coordinates, both screen and device coordinates.

To avoid uneven scaling on relative coordinates, they are pre-scaled by
screen ratio:resolution:device ratio factor before being mapped. This
ensures that a circle drawn on the device is a circle on the screen.

Previously, we used the ratio to scale x up. Synaptics already does its own
scaling based on the resolution and that is done by scaling y down by the
ratio. So we can remove the code from the driver and get approximately the
same behaviour here.

Minor ABI bump, so we can remove this from synaptics.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Tested-by: Emmanuel Benisty <benisty.e@gmail.com>
2013-07-22 14:18:30 +10:00
Peter Hutterer 756ab88d93 dix: fix device scaling to use a [min,max[ range.
defmin/defmax are screen coords and thus use a min-inclusive, max-exclusive
range. device axes ranges are inclusive, so bump the max up by one to get the
scaling right.

This fixes off-by-one coordinate errors if the coordinate matrix is used to
bind the device to a fraction of the screen. It introduces an off-by-one
scaling error in the device coordinate range, but since most devices have a
higher resolution than the screen (e.g. a Wacom I4 has 5080 dpi) the effect
of this should be limited.

This error manifests when we have numScreens > 1, as the scaling from
desktop size back to screen size drops one device unit.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2013-05-23 15:35:05 +10:00
Peter Hutterer 5cc2c96f82 dix: pre-scale x by the screen:device:resolution ratio
commit 61a99aff9d
    dix: pre-scale relative events from abs devices to desktop ratio (#31636)

added pre-scaling of relative coordinates coming from absolute devices to
undo uneven scaling based on the screen dimensions.

Devices have their own device width/height ratio as well (in a specific
resolution) and this must be applied for relative devices as well to avoid
scaling of the relative events into the device's ratio.

e.g. a Wacom Intuos4 6x9 is in 16:10 format with equal horiz/vert
resolution (dpi). A movement by 1000/1000 coordinates is a perfect diagonal
on the tablet and must be reflected as such on the screen.

However, we map the relative device-coordinate events to absolute screen
coordinates based on the axis ranges. This results in an effective scaling
of 1000/(1000 * 1.6) and thus an uneven x/y axis movement - the y
axis is always faster.

So we need to pre-scale not only by the desktop dimenstions but also by the
device width/height ratio _and_ the resolution ratio.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2013-05-23 15:35:05 +10:00
Peter Hutterer 23d1bc69f3 dix: send the current axis value in DeviceChangedEvents (#62321)
X.Org Bug 62321 <http://bugs.freedesktop.org/show_bug.cgi?id=62321>

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Keith Packard <keithp@keithp.com>
2013-05-07 09:40:42 +10:00
Peter Hutterer b58221f9da dix: support the transformation matrix for relative devices.
The transformation matrix we previously stored was a scaled matrix based on
the axis ranges of the device. For relative movements, the scaling is not
required (or desired).

Store two separate matrices, one as requested by the client, one as the
product of [scale . matrix . inv_scale]. Depending on the type of movement,
apply the respective matrix.

For relative movements, also drop the translation component since it doesn't
really make sense to use that bit.

Input ABI 19

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Keith Packard <keithp@keithp.com>
Signed-off-by: Keith Packard <keithp@keithp.com>
2013-02-08 09:02:57 -08:00
Peter Hutterer 0d5bb88260 Merge branch 'ptraccel-fixes' into for-keith 2013-02-08 14:10:52 +10:00
Peter Hutterer 61a99aff9d dix: pre-scale relative events from abs devices to desktop ratio (#31636)
Absolute devices may send relative events depending on the mode (synaptics
by default, wacom per option). The relative events are added to the previous
position, converted into device coordinates and then scaled into desktop
coordinates for pointer movement.

Because the device range must be mapped into the desktop coordinate range,
this results in uneven scaling depending dimensions, e.g. on a setup with
width == 2 * height, a relative movement of 10/10 in device coordinates
results in a cursor movement of 20/10 (+ acceleration)

Other commonly user-visible results:
* the touchpad changing acceleration once an external monitor as added.
* drawing a circle on a wacom tablet in relative mode gives an ellipsis in
  the same ratio as the desktop dimensions.

Solution: pre-scale the incoming relative x/y coordinates by width/height
ratio of the total desktop size. Then add them to the previous
coordinates and scale back with the previous mapping, which will undo the
pre-scaling and give us the right movement.

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

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Keith Packard <keithp@keithp.com>
2013-02-08 14:00:57 +10:00
Peter Hutterer 8571c648a7 Xext: if a root window is given in XTestFakeInput, move to that
For absolute events, if the client specifies a screen number offset the
coordinates by that. And add a new flag so we know when _not_ to add the
screen offset in GPE.

Without this offset and the flag, GPE would simply add the offset of the
current screen if POINTER_SCREEN is set.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Keith Packard <keithp@keithp.com>
2013-02-08 13:49:49 +10:00
Sybren van Elderen a191dbfe85 dix: when scaling from desktop coord, take the total desktop size (#51904)
Scaled is already in desktop coordinates, take the total width into account,
not just the current screen's width.

Fixes Xdmx pointer position calculation.

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

Signed-off-by: Sybren van Elderen <sowmestno@msn.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2013-02-08 13:47:24 +10:00
Benjamin Tissoires 05ed095dd8 dix: fix error logging occuring in signal context of GetTouchEvents
GetTouchEvents is usually called in a signal context.
Calling ErrorF for the error messages leads to X complaining about log:

(EE) BUG: triggered 'if (inSignalContext)'
(EE) BUG: log.c:484 in LogVMessageVerb()
(EE) Warning: attempting to log data in a signal unsafe manner while in signal context.
Please update to check inSignalContext and/or use LogMessageVerbSigSafe() or ErrorFSigSafe().
The offending log format message is:
%s: Attempted to start touch without x/y (driver bug)

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2013-01-11 14:57:48 +10:00
Peter Hutterer 21a15f9a04 Pass the event list through to the pointer barrier code to return it
Instead of having the pointer barrier code enqueue events separately from
GetPointerEvents, pass the event list through and let it add to it.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Jasper St. Pierre <jstpierre@mecheye.net>
2012-12-17 15:03:12 +10:00
Yuly Novikov 3b9f1c7017 dix: Save touchpoint last coordinates before transform. #49347
DDXTouchPointInfoRec.valuators used to store axis values after transform.
This resulted in Coordinate Transformation Matrix
being applied multiple times to the last coordinates,
in the case when only pressure changes in the last touch event.

Changed DDXTouchPointInfoRec.valuators to store values before transform.

Fixes: https://bugs.freedesktop.org/show_bug.cgi?id=49347

Signed-off-by: Yuly Novikov <ynovikov@chromium.org>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2012-11-20 16:06:06 +10:00
Thomas Jaeger d0fd592fc7 Simplify GetTouchEvents
With only one callee left, we are free to assume that
!(flags & TOUCH_CLIENT_ID)

Signed-off-by: Thomas Jaeger <ThJaeger@gmail.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2012-11-20 15:42:46 +10:00
Thomas Jaeger fe59774c55 Don't use GetTouchEvents in EmitTouchEnd
As before GetTouchEvents causes unwanted side effects.  Add a new
function GetDixTouchEnd, which generates a touch event from the touch
point.  We fill in the event's screen coordinates from the MD's current
sprite position.

Signed-off-by: Thomas Jaeger <ThJaeger@gmail.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2012-11-20 15:42:46 +10:00
Thomas Jaeger 90b177e5cb Update the MD's position when a touch event is received
Signed-off-by: Thomas Jaeger <ThJaeger@gmail.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2012-11-20 15:14:43 +10:00
Thomas Jaeger aa9da5eae1 remove init_event
The function is identical to init_device_event from inpututils.c with
the first two arguments swapped.

Signed-off-by: Thomas Jaeger <ThJaeger@gmail.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2012-11-19 12:12:28 +10:00
Peter Hutterer e7cd5cce74 dix: fix zaphod screen scrossing (#54654)
POINTER_SCREEN coordinates are screen-relative. For a Zaphod setup, the
coordinates after a screen crossing are already relative to the new screen's
origin. Add that offset to the coordinates before re-setting.

regression introduced by
commit bafbd99080
Author: Peter Hutterer <peter.hutterer@who-t.net>
Date:   Wed Aug 8 11:34:32 2012 +1000

    dix: work around scaling issues during WarpPointer (#53037)

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

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Keith Packard <keithp@keithp.com>
2012-10-29 13:15:50 +10:00
Yufeng Shen 0b02150c27 dix: fix scale_to_desktop for edge ABS events
Scale_to_desktop() converts ABS events from device coordinates
to screen coordinates:
[dev_X_min, dev_X_max]  -> [screen_X_min, screen_X_max]
[dev_Y_min, dev_Y_max]  -> [screen_Y_min, screen_Y_max]

An edge ABS event with X = dev_X_max (e.g., generated from the
edge of a touchscreen) will be converted to have screen X value
= screen_X_max, which, however, will be filterd out when xserver
tries to find proper Window to receive the event, because the
range check for a Window to receive events is
       window_X_min <= event_screen_X < window_X_max
Events with event_screen_X = screen_X_max will fail the test get
and rejected by the Window.

To fix this, we change the device to screen coordinates mapping to
[dev_X_min, dev_X_max]  -> [screen_X_min, screen_X_max-1]
[dev_Y_min, dev_Y_max]  -> [screen_Y_min, screen_Y_max-1]

Reviewed-by: Chase Douglas <chase.douglas@canonical.com>
Reviewed-by: Jeremy Huddleston Sequoia <jeremyhu@apple.com>
Signed-off-by: Yufeng Shen <miletus@chromium.org>
Signed-off-by: Keith Packard <keithp@keithp.com>
2012-09-24 11:12:04 -07:00
Peter Hutterer bafbd99080 dix: work around scaling issues during WarpPointer (#53037)
In WarpPointer calls, we get input in screen coordinates. They must be
scaled to device coordinates, and then back to screen coordinates for screen
crossing and root coordinates in events.

The rounding errors introduced (and clipping in core/XI 1.x events) can lead
to the actual position being different to the requested input coordinates.
e.g. 200 scales to 199.9999, truncated to 199 in the event.

Avoid this by simply overwriting the scaled screen coordinates with the
input coordinates for the POINTER_SCREEN case.

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

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Keith Packard <keithp@keithp.com>
2012-08-21 07:54:07 +10:00
Peter Hutterer cb306a8f17 dix: make sure the mask is set for emulated scroll events (#52508)
If a device has smooth scrolling axes, but submits scroll button events, we
convert those to motion events and update the valuators. For legacy button
events, the valuator mask is likely unset though, causing
add_to_scroll_valuator() to return early, leaving us with an empty mask.
That again skipped the rest of the code and no events were generated.

Fix it by making sure that the scroll valuator in the mask is at least
initialized to 0.

Broke evdev wheel emulation, introduced by
54476b5e44.

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

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Chase Douglas <chase.douglas@canonical.com>
2012-08-07 09:39:56 +10:00
Keith Packard 24525d96a3 Merge branch 'sigsafe-logging-varargs'
This merge includes a minor fixup for '%p' arguments; must cast to
uintptr_t instead of uint64_t as we use -Werror=pointer-to-int-cast
which complains when doing a cast (even explicitly) from a pointer
to an integer of different size.
2012-07-02 22:35:39 -07:00
Chase Douglas f752226e40 Log messages in GetTouchEvents() in a signal safe manner
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-07-02 22:34:32 -07:00
Peter Hutterer 54476b5e44 dix: if the scroll valuator reaches INT_MAX, reset to 0
Too much scrolling down may eventually trigger an overflow of the valuator.
If this happens, reset the valuator to 0 and skip this event for button
emulation. Clients will have to figure out a way to deal with this, but a
scroll event from (close to) INT_MAX to 0 is a hint of that it needs to be
ignored.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Chase Douglas <chase.douglas@canonical.com>
2012-06-20 10:36:11 +10:00
Peter Hutterer 642569fc79 Replace a few BUG_WARN with BUG_RETURN_VAL
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Chase Douglas <chase.douglas@canonical.com>
2012-06-07 13:30:54 +10:00
Michal Suchanek 88c767edb0 Fix crash for motion events from devices without valuators
A WarpPointer request may trigger a motion event on a device without
valuators. That request is ignored by GetPointerEvents but during smooth
scroll emulation we dereference dev->valuators to get the number of axes.

Break out early if the device doesn't have valuators.

Signed-off-by: Michal Suchanek <hramrach@gmail.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2012-06-04 11:28:44 +10:00
Peter Hutterer 749a593e49 dix: undo transformation for missing valuators (#49347)
last.valuators contains the transformed valuators of the device. If the
device submits events with x/y missing, we need to get that from
last.valuators and undo the transformation to that axis.

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

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Chase Douglas <chase.douglas@canonical.com>
2012-05-16 10:59:39 +10:00
Peter Hutterer af88b43f9e dix: don't emulate scroll events for non-existing axes (#47281)
Test case:
- create a device with REL_HWHEEL and ABS_X and ABS_Y. evdev 2.7.0 will set
  that up as device with 1 relative axis
- move pointer to VGA1
- xrandr --output VGA1 --off

Warps the pointer to the new spot and calls GPE with the x/y mask bits set.
When running through the loop to check for scroll event, this overruns the
axes and may try to emulate scroll events based on random garbage in the
memory. If that memory contained non-zero for the scroll type but near-zero
for the increment field, the server would hang in an infinite loop.

This was the trigger for this suggested, never-merged, patch here:
http://patchwork.freedesktop.org/patch/9543/

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

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Chase Douglas <chase.douglas@canonical.com>
2012-05-01 11:36:35 +10:00
Daniel Kurtz c5a45b0f76 dix: don't BUG_WARN for button events from button-only device
Events from button-only devices still need coordinates, and they get them
from scale_to_desktop().  Therefore, a dev without valuators is not a bug.
However, a dev with valuators, but less than two of them still is a bug.

This was noticed when unplugging a "Creative Technology SB Arena Headset",
which has some BTNs and some KEYs, but no REL or ABS valuators.
It emits [BTN_3] = 0 on unplug, which would trigger the BUG_WARN.

Signed-off-by: Daniel Kurtz <djkurtz@chromium.org>
Reviewed-by: Chase Douglas <chase.douglas@canonical.com>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2012-04-12 10:11:10 +10:00
Peter Hutterer bf876c87a9 Merge branch 'dtrace-input-abi' into for-keith 2012-03-22 11:34:43 +10:00
Peter Hutterer c0b0a9bce9 dix: add dtrace probes to input API
For driver debugging, it is helpful to know whether the driver has actually
submitted an event to the server. dtrace hooks can help here.

Note that GetPointerEvents and friends may also be triggered by the server
for other emulated devices, some care must be taken when analysing the
results.

Additional difficulty: proximity events have a run-time assigned type, so
this may make automatic detection a tad harder. If in doubt, go for any
event > 64 since the only two that can have that value are ProximityIn and
ProximityOut.

An example systemtap script is below:

  # Compile+run with
  #       stap -g xorg.stp /usr/bin/Xorg
  #

  function print_valuators:string(nvaluators:long, mask_in:long, valuators_in:long) %{
          int i;
          unsigned char *mask = (unsigned char*)THIS->mask_in;
          double *valuators = (double*)THIS->valuators_in;
          char str[128] = {0};
          char *s = str;

  #define BitIsSet(ptr, bit) (((unsigned char*)(ptr))[(bit)>>3] & (1 << ((bit) & 7)))

          s += sprintf(s, "nval: %d ::", (int)THIS->nvaluators);
          for (i = 0; i < THIS->nvaluators; i++)
          {
                  s += sprintf(s, "	%d: ", i);
                  if (BitIsSet(mask, i))
                      s += sprintf(s, "%d", (int)valuators[i]);
          }

          sprintf(THIS->__retvalue, "%s", str);
  %}

  probe process(@1).mark("input__event")
  {
      deviceid = $arg1
      type = $arg2
      detail = $arg3
      flags = $arg4
      nvaluators = $arg5

      str = print_valuators(nvaluators, $arg6, $arg7)
      printf("Event: device %d type %d detail %d flags %#x %s\n",
              deviceid, type, detail, flags, str);
  }

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Acked-by: Jeremy Huddleston <jeremyhu@apple.com>
2012-03-22 11:33:42 +10:00