Commit Graph

58 Commits

Author SHA1 Message Date
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
Keith Packard f84703b50c dix: Reallocate touchpoint buffer at input event time [v2]
Now that input is threaded, malloc can be used at event time to resize
the touchpoint buffer as needed.x

v2: Remove "Need to grow the queue means dropping events."
    from comment as it no longer applies. (Peter Hutterer)

Signed-off-by: Keith Packard <keithp@keithp.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
2016-05-26 16:07:54 -07:00
Keith Packard 6a5a4e6037 Remove SIGIO support for input [v5]
This removes all of the SIGIO handling support used for input
throughout the X server, preparing the way for using threads for input
handling instead.

Places calling OsBlockSIGIO and OsReleaseSIGIO are marked with calls
to stub functions input_lock/input_unlock so that we don't lose this
information.

xfree86 SIGIO support is reworked to use internal versions of
OsBlockSIGIO and OsReleaseSIGIO.

v2: Don't change locking order (Peter Hutterer)
v3: Comment weird && FALSE in xf86Helper.c
    Leave errno save/restore in xf86ReadInput
    Squash with stub adding patch (Peter Hutterer)
v4: Leave UseSIGIO config parameter so that
    existing config files don't break (Peter Hutterer)
v5: Split a couple of independent patch bits out
    of kinput.c (Peter Hutterer)

Signed-off-by: Keith Packard <keithp@keithp.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
2016-05-26 16:07:54 -07:00
Jon TURNEY bcb60a49c5 debug output format fix in TouchEventHistoryPush()
xserver/build.x86_64/../dix/touch.c:468:16: error: format ‘%d’ expects argument of type ‘int’, but argument 3 has type ‘size_t’ [-Werror=format=]

%zu is C99, but is already used in a few places.  Perhaps doc/c-extensions needs
to mention it.

