Commit Graph

68 Commits

Author SHA1 Message Date
Povilas Kanapickas 5163fc8bc2 Implement gesture processing logic 2021-05-30 13:26:42 +03:00
Povilas Kanapickas 100a2ad6da dix: Implement gesture event submission code path 2021-05-30 13:26:40 +03:00
Povilas Kanapickas 56d7205921 dix: Extract DeliverDeviceClassesChangedEvent() utility function 2020-11-25 04:20:21 +00:00
Povilas Kanapickas 5b0c5344b7 dix: Extract CopySprite() utility 2020-11-25 04:20:21 +00:00
Adam Jackson 03b2125005 dix: Remove LegalModifier()
This hasn't done anything besides return TRUE in a long long time.

Reviewed-by: Eric Anholt <eric@anholt.net>
Signed-off-by: Adam Jackson <ajax@redhat.com>
2018-09-28 16:25:17 -04:00
Peter Hutterer 4fe02b8da3 dix: check_modmap_change() returns Success, not true
Not sure what if anything calls XSetDeviceModifierMapping() but this would've
failed all the time. check_modmap_change() returns Success but we were
treating it like a boolean. Fix this.

Reported-by: Adam Jackson <ajax@redhat.com>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Keith Packard <keithp@keithp.com>
2018-08-08 09:45:27 -04:00
Jonas Ådahl 0fae3be068 dix: Add valuator_mask_set_absolute_unaccelerated
Add a valuator mask setter for setting absolute coordinate combined
with unaccelerated motion deltas. This will later be used by Xwayland
to combine a wl_pointer.motion() event with the unaccelerated delta of
a wp_relative_pointer.relative_motion() event.

Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
2016-10-05 13:46:29 -04:00
Daniel Stone c3788394e9 Input: Add DeviceEventSource enum
Add a flag to DeviceEvents, giving the source of the event. Currently
this only supports a 'normal' flag, but will be used later to add a
'focus-in' flag, noting events synthesised from key/button arrays on
focus-in notifications.

Signed-off-by: Daniel Stone <daniels@collabora.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-11-24 11:36:32 +10:00
Peter Hutterer 4c2f2cb4c8 dix: Add unaccelerated valuators to the ValuatorMask
Allows a mask to carry both accelerated and unaccelerated motion at the same
time.

This is required for xf86-input-libinput where the pointer acceleration
happens in libinput already, but parts of the server, specifically raw events
and DGA rely on device-specific unaccelerated data.

To ease integration add this as a second set to the ValuatorMask rather than
extending all APIs to carry a second, possibly NULL set of valuators.

Note that a valuator mask should only be used in either accel/unaccel or
standard mode at any time. Switching requires either a valuator_mask_zero()
call or unsetting all valuators one-by-one. Trying to mix the two will produce
a warning.

The server has a shortcut for changing a mask with the
valuator_mask_drop_unaccelerated() call. This saves us from having to loop
through all valuators on every event, we can just drop the bits we know we
don't want.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
2015-05-20 12:44:58 +10:00
Peter Hutterer 04ca169979 dix: silence compiler warning
inpututils.c:243:26: warning: comparison of constant 256 with expression of
type 'KeyCode' (aka 'unsigned char') is always false
[-Wtautological-constant-out-of-range-compare]
        if (modkeymap[i] >= MAP_LENGTH)
                    ~~~~~~~~~~~~ ^  ~~~~~~~~~~

MAP_LENGTH depends on MAX_BUTTONS which is somewhat arbitrarily chosen. We
don't expect this to ever change, but just in case leave the condition there
so the code is correct if we drop the number down.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2014-11-12 10:25:00 +10:00
Peter Hutterer 25d10464f4 dix: fix button state check before changing a button mapping
dev->button->down is a bitmask, not a normal array. Use the helper function to
check, we technically allow the mapping to change after the physical button
has been pressed (but not yet processed yet), so only check BUTTON_PROCESSED.

From XSetPointerMapping(3):
"If any of the buttons to be altered are logically in the down state,
XSetPointerMapping returns MappingBusy, and the mapping is not changed."

