summaryrefslogtreecommitdiff
path: root/dix
AgeCommit message (Collapse)AuthorFilesLines
2013-12-09bs: Set the screen's bs support level to WhenMappedAdam Jackson1-1/+5
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-09smartsched: Tweak the default scheduler intervalsAdam Jackson1-2/+3
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-10-31Add a RegionDuplicate functionKeith Packard1-0/+15
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-18Merge commit '2523a445a09a75a8baf642608d099a5e12d5437f'Keith Packard3-16/+62
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-18sync: if the idle time was reset, force alarms to trigger (#70476)Peter Hutterer1-4/+34
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-18dix: provide accessor methods for the last device event timePeter Hutterer3-15/+31
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-14Avoid use-after-free in dix/dixfonts.c: doImageText() [CVE-2013-4396]Alan Coopersmith1-0/+5
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-14dix: only deliver for the current grab typePeter Hutterer1-11/+2
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-14dix: don't attempt to deliver an event for a different grabtypePeter Hutterer1-0/+3
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-14dix: only allow button and key events to freeze a sync'd pointerPeter Hutterer1-1/+5
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-14input: calloc minimization for xi2mask_newAdam Jackson1-17/+13
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-09-10damage: Implicitly unregister on destroyAdam Jackson1-1/+0
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-10dix: FIXES is not optionalAdam Jackson2-12/+0
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-10dbe: Fold the window private private into the window privateAdam Jackson1-1/+0
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net> Signed-off-by: Adam Jackson <ajax@redhat.com>
2013-09-10dix: Remove a dead parameter from DoGetImageAdam Jackson1-57/+31
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net> Signed-off-by: Adam Jackson <ajax@redhat.com>
2013-09-06Fix bug in cursor handling.Thomas Klausner1-8/+15
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-08-30dix: check for grab type before checking XI2 maskPeter Hutterer1-1/+1
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-30DIX/Xi: Pass correct client to CheckDeviceGrabAndHintWindow()Egbert Eich1-7/+16
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-18dix: add missing include for DeleteWindowFromAnySelectionsJulien Cristau1-0/+1
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-07-25Merge remote-tracking branch 'whot/for-keith'Keith Packard2-3/+2
2013-07-25dix: set the valuator mask to ensure XI 1.x events have dataPeter Hutterer1-1/+1
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 b28a1af55cf, 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 b28a1af55cf, data in valuators is always absolute, regardless of the mode. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2013-07-24dix: check the xi2mask, not the grab type for touch listenersPeter Hutterer1-2/+1
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-23Allow DDX to provide a main()Jon TURNEY3-6/+38
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-22dix: scale y back instead of x up when pre-scaling coordinatesPeter Hutterer1-3/+3
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-17dix: allow a ConstantDeceleration between 0 and 1 (#66134)Peter Hutterer1-3/+2
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-17dix: UpdateTouchesForGrab must only free the listener grab if it is non-NULLPeter Hutterer1-1/+2
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-11dix: when ungrabbing an active grab, accept pointer grabs (#66720)Peter Hutterer1-2/+9
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-05-26dix: remove logspam in RefCursor()Peter Hutterer1-5/+1
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-23Merge remote-tracking branch 'whot/unreviewed'Keith Packard2-24/+40
2013-05-23dix: devices must have valuators before touch is initializedPeter Hutterer1-0/+1
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2013-05-23dix: fix device scaling to use a [min,max[ range.Peter Hutterer2-6/+12
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-23dix: pre-scale x by the screen:device:resolution ratioPeter Hutterer1-18/+28
commit 61a99aff9d33728a0b67920254d2d4d79f80cf39 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-15Abstract cursor refcountingPeter Hutterer4-31/+45
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-15dix: call UpdateDeviceState() for emulated TouchEndEventsPeter Hutterer1-0/+2
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-15dix: devices must have valuators before touch is initializedPeter Hutterer1-0/+1
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2013-05-15dix: fix cursor refcountingPeter Hutterer1-16/+4
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-10dix: free the old grab when activating a new grabPeter Hutterer1-1/+6
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-10Move TouchListenerGone call to CloseDownClientPeter Hutterer3-5/+3
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-10dix: remove all listeners when freeing a touchPeter Hutterer1-0/+4
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2013-05-10dix: always copy grabs, don't reference themPeter Hutterer2-3/+19
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-10dix: AllocGrab can copy if an argument is passed inPeter Hutterer2-11/+15
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2013-05-10dix: freeing a null grab is a bug, complain if doing soPeter Hutterer1-0/+2
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2013-05-10dix: use a temporary variable for listeners[0]Peter Hutterer1-8/+9
no functional changes Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2013-05-10dix: drop DeviceIntRec's activeGrab structPeter Hutterer2-6/+12
Obsolete since 4bc2761ad5ec2d0668aec639780ffb136605fbc8. 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-10dix: use a tmp variable for the to-be-removed touch listenerPeter Hutterer1-3/+4
No functional changes. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2013-05-10dix: invert a loop conditionPeter Hutterer1-12/+13
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-10dix: XAllowEvents() on a touch event means accepting itPeter Hutterer2-0/+24
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-10dix: move EmitTouchEnd to touch.cPeter Hutterer1-0/+27
No functional changes, this just enables it to be re-used easier. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2013-05-10Xi: use public.processInputProc to replay the touch historyPeter Hutterer1-1/+15
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-10dix: don't prepend an activated passive grab to the listenersPeter Hutterer1-1/+1
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>