Commit Graph

2250 Commits

Author SHA1 Message Date
Brendan King b92d86a982 dix: fix pixmap leak on server reset
The server is leaking a pixmap (created by CreateDefaultStipple()) on
reset. The leak is caused by some X Server graphics contexts not being
freed on reset by the machine independent cursor code in the server,
which in turn is caused by the cursor cleanup code
(miSpriteDeviceCursorCleanup()) not being called.

Ensures the DeviceCursorCleanup() function is called when the associated
input device is closed on server reset.

Signed-off-by: Frank Binns <frank.binns@imgtec.com>
Reviewed-by: Keith Packard <keithp@keithp.com>
Signed-off-by: Keith Packard <keithp@keithp.com>
2014-06-04 21:32:30 -07:00
Brendan King a99c061aaf dix: reference the cursor just once in InitializeSprite()
The new current cursor was being referenced twice, resulting in a
memory leak when the current server generation ended.

Signed-off-by: Frank Binns <frank.binns@imgtec.com>
Reviewed-by: Keith Packard <keithp@keithp.com>
Signed-off-by: Keith Packard <keithp@keithp.com>
2014-06-04 21:32:14 -07:00
Peter Hutterer e06fbe4dc8 dix: remove a now-superfluous comment
Obsolete since 93945b0a74

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2014-04-29 10:06:25 +10:00
Michal Srb 6a848122de input: Remove invalid bug checks.
Commit 2f1aedcaed added several bug checks. Some
of them are not correct.

Checks in Init(Ptr|String|Bell|Led|Integer)FeedbackClassDeviceStruct verify
that no feedback struct was set yet, but that is not required. If any feedback
structs are already present, the function will chain them behind the new one.

Signed-off-by: Michal Srb <msrb@suse.com>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2014-04-29 10:06:25 +10:00
Eric Anholt abf1202706 glx: Move the GLX variable caching what GL context is current to dix.
GLX is trying to track whether the context it wants is current, to
avoid the glFlush() (and the rest of the overhead) that occurs on all
MakeCurrent calls.  However, its cache can be incorrect now that
glamor exists.  This is a step toward getting glamor to coordinate
with GLX.

Signed-off-by: Eric Anholt <eric@anholt.net>
Reviewed-by: Michel Dänzer <michel.daenzer@amd.com>
Reviewed-by: Adam Jackson <ajax@redhat.com>
2014-04-23 10:32:02 -07:00
Jasper St. Pierre ea15f8b4c9 dixfonts: Turn a missing directory ErrorF into a DebugF
On systems without these directories, we don't need to be complaining
loudly.

Reviewed-by: Kristian Hoegsberg <krh@bitplanet.net>

Signed-off-by: Keith Packard <keithp@keithp.com>
2014-04-21 15:01:02 -07:00
Keith Packard 73698d41e4 Make XYToWindow a screen function
This allows DDXen to override the window picking to account for
native windows not seen by the X server.  The bulk of the picking logic
is exposed as a new helper function, miSpriteTrace().  This function
completes the sprite trace filled out by the caller, and can be set up
to start the search from a given toplevel window.

v2: Leave existing XYToWindow API in place for API compatibility

Signed-off-by: Keith Packard <keithp@keithp.com>
Reviewed-by: Kristian Høgsberg <krh@bitplanet.net>
2014-04-01 10:30:42 -07:00
Jon TURNEY bc348bd2c4 Handle -displayfd and an explicit display number sensibly
Handle -displayfd and an explicit display number sensibly, e.g. use the
explicitly specified display number, and write it to the displayfd

v2: displayfd might be 0, so use -1 as invalid value
v3: Rebase for addition of NoListenAll flag

Signed-off-by: Jon TURNEY <jon.turney@dronecode.org.uk>
Reviewed-by: Kristian Høgsberg <krh@bitplanet.net>
2014-03-27 14:34:34 +00:00
Keith Packard ae87b53615 dix: Allow NULL stipple in ChangeGC
miOpqStipDrawable resets the stipple after painting. When that stipple
was NULL, ChangeGC needs to handle that and not crash.

Signed-off-by: Keith Packard <keithp@keithp.com>
Signed-off-by: Eric Anholt <eric@anholt.net>
Reviewed-off-by: Eric Anholt <eric@anholt.net>
2014-03-26 12:58:40 -07:00
Peter Hutterer 45fb3a934d xkb: push locked modifier state down to attached slave devices
Whenever the master changes, push the locked modifier state to the attached
slave devices, then update the indicators. This way, when NumLock or CapsLock
are hit on any device, the LED will light up on all devices. Likewise, a new
keyboard attached to a master device will light up with the correct
indicators.

The indicators are handled per-keyboard, depending on the layout, i.e. if one
keyboard has grp_led:num set, the NumLock LED won't light up on that keyboard.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Daniel Stone <daniel@fooishbar.org>
2014-03-11 17:43:34 +10:00
Andrew Eikum 78e508c937 dix: Clear any existing selections before initializing privates
If there is a selection left over from a previous execution of the
main loop, and that selection has privates allocated for it, the X
server will crash. This is because dixResetPrivates() resets the
privates refcounts to zero without accounting for the reference held
by the selection object. When the selection is then deleted in
InitSelections() after the call to dixResetPrivates(), the refcount
for its privates type goes negative and bad things happen.

To fix this, we should delete any existing selections before calling
dixResetPrivates(). This will properly release the selection's
privates and avoid the crash.

A more thorough description of the problem and a test case to
reproduce the crash is available at a previous mail:
  "Negative Selection devPrivates refcount?"
  By Andrew Eikum to xorg-devel on 10 Dec 2013
  http://lists.freedesktop.org/archives/xorg-devel/2013-December/039492.html

Signed-off-by: Andrew Eikum <aeikum@codeweavers.com>
Reviewed-by: Adam Jackson <ajax@redhat.com>
Signed-off-by: Keith Packard <keithp@keithp.com>
2014-03-06 17:15:11 -08:00
Peter Hutterer c64130c13b dix: fix a -Wshadow warning
dispatch.c: In function 'SetVendorString':
dispatch.c:481:29: warning: declaration of 'string' shadows a global declaration [-Wshadow]
 SetVendorString(const char *string)
                             ^
dispatch.c:135:21: warning: shadowed declaration is here [-Wshadow]
 typedef const char *string;

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
Reviewed-by: Keith Packard <keithp@keithp.com>
2014-02-05 15:10:27 +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 87ca80a719 dix: prevent a driver from initializing or submitting buttons > MAX_BUTTONS
The server internally relies on arrays with a MAX_BUTTONS maximum size (which
is the max the core protocol can transport). Make sure a driver adheres to
that.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Daniel Stone <daniel@fooishbar.org>
2014-02-04 11:38:00 +10:00
Peter Hutterer 45f1d527f3 input: un-constify dev->name
Fallout from fecc7eb1cf, and reverts most of the
rest of that patch.

The device name is allocated and may even change during PreInit. The const
warnings came from the test codes, the correct fix here is to fix the test
code.

touch.c: In function ‘touch_init’:
touch.c:254:14: warning: assignment discards ‘const’ qualifier from pointer target type [enabled by default]
     dev.name = "test device";

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
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
Alan Coopersmith 435098a0dc Add RANDR 1.4 requests & events to dix/protocol.txt
Checked against randrproto.txt & randr.h

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>
2014-01-29 15:22:44 -08:00
Alan Coopersmith e6733ae91b On realloc failure, free font_path_string instead of leaking it
Flagged by cppcheck 1.62:
[dix/dixfonts.c:1792]: (error) Common realloc mistake:
 'font_path_string' nulled but not freed upon failure

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>
2014-01-29 15:22:19 -08:00
Keith Packard c1ce807d9f dix: Praise clients which haven't run for a while, rather than idle clients
A client which is ready, but hasn't run for a while, should receive
the same benefit as one which has simply been idle for a while. Use
the smart_stop_tick to see how long it has been since a client has
run instead of smart_check_tick, which got reset each time a client
was ready, even if it didn't get to run.

Reported-by: Chris Wilson <chris@chris-wilson.co.uk>
Signed-off-by: Keith Packard <keithp@keithp.com>
Tested-by: Chris Wilson <chris@chris-wilson.co.uk>
2014-01-23 10:10:28 -08:00
Keith Packard 25ebb9dbc9 Merge remote-tracking branch 'whot/for-keith' 2014-01-22 11:33:53 -08:00
Keith Packard 2d2d49dab5 Clean up a few function prototypes to not place formals in /**/
This just removes the comment markers from around the formals in
several function prototypes near where pointer -> void * changes were
made. There are plenty more of these to fix.

Signed-off-by: Keith Packard <keithp@keithp.com>
Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com>
2014-01-12 10:24:12 -08:00
Keith Packard 60014a4a98 Replace 'pointer' type with 'void *'
This lets us stop using the 'pointer' typedef in Xdefs.h as 'pointer'
is used throughout the X server for other things, and having duplicate
names generates compiler warnings.

Signed-off-by: Keith Packard <keithp@keithp.com>
Reviewed-by: Eric Anholt <eric@anholt.net>
2014-01-12 10:24:11 -08:00
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
Keith Packard d89b42bda4 Clean up warnings in DIX
As usual, mostly const char changes. However, filter_device_events had
a potentially uninitialized value, 'raw', which I added a bunch of
checks for. I suspect most of those are 'can't happen', but it's hard
to see that inside the function.

Signed-off-by: Keith Packard <keithp@keithp.com>
Reviewed-by: Adam Jackson <ajax@redhat.com>
2014-01-12 10:14:49 -08:00
Alan Coopersmith 863d2ad5c0 CheckPassiveGrabsOnWindow() needs to handle NULL return value from AllocGrab()
CheckPassiveGrabsOnWindow() calls AllocGrab() which can fail and return NULL.
This return value is not checked, and can cause NULL pointer dereferences.

Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
2014-01-09 13:36:29 +10:00
Alan Coopersmith 5493a67ec2 GrabDevice() needs to handle NULL return value from AllocGrab()
GrabDevice() calls AllocGrab() which can fail and return NULL.
This return value is not checked, and can cause NULL pointer dereferences.

Reported-by: Ilja Van Sprundel <ivansprundel@ioactive.com>
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
2014-01-09 13:36:29 +10:00
Alan Coopersmith 3a113815a0 If AllocGrab() fails to set up grab, don't copy to a NULL grab
If either the initial calloc or the xi2mask_new fails, grab is NULL,
but if a src grab is passed in, it was always being written to by
CopyGrab (and if that failed, dereferenced again in teardown).

Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
2014-01-09 13:36:29 +10:00
Peter Hutterer 929795d50d dix: fix check for grab type
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2013-12-11 14:00:50 +10:00
Adam Jackson e0cac00560 bs: Set the screen's bs support level to WhenMapped
Since we're using RedirectAutomatic to do this, we don't actually
preserve contents when unmapped.

v2: Don't say WhenMapped if Composite didn't initialize [vsyrjala]

Reviewed-by: Julien Cristau <jcristau@debian.org>
Signed-off-by: Adam Jackson <ajax@redhat.com>
2013-12-09 13:20:36 -05:00
Adam Jackson b61ccd5d9d smartsched: Tweak the default scheduler intervals
A default timeslice of 20ms means a pathological client can ruin up to
two frames per scheduler tick.  And a fifth of a second is just insane.

