diff options
Diffstat (limited to 'dix/getevents.c')
-rw-r--r-- | dix/getevents.c | 95 |
1 files changed, 52 insertions, 43 deletions
diff --git a/dix/getevents.c b/dix/getevents.c index 6969f782f..2a10038bc 100644 --- a/dix/getevents.c +++ b/dix/getevents.c @@ -1,23 +1,25 @@ /* * Copyright © 2006 Nokia Corporation - * Copyright © 2006 Daniel Stone + * Copyright © 2006-2007 Daniel Stone * - * Permission to use, copy, modify, distribute, and sell this software and - * its documentation for any purpose is hereby granted without fee, - * provided that the above copyright notice appear in all copies and that - * both that this copyright notice and this permission notice appear in - * supporting electronic documentation. + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. - * IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR AUTHORS BE LIABLE FOR ANY - * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, - * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE - * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. * * Author: Daniel Stone <daniel@fooishbar.org> */ @@ -443,9 +445,17 @@ GetKeyboardValuatorEvents(xEvent *events, DeviceIntPtr pDev, int type, ms = GetTimeInMillis(); + if (pDev->coreEvents) { + events->u.keyButtonPointer.time = ms; + events->u.u.type = type; + events->u.u.detail = key_code; + events++; + } + kbp = (deviceKeyButtonPointer *) events; kbp->time = ms; kbp->deviceid = pDev->id; + kbp->detail = key_code; if (type == KeyPress) kbp->type = DeviceKeyPress; else if (type == KeyRelease) @@ -459,12 +469,6 @@ GetKeyboardValuatorEvents(xEvent *events, DeviceIntPtr pDev, int type, num_valuators, valuators); } - if (pDev->coreEvents) { - events->u.keyButtonPointer.time = ms; - events->u.u.type = type; - events->u.u.detail = key_code; - } - return numEvents; } @@ -498,14 +502,18 @@ GetPointerEvents(xEvent *events, DeviceIntPtr pDev, int type, int buttons, if ((type == ButtonPress || type == ButtonRelease) && !pDev->button) return 0; + /* FIXME: I guess it should, in theory, be possible to post button events + * from devices without valuators. */ + if (!pDev->valuator) + return 0; + if (!coreOnly && pDev->coreEvents) num_events = 2; else num_events = 1; - if (type == MotionNotify && num_valuators <= 0) { + if (type == MotionNotify && num_valuators <= 0) return 0; - } /* Do we need to send a DeviceValuator event? */ if (!coreOnly && sendValuators) { @@ -599,8 +607,27 @@ GetPointerEvents(xEvent *events, DeviceIntPtr pDev, int type, int buttons, pDev->valuator->lastx = x; pDev->valuator->lasty = y; - if (!coreOnly) - { + /* for some reason inputInfo.pointer does not have coreEvents set */ + if (coreOnly || pDev->coreEvents) { + events->u.u.type = type; + events->u.keyButtonPointer.time = ms; + events->u.keyButtonPointer.rootX = x; + events->u.keyButtonPointer.rootY = y; + + if (type == ButtonPress || type == ButtonRelease) { + /* We hijack SetPointerMapping to work on all core-sending + * devices, so we use the device-specific map here instead of + * the core one. */ + events->u.u.detail = pDev->button->map[buttons]; + } + else { + events->u.u.detail = 0; + } + + events++; + } + + if (!coreOnly) { kbp = (deviceKeyButtonPointer *) events; kbp->time = ms; kbp->deviceid = pDev->id; @@ -628,24 +655,6 @@ GetPointerEvents(xEvent *events, DeviceIntPtr pDev, int type, int buttons, } } - /* for some reason inputInfo.pointer does not have coreEvents set */ - if (coreOnly || pDev->coreEvents) { - events->u.u.type = type; - events->u.keyButtonPointer.time = ms; - events->u.keyButtonPointer.rootX = x; - events->u.keyButtonPointer.rootY = y; - - if (type == ButtonPress || type == ButtonRelease) { - /* We hijack SetPointerMapping to work on all core-sending - * devices, so we use the device-specific map here instead of - * the core one. */ - events->u.u.detail = pDev->button->map[buttons]; - } - else { - events->u.u.detail = 0; - } - } - return num_events; } |