Reported-by: Ilja Van Sprundel <ivansprundel@ioactive.com>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Daniel Stone <daniel@fooishbar.org>
2014-02-05 07:50:16 +10:00
Peter Hutterer ce3df579e3 input: un-constify InputAttributes
Introduced in fecc7eb1cf and reverts most of
that but it's helpfully mixed with other stuff.

InputAttributes are not const, they're strdup'd everywhere but the test code
and freed properly. Revert the const char changes and fix the test up instead.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
2014-02-04 11:27:48 +10:00
Keith Packard fecc7eb1cf xi: More warning cleanup for input
Lots more const char stuff.

Remove duplicate defs of CoreKeyboardProc and CorePointerProc from
test/xi2/protocol-common.c

Signed-off-by: Keith Packard <keithp@keithp.com>
Reviewed-by: Adam Jackson <ajax@redhat.com>
2014-01-12 10:14:50 -08:00
Adam Jackson 5ac4bfca64 input: calloc minimization for xi2mask_new
There's no reason to do this as (nmasks + 2) callocs, and it's a
surprisingly hot path.  Turns out you hit this ~once per passive grab,
and you do a few bajillion passive grab changes every time you enter or
leave the overview in gnome-shell.  According to a callgrind of Xorg
with gnome-shell-perf-tool run against it:

Ir before: 721437275
Ir after:  454227086

Signed-off-by: Adam Jackson <ajax@redhat.com>
Reviewed-by: Jasper St. Pierre <jstpierre@mecheye.net>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2013-10-14 11:07:37 +10:00
Peter Hutterer a7c97d737e dix: split xi2_mask_isset into a per-device function
For touch selection conflicts, we need to check not only if the mask is set
for the device, but if it is set for only that specific device (regardless
of XIAll*Devices)

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2012-12-12 17:25:16 +10:00
Peter Hutterer 59d70b30e9 dix: use pixman for fp1616 conversions
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Søren Sandmann <ssp@redhat.com>>
2012-11-29 14:48:54 +10:00
Alan Coopersmith 0af79b124e Use C99 designated initializers in dix Events
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Reviewed-by: Keith Packard <keithp@keithp.com>
Tested-by: Daniel Stone <daniel@fooishbar.org>
2012-07-09 22:52:30 -07:00
Keith Packard 9838b7032e Introduce a consistent coding style
This is strictly the application of the script 'x-indent-all.sh'
from util/modular. Compared to the patch that Daniel posted in
January, I've added a few indent flags:

	-bap
	-psl
	-T PrivatePtr
	-T pmWait
	-T _XFUNCPROTOBEGIN
	-T _XFUNCPROTOEND
	-T _X_EXPORT

The typedefs were needed to make the output of sdksyms.sh match the
previous output, otherwise, the code is formatted badly enough that
sdksyms.sh generates incorrect output.

The generated code was compared with the previous version and found to
be essentially identical -- "assert" line numbers and BUILD_TIME were
the only differences found.

The comparison was done with this script:

dir1=$1
dir2=$2

for dir in $dir1 $dir2; do
	(cd $dir && find . -name '*.o' | while read file; do
		dir=`dirname $file`
		base=`basename $file .o`
		dump=$dir/$base.dump
		objdump -d $file > $dump
	done)
done

find $dir1 -name '*.dump' | while read dump; do
	otherdump=`echo $dump | sed "s;$dir1;$dir2;"`
	diff -u $dump $otherdump
done

Signed-off-by: Keith Packard <keithp@keithp.com>
Acked-by: Daniel Stone <daniel@fooishbar.org>
Acked-by: Alan Coopersmith <alan.coopersmith@oracle.com>
2012-03-21 13:54:42 -07:00
Benjamin Otte b96275c4cd dix: fix an out-of-memory crash
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2012-02-08 19:06:17 +10:00
Peter Hutterer 76c11e0872 dix: button state must show the logical buttons, not physical buttons
If the device is mapped 3 2 1, a click on physical button 1 sends a button 3
press, but the state was set for button 1. Fix this, the state must be set
for that button's logical mapping.

