Commit Graph

7711 Commits

Author SHA1 Message Date
Peter Hutterer
b25e29e801 mi: use GetMaster() from MIPOINTER and MISPRITE.
Both may in some cases be called for a SD attached to a master keyboard. In
this case, we need to get the right master device (i.e. the pointer).

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2009-05-22 15:44:57 +10:00
Peter Hutterer
c9df51b070 input: allow for master pointers to not have a button class.
There's devices (e.g. some barcode readers) that have axes but no buttons.
When such a device sends a motion event, the valuator and button class is
copied into the master pointer (i.e. removing the button class).
So we need a couple of extra sanity checks for the button class to exist.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2009-05-22 15:44:57 +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
d79318f269 dix: Add a deviceid to the DeviceChangedEvent.
ChangeDeviceId would actually overwrite the flags field if deviceid wasn't
present. Aside from the event of course not telling which device generated
it in the first place.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2009-05-22 15:44:57 +10:00
Peter Hutterer
eeffb83fea ABI_XINPUT_VERSION 6 2009-05-22 15:44:57 +10:00
Peter Hutterer
438a4eafa5 input: remove nested union from InternalEvent.
There's no need for internal events to be a struct with a single nested
union, we might as well make the union itself the InternalEvent.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2009-05-22 15:44:56 +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
73c7398aaf dix: 'namespace' HAS_OLD_SLAVE and HAS_NEW_SLAVE.
We need more flags for this in the near future, so let's namespace them now.
2009-05-21 11:59:17 +10:00
Peter Hutterer
5b5e3fa277 xfree86: treat other drivers as mouse drivers in the config.
Historically, if no input device was referenced in the ServerLayout,
the server would pick the first "mouse" device found in the xorg.conf.
This patch gives evdev, synaptics, vmmouse and void the same status. If
there is a section in the config file using this driver - use it as the core
pointer.

Device selection is in driver-order, not in config-order. If a "mouse"
device is listed after a "synaptics" device, the "mouse" device gets
preference. This replicates the original behaviour.

This code only takes effect if AllowEmptyInput is off and there is no core
pointer in the server layout.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2009-05-21 11:59:16 +10:00
Peter Hutterer
1cce55cc03 input: rename device->type to device->xinput_type.
This type is only used in XI to give a hint of what type this device may be.
Call it xinput_type for clarity.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2009-05-21 10:42:35 +10:00
Tomas Janousek
81b3b0cce0 Bug #6428, #16458, #21464: Fix crash due to uninitialized VModMap fields.
In ProcXkbGetKbdByName, mrep.firstVModMapKey, .nVModMapKeys and
.totalVModMapKeys were not initialized, contained random values and caused
accesses to unallocated and later modified memory, causing
XkbSizeVirtualModMap and XkbWriteVirtualModMap to see different number of
nonzero values, resulting in writes past the end of an array in XkbSendMap.

This patch initializes those values sensibly and reverts commits 5c0a2088 and
6dd4fc46, which have been plain non-sense.

Signed-off-by: Tomas Janousek <tomi@nomi.cz>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2009-05-21 10:42:35 +10:00
Peter Hutterer
c2785ae7eb dix: refuse events from disabled devices.
If the device is disabled ("off"), it must not send events to a client.
The driver shouldn't send events in that case anyway, but just to make sure
we simply drop events coming while the device is disabled.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2009-05-20 16:22:24 +10:00
Peter Hutterer
47a89b1cba Xi: remove DeviceIsPointerType
This approach is broken anyway. DIPT only checked for the XInput type
"MOUSE" and the only user of this is xf86ActivateDevice when it sets the
Activate/DeactivateGrab functions.
Since synaptics and wacom set their own types, evdev only sets MOUSE for,
well, mice half the devices didn't have this set correctly anyway.

Instead, ActivatePointerGrab should be merged together with
ActivateKeyboardGrab.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2009-05-20 16:22:24 +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
42719ce5c7 dix: remove superfluous loop in change_modmap.
A device can only be attached to a single master device. So instead of
looping and searching for the master device, we can just use dev->u.master
directly.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2009-05-20 16:22:24 +10:00
Peter Hutterer
b89dcfbfbd Xi: fix length field in XIQueryPointer.
Buttons append 4-byte units to the end of the reply, they need to be
included too.

