diff options
author | Peter Hutterer <peter.hutterer@redhat.com> | 2008-10-08 14:25:53 +1030 |
---|---|---|
committer | Peter Hutterer <peter.hutterer@redhat.com> | 2008-10-11 12:24:54 +1030 |
commit | 6f6ac982951165a6ac77b3e32750c47780ea4990 (patch) | |
tree | 8a3e4c671ccf9c85da6e4016c0506d578801a1ef /src | |
parent | a2633c807812e6e8ad9c82e2a5940dfbf370aff5 (diff) |
Add checkonly handling to property handlers.
If checkonly is TRUE, we can only check if applying the value would succeed.
The value is actually applied if checkonly is FALSE.
Diffstat (limited to 'src')
-rw-r--r-- | src/draglock.c | 21 | ||||
-rw-r--r-- | src/emuMB.c | 9 | ||||
-rw-r--r-- | src/emuWheel.c | 63 | ||||
-rw-r--r-- | src/evdev.c | 15 | ||||
-rw-r--r-- | src/evdev.h | 6 |
5 files changed, 70 insertions, 44 deletions
diff --git a/src/draglock.c b/src/draglock.c index 90809c9..86142b6 100644 --- a/src/draglock.c +++ b/src/draglock.c @@ -257,7 +257,8 @@ EvdevDragLockInitProperty(DeviceIntPtr dev) * i.e. to set bt 3 to draglock button 1, supply 0,0,1 */ int -EvdevDragLockSetProperty(DeviceIntPtr dev, Atom atom, XIPropertyValuePtr val) +EvdevDragLockSetProperty(DeviceIntPtr dev, Atom atom, XIPropertyValuePtr val, + BOOL checkonly) { InputInfoPtr pInfo = dev->public.devicePrivate; EvdevPtr pEvdev = pInfo->private; @@ -287,8 +288,11 @@ EvdevDragLockSetProperty(DeviceIntPtr dev, Atom atom, XIPropertyValuePtr val) if (meta > EVDEV_MAXBUTTONS) return BadValue; - pEvdev->dragLock.meta = meta; - memset(pEvdev->dragLock.lock_pair, 0, sizeof(pEvdev->dragLock.lock_pair)); + if (!checkonly) + { + pEvdev->dragLock.meta = meta; + memset(pEvdev->dragLock.lock_pair, 0, sizeof(pEvdev->dragLock.lock_pair)); + } } else { CARD8* vals = (CARD8*)val->data; @@ -297,11 +301,14 @@ EvdevDragLockSetProperty(DeviceIntPtr dev, Atom atom, XIPropertyValuePtr val) if (vals[i] > EVDEV_MAXBUTTONS) return BadValue; - pEvdev->dragLock.meta = 0; - memset(pEvdev->dragLock.lock_pair, 0, sizeof(pEvdev->dragLock.lock_pair)); + if (!checkonly) + { + pEvdev->dragLock.meta = 0; + memset(pEvdev->dragLock.lock_pair, 0, sizeof(pEvdev->dragLock.lock_pair)); - for (i = 0; i < val->size && i < EVDEV_MAXBUTTONS; i++) - pEvdev->dragLock.lock_pair[i] = vals[i]; + for (i = 0; i < val->size && i < EVDEV_MAXBUTTONS; i++) + pEvdev->dragLock.lock_pair[i] = vals[i]; + } } } diff --git a/src/emuMB.c b/src/emuMB.c index 5de5227..472e74f 100644 --- a/src/emuMB.c +++ b/src/emuMB.c @@ -385,7 +385,8 @@ EvdevMBEmuInitProperty(DeviceIntPtr dev) } int -EvdevMBEmuSetProperty(DeviceIntPtr dev, Atom atom, XIPropertyValuePtr val) +EvdevMBEmuSetProperty(DeviceIntPtr dev, Atom atom, XIPropertyValuePtr val, + BOOL checkonly) { InputInfoPtr pInfo = dev->public.devicePrivate; EvdevPtr pEvdev = pInfo->private; @@ -395,13 +396,15 @@ EvdevMBEmuSetProperty(DeviceIntPtr dev, Atom atom, XIPropertyValuePtr val) if (val->format != 8 || val->size != 1 || val->type != XA_INTEGER) return BadMatch; - pEvdev->emulateMB.enabled = *((BOOL*)val->data); + if (!checkonly) + pEvdev->emulateMB.enabled = *((BOOL*)val->data); } else if (atom == prop_mbtimeout) { if (val->format != 16 || val->size != 1 || val->type != XA_INTEGER) return BadMatch; - pEvdev->emulateMB.timeout = *((INT16*)val->data); + if (!checkonly) + pEvdev->emulateMB.timeout = *((INT16*)val->data); } return Success; diff --git a/src/emuWheel.c b/src/emuWheel.c index 27dec7c..246ab47 100644 --- a/src/emuWheel.c +++ b/src/emuWheel.c @@ -394,7 +394,8 @@ EvdevWheelEmuInitProperty(DeviceIntPtr dev) int -EvdevWheelEmuSetProperty(DeviceIntPtr dev, Atom atom, XIPropertyValuePtr val) +EvdevWheelEmuSetProperty(DeviceIntPtr dev, Atom atom, XIPropertyValuePtr val, + BOOL checkonly) { InputInfoPtr pInfo = dev->public.devicePrivate; EvdevPtr pEvdev = pInfo->private; @@ -404,26 +405,29 @@ EvdevWheelEmuSetProperty(DeviceIntPtr dev, Atom atom, XIPropertyValuePtr val) if (val->format != 8 || val->size != 1 || val->type != XA_INTEGER) return BadMatch; - pEvdev->emulateWheel.enabled = *((BOOL*)val->data); - /* Don't enable with zero inertia, otherwise we may get stuck in an - * infinite loop */ - if (pEvdev->emulateWheel.inertia <= 0) + if (!checkonly) { - pEvdev->emulateWheel.inertia = 10; - /* We may get here before the property is actually enabled */ - if (prop_wheel_inertia) - XIChangeDeviceProperty(dev, prop_wheel_inertia, XA_INTEGER, - 16, PropModeReplace, 1, - &pEvdev->emulateWheel.inertia, TRUE); - } + pEvdev->emulateWheel.enabled = *((BOOL*)val->data); + /* Don't enable with zero inertia, otherwise we may get stuck in an + * infinite loop */ + if (pEvdev->emulateWheel.inertia <= 0) + { + pEvdev->emulateWheel.inertia = 10; + /* We may get here before the property is actually enabled */ + if (prop_wheel_inertia) + XIChangeDeviceProperty(dev, prop_wheel_inertia, XA_INTEGER, + 16, PropModeReplace, 1, + &pEvdev->emulateWheel.inertia, TRUE); + } - /* Don't enable with negative timeout */ - if (pEvdev->emulateWheel.timeout < 0) - { - pEvdev->emulateWheel.timeout = 200; - XIChangeDeviceProperty(dev, prop_wheel_timeout, XA_INTEGER, 16, - PropModeReplace, 1, - &pEvdev->emulateWheel.timeout, TRUE); + /* Don't enable with negative timeout */ + if (pEvdev->emulateWheel.timeout < 0) + { + pEvdev->emulateWheel.timeout = 200; + XIChangeDeviceProperty(dev, prop_wheel_timeout, XA_INTEGER, 16, + PropModeReplace, 1, + &pEvdev->emulateWheel.timeout, TRUE); + } } } else if (atom == prop_wheel_button) @@ -435,16 +439,21 @@ EvdevWheelEmuSetProperty(DeviceIntPtr dev, Atom atom, XIPropertyValuePtr val) if (bt < 0 || bt >= EVDEV_MAXBUTTONS) return BadValue; - pEvdev->emulateWheel.button = bt; + + if (!checkonly) + pEvdev->emulateWheel.button = bt; } else if (atom == prop_wheel_axismap) { if (val->format != 8 || val->size != 4 || val->type != XA_INTEGER) return BadMatch; - pEvdev->emulateWheel.X.up_button = *((CARD8*)val->data); - pEvdev->emulateWheel.X.down_button = *(((CARD8*)val->data) + 1); - pEvdev->emulateWheel.Y.up_button = *(((CARD8*)val->data) + 2); - pEvdev->emulateWheel.Y.down_button = *(((CARD8*)val->data) + 3); + if (!checkonly) + { + pEvdev->emulateWheel.X.up_button = *((CARD8*)val->data); + pEvdev->emulateWheel.X.down_button = *(((CARD8*)val->data) + 1); + pEvdev->emulateWheel.Y.up_button = *(((CARD8*)val->data) + 2); + pEvdev->emulateWheel.Y.down_button = *(((CARD8*)val->data) + 3); + } } else if (atom == prop_wheel_inertia) { int inertia = *((CARD16*)val->data); @@ -455,7 +464,8 @@ EvdevWheelEmuSetProperty(DeviceIntPtr dev, Atom atom, XIPropertyValuePtr val) if (inertia < 0) return BadValue; - pEvdev->emulateWheel.inertia = inertia; + if (!checkonly) + pEvdev->emulateWheel.inertia = inertia; } else if (atom == prop_wheel_timeout) { int timeout = *((CARD16*)val->data); @@ -466,7 +476,8 @@ EvdevWheelEmuSetProperty(DeviceIntPtr dev, Atom atom, XIPropertyValuePtr val) if (timeout < 0) return BadValue; - pEvdev->emulateWheel.timeout = timeout; + if (!checkonly) + pEvdev->emulateWheel.timeout = timeout; } return Success; } diff --git a/src/evdev.c b/src/evdev.c index 1c2a559..97cc41c 100644 --- a/src/evdev.c +++ b/src/evdev.c @@ -108,7 +108,7 @@ static int EvdevCacheCompare(InputInfoPtr pInfo, Bool compare); #ifdef HAVE_PROPERTIES static void EvdevInitProperty(DeviceIntPtr dev); static int EvdevSetProperty(DeviceIntPtr dev, Atom atom, - XIPropertyValuePtr val); + XIPropertyValuePtr val, BOOL checkonly); static Atom prop_invert = 0; #endif @@ -1494,7 +1494,8 @@ EvdevInitProperty(DeviceIntPtr dev) } static int -EvdevSetProperty(DeviceIntPtr dev, Atom atom, XIPropertyValuePtr val) +EvdevSetProperty(DeviceIntPtr dev, Atom atom, XIPropertyValuePtr val, + BOOL checkonly) { InputInfoPtr pInfo = dev->public.devicePrivate; EvdevPtr pEvdev = pInfo->private; @@ -1504,9 +1505,13 @@ EvdevSetProperty(DeviceIntPtr dev, Atom atom, XIPropertyValuePtr val) BOOL* data; if (val->format != 8 || val->size != 2 || val->type != XA_INTEGER) return BadMatch; - data = (BOOL*)val->data; - pEvdev->invert_x = data[0]; - pEvdev->invert_y = data[1]; + + if (!checkonly) + { + data = (BOOL*)val->data; + pEvdev->invert_x = data[0]; + pEvdev->invert_y = data[1]; + } } return Success; diff --git a/src/evdev.h b/src/evdev.h index 525acb1..aa74481 100644 --- a/src/evdev.h +++ b/src/evdev.h @@ -133,13 +133,13 @@ unsigned int EvdevUtilButtonEventToButtonNumber(int code); #ifdef HAVE_PROPERTIES void EvdevMBEmuInitProperty(DeviceIntPtr); -int EvdevMBEmuSetProperty(DeviceIntPtr, Atom, XIPropertyValuePtr); +int EvdevMBEmuSetProperty(DeviceIntPtr, Atom, XIPropertyValuePtr, BOOL); void EvdevWheelEmuInitProperty(DeviceIntPtr); -int EvdevWheelEmuSetProperty(DeviceIntPtr, Atom, XIPropertyValuePtr); +int EvdevWheelEmuSetProperty(DeviceIntPtr, Atom, XIPropertyValuePtr, BOOL); void EvdevDragLockInitProperty(DeviceIntPtr); -int EvdevDragLockSetProperty(DeviceIntPtr, Atom, XIPropertyValuePtr); +int EvdevDragLockSetProperty(DeviceIntPtr, Atom, XIPropertyValuePtr, BOOL); #endif /* Mouse Wheel emulation */ |