Commit Graph

337 Commits

Author SHA1 Message Date
Alan Coopersmith
13c8bd3fde CloseDevice: call XkbRemoveResourceClient before freeing key class struct
XkbRemoveResourceClient() returns immediately if dev->key is NULL.
CloseDevice calls XkbRemoveResourceClient until it removes all resources.

If we free dev->key and NULL it before XkbRemoveResourceClient, then
infinite loop ensues, and the server appears to hang on exit or crash.

Signed-off-by: Alan Coopersmith <alan.coopersmith@sun.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Daniel Stone <daniel@fooishbar.org>
Signed-off-by: Keith Packard <keithp@keithp.com>
2010-01-04 18:48:18 -08:00
Peter Hutterer
66bb8c6fbd dix: remove core devices when shutting down. (#25028)
NewInputDeviceRequest (and RemoveDevice) have checks in place to not allow
removal of the VCP/VCK. When shutting down, they need to be cleaned up
nonetheless to free the memory associated.

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

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Keith Packard <keithp@keithp.com>
2009-12-03 08:24:04 +10:00
Peter Hutterer
83d90b90bc dix: remove some obsolete comment.
The "counterpart to biggest hack" included checking for the motion history
function - which is unified in 1.7. Hence the check (which is already
removed) would evaluate to true anyway, and this comment isn't needed.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Keith Packard <keithp@keithp.com>
2009-12-03 08:24:03 +10:00
Peter Hutterer
0e6cee853d dix: clean up accel old scheme data when switching schemes.
InitValuatorClassDeviceStruct always initializes with the default profile.
The default profile allocs data and adds a few properties which become
obsolete if the profile is changed lateron by the driver.

The property handlers are stored in the device's devPrivates and cleaned up.
Ideally, the property handler ID's could be stored somewhere more obvious,
but that seems to require breaking the ABI.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Acked-by: Simon Thum <simon.thum@gmx.de>
2009-11-25 10:57:07 +10:00
Peter Hutterer
982f6648fd dix: increase default number of buttons to 10.
Currently the XTEST device is limited to the same number of buttons the core
device has. This breaks if a user has a mouse with more than 3 buttons
connected and is using a core client to fake button 8+ presses.

Rather than expecting all clients to fix themselves, just increase the
default number of buttons to 10, which is somewhat a compromise. Ideally,
the XTEST devices should adjust themselves to the highest number of buttons
available on the slave devices (like the master pointers already do), but
that's a taks for another day.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Signed-off-by: Keith Packard <keithp@keithp.com>
2009-11-10 18:33:01 -08:00
Jon TURNEY
909df9beb3 Resolve an inconsistency between libX11 and Xserver over GetModifierMapping
libX11 ModMap.c believes that GetModifierMapping can never return an error

Xserver devices.c believes that GetModifierMapping can return an error if
the ModMap couldn't be generated

According to the protocol document I have, libX11 is right, so adjust the
server to send back an empty modmap if one couldn't be made...

http://bugs.freedesktop.org/show_bug.cgi?id=24621

Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
Signed-off-by: Keith Packard <keithp@keithp.com>
2009-10-22 10:32:25 +09: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
Keith Packard
8b5086250a Eliminate bogus event resizing.
Now that all event queues hold internal events only, they never need
to be resized. Resizing them led to memory corruption as they would
get sized for an appropriate xEvent, not an internal event.

Signed-off-by: Keith Packard <keithp@keithp.com>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2009-09-20 20:45:24 +10:00
Peter Hutterer
ec0ad408ef xfree86: use SendDevicePresenceEvents instead of manual event handling.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2009-09-18 08:23:33 +10:00
Peter Hutterer
744cdc8977 dix: Remove two _X_EXPORT defines from the function definition.
These two are defined _X_EXPORT in their declaration anyway.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2009-09-10 09:48:00 +10:00
Peter Hutterer
97e3f4316b dix: auto-float SD's with SendCoreEvents "false"
AlwaysCore and SendCoreEvents specify whether a device is to send core
events. A device that has either disabled is not supposed to send core
events.

With MPX/XI2, a device that is attached automatically sends core events when
the event is routed through the master device. Floating a slave device
disables core events by breaking the route.

This patch automatically floats devices that have coreEvents disabled in the
xorg.conf/HAL. This replicates the behaviour of a SendCoreEvents "false"
device in server 1.6 and earlier.

The devices may still be reattached to a master at runtime.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2009-09-09 10:31:23 +10:00
Peter Hutterer
d8aadfa5af dix: remove unused and half-broken code to restore original classes.
In theory, the MD should change back to its old, original classes when the
last SD is detached. Thanks to the XTEST devices, we'll always have an SD
attached until the MD is removed.  So let's not worry about that and do
nothing instead of having some code that's essentially untested.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2009-09-09 10:31:11 +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
8bfd23e144 input: move XTest device initialization into Xext/xtest.c
XTest devices are non-optional but nonetheless specific to the XTEST
extension.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2009-08-27 14:24:50 +10:00
Peter Hutterer
a95f80fa91 dix: use IsXtstDevice instead of the direct key lookup.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2009-08-27 14:24:50 +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
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
d3e5629fac dix: call SetFocusOut and LeaveWindow when disabling a device.
PointerWindows[x] would be set after removing a master pointer. Destroying
this window then crashed the server.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2009-08-03 10:11:48 +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
2d35ea8d95 dix: switch to byte-counting functions.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2009-07-14 10:05:54 +10:00
Peter Hutterer
2c535b6f13 dix: don't send presence events for attaching/detaching slave devices.
The code that didn't list attached slave devices for XI1 clients doesn't
exist anymore, so there's no need for these presence events.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2009-07-14 09:00:35 +10:00
Peter Hutterer
183c075d2f dix: always init the full button map to default values (#22594)
Master devices must have the standard button map applied for all buttons to
ensure buttons larger than 7 (the default for MDs) are mapped appropriately.

We can't copy the button map from SDs to MDs since that breaks the chained
button mapping. However, by ensuring all buttons (even non-existing ones)
are mapped, devices that send such buttons continue to work.

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

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2009-07-06 12:58:03 +10:00
Peter Hutterer
50a2a8dc76 Fix IsXtstDevice - returns false positives since 0814f511d5.
Missing check for the value of 'mid' returned false positives if master was
NULL.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2009-07-03 09:20:59 +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
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
280b7f92d7 dix: reduce MDs and xtest pointers to 7 buttons by default.
MD's will soon be the union of all devices anyway. XTest pointers are only
for the core protocol XTest stuff, so 7 buttons (lmr + 4 wheel buttons)
should do.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2009-06-18 14:41:50 +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
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
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
9390b7a133 dix: protect against missing ButtonClasses in GetPointerMapping.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2009-06-07 20:35:14 +10:00
Simon Thum
bb1c131b78 dix: suppress pointer acceleration on xtest devices
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2009-06-07 09:31:08 +10:00
Peter Hutterer
ebe45e1a72 input: introduce partial class copying depending on the event.
Copying all classes into the master device has drawbacks for hybrid devices
(devices that are both mice and keyboards). If such a device posts an event,
it's key classes are moved into the VCP. The key event itself is unaffected
by keyboard grabs and the like.

Partial class copying copies depending on the event and copies the classes
into the right master device (i.e. the VCK for key events, the VCP for
pointer events).

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2009-05-22 15:44:57 +10:00
Peter Hutterer
bc63c8a457 dix: introduce GetMaster()
For hybrid devices (keys + buttons/axes) the attached master device is
generally the wrong one. One shouldn't post a button event through a
keyboard and vice versa.

GetMaster(dev) returns the right master device for the given type needed.
This may be the MD paired with this device's MD.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2009-05-22 15:44:57 +10:00
Peter Hutterer
b12d302df8 Input: rename DeviceIntRec->isMaster to ->type.
isMaster is not enough as long as we differ between master pointers and
keyboard. With flexible device classes, the usual checks for whether a
master device is a pointer (currently check for ->button, ->valuators or
->key) do not work as an SD may post an event through a master and mess this
check up.

Example, a device with valuators but no buttons would remove the button
class from the VCP and thus result in the
IsPointerDevice(inputInfo.pointer) == FALSE.

This will become worse in the future when new device classes are introduced
that aren't provided in the current system (e.g. a switch class).

This patch replaces isMaster with "type", one of SLAVE, MASTER_POINTER and
MASTER_KEYBOARD. All checks for dev->isMaster are replaced with an
IsMaster(dev).
2009-05-22 15:44:50 +10:00
Peter Hutterer
add2defac7 Split the signal-handler's lastSlave out into a separate variable.
dev->u.lastSlave was not signal safe since it was accessed by the DIX and
during signal handling.
Replaced with:
'dev->last.slave' for the signal handler's lastSlave (used to generate
                  DeviceChangedEvents), .
'dev->u.lastSlave' for the DIX lastSlave (currently only used in
                   change_modmap)

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2009-05-22 15:44:03 +10:00
Peter Hutterer
7b891e450f dix: Remove obsolete comment
CorePointerProc doesn't back up the device classes anymore.
2009-05-20 16:22:24 +10:00
Peter Hutterer
273890924b input: reduce the number of superfluous hierarchy events
There's only two reasons for hierarchy events:
- device is added, removed, etc. In this case we want to send the event as
  it happens.
- devices are added in a XIChangeDeviceHierarchy request. In this case we
  only want one event cumulating all changes.
2009-05-16 12:20:58 +10:00
Peter Hutterer
033a2b12fc Xi: set per-device hierarchy changed flags.
Rather than have one field per hierarchy change, XI2 has two fields - one
generic one and one per-device that include the device-specific flags.
This requires some funky handling for removed devices, but oh well.
2009-05-16 12:20:58 +10:00
Peter Hutterer
fdce58ca82 dix: ensure Activate/DeactivateGrab has a valid value.
Xephyr doesn't manually set Activate/DeactivateGrab for new devices,
resulting in a NULL-pointer dereference later when a grab is activated.
Avoid the segfault by ensuring that the pointer is always valid.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2009-05-16 12:20:58 +10:00
Peter Hutterer
bae070914f input: update to inputproto 1.9.99.8 XI2 defines.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2009-05-08 14:33:44 +10:00
Peter Hutterer
057fc9a4f8 Merge branch 'master' into xi2
Conflicts:
	Xi/chdevhier.c
	include/input.h
2009-04-24 16:15:47 +10:00
Benjamin Close
fab563bf8f input: propagate XTst events through virtual slave devices.
A XTest virtual slave device pair (kbd/ptr) exists for every master
device pair. This is so XTest events are correctly propogated via slave
devices up to Master devices and the classes are correctly changed along
the way. We add the XTest slave device pair to the Virtual Core pointer
and provide a simple way of creating the devices.

A XTest Slave Device is identified by the XTstDevicePrivateKey property
being set in the devices devProperties

XI events are still propagated through the matching device, in the hope the
client knows what it is doing.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2009-04-24 15:28:33 +10:00
Benjamin Close
826a5bff01 dix: Change AllocMaster into AllocDevicePair, allow creation of SDs too.
Allocating a slave device is essentially the same as allocating a master device.
Hence we rename AllocMaster to AllocDevicePair and provided the ability to
indicate if a master or slave device pair is required.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2009-04-21 13:11:51 +10:00
Peter Hutterer
e2e5932bda dix: don't allow more than MAX_VALUATORS on one device.
Some keyboards (?) advertise more than MAX_VALUATORS axes. Parts of the
internal event delivery relies on not having more than MAX_VALUATOR axes, so
let's cap it down.
If there's real devices that require more than the current 36, I'm sure we can
bump this up.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2009-04-21 13:11:51 +10:00
Peter Hutterer
d5ad14c8ed Merge branch 'master' into xi2 2009-04-19 22:28:22 +10:00
Peter Hutterer
74d0fc3aee dix: don't allow more than MAX_VALUATORS on one device.
Some keyboards (?) advertise more than MAX_VALUATORS axes. Parts of the
internal event delivery relies on not having more than MAX_VALUATOR axes, so
let's cap it down.
If there's real devices that require more than the current 36, I'm sure we can
bump this up.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2009-04-19 22:28:11 +10:00