https://bugzilla.gnome.org/show_bug.cgi?id=655928

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 634b0da9a8 dix: set core and button state based on the touch state
If a pointer-emulating touch caused a button to be logically down, set that
state in the input events.

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
Peter Hutterer 7528a6b88e Merge branch 'for-whot' of git://people.freedesktop.org/~alanc/xserver into for-keith 2011-12-13 14:19:54 +10:00
Peter Hutterer adf8a0d62c dix: move event filter retrieval helpers to inpututils.c
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-13 13:24:57 +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
Alan Coopersmith 898d976729 verify_internal_event: preserve constness of data pointer
All we're using it for is ErrorF calls, so make it a const char *
to stop gcc from warning:

inpututils.c: In function 'verify_internal_event':
inpututils.c:629:9: warning: cast discards qualifiers from pointer target type

Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Reviewed-by: Jamey Sharp <jamey@minilop.net>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
2011-12-12 17:04:33 -08:00
Peter Hutterer 27425f07b2 dix: use BUG_WARN for input mask size issues
Yes, we're likely corrupting memory here but really this is unlikely to be
triggered other than a real bug in the server. In which case a stacktrace is
going to be more useful than any silent error handling.

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 b8b90cd161 Add a new XI2Mask struct and a few helper functions.
The current XI2 mask handling is handy for copying (fixed size arrays) but a
pain to deal with otherwise. Add a struct for XI2 masks and the required
accessors.

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
Keith Packard d91aa0e660 Merge remote-tracking branch 'whot/two-screen-coordinates' 2011-11-02 21:20:07 -07:00
Peter Hutterer c39c8d3428 input: switch InputOption to use XF86OptionRec storage.
Use the same struct for both InputOption and XF86OptionRec so we don't need
to convert to and fro the two in the config backends.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Dan Nicholson <dbn.lists@gmail.com>
Reviewed-by: Daniel Stone <daniel@fooishbar.org>
2011-10-25 14:06:39 +10:00
Keith Packard 15bbdc103b Merge remote-tracking branch 'whot/for-keith' 2011-10-19 17:26:50 -07:00
Peter Hutterer 82c60232c0 dix: add valuator_mask_fetch_double()
Using this call simplifies callers that don't know if the mask bit is set.

Before:
  if (valuator_mask_isset(mask, valnum))
    value = valuator_mask_get_double(mask, valnum));
  else
    value = someothervalue;

Now:
 if (!valuator_mask_fetch_double(mask, valnum, &value))
    value = someothervalue;

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Chase Douglas <chase.douglas@canonical.com>
Reviewed-by: Daniel Stone <daniel@fooishbar.org>
2011-10-18 09:15:54 +10:00
Keith Packard 64d2d1bef1 Merge remote-tracking branch 'jeremyhu/master' 2011-10-17 14:36:34 -07:00
Jeremy Huddleston f9c6903d4a dix: add utility functions for double to/fro FP1616/FP3232 conversion
Co-authored-by: Jeremy Huddleston <jeremyhu@apple.com>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Jeremy Huddleston <jeremyhu@apple.com>
Reviewed-by: Mark Kettenis <kettenis@openbsd.org>
2011-10-15 21:15:47 -07:00
Peter Hutterer 8bebb4b489 Store desktop dimensions in screenInfo.
For Zaphod mode screen crossing handling we need to know the size of all
screens together (i.e. the whole desktop size). Store that in the screenInfo to
have it readily available in events.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2011-10-13 11:26:09 +10:00
Peter Hutterer 911e7368bf Move pointOnScreen to inpututils.c
We need this from other files too.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Daniel Stone <daniel@fooishbar.org>
2011-10-04 13:01:33 +10:00
Daniel Stone 7e919ef5bf Input: Add double-precision valuator_mask API
Add API for valuator_mask that accepts and returns doubles, rather than
ints.  No double API is provided for set_range at the moment.

Signed-off-by: Daniel Stone <daniel@fooishbar.org>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
2011-09-29 12:23:51 +10:00
Daniel Stone 79d4deb76d Input: Convert ValuatorMask to double-precision internally
Switch the ValuatorMask struct to using doubles instead of ints for the
actual values.  Preserve the old int API, and (attempt to) round towards
zero for values we return.