Reported-by: Mark Dokter
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2009-05-18 16:30:12 +10:00
Peter Hutterer
33fcaaaea5 Fix missing parentheses in FP1616 macro.
Missing parens led to interesting results if an expression instead of a
constant was passed in (ProcXIQueryPointer for example).
2009-05-18 16:05:35 +10:00
Peter Hutterer
6258bb1d6b require inputproto 1.9.99.9 2009-05-16 12:20:59 +10:00
Peter Hutterer
e7e94ff5fd Xi: set the right length for the XIQueryPointer reply. 2009-05-16 12:20:59 +10:00
Peter Hutterer
00ab04d73c Include full modifier + button state in XIQueryPointer. 2009-05-16 12:20:59 +10:00
Peter Hutterer
de78aab0ea Xi: take the paired device as modifier device only for MD pointers. 2009-05-16 12:20:59 +10:00
Peter Hutterer
0e089f9ceb Xi: check cursor and grab_window before attempting the passive grab.
Both values need to fail the request, so we need to check them before
looping through the modifier masks. Otherwise, a wrong grab_window will
show up in each failed modifier return but not actually cause an error.
2009-05-16 12:20:59 +10:00
Peter Hutterer
5c3e728980 dix: count must be 1 if we have an XI2 match.
This fixes events that activated a grab not getting delivered to the client.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2009-05-16 12:20:59 +10:00
Peter Hutterer
e083a0d069 Xi: set the correct length for XIPassiveGrab replies. 2009-05-16 12:20:58 +10:00
Peter Hutterer
8ff1bff8f4 Update to new XI2 names 2009-05-16 12:20:58 +10:00
Peter Hutterer
bbf266cca3 mi: un-deprecate miPointerWarpCursor
This function was deprecated in ef68273f5b
because it didn't take a device argument. The device argument was added in
1c7568b8a1 though, so the deprecation is
obsolete.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2009-05-16 12:20:58 +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
8fb51feae2 xkb: if kbd init failed, NULL out the pointers after freeing them (#21278)
Reproducible:
Configure a server that uses the keyboard driver with an invalid ruleset,
e.g. (Option "XkbRules" "foobar"). Ensure that Option "AllowEmptyInput" is
"off" in the ServerFlags or ServerLayout section. Start the server.
After failing to init the keymap, the server will try to clean up after the
device, double-freeing some xkb structs that have not been reset properly.

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

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2009-05-16 12:20:58 +10:00
Peter Hutterer
0cea199eda kdrive: set Activate/Deactivate grab for input devices (#21591)
X.Org Bug 21591 <http://bugs.freedesktop.org/show_bug.cgi?id=21591>
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
e3f296d91d xfree86: Remove superfluous ifdef DEBUG checks.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2009-05-16 12:20:57 +10:00
Peter Hutterer
9c5b761c8c Revert "xkb: write the _XKB_RF_RULES_PROP to each device."
This commit shouldn't have been pushed, we're still sorting out the API we
want to use.

This reverts commit 876910a951.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2009-05-09 16:19:42 +10:00
Peter Hutterer
00bc043fa0 dix: export subpixel precision in XI2 events for root/event coordinates.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2009-05-08 14:33:50 +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
83f32d3972 Xi: Add XI2 property requests. 2009-05-08 14:33:23 +10:00
Peter Hutterer
9935bec6e8 Xi: split some code out of the XI 1.5 property request processing.
This is in preparation for the XI2 property requests that can re-use much of
this code.
2009-05-08 14:33:23 +10:00
Peter Hutterer
f6f1e41706 Xi: fix copy/paste error causing sizeof against wrong struct.
This wrong check may cause BadLength to be returned to the client even if the
length is correct.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2009-05-08 14:33:23 +10:00
Peter Hutterer
fc0013d744 Xi: don't double-swap the XListDeviceProperties reply.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2009-05-08 14:33:23 +10:00
Peter Hutterer
409012061b Xi: add missing break in XI event swapping function
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2009-05-08 14:33:23 +10:00
Peter Hutterer
c3c64978c4 Xi: fix a couple of wrong dixLookupDevice permission tags.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2009-05-08 14:33:23 +10:00
Peter Hutterer
0d947aa8e8 xfree86: fix xf86PostMotionEventP type checking
We only put internal events into the queue now, so let's check for ET_Motion
rather than the MotionNotify.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2009-05-08 14:33:23 +10:00
Simon Thum
9457ce4489 dix: remove superfluous includes from ptrveloc.c
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2009-05-08 14:33:22 +10:00
Simon Thum
ee30e1b102 dix: fix warning in pointer acceleration
newer gcc's warn against how this cast is done (though it eludes me why),
and lrintf() is also faster especially on insane processors like the P4
(http://www.mega-nerd.com/FPcast).

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2009-05-08 14:33:22 +10:00
Peter Hutterer
d220d6907d Xi: add GrabButton and GrabKeysym code.
We don't do keycode grabs in XI2, they're pointless.
2009-05-06 14:37:33 +10:00
Peter Hutterer
1b593ced17 Xi: access the prev_state to get group/modifier state for key events.
Key events may change the modifier state, so we need to get the prev_state for
those (i.e. without the changes by the event already applied).

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2009-05-06 14:37:32 +10:00
Peter Hutterer
35a4b8e7f4 xkb: remove oldState from XkbHandleActions.
I really don't know what the purpose of this variable is or was, aside from
potentially clobbering up our key state since there's a path where it may be
used uninitialised.

Also, this means that xkbi->prev_state is now accessible from the DIX with
meaningful data.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2009-05-06 14:37:32 +10:00
Peter Hutterer
d523fbe428 test: add test for xi2 struct sizes. 2009-05-06 14:37:22 +10:00