aboutsummaryrefslogtreecommitdiff
path: root/xorg-server/dix/devices.c
diff options
context:
space:
mode:
authormarha <marha@users.sourceforge.net>2011-12-23 11:12:22 +0100
committermarha <marha@users.sourceforge.net>2011-12-23 11:12:22 +0100
commit6f6a4d4a600eabf5d6a624eb5b0e98ee67afb52d (patch)
tree8dc28411ab42ebb9183bc090c10024a39fc669d6 /xorg-server/dix/devices.c
parent22891980a76b862bfcda406521b454f072090fb8 (diff)
parente22891346b85a7db40dec7260a100f90b451cbc8 (diff)
downloadvcxsrv-6f6a4d4a600eabf5d6a624eb5b0e98ee67afb52d.tar.gz
vcxsrv-6f6a4d4a600eabf5d6a624eb5b0e98ee67afb52d.tar.bz2
vcxsrv-6f6a4d4a600eabf5d6a624eb5b0e98ee67afb52d.zip
Merge remote-tracking branch 'origin/released'
Conflicts: xorg-server/glx/dispatch.h xorg-server/glx/glapi.c xorg-server/glx/indirect_dispatch.h xorg-server/glx/indirect_reqsize.c xorg-server/glx/indirect_reqsize.h xorg-server/glx/indirect_size.h xorg-server/glx/indirect_size_get.c xorg-server/glx/indirect_size_get.h xorg-server/glx/indirect_table.c xorg-server/mi/mieq.c
Diffstat (limited to 'xorg-server/dix/devices.c')
-rw-r--r--xorg-server/dix/devices.c87
1 files changed, 86 insertions, 1 deletions
diff --git a/xorg-server/dix/devices.c b/xorg-server/dix/devices.c
index e79ea5996..f01857e77 100644
--- a/xorg-server/dix/devices.c
+++ b/xorg-server/dix/devices.c
@@ -267,6 +267,7 @@ AddInputDevice(ClientPtr client, DeviceProc deviceProc, Bool autoStart)
return (DeviceIntPtr)NULL;
dev->last.scroll = NULL;
+ dev->last.touches = NULL;
dev->id = devid;
dev->public.processInputProc = ProcessOtherEvent;
dev->public.realInputProc = ProcessOtherEvent;
@@ -765,6 +766,21 @@ FreeDeviceClass(int type, pointer *class)
free((*v));
break;
}
+ case XITouchClass:
+ {
+ TouchClassPtr *t = (TouchClassPtr*)class;
+ int i;
+
+ for (i = 0; i < (*t)->num_touches; i++)
+ {
+ free((*t)->touches[i].sprite.spriteTrace);
+ free((*t)->touches[i].listeners);
+ free((*t)->touches[i].valuators);
+ }
+
+ free((*t));
+ break;
+ }
case FocusClass:
{
FocusClassPtr *f = (FocusClassPtr*)class;
@@ -873,6 +889,7 @@ FreeAllDeviceClasses(ClassesPtr classes)
FreeDeviceClass(KeyClass, (pointer)&classes->key);
FreeDeviceClass(ValuatorClass, (pointer)&classes->valuator);
+ FreeDeviceClass(XITouchClass, (pointer)&classes->touch);
FreeDeviceClass(ButtonClass, (pointer)&classes->button);
FreeDeviceClass(FocusClass, (pointer)&classes->focus);
FreeDeviceClass(ProximityClass, (pointer)&classes->proximity);
@@ -952,6 +969,9 @@ CloseDevice(DeviceIntPtr dev)
free(dev->deviceGrab.sync.event);
free(dev->config_info); /* Allocated in xf86ActivateDevice. */
free(dev->last.scroll);
+ for (j = 0; j < dev->last.num_touches; j++)
+ free(dev->last.touches[j].valuators);
+ free(dev->last.touches);
dev->config_info = NULL;
dixFreeObjectWithPrivates(dev, PRIVATE_DEVICE);
}
@@ -1427,7 +1447,6 @@ InitPtrFeedbackClassDeviceStruct(DeviceIntPtr dev, PtrCtrlProcPtr controlProc)
return TRUE;
}
-
static LedCtrl defaultLedControl = {
DEFAULT_LEDS, DEFAULT_LEDS_MASK, 0};
@@ -1550,6 +1569,72 @@ InitPointerDeviceStruct(DevicePtr device, CARD8 *map, int numButtons, Atom* btn_
InitPtrFeedbackClassDeviceStruct(dev, controlProc));
}
+/**
+ * Sets up multitouch capabilities on @device.
+ *
+ * @max_touches The maximum number of simultaneous touches, or 0 for unlimited.
+ * @mode The mode of the touch device (XIDirectTouch or XIDependentTouch).
+ * @num_axes The number of touch valuator axes.
+ */
+Bool
+InitTouchClassDeviceStruct(DeviceIntPtr device, unsigned int max_touches,
+ unsigned int mode, unsigned int num_axes)
+{
+ TouchClassPtr touch;
+ int i;
+
+ if (device->touch || !device->valuator)
+ return FALSE;
+
+ /* Check the mode is valid, and at least X and Y axes. */
+ if (mode != XIDirectTouch && mode != XIDependentTouch)
+ return FALSE;
+ if (num_axes < 2)
+ return FALSE;
+
+ if (num_axes > MAX_VALUATORS)
+ {
+ LogMessage(X_WARNING,
+ "Device '%s' has %d touch axes, only using first %d.\n",
+ device->name, num_axes, MAX_VALUATORS);
+ num_axes = MAX_VALUATORS;
+ }
+
+ touch = calloc(1, sizeof(*touch));
+ if (!touch)
+ return FALSE;
+
+ touch->max_touches = max_touches;
+ if (max_touches == 0)
+ max_touches = 5; /* arbitrary number plucked out of the air */
+ touch->touches = calloc(max_touches, sizeof(*touch->touches));
+ if (!touch->touches)
+ goto err;
+ touch->num_touches = max_touches;
+ for (i = 0; i < max_touches; i++)
+ TouchInitTouchPoint(touch, device->valuator, i);
+
+ touch->mode = mode;
+ touch->sourceid = device->id;
+
+ device->touch = touch;
+ device->last.touches = calloc(max_touches, sizeof(*device->last.touches));
+ device->last.num_touches = touch->num_touches;
+ for (i = 0; i < touch->num_touches; i++)
+ TouchInitDDXTouchPoint(device, &device->last.touches[i]);
+
+ return TRUE;
+
+err:
+ for (i = 0; i < touch->num_touches; i++)
+ TouchFreeTouchPoint(device, i);
+
+ free(touch->touches);
+ free(touch);
+
+ return FALSE;
+}
+
/*
* Check if the given buffer contains elements between low (inclusive) and
* high (inclusive) only.