Commit Graph

879 Commits

Author SHA1 Message Date
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 192b2c9a2e Export TouchEventRejected as TouchRejected
This function is mostly correct for early reject usage. With a small
change to pass the client resource explicitly and making the
TouchOwnership event optional, it is usable for all rejection scenarios.
This change exports it for use outside Xi/exevents.c and modifies the
name accordingly.

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 19073425e5 Factor out TouchEnd generation and delivery
The server often needs to generate and deliver TouchEnd events for
circumstances including touch grab acceptance and rejection. This change
refactors the code so it can be used more easily.

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
Keith Packard e476af417d Merge remote-tracking branch 'whot/multitouch' 2012-01-09 13:17:37 -08:00
Peter Hutterer ed8f3c4bd1 Xi: change XIChangeDeviceProperty from const pointer to const void *
According to Daniel Kurtz, a typedef void *pointer is a atomic type. So a
'const pointer' is equivalent to 'void* const' instead of the intended
'const void*'.

This technically changes the ABI, but we don't bump it for this.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Chase Douglas <chase.douglas@canonical.com>
2012-01-06 14:04:45 +10:00
Chase Douglas 146008358e Remove last listener on touch reject
The current code short-circuits around the block that removes the
rejecting listener if it is the only listener left. It also does not
delete the touchpoint record if the touch has not physically ended.

This change ensures the listener is removed under these circumstances.

Signed-off-by: Chase Douglas <chase.douglas@ubuntu.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2012-01-06 14:03:11 +10:00
Chase Douglas e30c3c5c59 Don't end touchpoint if owning client hasn't accepted/rejected
A touchpoint is ended when no further processing will take place for it.
This includes the situation where there is only one grabbing client, and
the client receives a touch end before it has accepted/rejected the
touchpoint.

This change ensures that a delivered touch end event is converted into a
touch update event under the above scenario. If the event is left as a
touch end event, the touchpoint will be ended in ProcessTouchEvent().

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-06 14:03:07 +10:00
Peter Hutterer 2bb282cd45 Xi: only activate the device grab if we don't already have one
If the device is already grabbed, don't activate the passive grab, it screws
with our event masks. Just deliver to the grabbing client instead.

Reported-by: Carlos Garnacho <carlosg@gnome.org>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Chase Douglas <chase.douglas@canonical.com>
2011-12-21 15:20:38 +10:00
Carlos Garnacho 5b169cb695 Xi: assign correct grab_mode/other_device_mode in XI2 passive grabs
CreateGrab() expects the keyboard mode to be stored in grab_mode, and the
pointer mode in other_device_mode, so respect this in passive XI2 grabs,
and switch modes if needed.

Signed-off-by: Carlos Garnacho <carlosg@gnome.org>
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 4469430b10 Xi: add the hooks for passive touch grabs
Co-authored-by: Daniel Stone <daniel@fooishbar.org>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Chase Douglas <chase.douglas@canonical.com>
2011-12-21 14:16:33 +10:00
Peter Hutterer bb0af002dc Xi: handle grab accept/reject requests
Consists mostly of generating an ownership event and processing it.

Co-authored-by: Daniel Stone <daniel@fooishbar.org>
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 209b3d613a Xi: hook up touch ownership handling
Ownership changes don't get processed directly when they happen, instead the
DIX submits an ownership event which goes through ProcessTouchEvents and
ProcessTouchOwnershipEvents.
Then on the required events are generated and sent to clients.

Co-authored-by: Daniel Stone <daniel@fooishbar.org>
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:36 +10:00
Peter Hutterer 1894468c2b Xi: hook up pointer emulation for emulating touches
Includes a hack for implicit grab activation, because integrating this
requires a larger rewrite and I'm not sleeping enough as it is.
Right now, we deliver the event and check before/after if there is an
implicit grab on. If one activated, then store the event in the grab and
switch the listener type to a grab listener.

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: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 dbfd7b37a0 Xi: make UpdateDeviceState aware of touch events
Update the logical button state for pointer-emulating events. Button state
must be kept separate from the ButtonClassRec to avoid clearing the button
state on a touch end if there is a physical button still down.

And obviously don't change the button state if we're currently replaying the
event history for some client.

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
Daniel Stone 8e58ce73c8 dix: when a window disappears, remove it from the touch sprite trace
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
Daniel Stone d2af968cb6 Xi: allow selecting for touch events
Selecting for any of XI_TouchBegin/Update/End/Ownership requires the three
bits for begin/update/end to be set.

Only one client at a time may select for XI_TouchBegin event

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
Daniel Stone 3fb258ca28 input: add a TouchClassRec to the devices
These structs will be used to store touch-related data, events and
information.

Drivers must call InitTouchClassDeviceStruct to set up a multi-touch capable
device.

Touchpoints for the DDX and the DIX are handled separately - touchpoints
submitted by the driver/DDX will be stored in the DDXTouchPointInfoRec. Once
the touchpoints are processed by the DIX, new TouchPointInfoRecs are created
and stored. This process is already used for pointer events with the
last.valuators field.

Note that this patch does not actually add the generation of touch events,
only the required structs.

TouchListeners are (future) recipients of touch or emulated pointer events.
Each listener is in a state, depending which event they have already
received. The type of listener defines how the listener got to be one.

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-19 09:08:36 +10:00
Peter Hutterer 93c2a1628a Hook up the ownership events
This patch applies most of the protocol conversions and the internal event
type for ownership events.

Note that ownership events are generated by the DIX only, they do not pass
through the event queue.

Co-authored-by: Daniel Stone <daniel@fooishbar.org>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Chase Douglas <chase.douglas@canonical.com>
2011-12-19 09:08:32 +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 84db813b9d Hook up TouchBegin/Update/End events
The are the same as device events internally but require the touch ID
separately from the detail.button field (the protocol uses the detail field
for the touch id).
For simpler integration of pointer emulation we need to set the
detail.button field while keeping the touchid around.

Add the three new touch event types to the various places in the server
where they need to be handled. The actual handling of the events is somewhat
more complicated in most places.

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 4c825eae89 Xi: add a FIXME
All the DeepCopy stuff really needs to be shared between the init calls the
drivers use and this code here. Too many bugs by not keeping the two in
sync.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Reviewed-by: Chase Douglas <chase.douglas@canonical.com>
2011-12-16 11:18:47 +10:00
Peter Hutterer 0b9d2e426d Xi: split ProcessOtherEvent into ProcessDeviceEvent
No functional changes.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Reviewed-by: Chase Douglas <chase.douglas@canonical.com>
2011-12-16 11:18:47 +10:00
Peter Hutterer 218752bdc5 input: replace GRABTYPE_* with the InputLevel enums
They achieve the same thing, re-use the more generic InputLevel so we can
convert to/fro easier.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Chase Douglas <chase.douglas@canonical.com>
2011-12-13 13:24:08 +10:00
Peter Hutterer cd56bd7b3e Add GrabIsPointerGrab and GrabIsKeyboardGrab helpers
No functional changes

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Chase Douglas <chase.douglas@canonical.com>
2011-12-13 13:24:08 +10:00
Peter Hutterer 1d01e861b6 dix: split out core state and event state setting into helper functions
no functional changes.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Chase Douglas <chase.douglas@canonical.com>
2011-12-13 13:24:08 +10:00
Peter Hutterer 86c3137c81 Xi: split updating button count and state into helper functions
Functional change: for a button mapped to 0, the motionHintWindow is not
updated to the NullWindow anymore. Before it got updated unconditionally to
the button mapping. I have no idea what the practical effect of this is, but
I guess it's closer to the correct behaviour: pressing a button that's
logically disabled now does not disrupt the motion hint delivery.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Chase Douglas <chase.douglas@canonical.com>
2011-12-13 13:24:00 +10:00
Peter Hutterer e0f37250ff Xi: deduplicate button motion mask setting
No functional changes

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Chase Douglas <chase.douglas@canonical.com>
2011-12-13 13:24:00 +10:00
Alan Coopersmith 372a6f10dc Change disable_clientpointer return type to void
It doesn't return anything, nor does it's caller expect it to.

Fixes Solaris Studio compiler error:
"xichangehierarchy.c", line 214: Function has no return statement : disable_clientpointer

Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
Signed-off-by: Keith Packard <keithp@keithp.com>
2011-12-09 14:55:37 -08:00
Keith Packard 522f8bcc03 Merge remote-tracking branch 'whot/for-keith' 2011-12-08 20:57:26 -08:00
Peter Hutterer 8c9589c71d Xi: rename "state" to "corestate" in ProcessDeviceEvents
'state' is shadowed by the XKB 'state' as well (which feeds into the event
too), so rename this one to clarify that this is the core event state only.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Chase Douglas <chase.douglas@canonical.com>
2011-12-09 14:56:24 +10:00
Peter Hutterer 631516a4aa Xi: check button mapping value _before_ assigning it
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Chase Douglas <chase.douglas@canonical.com>
2011-12-09 14:56:24 +10:00
Peter Hutterer a1304d6cb6 Xi: skip superfluous cast
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Chase Douglas <chase.douglas@canonical.com>
2011-12-09 14:56:24 +10:00
Peter Hutterer d2ebbcdaf6 Xi: when removing a device, reset ClientPointers where needed
if a client had the to-be-removed device as ClientPointer, reset to NULL.

Fixes #43165

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Jeremy Huddleston <jeremyhu@apple.com>
2011-12-09 14:56:23 +10:00
Peter Hutterer 86bb3781b3 input: swap the server over to use the XI2mask struct
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Chase Douglas <chase.douglas@canonical.com>
2011-12-09 14:56:23 +10:00
Peter Hutterer b601ea769f dix: allocate temporary grabs on the heap
Once grabs start having nested memory locations, we can't just use the
GrabRec on the stack anymore, we need to alloc/copy/free the grabs.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Chase Douglas <chase.douglas@canonical.com>
2011-12-09 14:56:23 +10:00
Dave Airlie 682c09a2ce Xi: avoid overrun of callback array.
This code had an off-by-one and would allow writing one past the end of
the callbacks array.

