dix: don't change the device struct while processing core events.

The device state needs to be changed while processing the XI event. Core
events are always processed after XI, so by then the device is already set up
properly. However, we now rely on DeviceButtonMotionMask to be equal to
ButtonMotionMask. It already is, but stick a big fat warning in so nobody
attempts to change it.

This commit disables XKB for the VCK, thus essentially for all devices.
Temporarily anyway.
This commit is contained in:
Peter Hutterer 2007-09-06 15:43:47 +09:30
parent c4fff05083
commit 03680a384a
4 changed files with 31 additions and 60 deletions

View File

@ -126,9 +126,6 @@ ProcessOtherEvent(xEventPtr xE, DeviceIntPtr device, int count)
ValuatorClassPtr v = device->valuator; ValuatorClassPtr v = device->valuator;
deviceValuator *xV = (deviceValuator *) xE; deviceValuator *xV = (deviceValuator *) xE;
if (grab && grab->coreGrab && !device->deviceGrab.fromPassiveGrab)
return;
CheckMotion(xE, device); CheckMotion(xE, device);
if (xE->u.u.type != DeviceValuator && xE->u.u.type != GenericEvent) { if (xE->u.u.type != DeviceValuator && xE->u.u.type != GenericEvent) {

View File

@ -879,8 +879,20 @@ FixExtensionEvents(ExtensionEntry * extEntry)
SetEventInfo(GetNextExtEventMask(), _deviceButton3Motion); SetEventInfo(GetNextExtEventMask(), _deviceButton3Motion);
SetEventInfo(GetNextExtEventMask(), _deviceButton4Motion); SetEventInfo(GetNextExtEventMask(), _deviceButton4Motion);
SetEventInfo(GetNextExtEventMask(), _deviceButton5Motion); SetEventInfo(GetNextExtEventMask(), _deviceButton5Motion);
/* If DeviceButtonMotionMask is != ButtonMotionMask, event delivery
* breaks down. The device needs the dev->button->motionMask. If DBMM is
* the same as BMM, we can ensure that both core and device events can be
* delivered, without the need for extra structures in the DeviceIntRec.
*/
DeviceButtonMotionMask = GetNextExtEventMask(); DeviceButtonMotionMask = GetNextExtEventMask();
SetEventInfo(DeviceButtonMotionMask, _deviceButtonMotion); SetEventInfo(DeviceButtonMotionMask, _deviceButtonMotion);
if (DeviceButtonMotionMask != ButtonMotionMask)
{
/* This should never happen, but if it does, hide under the
* bed and cry for help. */
ErrorF("DeviceButtonMotionMask != ButtonMotionMask. Trouble!\n");
}
DeviceFocusChangeMask = GetNextExtEventMask(); DeviceFocusChangeMask = GetNextExtEventMask();
SetMaskForExtEvent(DeviceFocusChangeMask, DeviceFocusIn); SetMaskForExtEvent(DeviceFocusChangeMask, DeviceFocusIn);

View File

@ -458,8 +458,8 @@ InitCoreDevices(void)
#ifdef XKB #ifdef XKB
dev->public.processInputProc = CoreProcessKeyboardEvent; dev->public.processInputProc = CoreProcessKeyboardEvent;
dev->public.realInputProc = CoreProcessKeyboardEvent; dev->public.realInputProc = CoreProcessKeyboardEvent;
if (!noXkbExtension) /*if (!noXkbExtension)*/
XkbSetExtension(dev, ProcessKeyboardEvent); /*XkbSetExtension(dev, ProcessKeyboardEvent);*/
#else #else
dev->public.processInputProc = ProcessKeyboardEvent; dev->public.processInputProc = ProcessKeyboardEvent;
dev->public.realInputProc = ProcessKeyboardEvent; dev->public.realInputProc = ProcessKeyboardEvent;

View File

@ -3524,7 +3524,9 @@ drawable.id:0;
#endif #endif
))) )))
#endif #endif
XE_KBPTR.state = (keyc->state | GetPairedPointer(keybd)->button->state); /* ProcessOtherEvent already updated the keyboard's state, so we need to
* access prev_state here! */
XE_KBPTR.state = (keyc->prev_state | GetPairedPointer(keybd)->button->state);
XE_KBPTR.rootX = keybd->spriteInfo->sprite->hot.x; XE_KBPTR.rootX = keybd->spriteInfo->sprite->hot.x;
XE_KBPTR.rootY = keybd->spriteInfo->sprite->hot.y; XE_KBPTR.rootY = keybd->spriteInfo->sprite->hot.y;
key = xE->u.u.detail; key = xE->u.u.detail;
@ -3545,31 +3547,14 @@ drawable.id:0;
switch (xE->u.u.type) switch (xE->u.u.type)
{ {
case KeyPress: case KeyPress:
if (*kptr & bit) /* allow ddx to generate multiple downs */ /* We MUST NOT change the device itself here. All device state
{ * changes must be performed in ProcessOtherEvents. We're dealing
if (!modifiers) * with the same device struct, so if we change it in POE and
{ * here, we've just screwed up the state by setting it twice.
xE->u.u.type = KeyRelease; *
(*keybd->public.processInputProc)(xE, keybd, count); * Devices may not send core events but always send XI events, so
xE->u.u.type = KeyPress; * the state must be changed in POE, not here.
/* release can have side effects, don't fall through */ */
(*keybd->public.processInputProc)(xE, keybd, count);
}
return;
}
GetPairedPointer(keybd)->valuator->motionHintWindow = NullWindow;
*kptr |= bit;
keyc->prev_state = keyc->state;
for (i = 0, mask = 1; modifiers; i++, mask <<= 1)
{
if (mask & modifiers)
{
/* This key affects modifier "i" */
keyc->modifierKeyCount[i]++;
keyc->state |= mask;
modifiers &= ~mask;
}
}
if (!grab && CheckDeviceGrabs(keybd, xE, 0, count)) if (!grab && CheckDeviceGrabs(keybd, xE, 0, count))
{ {
grabinfo->activatingKey = key; grabinfo->activatingKey = key;
@ -3579,20 +3564,7 @@ drawable.id:0;
case KeyRelease: case KeyRelease:
if (!(*kptr & bit)) /* guard against duplicates */ if (!(*kptr & bit)) /* guard against duplicates */
return; return;
GetPairedPointer(keybd)->valuator->motionHintWindow = NullWindow; /* No device state changes, see comment for KeyPress */
*kptr &= ~bit;
keyc->prev_state = keyc->state;
for (i = 0, mask = 1; modifiers; i++, mask <<= 1)
{
if (mask & modifiers) {
/* This key affects modifier "i" */
if (--keyc->modifierKeyCount[i] <= 0) {
keyc->state &= ~mask;
keyc->modifierKeyCount[i] = 0;
}
modifiers &= ~mask;
}
}
if (grabinfo->fromPassiveGrab && (key == grabinfo->activatingKey)) if (grabinfo->fromPassiveGrab && (key == grabinfo->activatingKey))
deactivateGrab = TRUE; deactivateGrab = TRUE;
break; break;
@ -3729,31 +3701,21 @@ ProcessPointerEvent (xEvent *xE, DeviceIntPtr mouse, int count)
switch (xE->u.u.type) switch (xE->u.u.type)
{ {
case ButtonPress: case ButtonPress:
mouse->valuator->motionHintWindow = NullWindow; /*
if (!(*kptr & bit)) * We rely on the fact that ButtonMotionMask is the same as
butc->buttonsDown++; * DeviceButtonMotionMask, so setting the motionMask
butc->motionMask = ButtonMotionMask; * to this value ensures correctness for both XI and core events.
*kptr |= bit; */
if (xE->u.u.detail == 0) if (xE->u.u.detail == 0)
return; return;
if (xE->u.u.detail <= 5)
butc->state |= (Button1Mask >> 1) << xE->u.u.detail;
filters[MotionNotify] = Motion_Filter(butc); filters[MotionNotify] = Motion_Filter(butc);
if (!grab) if (!grab)
if (CheckDeviceGrabs(mouse, xE, 0, count)) if (CheckDeviceGrabs(mouse, xE, 0, count))
return; return;
break; break;
case ButtonRelease: case ButtonRelease:
mouse->valuator->motionHintWindow = NullWindow;
if (*kptr & bit)
--butc->buttonsDown;
if (!butc->buttonsDown)
butc->motionMask = 0;
*kptr &= ~bit;
if (xE->u.u.detail == 0) if (xE->u.u.detail == 0)
return; return;
if (xE->u.u.detail <= 5)
butc->state &= ~((Button1Mask >> 1) << xE->u.u.detail);
filters[MotionNotify] = Motion_Filter(butc); filters[MotionNotify] = Motion_Filter(butc);
if (!butc->state && mouse->deviceGrab.fromPassiveGrab) if (!butc->state && mouse->deviceGrab.fromPassiveGrab)
deactivateGrab = TRUE; deactivateGrab = TRUE;