xfree86 input: Re-enable DGA support
Re-enable DGA support for relative mouse motion.
This commit is contained in:
parent
80d29475b9
commit
0f75c47e0c
|
@ -51,11 +51,14 @@
|
|||
|
||||
static unsigned long DGAGeneration = 0;
|
||||
static int DGAScreenIndex = -1;
|
||||
static int mieq_installed = 0;
|
||||
|
||||
static Bool DGACloseScreen(int i, ScreenPtr pScreen);
|
||||
static void DGADestroyColormap(ColormapPtr pmap);
|
||||
static void DGAInstallColormap(ColormapPtr pmap);
|
||||
static void DGAUninstallColormap(ColormapPtr pmap);
|
||||
static void DGAHandleEvent(int screen_num, xEvent *event,
|
||||
DeviceIntPtr device, int nevents);
|
||||
|
||||
static void
|
||||
DGACopyModeInfo(
|
||||
|
@ -96,7 +99,6 @@ typedef struct {
|
|||
Bool grabKeyboard;
|
||||
} DGAScreenRec, *DGAScreenPtr;
|
||||
|
||||
|
||||
_X_EXPORT Bool
|
||||
DGAInit(
|
||||
ScreenPtr pScreen,
|
||||
|
@ -146,7 +148,6 @@ DGAInit(
|
|||
modes[i].flags &= ~DGA_PIXMAP_AVAILABLE;
|
||||
#endif
|
||||
|
||||
|
||||
pScreen->devPrivates[DGAScreenIndex].ptr = (pointer)pScreenPriv;
|
||||
pScreenPriv->CloseScreen = pScreen->CloseScreen;
|
||||
pScreen->CloseScreen = DGACloseScreen;
|
||||
|
@ -157,11 +158,6 @@ DGAInit(
|
|||
pScreenPriv->UninstallColormap = pScreen->UninstallColormap;
|
||||
pScreen->UninstallColormap = DGAUninstallColormap;
|
||||
|
||||
/*
|
||||
* This is now set in InitOutput().
|
||||
*
|
||||
pScrn->SetDGAMode = xf86SetDGAMode;
|
||||
*/
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
@ -247,12 +243,22 @@ FreeMarkedVisuals(ScreenPtr pScreen)
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
static Bool
|
||||
DGACloseScreen(int i, ScreenPtr pScreen)
|
||||
{
|
||||
DGAScreenPtr pScreenPriv = DGA_GET_SCREEN_PRIV(pScreen);
|
||||
|
||||
if (XDGAEventBase) {
|
||||
OsBlockSignals();
|
||||
ProcessInputEvents();
|
||||
mieqSetHandler(*XDGAEventBase + MotionNotify, NULL);
|
||||
mieqSetHandler(*XDGAEventBase + ButtonPress, NULL);
|
||||
mieqSetHandler(*XDGAEventBase + ButtonRelease, NULL);
|
||||
mieqSetHandler(*XDGAEventBase + KeyPress, NULL);
|
||||
mieqSetHandler(*XDGAEventBase + KeyRelease, NULL);
|
||||
OsReleaseSignals();
|
||||
}
|
||||
|
||||
FreeMarkedVisuals(pScreen);
|
||||
|
||||
pScreen->CloseScreen = pScreenPriv->CloseScreen;
|
||||
|
@ -462,6 +468,15 @@ DGASetInputMode(int index, Bool keyboard, Bool mouse)
|
|||
{
|
||||
pScreenPriv->grabMouse = mouse;
|
||||
pScreenPriv->grabKeyboard = keyboard;
|
||||
|
||||
if (!mieq_installed) {
|
||||
mieqSetHandler(*XDGAEventBase + MotionNotify, DGAHandleEvent);
|
||||
mieqSetHandler(*XDGAEventBase + ButtonPress, DGAHandleEvent);
|
||||
mieqSetHandler(*XDGAEventBase + ButtonRelease, DGAHandleEvent);
|
||||
mieqSetHandler(*XDGAEventBase + KeyPress, DGAHandleEvent);
|
||||
mieqSetHandler(*XDGAEventBase + KeyRelease, DGAHandleEvent);
|
||||
mieq_installed = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -903,21 +918,93 @@ DGAVTSwitch(void)
|
|||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
/* We have the power to steal or modify events that are about to get queued */
|
||||
|
||||
Bool
|
||||
DGAStealKeyEvent(int index, xEvent *e)
|
||||
DGAStealKeyEvent(int index, int key_code, int is_down)
|
||||
{
|
||||
}
|
||||
DGAScreenPtr pScreenPriv;
|
||||
dgaEvent de;
|
||||
|
||||
if(DGAScreenIndex < 0) /* no DGA */
|
||||
return FALSE;
|
||||
|
||||
pScreenPriv = DGA_GET_SCREEN_PRIV(screenInfo.screens[index]);
|
||||
|
||||
if(!pScreenPriv || !pScreenPriv->grabKeyboard) /* no direct mode */
|
||||
return FALSE;
|
||||
|
||||
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);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static int DGAMouseX, DGAMouseY;
|
||||
|
||||
Bool
|
||||
DGAStealMouseEvent(int index, xEvent *e, int dx, int dy)
|
||||
DGAStealMotionEvent(int index, int dx, int dy)
|
||||
{
|
||||
DGAScreenPtr pScreenPriv;
|
||||
dgaEvent de;
|
||||
|
||||
if(DGAScreenIndex < 0) /* no DGA */
|
||||
return FALSE;
|
||||
|
||||
pScreenPriv = DGA_GET_SCREEN_PRIV(screenInfo.screens[index]);
|
||||
|
||||
if(!pScreenPriv || !pScreenPriv->grabMouse) /* no direct mode */
|
||||
return FALSE;
|
||||
|
||||
DGAMouseX += dx;
|
||||
if (DGAMouseX < 0)
|
||||
DGAMouseX = 0;
|
||||
else if (DGAMouseX > screenInfo.screens[index]->width)
|
||||
DGAMouseX = screenInfo.screens[index]->width;
|
||||
DGAMouseY += dy;
|
||||
if (DGAMouseY < 0)
|
||||
DGAMouseY = 0;
|
||||
else if (DGAMouseY > screenInfo.screens[index]->height)
|
||||
DGAMouseY = screenInfo.screens[index]->height;
|
||||
de.u.u.type = *XDGAEventBase + MotionNotify;
|
||||
de.u.u.detail = 0;
|
||||
de.u.event.time = GetTimeInMillis();
|
||||
de.u.event.dx = dx;
|
||||
de.u.event.dy = dy;
|
||||
de.u.event.pad1 = DGAMouseX;
|
||||
de.u.event.pad2 = DGAMouseY;
|
||||
mieqEnqueue (inputInfo.pointer, (xEvent *) &de);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
Bool
|
||||
DGAStealButtonEvent(int index, int button, int is_down)
|
||||
{
|
||||
DGAScreenPtr pScreenPriv;
|
||||
dgaEvent de;
|
||||
|
||||
if (DGAScreenIndex < 0)
|
||||
return FALSE;
|
||||
|
||||
pScreenPriv = DGA_GET_SCREEN_PRIV(screenInfo.screens[index]);
|
||||
|
||||
if (!pScreenPriv || !pScreenPriv->grabMouse)
|
||||
return FALSE;
|
||||
|
||||
de.u.u.type = *XDGAEventBase + (is_down ? ButtonPress : ButtonRelease);
|
||||
de.u.u.detail = button;
|
||||
de.u.event.time = GetTimeInMillis();
|
||||
de.u.event.dx = 0;
|
||||
de.u.event.dy = 0;
|
||||
de.u.event.pad1 = DGAMouseX;
|
||||
de.u.event.pad2 = DGAMouseY;
|
||||
mieqEnqueue (inputInfo.pointer, (xEvent *) &de);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/* We have the power to steal or modify events that are about to get queued */
|
||||
|
||||
Bool
|
||||
DGAIsDgaEvent (xEvent *e)
|
||||
{
|
||||
|
@ -1124,39 +1211,6 @@ DGAProcessPointerEvent (ScreenPtr pScreen, dgaEvent *de, DeviceIntPtr mouse)
|
|||
}
|
||||
}
|
||||
|
||||
Bool
|
||||
DGADeliverEvent (ScreenPtr pScreen, xEvent *e)
|
||||
{
|
||||
dgaEvent *de = (dgaEvent *) e;
|
||||
DGAScreenPtr pScreenPriv;
|
||||
int coreEquiv;
|
||||
|
||||
/* no DGA */
|
||||
if (DGAScreenIndex < 0 || XDGAEventBase == 0)
|
||||
return FALSE;
|
||||
pScreenPriv = DGA_GET_SCREEN_PRIV(pScreen);
|
||||
|
||||
/* DGA not initialized on this screen */
|
||||
if (!pScreenPriv)
|
||||
return FALSE;
|
||||
|
||||
coreEquiv = de->u.u.type - *XDGAEventBase;
|
||||
/* Not a DGA event */
|
||||
if (coreEquiv < KeyPress || coreEquiv > MotionNotify)
|
||||
return FALSE;
|
||||
|
||||
switch (coreEquiv) {
|
||||
case KeyPress:
|
||||
case KeyRelease:
|
||||
DGAProcessKeyboardEvent (pScreen, de, inputInfo.keyboard);
|
||||
break;
|
||||
default:
|
||||
DGAProcessPointerEvent (pScreen, de, inputInfo.pointer);
|
||||
break;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
_X_EXPORT Bool
|
||||
DGAOpenFramebuffer(
|
||||
int index,
|
||||
|
@ -1215,3 +1269,35 @@ DGAGetOldDGAMode(int index)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static void
|
||||
DGAHandleEvent(int screen_num, xEvent *event, DeviceIntPtr device, int nevents)
|
||||
{
|
||||
dgaEvent *de = (dgaEvent *) event;
|
||||
ScreenPtr pScreen = screenInfo.screens[screen_num];
|
||||
DGAScreenPtr pScreenPriv;
|
||||
int coreEquiv;
|
||||
|
||||
/* no DGA */
|
||||
if (DGAScreenIndex < 0 || XDGAEventBase == 0)
|
||||
return;
|
||||
pScreenPriv = DGA_GET_SCREEN_PRIV(pScreen);
|
||||
|
||||
/* DGA not initialized on this screen */
|
||||
if (!pScreenPriv)
|
||||
return;
|
||||
|
||||
coreEquiv = de->u.u.type - *XDGAEventBase;
|
||||
/* Not a DGA event; shouldn't happen, but you never know. */
|
||||
if (coreEquiv < KeyPress || coreEquiv > MotionNotify)
|
||||
return;
|
||||
|
||||
switch (coreEquiv) {
|
||||
case KeyPress:
|
||||
case KeyRelease:
|
||||
DGAProcessKeyboardEvent (pScreen, de, inputInfo.keyboard);
|
||||
break;
|
||||
default:
|
||||
DGAProcessPointerEvent (pScreen, de, inputInfo.pointer);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -90,6 +90,10 @@
|
|||
|
||||
#include "mi.h"
|
||||
|
||||
#ifdef XFreeXDGA
|
||||
#include "dgaproc.h"
|
||||
#endif
|
||||
|
||||
xEvent *xf86Events = NULL;
|
||||
|
||||
static Bool
|
||||
|
@ -395,10 +399,12 @@ xf86PostMotionEvent(DeviceIntPtr device,
|
|||
{
|
||||
va_list var;
|
||||
int i = 0, nevents = 0;
|
||||
int dx, dy;
|
||||
Bool drag = xf86SendDragEvents(device);
|
||||
int *valuators = NULL;
|
||||
int flags = 0;
|
||||
xEvent *xE = NULL;
|
||||
int index;
|
||||
|
||||
if (is_absolute)
|
||||
flags = POINTER_ABSOLUTE;
|
||||
|
@ -412,6 +418,22 @@ xf86PostMotionEvent(DeviceIntPtr device,
|
|||
valuators[i] = va_arg(var, int);
|
||||
va_end(var);
|
||||
|
||||
#if XFreeXDGA
|
||||
if (first_valuator == 0 && num_valuators >= 2) {
|
||||
index = miPointerGetScreen(inputInfo.pointer)->myNum;
|
||||
if (is_absolute) {
|
||||
dx = valuators[0] - device->valuator->lastx;
|
||||
dy = valuators[1] - device->valuator->lasty;
|
||||
}
|
||||
else {
|
||||
dx = valuators[0];
|
||||
dy = valuators[1];
|
||||
}
|
||||
if (DGAStealMotionEvent(index, dx, dy))
|
||||
goto out;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (!xf86Events)
|
||||
xf86Events = (xEvent *)xcalloc(sizeof(xEvent), GetMaximumEventsNum());
|
||||
if (!xf86Events)
|
||||
|
@ -430,6 +452,7 @@ xf86PostMotionEvent(DeviceIntPtr device,
|
|||
}
|
||||
}
|
||||
|
||||
out:
|
||||
xfree(valuators);
|
||||
}
|
||||
|
||||
|
@ -476,6 +499,13 @@ xf86PostButtonEvent(DeviceIntPtr device,
|
|||
va_list var;
|
||||
int *valuators = NULL;
|
||||
int i = 0, nevents = 0;
|
||||
int index;
|
||||
|
||||
#if XFreeXDGA
|
||||
index = miPointerGetScreen(inputInfo.pointer)->myNum;
|
||||
if (DGAStealButtonEvent(index, button, is_down))
|
||||
return;
|
||||
#endif
|
||||
|
||||
valuators = xcalloc(sizeof(int), num_valuators);
|
||||
|
||||
|
@ -552,6 +582,13 @@ xf86PostKeyboardEvent(DeviceIntPtr device,
|
|||
int is_down)
|
||||
{
|
||||
int nevents = 0, i = 0;
|
||||
int index;
|
||||
|
||||
#if XFreeXDGA
|
||||
index = miPointerGetScreen(inputInfo.pointer)->myNum;
|
||||
if (DGAStealKeyEvent(index, key_code, is_down))
|
||||
return;
|
||||
#endif
|
||||
|
||||
if (!xf86Events)
|
||||
xf86Events = (xEvent *)xcalloc(sizeof(xEvent), GetMaximumEventsNum());
|
||||
|
|
|
@ -191,6 +191,10 @@ InputInfoPtr xf86AllocateInput(InputDriverPtr drv, int flags);
|
|||
InputDriverPtr xf86LookupInputDriver(const char *name);
|
||||
InputInfoPtr xf86LookupInput(const char *name);
|
||||
void xf86DeleteInput(InputInfoPtr pInp, int flags);
|
||||
void xf86MotionHistoryAllocate(LocalDevicePtr local);
|
||||
int xf86GetMotionEvents(DeviceIntPtr dev, xTimecoord *buff,
|
||||
unsigned long start, unsigned long stop,
|
||||
ScreenPtr pScreen);
|
||||
|
||||
/* xf86Option.c */
|
||||
void xf86CollectInputOptions(InputInfoPtr pInfo, const char **defaultOpts,
|
||||
|
|
|
@ -120,8 +120,9 @@ int DGAGetOldDGAMode(int Index);
|
|||
int DGAGetModeInfo(int Index, XDGAModePtr mode, int num);
|
||||
|
||||
Bool DGAVTSwitch(void);
|
||||
Bool DGAStealMouseEvent(int Index, xEvent *e, int dx, int dy);
|
||||
Bool DGAStealKeyEvent(int Index, xEvent *e);
|
||||
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 DGAIsDgaEvent (xEvent *e);
|
||||
|
||||
Bool DGADeliverEvent (ScreenPtr pScreen, xEvent *e);
|
||||
|
|
Loading…
Reference in New Issue
Block a user