[PATCH libXi 5/5] Support XI 2.1 XIScrollClass
Peter Hutterer
peter.hutterer at who-t.net
Sun Aug 21 22:35:22 PDT 2011
Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
---
include/X11/extensions/XInput2.h | 11 ++++++++++
man/XIQueryDevice.txt | 39 +++++++++++++++++++++++++++++++++++++-
src/XExtInt.c | 37 ++++++++++++++++++++++++++++++++++++
3 files changed, 86 insertions(+), 1 deletions(-)
diff --git a/include/X11/extensions/XInput2.h b/include/X11/extensions/XInput2.h
index 3fcf083..910b25f 100644
--- a/include/X11/extensions/XInput2.h
+++ b/include/X11/extensions/XInput2.h
@@ -133,6 +133,17 @@ typedef struct
int mode;
} XIValuatorClassInfo;
+/* new in XI 2.1 */
+typedef struct
+{
+ int type;
+ int sourceid;
+ int number;
+ int scroll_type;
+ double increment;
+ int flags;
+} XIScrollClassInfo;
+
typedef struct
{
int deviceid;
diff --git a/man/XIQueryDevice.txt b/man/XIQueryDevice.txt
index 09da8d6..6b5a622 100644
--- a/man/XIQueryDevice.txt
+++ b/man/XIQueryDevice.txt
@@ -100,7 +100,7 @@ DESCRIPTION
The type field specifies the type of the input class.
Currently, the following types are defined:
- XIKeyClass, XIButtonClass, XIValuatorClass
+ XIKeyClass, XIButtonClass, XIValuatorClass, XIScrollClass
In the future, additional types may be added. Clients are
required to ignore unknown input classes.
@@ -194,6 +194,43 @@ DESCRIPTION
XIModeAbsolute this axis sends absolute coordinates. If the
mode is XIModeRelative, this device sends relative coordinates.
+ typedef struct
+ {
+ int type;
+ int sourceid;
+ int number;
+ int scroll_type;
+ double increment;
+ int flags;
+ } XIScrollClassInfo;
+
+ This class describes scrolling capability on a valuator. For
+ each XIScrollClassInfo, an XIValuatorClassInfo with the same
+ number is present on the device.
+
+ The number field specifies the valuator number on the physical
+ device that this scroll information applies to. See the
+ respective XIValuatorClassInfo for detailed information on this
+ valuator.
+
+ The scroll_type field specifies the type of scrolling, either
+ XIScrollTypeVertical or XIScrollTypeHorizontal.
+
+ The increment specifies the value change considered one unit of
+ scrolling down.
+
+ The flags field specifies flags that apply to this scrolling
+ information:
+
+ If XIScrollFlagNoEmulation is set, the server will not
+ emulate legacy button events for valuator changes on this
+ valuator.
+
+ If XIScrollFlagPreferred is set, this axis is the
+ preferred axis for this scroll type and will be used for
+ the emulation of XI_Motion events when the driver submits
+ legacy scroll button events.
+
XIQueryDevice can generate a BadDevice error.
XIFreeDeviceInfo frees the information returned by
diff --git a/src/XExtInt.c b/src/XExtInt.c
index 870dc0c..d74a8d4 100644
--- a/src/XExtInt.c
+++ b/src/XExtInt.c
@@ -1039,6 +1039,9 @@ sizeDeviceClassType(int type, int num_elements)
case XIValuatorClass:
l = sizeof(XIValuatorClassInfo);
break;
+ case XIScrollClass:
+ l = sizeof(XIScrollClassInfo);
+ break;
default:
printf("sizeDeviceClassType: unknown type %d\n", type);
break;
@@ -1098,6 +1101,9 @@ copyDeviceChangedEvent(XGenericEventCookie *in_cookie,
case XIValuatorClass:
len += sizeDeviceClassType(XIValuatorClass, 0);
break;
+ case XIScrollClass:
+ len += sizeDeviceClassType(XIScrollClass, 0);
+ break;
default:
printf("copyDeviceChangedEvent: unknown type %d\n",
any->type);
@@ -1162,6 +1168,15 @@ copyDeviceChangedEvent(XGenericEventCookie *in_cookie,
out->classes[i] = (XIAnyClassInfo*)vout;
break;
}
+ case XIScrollClass:
+ {
+ XIScrollClassInfo *sin, *sout;
+ sin = (XIScrollClassInfo*)any;
+ sout = next_block(&ptr, sizeof(XIScrollClassInfo));
+ *sout = *sin;
+ out->classes[i] = (XIAnyClassInfo*)sout;
+ break;
+ }
}
}
@@ -1433,6 +1448,9 @@ size_classes(xXIAnyInfo* from, int nclasses)
case XIValuatorClass:
l = sizeDeviceClassType(XIValuatorClass, 0);
break;
+ case XIScrollClass:
+ l = sizeDeviceClassType(XIScrollClass, 0);
+ break;
}
len += l;
@@ -1545,6 +1563,25 @@ copy_classes(XIDeviceInfo* to, xXIAnyInfo* from, int *nclasses)
to->classes[cls_idx++] = any_lib;
}
break;
+ case XIScrollClass:
+ {
+ XIScrollClassInfo *cls_lib;
+ xXIScrollInfo *cls_wire;
+
+ cls_lib = next_block(&ptr_lib, sizeof(XIScrollClassInfo));
+ cls_wire = (xXIScrollInfo*)any_wire;
+
+ cls_lib->type = cls_wire->type;
+ cls_lib->sourceid = cls_wire->sourceid;
+ cls_lib->number = cls_wire->number;
+ cls_lib->scroll_type= cls_wire->scroll_type;
+ cls_lib->flags = cls_wire->flags;
+ cls_lib->increment = cls_wire->increment.integral;
+ cls_lib->increment += (unsigned int)cls_wire->increment.frac/(double)(1UL << 32);
+
+ to->classes[cls_idx++] = any_lib;
+ }
+ break;
}
len += any_wire->length * 4;
ptr_wire += any_wire->length * 4;
--
1.7.6
More information about the xorg-devel
mailing list