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>
This commit is contained in:
parent
dbbe5735d1
commit
98fe735ea1
|
@ -2484,16 +2484,22 @@ GetPairedDevice(DeviceIntPtr dev)
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the right master for the type of event needed. If the event is a
|
* Returns the requested master for this device.
|
||||||
* keyboard event.
|
* The return values are:
|
||||||
* This function may be called with a master device as argument. If so, the
|
* - MASTER_ATTACHED: the master for this device or NULL for a floating
|
||||||
* returned master is either the device itself or the paired master device.
|
* slave.
|
||||||
* If dev is a floating slave device, NULL is returned.
|
* - 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
|
* @param which ::MASTER_KEYBOARD or ::MASTER_POINTER, ::MASTER_ATTACHED,
|
||||||
* @return The requested master device. In the case of MASTER_ATTACHED, this
|
* ::POINTER_OR_FLOAT or ::KEYBOARD_OR_FLOAT.
|
||||||
* is the directly attached master to this device, regardless of the type.
|
* @return The requested master device
|
||||||
* Otherwise, it is either the master keyboard or pointer for this device.
|
|
||||||
*/
|
*/
|
||||||
DeviceIntPtr
|
DeviceIntPtr
|
||||||
GetMaster(DeviceIntPtr dev, int which)
|
GetMaster(DeviceIntPtr dev, int which)
|
||||||
|
@ -2502,12 +2508,15 @@ GetMaster(DeviceIntPtr dev, int which)
|
||||||
|
|
||||||
if (IsMaster(dev))
|
if (IsMaster(dev))
|
||||||
master = dev;
|
master = dev;
|
||||||
else
|
else {
|
||||||
master = dev->master;
|
master = dev->master;
|
||||||
|
if (!master && (which == POINTER_OR_FLOAT || which == KEYBOARD_OR_FLOAT))
|
||||||
|
return dev;
|
||||||
|
}
|
||||||
|
|
||||||
if (master && which != MASTER_ATTACHED)
|
if (master && which != MASTER_ATTACHED)
|
||||||
{
|
{
|
||||||
if (which == MASTER_KEYBOARD)
|
if (which == MASTER_KEYBOARD || which == KEYBOARD_OR_FLOAT)
|
||||||
{
|
{
|
||||||
if (master->type != MASTER_KEYBOARD)
|
if (master->type != MASTER_KEYBOARD)
|
||||||
master = GetPairedDevice(master);
|
master = GetPairedDevice(master);
|
||||||
|
|
|
@ -472,7 +472,10 @@ typedef struct _SpriteInfoRec {
|
||||||
#define MASTER_POINTER 1
|
#define MASTER_POINTER 1
|
||||||
#define MASTER_KEYBOARD 2
|
#define MASTER_KEYBOARD 2
|
||||||
#define SLAVE 3
|
#define SLAVE 3
|
||||||
#define MASTER_ATTACHED 4 /* special type for GetMaster */
|
/* special types for GetMaster */
|
||||||
|
#define MASTER_ATTACHED 4 /* Master for this device */
|
||||||
|
#define KEYBOARD_OR_FLOAT 5 /* Keyboard master for this device or this device if floating */
|
||||||
|
#define POINTER_OR_FLOAT 6 /* Pointer master for this device or this device if floating */
|
||||||
|
|
||||||
typedef struct _DeviceIntRec {
|
typedef struct _DeviceIntRec {
|
||||||
DeviceRec public;
|
DeviceRec public;
|
||||||
|
|
13
test/input.c
13
test/input.c
|
@ -1292,6 +1292,19 @@ static void dix_get_master(void)
|
||||||
assert(GetMaster(&floating, MASTER_POINTER) == NULL);
|
assert(GetMaster(&floating, MASTER_POINTER) == NULL);
|
||||||
assert(GetMaster(&floating, MASTER_KEYBOARD) == NULL);
|
assert(GetMaster(&floating, MASTER_KEYBOARD) == NULL);
|
||||||
assert(GetMaster(&floating, MASTER_ATTACHED) == NULL);
|
assert(GetMaster(&floating, MASTER_ATTACHED) == NULL);
|
||||||
|
|
||||||
|
assert(GetMaster(&vcp, POINTER_OR_FLOAT) == &vcp);
|
||||||
|
assert(GetMaster(&vck, POINTER_OR_FLOAT) == &vcp);
|
||||||
|
assert(GetMaster(&ptr, POINTER_OR_FLOAT) == &vcp);
|
||||||
|
assert(GetMaster(&kbd, POINTER_OR_FLOAT) == &vcp);
|
||||||
|
|
||||||
|
assert(GetMaster(&vcp, KEYBOARD_OR_FLOAT) == &vck);
|
||||||
|
assert(GetMaster(&vck, KEYBOARD_OR_FLOAT) == &vck);
|
||||||
|
assert(GetMaster(&ptr, KEYBOARD_OR_FLOAT) == &vck);
|
||||||
|
assert(GetMaster(&kbd, KEYBOARD_OR_FLOAT) == &vck);
|
||||||
|
|
||||||
|
assert(GetMaster(&floating, KEYBOARD_OR_FLOAT) == &floating);
|
||||||
|
assert(GetMaster(&floating, POINTER_OR_FLOAT) == &floating);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue