xfree86: fix DGA to use the correct devices.

DGAStealXXXEvent modified to take in device argument.

The evdev driver only sends one valuator when only one axis changed. We need
to check for DGA either way (xf86PostMotionEventP), otherwise we lose purely
horizontal/vertical movements.

Note that DGA does not do XI events.
This commit is contained in:
Peter Hutterer 2007-10-02 13:19:07 +09:30
parent 122ae65ed9
commit 45ec6cd1fb
3 changed files with 40 additions and 31 deletions

View File

@ -916,7 +916,7 @@ DGAVTSwitch(void)
}
Bool
DGAStealKeyEvent(int index, int key_code, int is_down)
DGAStealKeyEvent(DeviceIntPtr dev, int index, int key_code, int is_down)
{
DGAScreenPtr pScreenPriv;
dgaEvent de;
@ -932,7 +932,7 @@ DGAStealKeyEvent(int index, int key_code, int is_down)
de.u.u.type = *XDGAEventBase + (is_down ? KeyPress : KeyRelease);
de.u.u.detail = key_code;
de.u.event.time = GetTimeInMillis();
mieqEnqueue (inputInfo.keyboard, (xEvent *) &de);
mieqEnqueue (dev, (xEvent *) &de);
return TRUE;
}
@ -940,7 +940,7 @@ DGAStealKeyEvent(int index, int key_code, int is_down)
static int DGAMouseX, DGAMouseY;
Bool
DGAStealMotionEvent(int index, int dx, int dy)
DGAStealMotionEvent(DeviceIntPtr dev, int index, int dx, int dy)
{
DGAScreenPtr pScreenPriv;
dgaEvent de;
@ -970,12 +970,12 @@ DGAStealMotionEvent(int index, int dx, int dy)
de.u.event.dy = dy;
de.u.event.pad1 = DGAMouseX;
de.u.event.pad2 = DGAMouseY;
mieqEnqueue (inputInfo.pointer, (xEvent *) &de);
mieqEnqueue (dev, (xEvent *) &de);
return TRUE;
}
Bool
DGAStealButtonEvent(int index, int button, int is_down)
DGAStealButtonEvent(DeviceIntPtr dev, int index, int button, int is_down)
{
DGAScreenPtr pScreenPriv;
dgaEvent de;
@ -995,7 +995,7 @@ DGAStealButtonEvent(int index, int button, int is_down)
de.u.event.dy = 0;
de.u.event.pad1 = DGAMouseX;
de.u.event.pad2 = DGAMouseY;
mieqEnqueue (inputInfo.pointer, (xEvent *) &de);
mieqEnqueue (dev, (xEvent *) &de);
return TRUE;
}
@ -1038,6 +1038,7 @@ DGAProcessKeyboardEvent (ScreenPtr pScreen, dgaEvent *de, DeviceIntPtr keybd)
xEvent core;
KeyClassPtr keyc = keybd->key;
DGAScreenPtr pScreenPriv = DGA_GET_SCREEN_PRIV(pScreen);
DeviceIntPtr pointer = GetPairedPointer(keybd);
coreEquiv = de->u.u.type - *XDGAEventBase;
@ -1047,7 +1048,7 @@ DGAProcessKeyboardEvent (ScreenPtr pScreen, dgaEvent *de, DeviceIntPtr keybd)
de->u.event.dx = 0;
de->u.event.dy = 0;
de->u.event.screen = pScreen->myNum;
de->u.event.state = keyc->state | (inputInfo.pointer)->button->state;
de->u.event.state = keyc->state | pointer->button->state;
/*
* Keep the core state in sync by duplicating what
@ -1060,7 +1061,7 @@ DGAProcessKeyboardEvent (ScreenPtr pScreen, dgaEvent *de, DeviceIntPtr keybd)
switch (coreEquiv)
{
case KeyPress:
inputInfo.pointer->valuator->motionHintWindow = NullWindow;
pointer->valuator->motionHintWindow = NullWindow;
*kptr |= bit;
keyc->prev_state = keyc->state;
#ifdef XKB
@ -1081,7 +1082,7 @@ DGAProcessKeyboardEvent (ScreenPtr pScreen, dgaEvent *de, DeviceIntPtr keybd)
}
break;
case KeyRelease:
inputInfo.pointer->valuator->motionHintWindow = NullWindow;
pointer->valuator->motionHintWindow = NullWindow;
*kptr &= ~bit;
keyc->prev_state = keyc->state;
#ifdef XKB
@ -1197,8 +1198,6 @@ DGAProcessPointerEvent (ScreenPtr pScreen, dgaEvent *de, DeviceIntPtr mouse)
/* If the pointer is actively grabbed, deliver a grabbed core event */
if (mouse->deviceGrab.grab && !mouse->deviceGrab.fromPassiveGrab)
{
/* I've got no clue if that is correct but only working on core
* grabs seems the right thing here. (whot) */
core.u.u.type = coreEquiv;
core.u.u.detail = de->u.u.detail;
core.u.keyButtonPointer.time = de->u.event.time;

View File

@ -539,7 +539,7 @@ xf86PostMotionEventP(DeviceIntPtr device,
int *valuators)
{
int i = 0, nevents = 0;
int dx, dy;
int dx = 0, dy = 0;
Bool drag = xf86SendDragEvents(device);
xEvent *xE = NULL;
int index;
@ -551,18 +551,25 @@ xf86PostMotionEventP(DeviceIntPtr device,
flags = POINTER_RELATIVE | POINTER_ACCELERATE;
#if XFreeXDGA
if (first_valuator == 0 && num_valuators >= 2) {
if (miPointerGetScreen(inputInfo.pointer)) {
index = miPointerGetScreen(inputInfo.pointer)->myNum;
if (is_absolute) {
dx = valuators[0] - device->valuator->lastx;
dy = valuators[1] - device->valuator->lasty;
}
else {
/* The evdev driver may not always send all axes across. */
if (num_valuators >= 1 && first_valuator <= 1) {
if (miPointerGetScreen(device)) {
index = miPointerGetScreen(device)->myNum;
if (first_valuator == 0)
{
dx = valuators[0];
dy = valuators[1];
if (is_absolute)
dx -= device->valuator->lastx;
}
if (DGAStealMotionEvent(index, dx, dy))
if (first_valuator == 1 || num_valuators >= 2)
{
dy = valuators[1 - first_valuator];
if (is_absolute)
dy -= device->valuator->lasty;
}
if (DGAStealMotionEvent(device, index, dx, dy))
return;
}
}
@ -633,9 +640,9 @@ xf86PostButtonEvent(DeviceIntPtr device,
int index;
#if XFreeXDGA
if (miPointerGetScreen(inputInfo.pointer)) {
index = miPointerGetScreen(inputInfo.pointer)->myNum;
if (DGAStealButtonEvent(index, button, is_down))
if (miPointerGetScreen(device)) {
index = miPointerGetScreen(device)->myNum;
if (DGAStealButtonEvent(device, index, button, is_down))
return;
}
#endif
@ -716,9 +723,11 @@ xf86PostKeyboardEvent(DeviceIntPtr device,
int index;
#if XFreeXDGA
if (miPointerGetScreen(inputInfo.pointer)) {
index = miPointerGetScreen(inputInfo.pointer)->myNum;
if (DGAStealKeyEvent(index, key_code, is_down))
DeviceIntPtr pointer = GetPairedPointer(device);
if (miPointerGetScreen(pointer)) {
index = miPointerGetScreen(pointer)->myNum;
if (DGAStealKeyEvent(device, index, key_code, is_down))
return;
}
#endif

View File

@ -120,9 +120,10 @@ int DGAGetOldDGAMode(int Index);
int DGAGetModeInfo(int Index, XDGAModePtr mode, int num);
Bool DGAVTSwitch(void);
Bool DGAStealButtonEvent(int Index, int button, int is_down);
Bool DGAStealMotionEvent(int Index, int dx, int dy);
Bool DGAStealKeyEvent(int Index, int key_code, int is_down);
Bool DGAStealButtonEvent(DeviceIntPtr dev, int Index, int button,
int is_down);
Bool DGAStealMotionEvent(DeviceIntPtr dev, int Index, int dx, int dy);
Bool DGAStealKeyEvent(DeviceIntPtr dev, int Index, int key_code, int is_down);
Bool DGAIsDgaEvent (xEvent *e);
Bool DGADeliverEvent (ScreenPtr pScreen, xEvent *e);