Pick two different numbers out of the hat.  A 5ms slice means you can
probably keep up with two or three abusive clients, and letting it burst
to 15ms should give you about all the timeslice you need for a
fullscreen game (that's doing server-side rendering for some reason).

If you're running on a system with a 10ms granularity on SIGALRM, then
this effectively changes the intervals to 10ms and 30ms.  Which is still
better, just not as better.

I suspect this is about as good as we can do without actually going
preemptive, which is an entire other nightmare.

Reviewed-by: Julien Cristau <jcristau@debian.org>
Signed-off-by: Adam Jackson <ajax@redhat.com>
2013-12-09 13:20:36 -05:00
Keith Packard 26f013ba45 Add a RegionDuplicate function
This allocates a new region structure and copies a source region into
it in a single API rather than forcing the caller to do both steps themselves.

Signed-off-by: Keith Packard <keithp@keithp.com>
Reviewed-by: Adam Jackson <ajax@redhat.com>
2013-10-31 16:58:16 -07:00
Keith Packard e3220d7bae Merge commit '2523a445a09a75a8baf642608d099a5e12d5437f'
This is merging the commits along Peter's for-keith branch, without
also merging in the spurious merge at the top of that branch.
2013-10-18 17:22:52 -07:00
Peter Hutterer 06b87aa528 sync: if the idle time was reset, force alarms to trigger (#70476)
The time between the idle reset and the IdleTimeWakeupHandler to be called is
indeterminate. Clients with an PositiveTransition or NegativeTransition alarm
on a low threshold may miss an alarm.

Work around this by keeping a reset flag for each device. When the
WakeupHandler triggers and the reset flag is set, we force a re-calculation of
everything and pretend the current idle time is zero. Immediately after is the
next calculation with the real idle time.

Relatively reproducible test case: Set up a XSyncNegativeTransition alarm for
a threshold of 1 ms. May trigger, may not.

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

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Adam Jackson <ajax@redhat.com>
Reviewed-by: Keith Packard <keithp@keithp.com>
2013-10-18 16:44:32 +10:00
Peter Hutterer efc1035ca9 dix: provide accessor methods for the last device event time
And now that we have the accessors, localize it. No functional changes, just
preparing for a future change.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Adam Jackson <ajax@redhat.com>
Reviewed-by: Keith Packard <keithp@keithp.com>
2013-10-18 16:44:32 +10:00
Alan Coopersmith 73b2660d72 Avoid use-after-free in dix/dixfonts.c: doImageText() [CVE-2013-4396]
Save a pointer to the passed in closure structure before copying it
and overwriting the *c pointer to point to our copy instead of the
original.  If we hit an error, once we free(c), reset c to point to
the original structure before jumping to the cleanup code that
references *c.

Since one of the errors being checked for is whether the server was
able to malloc(c->nChars * itemSize), the client can potentially pass
a number of characters chosen to cause the malloc to fail and the
error path to be taken, resulting in the read from freed memory.

Since the memory is accessed almost immediately afterwards, and the
X server is mostly single threaded, the odds of the free memory having
invalid contents are low with most malloc implementations when not using
memory debugging features, but some allocators will definitely overwrite
the memory there, leading to a likely crash.

Reported-by: Pedro Ribeiro <pedrib@gmail.com>
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Reviewed-by: Julien Cristau <jcristau@debian.org>
2013-10-14 17:56:44 -07:00
Peter Hutterer 7cf1b595c8 dix: only deliver for the current grab type
Use the grabtype to determine which type of event to send - all other events
are pointless and may result in erroneous events being delivered.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2013-10-14 11:07:38 +10:00
Peter Hutterer 78944d62ff dix: don't attempt to deliver an event for a different grabtype
For an active grab, grab->eventMask can be either the core or the XI1 mask.
With the overlap of event filters, calling DeliverOneGrabbedEvent(XI1) for a
ProximityOut event will trigger if the client has selected for enter events -
the filter is the same for both.

Thus, we end up delivering a proximity event to a client not expecting one.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2013-10-14 11:07:38 +10:00
Peter Hutterer be6ea80b79 dix: only allow button and key events to freeze a sync'd pointer
If a client calls XAllowEvents(SyncPointer) it expects events as normal until
the next button press or release event - that freezes the device. An e.g.
proximity event must thus not freeze the pointer.

As per the spec, only button and key events may do so, so narrow it to these
cases.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2013-10-14 11:07:37 +10: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
Adam Jackson 28708a045d damage: Implicitly unregister on destroy
There's no reason not to, and it simplifies quite a few callers.

Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>
Reviewed-by: Eric Anholt <eric@anholt.net>
Signed-off-by: Adam Jackson <ajax@redhat.com>
2013-09-10 14:28:09 -04:00
Adam Jackson abbd85742a dix: FIXES is not optional
It's already not optional at configure time, this just makes it so at
build time too.

Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
Signed-off-by: Adam Jackson <ajax@redhat.com>
2013-09-10 13:28:24 -04:00
Adam Jackson dbe10ef0e3 dbe: Fold the window private private into the window private
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
Signed-off-by: Adam Jackson <ajax@redhat.com>
2013-09-10 13:28:24 -04:00
Adam Jackson 19d3a7cb5d dix: Remove a dead parameter from DoGetImage
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
Signed-off-by: Adam Jackson <ajax@redhat.com>
2013-09-10 13:28:23 -04:00
Thomas Klausner 47218a6e09 Fix bug in cursor handling.
CreateCursor (Xlib call XCreatePixmapCursor) with a non-bitmap
source pixmap and a None mask is supposed to error out with BadMatch,
but didn't.

From der Mouse <mouse@Rodents-Montreal.ORG>, changed following
comments by Alan Coopersmith <alan.coopersmith@oracle.com>.

Signed-off-by: Thomas Klausner <wiz@NetBSD.org>
Reviewed-by: Jasper St. Pierre <jstpierre@mecheye.net>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2013-09-06 07:04:18 +10:00
Peter Hutterer 82939e0239 dix: check for grab type before checking XI2 mask
if the grab type isn't XI2, grab->xi2mask is random. That random data may
have the enter/leave mask set, leading to events sent to the client that the
client can't handler.

Source of these errors:
  _xgeWireToEvent: Unknown extension 131, this should never happen.

Simplest reproducer:
   Start Xephyr, press button inside window, move out. As the pointer leaves
   the Xephyr window, the errors appear.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Adam Jackson <ajax@redhat.com>
2013-08-30 14:26:55 +10:00
Egbert Eich 05ea6307fa DIX/Xi: Pass correct client to CheckDeviceGrabAndHintWindow()
If we have a client which has registered for a DeviceButton grab
be sure to pass this to CheckDeviceGrabAndHintWindow(). Since the
order of clients is arbitrary there is no guarantee that the last
client in the list is the one that belongs to this class.

Signed-off-by: Egbert Eich <eich@freedesktop.org>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2013-08-30 14:26:55 +10:00
Julien Cristau fe7463b8ce dix: add missing include for DeleteWindowFromAnySelections
Fixes build error with XACE disabled:
window.c:886:5: error: implicit declaration of function 'DeleteWindowFromAnySelections' [-Werror=implicit-function-declaration]
     DeleteWindowFromAnySelections(pWin);
     ^

Debian bug#701372

Reported-by: Matthias Klose <doko@debian.org>
Signed-off-by: Julien Cristau <jcristau@debian.org>
Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Signed-off-by: Keith Packard <keithp@keithp.com>
2013-08-18 02:39:44 +02:00
Keith Packard ff38bbe81a Merge remote-tracking branch 'whot/for-keith' 2013-07-25 22:50:27 -07:00
Peter Hutterer 3d87566310 dix: set the valuator mask to ensure XI 1.x events have data
XI 1.x only allows for first + num valuators, so if a device sends data for
valuators 0 and 2+ only (i.e. valuator 1 is missing) we still need to get
the data for that from somewhere.
XI 1.x uses the hack of an unset valuator mask to get the right coordinates,
i.e. we set the value but don't set the mask for it so XI2 events have the
right mask.

For an absolute device in relative mode, this broke in b28a1af55c, the
value was now always 0. This wasn't visible on the cursor, only in an XI 1.x
client. The GIMP e.g. sees jumps to x/0 every few events.

Drop the condition introduced in b28a1af55c, data in valuators is always
absolute, regardless of the mode.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2013-07-25 12:57:41 +10:00
Peter Hutterer 4fb686d6a6 dix: check the xi2mask, not the grab type for touch listeners
grab->type is only non-zero for passive grabs. We're checking an active grab
here, so we need to check if the touch mask is set on the grab.

Test case: grab the device, then start two simultaneous touches. The
grabbing client won't see the second touchpoints because grab->type is 0
and the second touch is not an emulating pointer.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2013-07-24 11:50:00 +10:00
Jon TURNEY 15febb05d7 Allow DDX to provide a main()
XQuartz already conditionally renames main() as dix_main() so it can provide
it's own main().  This isn't the ideal way of doing this, as it prevents libdix
built this way from being useful with any other DDX.

So instead, always name that function dix_main(), and also provide a stub main()
which just calls dix_main(), which can be overriden in the DDX.

Add a main() to XWin (XQuartz already has one, of course).

It's no longer neccessary to link XWin and XQuartz with libmain.

v2: Remove unneeded stub main hw/xwin/InitOutput.c

Signed-off-by: Jon TURNEY <jon.turney@dronecode.org.uk>
Reviewed-by: Julien Cristau <jcristau@debian.org>
Reviewed-by: Colin Harrison <colin.harrison@virgin.net>
2013-07-23 23:56:58 +01:00
Peter Hutterer 21ea7ebb6a dix: scale y back instead of x up when pre-scaling coordinates
The peculiar way we handle coordinates results in relative coordinates on
absolute devices being added to the last value, then that value is mapped to
the screen (taking the device dimensions into account). From that mapped
value we get the final coordinates, both screen and device coordinates.

To avoid uneven scaling on relative coordinates, they are pre-scaled by
screen ratio:resolution:device ratio factor before being mapped. This
ensures that a circle drawn on the device is a circle on the screen.

Previously, we used the ratio to scale x up. Synaptics already does its own
scaling based on the resolution and that is done by scaling y down by the
ratio. So we can remove the code from the driver and get approximately the
same behaviour here.

Minor ABI bump, so we can remove this from synaptics.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Tested-by: Emmanuel Benisty <benisty.e@gmail.com>
2013-07-22 14:18:30 +10:00
Peter Hutterer 74469895e3 dix: allow a ConstantDeceleration between 0 and 1 (#66134)
A constant deceleration of x simply means (delta * 1/x). We limited that to
values >= 1.0f for obvious reasons, but can also allow values from 0-1.
That means that ConstantDeceleration is actually a ConstantAcceleration, but
hey, if someone needs it...

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

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Keith Packard <keithp@keithp.com>
2013-07-17 14:27:26 +10:00
Peter Hutterer 0e3be0b25f dix: UpdateTouchesForGrab must only free the listener grab if it is non-NULL
If a client calls XIGrabDevice in response to a ButtonPress event (regular
event selection), the device will have a grab, but listener->grab is NULL.

Check for that, to avoid logspam.

[ 26293.863] (EE) BUG: triggered 'if (!pGrab)'
[ 26293.863] (EE) BUG: grabs.c:256 in FreeGrab()
[ 26293.863] (EE)
[ 26293.863] (EE) Backtrace:
[ 26293.864] (EE) 0: /usr/bin/Xorg (FreeGrab+0x54) [0x45d3fc]
[ 26293.864] (EE) 1: /usr/bin/Xorg (UpdateTouchesForGrab+0x135) [0x447d4e]
[ 26293.864] (EE) 2: /usr/bin/Xorg (ActivatePointerGrab+0x1ba) [0x447f3d]
[ 26293.864] (EE) 3: /usr/bin/Xorg (GrabDevice+0x3e6) [0x4503bc]
[ 26293.864] (EE) 4: /usr/bin/Xorg (ProcXIGrabDevice+0x1f9) [0x5981b1]
[ 26293.865] (EE) 5: /usr/bin/Xorg (ProcIDispatch+0x78) [0x58aa17]
[ 26293.865] (EE) 6: /usr/bin/Xorg (Dispatch+0x30d) [0x43347e]
[ 26293.865] (EE) 7: /usr/bin/Xorg (main+0x61d) [0x498175]
[ 26293.865] (EE) 8: /lib64/libc.so.6 (__libc_start_main+0xf5) [0x3df5621b75]
[ 26293.865] (EE) 9: /usr/bin/Xorg (_start+0x29) [0x423a19]
[ 26293.866] (EE) 10: ? (?+0x29) [0x29]
[ 26293.866] (EE)

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Keith Packard <keithp@keithp.com>
2013-07-17 14:27:26 +10:00
Peter Hutterer 8eeaa74bc2 dix: when ungrabbing an active grab, accept pointer grabs (#66720)
Ungrabbing a device during an active touch grab rejects the grab. Ungrabbing
a device during an active pointer grab accepts the grab.

Rejection is not really an option for a pointer-emulated grab, if a client
has a button mask on the window it would get a ButtonPress emulated after
UngrabDevice. That is against the core grab behaviour.

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

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Jasper St. Pierre <jstpierre@mecheye.net>
2013-07-11 07:38:57 +10:00
Peter Hutterer c21344add2 dix: remove logspam in RefCursor()
This shouldn't have been in the patch

Reported-by: Colin Harrison <colin.harrison@virgin.net>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Keith Packard <keithp@keithp.com>
Signed-off-by: Keith Packard <keithp@keithp.com>
2013-05-26 22:41:31 -06:00
Keith Packard cb3018d8a1 Merge remote-tracking branch 'whot/unreviewed' 2013-05-23 19:58:46 -06:00
Peter Hutterer 6589f3b55e dix: devices must have valuators before touch is initialized
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2013-05-23 15:35:11 +10:00
Peter Hutterer 756ab88d93 dix: fix device scaling to use a [min,max[ range.
defmin/defmax are screen coords and thus use a min-inclusive, max-exclusive
range. device axes ranges are inclusive, so bump the max up by one to get the
scaling right.

This fixes off-by-one coordinate errors if the coordinate matrix is used to
bind the device to a fraction of the screen. It introduces an off-by-one
scaling error in the device coordinate range, but since most devices have a
higher resolution than the screen (e.g. a Wacom I4 has 5080 dpi) the effect
of this should be limited.

This error manifests when we have numScreens > 1, as the scaling from
desktop size back to screen size drops one device unit.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2013-05-23 15:35:05 +10:00
Peter Hutterer 5cc2c96f82 dix: pre-scale x by the screen:device:resolution ratio
commit 61a99aff9d
    dix: pre-scale relative events from abs devices to desktop ratio (#31636)

added pre-scaling of relative coordinates coming from absolute devices to
undo uneven scaling based on the screen dimensions.

Devices have their own device width/height ratio as well (in a specific
resolution) and this must be applied for relative devices as well to avoid
scaling of the relative events into the device's ratio.

e.g. a Wacom Intuos4 6x9 is in 16:10 format with equal horiz/vert
resolution (dpi). A movement by 1000/1000 coordinates is a perfect diagonal
on the tablet and must be reflected as such on the screen.

However, we map the relative device-coordinate events to absolute screen
coordinates based on the axis ranges. This results in an effective scaling
of 1000/(1000 * 1.6) and thus an uneven x/y axis movement - the y
axis is always faster.

So we need to pre-scale not only by the desktop dimenstions but also by the
device width/height ratio _and_ the resolution ratio.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2013-05-23 15:35:05 +10:00
Peter Hutterer 9a5ad65330 Abstract cursor refcounting
Too many callers relied on the refcnt being handled correctly. Use a simple
wrapper to handle that case.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2013-05-15 19:17:57 +10:00
Peter Hutterer 35c2e263db dix: call UpdateDeviceState() for emulated TouchEndEvents
ProcessTouchEvents() calls UDS for all touch events, but if the event type
was switched to TouchUpdate(pending end) UDS is a noop.

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

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

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

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

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

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2013-05-15 19:17:39 +10:00
Peter Hutterer 8b9dc26281 dix: devices must have valuators before touch is initialized
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2013-05-15 19:17:39 +10:00
Peter Hutterer 481702101b dix: fix cursor refcounting
The cursor is referenced during CopyGrab(), thus doesn't need to be handled
manually anymore. It does need to be refcounted for temp grabs though.

The oldGrab handling in ProcGrabPointer is a leftover from the cursor in the
grab being refcounted, but the grab itself being a static struct in the
DeviceIntRec. Now that all grabs are copied, this lead to a double-free of
the cursor (Reproduced in Thunderbird, dragging an email twice (or more
often) causes a crash).

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2013-05-15 19:16:59 +10:00
Peter Hutterer 3093f78d17 dix: free the old grab when activating a new grab
A client may call XIGrabDevice twice, overwriting the existing grab. Thus,
make sure we free the old copy after we copied it. Free it last, to make
sure our refcounts don't run to 0 and inadvertantly free something on the
way.

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

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

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

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

Reported-by: Maarten Lankhorst <maarten.lankhorst@canonical.com>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2013-05-10 14:32:38 +10:00
Peter Hutterer 925e35122e dix: AllocGrab can copy if an argument is passed in
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2013-05-10 14:32:37 +10:00
Peter Hutterer 4980bcef99 dix: freeing a null grab is a bug, complain if doing so
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2013-05-10 14:32:37 +10:00
Peter Hutterer ccfa0f2d5d dix: use a temporary variable for listeners[0]
no functional changes

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2013-05-10 14:32:37 +10:00
Peter Hutterer 5363433a5c dix: drop DeviceIntRec's activeGrab struct
Obsolete since 4bc2761ad5. This struct
existed so copying a passive grab could be simply done by
  activeGrab = *grab

and thus have a copy of the GrabPtr we'd get from various sources but still
be able to check device->grab for NULL.

Since 4bc2761 activeGrab is a pointer itself and points to the same memory
as grabinfo->grab, leaving us with the potential of dangling pointers if
either calls FreeGrab() and doesn't reset the other one.

There is no reader of activeGrab anyway, so simply removing it is
sufficient.

Note: field is merely renamed to keep the ABI. Should be removed in the
future.

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

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

No functional changes.

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

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

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

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

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

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

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

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

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2013-05-10 14:26:15 +10:00
Peter Hutterer 2f1aedcaed input: print warnings if drivers don't initialize properly
If drivers supply incorrect values don't just quietly return False, spew to
the log so we can detect what's going on. All these cases are driver bugs
and should be fixed immediately.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Dave Airlie <airlied@redhat.com>
2013-05-10 11:05:00 +10:00
Peter Hutterer 8a88b0ab52 dix: don't overwrite proximity/focus classes
InitPointerClassDeviceStruct/InitKeyboardDeviceStruct allocate a
proximity/focus class, respectively. If a driver calls
InitFocusClassDeviceStruct or InitProximityClassDeviceStruct beforehand,
the previously allocated class is overwritten, leaking the memory.

Neither takes a parameter other than the device, so we can simply skip
initialising it if we already have one.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Dave Airlie <airlied@redhat.com>
2013-05-10 11:04:53 +10:00
Peter Hutterer 34b0d07ebf dix: reset the OsBuffers after killing all clients
==21860== 24 bytes in 1 blocks are still reachable in loss record 85 of 397
==21860==    at 0x4C2B3F8: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==21860==    by 0x61ED93: AllocateOutputBuffer (io.c:1037)
==21860==    by 0x61E15A: WriteToClient (io.c:764)
==21860==    by 0x457B30: ProcQueryExtension (extension.c:275)
==21860==    by 0x43596B: Dispatch (dispatch.c:432)
==21860==    by 0x425DAB: main (main.c:295)

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Dave Airlie <airlied@redhat.com>
2013-05-10 11:04:44 +10:00
Peter Hutterer ddc11397a5 dix: delete all callbacks before reset
DeleteCallbackManager() introduced for better symmetry in the caller, they
do the same thing.

==20085== 24 bytes in 1 blocks are still reachable in loss record 11 of 103
==20085==    at 0x4C2A4CD: malloc (vg_replace_malloc.c:236)
==20085==    by 0x43A097: CreateCallbackList (dixutils.c:837)
==20085==    by 0x43A1D3: AddCallback (dixutils.c:869)
==20085==    by 0x4B1736: GEExtensionInit (geext.c:209)
==20085==    by 0x41C8A8: InitExtensions (miinitext.c:389)
==20085==    by 0x5AC918: main (main.c:208)

==2042== 8 bytes in 1 blocks are still reachable in loss record 2 of 97
==2042==    at 0x4C2A4CD: malloc (vg_replace_malloc.c:236)
==2042==    by 0x4C2A657: realloc (vg_replace_malloc.c:525)
==2042==    by 0x4802F5: XNFrealloc (utils.c:1095)
==2042==    by 0x43A17A: CreateCallbackList (dixutils.c:855)
==2042==    by 0x43A1EF: AddCallback (dixutils.c:870)
==2042==    by 0x4B1752: GEExtensionInit (geext.c:209)
==2042==    by 0x41C8A8: InitExtensions (miinitext.c:389)
==2042==    by 0x5AC9E4: main (main.c:208)
==2042==

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Keith Packard <keithp@keithp.com>
2013-05-08 09:27:30 +10:00
Peter Hutterer d3d4af5f9e dix: reset the registry before quitting
Heaps of these:
==2042== 15,360 bytes in 120 blocks are still reachable in loss record 94 of
97
==2042==    at 0x4C2A4CD: malloc (vg_replace_malloc.c:236)
==2042==    by 0x4C2A657: realloc (vg_replace_malloc.c:525)
==2042==    by 0x45FB91: double_size (registry.c:65)
==2042==    by 0x45FC97: RegisterRequestName (registry.c:85)
==2042==    by 0x460095: RegisterExtensionNames (registry.c:179)
==2042==    by 0x460729: dixResetRegistry (registry.c:334)
==2042==    by 0x5AC992: main (main.c:201)

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Keith Packard <keithp@keithp.com>
2013-05-07 09:41:02 +10:00
Peter Hutterer 6f44d672aa xkb: free XkbRulesUsed and XkbRulesDflt on extension cleanup
==2547== 1 bytes in 1 blocks are still reachable in loss record 1 of 111
==2547==    at 0x4C2A4CD: malloc (vg_replace_malloc.c:236)
==2547==    by 0x64D1551: strdup (strdup.c:43)
==2547==    by 0x4802FB: Xstrdup (utils.c:1113)
==2547==    by 0x585B6C: XkbSetRulesUsed (xkbInit.c:219)
==2547==    by 0x58700F: InitKeyboardDeviceStruct (xkbInit.c:595)
==2547==    by 0x419FA3: vfbKeybdProc (InitInput.c:74)
==2547==    by 0x425A3D: ActivateDevice (devices.c:540)
==2547==    by 0x425F65: InitAndStartDevices (devices.c:713)
==2547==    by 0x5ACA57: main (main.c:259)

and a few more of the above.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Keith Packard <keithp@keithp.com>
2013-05-07 09:40:51 +10:00
Peter Hutterer 23d1bc69f3 dix: send the current axis value in DeviceChangedEvents (#62321)
X.Org Bug 62321 <http://bugs.freedesktop.org/show_bug.cgi?id=62321>

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Keith Packard <keithp@keithp.com>
2013-05-07 09:40:42 +10:00
Dave Airlie f2fd8ec372 gpu: call CreateScreenResources for GPU screens
I didn't think we needed this before, but after doing some more
work with reverse optimus it seems like it should be called.

Reviewed-by: Keith Packard <keithp@keithp.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>
2013-04-30 10:10:51 +10:00
Dave Airlie 8fcb9d91b6 dix: allow pixmap dirty helper to be used for non-shared pixmaps
this allows the pixmap dirty helper to be used for reverse optimus,
where the GPU wants to copy from the shared pixmap to its VRAM copy.

[airlied: slave_dst is wrong name now but pointless ABI churn at this point]
Reviewed-by: Keith Packard <keithp@keithp.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>
2013-04-30 10:10:31 +10:00
Dave Airlie f0d0d75bfe dix/gpu: remove asserts for output/offload from same slave
We should have no problem allowing output/offload from the same slave,
I asserted here, but in order to implement reverse optimus this makes
perfect sense. (reverse optimus is intel outputting to nvidia).

Reviewed-by: Keith Packard <keithp@keithp.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>
2013-04-30 10:10:14 +10:00
Peter Hutterer 7d722796c6 dix: plug memory leak in freeing TouchClass
==15562== 1,800 bytes in 1 blocks are definitely lost in loss record 298 of 330
==15562==    at 0x4A06B6F: calloc (vg_replace_malloc.c:593)
==15562==    by 0x4312C7: InitTouchClassDeviceStruct (devices.c:1644)

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com>
2013-04-23 17:33:24 +10:00
Peter Hutterer 27356a45b4 dix: only allocate unused classes for master devices
Slave devices don't need these and the matching code in CloseDevice() has a
IsMaster() condition on freeing these, causing a leak.

==16111== 384 bytes in 4 blocks are definitely lost in loss record 72 of 105
==16111==    at 0x4C28BB4: calloc (vg_replace_malloc.c:467)
==16111==    by 0x42AEE2: AllocDevicePair (devices.c:2707)
==16111==    by 0x4BAA27: AllocXTestDevice (xtest.c:617)
==16111==    by 0x4BA89A: InitXTestDevices (xtest.c:570)
==16111==    by 0x425F5E: InitCoreDevices (devices.c:690)
==16111==    by 0x5ACB2D: main (main.c:257)

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Chase Douglas <chase.douglas@canonical.com>
2013-04-16 13:54:45 +10:00
Maarten Lankhorst 98b94c36d6 dix: copy event in TouchConvertToPointerEvent correctly
Fixes reading random memory read beyond the end of original event.

sizeof device_event: 424
sizeof internal_event: 2800

Signed-off-by: Maarten Lankhorst <maarten.lankhorst@canonical.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2013-04-16 07:32:42 +10:00
Peter Hutterer b86b3d10bb dix: don't set non-exisiting flags on touch events
Unlike pointer/keyboard events, the flags field for ET_Touch* is a set of
server-internal defines that we need to convert to XI protocol defines.
Currently only two of those defines actually translate to the protocol, so
make sure we don't send internal garbage down the wire.

No effect to current clients since they shouldn't look at undefined bits
anyway.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2013-04-11 10:16:22 +10:00
Peter Hutterer 2fdde2c40d dix: update coords for touch events in PlayReleasedEvents
Note: this is only hit for #ifdef PANORAMIX

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Keith Packard <keithp@keithp.com>
2013-03-25 10:34:23 +10:00
Peter Hutterer 11bead1fa2 dix: fix a comment
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Keith Packard <keithp@keithp.com>
2013-03-25 10:34:22 +10:00
Peter Hutterer c100211034 dix: only show the cursor if a window defines one (#58398)
e02f864fdf "Suppress cursor display until the first XDefineCursor() request"
disabled cursor display a priori unless -retro is given.

On a plain server, caling XFixesHideCursor() and XFixesShowCursor() would
show the default root cursor, despite no client actually defining a cursor.

Change the logic, disable CursorVisible by default and only enable it from
the window's CWCursor logic. If no window ever defines a cursor, said cursor
stays invisible.

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

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Tested-by: Bastien Nocera <hadess@hadess.net>
Reviewed-by: Daniel Martin <consume.noise@gmail.com>
2013-03-06 08:56:23 +10:00
Peter Hutterer f9198e278b dix: FreeAllAtoms() on reset
==5712== 6 bytes in 1 blocks are still reachable in loss record 17 of 585
==5712==    at 0x4A074CD: malloc (vg_replace_malloc.c:236)
==5712==    by 0x3D1DE885B1: strndup (strndup.c:46)
==5712==    by 0x41CB71: MakeAtom (atom.c:121)
==5712==    by 0x55AE3E: XIGetKnownProperty (xiproperty.c:401)
==5712==    by 0x4251C9: AddInputDevice (devices.c:312)
==5712==    by 0x42AC0C: AllocDevicePair (devices.c:2657)
==5712==    by 0x425E6E: InitCoreDevices (devices.c:677)
==5712==    by 0x5ACA05: main (main.c:257)

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Chase Douglas <chase.douglas@canonical.com>
2013-02-15 14:39:27 +10:00
Peter Hutterer 9f79e93b6b Short-cut the input device cleanup process during AbortServer()
If we're about to abort, we're already in the signal handler and cannot call
down to the default device cleanup routines (which reset, free, alloc, and
do a bunch of other things).

Add a new DEVICE_ABORT mode to signal a driver's DeviceProc that it must
reset the hardware if needed but do nothing else. An actual HW reset is only
required for some drivers dealing with the HW directly.

This is largely backwards-compatible, hence the input ABI minor bump only.

Drivers we care about either return BadValue on a mode that's not
DEVICE_{INIT|ON|OFF|CLOSE} or print an error and return BadValue. Exception
here is vmmouse, which currently ignores it and would not reset anything.
This should be fixed if the reset is required.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Keith Packard <keithp@keithp.com>
Signed-off-by: Keith Packard <keithp@keithp.com>
2013-02-08 09:06:14 -08:00
Peter Hutterer b58221f9da dix: support the transformation matrix for relative devices.
The transformation matrix we previously stored was a scaled matrix based on
the axis ranges of the device. For relative movements, the scaling is not
required (or desired).

Store two separate matrices, one as requested by the client, one as the
product of [scale . matrix . inv_scale]. Depending on the type of movement,
apply the respective matrix.

For relative movements, also drop the translation component since it doesn't
really make sense to use that bit.

Input ABI 19

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Keith Packard <keithp@keithp.com>
Signed-off-by: Keith Packard <keithp@keithp.com>
2013-02-08 09:02:57 -08:00
Carlos Garnacho 509b3c3dc8 dix: Set focus field on XI2 crossing events
Set on DeviceEnterLeaveEvent() the xXIEnterEvent->focus field
similarly to how the CoreEnterLeaveEvent() function above does
for core events.

This fixes bug https://bugzilla.gnome.org/show_bug.cgi?id=677329
reported to GTK+, where focus handling on window managers with
sloppy focus or no window manager present was broken due to this
field being always set to FALSE.

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>
2013-02-08 16:09:27 +10:00
Peter Hutterer 3e4be4033a dix: when shutting down slave devices, shut down xtest devices last
XTest devices are the first ones in the list, being initialised together
with the master devices. If we disable the devices in-order and a device has
a button down when being disabled, the XTest device is checked for a
required button release (xkbAccessX.c's ProcessPointerEvent). This fails if
the device is already NULL.

Instead of putting the check there, disable the devices in the reverse order
they are initialised. Disable physical slaves first, then xtest devices,
then the master devices.

Testcase: shut down server with a button still held down on a physical
device

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Keith Packard <keithp@keithp.com>
2013-02-08 14:12:56 +10:00
Peter Hutterer 0d5bb88260 Merge branch 'ptraccel-fixes' into for-keith 2013-02-08 14:10:52 +10:00
Peter Hutterer 61a99aff9d dix: pre-scale relative events from abs devices to desktop ratio (#31636)
Absolute devices may send relative events depending on the mode (synaptics
by default, wacom per option). The relative events are added to the previous
position, converted into device coordinates and then scaled into desktop
coordinates for pointer movement.

Because the device range must be mapped into the desktop coordinate range,
this results in uneven scaling depending dimensions, e.g. on a setup with
width == 2 * height, a relative movement of 10/10 in device coordinates
results in a cursor movement of 20/10 (+ acceleration)

Other commonly user-visible results:
* the touchpad changing acceleration once an external monitor as added.
* drawing a circle on a wacom tablet in relative mode gives an ellipsis in
  the same ratio as the desktop dimensions.

Solution: pre-scale the incoming relative x/y coordinates by width/height
ratio of the total desktop size. Then add them to the previous
coordinates and scale back with the previous mapping, which will undo the
pre-scaling and give us the right movement.

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

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Keith Packard <keithp@keithp.com>
2013-02-08 14:00:57 +10:00
Peter Hutterer a6ba2b79ae dix: unify prefix for ptraccel debugging in DebugAccelF macro
If we're already using our own custom macro, might as well use it properly.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Keith Packard <keithp@keithp.com>
2013-02-08 14:00:56 +10:00
Peter Hutterer 0d7d794060 dix: use BUG_RETURN_VAL for an error message
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Keith Packard <keithp@keithp.com>
2013-02-08 14:00:56 +10:00
Peter Hutterer a0c38ea6cb dix: add some more info to a ptraccel debug msg
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Keith Packard <keithp@keithp.com>
2013-02-08 14:00:56 +10:00
Peter Hutterer 95125a7c0c dix: fix ptraccel debugging printfs
This is mostly sigsafe code, so use sigsave printf. And update some fields
to double that used to be int.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Keith Packard <keithp@keithp.com>
2013-02-08 14:00:53 +10:00
Peter Hutterer 8571c648a7 Xext: if a root window is given in XTestFakeInput, move to that
For absolute events, if the client specifies a screen number offset the
coordinates by that. And add a new flag so we know when _not_ to add the
screen offset in GPE.

Without this offset and the flag, GPE would simply add the offset of the
current screen if POINTER_SCREEN is set.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Keith Packard <keithp@keithp.com>
2013-02-08 13:49:49 +10:00
Sybren van Elderen a191dbfe85 dix: when scaling from desktop coord, take the total desktop size (#51904)
Scaled is already in desktop coordinates, take the total width into account,
not just the current screen's width.

Fixes Xdmx pointer position calculation.

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

Signed-off-by: Sybren van Elderen <sowmestno@msn.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2013-02-08 13:47:24 +10:00
Peter Hutterer fa6ab7d9b2 Merge branch 'pointer-emulation-fixes-56558-v2' into for-keith 2013-01-11 14:58:17 +10:00
Peter Hutterer adde4e6448 dix: typo fix in comment
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2013-01-11 14:57:48 +10:00
Benjamin Tissoires 05ed095dd8 dix: fix error logging occuring in signal context of GetTouchEvents
GetTouchEvents is usually called in a signal context.
Calling ErrorF for the error messages leads to X complaining about log:

(EE) BUG: triggered 'if (inSignalContext)'
(EE) BUG: log.c:484 in LogVMessageVerb()
(EE) Warning: attempting to log data in a signal unsafe manner while in signal context.
Please update to check inSignalContext and/or use LogMessageVerbSigSafe() or ErrorFSigSafe().
The offending log format message is:
%s: Attempted to start touch without x/y (driver bug)

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2013-01-11 14:57:48 +10:00
Peter Hutterer 4e13dd9014 dix: don't filter RawEvents if the grab window is not the root window (#53897)
If a XI2.1+ client has a grab on a non-root window, it  must still receive
raw events on the root window.

Test case: register for XI_ButtonPress on window and XI_RawMotion on root.
No raw events are received once the press activates an implicit grab on the
window.

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

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Keith Packard <keithp@keithp.com>
2013-01-11 14:57:29 +10:00
Peter Hutterer 0e1ab433f4 dix: remove already-moved hunk
Should've been removed in bc1f90a615018c05994fae3e678dd2341256cd82a, but got
left here due to a botched rebase.

Fixes stray button events sent to clients after deactivating an async
pointer grab on a pointer-emulating-touch.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Keith Packard <keithp@keithp.com>
2013-01-09 12:33:49 +10:00
Peter Hutterer 32a6d8a6b5 dix: check for the right device's xi2 mask
events.c: In function 'DeactivatePointerGrab':
events.c:1524:51: warning: 'dev' may be used uninitialized in this function
[-Wuninitialized

dev is unset when we get here, the device to check is "mouse".
Introduced in ece8157a59.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Keith Packard <keithp@keithp.com>
2013-01-09 12:33:43 +10:00
Peter Hutterer f59499b5d0 dix: add resource type to touch listeners
Instead of guessing what resource type the listener is and what property to
retrieve, store the resource type in the listener directly.

Breaks XIT test cases:
TouchGrabTestMultipleTaps.PassiveGrabPointerEmulationMultipleTouchesFastSuccession

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

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

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

Signed-off-by: Keith Packard <keithp@keithp.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2013-01-09 12:33:33 +10:00
Keith Packard 0eb1559eb2 Merge remote-tracking branch 'yselkowitz/master'
I checked this patch with diff -w to check that it only affected
whitespace.
2012-12-19 12:22:03 -08:00
Keith Packard 014a5c8a9d Merge remote-tracking branch 'whot/barriers'
Conflicts:
	Xi/xichangehierarchy.c

Small conflict with the patch from

	Xi: don't use devices after removing them

Was easily resolved by hand.

Signed-off-by: Keith Packard <keithp@keithp.com>
2012-12-19 12:09:31 -08:00
Peter Hutterer f793b5fd3e dix: don't copy the wrong event mask when activating a passive grab
GrabMask is a union of core, XI1 and XI2 masks. If a XI2 grab is activated,
the value is a random pointer value, using it as mask has unpredictable
effects.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Jasper St. Pierre <jstpierre@mecheye.net>
Reviewed-by: Keith Packard <keithp@keithp.com>
2012-12-18 08:53:46 +10:00
Peter Hutterer dd3242c87a dix: don't allow overriding a grab with a different type of grab (#58255)
If a client has a core grab, don't allow re-grabbing with type XI2, etc.
This was the intent of the original commit
xorg-server-1.5.99.1-782-g09f9a86, but ineffective.

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

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Keith Packard <keithp@keithp.com>
2012-12-18 08:53:41 +10:00
Peter Hutterer 3b16140170 dix: ignore barrier events in FixUpEventFromWindow
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Jasper St. Pierre <jstpierre@mecheye.net>
2012-12-17 15:03:32 +10:00
Peter Hutterer a1eeb6fbec dix: handle barrier events properly when converting to core/XI 1.x
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Jasper St. Pierre <jstpierre@mecheye.net>
2012-12-17 15:03:26 +10:00
Peter Hutterer 1b83775f67 dix: skip delivery if it's not the right pointer barrier client
Only deliver to the client that created the barrier, not to other clients.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Jasper St. Pierre <jstpierre@mecheye.net>
2012-12-17 15:03:23 +10:00
Peter Hutterer 21a15f9a04 Pass the event list through to the pointer barrier code to return it
Instead of having the pointer barrier code enqueue events separately from
GetPointerEvents, pass the event list through and let it add to it.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Jasper St. Pierre <jstpierre@mecheye.net>
2012-12-17 15:03:12 +10:00
Jasper St. Pierre e130a46ab4 Add support for XI2.3: Pointer barrier events and releases.
This adds support for clients that would like to get a notification
every time a barrier is hit, and allows clients to temporarily release
a barrier so that pointers can go through them, without having to
destroy and recreate barriers.

Based on work by Chris Halse Rogers <chris.halse.rogers@canonical.com>

Signed-off-by: Jasper St. Pierre <jstpierre@mecheye.net>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2012-12-17 15:01:45 +10:00
Peter Hutterer bb6f3514ca Merge branch 'stack-smash-on-touchpoint' into for-keith 2012-12-12 17:25:28 +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 08da994a08 dix: add FIXME, TouchRemovePointerGrab does nothing
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2012-12-12 17:24:56 +10:00
Peter Hutterer ece8157a59 dix: when deactivating pointer-only grabs, don't emulate TouchEnd events
A client with a pointer grab on a touch device must reject the touch when
detactivating the grab while the touch is active. However, such a rejecting
must not trigger a ButtonRelease event to be emulated and sent to the
client.
Set the grabbing listener's state to HAS_END, so we simply skip delivery to
that client.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2012-12-12 17:24:56 +10:00
Peter Hutterer bc1f90a615 dix: only reject active grabs on ungrab and do it before actually ungrabbing
An active grab ungrabbing is the same as rejecting the grab, since the
client is no longer interested in those events. So reject any touch grab,
but do so before actually deactivating since we're interested in the
TouchEnd for the current grabbing client.

A passive grab otoh is _not_ like rejecting a grab, since it deactivates
automatically when the touch ends.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2012-12-12 17:24:56 +10:00
Peter Hutterer 146f48c293 dix: don't call ProcessInputEvents() when accepting/rejecting touches
TouchListenerAcceptReject may be called during normal event processing, but
ProcessInputEvents is not reentrant and calling it here smashes the event
queue.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2012-12-12 17:24:55 +10:00
Yaakov Selkowitz ea1d76d1b6 Fix formatting of address operators
The formatter confused address operators preceded by casts with
bitwise-and expressions, placing spaces on either side of both.
That syntax isn't used by ordinary address operators, however,
so fix them for consistency.

Signed-off-by: Yaakov Selkowitz <yselkowitz@users.sourceforge.net>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
2012-12-05 18:09:48 -06:00
Peter Hutterer ce6b652929 Merge branch 'high-resolution-touch-devices' into for-keith 2012-11-29 14:49:22 +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
Peter Hutterer 2dc6d92284 When resetting device idle time, reset XIAll(Master)Devices too (#56649)
When the screen saver is forcibly deactivated, the idle time counter is
reset for all devices but not for the fake XIAllDevices and
XIAllMasterDevices. XScreenSaverQueryInfo uses XIAlldevices to fill the
"idle" field, thus returning the wrong value.

Regression introduced in
commit 6aef209ebc
Author: Peter Hutterer <peter.hutterer@who-t.net>
Date:   Mon Mar 12 13:51:02 2012 +1000

    Change lastDeviceIdleTime to be per-device

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

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Tested-by: Giacomo Perale <ghepeu@virgilio.it>
Reviewed-by: Keith Packard <keithp@keithp.com>
2012-11-29 14:48:54 +10:00
Jon TURNEY fb170498ab dix/dispatch.c, os/utils.c: Disable smart scheduler on WIN32
setitimer() and SIGALRM aren't available on WIN32, so smart scheduler
code cannot be built.  Provide only stubs for smart scheduler timer
code, and disable smart scheduler by default.

Signed-off-by: Ryan Pavlik <rpavlik@iastate.edu>
Reviewed-by: Jon TURNEY <jon.turney@dronecode.org.uk>
Tested-by: Yaakov Selkowitz <yselkowitz@users.sourceforge.net>
Reviewed-by: Keith Packard <keithp@keithp.com>
2012-11-28 14:44:12 +00:00
Yuly Novikov 3b9f1c7017 dix: Save touchpoint last coordinates before transform. #49347
DDXTouchPointInfoRec.valuators used to store axis values after transform.
This resulted in Coordinate Transformation Matrix
being applied multiple times to the last coordinates,
in the case when only pressure changes in the last touch event.

Changed DDXTouchPointInfoRec.valuators to store values before transform.

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

Signed-off-by: Yuly Novikov <ynovikov@chromium.org>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2012-11-20 16:06:06 +10:00
Thomas Jaeger d0fd592fc7 Simplify GetTouchEvents
With only one callee left, we are free to assume that
!(flags & TOUCH_CLIENT_ID)

Signed-off-by: Thomas Jaeger <ThJaeger@gmail.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2012-11-20 15:42:46 +10:00
Thomas Jaeger fe59774c55 Don't use GetTouchEvents in EmitTouchEnd
As before GetTouchEvents causes unwanted side effects.  Add a new
function GetDixTouchEnd, which generates a touch event from the touch
point.  We fill in the event's screen coordinates from the MD's current
sprite position.

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

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

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

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

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2012-11-20 15:42:01 +10:00
Thomas Jaeger 90b177e5cb Update the MD's position when a touch event is received
Signed-off-by: Thomas Jaeger <ThJaeger@gmail.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2012-11-20 15:14:43 +10:00
Thomas Jaeger aa9da5eae1 remove init_event
The function is identical to init_device_event from inpututils.c with
the first two arguments swapped.

Signed-off-by: Thomas Jaeger <ThJaeger@gmail.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2012-11-19 12:12:28 +10:00
Peter Hutterer fd214aabf7 input: drop FP1616 macro
The double_to_f1616() functions do the same thing, and they're tested.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Keith Packard <keithp@keithp.com>
2012-11-19 12:12:23 +10:00
Keith Packard 011f845880 Merge remote-tracking branch 'whot/for-keith' 2012-11-05 17:16:07 -08:00
Peter Hutterer aad65415bf dix: don't allow disabling XTest devices
Disabling a XTest device followed by an XTest API call crashes the server.
This could be fixed elsewhere but disabled devices must not send events
anyway. The use-case for disabled XTest devices is somewhat limited, so
simply disallow disabling the devices.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Keith Packard <keithp@keithp.com>
2012-11-06 10:48:32 +10:00
Yaakov Selkowitz e8d45f3018 dix: fix shadow warnings
dispatch.c: In function 'ProcCopyArea':
dispatch.c:1608:5: warning: declaration of 'rc' shadows a previous local
dispatch.c:1604:9: warning: shadowed declaration is here
dispatch.c: In function 'ProcCopyPlane':
dispatch.c:1647:5: warning: declaration of 'rc' shadows a previous local
dispatch.c:1643:9: warning: shadowed declaration is here
events.c: In function 'GetClientsForDelivery':
events.c:2030:68: warning: declaration of 'clients' shadows a global declaration
../include/dix.h:124:28: warning: shadowed declaration is here
events.c: In function 'DeliverEventToWindowMask':
events.c:2113:19: warning: declaration of 'clients' shadows a global declaration
../include/dix.h:124:28: warning: shadowed declaration is here
events.c: In function 'EventSuppressForWindow':
events.c:4420:12: warning: declaration of 'free' shadows a global declaration

Signed-off-by: Yaakov Selkowitz <yselkowitz@users.sourceforge.net>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
2012-11-05 13:25:00 -06:00
Yaakov Selkowitz 1aa783754e dix: fix redundant redeclaration warnings in dixfont
These functions are already declared in <X11/fonts/fontproto.h>.
Redeclaring them just for _X_EXPORT causes tons of warnings throughout
xserver, but they need to be declared somewhere to be picked up by
sdksyms.sh.  Doing so in a private header limits the warnings to
sdksyms.c; fixing those as well would require changes to fontsproto.

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

Signed-off-by: Carlos Garnacho <carlosg@gnome.org>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2012-10-30 15:11:09 +10:00
Peter Hutterer e7cd5cce74 dix: fix zaphod screen scrossing (#54654)
POINTER_SCREEN coordinates are screen-relative. For a Zaphod setup, the
coordinates after a screen crossing are already relative to the new screen's
origin. Add that offset to the coordinates before re-setting.

regression introduced by
commit bafbd99080
Author: Peter Hutterer <peter.hutterer@who-t.net>
Date:   Wed Aug 8 11:34:32 2012 +1000

    dix: work around scaling issues during WarpPointer (#53037)

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

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Keith Packard <keithp@keithp.com>
2012-10-29 13:15:50 +10:00
Lionel Elie Mamane c0a752d286 dix: fix Ungrab action #55785
UngrabAllDevices(Bool kill_client):
If we are not going to kill the client (kill_clients false),
we need to deactivate grabs of active clients, too.
(If we are going to kill the client,
 no need to deactivate the grab,
 as this will be done as part of the client kill.)

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

Signed-off-by: Lionel Elie Mamane <lionel@mamane.lu>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2012-10-19 13:12:33 +10:00
Chase Douglas 3b67cd2614 End physically active touches when device is disabled
Otherwise:

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

Signed-off-by: Chase Douglas <chase.douglas@canonical.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2012-10-19 13:12:33 +10:00
Peter Hutterer 4b7f00346d dix: fix crash on shutdown if a disabled device is still grabbed (XI1 grab)
A disabled device doesn't have a sprite (less so a sprite->win) and triggers
a NULL-pointer dereference on shutdown when all active grabs are released as
part of the cleanup.

Fix this by checking for sprite being non-null and setting the focus window
to the NullWindow if it is. The rest of the patch just attempts to make
things more readable.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Keith Packard <keithp@keithp.com>
2012-10-10 14:40:45 +10:00
Keith Packard 8367dd9736 Merge remote-tracking branch 'whot/for-keith' 2012-10-04 13:08:35 -07:00
Peter Hutterer 9d6b836570 dix: fix crash on XI 1.x grabs on disabled devices. (#54934)
If the device is disabled, the sprite window is NULL and dereferencing
crashes the server.

This is only triggered for XI 1.x grabs (ProcXGrabDevice) as XI2 grabs would
trigger another code path, creating a sprite for the disabled device as if
detaching it (which is wrong and fixed with this patch too).

Grabbing a disabled device doesn't make sense as it won't send events
anyway. However, the protocol specs do not prohibit it, so we need to keep
it working.
Luckily, oldWin is only used for focus out events, which aren't necessary
given that the device is disabled.

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

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Chase Douglas <chase.douglas@ubuntu.com>
2012-10-04 13:24:43 +10:00
Keith Packard 4dd5989d15 Merge remote-tracking branch 'ajax/server-1.14-abi-churn' 2012-09-24 11:43:01 -07:00
Yufeng Shen 0b02150c27 dix: fix scale_to_desktop for edge ABS events
Scale_to_desktop() converts ABS events from device coordinates
to screen coordinates:
[dev_X_min, dev_X_max]  -> [screen_X_min, screen_X_max]
[dev_Y_min, dev_Y_max]  -> [screen_Y_min, screen_Y_max]

An edge ABS event with X = dev_X_max (e.g., generated from the
edge of a touchscreen) will be converted to have screen X value
= screen_X_max, which, however, will be filterd out when xserver
tries to find proper Window to receive the event, because the
range check for a Window to receive events is
       window_X_min <= event_screen_X < window_X_max
Events with event_screen_X = screen_X_max will fail the test get
and rejected by the Window.

To fix this, we change the device to screen coordinates mapping to
[dev_X_min, dev_X_max]  -> [screen_X_min, screen_X_max-1]
[dev_Y_min, dev_Y_max]  -> [screen_Y_min, screen_Y_max-1]

Reviewed-by: Chase Douglas <chase.douglas@canonical.com>
Reviewed-by: Jeremy Huddleston Sequoia <jeremyhu@apple.com>
Signed-off-by: Yufeng Shen <miletus@chromium.org>
Signed-off-by: Keith Packard <keithp@keithp.com>
2012-09-24 11:12:04 -07:00
Adam Jackson ad0156c369 dix: Remove MapUnmapEventsEnabled and friends
This hack was added to suppress events generated by Composite's internal
unmap/map cycle on redirection state change.  Since that cycle was
removed in 193ecc8b4, these can go.

Signed-off-by: Adam Jackson <ajax@redhat.com>
Reviewed-by: Ville Syrjälä <syrjala@sci.fi>
Signed-off-by: Keith Packard <keithp@keithp.com>
2012-09-23 10:41:54 -07:00
Adam Jackson 387b1ac33c dix: Factor out DeliverUnmapNotify
Signed-off-by: Adam Jackson <ajax@redhat.com>
Reviewed-by: Keith Packard <keithp@keithp.com>
Signed-off-by: Keith Packard <keithp@keithp.com>
2012-09-23 10:41:41 -07:00
Adam Jackson d20cc0fca4 dix: Factor out DeliverMapNotify
Signed-off-by: Adam Jackson <ajax@redhat.com>
Reviewed-by: Keith Packard <keithp@keithp.com>
Signed-off-by: Keith Packard <keithp@keithp.com>
2012-09-23 10:41:26 -07:00
Adam Jackson 63843cb700 dix: Factor out MaybeDeliverMapRequest
Signed-off-by: Adam Jackson <ajax@redhat.com>
Reviewed-by: Keith Packard <keithp@keithp.com>
Signed-off-by: Keith Packard <keithp@keithp.com>
2012-09-23 10:40:38 -07:00
Adam Jackson dab7a1ec7f dix: Fix some indentation
Signed-off-by: Adam Jackson <ajax@redhat.com>
Reviewed-by: Keith Packard <keithp@keithp.com>
Signed-off-by: Keith Packard <keithp@keithp.com>
2012-09-23 10:40:08 -07:00
Peter Hutterer 3d1051aecb dix: set the device transformation matrix
The property handler is registered after setting the property, so
dev->transform remains as all-zeros. That causes pixman_f_transform_invert()
to fail (in transformAbsolute()) and invert remains as garbage. This
may then cause a cursor jump to 0,0.

Since the axes are not yet initialized here and we need to allow for drivers
changing the matrix, we cannot use the property handler for matrix
initialization, essentially duplicating the code.

Triggered by the fix to (#49347) in 749a593e49

https://bugzilla.redhat.com/show_bug.cgi?id=852841

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Chase Douglas <chase.douglas@ubuntu.com>
Signed-off-by: Keith Packard <keithp@keithp.com>
2012-09-23 10:38:42 -07:00
Adam Jackson e2c7d70e5d dix: Extend initial connection handshake for forwarding proxies
Forwarding proxies like sshd will appear to be local, even though they
aren't really.  This leads to weird behaviour for extensions that truly
require running under the same OS services as the client, like MIT-SHM
and DRI2.

Add two new legal values for the initial connection's byteOrder field,
'r' and 'R'.  These act like 'l' and 'B' respectively, but have the side
effect of forcing the client to be treated as non-local.  Forwarding
proxies should attempt to munge the first packet of the connection
accordingly; older servers will reject connections thusly munged, so the
proxy should fall back to passthrough if the munged connection attempt
fails.

Reviewed-by: Daniel Stone <daniel@fooishbar.org>
Signed-off-by: Adam Jackson <ajax@redhat.com>
2012-09-20 14:40:18 -04:00
Dave Airlie 49ec57d509 dix: free default colormap before screen deletion
If we don't free this here, it gets freed later in the resource
cleanups, however it then looks up up pmap->pScreen, which we
freed already in this function. So free the default colormap
when we should.

This fixes a bug after a couple of hotplug cycles when you try
to exit the X server and it crashes.

Reviewed-by: Keith Packard <keithp@keithp.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>
2012-09-04 16:15:52 +10:00
Keith Packard a557edca61 Merge remote-tracking branch 'whot/for-keith' 2012-08-27 08:06:09 -07:00
Peter Hutterer bafbd99080 dix: work around scaling issues during WarpPointer (#53037)
In WarpPointer calls, we get input in screen coordinates. They must be
scaled to device coordinates, and then back to screen coordinates for screen
crossing and root coordinates in events.

The rounding errors introduced (and clipping in core/XI 1.x events) can lead
to the actual position being different to the requested input coordinates.
e.g. 200 scales to 199.9999, truncated to 199 in the event.

Avoid this by simply overwriting the scaled screen coordinates with the
input coordinates for the POINTER_SCREEN case.

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

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Keith Packard <keithp@keithp.com>
2012-08-21 07:54:07 +10:00
Keith Packard 288b87e42c Close GPU screens before core screens
This should make cleaning up the GPU screens easier as the core
screens they are associated with will still be around.

Signed-off-by: Keith Packard <keithp@keithp.com>
Reviewed-by: Dave Airlie <airlied@redhat.com>
2012-08-14 17:13:52 -07:00
Keith Packard 02f94b2d44 Merge remote-tracking branch 'whot/for-keith' 2012-08-06 16:52:12 -07:00
Keith Packard 360fa7736b Merge remote-tracking branch 'airlied/for-keithp' 2012-08-06 16:42:34 -07:00
Peter Hutterer cb306a8f17 dix: make sure the mask is set for emulated scroll events (#52508)
If a device has smooth scrolling axes, but submits scroll button events, we
convert those to motion events and update the valuators. For legacy button
events, the valuator mask is likely unset though, causing
add_to_scroll_valuator() to return early, leaving us with an empty mask.
That again skipped the rest of the code and no events were generated.

Fix it by making sure that the scroll valuator in the mask is at least
initialized to 0.

Broke evdev wheel emulation, introduced by
54476b5e44.

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

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Chase Douglas <chase.douglas@canonical.com>
2012-08-07 09:39:56 +10:00
Dave Airlie 1a465fef9b pixmap: have slave pixmap take a reference on master pixmap
Since the free routines free the master pixmap then the slave, we should
be taking a reference when we bind them together.

Fixes a use-after-free when resizing a primed gears.

Signed-off-by: Dave Airlie <airlied@redhat.com>
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2012-08-07 08:25:06 +10:00
Alan Coopersmith c37c65052f Make indentation of dix/tables.c much more consistent and readable
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Acked-by: Daniel Stone <daniel@fooishbar.org>
2012-08-06 15:22:53 -07:00
Alan Coopersmith 9f7ef7f7f0 Fix up formatting of initializers for arrays of structs
The indenter seems to have gotten confused by initializing arrays of
structs with the struct defined inline - for predefined structs it did
a better job, so match that.

Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
2012-08-06 15:22:53 -07:00
Daniel Stone 59c2c4f645 AllocDevicePair: Ensure XKB privates are initialised
Since we call directly into XKB and may be doing so before the extension
has been initialised, make sure its privates are set up first.  XTest
had a hack to do this itself, but seems cleaner to just make sure we do
it in AllocDevicePair.

Signed-off-by: Daniel Stone <daniel@fooishbar.org>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
Signed-off-by: Keith Packard <keithp@keithp.com>
2012-07-10 23:12:39 -07:00
Keith Packard 34cf559bcf ProcGetPointerMapping uses rep.nElts before it is initialized
In:

	commit d792ac125a
	Author: Alan Coopersmith <alan.coopersmith@oracle.com>
	Date:   Mon Jul 9 19:12:43 2012 -0700

	    Use C99 designated initializers in dix Replies

the initializer for the .length element of the xGetPointerMappingReply
structure uses the value of rep.nElts, but that won't be set until
after this initializer runs, so we get garbage in the length element
and clients using it will generally wedge.

Easy to verify:

	$ xmodmap -pp

Fixed by creating a local nElts variable and using that.

Signed-off-by: Keith Packard <keithp@keithp.com>
Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com>
2012-07-10 23:07:06 -07:00
Keith Packard 6e12cb147d Merge branch 'local-fixes' 2012-07-10 00:52:11 -07:00
Alan Coopersmith ad4092cf7d Replace padlength tables with inline functions from misc.h
Adds new function padding_for_int32() and uses existing pad_to_int32()
depending on required results.

Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Reviewed-by: Keith Packard <keithp@keithp.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
Tested-by: Daniel Stone <daniel@fooishbar.org>
2012-07-09 22:52:30 -07:00
Alan Coopersmith 1622dd8ab2 Use C99 designated initializers in dix registry
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
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
Alan Coopersmith d792ac125a Use C99 designated initializers in dix Replies
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 19:58:29 -07:00
Alan Coopersmith 69fa5630b5 Use C99 designated initializers in SendErrorToClient
Let the compiler worry about 0-filling the rest of the fields,
instead of memsetting the whole struct and then going back to
overwrite some of the fields.

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 19:58:29 -07:00
Alan Coopersmith 5b86c072d1 Use temporary variables instead of parts of reply structures
When passing variable pointers to functions or otherwise doing long
sequences to compute values for replies, create & use some new
temporary variables, to allow for simpler initialization of reply
structures in the following patches.

Move memsets & other initializations to group with the rest of the
filling in of the reply structure, now that they're not needed so
early in the code path.

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 19:14:50 -07:00
Alan Coopersmith c2fb1a7b2a ProcQueryKeymap: rework logic around permission to copy key states
Always initialize to zero, and then if permission is granted, copy
the current key state maps, instead of always copying and then
zeroing out if permission was denied.

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 19:14:50 -07:00
Alan Coopersmith dccb0858d7 Core events: invert check for permission to copy key states
Always initialize to zero, and then if permission is granted, copy
the current key state maps.   Use memcpy instead of memmove for the
copy, since we're always copying to a newly allocated event on the
stack, so guaranteed not to overlap with the device map structure.

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 19:14:50 -07:00
Alan Coopersmith db69212df8 Rework reply initialization in ProcGetProperty & NullPropertyReply
Don't need to pass an empty reply to NullPropertyReply, let it make
it's own.   Move reply initialization code in remaining replies in
ProcGetProperty to group with the rest of the fields.   (Prepares
for coming C99 designated initializer conversion.)

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 19:14:50 -07:00
Alan Coopersmith 6be74a9080 Fix more poorly indented/wrapped comments & code
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 19:14:50 -07:00
Alan Coopersmith 789d64e19a Remove unneccesary casts from WriteToClient calls
Casting return to (void) was used to tell lint that you intended
to ignore the return value, so it didn't warn you about it.

Casting the third argument to (char *) was used as the most generic
pointer type in the days before compilers supported C89 (void *)
(except for a couple places it's used for byte-sized pointer math).

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 19:12:56 -07:00
Keith Packard ea8b04507e privates: Resize GPU screen-specific privates too
When allocating new global privates, make sure the gpu
screens get their private offsets updated.

This only affects GPU screens that enumerate before the non-GPU
screens, which generally requires that the related device be present
when the system boots so that it can get an earlier DRM filename.

Signed-off-by: Keith Packard <keithp@keithp.com>
2012-07-09 16:30:24 -07:00
Dave Airlie 12905dfaf0 dix/xf86: initial offload slave tracking (v1.1)
add the linked list and provider hooks.

v1.1: add another assert in the add path.

Reviewed-by: Keith Packard <keithp@keithp.com>
Reviewed-by: Adam Jackson <ajax@redhat.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>
2012-07-07 10:37:45 +01:00
Dave Airlie 9b8217f9ef dix/pixmap: track dirty pixmaps in server. (v4)
This adds two functions for drivers to use directly to keep a
linked list of slave pixmaps to do damage tracking on and keep
updated. It also adds a helper function that drivers may optionally
call to do a simple copy area damage update.

v2: use damage.h not damagestr.h, fixes ephyr build.

v3: address ajax review: use slave_dst, drop unused dst member.

v4: check DamageCreate return, add SourceValidate comment,
add a comment addressing possible optimisation possibility

Reviewed-by: Keith Packard <keithp@keithp.com>
Reviewed-by: Adam Jackson <ajax@redhat.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>
2012-07-07 10:37:11 +01:00
Dave Airlie f2da2c1204 randr: add initial scanout pixmap support (v3)
When randr notices a crtc configuration request for a slave device,
it checks if the slave allocated pixmap exists and is suitable,
if not it allocates a new shared pixmap from the master, shares
it to the slave, and starts the master tracking damage to it,
to keep it updated from the current front pixmap.

If the resize means the crtc is no longer used it will destroy
the slave pixmap.

This adds the concept of a scanout_pixmap to the randr_crtc object,
and also adds a master pixmap pointer to the pixmap object, along
with defining some pixmap helper functions for getting pixmap box/regions.

v2: split out pixmap sharing to a separate function.

v3: update for void *

Reviewed-by: Keith Packard <keithp@keithp.com>
Reviewed-by: Adam Jackson <ajax@redhat.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>
2012-07-07 10:37:10 +01:00
Dave Airlie 382dd45bb8 dix: add ability to link output slave gpus to the current gpu (v1.1)
Just add the interfaces to attach/detach output slaves, and
a linked list to keep track of them. Hook up the randr providers
list to include these slaves.

v1.1: add another assert to the add path.

Reviewed-by: Keith Packard <keithp@keithp.com>
Reviewed-by: Adam Jackson <ajax@redhat.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>
2012-07-07 10:37:10 +01:00
Dave Airlie 4caad34c93 dix: add unattached list for attaching screens to initially. (v1.1)
This list is meant for attaching unbound gpu screens to initially,
before the client side rebinds them.

v1.1: add another assert in the add path.

Reviewed-by: Keith Packard <keithp@keithp.com>
Reviewed-by: Adam Jackson <ajax@redhat.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>
2012-07-06 22:16:13 +01:00
Dave Airlie 9d17981829 dix: introduce gpu screens. (v5)
This patch introduces gpu screens into screenInfo. It adds interfaces
for adding and removing gpu screens, along with adding private fixup,
block handler support, and scratch pixmap init.

GPU screens have a myNum that is offset by GPU_SCREEN_OFFSET (256),
this is used for logging etc.

RemoveGPUScreen isn't used until "xfree86: add platform bus hotplug support".

v2: no glyph pictures for GPU screens for now.
v3: introduce MAXGPUSCREENS, fix return value check
v4: fixup myNum when renumbering screens (ajax)
v5: drop cursor privates for now.

Reviewed-by: Keith Packard <keithp@keithp.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>
2012-07-06 10:35:13 +01:00
Dave Airlie 3478af3374 screen: split out screen init code. (v2)
This is a precursor for reusing this code to init gpu screens.

v2: fixup int check as per Keith's review.

Reviewed-by: Keith Packard <keithp@keithp.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>
2012-07-06 10:20:19 +01:00
Keith Packard 9e4b8b74b0 privates: Allow device privates to be allocated after server start
This will permit midispcur to allocate its privates for hotplug outputs

Signed-off-by: Keith Packard <keithp@keithp.com>
Reviewed-by: Dave Airlie <airlied@redhat.com>
2012-07-05 13:40:27 -07:00
Keith Packard 493ad83323 dix: Allocate device privates separate from devices
This will allow device privates to be resized.

Signed-off-by: Keith Packard <keithp@keithp.com>
Reviewed-by: Dave Airlie <airlied@redhat.com>
2012-07-05 13:40:25 -07:00
Keith Packard 9d457f9c55 Add screen-specific privates.
Screen-specific privates areas are only allocated for objects related
to the target screen; objects allocated for other screens will not
have the private space reserved. This saves memory in these objects
while also allowing hot-plug screens to have additional private
allocation space beyond what the core screens are using.

Drivers are encouraged to switch to this mechanism as it will reduce
memory usage in multi-GPU environments, but it is only required for
drivers which will be loaded after the server starts, like
modesetting.

Objects providing screen-specific privates *must* be managed by the
screen-specific private API when allocating or initializing privates
so that the per-screen area can be initialized properly.

The objects which support screen-specific privates are:

	Windows
	Pixmaps
	GCs
	Pictures

Extending this list to include Colormaps would be possible, but
require slightly more work as the default colormap is created before
all colormap privates are allocated during server startup, and hence
gets a bunch of special treatment.

Of particular note, glyphs are *not* capable of supporting
screen-specific privates as they are global objects, not allocated on
a screen-specific basis, and so each driver must be able to see their
privates within the glyph.

Signed-off-by: Keith Packard <keithp@keithp.com>
Reviewed-by: Dave Airlie <airlied@redhat.com>
2012-07-05 13:39:50 -07:00
Peter Hutterer a9c09f8f8e dix: fix memory leak in TouchEventHistoryReplay
Don't leak if ti->history is NULL.

Found by coverity.

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

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Dave Airlie <airlied@redhat.com>
2012-07-04 21:16:16 +10:00
Keith Packard 24525d96a3 Merge branch 'sigsafe-logging-varargs'
This merge includes a minor fixup for '%p' arguments; must cast to
uintptr_t instead of uint64_t as we use -Werror=pointer-to-int-cast
which complains when doing a cast (even explicitly) from a pointer
to an integer of different size.
2012-07-02 22:35:39 -07:00
Chase Douglas 7f4a69b628 Log messages in TouchBeginDDXTouch() in a signal-safe manner
Signed-off-by: Chase Douglas <chase.douglas@canonical.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2012-07-02 22:34:32 -07:00
Chase Douglas f752226e40 Log messages in GetTouchEvents() in a signal safe manner
Signed-off-by: Chase Douglas <chase.douglas@canonical.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2012-07-02 22:34:32 -07:00
Alan Coopersmith a00066d291 Add dixGetGlyphs to replace GetGlyphs from libXfont to simplify linking
No other Xfont consumer used it, and this saves us from having to link
callers against libXfont for one simple function when doing
-no-undefined symbols builds.

The function is given a new name to avoid clashing with existing libXfont
binaries, but a #define is provided to preserve the API so we don't have
to fix all the callers at the same time.

Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Reviewed-by: Yaakov Selkowitz <yselkowitz@users.sourceforge.net>
2012-07-02 10:09:08 -07:00
Dave Airlie 957bf959fb dix/render: consolidate window format matching code.
This code existed in 3 different forms, perhaps it should be
consolidated.

Reviewed-by: Keith Packard <keithp@keithp.com>
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>
Signed-off-by: Keith Packard <keithp@keithp.com>
2012-06-28 10:43:35 -07:00
Keith Packard 59294a2179 Merge remote-tracking branch 'whot/for-keith' 2012-06-28 10:11:44 -07:00
Alan Coopersmith 687536b104 Fix some overly indented/poorly line wrapped comments in dix/events.c
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Keith Packard <keithp@keithp.com>
2012-06-20 21:41:42 -07:00
Alan Coopersmith 93a378aad4 OtherClientGone: Remove unreachable return statement
Now that FatalError is marked as _X_NORETURN, the compilers know we
can't get here, and the return statement added to make them happy in
the past now makes them unhappy.

Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Keith Packard <keithp@keithp.com>
2012-06-20 21:41:37 -07:00
Peter Hutterer 54476b5e44 dix: if the scroll valuator reaches INT_MAX, reset to 0
Too much scrolling down may eventually trigger an overflow of the valuator.
If this happens, reset the valuator to 0 and skip this event for button
emulation. Clients will have to figure out a way to deal with this, but a
scroll event from (close to) INT_MAX to 0 is a hint of that it needs to be
ignored.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Chase Douglas <chase.douglas@canonical.com>
2012-06-20 10:36:11 +10:00
Keith Packard 6d86b64dba Merge remote-tracking branch 'whot/for-keith' 2012-06-14 11:05:22 -07:00
Peter Hutterer 4c68f5d395 dix: disable all devices before shutdown
f3410b97cf introduced a regression on server
shutdown. If any button or key was held on shutdown (ctrl, alt, backspace
are usually still down) sending a raw event will segfault the server. The
the root windows are set to NULL before calling CloseDownDevices().

Avoid this by disabling all devices first when shutting down. Disabled
devices won't send events anymore.

Master keyboards must be disabled first, otherwise disabling the pointer
will trigger DisableDevice(keyboard) and the keyboard is removed from the
inputInfo.devices list and moved to inputInfo.off_devices. A regular loop
through inputInfo.devices would thus jump to off_devices and not recover.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Acked-by: Chase Douglas <chase.douglas@canonical.com>
Reviewed-by: Chase Douglas <chase.douglas@canonical.com>
2012-06-07 14:13:51 +10:00
Peter Hutterer e433d1046c dix: disable non-sprite-owners first when disabling paired devices
If a sprite-owner is to be disabled but still paired, disable the paired
device first. i.e. disabling a master pointer will disable the master
keyboard first.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Chase Douglas <chase.douglas@canonical.com>
2012-06-07 14:13:47 +10:00
Peter Hutterer df1704365e dix: free the sprite when disabling the device
Disabled devices don't need sprites (they can't send events anyway) and the
device init process is currently geared to check for whether sprite is
present to check if the device should be paired/attached.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Chase Douglas <chase.douglas@canonical.com>
2012-06-07 14:13:45 +10:00
Peter Hutterer e57d6a8902 dix: move freeing the sprite into a function
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Chase Douglas <chase.douglas@canonical.com>
2012-06-07 14:13:44 +10:00
Peter Hutterer 46adcefb0e dix: return early from DisableDevice if the device is already disabled
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Chase Douglas <chase.douglas@canonical.com>
2012-06-07 14:13:43 +10:00
Peter Hutterer 076f9d3a66 dix: drop client argument from PairDevices - unused
This is a leftover from early MPX days where any keyboard could be paired
with any pointer (before the device hierarchy).

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Chase Douglas <chase.douglas@canonical.com>
2012-06-07 14:13:41 +10:00
Peter Hutterer d034605f39 dix: rename shadowing loop variable in TouchResizeQueue
second 'i' shadows the function-wide one, rename to 'j'

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Chase Douglas <chase.douglas@canonical.com>
2012-06-07 13:31:41 +10:00
Peter Hutterer a86f3ef511 dix: change "still paired warning" to use BUG_RETURN_VAL
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Chase Douglas <chase.douglas@canonical.com>
2012-06-07 13:31:06 +10:00
Peter Hutterer 4bcf43919a dix: use BUG_RETURN_VAL for pairing errors
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Chase Douglas <chase.douglas@canonical.com>
Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com>
2012-06-07 13:30:58 +10:00
Peter Hutterer 642569fc79 Replace a few BUG_WARN with BUG_RETURN_VAL
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Chase Douglas <chase.douglas@canonical.com>
2012-06-07 13:30:54 +10:00
Dave Airlie 1f0e8bd5eb api: rework the X server driver API to avoid global arrays.
This is a squash merge containing all the API changes, as
well as the video ABI bump.

Its been squashed to make bisection easier.

Full patch log below:

commit b202738bbf0c5a1c1172767119c2c71f1e7f8070
Author: Aaron Plattner <aplattner@nvidia.com>
Date:   Mon May 14 15:16:11 2012 -0700

    xfree86: Bump video ABI to 13.0

    The ABI was broken by changes to convert from screen index numbers to ScreenPtr
    / ScrnInfoPtr in various structures and function signatures.

    Signed-off-by: Aaron Plattner <aplattner@nvidia.com>
    Reviewed-by: Dave Airlie <airlied@redhat.com>
    Signed-off-by: Dave Airlie <airlied@redhat.com>

commit 3d5f7d9f8d408bcad3f83277d255f25d3b0edbf3
Author: Dave Airlie <airlied@redhat.com>
Date:   Thu May 24 10:56:57 2012 +0100

    xf86: xf86ClearEntityListForScreen should take a pScrn

    When adding GPU screens this make life easier.

    (also fix comment, as pointed out by Alan)

    Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com>
    Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
    Signed-off-by: Dave Airlie <airlied@redhat.com>

commit afee8b5ab4501597ecc1ade34124d7ca227ab055
Author: Dave Airlie <airlied@redhat.com>
Date:   Thu May 24 07:07:32 2012 +0100

    xf86i2c: add pscrn for drivers to use

    This just adds a pScrn pointer into the struct for the drivers to use
    instead of scrnIndex. Mostly scrnIndex is used for logging, but some
    drivers use it to lookup xf86Screens, so let them stash a pScrn instead.

    Removing the scrnIndex is a bit more involved and I'm not sure its worth
    the effort. Doing i2c in the X server is legacy code as far as I'm concerned.

    Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
    Signed-off-by: Dave Airlie <airlied@redhat.com>

commit ea5092f1f679691d187f1eee9427e6057beec56e
Author: Dave Airlie <airlied@redhat.com>
Date:   Wed May 23 19:25:20 2012 +0100

    dix/gc: consolidate GC object creation in one place

    The standard GC create and scratch GC create were 90% the same really,
    and I have a need in the future for creating GC objects without the
    other bits, so wanted to avoid a third copy.

    Reviewed-by: Keith Packard <keithp@keithp.com>
    Signed-off-by: Dave Airlie <airlied@redhat.com>

commit 3d91482ea9b4883e64e496f2768168e0ffa21ba1
Author: Dave Airlie <airlied@redhat.com>
Date:   Wed May 23 10:24:06 2012 +0100

    xf86: add a define to denote the new non-index interfaces are being used

    This can be used by drivers to provide compatible APIs.

    Reviewed-by: Keith Packard <keithp@keithp.com>
    Signed-off-by: Dave Airlie <airlied@redhat.com>

commit 37c3ae3e6cd4f3dedc72f371096d6743f8f99df3
Author: Dave Airlie <airlied@redhat.com>
Date:   Wed May 23 15:09:12 2012 +0100

    dix: make Create/Free scratch pixmaps take a ScreenPtr

    While technically an API/ABI change I doubt anyone uses it,
    but it helps in splitting screens up.

    Reviewed-by: Keith Packard <keithp@keithp.com>
    Signed-off-by: Dave Airlie <airlied@redhat.com>

commit 75f2062a3fe94f04764ecc7d2ff2fbbeccb9da60
Author: Dave Airlie <airlied@redhat.com>
Date:   Wed May 23 14:57:55 2012 +0100

    xf86/xv: remove scrnIndexfrom xf86FindXvOptions.

    Move this interface to taking an ScrnInfoPtr.

    Reviewed-by: Keith Packard <keithp@keithp.com>
    Signed-off-by: Dave Airlie <airlied@redhat.com>

commit f80c2374f40ea7b2ee0556e2e76cc07406f3d843
Author: Dave Airlie <airlied@redhat.com>
Date:   Wed May 23 14:53:59 2012 +0100

    xf86: make xf86DeleteScreen take a ScrnInfoPtr (v2)

    stop passing indices into this function.

    v2: drop flags argument.

    Reviewed-by: Keith Packard <keithp@keithp.com>
    Signed-off-by: Dave Airlie <airlied@redhat.com>

commit 58824e414f35682435f15bfe6c4b656bd90b9235
Author: Dave Airlie <airlied@redhat.com>
Date:   Wed May 23 14:48:09 2012 +0100

    xf86: fix xf86IsScreenPrimary interface to take a pScrn (API/ABI)

    Reviewed-by: Keith Packard <keithp@keithp.com>
    Signed-off-by: Dave Airlie <airlied@redhat.com>

commit 6b4fc1f9d391bcdf7ca288766e49bce60f4635cd
Author: Dave Airlie <airlied@gmail.com>
Date:   Tue Apr 10 14:18:59 2012 +0100

    xserver: convert block/wakeup handlers to passing ScreenPtr (ABI/API) (v2)

    Instead of passing an index, pass the actual ScreenPtr. This allows
    more moving towards not abusing xf86Screens + screenInfo.

    v2: drop the blockData/wakeupData args as per ajax's suggestion.,
    fix docs.

    Reviewed-by: Keith Packard <keithp@keithp.com>
    Signed-off-by: Dave Airlie <airlied@redhat.com>

commit 790d003de20fb47674420a24dadd92412d78620d
Author: Dave Airlie <airlied@gmail.com>
Date:   Wed Apr 11 09:53:14 2012 +0100

    xf86/common: remove some more pScrn->pScreen uses

    remove some more conversions that appeared after api cleanups.

    Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com>
    Acked-by: Aaron Plattner <aplattner@nvidia.com>
    Reviewed-by: Adam Jackson <ajax@redhat.com>
    Signed-off-by: Dave Airlie <airlied@redhat.com>

commit aac85e18d1dd093f2cad6bd29375e40bd7af0b8f
Author: Dave Airlie <airlied@gmail.com>
Date:   Tue Apr 10 16:34:53 2012 +0100

    ddc: change API to take ScrnInfoPtr (v2)

    This removes all xf86Screens usage from ddc code,
    it modifies the API for some functions to avoid taking indices.

    v2: address Alan's comments about dropping DDC2Init parameter.

    Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com>
    Acked-by: Aaron Plattner <aplattner@nvidia.com>
    Reviewed-by: Adam Jackson <ajax@redhat.com>
    Signed-off-by: Dave Airlie <airlied@redhat.com>

commit fe3f57b6eaf6860a33876a54f9439f69578f03a5
Author: Dave Airlie <airlied@gmail.com>
Date:   Tue Apr 10 16:31:26 2012 +0100

    vbe: don't use index for VBEInterpretPanelID (API)

    Remove use of xf86screens from vbe module.

    Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com>
    Acked-by: Aaron Plattner <aplattner@nvidia.com>
    Reviewed-by: Adam Jackson <ajax@redhat.com>
    Signed-off-by: Dave Airlie <airlied@redhat.com>

commit abf1965f4ed91529036d3fdb470d6a3ce6f29675
Author: Dave Airlie <airlied@gmail.com>
Date:   Tue Apr 10 16:25:11 2012 +0100

    int10/vbe: don't use xf86Screens. (ABI) (v3)

    Pass the ScrnInfoPtr instead of the index in the int10 struct.

    This saves us using it to dereference xf86Screens.

    v2: address Alan's comment to fix struct alignment.

    v3: squash in all the int10 fixes, test the vm86 code builds,
    after comments by Keith.

    Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com>
    Acked-by: Aaron Plattner <aplattner@nvidia.com>
    Reviewed-by: Adam Jackson <ajax@redhat.com>
    Signed-off-by: Dave Airlie <airlied@redhat.com>

commit 23cca612b4fb5efc33683c7624b803b457387e3d
Author: Dave Airlie <airlied@gmail.com>
Date:   Tue Apr 10 15:30:18 2012 +0100

    xserver: drop index argument to ScreenInit (ABI/API) (v2)

    This drops the index argument, its the same as pScreen->myNum,
    and its the last major index abuse I can find.

    v2: address Alan's review - update docs, fix xwin/xnest/darwin

    Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com>
    Acked-by: Aaron Plattner <aplattner@nvidia.com>
    Reviewed-by: Adam Jackson <ajax@redhat.com>
    Signed-off-by: Dave Airlie <airlied@redhat.com>

commit 40d360e2d7e832407f3ed64e3a02c27ecc89a960
Author: Dave Airlie <airlied@gmail.com>
Date:   Tue Apr 10 15:23:01 2012 +0100

    xf86: migrate PointerMoved from index to ScrnInfoPtr (ABI/API)

    This migrates PointerMoved from an index to ScrnInfoPtr.

    Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com>
    Acked-by: Aaron Plattner <aplattner@nvidia.com>
    Reviewed-by: Adam Jackson <ajax@redhat.com>
    Signed-off-by: Dave Airlie <airlied@redhat.com>

commit aa60a2f38679d0eeb979a9c2648c9bc771409bf9
Author: Dave Airlie <airlied@gmail.com>
Date:   Tue Apr 10 15:20:46 2012 +0100

    xf86: migrate PMEvent to a ScrnInfoPtr (ABI/API)

    This migrates the PMEvent from index to ScrnInfoPtr.

    Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com>
    Acked-by: Aaron Plattner <aplattner@nvidia.com>
    Reviewed-by: Adam Jackson <ajax@redhat.com>
    Signed-off-by: Dave Airlie <airlied@redhat.com>

commit d3f28ef44371ed4a039ffc5dd7eb6408d1269ba2
Author: Dave Airlie <airlied@gmail.com>
Date:   Tue Apr 10 15:18:30 2012 +0100

    xf86: migrate SetDGAMode from index to ScrnInfoPtr (ABI/API)

    This migrates the SetDGAMode callback from an index to ScrnInfoPtr.

    Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com>
    Acked-by: Aaron Plattner <aplattner@nvidia.com>
    Reviewed-by: Adam Jackson <ajax@redhat.com>
    Signed-off-by: Dave Airlie <airlied@redhat.com>

commit baf5e4818a74f2b68c3dfdcc56f54322351039a0
Author: Dave Airlie <airlied@gmail.com>
Date:   Tue Apr 10 15:14:11 2012 +0100

    xf86: migrate ChangeGamma from index to ScrnInfoPtr (ABI/API) (v2)

    This migrates the ChangeGamma interface to avoid passing a index.

    v2: fix xf86RandR12.c + xf86cmap.c call

    Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com>
    Acked-by: Aaron Plattner <aplattner@nvidia.com>
    Reviewed-by: Adam Jackson <ajax@redhat.com>
    Signed-off-by: Dave Airlie <airlied@redhat.com>

commit 51e5f90ada929d6b23176090badbb42fdb3fa550
Author: Dave Airlie <airlied@gmail.com>
Date:   Tue Apr 10 15:11:09 2012 +0100

    xf86/exa: migrate index to screen types for EnableDisableFBAccess (ABI/API)

    The EXA interface migrates to ScreenPtr,
    and the xf86 interface migrated to ScrnInfoPtr.

    Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com>
    Acked-by: Aaron Plattner <aplattner@nvidia.com>
    Reviewed-by: Adam Jackson <ajax@redhat.com>
    Signed-off-by: Dave Airlie <airlied@redhat.com>

commit 94f1f21d17e86f96d4a54292a399160950087675
Author: Dave Airlie <airlied@gmail.com>
Date:   Tue Apr 10 15:02:11 2012 +0100

    xf86: migrate ValidMode callback to ScrnInfoPtr (ABI/API)

    This migrates the ValidMode to passing a ScrnInfoPtr instead
    of an index.

    Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com>
    Acked-by: Aaron Plattner <aplattner@nvidia.com>
    Reviewed-by: Adam Jackson <ajax@redhat.com>
    Signed-off-by: Dave Airlie <airlied@redhat.com>

commit 3f8f18198fed4f39ec805b508a3482e91eea26b2
Author: Dave Airlie <airlied@gmail.com>
Date:   Tue Apr 10 14:59:46 2012 +0100

    xf86: migrate SwitchMode to taking ScrnInfoPtr (ABI/API) (v2)

    This migrate the SwitchMode interface to take a ScrnInfoPtr
    instead of an index.

    v2: drop flags.

    Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com>
    Acked-by: Aaron Plattner <aplattner@nvidia.com>
    Reviewed-by: Adam Jackson <ajax@redhat.com>
    Signed-off-by: Dave Airlie <airlied@redhat.com>

commit d06a038a5c49328ab3a8d969d24f9fcd22c63202
Author: Dave Airlie <airlied@gmail.com>
Date:   Tue Apr 10 14:50:37 2012 +0100

    xf86: move AdjustFrame to passing ScrnInfoPtr (ABI/API) (v2)

    This converts AdjustFrame code paths to passing a ScrnInfoPtr
    instead of an integer index.

    v2: drop flags args.

    Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com>
    Acked-by: Aaron Plattner <aplattner@nvidia.com>
    Reviewed-by: Adam Jackson <ajax@redhat.com>
    Signed-off-by: Dave Airlie <airlied@redhat.com>

commit 53d2f8608ffd4090d08e7d5cf2e92fb954959b90
Author: Dave Airlie <airlied@gmail.com>
Date:   Tue Apr 10 14:41:27 2012 +0100

    xf86: modify FreeScreen callback to take pScrn instead of index. (ABI/API) (v2)

    Another index->pScrn conversion.

    v2: drop flags arg.

    Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com>
    Acked-by: Aaron Plattner <aplattner@nvidia.com>
    Reviewed-by: Adam Jackson <ajax@redhat.com>
    Signed-off-by: Dave Airlie <airlied@redhat.com>

commit 60db37c0b247052e0f5c54b1921fe58a3609c2e3
Author: Dave Airlie <airlied@gmail.com>
Date:   Tue Apr 10 14:35:41 2012 +0100

    xf86: change EnterVT/LeaveVT to take a ScrnInfoPtr (ABI/API break) (v2)

    This modifies the EnterVT/LeaveVT interfaces to take a ScrnInfoPtr
    instead of an index into xf86Screens. This allows dropping more
    public dereferences of the xf86Screens and screenInfo.

    v2: drop flags args as suggested by Keith, fix docs.

    Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com>
    Acked-by: Aaron Plattner <aplattner@nvidia.com>
    Reviewed-by: Adam Jackson <ajax@redhat.com>
    Signed-off-by: Dave Airlie <airlied@redhat.com>

commit 06729dbbc804a20242e6499f446acb5d94023c3c
Author: Dave Airlie <airlied@gmail.com>
Date:   Tue Apr 10 14:04:59 2012 +0100

    xserver: remove index from CloseScreen (API/ABI breakage)

    This drops the index from the CloseScreen callback,
    its always been useless really, since the pScreen contains it.

    Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com>
    Acked-by: Aaron Plattner <aplattner@nvidia.com>
    Reviewed-by: Adam Jackson <ajax@redhat.com>
    Signed-off-by: Dave Airlie <airlied@redhat.com>
2012-06-05 13:22:18 +01:00
Michal Suchanek 88c767edb0 Fix crash for motion events from devices without valuators
A WarpPointer request may trigger a motion event on a device without
valuators. That request is ignored by GetPointerEvents but during smooth
scroll emulation we dereference dev->valuators to get the number of axes.

Break out early if the device doesn't have valuators.

Signed-off-by: Michal Suchanek <hramrach@gmail.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2012-06-04 11:28:44 +10:00
Peter Hutterer ca6d25ad2d dix: Move DeviceFocusEvent from Xi into enterleave.c
This is only called from the enterleave implementation, so move it and its
helper functions to there. No functional changes.

Fixes build error introduced in 31174565ec if
building with '-Werror=implicit-function-declaration'

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Dave Airlie <airlied@redhat.com>
Reviewed-by: Jeremy Huddleston <jeremyhu@apple.com>
2012-05-17 08:50:44 +10:00
Peter Hutterer 749a593e49 dix: undo transformation for missing valuators (#49347)
last.valuators contains the transformed valuators of the device. If the
device submits events with x/y missing, we need to get that from
last.valuators and undo the transformation to that axis.

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

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Chase Douglas <chase.douglas@canonical.com>
2012-05-16 10:59:39 +10:00
Simon Thum 693a31e704 dix: indentation fixes for pointer acceleration
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>
2012-05-16 10:59:35 +10:00
Michal Suchanek 31174565ec dix: Remove redundant declarations.
Signed-off-by: Michal Suchanek <hramrach@gmail.com>
Reviewed-by: Dave Airlie <airlied@redhat.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>
2012-05-14 13:31:00 +01:00
Michal Suchanek 369edd7876 dix: don't duplicate DoFocusEvents declaration.
Signed-off-by: Michal Suchanek <hramrach@gmail.com>
Reviewed-by: Dave Airlie <airlied@redhat.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>
2012-05-14 13:17:21 +01:00
Michal Suchanek 36377fb0e8 dix: Remove redundant declarations.
Signed-off-by: Michal Suchanek <hramrach@gmail.com>
Reviewed-by: Dave Airlie <airlied@redhat.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>
2012-05-14 13:17:17 +01:00
Peter Hutterer f3410b97cf dix: when disabling a device, release all buttons and keys
A suspend-induced device disable may happen before the device gets to see
the button release event. On resume, the server's internal state still has
some buttons pressed, causing inconsistent behaviour.

Force the release and the matching events to be sent to the client.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Chase Douglas <chase.douglas@canonical.com>
2012-05-01 11:36:36 +10:00
Peter Hutterer af88b43f9e dix: don't emulate scroll events for non-existing axes (#47281)
Test case:
- create a device with REL_HWHEEL and ABS_X and ABS_Y. evdev 2.7.0 will set
  that up as device with 1 relative axis
- move pointer to VGA1
- xrandr --output VGA1 --off

Warps the pointer to the new spot and calls GPE with the x/y mask bits set.
When running through the loop to check for scroll event, this overruns the
axes and may try to emulate scroll events based on random garbage in the
memory. If that memory contained non-zero for the scroll type but near-zero
for the increment field, the server would hang in an infinite loop.

This was the trigger for this suggested, never-merged, patch here:
http://patchwork.freedesktop.org/patch/9543/

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

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Chase Douglas <chase.douglas@canonical.com>
2012-05-01 11:36:35 +10:00
Chase Douglas 5c361d59c5 TouchListenerAcceptReject: Warn and return early on bad listener index
Signed-off-by: Chase Douglas <chase.douglas@canonical.com>
Reviewed-by: Bryce Harrington <bryce@canonical.com>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2012-05-01 11:36:35 +10:00
Chase Douglas 88bacc49f0 os: Add -displayfd option
This option specifies a file descriptor in the launching process.  X
will scan for an available display number and write that number back to
the launching process, at the same time as SIGUSR1 generation.  This
means display managers don't need to guess at available display numbers.
As a consequence, if X fails to start when using -displayfd, it's not
because the display was in use, so there's no point in retrying the X
launch on a higher display number.

Signed-off-by: Adam Jackson <ajax@redhat.com>
Signed-off-by: Chase Douglas <chase.douglas@canonical.com>
Reviewed-by: Julien Cristau <jcristau@debian.org>
Tested-by: Julien Cristau <jcristau@debian.org>
Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2012-05-01 11:36:30 +10:00
Keith Packard e6308e32fe Merge remote-tracking branch 'whot/for-keith'
Touch input changes from Chase
2012-04-19 10:45:07 -05:00
Peter Hutterer 51a8d8dd19 Merge branch 'input-fixes' of git://people.freedesktop.org/~cndougla/xserver into for-keith 2012-04-19 17:03:54 +10:00
Chase Douglas 00cf1c40b2 Replay original touch begin event instead of generated begin event
The generated event does not have axes other than X and Y and has a
newer timestamp. In particular, the newer timestamp may be newer than
the real touch end event, which may be stuck in the syncEvents queue. If
a client uses the timestamps for grabbing bad things may happen.

Signed-off-by: Chase Douglas <chase.douglas@canonical.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
2012-04-18 20:36:02 -07:00
Chase Douglas 312910b4e3 Update currentTime in dispatch loop
A request, like input device grabs, may check a request timestamp
against currentTime. It is possible for currentTime to lag a previously
sent event timestamp. If the client makes a request based on such an
event timestamp, the request may fail the validity check against
currentTime unless we always update the time before processing the
request.

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

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

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

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

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

Signed-off-by: Chase Douglas <chase.douglas@canonical.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
2012-04-18 13:58:40 -07:00
Chase Douglas 2efbed23c2 When activating an explicit grab, update owning listener
Pointer passive grabs may be changed by the grabbing client. This allows
for a selecting client to change an implicit grab to an active grab,
which is the mechanism used for pop-up windows like application menus.

We need to do the same thing with touches. If the grabbing client is the
owner of a touch sequence, change the listener record to reflect the new
grab. If the grabbing client is not the owner, nothing changes for the
touch.

Signed-off-by: Chase Douglas <chase.douglas@canonical.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
2012-04-18 13:58:40 -07:00
Chase Douglas 8dfd98245d Fix copy/paste error from before git history in UpdateCurrentTimeIf()
See UpdateCurrentTime() for reference. I don't know what bug this might
trigger, but it wouldn't hurt to fix this.

Signed-off-by: Chase Douglas <chase.douglas@canonical.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
2012-04-18 13:58:40 -07:00
Chase Douglas 6ca30cb33e When deactivating an explicit pointer grab, reject all grabs on touches
Explicit pointer grabs are placed at the head of the touch listener
array for pointer emulated touches. If the grab is deactivated, we must
remove it from all touches for the device.

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

Signed-off-by: Chase Douglas <chase.douglas@canonical.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
2012-04-18 13:58:39 -07:00
Erkki Seppälä 233eab4d05 dix: add reference count of the resource to ResourceSizeRec
The ResourceSizeRec now contains the number of references to the
resource. For example a Pixmap knows this value and it can be useful
for determining the "weight" of the resource. Typically this value
is 1.

Reviewed-by: Rami Ylimäki <rami.ylimaki@vincit.fi>
Signed-off-by: Erkki Seppälä <erkki.seppala@vincit.fi>
2012-04-18 12:49:11 +03:00
Erkki Seppälä a2ac01a8ea dix: don't use a local wrapper for calling HashResourceID
Calls to Hash(client, id) were replaced with calls directly to
HashResourceID(id, clientTable[client].hashsize) and the Hash-function
was removed.

Signed-off-by: Erkki Seppälä <erkki.seppala@vincit.fi>
2012-04-18 12:44:49 +03:00
Erkki Seppälä a0b0fb83f9 dix: add hashing functions to resource.h for others to use.
The public hashing function HashResourceID uses the same hashing
hashing algorithm as resource.c uses internally, but it provides an
interface that will is usable by external modules. It provides a
parameter for the number of bits for the hash, instead of finding the
size from its internal hash table.

Signed-off-by: Erkki Seppälä <erkki.seppala@vincit.fi>
2012-04-18 12:43:54 +03:00
Erkki Seppälä 3ba0decb4b dix: add a mechanism for iterating through all subresources
The mechanism allows iterating even through subresources that don't
have specific XID's. When such 'resources' are iterated, the XID for
them will be zero. A resource type can assign an iteration function
for its subresources with SetResourceTypeFindSubResFunc; by default
resources are assumed not to contain subresources.

The purpose of this extension is to enable accurate accounting of
the resources a resource consumes or uses.

This patch provides the subresource iteration functions for Windows
and GCs.

Reviewed-by: Rami Ylimäki <rami.ylimaki@vincit.fi>
Signed-off-by: Erkki Seppälä <erkki.seppala@vincit.fi>
2012-04-18 12:36:25 +03:00
Rami Ylimäki e83388cc70 render: Report pixmap usage of pictures to resource extension.
Signed-off-by: Erkki Seppälä <erkki.seppala@vincit.fi>
Signed-off-by: Rami Ylimäki <rami.ylimaki@vincit.fi>
Reviewed-by: Mikhail Gusarov <dottedmag@dottedmag.net>
Reviewed-by: Tiago Vignatti <tiago.vignatti@nokia.com>
2012-04-18 12:31:24 +03:00
Peter Hutterer ebf214876a dix: indentation fix
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2012-04-18 15:56:37 +10:00