Signed-off-by: Daniel Stone <daniel@fooishbar.org>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
2011-09-29 12:23:51 +10:00
Peter Hutterer 05284a03f9 input: make InputOption opaque, provide interface functions.
InputOptions is not switched to use struct list for a future patch to unify
it with the XF86OptionRec.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Dan Nicholson <dbn.lists@gmail.com>
2011-08-22 15:56:53 +10:00
Peter Hutterer 3a077f246e input: provide a single function to init DeviceEvents to 0
getevents.c already had that function, but XKB was manually initializing it,
causing bugs when the event structure was updated in one place but not the
other.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2011-08-22 15:56:52 +10:00
Jeremy Huddleston ba7d1020ac input: Fix format string for verify_internal_event
inpututils.c:577:25: warning: conversion specifies type 'unsigned short' but the argument has type 'unsigned char' [-Wformat,Format String Issue]
            ErrorF("%02hx ", *data);
                    ~~~~^    ~~~~~
                    %02hhx
1 warning generated.

Signed-off-by: Jeremy Huddleston <jeremyhu@apple.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2011-05-24 14:08:13 +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 17265ccb02 Move master/lastSlave out of the union into separate fields.
The removal of the double-use will cause some suble bugs as some conditions
to check for the dev->u.master case were broken and also evaluated as true
if lastSlave was set (instead of master).

Also breaks the input ABI.

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 ce7f79efd5 dix: fix a master device access in change_modmap.
We need to check if our master keyboard is the given device since we may be
a pointer with keys and thus need to change the modmap too.

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 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 fc6cbee772 input: add valuator_mask_free() to free a valuator mask.
Expecting the caller to free the mask requires us to keep it in a single
memory block (which may be an issue lateron), aside from leaving the API
asymetrical. Provide valuator_mask_free() to free the memory and reset the
mask pointer to NULL.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Fernando Carrijo <fcarrijo@freedesktop.org>
Reviewed-by: Chase Douglas <chase.douglas@canonical.com>
2011-01-07 08:28:27 +10:00
Peter Hutterer 2362adc2da dix: remove valuator_mask_copy_valuators, not needed anymore.
With the switch to masks internally, this isn't needed anymore.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Chase Douglas <chase.douglas@canonical.com>
2010-10-22 11:02:53 +10:00
Peter Hutterer 675f4a8525 Abstract valuator masks through a set of APIs.
This commit introduces an abstraction API for handling masked valuators. The
intent is that drivers just allocate a mask, set the data and pass the mask
to the server. The actual storage type of the mask is hidden from the
drivers.

The new calls for drivers are:
    valuator_mask_new()     /* to allocate a valuator mask */
    valuator_mask_zero()    /* to reset a mask to zero */
    valuator_mask_set()     /* to set a valuator value */

The new interface to the server is
    xf86PostMotionEventM()
    xf86PostButtonEventM()
    xf86PostKeyboardEventM()
    xf86PostProximityEventM()

all taking a mask instead of the valuator array.

The ValuatorMask is currently defined for MAX_VALUATORS fixed size due to
memory allocation restrictions in SIGIO handlers.

For easier review, a lot of the code still uses separate valuator arrays.
This will be fixed in a later patch.

This patch was initially written by Chase Douglas.

Signed-off-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>
2010-10-22 11:02:48 +10:00
Chase Douglas fc48a8f9f5 Add CountBits() to the server.
Function to count the number of bits set in the given array.

Signed-off-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>
2010-10-20 09:38:27 +10:00
Adam Tkac 05e616767e Return Success from generate_modkeymap() when max_keys_per_mod is zero
max_keys_per_mod equal to zero is a valid situation so generate_modkeymap
should not return BadAlloc in this case.

Signed-off-by: Adam Tkac <atkac@redhat.com>
Reviewed-by: Patrick E. Kane <pekane52 at gmail.com>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2010-09-01 14:44:46 +10:00
Dan Nicholson 87a1507da7 xfree86: Match devices based on USB ID
Sometimes the vendor and product names aren't specific enough to target
a USB device, so expose the numeric codes in the ID. A MatchUSBID entry
has been added that supports shell pattern matching when fnmatch(3) is
available. For example:

	MatchUSBID "046d:*"

The IDs are stored in lowercase hex separated by a ':' like "lsusb" or
"lspci -n".

Signed-off-by: Dan Nicholson <dbn.lists@gmail.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2010-06-11 09:30:33 +10:00