summaryrefslogtreecommitdiff
path: root/Xi
diff options
context:
space:
mode:
authorDaniel Stone <daniel@fooishbar.org>2011-12-14 12:46:40 +1000
committerPeter Hutterer <peter.hutterer@who-t.net>2011-12-19 09:08:36 +1000
commit3fb258ca28850c998097b55884774cb95f476f69 (patch)
tree8e620ad39a18467800e599694c9258411632988c /Xi
parent098b837440e40bbc485368ec9658e12efd6ef581 (diff)
input: add a TouchClassRec to the devices
These structs will be used to store touch-related data, events and information. Drivers must call InitTouchClassDeviceStruct to set up a multi-touch capable device. Touchpoints for the DDX and the DIX are handled separately - touchpoints submitted by the driver/DDX will be stored in the DDXTouchPointInfoRec. Once the touchpoints are processed by the DIX, new TouchPointInfoRecs are created and stored. This process is already used for pointer events with the last.valuators field. Note that this patch does not actually add the generation of touch events, only the required structs. TouchListeners are (future) recipients of touch or emulated pointer events. Each listener is in a state, depending which event they have already received. The type of listener defines how the listener got to be one. Co-authored-by: Peter Hutterer <peter.hutterer@who-t.net> Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Reviewed-by: Chase Douglas <chase.douglas@canonical.com>
Diffstat (limited to 'Xi')
-rw-r--r--Xi/exevents.c61
-rw-r--r--Xi/xiquerydevice.c39
-rw-r--r--Xi/xiquerydevice.h1
3 files changed, 101 insertions, 0 deletions
diff --git a/Xi/exevents.c b/Xi/exevents.c
index 2db605302..ffb48d1c7 100644
--- a/Xi/exevents.c
+++ b/Xi/exevents.c
@@ -44,6 +44,32 @@ SOFTWARE.
********************************************************/
+/*
+ * Copyright © 2010 Collabora Ltd.
+ * Copyright © 2011 Red Hat, Inc.
+ *
+ * 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 (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 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>
+ */
+
/********************************************************************
*
* Routines to register and initialize extension input devices.
@@ -641,6 +667,41 @@ DeepCopyPointerClasses(DeviceIntPtr from, DeviceIntPtr to)
classes->proximity = to->proximity;
to->proximity = NULL;
}
+
+ if (from->touch)
+ {
+ TouchPointInfoPtr tmp;
+ if (!to->touch)
+ {
+ classes = to->unused_classes;
+ to->touch = classes->touch;
+ if (!to->touch)
+ {
+ int i;
+ to->touch = calloc(1, sizeof(TouchClassRec));
+ if (!to->touch)
+ FatalError("[Xi] no memory for class shift.\n");
+ to->touch->num_touches = from->touch->num_touches;
+ to->touch->touches = calloc(to->touch->num_touches,
+ sizeof(TouchPointInfoRec));
+ for (i = 0; i < to->touch->num_touches; i++)
+ TouchInitTouchPoint(to->touch, to->valuator, i);
+ if (!to->touch)
+ FatalError("[Xi] no memory for class shift.\n");
+ } else
+ classes->touch = NULL;
+ }
+ tmp = to->touch->touches;
+ memcpy(to->touch, from->touch, sizeof(TouchClassRec));
+ to->touch->touches = tmp;
+ to->touch->sourceid = from->id;
+ } else if (to->touch)
+ {
+ ClassesPtr classes;
+ classes = to->unused_classes;
+ classes->touch = to->touch;
+ to->touch = NULL;
+ }
}
/**
diff --git a/Xi/xiquerydevice.c b/Xi/xiquerydevice.c
index 5f543f620..0879080ad 100644
--- a/Xi/xiquerydevice.c
+++ b/Xi/xiquerydevice.c
@@ -240,6 +240,8 @@ SizeDeviceClasses(DeviceIntPtr dev)
}
}
+ if (dev->touch)
+ len += sizeof(xXITouchInfo);
return len;
}
@@ -427,6 +429,31 @@ SwapScrollInfo(DeviceIntPtr dev, xXIScrollInfo* info)
swapl(&info->increment.frac);
}
+/**
+ * List multitouch information
+ *
+ * @return The number of bytes written into info.
+ */
+int
+ListTouchInfo(DeviceIntPtr dev, xXITouchInfo *touch)
+{
+ touch->type = XITouchClass;
+ touch->length = sizeof(xXITouchInfo) >> 2;
+ touch->sourceid = touch->sourceid;
+ touch->mode = dev->touch->mode;
+ touch->num_touches = dev->touch->num_touches;
+
+ return touch->length << 2;
+}
+
+static void
+SwapTouchInfo(DeviceIntPtr dev, xXITouchInfo* touch)
+{
+ swaps(&touch->type);
+ swaps(&touch->length);
+ swaps(&touch->sourceid);
+}
+
int GetDeviceUse(DeviceIntPtr dev, uint16_t *attachment)
{
DeviceIntPtr master = GetMaster(dev, MASTER_ATTACHED);
@@ -525,6 +552,14 @@ ListDeviceClasses(ClientPtr client, DeviceIntPtr dev,
total_len += len;
}
+ if (dev->touch)
+ {
+ (*nclasses)++;
+ len = ListTouchInfo(dev, (xXITouchInfo*)any);
+ any += len;
+ total_len += len;
+ }
+
return total_len;
}
@@ -554,6 +589,10 @@ SwapDeviceInfo(DeviceIntPtr dev, xXIDeviceInfo* info)
case XIScrollClass:
SwapScrollInfo(dev, (xXIScrollInfo*)any);
break;
+ case XITouchClass:
+ SwapTouchInfo(dev, (xXITouchInfo*)any);
+ break;
+
}
any += len * 4;
diff --git a/Xi/xiquerydevice.h b/Xi/xiquerydevice.h
index 9db6aa293..632c42eeb 100644
--- a/Xi/xiquerydevice.h
+++ b/Xi/xiquerydevice.h
@@ -45,4 +45,5 @@ int ListKeyInfo(DeviceIntPtr dev, xXIKeyInfo* info);
int ListValuatorInfo(DeviceIntPtr dev, xXIValuatorInfo* info,
int axisnumber, Bool reportState);
int ListScrollInfo(DeviceIntPtr dev, xXIScrollInfo* info, int axisnumber);
+int ListTouchInfo(DeviceIntPtr dev, xXITouchInfo* info);
#endif /* QUERYDEV_H */