[PATCH v2 13/17] input: replace remaining GetPairedDevice() with GetMaster()
Peter Hutterer
peter.hutterer at who-t.net
Mon Aug 8 20:28:40 PDT 2011
Wherever it's obvious which device we need (keyboard or pointer), use
GetMaster() instead of GetPairedDevice(). It is more reliable in actually
getting the device type we want.
Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
Reviewed-by: Daniel Stone <daniel at fooishbar.org>
---
Changes to v1:
- xiquerypointer hunk: use GetMaster(MASTER_KEYBOARD) to maintain previous
behaviour
- CheckPassiveGrabsOnWindow hunk: use KEYBOARD_OR_FLOAT to get right
modifier device.
- xkbActions hunk: use POINTER_OR_FLOAT, this is the pointer event branch
Xi/exevents.c | 6 +++---
Xi/xiquerypointer.c | 2 +-
dix/enterleave.c | 10 +++++-----
dix/events.c | 23 ++++++++---------------
hw/xfree86/common/xf86DGA.c | 2 +-
hw/xfree86/common/xf86Xinput.c | 2 +-
xkb/xkbActions.c | 2 +-
7 files changed, 20 insertions(+), 27 deletions(-)
diff --git a/Xi/exevents.c b/Xi/exevents.c
index 38089a2..919ea85 100644
--- a/Xi/exevents.c
+++ b/Xi/exevents.c
@@ -104,7 +104,7 @@ int
XIShouldNotify(ClientPtr client, DeviceIntPtr dev)
{
DeviceIntPtr current_ptr = PickPointer(client);
- DeviceIntPtr current_kbd = GetPairedDevice(current_ptr);
+ DeviceIntPtr current_kbd = GetMaster(current_ptr, KEYBOARD_OR_FLOAT);
if (dev == current_kbd || dev == current_ptr)
return 1;
@@ -905,13 +905,13 @@ ProcessOtherEvent(InternalEvent *ev, DeviceIntPtr device)
if (IsPointerDevice(device))
{
- kbd = GetPairedDevice(device);
+ kbd = GetMaster(device, KEYBOARD_OR_FLOAT);
mouse = device;
if (!kbd->key) /* can happen with floating SDs */
kbd = NULL;
} else
{
- mouse = GetPairedDevice(device);
+ mouse = GetMaster(device, POINTER_OR_FLOAT);
kbd = device;
if (!mouse->valuator || !mouse->button) /* may be float. SDs */
mouse = NULL;
diff --git a/Xi/xiquerypointer.c b/Xi/xiquerypointer.c
index 5131799..efc7782 100644
--- a/Xi/xiquerypointer.c
+++ b/Xi/xiquerypointer.c
@@ -111,7 +111,7 @@ ProcXIQueryPointer(ClientPtr client)
MaybeStopHint(pDev, client);
if (IsMaster(pDev))
- kbd = GetPairedDevice(pDev);
+ kbd = GetMaster(pDev, MASTER_KEYBOARD);
else
kbd = (pDev->key) ? pDev : NULL;
diff --git a/dix/enterleave.c b/dix/enterleave.c
index b1ee3fb..a39e640 100644
--- a/dix/enterleave.c
+++ b/dix/enterleave.c
@@ -766,7 +766,7 @@ CoreFocusOutNotifyPointerEvents(DeviceIntPtr dev,
{
WindowPtr P, stopAt;
- P = PointerWin(GetPairedDevice(dev));
+ P = PointerWin(GetMaster(dev, POINTER_OR_FLOAT));
if (!P)
return;
@@ -821,7 +821,7 @@ CoreFocusInNotifyPointerEvents(DeviceIntPtr dev,
{
WindowPtr P;
- P = PointerWin(GetPairedDevice(dev));
+ P = PointerWin(GetMaster(dev, POINTER_OR_FLOAT));
if (!P || P == exclude || (pwin_parent != P && !IsParent(pwin_parent, P)))
return;
@@ -1087,7 +1087,7 @@ CoreFocusPointerRootNoneSwitch(DeviceIntPtr dev,
for (i = 0; i < nscreens; i++)
{
root = screenInfo.screens[i]->root;
- if (!HasOtherPointer(root, GetPairedDevice(dev)) && !FirstFocusChild(root))
+ if (!HasOtherPointer(root, GetMaster(dev, POINTER_OR_FLOAT)) && !FirstFocusChild(root))
{
/* If pointer was on PointerRootWin and changes to NoneWin, and
* the pointer paired with dev is below the current root window,
@@ -1095,7 +1095,7 @@ CoreFocusPointerRootNoneSwitch(DeviceIntPtr dev,
if (dev->focus && dev->focus->win == PointerRootWin &&
B != PointerRootWin)
{
- WindowPtr ptrwin = PointerWin(GetPairedDevice(dev));
+ WindowPtr ptrwin = PointerWin(GetMaster(dev, POINTER_OR_FLOAT));
if (ptrwin && IsParent(root, ptrwin))
CoreFocusOutNotifyPointerEvents(dev, root, None, mode, TRUE);
}
@@ -1187,7 +1187,7 @@ CoreFocusFromPointerRootOrNone(DeviceIntPtr dev,
if (dev->focus && dev->focus->win == PointerRootWin &&
B != PointerRootWin)
{
- WindowPtr ptrwin = PointerWin(GetPairedDevice(dev));
+ WindowPtr ptrwin = PointerWin(GetMaster(dev, POINTER_OR_FLOAT));
if (ptrwin)
CoreFocusOutNotifyPointerEvents(dev, root, None, mode, TRUE);
}
diff --git a/dix/events.c b/dix/events.c
index 51cbe82..616d727 100644
--- a/dix/events.c
+++ b/dix/events.c
@@ -3604,10 +3604,7 @@ CheckPassiveGrabsOnWindow(
gdev= grab->modifierDevice;
if (grab->grabtype == GRABTYPE_CORE)
{
- if (IsPointerDevice(device))
- gdev = GetPairedDevice(device);
- else
- gdev = device;
+ gdev = GetMaster(device, KEYBOARD_OR_FLOAT);
} else if (grab->grabtype == GRABTYPE_XI2)
{
/* if the device is an attached slave device, gdev must be the
@@ -3906,8 +3903,7 @@ DeliverFocusedEvent(DeviceIntPtr keybd, InternalEvent *event, WindowPtr window)
}
/* just deliver it to the focus window */
- ptr = GetPairedDevice(keybd);
-
+ ptr = GetMaster(keybd, POINTER_OR_FLOAT);
rc = EventToXI2(event, &xi2);
if (rc == Success)
@@ -4409,7 +4405,7 @@ CoreEnterLeaveEvent(
GrabPtr grab = mouse->deviceGrab.grab;
Mask mask;
- keybd = GetPairedDevice(mouse);
+ keybd = GetMaster(mouse, KEYBOARD_OR_FLOAT);
if ((pWin == mouse->valuator->motionHintWindow) &&
(detail != NotifyInferior))
@@ -4629,10 +4625,7 @@ SetInputFocus(
}
time = ClientTimeToServerTime(ctime);
- if (IsKeyboardDevice(dev))
- keybd = dev;
- else
- keybd = GetPairedDevice(dev);
+ keybd = GetMaster(dev, KEYBOARD_OR_FLOAT);
if ((focusID == None) || (focusID == PointerRoot))
focusWin = (WindowPtr)(long)focusID;
@@ -5107,7 +5100,7 @@ ProcQueryPointer(ClientPtr client)
if (rc != Success && rc != BadAccess)
return rc;
- keyboard = GetPairedDevice(mouse);
+ keyboard = GetMaster(mouse, MASTER_KEYBOARD);
pSprite = mouse->spriteInfo->sprite;
if (mouse->valuator->motionHintWindow)
@@ -5229,7 +5222,7 @@ ProcSendEvent(ClientPtr client)
WindowPtr pWin;
WindowPtr effectiveFocus = NullWindow; /* only set if dest==InputFocus */
DeviceIntPtr dev = PickPointer(client);
- DeviceIntPtr keybd = GetPairedDevice(dev);
+ DeviceIntPtr keybd = GetMaster(dev, MASTER_KEYBOARD);
SpritePtr pSprite = dev->spriteInfo->sprite;
REQUEST(xSendEventReq);
@@ -5492,7 +5485,7 @@ ProcGrabButton(ClientPtr client)
}
ptr = PickPointer(client);
- modifierDevice = GetPairedDevice(ptr);
+ modifierDevice = GetMaster(ptr, MASTER_KEYBOARD);
if (stuff->pointerMode == GrabModeSync ||
stuff->keyboardMode == GrabModeSync)
access_mode |= DixFreezeAccess;
@@ -5549,7 +5542,7 @@ ProcUngrabButton(ClientPtr client)
tempGrab.window = pWin;
tempGrab.modifiersDetail.exact = stuff->modifiers;
tempGrab.modifiersDetail.pMask = NULL;
- tempGrab.modifierDevice = GetPairedDevice(ptr);
+ tempGrab.modifierDevice = GetMaster(ptr, MASTER_KEYBOARD);
tempGrab.type = ButtonPress;
tempGrab.detail.exact = stuff->button;
tempGrab.grabtype = GRABTYPE_CORE;
diff --git a/hw/xfree86/common/xf86DGA.c b/hw/xfree86/common/xf86DGA.c
index 74eb739..46e3005 100644
--- a/hw/xfree86/common/xf86DGA.c
+++ b/hw/xfree86/common/xf86DGA.c
@@ -1016,7 +1016,7 @@ DGAProcessKeyboardEvent (ScreenPtr pScreen, DGAEvent *event, DeviceIntPtr keybd)
{
KeyClassPtr keyc = keybd->key;
DGAScreenPtr pScreenPriv = DGA_GET_SCREEN_PRIV(pScreen);
- DeviceIntPtr pointer = GetPairedDevice(keybd);
+ DeviceIntPtr pointer = GetMaster(keybd, POINTER_OR_FLOAT);
DeviceEvent ev;
memset(&ev, 0, sizeof(ev));
diff --git a/hw/xfree86/common/xf86Xinput.c b/hw/xfree86/common/xf86Xinput.c
index d22fdc8..2bfeb9b 100644
--- a/hw/xfree86/common/xf86Xinput.c
+++ b/hw/xfree86/common/xf86Xinput.c
@@ -1243,7 +1243,7 @@ xf86PostKeyEventM(DeviceIntPtr device,
DeviceIntPtr pointer;
/* Some pointers send key events, paired device is wrong then. */
- pointer = IsPointerDevice(device) ? device : GetPairedDevice(device);
+ pointer = GetMaster(device, POINTER_OR_FLOAT);
if (miPointerGetScreen(pointer)) {
int index = miPointerGetScreen(pointer)->myNum;
diff --git a/xkb/xkbActions.c b/xkb/xkbActions.c
index 4b5405a..86352eb 100644
--- a/xkb/xkbActions.c
+++ b/xkb/xkbActions.c
@@ -1200,7 +1200,7 @@ xkbDeviceInfoPtr xkbPrivPtr = XKBDEVICEINFO(dev);
if (keyEvent)
tmpdev = dev;
else
- tmpdev = GetPairedDevice(dev);
+ tmpdev = GetMaster(dev, POINTER_OR_FLOAT);
UNWRAP_PROCESS_INPUT_PROC(tmpdev,xkbPrivPtr, backupproc);
dev->public.processInputProc((InternalEvent*)event, tmpdev);
--
1.7.6
More information about the xorg-devel
mailing list