Pointed out by coverity.

Signed-off-by: Dave Airlie <airlied@redhat.com>
Reviewed-by: Jeremy Huddleston <jeremyhu@apple.com>
2011-12-06 16:00:35 +00:00
Peter Hutterer 61ef4daf64 Xi: add FreeInputMask function
Does what it says on the box, complements MakeInputMask.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Chase Douglas <chase.douglas@canonical.com>
2011-11-29 15:12:59 +10:00
Peter Hutterer ee9346bb31 Xi: add helper functions to alloc/free InputClientPtrs
Currently not needed since the InputClientRec is a self-contained struct. As
part of the touch rework that won't be the case in the future and a function
to allocate/free memory appropriately is required.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Chase Douglas <chase.douglas@canonical.com>
2011-11-29 15:12:43 +10:00
Peter Hutterer bedb8fd90d Xi: use single return code from XIPassiveGrabDevice
Some failures returned status but the actual return code was "ret". Use
"ret" consistently and move status to the local block is used in.

[the goto isn't necessary yet, but for a future patch]

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Chase Douglas <chase.douglas@canonical.com>
2011-11-29 15:12:32 +10:00
Alan Coopersmith 05f589d464 Fix gcc -Wwrite-strings warnings in various extensions
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Reviewed-by: Jeremy Huddleston <jeremyhu@apple.com>
2011-11-23 12:15:07 -08:00
Alan Coopersmith 5f285a30a1 Make XIGetKnownProperty take a const char * argument
Now that MakeAtom takes const char *, so can XIGetKnownProperty.
Clears 71 warnings from gcc -Wwrite-strings of the form:
devices.c:145:5: warning: passing argument 1 of 'XIGetKnownProperty' discards qualifiers from pointer target type
../include/exevents.h:128:23: note: expected 'char *' but argument is of type 'const char *'

Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
2011-11-23 12:15:06 -08:00
Peter Hutterer 35ec24cf24 input: replace remaining GetPairedDevice() with GetMaster()
Wherever it's obvious which device we need (keyboard or pointer), use
GetMaster() instead of GetPairedDevice(). It is more reliable in actually
getting the device type we want.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Daniel Stone <daniel@fooishbar.org>
2011-11-09 13:26:47 +10:00
Peter Hutterer 22715e465b Xi: allow passive keygrabs on the XIAll(Master)Devices fake devices
They don't have a KeyClassRec, but we must still allow passive grabs on
them.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Tested-by: Bastien Nocera <hadess@hadess.net>
Reviewed-by: Daniel Stone <daniel@fooishbar.org>
2011-11-09 13:26:41 +10:00
Peter Hutterer ffe20acedb Use new FP1616/FP3232 conversion functions
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Jeremy Huddleston <jeremyhu@apple.com>
2011-10-25 14:06:41 +10:00
Peter Hutterer 4bb5d8fae4 Xi: send DeviceChangedEvents when the scroll valuators change value
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 d77dec6971 Xi: ensure the deviceid for DeviceChangedEvents is always the right one
If we're sending the event for a given device, make sure the deviceid is
that of the device.
This allows callers to use the same DCE for slave and master without having
to fiddle the DCE's internal fields.

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 fcdd2587a1 dix: drop unused argument from XISendDeviceChangedEvent
Instead of device and master (and just using master), drop the master
argument and let the callers pass in the device the event is to be sent for.

No effective functional changes.

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 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
Peter Hutterer 635a1f50bc input: allow for max < min for relative axes on InitValuatorAxisStruct
Relative axes are initialized with 0, -1 but so far this never had any
effect as all users of this function (for relative axes) just set it to the
defaults anyway.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Daniel Stone <daniel@fooishbar.org>
2011-09-29 12:26:43 +10:00
Peter Hutterer 8d1a414cca input: switch InitValuatorAxisStruct to return Bool
Return errors instead of silently ignoring them.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Daniel Stone <daniel@fooishbar.org>
2011-09-29 12:26:43 +10:00
Daniel Stone 78d8d6dd7f Input: Add vertical and horizontal scroll axes
To be used for smooth scrolling with future driver APIs, replacing
Rel Vert Wheel and Rel Horiz Wheel axes, which have not been used in any
open driver to date.

Combined with double-granularity ValuatorMasks, these axes allow for
fine-grained scroll data to be sent to clients.  Future commits allow
drivers to post these scroll axes to
QueuePointerEvents/GetPointerEvents, which take care of emulating legacy
scroll button events.

Signed-off-by: Daniel Stone <daniel@fooishbar.org>
2011-09-29 12:26:43 +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
Keith Packard afb1fe695d Merge remote-tracking branch 'whot/next' 2011-09-26 20:24:15 -07:00
Carlos Garnacho f52d5cd374 Xi: Fix passive XI2 ungrabs on XIAll[Master]Devices
The corresponding DeviceIntPtr wasn't being gotten properly,
resulting in BadDevice from dixLookupDevice().

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>
2011-09-27 11:56:27 +10:00
Matt Turner 9edcae78c4 Use correct swap{l,s} (or none at all for CARD8)
Swapping the wrong size was never caught because swap{l,s} are macros.

It's clear in the case of Xext/xres.c, that the author believed
client_major/minor to be CARD16 from looking at the code in the first
hunk.

v2: dmx.c fixes from Keith.

Reviewed-by: Peter Harris <pharris@opentext.com>
Signed-off-by: Matt Turner <mattst88@gmail.com>
2011-09-21 17:14:16 -04:00
Matt Turner 2c7c520cfe Use internal temp variable for swap macros
Also, fix whitespace, mainly around
	swaps(&rep.sequenceNumber)

Reviewed-by: Peter Harris <pharris@opentext.com>
Signed-off-by: Matt Turner <mattst88@gmail.com>
2011-09-21 17:12:04 -04:00
Peter Hutterer 484cef5b29 Xi: silence compiler warnings (set but not used)
exevents.c: In function 'UpdateDeviceState':
exevents.c:719:9: warning: variable 'bit' set but not used
[-Wunused-but-set-variable]

exevents.c: In function 'ProcessOtherEvent':
exevents.c:889:22: warning: variable 'v' set but not used
[-Wunused-but-set-variable]
exevents.c:888:17: warning: variable 'k' 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:51 +10:00
Peter Hutterer 08a7246f43 dix: rename ProcessRawEvents to dix/events.c:DeliverRawEvent
No functional changes, prep work for future changes.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Cyril Brulebois <kibi@debian.org>
Reviewed-by: Jeremy Huddleston <jeremyhu@apple.com>
Reviewed-by: Daniel Stone <daniel@fooishbar.org>
2011-06-08 13:57:05 +10:00
Peter Hutterer 0aa45c5c53 Xi: use temporary variable for filter.
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-06-08 13:57:03 +10:00
Peter Hutterer bfd8422e88 Xi: use __func__ instead of function name.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Cyril Brulebois <kibi@debian.org>
2011-06-03 14:43:05 +10:00
Peter Hutterer ffd4874798 include: add version_compare helper function
Compare two version numbers in the major.minor form.
Switch the few users of manual version switching over to the new function.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Jamey Sharp <jamey@minilop.net>
2011-05-13 09:41:50 +10:00
Peter Hutterer dc45d5816d Xi: split DeviceStateNotify delivery into a separate function
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Jamey Sharp <jamey@minilop.net>
2011-05-13 09:41:38 +10:00
Peter Hutterer 5690199802 input: change CHECKEVENT macro to verify_internal_event function
The macro is sufficient if called during a development cycle, but not
sufficient information when triggered by a user (e.g.
https://bugzilla.redhat.com/show_bug.cgi?id=688693).

Expand what this does to print the event content and a backtrace, so at
least we know where we're coming from. Only the first 32 bytes are printed
since if something goes wrong, the event we have is almost certainly an
xEvent or xError, both restricted to 32 bytes.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Daniel Stone <daniel@fooishbar.org>
2011-05-06 09:58:08 +10:00
Peter Hutterer bf2059b07a input: Only release SD buttons for explicit floating/reattachment (#36146)
Grabbing an SD device temporary floats the device but we must not release
the buttons. Introduced in

    commit 9d23459415
    Author: Peter Hutterer <peter.hutterer@who-t.net>
    Date:   Fri Feb 25 11:08:19 2011 +1000

    dix: release all buttons and keys before reattaching a device (#34182)

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

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Jeremy Huddleston <jeremyhu@apple.com>
2011-05-05 10:29:17 +10:00
Nicolas Kaiser 9b5046d213 Xi: 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:05 -07:00
Peter Hutterer 60b08e013d Xi: don't swap the status byte in the XIPassiveGrab replies
Reported-by: Julien Cristau <jcristau@debian.org>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Daniel Stone <daniel@fooishbar.org>
2011-04-18 13:04:47 +10:00
Peter Hutterer a3f37f3698 Xi: exit with error value if CheckGrabValues failed.
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:04:44 +10:00
Peter Hutterer f4d9ff73b1 Xi: fix reply swapping function check for XIPassiveGrabDevice
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:04:42 +10:00
Peter Hutterer 2a49ffa3c9 Xi: return the bad device ID if a passive grab fails with BadDevice.
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:04:39 +10:00
Peter Hutterer f0f0eec869 Xi: silence valgrind warning. (#36120)
Conditional jump or move depends on uninitialised value(s)
   at 0x4357A1: GetEventMask (events.c:454)
   by 0x43B9E8: DeliverEventsToWindow (events.c:2029)
   by 0x4E0C59: SendEventToAllWindows (exevents.c:2125)
   by 0x4E8301: XISendDeviceHierarchyEvent (xichangehierarchy.c:118)
   by 0x426F99: DisableDevice (devices.c:507)
   by 0x46BF72: xf86Wakeup (xf86Events.c:457)
   by 0x432ABA: WakeupHandler (dixutils.c:419)
   by 0x45B708: WaitForSomething (WaitFor.c:235)
   by 0x42E8D9: Dispatch (dispatch.c:367)
   by 0x422DC9: main (main.c:287)
 Uninitialised value was created by a stack allocation
   at 0x4E8190: XISendDeviceHierarchyEvent (xichangehierarchy.c:61)

Conditional jump or move depends on uninitialised value(s)
   at 0x43BB78: DeliverEventsToWindow (events.c:2010)
   by 0x4DDEEA: FindInterestedChildren (exevents.c:2103)
   by 0x4DDEFF: FindInterestedChildren (exevents.c:2104)
   by 0x4DDEFF: FindInterestedChildren (exevents.c:2104)
   by 0x4DDEFF: FindInterestedChildren (exevents.c:2104)
   by 0x4DDEFF: FindInterestedChildren (exevents.c:2104)
   by 0x4E0C6F: SendEventToAllWindows (exevents.c:2127)
   by 0x4E8301: XISendDeviceHierarchyEvent (xichangehierarchy.c:118)
   by 0x426F99: DisableDevice (devices.c:507)
   by 0x46BF72: xf86Wakeup (xf86Events.c:457)
   by 0x432ABA: WakeupHandler (dixutils.c:419)
   by 0x45B708: WaitForSomething (WaitFor.c:235)
 Uninitialised value was created by a stack allocation
   at 0x4E8190: XISendDeviceHierarchyEvent (xichangehierarchy.c:61)

Set the type of dummyDev to SLAVE. The jump listed above comes from a check
to IsMaster() in GetEventMask() that would then set the
XIAllMasterDevices mask.
Hierarchy events can only be set for XIAllDevices so the above IsMaster()
check had no effect and the device type doesn't really matter anyway beyond
shuting up valgrind.

Also initialize dummyDev to 0 to ease future debugging.

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

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2011-04-18 13:04:19 +10:00
Peter Hutterer 419a27b521 Xi: fix valuator alignment in DeepCopyDeviceClasses (#36119)
commit 678f5396c9 only fixed the
initialization, not the copy. After a slave device change, the valuator
were out of alignment again.

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

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Jeremy Huddleston <jeremyhu@apple.com>
2011-04-18 13:04:19 +10:00
Keith Packard c9d89cec14 Merge remote-tracking branch 'vignatti/for-keith' 2011-04-04 11:57:39 -07:00
Tiago Vignatti daae5e5de1 xi: fix memory leak in AddExtensionClient
Signed-off-by: Tiago Vignatti <tiago.vignatti@nokia.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Nicolas Peninguy <nico@lostgeeks.org>
2011-04-04 15:41:47 +03:00
Tiago Vignatti 4d87606a0d Xi: fix memory leak in ProcXGetSelectedExtensionEvents
Signed-off-by: Tiago Vignatti <tiago.vignatti@nokia.com>
Reviewed-by: Nicolas Peninguy <nico@lostgeeks.org>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
2011-04-04 15:41:13 +03:00
Tiago Vignatti 623bb34342 xi: fix memory leak in ProcXIQueryDevice
Signed-off-by: Tiago Vignatti <tiago.vignatti@nokia.com>
Reviewed-by: Nicolas Peninguy <nico@lostgeeks.org>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
2011-04-04 15:41:13 +03:00
Tiago Vignatti aa7096ca6f xorg: remove unused pointer values all over the server
Signed-off-by: Tiago Vignatti <tiago.vignatti@nokia.com>
Reviewed-by: Nicolas Peninguy <nico@lostgeeks.org>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
2011-04-04 15:41:13 +03:00
Matthieu Herrb 266ea63bc3 Xi: fix querydevice request swapping
WriteReplyToClient() swaps rep.length, so it can't be used
on return of WriteReplyToClient(). So save it's value for later
use.

Signed-off-by: Matthieu Herrb <matthieu.herrb@laas.fr>
Reviewed-by: Julien Cristau <jcristau@debian.org>
2011-04-02 09:14:53 +02:00
Matthieu Herrb a074e6b675 Xi: add XI_Focus{In,Out} to swapped events.
Signed-off-by: Matthieu Herrb <matthieu.herrb@laas.fr>
Reviewed-by: Julien Cristau <jcristau@debian.org>
2011-04-02 09:14:29 +02:00
Matthieu Herrb 81257377a2 Xi: take XI2 requests into account also for the swapping case.
Signed-off-by: Matthieu Herrb <matthieu.herrb@laas.fr>
Reviewed-by: Julien Cristau <jcristau@debian.org>
2011-04-02 09:14:23 +02:00
Simon Thum 633b81e8ba xserver: remove AbsoluteClassRec keeping the ABI
This removes the struct, but keeps InitAbsoluteClassDeviceStruct as
a no-op and preserves related struct layout.

Signed-off-by: Simon Thum <simon.thum@gmx.de>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2011-03-24 09:52:51 +10:00
Simon Thum 2103d61909 simplify ChangeDeviceControl in stubs
Signed-off-by: Simon Thum <simon.thum@gmx.de>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2011-03-24 09:52:48 +10:00
Keith Packard c3c0e2fdd3 Merge remote branch 'whot/for-keith' 2011-03-09 14:25:54 -08:00
Peter Hutterer 33fee13361 Xi: fix XI2 passive grab reply length calculation
If modifiers failed, the reply length was 4 bytes too short.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Julien Cristau <jcristau@debian.org>
Reviewed-by: Daniel Stone <daniel@fooishbar.org>
2011-03-09 10:53:27 +10:00
Julien Cristau eb8141b6ed Xi: fix length checks for swapped clients
ChangeDeviceProperty and XIChangeProperty are followed by some data, so
use REQUEST_AT_LEAST_SIZE instead of REQUEST_SIZE_MATCH.

X.Org bug#35082 <https://bugs.freedesktop.org/show_bug.cgi?id=35082>

Reported-by: Markus Fleschutz <markus.fleschutz@x-software.com>
Signed-off-by: Julien Cristau <jcristau@debian.org>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2011-03-09 07:59:41 +10:00
Adam Jackson 2cb3dc020c xi: Use RESTYPE consistently
No functional change

Reviewed-by: Soren Sandmann <ssp@redhat.com>
Signed-off-by: Adam Jackson <ajax@redhat.com>
2011-03-08 13:20:33 -05:00
Peter Hutterer 579ee8f5d8 Merge branch 'mi-cleanup' into next 2011-02-23 08:44:42 +10:00
Peter Hutterer 77113dd3ee input: Change a bunch of direct dev->u.master accesses to use GetMaster()
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Benjamin Tissoires <tissoire@cena.fr>
2011-02-22 14:35:45 +10:00
Peter Hutterer febce8cb81 Xi: replace a direct master access with GetMaster()
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 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 dc32a23890 Fix two incorrect checks for master devices.
These two were sideeffects of lastSlave being in the same field as the
master. For devices generated by the master device directly, lastSlave was 0
and the device would (with the old checks) be interpreted as floating.

Add the required checks to safeguard against master devices.

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
Bryce Harrington 649269d406 Check for OOM condition in XISendDeviceHierarchyEvent
When system is out of memory, calloc can fail returning a NULL pointer.
Check for this before dereferencing it, and bail out if it fails.

Ref.: https://bugs.launchpad.net/ubuntu/+source/xorg-server/+bug/720445

Signed-off-by: Bryce Harrington <bryce@canonical.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2011-02-17 15:38:27 +10:00
Daniel Stone 737562257e Input: Actually send Xi 1.x DeviceStateNotify events
When a client has selected for Xi 1.x DeviceStateNotify events, they
should receive them when a DeviceFocusIn event is generated.  The code
to do this was there, but an incorrect test meant they were never being
sent.

The "type" passed in is the XI2 type, the XI1 type is in event.type.

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-02-17 09:22:00 +10:00
Daniel Stone da39d57a20 Input: Store passive-activating key in CheckDeviceGrabs
CheckDeviceGrabs will activate a passive grab for KeyPress and
ButtonPress events.  GrabInfoRec::activatingKey contains the keycode
which activated the passive grab, so we can deactivate it later in
ProcessOtherEvents.

Previously, CheckDeviceGrabs relied on its callers to set
activatingKey, which not all callers were doing (I'm looking at you,
ComputeFreezes).  Just set it in CheckDeviceGrabs instead.

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-02-17 09:10:10 +10:00
Carlos Garnacho 787ba25a8a Xi: make XIQueryPointer return the current modifiers/group as documented.
The previous XKB info was being returned instead of the current
one, producing inconsistent results between the latest events
and the modifiers/group returned by this call.

Signed-off-by: Carlos Garnacho <carlosg@gnome.org>
Reviewed-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-02-14 09:12:59 +10:00
Peter Hutterer 81daba8ce9 Xi: constify XIChangeDeviceProperty()
We don't modify "value", make it official.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Chase Douglas <chase.douglas@canonical.com>
Signed-off-by: Ander Conselvan de Oliveira <ander.conselvan-de-oliveira@nokia.com>
2011-02-14 09:12:58 +10:00
Peter Hutterer 16eb4f2a7b Xi: reset remainders when warping the device.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Daniel Stone <daniel@fooishbar.org>
Reviewed-by: Chase Douglas <chase.douglas@canonical.com>
Reviewed-by: Simon Thum <simon.thum@gmx.de>
2011-01-20 07:48:46 +10:00
Daniel Stone 07a892cd82 Input: Pass sprite instead of device to FixUpEventFromWindow
Since FixUpEventFromWindow only uses the sprite trace to determine the
window stack, pass in a sprite instead of hardcoding the device sprite,
so we can deliver to windows other than the one currently containing the
sprite.

Signed-off-by: Daniel Stone <daniel@fooishbar.org>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Chase Douglas <chase.douglas@canonical.com>
2011-01-06 17:10:36 +00:00
Daniel Stone e1aed88be9 Input: Swap flags in DeviceEvents
Swap flags for different-endian clients when delivering XI2
DeviceEvents.

Signed-off-by: Daniel Stone <daniel@fooishbar.org>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Chase Douglas <chase.douglas@canonical.com>
2011-01-06 17:10:02 +00:00
Daniel Stone 03f2eb1e15 Input: Set client error value for invalid mask bits
When we send BadValue back to the client for having invalid mask bits,
at least tell them what the (first) invalid bit was.

Signed-off-by: Daniel Stone <daniel@fooishbar.org>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2010-12-31 12:36:44 +00:00
Eoghan Sherry 36b614dedf Xi: Fix master button update when slave buttons are mapped. #24887
It is currently assumed that an event button delieved to a master device
corresponds to the slave button states. However, the event button is a
logical (mapped) slave button and slave button states correspond to
physical (unmapped) slave buttons. This leads to incorrect update of the
master button state and incorrect events devlivered to clients. Fix the
situation by taking the slave button map into account when querying a
slave button state.

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

Signed-off-by: Eoghan Sherry <ejsherry@gmail.com>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2010-12-07 08:07:54 +10:00
Peter Hutterer 5cd11d2356 Xi: move property reset from extension shutdown to init.
If any part of the stack calls XIGetKnownProperty during device shutdown
the property is re-initialized before the server generation resets, leaving
the value invalid again.

Move the reset to the extension init which happens before input devices are
initialized before the first property is requested.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Julien Cristau <jcristau@debian.org>
2010-11-12 11:48:28 +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 9e999d18b0 Xi: if XTEST device creation fails, fail the master devices.
When getting close to the MAXDEVICES limit, the creation of XTEST devices
may fail due to device id exhaustion. In that case, fail the creation of
master devices too and return an error to the client.

Theoretically, we could alloc the MDs without the XTEST devices but that
will get interesting when a client starts sending XTEST events through those
devices.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Julien Cristau <jcristau@debian.org>
2010-11-09 07:59:56 +10:00
Peter Hutterer 5a455e0c80 Xi: rename two variables from ptr to dev.
They were named ptr when everything was in one function to save one more
variable. Now that the stuff is split out, "dev" makes more sense.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Julien Cristau <jcristau@debian.org>
2010-11-09 07:59:45 +10:00
Peter Hutterer 9b89b91c68 Xi: split hierarchy manipulation into static functions.
No functional changes, just code cleanup to improve readability.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Julien Cristau <jcristau@debian.org>
2010-11-09 07:59:07 +10:00
Peter Hutterer fe8d122b13 Xi: reshuffle conditions for labeling a device as IsXExtensionKeyboard (#29046)
From the original bug reporter Ezra Reeves:

"I did some more digging on this today, and I found that an HP branded
wireless USB mouse has the same issue. With this mouse (as well as the
logitech wireless mouse), the return from:

xdev = XListInputDevices(GDK_WINDOW_XDISPLAY(rootwin), &ndevices_return);

lists the USB device twice, but both have xdev[num].use == 3
(IsXExtensionKeyboard as defined in X11/XI.h).

[...]

Swapping the order of the test in Xi/listdev.c that determines whether a
device is a pointer or a keyboard properly detects my devices (OEM USB
wireless mouse/kb combo) -- one as a keyboard and one as a pointer."

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

Reported-by: Erik Kilfoil <ekilfoil@gmail.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2010-10-29 08:28:57 +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 dd11f734a9 input: remove "mode" field from ValuatorClassRec.
We have per-axis mode now. For those bits that still need it (XI 1.x),
assume that the first axis holds the device's mode.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Chase Douglas <chase.douglas@canonical.com>
2010-10-22 16:19:00 +10:00
Peter Hutterer 5cf3b654fc input: move proximity state into ProximityClassRec.
Previously the OutOfProximity bit in the valuator 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
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 eaf0b6a4d8 Merge branch 'master' into input-api
Conflicts:
	config/udev.c
	hw/xfree86/common/xf86Helper.c
	hw/xfree86/common/xf86Module.h
	hw/xfree86/common/xf86Xinput.h
	hw/xfree86/os-support/linux/lnx_init.c

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2010-10-15 13:46:59 +10:00
Peter Hutterer 4ac3be29bc input: Purge AddOtherInputDevices DDX hook.
This hook wasn't used by any DDX. Device addition and removal is handled by
the config backend, so we don't need to do anything special that during the
ListInputDevices request processing.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Adam Jackson <ajax@redhat.com>
Reviewed-by: Daniel Stone <daniel@fooishbar.org>
2010-09-01 15:26:52 +10:00
Peter Hutterer cb672a461c input: remove OpenInputDevice and CloseInputDevice DDX hooks.
In theory, these hooks were to be used for DDX-specific device enablement.
None of the DDXs however did anything here. Now we call DEVICE_INIT on all
devices when they are added, so the xfree86 DDX as the only one with real
code didn't do anything here.

kdrive checked for device validity but that's already handled in
ProcXOpenDevice.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Adam Jackson <ajax@redhat.com>
Reviewed-by: Daniel Stone <daniel@fooishbar.org>
2010-09-01 15:26:51 +10:00
Peter Hutterer 0fb7a5c261 input: Purge Register*Device() functions.
RegisterPointerDevice() and RegisterKeyboardDevice() were already mapped to
RegisterOtherDevice() and obsolete.

RegisterOtherDevice() was called for all devices and the two assignments can
simply be moved into AddInputDevice(). Purge RegisterOtherDevice() and
pretend it never happened.

*lalalalala*

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Adam Jackson <ajax@redhat.com>
Reviewed-by: Daniel Stone <daniel@fooishbar.org>
2010-09-01 15:26:47 +10:00
Matt Turner 08adf41f63 Replace malloc/strlen/strcpy with strdup.
Reviewed-by: Jeremy Huddleston <jeremyhu@apple.com>
Signed-off-by: Matt Turner <mattst88@gmail.com>
2010-08-27 19:05:48 -04:00
Peter Hutterer 619ca32202 Xi: reset the unused classes pointer after copying
After copying the unused_classes into the device, reset the original
pointer. Otherwise we have two pointers pointing to the same field and both
get freed on device removal.

Some classes already have this behaviour since 51c8fd69.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Keith Packard <keithp@keithp.com>
2010-08-13 11:07:21 +10:00
Peter Hutterer a1afe17255 dix: add aux. functions for button_is_down, set_button_down, set_button_up.
Same as the matching key functions. Buttons, like keys, can have two states
for down/up - one posted, one processed. Posted is set during event
generation (usually in the signal handler). Processed is set during event
processing when the event queue is emptied and events are being delivered to
the client.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Daniel Stone <daniel@fooishbar.org>
2010-07-07 13:29:46 +10:00
Peter Hutterer c184429080 Xi: use set_key_up/down instead of manual bit handling.
We have the wrappers, use them.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2010-07-07 13:29:45 +10:00
Keith Packard 07a093add0 Merge remote branch 'whot/for-keith' 2010-06-10 18:39:10 -07:00
Peter Hutterer dc614484f9 Xi: don't copy the modifier key count when copying device classes (#25480)
The modifier key count is maintained by the XKB layer and
increased/decreased for all modifiers that set state.

Test case, MD/SD modifier key count in comment:
1. keyboard 1: press and hold Shift_L    # SD:1     MD:1
2. keyboard 2: press and release Shift_L # SD:1,0   MD:1,0
<class copy happens>                     # SD:1     MD:1
3. keyboard 1: release Shift_L           # SD:0     MD:1
4. keyboard 1: press and release Shift_L # SD:1,0   MD:2,1

The modifier is now logically down on the MD but not on keyboard 1 or
keyboard 2.

XKB is layered in before the DIX, it increases/decreases the modifier key
count accordingly. In the above example, during (2), the MD gets the key
release and thus clears the modifier bit. (3) doesn't forward the release to
the MD because it is already cleared. The copy of modifierKeysDown when the
lastSlave changes however increases the counter for the held key. On (4),
the press and release are both forwarded to the MD, causing a offset by 1
and thus do not clear the logical modifier state.

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

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Acked-by: Daniel Stone <daniel@fooishbar.org>
2010-06-11 09:47:42 +10:00
Mikhail Gusarov 7287ef9e6c Remove unnecessary parentheses around return values in functions
This patch was generated by the following Perl code:

perl -i -pe 's/([^_])return\s*\(\s*([^(]+?)\s*\)s*;(\s+(\n))?/$1return $2;$4/g;'

Signed-off-by: Mikhail Gusarov <dottedmag@dottedmag.net>
Reviewed-by: Jamey Sharp <jamey@minilop.net>
Reviewed-by: Daniel Stone <daniel@fooishbar.org>
Signed-off-by: Keith Packard <keithp@keithp.com>
2010-06-10 06:42:42 -07:00
Mikhail Gusarov 0a4d8cbdcd Remove more superfluous if(p) checks around free(p)
This patch has been generated by the following Coccinelle semantic patch:

@@
expression E;
@@

-if(E) { free(E); }
+free(E);

Signed-off-by: Mikhail Gusarov <dottedmag@dottedmag.net>
Reviewed-by: Julien Cristau <jcristau@debian.org>
Reviewed-by: Fernando Carrijo <fcarrijo@yahoo.com.br>
Reviewed-by: Matt Turner <mattst88@gmail.com>
2010-06-06 20:27:18 +07:00
Keith Packard faeebead7b Change the devPrivates API to require dixRegisterPrivateKey
This patch only changes the API, not the implementation of the
devPrivates infrastructure. This will permit a new devPrivates
implementation to be layed into the server without requiring
simultaneous changes in every devPrivates user.

Signed-off-by: Keith Packard <keithp@keithp.com>
Tested-by: Tiago Vignatti <tiago.vignatti@nokia.com>
2010-06-05 19:23:03 -07:00
Jamey Sharp a83cff9f4d Move each screen's x/y origin into ScreenRec.
Many references to the dixScreenOrigins array already had the
corresponding screen pointer handy, which meant they usually looked like
"dixScreenOrigins[pScreen->myNum]". Adding a field to ScreenRec instead
of keeping this information in a parallel array simplifies those
expressions, and eliminates a MAXSCREENS-sized array.

Since dix declared the dixScreenOrigins array, I figure allocating a
screen private for these values is overkill.

Signed-off-by: Jamey Sharp <jamey@minilop.net>
Reviewed-by: Tiago Vignatti <tiago.vignatti@nokia.com>
Tested-by: Tiago Vignatti <tiago.vignatti@nokia.com> (i686 GNU/Linux)
2010-06-03 14:03:23 -07:00
Jamey Sharp 217ccaa5a3 Delete panoramiXdataPtr: it's redundant.
This eliminates a dynamically-allocated MAXSCREENS-sized array.

Signed-off-by: Jamey Sharp <jamey@minilop.net>
Reviewed-by: Tiago Vignatti <tiago.vignatti@nokia.com>
Tested-by: Tiago Vignatti <tiago.vignatti@nokia.com> (i686 GNU/Linux)
2010-06-03 14:03:23 -07:00
Jamey Sharp e7fae9ecc4 Move each screen's root-window pointer into ScreenRec.
Many references to the WindowTable array already had the corresponding
screen pointer handy, which meant they usually looked like
"WindowTable[pScreen->myNum]". Adding a field to ScreenRec instead of
keeping this information in a parallel array simplifies those
expressions, and eliminates a MAXSCREENS-sized array.

Since dix uses this data, a screen private entry isn't appropriate.

xf86-video-dummy currently uses WindowTable, so it needs to be updated
to reflect this change.

Signed-off-by: Jamey Sharp <jamey@minilop.net>
Reviewed-by: Tiago Vignatti <tiago.vignatti@nokia.com>
Tested-by: Tiago Vignatti <tiago.vignatti@nokia.com> (i686 GNU/Linux)
2010-06-03 14:03:23 -07:00
Peter Korsgaard 6cccf0131c dix: add 3x3 transformation matrix xinput property for multi-head handling
For absolute input devices (E.G. touchscreens) in multi-head setups,
we need a way to bind the device to an randr output. This adds the
infrastructure to the server to allow us to do so.

positionSprite() scales input coordinates to the dimensions of the shared
(total) screen frame buffer, so to restrict motion to an output we need to
scale/rotate/translate device coordinates to a subset of the frame buffer
before passing them on to positionSprite.

This is done here using a 3x3 transformation matrix, which is applied to
the device coordinates using homogeneous coordinates, E.G.:

[ c0 c1 c2 ]   [ x ]
[ c3 c4 c5 ] * [ y ]
[ c6 c7 c8 ]   [ 1 ]

Notice: As input devices have varying input ranges, the coordinates are
first scaled to the [0..1] range for generality, and afterwards scaled
back up.

E.G. for a dual head setup (using same resolution) next to each other, you
would want to scale the X coordinates of the touchscreen connected to the
both heads by 50%, and translate (offset) the coordinates of the rightmost
head by 50%, or in matrix form:

   left:            right:
[ 0.5 0 0 ]     [ 0.5 0 0.5 ]
[ 0   1 0 ]     [ 0   1 0   ]
[ 0   0 1 ]     [ 0   0 0   ]

Which can be done using xinput:

xinput set-prop <left> --type=float "Coordinate Transformation Matrix" \
       0.5 0 0 0 1 0 0 0 1

xinput set-prop <right> --type=float "Coordinate Transformation Matrix" \
       0.5 0 0.5 0 1 0 0 0 1

Likewise more complication setups involving more heads, rotation or
different resolution can be handled.

Signed-off-by: Peter Korsgaard <peter.korsgaard@barco.com>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2010-05-28 16:49:30 +10:00
Keith Packard 4e9d3e4132 Revert "Add a "flags" field to DeleteInputDeviceRequest."
Peter wants to get a larger patch sequence put together and I didn't
read past the commit message to see the 'don't take this patch
please'.

This reverts commit 531ff40301.
2010-05-26 07:54:35 -07:00
Peter Hutterer 531ff40301 Add a "flags" field to DeleteInputDeviceRequest.
Some input drivers need to implement an internal hotplugging scheme for
dependent devices to provide multiple X devices off one kernel device file.
Such dependent devices can be added with NewInputDeviceRequest() but they are
not removed when the config backend calls DeleteInputDeviceRequest(),
leaving the original device to clean up.

Example of the wacom driver:

config/udev calls NewInputDeviceRequest("stylus")

wacom PreInit calls
        NewInputDeviceRequest("eraser")
        NewInputDeviceRequest("pad")
        NewInputDeviceRequest("cursor")
        PreInit finishes.

When the device is removed, the config backend only calls
DeleteInputDeviceRequest for "stylus". The driver needs to call
DeleteInputDeviceRequest for the dependent devices eraser, pad and cursor to
clean up properly.
However, when the server terminates, DeleteInputDeviceRequest is called for
all devices - the driver must not remove the dependent devices to avoid
double-frees. There is no method for the driver to detect why a device is
being removed, leading to elaborate guesswork and some amount of wishful
thinking.

Though the input driver's UnInit already supports flags, they are unused.
This patch uses the flags to supply information where the
DeleteInputDeviceRequest request originates from, allowing a driver to
selectively call DeleteInputDeviceRequest when necessary.

Also bumps XINPUT ABI.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Dan Nicholson <dbn.lists@gmail.com>
Signed-off-by: Keith Packard <keithp@keithp.com>
2010-05-25 17:47:32 -07:00
Jamey Sharp e291c56182 Return an appropriately-typed error from dixLookupResourceByType.
Rather than always returning BadValue, associate an error status like
BadWindow with a resource type like RT_WINDOW, and return the
appropriate one for the requested type.

This patch only touches the core protocol resource types. Others still
return BadValue and need to be mapped appropriately.

dixLookupResourceByType can now return BadImplementation, if the caller
asked for a resource type that has not been allocated in the server.

Signed-off-by: Jamey Sharp <jamey@minilop.net>
Reviewed-by: Adam Jackson <ajax@redhat.com>
2010-05-19 12:32:48 -07:00
Jamey Sharp 92ed75ac59 Eliminate boilerplate around client->noClientException.
Just let Dispatch() check for a noClientException, rather than making
every single dispatch procedure take care of it.

Signed-off-by: Jamey Sharp <jamey@minilop.net>
Reviewed-by: Daniel Stone <daniel@fooishbar.org>
2010-05-13 17:14:07 -07:00
Mikhail Gusarov 3f3ff971ec Replace X-allocation functions with their C89 counterparts
The only remaining X-functions used in server are XNF*, the rest is converted to
plain alloc/calloc/realloc/free/strdup.

X* functions are still exported from server and x* macros are still defined in
header file, so both ABI and API are not affected by this change.

Signed-off-by: Mikhail Gusarov <dottedmag@dottedmag.net>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
2010-05-13 00:22:37 +07:00
Peter Hutterer 9802839d35 Xi: reset the known properties at the end of the server generation.
Properties allocated through XIGetKnownProperty() aren't reset on the second
server generation but keep the old value. As a result, wrong Atoms are
supplied to the driver, resulting in potential data corruption or weird
error message.

Reproducible by running "xlsatom | grep FLOAT" twice on a plain X server.
The second X server generation won't have the FLOAT atom defined anymore,
despite the users of this atom not noticing any errors.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Julien Cristau <jcristau@debian.org>
Signed-off-by: Keith Packard <keithp@keithp.com>
2010-05-07 12:16:43 -07:00
Keith Packard 65e961fcc1 Replace some input devPrivates with regular struct fields
In the process, fixes a memory leak in CloseDevice, and an unchecked
memory allocation in InitializePredictableAccelerationProperties.

Signed-off-by: Keith Packard <keithp@keithp.com>
Reviewed-by: Jamey Sharp <jamey@minilop.net>
2010-04-30 13:05:11 -07:00
Tiago Vignatti 057c147541 Xi: check for NULL pointer before dereferences it in ListButtonInfo
Both dev and dev->button are already used before their checking were being
performed. So check on the beginning.

Signed-off-by: Tiago Vignatti <tiago.vignatti@nokia.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Dan Nicholson <dbn.lists@gmail.com>
2010-04-21 18:07:19 +03:00
Tiago Vignatti d948dcd955 Xi: fix not reached code in XSendExtensionEvent
Error was introduced in 31a7994a. I.e., broken since 2007. I guess nobody uses
XSendExtensionEvent.

Signed-off-by: Tiago Vignatti <tiago.vignatti@nokia.com>
Reviewed-by: Dan Nicholson <dbn.lists@gmail.com>
2010-04-21 18:07:16 +03:00
Daniel Stone a2ea8c2f2c Record: Avoid duplicates from replaying frozen events
Reintroduce a check which used to be there in the old
ProcessKeyboardEvent/ProcessPointerEvent codepath, which avoids us
recording events subject to a grab twice: once when it's first processed
in EnqueueEvent, and then again when it's thawed and being replayed.

This required a tiny amount of code motion to expose syncEvents.

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>
2010-03-12 13:06:22 +10:00
Peter Hutterer 02d1116e7e Xi: assume BadMode for non-BadMatch errors returned from SetDeviceMode.
The XI protocol spec only allows for two errors on the SetDeviceMode
requests: BadMatch or BadMode. BadMode however is a dynamically assigned
extension error and the driver doesn't have access to the actual error
number. Hence, if a SetDeviceMode driver returns an error other than
BadMatch, assume BadMode.

The two exceptions are BadAlloc and BadImplementations, pass these on to the
client (any request is allowed to return either of those).

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Dan Nicholson <dbn.lists@gmail.com>
2010-02-22 12:04:36 +10:00
Chris Dekter 122fc0e7a0 Re-enable RECORD extension.
RECORD was disabled during the switch to internal events. This patch
modifies the record callback to work with internal events instead of
xEvents. The InternalEvents are converted to core/Xi events as needed.

Since record is a loadable extension, the EventTo* calls must be externed.

Signed-off-by: Chris Dekter <cdekter@gmail.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Adam Jackson <ajax@redhat.com>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2010-02-22 12:04:28 +10:00
Peter Hutterer 48f7298657 Xi: reset the sli pointers after copying device classes. (#25640)
If the indicator flags have the XkbSLI_IsDefault bit set, the indicator map
and names aren't their own bit of memory but rather point into the
device->key->xkbInfo->desc structure. XkbCopySrvLedInfo knows about this and
leaves the pointers alone.

When copying the classes from the slave to the master, these pointers are
copied and still point to the dev->key class of the slave device. If the
slave device is removed, the memory becomes invalid and a call to modify
this data (e.g. XkbSetIndicators) may cause a deadlock.

The copying of dev->key relies on dev->kbdfeed to be already set up. Hence
the pointers need to be reset once _both_ kbdfeed and key have been copied
into the master device.

X.Org Bug 25640 <http://bugs.freedesktop.org/show_bug.cgi?id=25640>
Fedora Bug 540584 <https://bugzilla.redhat.com/show_bug.cgi?id=540584>

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Keith Packard <keithp@keithp.com>
2010-02-15 15:27:41 +10:00
Benjamin Tissoires a34812b090 Add labels for multitouch valuators
Thoses definitions have been included in the kernel but the X server is not updated accordingly.
Without these definitions, the multitouch axes are not correctly labelled.

Signed-off-by: Benjamin Tissoires <tissoire@cena.fr>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2010-02-09 10:21:27 +10:00
Dan Nicholson 0711598dd3 config: Introduce InputAttributes in NewInputDeviceRequest
In order to give NewInputDeviceRequest more information, a new
InputAttributes type is introduced. Currently, this collects the product
and vendor name, device path, and sets booleans for attributes such as
having keys and/or a pointer. Only the HAL backend fills in the
attributes, though.

Signed-off-by: Dan Nicholson <dbn.lists@gmail.com>
Reviewed-by: Peter Hutterer <peter.hutterer at who-t.net>
2009-12-22 23:24:13 -08:00
Alan Coopersmith 895f40792a Add type name argument to CreateNewResourceType
Convert all calls of CreateNewResourceType to pass name argument

Breaks DIX ABI.

ABI versions bumped:

Signed-off-by: Alan Coopersmith <alan.coopersmith@sun.com>
Reviewed-by: Keith Packard <keithp@keithp.com>
Signed-off-by: Keith Packard <keithp@keithp.com>
2009-12-18 17:44:12 -08:00
Alan Coopersmith eb750f8b5e Check for failures from CreateNewResourceType
Make sure to check return value before setting bitmask flags.
For most calls, just fails to init the extension.   Since Xinput
already calls FatalError() on initialization failure, so does
failure to allocate Xinput's resource type.

Signed-off-by: Alan Coopersmith <alan.coopersmith@sun.com>
Reviewed-by: Keith Packard <keithp@keithp.com>
2009-12-18 16:51:45 -08:00
Peter Hutterer ea14a41821 Xi: reset device properties to NULL after deleting them. (#25374)
Commit 0e6cee853d introduced cleanup code to
remove the accel properties when switching schemes. The same code is
triggered by the default closedown code but only after unconditionally
removing all device properties (as part of the cleanup). The properties,
although deleted never got reset to NULL.

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

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Tested-by: Andy Furniss <lists@andyfurniss.entadsl.com>
Reviewed-by: Dave Airlie <airlied@redhat.com>
2009-12-11 11:37:37 +10:00
Peter Hutterer 1b127ab842 Xi: when deleting all properties, reset property handler to NULL.
Trying to unregister property handlers during the device closure process
leads to invalid memory accesses.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Keith Packard <keithp@keithp.com>
2009-11-25 10:57:07 +10:00
Peter Hutterer a30e739a14 Xi: don't crash when deleting invalid device properties.
Deleting a property that was not set on a device leads to a null-pointer
reference. The protocol allows deleting those properties - it has to be a
noop.

Reproducible:
xinput --set-prop "My device" --type=int --format=8 "my property" 1
xinput --delete-prop "My other device" "my property"

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Signed-off-by: Keith Packard <keithp@keithp.com>
2009-11-22 19:42:13 -08:00
Eamon Walsh 8502c06e19 xace: Fake return values on denials in input polling requests.
Instead of returning BadAccess when "read" permission is denied
on a device, falsify the device state (buttons down, keys pressed).
This is nicer to applications, but may still have undesired side
effects.  The long-term solution is not to use these requests in
event-driven code!

Requests affected: QueryPointer, QueryKeymap, XiQueryDevice.

Signed-off-by: Eamon Walsh <ewalsh@tycho.nsa.gov>
2009-10-14 19:19:19 -04:00
Jeremy Huddleston fb7938315b Xi: Make CopyKeyClass X_HIDDEN to avoid ugly ifdef-fu
(cherry picked from commit 6d436e17a9ae7f4ce8537f3fabc052d4f07ca75f)
2009-09-27 09:52:03 -07:00
Jeremy Huddleston fba8c702ba Xi: CopyKeyClass is not static for XQuartz
(cherry picked from commit 85d6402354cdf143c6490f2725744c2f08b5605b)
2009-09-26 23:30:41 -07:00
Peter Hutterer 9bd08c690f Xi: update axisVals with the right subpixel data.
Subpixel data in data_frac is stored as FP32.32, hence we need to get that
down again before adding it to the current value.

Reported-by: Thomas Jaeger
Tested-by: Thomas Jaeger
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2009-09-26 12:25:18 +10:00
Peter Hutterer 6ee796e9bb Xi: fix length calculation for ValuatorState in QueryDeviceState reply.
The length field needs to include the bytes required for the valuators
(INT32) as well.

The reply length has the right value and since the valuator state is always
last, clients didn't notice the wrong offset.

Tested-by: Thomas Jaeger
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2009-09-25 08:16:37 +10:00
Peter Hutterer 90aa0e4a49 input: don't use typecasts to access members of InternalEvent.
To avoid confusion, the member names are now postfixed with _event.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2009-09-22 11:15:32 +10:00
Peter Hutterer 55747d256d input: define server-supported protocol versions in one single file.
include/protocol-versions.h specifies each extension version as supported by
the server and sent back on the wire to the client.

This fixes up several issues with the server potentially reporting a higher
version of the protocol if recompiled against a newer version of the
protocol.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Acked-by: RĂ©mi Cardona <remi@gentoo.org>
Acked-by: Julien Cristau <jcristau@debian.org>
2009-09-21 21:47:35 +10:00
Daniel Stone bfb219f532 input: allow for detectable autorepeat.
For core and XI1 events, store the key_repeat flag in the sequence number
until TryClientEvents. The sequenceNumber is unset until TryClientEvents.

[Also thrown in, some random indentation changes. Thanks]

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2009-09-04 12:59:41 +10:00
Peter Hutterer 61a6e1f074 Xi: return BadDevice for master kbds and attached slaves in XIWarpPointer
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2009-09-03 10:00:34 +10:00
Peter Hutterer 8939ad2b2a Xi: return error values to client from XIWarpPointer.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2009-09-03 09:44:20 +10:00
Peter Hutterer d481720c57 Xi: standardise XI2 headers.
Adding missing dix-config.h include, adding one missing header guard.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2009-09-03 08:39:27 +10:00
Peter Hutterer 377a5f655c Xi: if XISetEventMask fails, return this to the client.
The only failure point can be a BadAlloc.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2009-09-03 08:39:27 +10:00
Peter Hutterer b41db8fe46 Xi: fix broken swap code in XISelectEvents request processing.
The pointer advanced 12 bytes too short. Rather unfortunate if both the code
and the test have the same bug.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2009-09-03 08:39:27 +10:00
Peter Hutterer 727de7c90d Xi: Unify checking for invalid bits in grab masks.
Bits above XI2LASTEVENT are invalid and cause in BadValues. These checks
must be performed anywhere where a mask_len parameter is given.

This patch also adds the missing checks to grab masks.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2009-09-03 08:39:27 +10:00
Peter Hutterer 59a6d7d478 Xi: don't overrun memory for grab masks.
A grab mask provided in the request may be larger than the one used in the
server. Cut down to size before memcopying.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2009-09-03 08:39:27 +10:00
Peter Hutterer 83db2b126e Xi: don't try to set oversized or non-existing masks.
Fixes crash if the first XISelectEvents has a zero sized event mask.
Fixes crash if the mask provided is larger than others->xi2mask[].

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2009-09-03 08:39:26 +10:00
Peter Hutterer 58c298acc1 Xi: extra length checking for requests providing masks.
masks can be of arbitrary length. If the client did not initialize mask_len,
some sort of boundary check is needed to avoid running over memory.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2009-09-03 08:39:26 +10:00
Daniel Stone 65183dc315 Input: Mark Xi input events as critical
Note that the Xi events are critical and should thus cause a flush to
the client when an input event is pending.

Signed-off-by: Daniel Stone <daniel@fooishbar.org>
2009-09-01 11:25:43 +10:00
Daniel Stone a4e614d301 Xi: Fix harmless ButtonPress/ButtonRelease confusion
A missing break meant that ButtonPress would fall through into
ButtonRelease, but luckily it appears to have been completely harmless.

Signed-off-by: Daniel Stone <daniel@fooishbar.org>
2009-09-01 11:25:38 +10:00
Peter Hutterer 3be80bd983 Xi: silence compiler warning "type may be used uninitialized"
GrabKey and GrabButton are only called from XI/XI2 code. Set type to -1,
just in case.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2009-08-31 09:06:36 +10:00
Peter Hutterer 903c3db1d1 Xext: rename Xtst* to XTest*
This patch corrects a misnaming of XTest-related functions.

The extension itself announces itself as XTEST. Xtst is the library name
itself, but all library functions are prefixed by XTest. Same with the
naming in the server.

- Rename all *Xtst* functions to *XTest* for consistency with the library
  and in-server API.
- Rename the "Xtst device" property to "XTEST device" for consistency with
  the extension naming.
- Rename the device naming to "<master device name> XTEST device". The
  default xtest devices become "Virtual core XTEST pointer" and "Virtual
  core XTEST keyboard".

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2009-08-27 14:24:51 +10:00
Peter Hutterer 0f9ffc887c Xi: fix XIWarpPointer up for FP3232 as input coordinates.
requires inputproto 1.9.99.902

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2009-08-25 10:24:08 +10:00
Peter Hutterer 5e96945cf5 Xi: fix swapping for XIWarpPointer and XIChangeCursor requests.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2009-08-25 10:23:58 +10:00
Peter Hutterer 80f18a7326 input: move CorePointer/KeyboardProc declarations into header.
The extern declaration in xichangehierarchy.c was broken anyway.
This fixes a crash on creating a new master device.

Reported-by: Maxim Levitsky
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2009-08-24 10:09:23 +10:00
Peter Hutterer 1b3859a49a Xi: add swapping hook for XIGetFocus reply.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2009-08-24 10:09:05 +10:00
Peter Hutterer 285c88018b Xi: correct length field for XIQueryPointer reply.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2009-08-24 10:08:12 +10:00
Peter Hutterer e4ea91a02d Xi: allow XIQueryPointer requests for master pointers and floating slaves.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2009-08-24 10:08:09 +10:00
Peter Hutterer 8e396f2b80 Xi: fix swapping for XIQueryPointer request/reply handling.
buttons_size is necessary as WriteToClient swaps the buttons_len field,
resulting in the wrong number of bytes being written later.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2009-08-24 10:07:11 +10:00
Peter Hutterer 58fd28f6b6 Xi: return deviceid as error value in XIQueryPointer.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2009-08-24 10:07:01 +10:00
Peter Hutterer 65354e5a69 Xi: return BadDevice for changing device cursors on non-master pointers.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2009-08-24 10:06:40 +10:00
Peter Hutterer 2851f04cb2 dix: rework DeviceChangedEvents a bit.
DCEs are now processed when sent throught the master device, not when sent
through the slave device. This includes a removal of some un-used (or partly
used) fields in the DCE itself to something more self-explanatory.

TODO: if a device has events queued and its attachment is changed, the DCE
is silently dropped now. Instead, it should be generated as soon as the
first event after the attachment is sent.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2009-08-17 13:25:35 +10:00
Peter Hutterer fe045820f1 input: move DeviceChangedEvent conversion into eventconvert.c
The version in eventconvert.c was half broken and for some reason we ended
up with a second version in exevents.c (which works). Move it over to where
it belongs and call EventToXI2 instad of having a custom function for it.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2009-08-17 10:14:20 +10:00
Peter Hutterer ce69a06aff Xi: fix up broken DeviceChangedEvent swapping code 2009-08-13 11:19:37 +10:00
Peter Hutterer 3f2e4b9867 Xi: add event swapping for XIRawEvents.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2009-08-13 11:19:36 +10:00
Peter Hutterer f3b2f9fb73 Xi: fix event swapping for XIDeviceEvents.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2009-08-13 11:19:36 +10:00
Peter Hutterer 3f161a0aac Xi: un-statify XI2EventSwap, it is needed for tests.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2009-08-13 11:19:35 +10:00
Peter Hutterer 55e1ea08d0 Xi: get device changed data from DeviceChangedEvents, not the device (#23100)
If a new device posts an event while the DCE is in the queue, getting the
data from the device may result in invalid memory access.

X.Org Bug 23100 <http://bugs.freedesktop.org/show_bug.cgi?id=23100>
2009-08-13 10:58:39 +10:00
Peter Hutterer 26b83ad4a2 dix: require PointerProc and KeyboardProc to be passed into AllocDevicePair.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2009-08-05 09:33:15 +10:00
Peter Hutterer 0565f4ed45 Xi: set the sourceid for focus devices to the device id.
Unlike Enter/Leave events generated by a device pushing the pointer around,
a device doesn't change focus all by itself. It's a result of a
SetInputFocus call, a window becoming unviewable or a grab activating. As
such, the sourceid for focus events is always the deviceid itself.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2009-07-30 11:04:32 +10:00
Peter Hutterer 5085ac09a5 input: switch internal event types to enums.
Use enum EventType instead of ints. This requires a load of default
cases in various switch statements to silence compiler warnings.

Reported-by: Aaron Plattner
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2009-07-30 08:43:14 +10:00
Peter Hutterer a863d63629 Xi: remove FIXME and obsolete include.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2009-07-30 08:43:14 +10:00
Peter Hutterer fac49df08f Xi: remove obsolete comment.
XI1 only uses 7 bits for deviceids, bit 8 is used for the MORE_EVENTS flag
on the wire (when DeviceValuator events are required).

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2009-07-30 08:43:14 +10:00
Peter Hutterer 4e9b2938cd include: untangle events.h from the SDK headers.
InternalEvents shouldn't be used anywhere outside the X server itself. Split
up into events.h for opaque typedefs for the events needed by various
headers and eventstr.h for the actual struct definitions.

eventstr.h must only be included by code that requires internal events and
is not part of the SDK.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2009-07-30 08:43:13 +10:00
Peter Hutterer 9a1bfa5664 input: remove XI2 keysym grabs, use keycode grabs instead.
Keysym grabs are tricky in the details, keycode grabs are known to work. So
for now, provide keycode grabs only.

Requires inputproto 1.9.99.15.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2009-07-22 12:12:51 +10:00
Peter Hutterer d040af7fa3 Update to type-specific raw events - require inputproto 1.9.99.14.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2009-07-15 10:36:30 +10:00
Peter Hutterer 7dd415aa6a Xi: use byte-counting macros instead of manual calculation.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2009-07-14 10:05:53 +10:00
Peter Hutterer 9f1570c8f4 input: include effective modifiers in device events.
Require inputproto 1.9.99.13

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2009-07-12 16:57:08 +10:00
Peter Hutterer e13605ea40 dix: introduce "Xtst Device" label property.
Xtst devices get this property assigned automatically so they can be
detected easily by a client.
The property is read-only.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2009-07-01 08:46:31 +10:00
Peter Hutterer 0814f511d5 input: store the master device's ID in the devPrivate for XTest devices.
Rather than storing a simple boolean in the devPrivate for XTest devices,
store the actual master device's id (since it is constant for the life of
the device anyway).

Callers should use GetXtstDevice now instead of digging around in the
devPrivates themselves.

This patch allows for a cleanup in the creation of new master devices since
GetMaster and GetXtstDevice spare the need for loops, IsPointer checks and
similar.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Acked-by: Benjamin Close <Benjamin.Close@clearchain.com>
2009-07-01 08:46:31 +10:00
Peter Hutterer 1bcc0d3c24 input: abstract Xtst device lookup
The callers should need to use the dev privates key to look up xtest
devices.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Acked-by: Benjamin Close <Benjamin.Close@clearchain.com>
2009-07-01 08:46:31 +10:00
Eamon Walsh 84662e40c3 Xi: check for GetAttr permission when listing or querying devices.
If the check fails, leave the device off the returned list of info
structures.  Under XI2, this may cause inconsistent views of the device
topology after a change (for example, devices disappearing from view,
or showing as attached to a master that cannot be seen).  More work is
needed to deal with topology changes and device relabeling.

Signed-off-by: Eamon Walsh <ewalsh@tycho.nsa.gov>
2009-06-23 21:15:27 -04:00
Eamon Walsh 00bc8d34c6 Xi: check for Use permission on the device in SetClientPointer().
Presumably, some intelligent, XI2-aware management app will be calling
XISetClientPointer on behalf of other clients; this check makes sure
the target client has permission on the device.

Requires changing the prototype to return status code instead of Bool.

Signed-off-by: Eamon Walsh <ewalsh@tycho.nsa.gov>
Acked-by: Peter Hutterer <peter.hutterer@who-t.net>
2009-06-23 20:50:29 -04:00
Eamon Walsh 119b966677 Xi: fix up access modes for calls to dixLookupDevice().
New access modes are being passed to the device access hook for XI2:
DixCreateAccess for creating a new master device;
DixAdd/RemoveAccess for attaching/removing slave devices to a master; and
DixListProp/GetProp/SetPropAccess for device properties.

Refer to the XACE-Spec document in xorg-docs, section "Device Access."

Signed-off-by: Eamon Walsh <ewalsh@tycho.nsa.gov>
2009-06-23 20:50:29 -04:00
Eamon Walsh 30df49f549 Xi: fix 2 memory leaks.
In ProcXIQueryDevice() and XISendDeviceHierarchyEvent().

Signed-off-by: Eamon Walsh <ewalsh@tycho.nsa.gov>
2009-06-19 20:29:52 -04:00
Peter Hutterer e92dcb6ce0 input: unify button numbers on master devices.
Master devices provide the union of all attached slave devices' buttons,
i.e. the number of buttons on the master device is always the number of
buttons of the slave device with the highest number of buttons. When slaves
are attached or detached, the master device adjusts the button number to
reflect the new buttons.

On a slave switch, this slave's button labels are copied into the master (up
to slave->num_buttons). The remaining button labels (if any) stay as they
are. Thus, if any of the higher buttons is still pressed, it reflects the
label of the last pressed device that provided this button.

If two devices press the same button and it is differently labelled the last
pressed one will be reflected in the master device.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2009-06-18 15:50:47 +10:00
Peter Hutterer 09cef75739 Xi: valuator/button labels are called labels now, not 'names'
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2009-06-18 14:41:49 +10:00
Peter Hutterer bc2ff53650 Xi: copy the valuator mode from SD to MD.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2009-06-18 14:41:49 +10:00
Peter Hutterer 87d1f44bad Xi: copy the button and axes labels into the XIQueryDevice reply.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2009-06-18 14:41:49 +10:00
Peter Hutterer a30fef9956 input: Add labels to buttons and valuators - ABI_XINPUT_VERSION 7
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2009-06-18 14:41:47 +10:00
Peter Hutterer 17f9723f48 input: bump to ints for deviceids - XI2 requires 16-bit deviceids.
Note: ABI break, but ABI_XINPUT_VERSION has NOT been bumped. Recompile input
drivers.

Revert "Xi: return BadImplementation for deviceids 256 and above"
This reverts commit 2b459f44f3.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2009-06-18 14:40:54 +10:00
Peter Hutterer cbeb73e205 Xi: return current valuator values in XIQueryDevice.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2009-06-18 14:40:54 +10:00
Peter Hutterer 80837dbefd input: change axisVal from uint to double.
With subpixel support, uint just doesn't cut it.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2009-06-18 14:40:53 +10:00
Peter Hutterer 25b6fc4a42 Xi: last_valuator is used like an index, so range it accordingly.
The previous code would always skip the last valuator due to a wrong
upper boundary in the loop. last_valuator is the index of the last set
valuator - which also means it must be initialized to -1, not 0.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2009-06-18 14:40:53 +10:00
Peter Hutterer 3fc762ea94 Xi: Motion events update the device state too.
Without this line the device's axis values don't get updated properly for
pure motion events.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2009-06-18 14:40:53 +10:00
Peter Hutterer ad6347afea Xi: don't use a constant number for class sizes - use sizeof instead
The protocol is still changing, and having to debug crap like this is
annoying.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2009-06-18 14:40:53 +10:00
Peter Hutterer d5a15e65b7 Xi: include button state in XIButtonInfo.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2009-06-18 14:40:50 +10:00
Peter Hutterer 01241b4247 Xi: Add support for sourceid in the device classes. 2009-06-17 11:21:19 +10:00
Peter Hutterer d230742ea8 Xi: namespace XI2 files.
Some files (notably those merged with MPX before XI2 came along) didn't use
a 'xi' prefix. This patch changes all of them to meaningful names.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2009-06-17 09:05:22 +10:00
Peter Hutterer 1d20b9021e Xi: fix wrong bit->byte conversion in ProcXIQueryPointer
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2009-06-14 18:47:22 +10:00
Peter Hutterer 9afc3241c1 Xi: remove un-used IsOn macro.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2009-06-14 18:47:21 +10:00
Peter Hutterer b67ff1d6e0 Xi: XISelectEvents/XIGetSelectedEvents use 'win' instead of 'window' now.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2009-06-14 11:34:35 +10:00
Peter Hutterer 5e0ca6fabd input: remove un-used "setter" argument from SetClientPointer.
It's obsolete, not likely to come back, let's drop it.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2009-06-12 12:37:16 +10:00
Peter Hutterer e6a18762ef Xi: fix XISetClientPointer return values.
If SetClientPointer fails, the only reason may be that the device is not a
pointer or that the device is an SD. Return BadDevice instead of BadAccess.
(BadAccess is a leftover from the early times of the ClientPointer
implementation when only one client was allowed to set it).

If the window parameter doesn't name a valid window or client, return
BadWindow.

Finally, allow both master keyboards and master pointers as deviceid.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2009-06-12 12:37:16 +10:00
Peter Hutterer ae7dab2a13 Xi: Fix XISetClientPointer swapping.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2009-06-12 12:37:16 +10:00
Peter Hutterer 98e8ec8deb Xi: sanitize ProcXIGetClientPointer.
This was quite old code and can be streamlined a bit. The new code is
essentially the same as in ProcXISetClientPointer.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2009-06-12 12:37:16 +10:00
Peter Hutterer 96ea82fdac Xi: fix reply swapping in XIGetClientPointer.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2009-06-12 12:37:16 +10:00
Peter Hutterer a85d210b34 Xi: store mask_len before swapping in ProcXIGetSelectedEvents.
Swapping the mask_len and then advancing the pointer by the swapped length
is just a bad idea.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2009-06-11 13:42:50 +10:00
Peter Hutterer 5043f42f36 Xi: correct return buffer size for XIGetSelectedEvents.
The maximum number of bytes is calculated by the mask len, and the mask len
is always in 4-byte units. XI2MASKSIZE however is in bytes.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2009-06-11 13:42:50 +10:00
Peter Hutterer fcf0c0b8f3 Xi: XISetEventMask needs to clear the mask if len is 0
zero-length masks are supposed to clear the device's mask.
ProcXISelectEvents passes these masks through directly, so we need to clear
the bits here if such a mask is supplied.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2009-06-11 13:42:50 +10:00
Peter Hutterer 22b4ac44e4 Xi: XIGetSelectedEvents mustn't returned masks from non-existing devices.
Or devices the client doesn't have XACE permissions for.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2009-06-11 13:42:49 +10:00
Peter Hutterer 7868956b0f Xi: ProcXIGetSelectedEvents must use WriteToClient for swapped data.
The data is already swapped before, so we just post it to the client as-is,
without attempting to swap it again.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2009-06-11 13:42:49 +10:00
Peter Hutterer aa2babf11c input: remove dependency on XI2 protocol for XI_LASTEVENT.
inputstr includes XI2proto.h for the sole purpose of XI_LASTEVENT.
However, using XI_LASTEVENT in the server is prone to errors, if the server
is recompiled against a newer version of the protocol it would bump this
variable and associates bits, including potential ABI.

This patch defines an XI2LASTEVENT for use in the server and removes the
XI2proto.h require. XI2LASTEVENT is the current value of XI_LASTEVENT.

This patch is required by components that require access to inputInfo
(currently xf86-video-geode and xf86-video-cirrus) but should not have a
require for the XI2 protocol.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2009-06-11 13:42:49 +10:00
Peter Hutterer 77cc816da4 Xi: rename ProcXISelectEvent to ProcXISelectEvents.
The request name has the plural, so let's do it here too. Purely cosmetic
change.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2009-06-11 13:42:49 +10:00
Peter Hutterer 9563feeeb5 Xi: start checking for invalid mask bits _after_ LASTEVENT.
Two issues that combined to false positives and false negatives.
- The checking for invalid bits must be performed when there are enough bits
that an event outside of LASTEVENT may be selected.
- The first invalid bit is LASTEVENT + 1, not LASTEVENT.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2009-06-11 13:39:48 +10:00
Peter Hutterer e2fbaebb87 Xi: XISelectEvents returns BadValue for num_masks == 0.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2009-06-11 13:39:48 +10:00
Peter Hutterer cfeb65ac45 Xi: XISelectEvents needs to be at least size 3, not exactly.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2009-06-11 13:39:48 +10:00
Peter Hutterer f3c26034ec Xi: XIQueryDevice should use XIFooClass instead of the old FooClass defines.
This is merely a cosmetic change, the actual values are the same anyway.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2009-06-11 13:39:48 +10:00
Peter Hutterer 482cc72aa7 Xi: get the class length before swapping.
Advancing by the already-swapped length lets our pointers point into
nirvana.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2009-06-11 13:39:48 +10:00
Peter Hutterer 9974249980 Xi: Swapping 32 bit keycodes requires swapl, not swaps.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2009-06-11 13:39:47 +10:00
Peter Hutterer c5bebca46f Xi: hierarchy events have a num_info now instead of num_devices.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2009-06-09 10:34:31 +10:00
Peter Hutterer 810b74dbbc Xi: change from XICreateMaster to XIAddMaster for consistency.
add/remove is used for slave devices and hierarchy flags.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2009-06-09 10:34:30 +10:00
Peter Hutterer 0e66a443a0 Xi: return BadValue for XI_HierarchyChangd mask on devices.
This mask may only be selected for XIAllDevices.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2009-06-09 10:34:30 +10:00
Peter Hutterer d770d57f17 Xi: fix XIQueryVersion major/minor swapping.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2009-06-05 16:09:09 +10:00
Peter Hutterer 17d62306b6 Xi: add XIQueryVersion reply swapping hook.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2009-06-05 16:09:09 +10:00
Peter Hutterer 2b459f44f3 Xi: return BadImplementation for deviceids 256 and above
The protocol allows for 16 bit device ids, but the implementation doesn't
yet. We need to break the input ABI once more to shift the DeviceIntRec's
CARD8 to a CARD16, along with some changes in the privates.

Once that is done, revert this patch.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2009-06-05 16:09:09 +10:00
Peter Hutterer c77f42049f Xi: fix flawed logic in XIQueryVersion return value.
The server returned the minimum of major/minor each instead of the lower of
the combined major.minor version. As a result, a client reporting
3.0 and a server supporting 2.7, the return value would be 2.0 (the minimum
of both).

Reported-by: RĂ©mi Cardona
Reported-by: Simon Thum
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2009-06-05 16:09:09 +10:00
Peter Hutterer 2bda50ee14 Xi: memset the device name padding to 0.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2009-06-04 15:11:09 +10:00
Peter Hutterer 09266d6cd1 Xi: XIQueryVersion requires major_version of 2 or higher.
Otherwise, a BadValue error is sent.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2009-06-04 15:11:09 +10:00
Peter Hutterer 6ea76c5504 Xi: reply with the XI2 version that is supported by both client and server.
XIQueryVersion must return the client's version if the client's version is
lower than or equal to the server's version, or the server's version
otherwise.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2009-06-04 15:11:07 +10:00
Peter Hutterer a1d1dd06f8 Xi: fix wrong grabtype from ProcXGrabDevice.
86077f0058ce88ee9b3df5d1ab854eeca43 switched from a boolean to a grabtype
enum. ProcXGrabDevice didn't switch with it. PickPointer during an XI grab
on a slave device would thus return a wrong (or NULL) device and crash the
server.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2009-06-03 12:17:54 +10:00