aboutsummaryrefslogtreecommitdiff
path: root/xorg-server/hw/xfree86/common/xf86DGA.c
diff options
context:
space:
mode:
Diffstat (limited to 'xorg-server/hw/xfree86/common/xf86DGA.c')
-rw-r--r--xorg-server/hw/xfree86/common/xf86DGA.c189
1 files changed, 55 insertions, 134 deletions
diff --git a/xorg-server/hw/xfree86/common/xf86DGA.c b/xorg-server/hw/xfree86/common/xf86DGA.c
index 0daf1de44..a06f285f1 100644
--- a/xorg-server/hw/xfree86/common/xf86DGA.c
+++ b/xorg-server/hw/xfree86/common/xf86DGA.c
@@ -46,10 +46,13 @@
#include <xkbsrv.h>
#endif
#include "xf86Xinput.h"
+#include "exglobals.h"
+#include "exevents.h"
#include "mi.h"
-static DevPrivateKey DGAScreenKey = NULL;
+static int DGAScreenKeyIndex;
+static DevPrivateKey DGAScreenKey;
static int mieq_installed = 0;
static Bool DGACloseScreen(int i, ScreenPtr pScreen);
@@ -115,7 +118,7 @@ DGAInit(
if(!modes || num <= 0)
return FALSE;
- DGAScreenKey = &DGAScreenKey;
+ DGAScreenKey = &DGAScreenKeyIndex;
if(!(pScreenPriv = (DGAScreenPtr)xalloc(sizeof(DGAScreenRec))))
return FALSE;
@@ -912,7 +915,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;
@@ -920,6 +923,9 @@ DGAStealKeyEvent(int index, int key_code, int is_down)
if(DGAScreenKey == NULL) /* no DGA */
return FALSE;
+ if (key_code < 8 || key_code > 255)
+ return FALSE;
+
pScreenPriv = DGA_GET_SCREEN_PRIV(screenInfo.screens[index]);
if(!pScreenPriv || !pScreenPriv->grabKeyboard) /* no direct mode */
@@ -928,7 +934,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;
}
@@ -936,7 +942,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;
@@ -966,12 +972,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;
@@ -991,7 +997,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;
}
@@ -1025,16 +1031,12 @@ static Mask filters[] =
static void
DGAProcessKeyboardEvent (ScreenPtr pScreen, dgaEvent *de, DeviceIntPtr keybd)
{
- int key, bit;
- register BYTE *kptr;
- register int i;
- register CARD8 modifiers;
- register CARD16 mask;
int coreEquiv;
- xEvent core;
+ xEvent xi;
KeyClassPtr keyc = keybd->key;
DGAScreenPtr pScreenPriv = DGA_GET_SCREEN_PRIV(pScreen);
-
+ DeviceIntPtr pointer = GetPairedDevice(keybd);
+
coreEquiv = de->u.u.type - *XDGAEventBase;
/*
@@ -1043,84 +1045,36 @@ 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;
+
+ de->u.u.type = (IEventBase - 1) + coreEquiv; /* change to XI event */
+ UpdateDeviceState(keybd, (xEvent*)de, 1);
+ de->u.u.type = *XDGAEventBase + coreEquiv; /* change back */
- /*
- * Keep the core state in sync by duplicating what
- * CoreProcessKeyboardEvent does
- */
- key = de->u.u.detail;
- kptr = &keyc->down[key >> 3];
- bit = 1 << (key & 7);
- modifiers = keyc->modifierMap[key];
- switch (coreEquiv)
- {
- case KeyPress:
- inputInfo.pointer->valuator->motionHintWindow = NullWindow;
- *kptr |= bit;
- keyc->prev_state = keyc->state;
-#ifdef XKB
- if (noXkbExtension)
-#endif
- {
-
- 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;
- }
- }
- }
- break;
- case KeyRelease:
- inputInfo.pointer->valuator->motionHintWindow = NullWindow;
- *kptr &= ~bit;
- keyc->prev_state = keyc->state;
-#ifdef XKB
- if (noXkbExtension)
-#endif
- {
- 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;
- }
- }
- }
- break;
- }
/*
* Deliver the DGA event
*/
if (pScreenPriv->client)
{
/* If the DGA client has selected input, then deliver based on the usual filter */
- TryClientEvents (pScreenPriv->client, (xEvent *) de, 1,
+ TryClientEvents (pScreenPriv->client, keybd, (xEvent *) de, 1,
filters[coreEquiv], pScreenPriv->input, 0);
}
else
{
/* If the keyboard is actively grabbed, deliver a grabbed core event */
- if (keybd->grab && !keybd->fromPassiveGrab)
+ if (keybd->deviceGrab.grab && !keybd->deviceGrab.fromPassiveGrab)
{
- core.u.u.type = coreEquiv;
- core.u.u.detail = de->u.u.detail;
- core.u.keyButtonPointer.time = de->u.event.time;
- core.u.keyButtonPointer.eventX = de->u.event.dx;
- core.u.keyButtonPointer.eventY = de->u.event.dy;
- core.u.keyButtonPointer.rootX = de->u.event.dx;
- core.u.keyButtonPointer.rootY = de->u.event.dy;
- core.u.keyButtonPointer.state = de->u.event.state;
- DeliverGrabbedEvent (&core, keybd, FALSE, 1);
+ xi.u.u.type = (IEventBase - 1) + coreEquiv;
+ xi.u.u.detail = de->u.u.detail;
+ xi.u.keyButtonPointer.time = de->u.event.time;
+ xi.u.keyButtonPointer.eventX = de->u.event.dx;
+ xi.u.keyButtonPointer.eventY = de->u.event.dy;
+ xi.u.keyButtonPointer.rootX = de->u.event.dx;
+ xi.u.keyButtonPointer.rootY = de->u.event.dy;
+ xi.u.keyButtonPointer.state = de->u.event.state;
+ ((deviceKeyButtonPointer*)&xi)->deviceid = keybd->id;
+ DeliverGrabbedEvent (&xi, keybd, FALSE, 1);
}
}
}
@@ -1129,77 +1083,44 @@ static void
DGAProcessPointerEvent (ScreenPtr pScreen, dgaEvent *de, DeviceIntPtr mouse)
{
ButtonClassPtr butc = mouse->button;
- int coreEquiv;
+ int coreEquiv;
DGAScreenPtr pScreenPriv = DGA_GET_SCREEN_PRIV(pScreen);
- xEvent core;
+ xEvent xi;
coreEquiv = de->u.u.type - *XDGAEventBase;
/*
* Fill in remaining event state
*/
de->u.event.screen = pScreen->myNum;
- de->u.event.state = butc->state | inputInfo.keyboard->key->state;
- /*
- * Keep the core state in sync by duplicating what
- * CoreProcessPointerEvent does
- */
- if (coreEquiv != MotionNotify)
- {
- register int key;
- register BYTE *kptr;
- int bit;
-
- key = de->u.u.detail;
- kptr = &butc->down[key >> 3];
- bit = 1 << (key & 7);
- switch (coreEquiv)
- {
- case ButtonPress:
- mouse->valuator->motionHintWindow = NullWindow;
- if (!(*kptr & bit))
- butc->buttonsDown++;
- butc->motionMask = ButtonMotionMask;
- *kptr |= bit;
- if (key <= 5)
- butc->state |= (Button1Mask >> 1) << key;
- break;
- case ButtonRelease:
- mouse->valuator->motionHintWindow = NullWindow;
- if (*kptr & bit)
- --butc->buttonsDown;
- if (!butc->buttonsDown)
- butc->motionMask = 0;
- *kptr &= ~bit;
- if (key == 0)
- return;
- if (key <= 5)
- butc->state &= ~((Button1Mask >> 1) << key);
- break;
- }
- }
+ de->u.event.state = butc->state | GetPairedDevice(mouse)->key->state;
+
+ de->u.u.type = (IEventBase - 1) + coreEquiv; /* change to XI event */
+ UpdateDeviceState(mouse, (xEvent*)de, 1);
+ de->u.u.type = *XDGAEventBase + coreEquiv; /* change back */
+
/*
* Deliver the DGA event
*/
if (pScreenPriv->client)
{
/* If the DGA client has selected input, then deliver based on the usual filter */
- TryClientEvents (pScreenPriv->client, (xEvent *) de, 1,
+ TryClientEvents (pScreenPriv->client, mouse, (xEvent *) de, 1,
filters[coreEquiv], pScreenPriv->input, 0);
}
else
{
/* If the pointer is actively grabbed, deliver a grabbed core event */
- if (mouse->grab && !mouse->fromPassiveGrab)
+ if (mouse->deviceGrab.grab && !mouse->deviceGrab.fromPassiveGrab)
{
- core.u.u.type = coreEquiv;
- core.u.u.detail = de->u.u.detail;
- core.u.keyButtonPointer.time = de->u.event.time;
- core.u.keyButtonPointer.eventX = de->u.event.dx;
- core.u.keyButtonPointer.eventY = de->u.event.dy;
- core.u.keyButtonPointer.rootX = de->u.event.dx;
- core.u.keyButtonPointer.rootY = de->u.event.dy;
- core.u.keyButtonPointer.state = de->u.event.state;
- DeliverGrabbedEvent (&core, mouse, FALSE, 1);
+ xi.u.u.type = (IEventBase - 1 ) + coreEquiv;
+ xi.u.u.detail = de->u.u.detail;
+ xi.u.keyButtonPointer.time = de->u.event.time;
+ xi.u.keyButtonPointer.eventX = de->u.event.dx;
+ xi.u.keyButtonPointer.eventY = de->u.event.dy;
+ xi.u.keyButtonPointer.rootX = de->u.event.dx;
+ xi.u.keyButtonPointer.rootY = de->u.event.dy;
+ xi.u.keyButtonPointer.state = de->u.event.state;
+ DeliverGrabbedEvent (&xi, mouse, FALSE, 1);
}
}
}
@@ -1287,10 +1208,10 @@ DGAHandleEvent(int screen_num, xEvent *event, DeviceIntPtr device, int nevents)
switch (coreEquiv) {
case KeyPress:
case KeyRelease:
- DGAProcessKeyboardEvent (pScreen, de, inputInfo.keyboard);
+ DGAProcessKeyboardEvent (pScreen, de, device);
break;
default:
- DGAProcessPointerEvent (pScreen, de, inputInfo.pointer);
+ DGAProcessPointerEvent (pScreen, de, device);
break;
}
}