dix: Extract FixUpXI2DeviceEventFromWindow()

This commit is contained in:
Povilas Kanapickas 2020-10-10 02:51:31 +03:00 committed by Peter Hutterer
parent bb7aab6afe
commit acd819ac07

View File

@ -2502,45 +2502,10 @@ FindChildForEvent(SpritePtr pSprite, WindowPtr event)
return child; return child;
} }
/** static void
* Adjust event fields to comply with the window properties. FixUpXI2DeviceEventFromWindow(SpritePtr pSprite, int evtype,
* xXIDeviceEvent *event, WindowPtr pWin, Window child)
* @param xE Event to be modified in place
* @param pWin The window to get the information from.
* @param child Child window setting for event (if applicable)
* @param calcChild If True, calculate the child window.
*/
void
FixUpEventFromWindow(SpritePtr pSprite,
xEvent *xE, WindowPtr pWin, Window child, Bool calcChild)
{ {
int evtype;
if (calcChild)
child = FindChildForEvent(pSprite, pWin);
if ((evtype = xi2_get_type(xE))) {
xXIDeviceEvent *event = (xXIDeviceEvent *) xE;
switch (evtype) {
case XI_RawKeyPress:
case XI_RawKeyRelease:
case XI_RawButtonPress:
case XI_RawButtonRelease:
case XI_RawMotion:
case XI_RawTouchBegin:
case XI_RawTouchUpdate:
case XI_RawTouchEnd:
case XI_DeviceChanged:
case XI_HierarchyChanged:
case XI_PropertyEvent:
case XI_BarrierHit:
case XI_BarrierLeave:
return;
default:
break;
}
event->root = RootWindow(pSprite)->drawable.id; event->root = RootWindow(pSprite)->drawable.id;
event->event = pWin->drawable.id; event->event = pWin->drawable.id;
@ -2564,7 +2529,46 @@ FixUpEventFromWindow(SpritePtr pSprite,
event->evtype == XI_FocusIn || event->evtype == XI_FocusOut) event->evtype == XI_FocusIn || event->evtype == XI_FocusOut)
((xXIEnterEvent *) event)->same_screen = ((xXIEnterEvent *) event)->same_screen =
(pSprite->hot.pScreen == pWin->drawable.pScreen); (pSprite->hot.pScreen == pWin->drawable.pScreen);
}
/**
* Adjust event fields to comply with the window properties.
*
* @param xE Event to be modified in place
* @param pWin The window to get the information from.
* @param child Child window setting for event (if applicable)
* @param calcChild If True, calculate the child window.
*/
void
FixUpEventFromWindow(SpritePtr pSprite,
xEvent *xE, WindowPtr pWin, Window child, Bool calcChild)
{
int evtype;
if (calcChild)
child = FindChildForEvent(pSprite, pWin);
if ((evtype = xi2_get_type(xE))) {
switch (evtype) {
case XI_RawKeyPress:
case XI_RawKeyRelease:
case XI_RawButtonPress:
case XI_RawButtonRelease:
case XI_RawMotion:
case XI_RawTouchBegin:
case XI_RawTouchUpdate:
case XI_RawTouchEnd:
case XI_DeviceChanged:
case XI_HierarchyChanged:
case XI_PropertyEvent:
case XI_BarrierHit:
case XI_BarrierLeave:
return;
default:
FixUpXI2DeviceEventFromWindow(pSprite, evtype,
(xXIDeviceEvent*) xE, pWin, child);
break;
}
} }
else { else {
XE_KBPTR.root = RootWindow(pSprite)->drawable.id; XE_KBPTR.root = RootWindow(pSprite)->drawable.id;