summaryrefslogtreecommitdiff
path: root/dix/devices.c
diff options
context:
space:
mode:
authorPeter Hutterer <peter.hutterer@who-t.net>2011-08-01 13:52:13 +1000
committerPeter Hutterer <peter.hutterer@who-t.net>2011-08-22 15:56:51 +1000
commit98fe735ea1d756711019c3d90ed6abd9c06abebf (patch)
tree8ec8b4d4d49630dc1fdf10e95d01f3877a29aa0e /dix/devices.c
parentdbbe5735d1451bb32f43bce90f0bcfeff46f9743 (diff)
dix: add KEYBOARD_OR_FLOAT and POINTER_OR_FLOAT to GetMaster()
GetMaster() currently requires an attached slave device as parameter, resuling in many calls being IsFloating(dev) ? dev : GetMaster(...); Add two new parameters so GetMaster can be called unconditionally to get the right device. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Reviewed-by: Daniel Stone <daniel@fooishbar.org>
Diffstat (limited to 'dix/devices.c')
-rw-r--r--dix/devices.c31
1 files changed, 20 insertions, 11 deletions
diff --git a/dix/devices.c b/dix/devices.c
index 0ccf25277..334f5d3f5 100644
--- a/dix/devices.c
+++ b/dix/devices.c
@@ -2484,16 +2484,22 @@ GetPairedDevice(DeviceIntPtr dev)
/**
- * Returns the right master for the type of event needed. If the event is a
- * keyboard event.
- * This function may be called with a master device as argument. If so, the
- * returned master is either the device itself or the paired master device.
- * If dev is a floating slave device, NULL is returned.
+ * Returns the requested master for this device.
+ * The return values are:
+ * - MASTER_ATTACHED: the master for this device or NULL for a floating
+ * slave.
+ * - MASTER_KEYBOARD: the master keyboard for this device or NULL for a
+ * floating slave
+ * - MASTER_POINTER: the master keyboard for this device or NULL for a
+ * floating slave
+ * - POINTER_OR_FLOAT: the master pointer for this device or the device for
+ * a floating slave
+ * - KEYBOARD_OR_FLOAT: the master keyboard for this device or the device for
+ * a floating slave
*
- * @type ::MASTER_KEYBOARD or ::MASTER_POINTER or ::MASTER_ATTACHED
- * @return The requested master device. In the case of MASTER_ATTACHED, this
- * is the directly attached master to this device, regardless of the type.
- * Otherwise, it is either the master keyboard or pointer for this device.
+ * @param which ::MASTER_KEYBOARD or ::MASTER_POINTER, ::MASTER_ATTACHED,
+ * ::POINTER_OR_FLOAT or ::KEYBOARD_OR_FLOAT.
+ * @return The requested master device
*/
DeviceIntPtr
GetMaster(DeviceIntPtr dev, int which)
@@ -2502,12 +2508,15 @@ GetMaster(DeviceIntPtr dev, int which)
if (IsMaster(dev))
master = dev;
- else
+ else {
master = dev->master;
+ if (!master && (which == POINTER_OR_FLOAT || which == KEYBOARD_OR_FLOAT))
+ return dev;
+ }
if (master && which != MASTER_ATTACHED)
{
- if (which == MASTER_KEYBOARD)
+ if (which == MASTER_KEYBOARD || which == KEYBOARD_OR_FLOAT)
{
if (master->type != MASTER_KEYBOARD)
master = GetPairedDevice(master);