dix: introduce GetMaster()
For hybrid devices (keys + buttons/axes) the attached master device is generally the wrong one. One shouldn't post a button event through a keyboard and vice versa. GetMaster(dev) returns the right master device for the given type needed. This may be the MD paired with this device's MD. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
This commit is contained in:
parent
d79318f269
commit
bc63c8a457
|
@ -2345,6 +2345,41 @@ 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.
|
||||
*
|
||||
* @type ::MASTER_KEYBOARD or ::MASTER_POINTER
|
||||
*/
|
||||
DeviceIntPtr
|
||||
GetMaster(DeviceIntPtr dev, int which)
|
||||
{
|
||||
DeviceIntPtr master;
|
||||
|
||||
if (IsMaster(dev))
|
||||
master = dev;
|
||||
else
|
||||
master = dev->u.master;
|
||||
|
||||
if (master)
|
||||
{
|
||||
if (which == MASTER_KEYBOARD)
|
||||
{
|
||||
if (master->type != MASTER_KEYBOARD)
|
||||
master = GetPairedDevice(master);
|
||||
} else
|
||||
{
|
||||
if (master->type != MASTER_POINTER)
|
||||
master = GetPairedDevice(master);
|
||||
}
|
||||
}
|
||||
|
||||
return master;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new device pair (== one pointer, one keyboard device).
|
||||
* Only allocates the devices, you will need to call ActivateDevice() and
|
||||
|
|
|
@ -612,7 +612,10 @@ clipValuators(DeviceIntPtr pDev, int first_valuator, int num_valuators,
|
|||
static EventListPtr
|
||||
updateFromMaster(EventListPtr events, DeviceIntPtr dev, int *num_events)
|
||||
{
|
||||
DeviceIntPtr master = dev->u.master;
|
||||
DeviceIntPtr master;
|
||||
|
||||
master = GetMaster(dev, (type & DEVCHANGE_POINTER_EVENT) ? MASTER_POINTER : MASTER_KEYBOARD);
|
||||
|
||||
if (master && master->last.slave != dev)
|
||||
{
|
||||
CreateClassesChangedEvent(events, master, dev);
|
||||
|
@ -793,8 +796,10 @@ updateHistory(DeviceIntPtr dev, int first, int num, CARD32 ms)
|
|||
{
|
||||
updateMotionHistory(dev, ms, first, num, &dev->last.valuators[first]);
|
||||
if (dev->u.master)
|
||||
updateMotionHistory(dev->u.master, ms, first, num,
|
||||
&dev->last.valuators[first]);
|
||||
{
|
||||
DeviceIntPtr master = GetMaster(dev, MASTER_POINTER);
|
||||
updateMotionHistory(master, ms, first, num, &dev->last.valuators[first]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -472,6 +472,7 @@ extern int AttachDevice(ClientPtr client,
|
|||
DeviceIntPtr master);
|
||||
|
||||
extern _X_EXPORT DeviceIntPtr GetPairedDevice(DeviceIntPtr kbd);
|
||||
extern DeviceIntPtr GetMaster(DeviceIntPtr dev, int type);
|
||||
|
||||
extern int AllocDevicePair(ClientPtr client,
|
||||
char* name,
|
||||
|
|
Loading…
Reference in New Issue
Block a user