From 1906e4d5c112c25c9d7a736d4924d1005267aba7 Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Thu, 22 Jan 2009 09:44:15 +1100 Subject: Reshuffle property initialization. We don't need axis calibration, etc. on keyboards, so let's do it conditionally on actually having axes. Reported by Simon Thum. Signed-off-by: Peter Hutterer --- src/evdev.c | 139 ++++++++++++++++++++++++++++++------------------------------ 1 file changed, 69 insertions(+), 70 deletions(-) diff --git a/src/evdev.c b/src/evdev.c index 7506d86..f6442fb 100644 --- a/src/evdev.c +++ b/src/evdev.c @@ -1692,6 +1692,17 @@ EvdevInitProperty(DeviceIntPtr dev) BOOL invert[2]; char reopen; + prop_reopen = MakeAtom(EVDEV_PROP_REOPEN, strlen(EVDEV_PROP_REOPEN), + TRUE); + + reopen = pEvdev->reopen_attempts; + rc = XIChangeDeviceProperty(dev, prop_reopen, XA_INTEGER, 8, + PropModeReplace, 1, &reopen, FALSE); + if (rc != Success) + return; + + XISetDevicePropertyDeletable(dev, prop_reopen, FALSE); + if (pEvdev->flags & (EVDEV_RELATIVE_EVENTS | EVDEV_ABSOLUTE_EVENTS)) { invert[0] = pEvdev->invert_x; @@ -1706,88 +1717,76 @@ EvdevInitProperty(DeviceIntPtr dev) return; XISetDevicePropertyDeletable(dev, prop_invert, FALSE); - } - - prop_reopen = MakeAtom(EVDEV_PROP_REOPEN, strlen(EVDEV_PROP_REOPEN), - TRUE); - reopen = pEvdev->reopen_attempts; - rc = XIChangeDeviceProperty(dev, prop_reopen, XA_INTEGER, 8, - PropModeReplace, 1, &reopen, FALSE); - if (rc != Success) - return; - - XISetDevicePropertyDeletable(dev, prop_reopen, FALSE); - - - prop_calibration = MakeAtom(EVDEV_PROP_CALIBRATION, - strlen(EVDEV_PROP_CALIBRATION), TRUE); - rc = XIChangeDeviceProperty(dev, prop_calibration, XA_INTEGER, 32, - PropModeReplace, 0, NULL, FALSE); - if (rc != Success) - return; - - XISetDevicePropertyDeletable(dev, prop_calibration, FALSE); - - prop_swap = MakeAtom(EVDEV_PROP_SWAP_AXES, - strlen(EVDEV_PROP_SWAP_AXES), TRUE); + prop_calibration = MakeAtom(EVDEV_PROP_CALIBRATION, + strlen(EVDEV_PROP_CALIBRATION), TRUE); + rc = XIChangeDeviceProperty(dev, prop_calibration, XA_INTEGER, 32, + PropModeReplace, 0, NULL, FALSE); + if (rc != Success) + return; - rc = XIChangeDeviceProperty(dev, prop_swap, XA_INTEGER, 8, - PropModeReplace, 1, &pEvdev->swap_axes, FALSE); - if (rc != Success) - return; + XISetDevicePropertyDeletable(dev, prop_calibration, FALSE); - XISetDevicePropertyDeletable(dev, prop_swap, FALSE); + prop_swap = MakeAtom(EVDEV_PROP_SWAP_AXES, + strlen(EVDEV_PROP_SWAP_AXES), TRUE); + rc = XIChangeDeviceProperty(dev, prop_swap, XA_INTEGER, 8, + PropModeReplace, 1, &pEvdev->swap_axes, FALSE); + if (rc != Success) + return; - /* Axis labelling - This is of course rather stupid. Because evdev doesn't really deal with - arbitrary axes yet, axis 0/1 must always be X/Y. If we have pressure, - then it's always axis 2. So the labelling is rather lame. - */ - if ((prop_label = XIGetKnownProperty(AXIS_LABEL_PROP))) - { - Atom atom, atoms[3]; + XISetDevicePropertyDeletable(dev, prop_swap, FALSE); - if (TestBit(REL_X, pEvdev->rel_bitmask)) - { - atom = XIGetKnownProperty(AXIS_LABEL_PROP_REL_X); - if (atom) - atoms[0] = atom; - } else if (TestBit(ABS_X, pEvdev->abs_bitmask)) + /* Axis labelling + This is of course rather stupid. Because evdev doesn't really deal + with arbitrary axes yet, axis 0/1 must always be X/Y. If we have + pressure, then it's always axis 2. So the labelling is rather lame. + */ + if ((prop_label = XIGetKnownProperty(AXIS_LABEL_PROP))) { - atom = XIGetKnownProperty(AXIS_LABEL_PROP_ABS_X); - if (atom) - atoms[0] = atom; - } + Atom atom, atoms[3]; - if (TestBit(REL_Y, pEvdev->rel_bitmask)) - { - atom = XIGetKnownProperty(AXIS_LABEL_PROP_REL_Y); - if (atom) - atoms[1] = atom; - } else if (TestBit(ABS_Y, pEvdev->abs_bitmask)) - { - atom = XIGetKnownProperty(AXIS_LABEL_PROP_ABS_Y); - if (atom) - atoms[1] = atom; - } + if (TestBit(REL_X, pEvdev->rel_bitmask)) + { + atom = XIGetKnownProperty(AXIS_LABEL_PROP_REL_X); + if (atom) + atoms[0] = atom; + } else if (TestBit(ABS_X, pEvdev->abs_bitmask)) + { + atom = XIGetKnownProperty(AXIS_LABEL_PROP_ABS_X); + if (atom) + atoms[0] = atom; + } - if (TestBit(ABS_PRESSURE, pEvdev->abs_bitmask)) - { - atom = XIGetKnownProperty(AXIS_LABEL_PROP_ABS_PRESSURE); - if (atom) - atoms[2] = atom; - } + if (TestBit(REL_Y, pEvdev->rel_bitmask)) + { + atom = XIGetKnownProperty(AXIS_LABEL_PROP_REL_Y); + if (atom) + atoms[1] = atom; + } else if (TestBit(ABS_Y, pEvdev->abs_bitmask)) + { + atom = XIGetKnownProperty(AXIS_LABEL_PROP_ABS_Y); + if (atom) + atoms[1] = atom; + } - if (atoms[0] != -1 && atoms[1] != -1) - { - int natoms = (pEvdev->has_pressure && atoms[2] != -1) ? 3 : 2; - XIChangeDeviceProperty(dev, prop_label, XA_ATOM, 32, - PropModeReplace, natoms, &atoms, FALSE); - XISetDevicePropertyDeletable(dev, prop_label, FALSE); + if (TestBit(ABS_PRESSURE, pEvdev->abs_bitmask)) + { + atom = XIGetKnownProperty(AXIS_LABEL_PROP_ABS_PRESSURE); + if (atom) + atoms[2] = atom; + } + + if (atoms[0] != -1 && atoms[1] != -1) + { + int natoms = (pEvdev->has_pressure && atoms[2] != -1) ? 3 : 2; + XIChangeDeviceProperty(dev, prop_label, XA_ATOM, 32, + PropModeReplace, natoms, &atoms, FALSE); + XISetDevicePropertyDeletable(dev, prop_label, FALSE); + } } } + } static int -- cgit v1.2.3