summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Hutterer <peter.hutterer@redhat.com>2008-08-18 12:13:15 +0930
committerPeter Hutterer <peter.hutterer@redhat.com>2008-08-18 13:44:02 +0930
commit92c6611b6f4495103fccea38dcafc6c6bf18049a (patch)
tree6bc25c8a78fda6d94078db09e06093fa4956c398
parentbd405ddc83b9ad1ceed47f572245fccae598e6bb (diff)
Add property support for drag lock.
-rw-r--r--src/draglock.c103
-rw-r--r--src/evdev.c2
-rw-r--r--src/evdev.h3
3 files changed, 108 insertions, 0 deletions
diff --git a/src/draglock.c b/src/draglock.c
index 8739697..da0e7f8 100644
--- a/src/draglock.c
+++ b/src/draglock.c
@@ -7,6 +7,7 @@
* (Ported from xf86-input-mouse, above copyrights taken from there)
* Copyright © 2008 University of South Australia
* Copyright 2008 by Chris Salch
+ * Copyright 2008 Red Hat, Inc.
*
* Permission to use, copy, modify, distribute, and sell this software
* and its documentation for any purpose is hereby granted without
@@ -37,9 +38,14 @@
#include <xf86.h>
#include <xf86Xinput.h>
+#include <X11/Xatom.h>
#include "evdev.h"
+static const char *propname_dlock = "Drag Lock Buttons";
+
+static Atom prop_dlock = 0; /* Drag lock buttons. */
+
void EvdevDragLockLockButton(InputInfoPtr pInfo, unsigned int button);
@@ -201,3 +207,100 @@ EvdevDragLockFilterEvent(InputInfoPtr pInfo, unsigned int button, int value)
return FALSE;
}
+#if GET_ABI_MAJOR(ABI_XINPUT_VERSION) >= 3
+/**
+ * Initialise property for drag lock buttons setting.
+ */
+void
+EvdevDragLockInitProperty(DeviceIntPtr dev)
+{
+ InputInfoPtr pInfo = dev->public.devicePrivate;
+ EvdevPtr pEvdev = pInfo->private;
+
+ if (!dev->button) /* don't init prop for keyboards */
+ return;
+
+ prop_dlock = MakeAtom((char*)propname_dlock, strlen(propname_dlock), TRUE);
+ if (pEvdev->dragLock.meta)
+ {
+ XIChangeDeviceProperty(dev, prop_dlock, XA_INTEGER, 8,
+ PropModeReplace, 1, &pEvdev->dragLock.meta,
+ FALSE, FALSE, FALSE);
+ } else {
+ int highest = 0;
+ int i;
+ CARD8 pair[EVDEV_MAXBUTTONS] = {0};
+
+ for (i = 0; i < EVDEV_MAXBUTTONS; i++)
+ {
+ if (pEvdev->dragLock.lock_pair[i])
+ highest = i;
+ pair[i] = pEvdev->dragLock.lock_pair[i];
+ }
+
+ XIChangeDeviceProperty(dev, prop_dlock, XA_INTEGER, 8, PropModeReplace,
+ highest + 1, pair, FALSE, FALSE, FALSE);
+ }
+
+ return;
+}
+
+/**
+ * Set the drag lock property.
+ * If only one value is supplied, then this is used as the meta button.
+ * If more than one value is supplied, then each value is the drag lock button
+ * for the pair. 0 disables a pair.
+ * i.e. to set bt 3 to draglock button 1, supply 0,0,1
+ */
+BOOL
+EvdevDragLockSetProperty(DeviceIntPtr dev, Atom atom, XIPropertyValuePtr val)
+{
+ InputInfoPtr pInfo = dev->public.devicePrivate;
+ EvdevPtr pEvdev = pInfo->private;
+
+ if (atom == prop_dlock)
+ {
+ int i;
+ if (val->format != 8 || val->type != XA_INTEGER)
+ return FALSE;
+
+ /* Don't allow changes while a lock is active */
+ /* FIXME: Need more meaningful method of returning Busy. */
+ if (pEvdev->dragLock.meta)
+ {
+ if (pEvdev->dragLock.meta_state)
+ return FALSE;
+ } else
+ {
+ for (i = 0; i < EVDEV_MAXBUTTONS; i++)
+ if (pEvdev->dragLock.lock_state[i])
+ return FALSE;
+ }
+
+ if (val->size == 1)
+ {
+ int meta = *((CARD8*)val->data);
+ if (meta > EVDEV_MAXBUTTONS)
+ return FALSE;
+
+ pEvdev->dragLock.meta = meta;
+ memset(pEvdev->dragLock.lock_pair, 0, sizeof(pEvdev->dragLock.lock_pair));
+ } else
+ {
+ CARD8* vals = (CARD8*)val->data;
+
+ for (i = 0; i < val->size && i < EVDEV_MAXBUTTONS; i++)
+ if (vals[i] > EVDEV_MAXBUTTONS)
+ return FALSE;
+
+ 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];
+ }
+ }
+
+ return TRUE;
+}
+#endif
diff --git a/src/evdev.c b/src/evdev.c
index 4895317..2c071fa 100644
--- a/src/evdev.c
+++ b/src/evdev.c
@@ -23,6 +23,7 @@
* Authors:
* Kristian Høgsberg (krh@redhat.com)
* Adam Jackson (ajax@redhat.com)
+ * Peter Hutterer (peter.hutterer@redhat.com)
*/
#ifdef HAVE_CONFIG_H
@@ -105,6 +106,7 @@ static PropHandler evdevPropHandlers[] =
{
{EvdevMBEmuInitProperty, EvdevMBEmuSetProperty},
{EvdevWheelEmuInitProperty, EvdevWheelEmuSetProperty},
+ {EvdevDragLockInitProperty, EvdevDragLockSetProperty},
{NULL, NULL}
};
diff --git a/src/evdev.h b/src/evdev.h
index 74fbfc6..1f829f0 100644
--- a/src/evdev.h
+++ b/src/evdev.h
@@ -112,6 +112,9 @@ BOOL EvdevMBEmuSetProperty(DeviceIntPtr, Atom, XIPropertyValuePtr);
void EvdevWheelEmuInitProperty(DeviceIntPtr);
BOOL EvdevWheelEmuSetProperty(DeviceIntPtr, Atom, XIPropertyValuePtr);
+
+void EvdevDragLockInitProperty(DeviceIntPtr);
+BOOL EvdevDragLockSetProperty(DeviceIntPtr, Atom, XIPropertyValuePtr);
#endif
/* Mouse Wheel emulation */