diff options
Diffstat (limited to 'xorg-server/hw/xfree86/common/xf86DGA.c')
-rw-r--r-- | xorg-server/hw/xfree86/common/xf86DGA.c | 271 |
1 files changed, 138 insertions, 133 deletions
diff --git a/xorg-server/hw/xfree86/common/xf86DGA.c b/xorg-server/hw/xfree86/common/xf86DGA.c index a06f285f1..8328f5875 100644 --- a/xorg-server/hw/xfree86/common/xf86DGA.c +++ b/xorg-server/hw/xfree86/common/xf86DGA.c @@ -35,19 +35,19 @@ #include "xf86str.h" #include "xf86Priv.h" #include "dgaproc.h" -#include <X11/extensions/xf86dgastr.h> +#include <X11/extensions/xf86dgaproto.h> #include "colormapst.h" #include "pixmapstr.h" #include "inputstr.h" #include "globals.h" #include "servermd.h" #include "micmap.h" -#ifdef XKB -#include <xkbsrv.h> -#endif +#include "xkbsrv.h" #include "xf86Xinput.h" #include "exglobals.h" #include "exevents.h" +#include "eventstr.h" +#include "eventconvert.h" #include "mi.h" @@ -59,8 +59,8 @@ 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 DGAHandleEvent(int screen_num, InternalEvent *event, + DeviceIntPtr device); static void DGACopyModeInfo( @@ -68,7 +68,7 @@ DGACopyModeInfo( XDGAModePtr xmode ); -_X_EXPORT int *XDGAEventBase = NULL; +int *XDGAEventBase = NULL; #define DGA_GET_SCREEN_PRIV(pScreen) ((DGAScreenPtr) \ dixLookupPrivate(&(pScreen)->devPrivates, DGAScreenKey)) @@ -101,7 +101,7 @@ typedef struct { Bool grabKeyboard; } DGAScreenRec, *DGAScreenPtr; -_X_EXPORT Bool +Bool DGAInit( ScreenPtr pScreen, DGAFunctionPtr funcs, @@ -164,7 +164,7 @@ DGAInit( * the DGA mode list. */ -_X_EXPORT Bool +Bool DGAReInitModes( ScreenPtr pScreen, DGAModePtr modes, @@ -247,11 +247,7 @@ DGACloseScreen(int i, ScreenPtr pScreen) DGAScreenPtr pScreenPriv = DGA_GET_SCREEN_PRIV(pScreen); if (XDGAEventBase) { - mieqSetHandler(*XDGAEventBase + MotionNotify, NULL); - mieqSetHandler(*XDGAEventBase + ButtonPress, NULL); - mieqSetHandler(*XDGAEventBase + ButtonRelease, NULL); - mieqSetHandler(*XDGAEventBase + KeyPress, NULL); - mieqSetHandler(*XDGAEventBase + KeyRelease, NULL); + mieqSetHandler(ET_DGAEvent, NULL); } FreeMarkedVisuals(pScreen); @@ -453,7 +449,7 @@ xf86SetDGAMode( /*********** exported ones ***************/ -_X_EXPORT void +void DGASetInputMode(int index, Bool keyboard, Bool mouse) { ScreenPtr pScreen = screenInfo.screens[index]; @@ -465,17 +461,13 @@ DGASetInputMode(int index, Bool keyboard, Bool 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); + mieqSetHandler(ET_DGAEvent, DGAHandleEvent); mieq_installed = 1; } } } -_X_EXPORT Bool +Bool DGAChangePixmapMode(int index, int *x, int *y, int mode) { DGAScreenPtr pScreenPriv; @@ -530,24 +522,19 @@ DGAChangePixmapMode(int index, int *x, int *y, int mode) return TRUE; } -_X_EXPORT Bool +Bool DGAAvailable(int index) { if(DGAScreenKey == NULL) return FALSE; - if (!xf86NoSharedResources(((ScrnInfoPtr)dixLookupPrivate( - &screenInfo.screens[index]->devPrivates, - xf86ScreenKey))->scrnIndex, MEM)) - return FALSE; - if(DGA_GET_SCREEN_PRIV(screenInfo.screens[index])) return TRUE; return FALSE; } -_X_EXPORT Bool +Bool DGAActive(int index) { DGAScreenPtr pScreenPriv; @@ -567,8 +554,8 @@ DGAActive(int index) /* Called by the event code in case the server is abruptly terminated */ -void -DGAShutdown() +void +DGAShutdown(void) { ScrnInfoPtr pScrn; int i; @@ -585,7 +572,7 @@ DGAShutdown() /* Called by the extension to initialize a mode */ -_X_EXPORT int +int DGASetMode( int index, int num, @@ -609,7 +596,7 @@ DGASetMode( /* Called from the extension to let the DDX know which events are requested */ -_X_EXPORT void +void DGASelectInput( int index, ClientPtr client, @@ -622,7 +609,7 @@ DGASelectInput( pScreenPriv->input = mask; } -_X_EXPORT int +int DGAGetViewportStatus(int index) { DGAScreenPtr pScreenPriv = DGA_GET_SCREEN_PRIV(screenInfo.screens[index]); @@ -635,7 +622,7 @@ DGAGetViewportStatus(int index) return (*pScreenPriv->funcs->GetViewport)(pScreenPriv->pScrn); } -_X_EXPORT int +int DGASetViewport( int index, int x, int y, @@ -663,7 +650,7 @@ BitsClear(CARD32 data) return bits; } -_X_EXPORT int +int DGACreateColormap(int index, ClientPtr client, int id, int mode, int alloc) { ScreenPtr pScreen = screenInfo.screens[index]; @@ -732,7 +719,7 @@ DGACreateColormap(int index, ClientPtr client, int id, int mode, int alloc) /* Called by the extension to install a colormap on DGA active screens */ -_X_EXPORT void +void DGAInstallCmap(ColormapPtr cmap) { ScreenPtr pScreen = cmap->pScreen; @@ -748,7 +735,7 @@ DGAInstallCmap(ColormapPtr cmap) (*pScreen->InstallColormap)(cmap); } -_X_EXPORT int +int DGASync(int index) { DGAScreenPtr pScreenPriv = DGA_GET_SCREEN_PRIV(screenInfo.screens[index]); @@ -761,7 +748,7 @@ DGASync(int index) return Success; } -_X_EXPORT int +int DGAFillRect( int index, int x, int y, int w, int h, @@ -780,7 +767,7 @@ DGAFillRect( return BadMatch; } -_X_EXPORT int +int DGABlitRect( int index, int srcx, int srcy, @@ -801,7 +788,7 @@ DGABlitRect( return BadMatch; } -_X_EXPORT int +int DGABlitTransRect( int index, int srcx, int srcy, @@ -824,7 +811,7 @@ DGABlitTransRect( } -_X_EXPORT int +int DGAGetModes(int index) { DGAScreenPtr pScreenPriv = DGA_GET_SCREEN_PRIV(screenInfo.screens[index]); @@ -834,7 +821,7 @@ DGAGetModes(int index) } -_X_EXPORT int +int DGAGetModeInfo( int index, XDGAModePtr mode, @@ -892,7 +879,7 @@ DGACopyModeInfo( } -Bool +Bool DGAVTSwitch(void) { ScreenPtr pScreen; @@ -918,8 +905,8 @@ Bool DGAStealKeyEvent(DeviceIntPtr dev, int index, int key_code, int is_down) { DGAScreenPtr pScreenPriv; - dgaEvent de; - + DGAEvent event; + if(DGAScreenKey == NULL) /* no DGA */ return FALSE; @@ -931,10 +918,16 @@ DGAStealKeyEvent(DeviceIntPtr dev, int index, int key_code, int is_down) 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 (dev, (xEvent *) &de); + memset(&event, 0, sizeof(event)); + event.header = ET_Internal; + event.type = ET_DGAEvent; + event.length = sizeof(event); + event.time = GetTimeInMillis(); + event.subtype = (is_down ? ET_KeyPress : ET_KeyRelease); + event.detail = key_code; + event.dx = 0; + event.dy = 0; + mieqEnqueue (dev, (InternalEvent*)&event); return TRUE; } @@ -945,7 +938,7 @@ Bool DGAStealMotionEvent(DeviceIntPtr dev, int index, int dx, int dy) { DGAScreenPtr pScreenPriv; - dgaEvent de; + DGAEvent event; if(DGAScreenKey == NULL) /* no DGA */ return FALSE; @@ -965,14 +958,17 @@ DGAStealMotionEvent(DeviceIntPtr dev, int index, int dx, int dy) 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 (dev, (xEvent *) &de); + + memset(&event, 0, sizeof(event)); + event.header = ET_Internal; + event.type = ET_DGAEvent; + event.length = sizeof(event); + event.time = GetTimeInMillis(); + event.subtype = ET_Motion; + event.detail = 0; + event.dx = dx; + event.dy = dy; + mieqEnqueue (dev, (InternalEvent*)&event); return TRUE; } @@ -980,7 +976,7 @@ Bool DGAStealButtonEvent(DeviceIntPtr dev, int index, int button, int is_down) { DGAScreenPtr pScreenPriv; - dgaEvent de; + DGAEvent event; if (DGAScreenKey == NULL) return FALSE; @@ -990,14 +986,16 @@ DGAStealButtonEvent(DeviceIntPtr dev, int index, int button, int is_down) 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 (dev, (xEvent *) &de); + memset(&event, 0, sizeof(event)); + event.header = ET_Internal; + event.type = ET_DGAEvent; + event.length = sizeof(event); + event.time = GetTimeInMillis(); + event.subtype = (is_down ? ET_ButtonPress : ET_ButtonRelease); + event.detail = button; + event.dx = 0; + event.dy = 0; + mieqEnqueue (dev, (InternalEvent*)&event); return TRUE; } @@ -1029,82 +1027,94 @@ static Mask filters[] = }; static void -DGAProcessKeyboardEvent (ScreenPtr pScreen, dgaEvent *de, DeviceIntPtr keybd) +DGAProcessKeyboardEvent (ScreenPtr pScreen, DGAEvent *event, DeviceIntPtr keybd) { - int coreEquiv; - xEvent xi; KeyClassPtr keyc = keybd->key; DGAScreenPtr pScreenPriv = DGA_GET_SCREEN_PRIV(pScreen); DeviceIntPtr pointer = GetPairedDevice(keybd); + DeviceEvent ev; - coreEquiv = de->u.u.type - *XDGAEventBase; - - /* - * Fill in remaining event state - */ - de->u.event.dx = 0; - de->u.event.dy = 0; - de->u.event.screen = pScreen->myNum; - de->u.event.state = keyc->state | pointer->button->state; + memset(&ev, 0, sizeof(ev)); + ev.length = sizeof(ev); + ev.detail.key = event->detail; + ev.type = event->subtype; + ev.root_x = 0; + ev.root_y = 0; + ev.corestate = XkbStateFieldFromRec(&keyc->xkbInfo->state); + ev.corestate |= 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 */ + UpdateDeviceState(keybd, &ev); /* * Deliver the DGA event */ if (pScreenPriv->client) { + dgaEvent de; + de.u.u.type = *XDGAEventBase + GetCoreType((InternalEvent*)&ev); + de.u.u.detail = event->detail; + de.u.event.time = event->time; + de.u.event.dx = 0; + de.u.event.dy = 0; + de.u.event.screen = pScreen->myNum; + de.u.event.state = ev.corestate; + /* If the DGA client has selected input, then deliver based on the usual filter */ - TryClientEvents (pScreenPriv->client, keybd, (xEvent *) de, 1, - filters[coreEquiv], pScreenPriv->input, 0); + TryClientEvents (pScreenPriv->client, keybd, (xEvent *)&de, 1, + filters[ev.type], pScreenPriv->input, 0); } else { /* If the keyboard is actively grabbed, deliver a grabbed core event */ if (keybd->deviceGrab.grab && !keybd->deviceGrab.fromPassiveGrab) { - 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); + ev.detail.key = event->detail; + ev.time = event->time; + ev.root_x = event->dx; + ev.root_y = event->dy; + ev.corestate = event->state; + ev.deviceid = keybd->id; + DeliverGrabbedEvent ((InternalEvent*)&ev, keybd, FALSE); } } } static void -DGAProcessPointerEvent (ScreenPtr pScreen, dgaEvent *de, DeviceIntPtr mouse) +DGAProcessPointerEvent (ScreenPtr pScreen, DGAEvent *event, DeviceIntPtr mouse) { ButtonClassPtr butc = mouse->button; - int coreEquiv; DGAScreenPtr pScreenPriv = DGA_GET_SCREEN_PRIV(pScreen); - xEvent xi; + DeviceEvent ev; - coreEquiv = de->u.u.type - *XDGAEventBase; - /* - * Fill in remaining event state - */ - de->u.event.screen = pScreen->myNum; - de->u.event.state = butc->state | GetPairedDevice(mouse)->key->state; + memset(&ev, 0, sizeof(ev)); + ev.header = ET_Internal; + ev.length = sizeof(ev); + ev.type = event->subtype; + ev.corestate = butc->state; + ev.corestate |= XkbStateFieldFromRec(&GetPairedDevice(mouse)->key->xkbInfo->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 */ + UpdateDeviceState(mouse, &ev); /* * Deliver the DGA event */ if (pScreenPriv->client) { + dgaEvent de; + int coreEquiv; + + coreEquiv = GetCoreType((InternalEvent*)&ev); + + de.u.u.type = *XDGAEventBase + coreEquiv; + de.u.u.detail = event->detail; + de.u.event.time = event->time; + de.u.event.dx = 0; + de.u.event.dy = 0; + de.u.event.screen = pScreen->myNum; + de.u.event.state = ev.corestate; + /* If the DGA client has selected input, then deliver based on the usual filter */ - TryClientEvents (pScreenPriv->client, mouse, (xEvent *) de, 1, + TryClientEvents (pScreenPriv->client, mouse, (xEvent *)&de, 1, filters[coreEquiv], pScreenPriv->input, 0); } else @@ -1112,20 +1122,17 @@ 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) { - 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); + ev.detail.button = event->detail; + ev.time = event->time; + ev.root_x = event->dx; + ev.root_y = event->dy; + ev.corestate = event->state; + DeliverGrabbedEvent ((InternalEvent*)&ev, mouse, FALSE); } } } -_X_EXPORT Bool +Bool DGAOpenFramebuffer( int index, char **name, @@ -1142,7 +1149,7 @@ DGAOpenFramebuffer( name, mem, size, offset, flags); } -_X_EXPORT void +void DGACloseFramebuffer(int index) { DGAScreenPtr pScreenPriv = DGA_GET_SCREEN_PRIV(screenInfo.screens[index]); @@ -1154,7 +1161,7 @@ DGACloseFramebuffer(int index) /* For DGA 1.0 backwards compatibility only */ -_X_EXPORT int +int DGAGetOldDGAMode(int index) { DGAScreenPtr pScreenPriv = DGA_GET_SCREEN_PRIV(screenInfo.screens[index]); @@ -1166,7 +1173,7 @@ DGAGetOldDGAMode(int index) w = pScrn->currentMode->HDisplay; h = pScrn->currentMode->VDisplay; - p = ((pScrn->displayWidth * (pScrn->bitsPerPixel >> 3)) + 3) & ~3L; + p = pad_to_int32(pScrn->displayWidth * bits_to_bytes(pScrn->bitsPerPixel)); for(i = 0; i < pScreenPriv->numModes; i++) { mode = &(pScreenPriv->modes[i]); @@ -1184,34 +1191,32 @@ DGAGetOldDGAMode(int index) } static void -DGAHandleEvent(int screen_num, xEvent *event, DeviceIntPtr device, int nevents) +DGAHandleEvent(int screen_num, InternalEvent *ev, DeviceIntPtr device) { - dgaEvent *de = (dgaEvent *) event; + DGAEvent *event= (DGAEvent*)ev; ScreenPtr pScreen = screenInfo.screens[screen_num]; DGAScreenPtr pScreenPriv; - int coreEquiv; /* no DGA */ if (DGAScreenKey == NULL || 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) { + + switch (event->subtype) { case KeyPress: case KeyRelease: - DGAProcessKeyboardEvent (pScreen, de, device); + DGAProcessKeyboardEvent (pScreen, event, device); break; + case MotionNotify: + case ButtonPress: + case ButtonRelease: + DGAProcessPointerEvent (pScreen, event, device); + break; default: - DGAProcessPointerEvent (pScreen, de, device); break; } } |