Signed-off-by: Jon TURNEY <jon.turney@dronecode.org.uk>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-08-28 12:07:13 +01:00
Alan Coopersmith b9e665c8b2 Convert dix/* to new *allocarray functions
v2: remove now useless parentheses

Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Reviewed-by: Matt Turner <mattst88@gmail.com>
2015-04-21 16:57:08 -07:00
Keith Packard 60014a4a98 Replace 'pointer' type with 'void *'
This lets us stop using the 'pointer' typedef in Xdefs.h as 'pointer'
is used throughout the X server for other things, and having duplicate
names generates compiler warnings.

Signed-off-by: Keith Packard <keithp@keithp.com>
Reviewed-by: Eric Anholt <eric@anholt.net>
2014-01-12 10:24:11 -08:00
Peter Hutterer 4fb686d6a6 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>
2013-07-24 11:50:00 +10:00
Peter Hutterer 35c2e263db dix: call UpdateDeviceState() for emulated TouchEndEvents
ProcessTouchEvents() calls UDS for all touch events, but if the event type
was switched to TouchUpdate(pending end) UDS is a noop.

Daniel Drake found this can cause stuck buttons if a touch grab is
activated, rejected and the touch event is passed to a regular listener.
This sequence causes the TouchEnd to be changed to TouchUpdate(pending end).

The actual TouchEnd event is later generated by the server once it is passed
to the next listener. UDS is never called for this event, thus the button
remains logically down.

A previous patch suggested for UDS to handle TouchUpdate events [1], however
this would release the button when the first TouchEvent is processed, not
when the last grab has been released (as is the case for sync pointer
grabs). A client may thus have the grab on the device, receive a ButtonPress
but see the button logically up in an XQueryPointer request.

This patch adds a call to UDS to TouchEmitTouchEnd(). The device state must
be updated once a TouchEnd event was sent to the last grabbing listener and
the number of grabs on the touchpoint is 0.

[1] http://patchwork.freedesktop.org/patch/13464/

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2013-05-15 19:17:39 +10:00
Peter Hutterer 5b00fc5227 Move TouchListenerGone call to CloseDownClient
TouchListenerGone cleans up if a client disappears. Having this in
FreeGrab() triggers cyclic removal of grabs, emitting wrong events. In
particular, it would clean up a passive grab record while that grab is
active.

Move it to CloseDownClient() instead, cleaning up before we go.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2013-05-10 14:32:38 +10:00
Peter Hutterer 34c9b39d99 dix: remove all listeners when freeing a touch
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2013-05-10 14:32:38 +10:00
Peter Hutterer 395124bd27 dix: always copy grabs, don't reference them
Introduced in xorg-server-1.13.99.901-2-g9ad0fdb. Storing the grab pointer
in the listener turns out to be a bad idea. If the grab is not an active
grab or an implicit grab, the pointer stored is the one to the grab attached
on the window. This grab may be removed if the client calls UngrabButton or
similar while the touch is still active, leaving a dangling pointer.

To avoid this, copy the grab wherever we need to reference it later. This
is also what we do for pointer/keyboard grabs, where we copy the grab as
soon as it becomes active.

Reported-by: Maarten Lankhorst <maarten.lankhorst@canonical.com>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2013-05-10 14:32:38 +10:00
Peter Hutterer 7dbf61817d dix: use a tmp variable for the to-be-removed touch listener
No functional changes.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2013-05-10 14:32:37 +10:00
Peter Hutterer a71a283934 dix: invert a loop condition
Change the single if condition in the loop body to a
    if (!foo) continue;
and re-indent the rest.

No functional changes.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2013-05-10 14:32:37 +10:00
Peter Hutterer 5174b1f982 dix: XAllowEvents() on a touch event means accepting it
A sync grab is the owner once it gets events. If it doesn't replay the
event it will get all events from this touch, equivalent to accepting it.

If the touch has ended before XAllowEvents() is called, we also now need to
send the TouchEnd event and clean-up since we won't see anything more from
this touch.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2013-05-10 14:32:36 +10:00
Peter Hutterer e7f79c48b0 dix: move EmitTouchEnd to touch.c
No functional changes, this just enables it to be re-used easier.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2013-05-10 14:32:36 +10:00
Peter Hutterer a7d989d335 Xi: use public.processInputProc to replay the touch history
If a device is frozen in results to a grab, we need to enqueue the events.

This makes things complicated, and hard to follow since touch events are now
replayed in the history, pushed into EnqueueEvent, then replayed later
during PlayReleasedEvents in response to an XAllowEvents.

While the device is frozen, no touch events are processed, so if there is a
touch client with ownership mask _below_ the grab this will delay the
delivery and potentially screw gesture recognition. However, this is the
behaviour we have already anyway if the top-most client is a sync pgrab or
there is a sync grab active on the device when the TouchBegin was generated.

(also note, such a client would only reliably work in case of ReplayPointer
anyway)

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2013-05-10 14:32:36 +10:00
Peter Hutterer 363b6387da dix: don't prepend an activated passive grab to the listeners
If the device is currently grabbed as the result of a passive grab
activating, do not prepend that grab to the listeners (unlike active grabs).
Otherwise, a client with a passive pointer grab will prevent touch grabs
from activating higher up in the window stack.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2013-05-10 14:26:15 +10:00
Maarten Lankhorst 98b94c36d6 dix: copy event in TouchConvertToPointerEvent correctly
Fixes reading random memory read beyond the end of original event.

sizeof device_event: 424
sizeof internal_event: 2800

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>
2013-04-16 07:32:42 +10:00
Peter Hutterer 11bead1fa2 dix: fix a comment
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Keith Packard <keithp@keithp.com>
2013-03-25 10:34:22 +10:00
Peter Hutterer f59499b5d0 dix: add resource type to touch listeners
Instead of guessing what resource type the listener is and what property to
retrieve, store the resource type in the listener directly.

Breaks XIT test cases:
TouchGrabTestMultipleTaps.PassiveGrabPointerEmulationMultipleTouchesFastSuccession

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

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Keith Packard <keithp@keithp.com>
Reviewed-by: Chase Douglas <chase.douglas@ubuntu.com>
2013-01-09 12:33:36 +10:00
Keith Packard 9ad0fdb135 input: Record grab pointer in TouchListener
This places a pointer to the grab related to a TouchListener directly
in the TouchListener structure rather than hoping to find the grab
later on using the resource ID.

Passive grabs have resource ID in the resource DB so they can be
removed when a client exits, and those resource IDs get copied when
activated, but implicit grabs are constructed on-the-fly and have no
resource DB entry.

Signed-off-by: Keith Packard <keithp@keithp.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2013-01-09 12:33:33 +10:00
Peter Hutterer 08da994a08 dix: add FIXME, TouchRemovePointerGrab does nothing
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2012-12-12 17:24:56 +10:00
Peter Hutterer 146f48c293 dix: don't call ProcessInputEvents() when accepting/rejecting touches
TouchListenerAcceptReject may be called during normal event processing, but
ProcessInputEvents is not reentrant and calling it here smashes the event
queue.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2012-12-12 17:24:55 +10:00
Thomas Jaeger cc79107a5b Don't use GetTouchEvents when replaying events
GetTouchEvents has plenty of side effects such as moving the pointer or
updating the master device, which we don't want to happen when
replaying.  The only reason for calling it was to generate a DCCE event,
but GetTouchEvents doesn't even do that right (we might need a DCCE
event even when replaying a master event, or clients could interpret
valuator data incorrectly).

This discussion is moot at the moment anyway, since DeliverTouchEvents
doesn't appear to deliver DCCE events.

Signed-off-by: Thomas Jaeger <ThJaeger@gmail.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>

[Added call to processInputProc instead of direct call to DeliverTouchEvents]

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2012-11-20 15:42:01 +10:00
Carlos Garnacho ced56f322e Sync TouchListener memory allocation with population in TouchSetupListeners()
The allocated TouchListener array may fall short by 1 if hitting the worst case
situation where there's an active grab, passive grabs on each window in the
sprite trace and event selection for touch in one of the windows. This may lead
to memory corruptions as the array is overflown.

Signed-off-by: Carlos Garnacho <carlosg@gnome.org>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2012-10-30 15:11:09 +10:00
Chase Douglas 3b67cd2614 End physically active touches when device is disabled
Otherwise:

* We can't end the touches while device is disabled
* New touches after enabling the device may erroneously be mapped to old
  logical touches

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-10-19 13:12:33 +10:00
Peter Hutterer a9c09f8f8e dix: fix memory leak in TouchEventHistoryReplay
Don't leak if ti->history is NULL.

Found by coverity.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Dave Airlie <airlied@redhat.com>
2012-07-04 21:16:16 +10:00
Peter Hutterer 55ff20eb37 dix: fix dereference before null check
Found by Coverity.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Dave Airlie <airlied@redhat.com>
2012-07-04 21:16:16 +10:00
Chase Douglas 7f4a69b628 Log messages in TouchBeginDDXTouch() 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 d034605f39 dix: rename shadowing loop variable in TouchResizeQueue
second 'i' shadows the function-wide one, rename to 'j'

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Chase Douglas <chase.douglas@canonical.com>
2012-06-07 13:31:41 +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
Chase Douglas 5c361d59c5 TouchListenerAcceptReject: Warn and return early on bad listener index
Signed-off-by: Chase Douglas <chase.douglas@canonical.com>
Reviewed-by: Bryce Harrington <bryce@canonical.com>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2012-05-01 11:36:35 +10:00
Chase Douglas 00cf1c40b2 Replay original touch begin event instead of generated begin event
The generated event does not have axes other than X and Y and has a
newer timestamp. In particular, the newer timestamp may be newer than
the real touch end event, which may be stuck in the syncEvents queue. If
a client uses the timestamps for grabbing bad things may happen.

Signed-off-by: Chase Douglas <chase.douglas@canonical.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
2012-04-18 20:36:02 -07:00
Chase Douglas a986f2f30c Update device state including when touch record does not exist
If a touch is physically active, the pointer core state should reflect
that the first button is pressed. Currently, this only occurs when there
are active listeners of the touch sequence. By moving the device state
updating to the beginning of touch processing we ensure it is updated
according to the processed physical state no matter what.

Signed-off-by: Chase Douglas <chase.douglas@canonical.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
2012-04-18 18:29:56 -07:00
Chase Douglas ec9c429583 Check other clients' core masks properly when adding touch listener
The current code checks the core event mask as though it were an XI
mask. This change fixes the checks so the proper client and event masks
are used.

Signed-off-by: Chase Douglas <chase.douglas@canonical.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
2012-04-18 18:29:56 -07:00
Chase Douglas d0449851d1 Create a new dix touch record for an emulated touch with no listeners
As a special case, if a still physically active pointer emulated touch
has no listeners and the device is explicitly grabbed for pointer
events, create a new dix touch record for the grab only.

This allows for clients to "hand off" grabs. For example, when dragging
a window under compiz the window decorator sees the button press and
then ungrabs the implicit grab. It then tells compiz to grab the device,
and compiz then moves the window with the pointer motion. This is racy,
but is allowed by the input protocol for pointer events when there are
no other clients with a grab on the device.

Signed-off-by: Chase Douglas <chase.douglas@canonical.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
2012-04-18 13:58:40 -07:00
Chase Douglas 3d06bfe93d Rename TouchEnsureSprite to TouchBuildSprite and event type checks
The function will be used for building a sprite for pointer emulation
after an explicit device grab. This commit refactors the code so that
TouchBuildSprite will function with any event type and moves the checks
to the caller.

Signed-off-by: Chase Douglas <chase.douglas@canonical.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
2012-04-18 13:58:40 -07:00
Chase Douglas 447fe7a1a7 Split out helper function TouchListenerAcceptReject()
This will be used for accepting and rejecting touches in the future.

Signed-off-by: Chase Douglas <chase.douglas@canonical.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
2012-04-18 13:58:39 -07:00
Chase Douglas 31df08a449 Use a new sprite trace for indirect touches when all touches have physically ended
All touches of an indirect device, such as a trackpad, are sent to the
same window set. When there are no active touches, a new window set is
created; otherwise, the window set of an existing touch is copied.

The current code checks for any logically active touches. This includes
touches that have physically ended but are still logically active due to
unhandled touch grabs. Instead, we want a new window set whenever there
are no physically active touches.

This change skips over logically active but pending end touches, which
are touches that have physically ended.

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-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
Chase Douglas 6241b5e4fd Implement touch early accept
This doesn't really implement early accept as it should. Ideally, the
server should send end events to all subsequent touch clients as soon as
an early accept comes in. However, this implementation is still protocol
compliant. We can always improve it later.

Signed-off-by: Chase Douglas <chase.douglas@canonical.com>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
2012-02-08 18:04:15 +10:00
Chase Douglas b0c54856df Implement early touch reject
Signed-off-by: Chase Douglas <chase.douglas@canonical.com>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
2012-02-08 18:04:15 +10:00
Chase Douglas 656ab879f2 Check for proper window ID when processing touch allow requests
Signed-off-by: Chase Douglas <chase.douglas@canonical.com>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
2012-02-08 18:04:15 +10:00
Chase Douglas 9a260e9af8 Move AllowTouch to dix/touch.c, and rename to TouchAcceptReject
Signed-off-by: Chase Douglas <chase.douglas@canonical.com>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
2012-02-08 18:04:15 +10:00
Chase Douglas ab60cadc2a Store window pointer in touch listener record
Signed-off-by: Chase Douglas <chase.douglas@canonical.com>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
2012-02-08 18:04:14 +10:00
Daniel Stone 3b1e2035cc dix: Remove touch grabs if the grab disappears
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Chase Douglas <chase.douglas@canonical.com>
2011-12-21 14:16:36 +10:00
Peter Hutterer cd3de8324e dix: hook up passive grabs and pointer emulated passive grabs
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Chase Douglas <chase.douglas@canonical.com>
2011-12-21 14:16:36 +10:00
Peter Hutterer 753c4dca1e dix: add touch to pointer event conversion helper
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Chase Douglas <chase.douglas@canonical.com>
2011-12-21 12:38:36 +10:00
Peter Hutterer e389a19a73 Process and deliver touch events
Does not include pointer emulation handling.
Does include partial ownership handling but not the actual processing of
ownership events.

Note: this commit is a retroactive commit extracted from a series of ~50
commits and may thus appear a bit more complicated than what you'd write out
from scratch.

Pointer processing tree is roughly:
- ProcessOtherEvents
  - ProcessTouchEvents
    - DeliverTouchEvents
      - DeliverTouchBeginEvent|DeliverTouchEndEvent|...
        - DeliverOneTouchEvent

Also hooks up the event history playing to the right function now.

Co-authored-by: Daniel Stone <daniel@fooishbar.org>
Co-authored-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>
Reviewed-by: Chase Douglas <chase.douglas@canonical.com>
2011-12-21 12:38:35 +10:00
Peter Hutterer 593c3e2eb3 dix: add TouchResourceIsOwner helper function
The first listener in the sequence is the owner of the touch sequence.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Chase Douglas <chase.douglas@canonical.com>
2011-12-21 12:38:35 +10:00