[PATCH 11/20] dix: add MASTER_ATTACHED as allowed type for GetMaster().

Peter Hutterer peter.hutterer at who-t.net
Thu Feb 17 19:52:18 PST 2011


In some cases, we don't know/care whether we want the master pointer or keyboard
for a device. Add a new type MASTER_ATTACHED to return the master this
device is attached to.

Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
---
 dix/devices.c      |    7 +++++--
 include/inputstr.h |    1 +
 2 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/dix/devices.c b/dix/devices.c
index a3367f7..8be1903 100644
--- a/dix/devices.c
+++ b/dix/devices.c
@@ -2473,7 +2473,10 @@ GetPairedDevice(DeviceIntPtr dev)
  * returned master is either the device itself or the paired master device.
  * If dev is a floating slave device, NULL is returned.
  *
- * @type ::MASTER_KEYBOARD or ::MASTER_POINTER
+ * @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.
  */
 DeviceIntPtr
 GetMaster(DeviceIntPtr dev, int which)
@@ -2485,7 +2488,7 @@ GetMaster(DeviceIntPtr dev, int which)
     else
         master = dev->u.master;
 
-    if (master)
+    if (master && which != MASTER_ATTACHED)
     {
         if (which == MASTER_KEYBOARD)
         {
diff --git a/include/inputstr.h b/include/inputstr.h
index b74ee04..58d318f 100644
--- a/include/inputstr.h
+++ b/include/inputstr.h
@@ -493,6 +493,7 @@ typedef struct _SpriteInfoRec {
 #define MASTER_POINTER          1
 #define MASTER_KEYBOARD         2
 #define SLAVE                   3
+#define MASTER_ATTACHED         4  /* special type for GetMaster */
 
 typedef struct _DeviceIntRec {
     DeviceRec	public;
-- 
1.7.4



More information about the xorg-devel mailing list