From 0f834b91a4768673833ab4917e87d86c237bb1a6 Mon Sep 17 00:00:00 2001 From: marha Date: Fri, 23 Mar 2012 10:05:55 +0100 Subject: libX11 xserver fontconfig mesa pixman xkbcomp xkeyboard-config git update 23 Mar 2012 --- xorg-server/hw/xquartz/xpr/appledri.c | 211 +++--- xorg-server/hw/xquartz/xpr/appledristr.h | 309 +++++---- xorg-server/hw/xquartz/xpr/dri.c | 549 +++++++-------- xorg-server/hw/xquartz/xpr/dri.h | 58 +- xorg-server/hw/xquartz/xpr/driWrap.c | 1089 +++++++++++++++--------------- xorg-server/hw/xquartz/xpr/dristruct.h | 31 +- xorg-server/hw/xquartz/xpr/x-hash.c | 188 +++--- xorg-server/hw/xquartz/xpr/x-hash.h | 64 +- xorg-server/hw/xquartz/xpr/x-hook.c | 231 +++---- xorg-server/hw/xquartz/xpr/x-hook.h | 14 +- xorg-server/hw/xquartz/xpr/x-list.c | 164 ++--- xorg-server/hw/xquartz/xpr/xprAppleWM.c | 71 +- xorg-server/hw/xquartz/xpr/xprCursor.c | 101 ++- xorg-server/hw/xquartz/xpr/xprEvent.c | 39 +- xorg-server/hw/xquartz/xpr/xprFrame.c | 224 +++--- xorg-server/hw/xquartz/xpr/xprScreen.c | 268 ++++---- 16 files changed, 1758 insertions(+), 1853 deletions(-) (limited to 'xorg-server/hw/xquartz/xpr') diff --git a/xorg-server/hw/xquartz/xpr/appledri.c b/xorg-server/hw/xquartz/xpr/appledri.c index 44c132abc..4ef0061b2 100644 --- a/xorg-server/hw/xquartz/xpr/appledri.c +++ b/xorg-server/hw/xquartz/xpr/appledri.c @@ -59,36 +59,31 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. static int DRIErrorBase = 0; - -static void AppleDRIResetProc(ExtensionEntry* extEntry); +static void AppleDRIResetProc(ExtensionEntry * extEntry); static int ProcAppleDRICreatePixmap(ClientPtr client); static unsigned char DRIReqCode = 0; static int DRIEventBase = 0; -static void SNotifyEvent(xAppleDRINotifyEvent *from, xAppleDRINotifyEvent *to); +static void SNotifyEvent(xAppleDRINotifyEvent * from, + xAppleDRINotifyEvent * to); typedef struct _DRIEvent *DRIEventPtr; typedef struct _DRIEvent { - DRIEventPtr next; - ClientPtr client; - XID clientResource; - unsigned int mask; + DRIEventPtr next; + ClientPtr client; + XID clientResource; + unsigned int mask; } DRIEventRec; -/*ARGSUSED*/ -static void -AppleDRIResetProc ( - ExtensionEntry* extEntry -) + /*ARGSUSED*/ static void +AppleDRIResetProc(ExtensionEntry * extEntry) { DRIReset(); } static int -ProcAppleDRIQueryVersion( - register ClientPtr client -) +ProcAppleDRIQueryVersion(register ClientPtr client) { xAppleDRIQueryVersionReply rep; @@ -106,17 +101,14 @@ ProcAppleDRIQueryVersion( swaps(&rep.minorVersion); swapl(&rep.patchVersion); } - WriteToClient(client, sizeof(xAppleDRIQueryVersionReply), (char *)&rep); + WriteToClient(client, sizeof(xAppleDRIQueryVersionReply), (char *) &rep); return Success; } - /* surfaces */ static int -ProcAppleDRIQueryDirectRenderingCapable( - register ClientPtr client -) +ProcAppleDRIQueryDirectRenderingCapable(register ClientPtr client) { xAppleDRIQueryDirectRenderingCapableReply rep; Bool isCapable; @@ -127,8 +119,8 @@ ProcAppleDRIQueryDirectRenderingCapable( rep.length = 0; rep.sequenceNumber = client->sequence; - if (!DRIQueryDirectRenderingCapable( screenInfo.screens[stuff->screen], - &isCapable)) { + if (!DRIQueryDirectRenderingCapable(screenInfo.screens[stuff->screen], + &isCapable)) { return BadValue; } rep.isCapable = isCapable; @@ -141,18 +133,17 @@ ProcAppleDRIQueryDirectRenderingCapable( swapl(&rep.length); } - WriteToClient(client, - sizeof(xAppleDRIQueryDirectRenderingCapableReply), (char *)&rep); + WriteToClient(client, + sizeof(xAppleDRIQueryDirectRenderingCapableReply), + (char *) &rep); return Success; } static int -ProcAppleDRIAuthConnection( - register ClientPtr client -) +ProcAppleDRIAuthConnection(register ClientPtr client) { xAppleDRIAuthConnectionReply rep; - + REQUEST(xAppleDRIAuthConnectionReq); REQUEST_SIZE_MATCH(xAppleDRIAuthConnectionReq); @@ -161,25 +152,23 @@ ProcAppleDRIAuthConnection( rep.sequenceNumber = client->sequence; rep.authenticated = 1; - if (!DRIAuthConnection( screenInfo.screens[stuff->screen], stuff->magic)) { - ErrorF("Failed to authenticate %u\n", (unsigned int)stuff->magic); + if (!DRIAuthConnection(screenInfo.screens[stuff->screen], stuff->magic)) { + ErrorF("Failed to authenticate %u\n", (unsigned int) stuff->magic); rep.authenticated = 0; } if (client->swapped) { swaps(&rep.sequenceNumber); swapl(&rep.length); - swapl(&rep.authenticated); /* Yes, this is a CARD32 ... sigh */ + swapl(&rep.authenticated); /* Yes, this is a CARD32 ... sigh */ } - WriteToClient(client, sizeof(xAppleDRIAuthConnectionReply), (char *)&rep); + WriteToClient(client, sizeof(xAppleDRIAuthConnectionReply), (char *) &rep); return Success; } -static void surface_notify( - void *_arg, - void *data -) +static void +surface_notify(void *_arg, void *data) { DRISurfaceNotifyArg *arg = _arg; int client_index = (int) x_cvt_vptr_to_uint(data); @@ -192,13 +181,11 @@ static void surface_notify( se.kind = arg->kind; se.arg = arg->id; se.time = currentTime.milliseconds; - WriteEventsToClient (clients[client_index], 1, (xEvent *) &se); + WriteEventsToClient(clients[client_index], 1, (xEvent *) &se); } static int -ProcAppleDRICreateSurface( - ClientPtr client -) +ProcAppleDRICreateSurface(ClientPtr client) { xAppleDRICreateSurfaceReply rep; DrawablePtr pDrawable; @@ -213,17 +200,16 @@ ProcAppleDRICreateSurface( rep.sequenceNumber = client->sequence; rc = dixLookupDrawable(&pDrawable, stuff->drawable, client, 0, - DixReadAccess); + DixReadAccess); if (rc != Success) - return rc; + return rc; rep.key_0 = rep.key_1 = rep.uid = 0; - if (!DRICreateSurface( screenInfo.screens[stuff->screen], - (Drawable)stuff->drawable, pDrawable, - stuff->client_id, &sid, key, - surface_notify, - x_cvt_uint_to_vptr(client->index))) { + if (!DRICreateSurface(screenInfo.screens[stuff->screen], + (Drawable) stuff->drawable, pDrawable, + stuff->client_id, &sid, key, + surface_notify, x_cvt_uint_to_vptr(client->index))) { return BadValue; } @@ -239,28 +225,27 @@ ProcAppleDRICreateSurface( swapl(&rep.uid); } - WriteToClient(client, sizeof(xAppleDRICreateSurfaceReply), (char *)&rep); + WriteToClient(client, sizeof(xAppleDRICreateSurfaceReply), (char *) &rep); return Success; } static int -ProcAppleDRIDestroySurface( - register ClientPtr client -) +ProcAppleDRIDestroySurface(register ClientPtr client) { int rc; + REQUEST(xAppleDRIDestroySurfaceReq); DrawablePtr pDrawable; + REQUEST_SIZE_MATCH(xAppleDRIDestroySurfaceReq); rc = dixLookupDrawable(&pDrawable, stuff->drawable, client, 0, - DixReadAccess); + DixReadAccess); if (rc != Success) - return rc; + return rc; - if (!DRIDestroySurface( screenInfo.screens[stuff->screen], - (Drawable)stuff->drawable, - pDrawable, NULL, NULL)) { + if (!DRIDestroySurface(screenInfo.screens[stuff->screen], + (Drawable) stuff->drawable, pDrawable, NULL, NULL)) { return BadValue; } @@ -283,23 +268,21 @@ ProcAppleDRICreatePixmap(ClientPtr client) rc = dixLookupDrawable(&pDrawable, stuff->drawable, client, 0, DixReadAccess); - if(rc != Success) + if (rc != Success) return rc; - - if(!DRICreatePixmap(screenInfo.screens[stuff->screen], - (Drawable)stuff->drawable, - pDrawable, - path, PATH_MAX)) { + + if (!DRICreatePixmap(screenInfo.screens[stuff->screen], + (Drawable) stuff->drawable, + pDrawable, path, PATH_MAX)) { + return BadValue; + } + + if (!DRIGetPixmapData(pDrawable, &width, &height, &pitch, &bpp, &ptr)) { return BadValue; } - if(!DRIGetPixmapData(pDrawable, &width, &height, - &pitch, &bpp, &ptr)) { - return BadValue; - } - rep.stringLength = strlen(path) + 1; - + rep.type = X_Reply; rep.length = bytes_to_int32(rep.stringLength); rep.sequenceNumber = client->sequence; @@ -309,9 +292,9 @@ ProcAppleDRICreatePixmap(ClientPtr client) rep.bpp = bpp; rep.size = pitch * height; - if(sizeof(rep) != sz_xAppleDRICreatePixmapReply) - ErrorF("error sizeof(rep) is %zu\n", sizeof(rep)); - + if (sizeof(rep) != sz_xAppleDRICreatePixmapReply) + ErrorF("error sizeof(rep) is %zu\n", sizeof(rep)); + if (client->swapped) { swaps(&rep.sequenceNumber); swapl(&rep.length); @@ -334,15 +317,16 @@ ProcAppleDRIDestroyPixmap(ClientPtr client) { DrawablePtr pDrawable; int rc; + REQUEST(xAppleDRIDestroyPixmapReq); REQUEST_SIZE_MATCH(xAppleDRIDestroyPixmapReq); rc = dixLookupDrawable(&pDrawable, stuff->drawable, client, 0, - DixReadAccess); + DixReadAccess); + + if (rc != Success) + return rc; - if(rc != Success) - return rc; - DRIDestroyPixmap(pDrawable); return Success; @@ -351,14 +335,11 @@ ProcAppleDRIDestroyPixmap(ClientPtr client) /* dispatch */ static int -ProcAppleDRIDispatch ( - register ClientPtr client -) +ProcAppleDRIDispatch(register ClientPtr client) { REQUEST(xReq); - switch (stuff->data) - { + switch (stuff->data) { case X_AppleDRIQueryVersion: return ProcAppleDRIQueryVersion(client); case X_AppleDRIQueryDirectRenderingCapable: @@ -368,8 +349,7 @@ ProcAppleDRIDispatch ( if (!LocalClient(client)) return DRIErrorBase + AppleDRIClientNotLocal; - switch (stuff->data) - { + switch (stuff->data) { case X_AppleDRIAuthConnection: return ProcAppleDRIAuthConnection(client); case X_AppleDRICreateSurface: @@ -377,9 +357,9 @@ ProcAppleDRIDispatch ( case X_AppleDRIDestroySurface: return ProcAppleDRIDestroySurface(client); case X_AppleDRICreatePixmap: - return ProcAppleDRICreatePixmap(client); + return ProcAppleDRICreatePixmap(client); case X_AppleDRIDestroyPixmap: - return ProcAppleDRIDestroyPixmap(client); + return ProcAppleDRIDestroyPixmap(client); default: return BadRequest; @@ -387,22 +367,17 @@ ProcAppleDRIDispatch ( } static void -SNotifyEvent( - xAppleDRINotifyEvent *from, - xAppleDRINotifyEvent *to -) +SNotifyEvent(xAppleDRINotifyEvent * from, xAppleDRINotifyEvent * to) { to->type = from->type; to->kind = from->kind; - cpswaps (from->sequenceNumber, to->sequenceNumber); - cpswapl (from->time, to->time); - cpswapl (from->arg, to->arg); + cpswaps(from->sequenceNumber, to->sequenceNumber); + cpswapl(from->time, to->time); + cpswapl(from->arg, to->arg); } static int -SProcAppleDRIQueryVersion( - register ClientPtr client -) +SProcAppleDRIQueryVersion(register ClientPtr client) { REQUEST(xAppleDRIQueryVersionReq); swaps(&stuff->length); @@ -410,9 +385,7 @@ SProcAppleDRIQueryVersion( } static int -SProcAppleDRIQueryDirectRenderingCapable( - register ClientPtr client -) +SProcAppleDRIQueryDirectRenderingCapable(register ClientPtr client) { REQUEST(xAppleDRIQueryDirectRenderingCapableReq); swaps(&stuff->length); @@ -421,9 +394,7 @@ SProcAppleDRIQueryDirectRenderingCapable( } static int -SProcAppleDRIAuthConnection( - register ClientPtr client -) +SProcAppleDRIAuthConnection(register ClientPtr client) { REQUEST(xAppleDRIAuthConnectionReq); swaps(&stuff->length); @@ -433,9 +404,7 @@ SProcAppleDRIAuthConnection( } static int -SProcAppleDRICreateSurface( - register ClientPtr client -) +SProcAppleDRICreateSurface(register ClientPtr client) { REQUEST(xAppleDRICreateSurfaceReq); swaps(&stuff->length); @@ -446,9 +415,7 @@ SProcAppleDRICreateSurface( } static int -SProcAppleDRIDestroySurface( - register ClientPtr client -) +SProcAppleDRIDestroySurface(register ClientPtr client) { REQUEST(xAppleDRIDestroySurfaceReq); swaps(&stuff->length); @@ -458,9 +425,7 @@ SProcAppleDRIDestroySurface( } static int -SProcAppleDRICreatePixmap( - register ClientPtr client -) +SProcAppleDRICreatePixmap(register ClientPtr client) { REQUEST(xAppleDRICreatePixmapReq); swaps(&stuff->length); @@ -470,9 +435,7 @@ SProcAppleDRICreatePixmap( } static int -SProcAppleDRIDestroyPixmap( - register ClientPtr client -) +SProcAppleDRIDestroyPixmap(register ClientPtr client) { REQUEST(xAppleDRIDestroyPixmapReq); swaps(&stuff->length); @@ -481,14 +444,11 @@ SProcAppleDRIDestroyPixmap( } static int -SProcAppleDRIDispatch ( - register ClientPtr client -) +SProcAppleDRIDispatch(register ClientPtr client) { REQUEST(xReq); - switch (stuff->data) - { + switch (stuff->data) { case X_AppleDRIQueryVersion: return SProcAppleDRIQueryVersion(client); case X_AppleDRIQueryDirectRenderingCapable: @@ -498,8 +458,7 @@ SProcAppleDRIDispatch ( if (!LocalClient(client)) return DRIErrorBase + AppleDRIClientNotLocal; - switch (stuff->data) - { + switch (stuff->data) { case X_AppleDRIAuthConnection: return SProcAppleDRIAuthConnection(client); case X_AppleDRICreateSurface: @@ -507,9 +466,9 @@ SProcAppleDRIDispatch ( case X_AppleDRIDestroySurface: return SProcAppleDRIDestroySurface(client); case X_AppleDRICreatePixmap: - return SProcAppleDRICreatePixmap(client); + return SProcAppleDRICreatePixmap(client); case X_AppleDRIDestroyPixmap: - return SProcAppleDRIDestroyPixmap(client); + return SProcAppleDRIDestroyPixmap(client); default: return BadRequest; @@ -519,7 +478,7 @@ SProcAppleDRIDispatch ( void AppleDRIExtensionInit(void) { - ExtensionEntry* extEntry; + ExtensionEntry *extEntry; if (DRIExtensionInit() && (extEntry = AddExtension(APPLEDRINAME, @@ -527,13 +486,13 @@ AppleDRIExtensionInit(void) AppleDRINumberErrors, ProcAppleDRIDispatch, SProcAppleDRIDispatch, - AppleDRIResetProc, - StandardMinorOpcode))) { + AppleDRIResetProc, StandardMinorOpcode))) { size_t i; - DRIReqCode = (unsigned char)extEntry->base; + + DRIReqCode = (unsigned char) extEntry->base; DRIErrorBase = extEntry->errorBase; DRIEventBase = extEntry->eventBase; - for (i=0; i < AppleDRINumberEvents; i++) + for (i = 0; i < AppleDRINumberEvents; i++) EventSwapVector[DRIEventBase + i] = (EventSwapPtr) SNotifyEvent; } } diff --git a/xorg-server/hw/xquartz/xpr/appledristr.h b/xorg-server/hw/xquartz/xpr/appledristr.h index b5ffe5b46..131a699d9 100644 --- a/xorg-server/hw/xquartz/xpr/appledristr.h +++ b/xorg-server/hw/xquartz/xpr/appledristr.h @@ -46,207 +46,200 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #define APPLE_DRI_MINOR_VERSION 0 #define APPLE_DRI_PATCH_VERSION 0 -typedef struct _AppleDRIQueryVersion -{ - CARD8 reqType; /* always DRIReqCode */ - CARD8 driReqType; /* always X_DRIQueryVersion */ - CARD16 length B16; +typedef struct _AppleDRIQueryVersion { + CARD8 reqType; /* always DRIReqCode */ + CARD8 driReqType; /* always X_DRIQueryVersion */ + CARD16 length B16; } xAppleDRIQueryVersionReq; + #define sz_xAppleDRIQueryVersionReq 4 -typedef struct -{ - BYTE type; /* X_Reply */ - BOOL pad1; - CARD16 sequenceNumber B16; - CARD32 length B32; - CARD16 majorVersion B16; /* major version of DRI protocol */ - CARD16 minorVersion B16; /* minor version of DRI protocol */ - CARD32 patchVersion B32; /* patch version of DRI protocol */ - CARD32 pad3 B32; - CARD32 pad4 B32; - CARD32 pad5 B32; - CARD32 pad6 B32; +typedef struct { + BYTE type; /* X_Reply */ + BOOL pad1; + CARD16 sequenceNumber B16; + CARD32 length B32; + CARD16 majorVersion B16; /* major version of DRI protocol */ + CARD16 minorVersion B16; /* minor version of DRI protocol */ + CARD32 patchVersion B32; /* patch version of DRI protocol */ + CARD32 pad3 B32; + CARD32 pad4 B32; + CARD32 pad5 B32; + CARD32 pad6 B32; } xAppleDRIQueryVersionReply; + #define sz_xAppleDRIQueryVersionReply 32 -typedef struct _AppleDRIQueryDirectRenderingCapable -{ - CARD8 reqType; /* always DRIReqCode */ - CARD8 driReqType; /* X_DRIQueryDirectRenderingCapable */ - CARD16 length B16; - CARD32 screen B32; +typedef struct _AppleDRIQueryDirectRenderingCapable { + CARD8 reqType; /* always DRIReqCode */ + CARD8 driReqType; /* X_DRIQueryDirectRenderingCapable */ + CARD16 length B16; + CARD32 screen B32; } xAppleDRIQueryDirectRenderingCapableReq; + #define sz_xAppleDRIQueryDirectRenderingCapableReq 8 -typedef struct -{ - BYTE type; /* X_Reply */ - BOOL pad1; - CARD16 sequenceNumber B16; - CARD32 length B32; - BOOL isCapable; - BOOL pad2; - BOOL pad3; - BOOL pad4; - CARD32 pad5 B32; - CARD32 pad6 B32; - CARD32 pad7 B32; - CARD32 pad8 B32; - CARD32 pad9 B32; +typedef struct { + BYTE type; /* X_Reply */ + BOOL pad1; + CARD16 sequenceNumber B16; + CARD32 length B32; + BOOL isCapable; + BOOL pad2; + BOOL pad3; + BOOL pad4; + CARD32 pad5 B32; + CARD32 pad6 B32; + CARD32 pad7 B32; + CARD32 pad8 B32; + CARD32 pad9 B32; } xAppleDRIQueryDirectRenderingCapableReply; + #define sz_xAppleDRIQueryDirectRenderingCapableReply 32 -typedef struct _AppleDRIAuthConnection -{ - CARD8 reqType; /* always DRIReqCode */ - CARD8 driReqType; /* always X_DRICloseConnection */ - CARD16 length B16; - CARD32 screen B32; - CARD32 magic B32; +typedef struct _AppleDRIAuthConnection { + CARD8 reqType; /* always DRIReqCode */ + CARD8 driReqType; /* always X_DRICloseConnection */ + CARD16 length B16; + CARD32 screen B32; + CARD32 magic B32; } xAppleDRIAuthConnectionReq; + #define sz_xAppleDRIAuthConnectionReq 12 -typedef struct -{ - BYTE type; - BOOL pad1; - CARD16 sequenceNumber B16; - CARD32 length B32; - CARD32 authenticated B32; - CARD32 pad2 B32; - CARD32 pad3 B32; - CARD32 pad4 B32; - CARD32 pad5 B32; - CARD32 pad6 B32; +typedef struct { + BYTE type; + BOOL pad1; + CARD16 sequenceNumber B16; + CARD32 length B32; + CARD32 authenticated B32; + CARD32 pad2 B32; + CARD32 pad3 B32; + CARD32 pad4 B32; + CARD32 pad5 B32; + CARD32 pad6 B32; } xAppleDRIAuthConnectionReply; + #define zx_xAppleDRIAuthConnectionReply 32 -typedef struct _AppleDRICreateSurface -{ - CARD8 reqType; /* always DRIReqCode */ - CARD8 driReqType; /* always X_DRICreateSurface */ - CARD16 length B16; - CARD32 screen B32; - CARD32 drawable B32; - CARD32 client_id B32; +typedef struct _AppleDRICreateSurface { + CARD8 reqType; /* always DRIReqCode */ + CARD8 driReqType; /* always X_DRICreateSurface */ + CARD16 length B16; + CARD32 screen B32; + CARD32 drawable B32; + CARD32 client_id B32; } xAppleDRICreateSurfaceReq; + #define sz_xAppleDRICreateSurfaceReq 16 -typedef struct -{ - BYTE type; /* X_Reply */ - BOOL pad1; - CARD16 sequenceNumber B16; - CARD32 length B32; - CARD32 key_0 B32; - CARD32 key_1 B32; - CARD32 uid B32; - CARD32 pad4 B32; - CARD32 pad5 B32; - CARD32 pad6 B32; +typedef struct { + BYTE type; /* X_Reply */ + BOOL pad1; + CARD16 sequenceNumber B16; + CARD32 length B32; + CARD32 key_0 B32; + CARD32 key_1 B32; + CARD32 uid B32; + CARD32 pad4 B32; + CARD32 pad5 B32; + CARD32 pad6 B32; } xAppleDRICreateSurfaceReply; + #define sz_xAppleDRICreateSurfaceReply 32 -typedef struct _AppleDRIDestroySurface -{ - CARD8 reqType; /* always DRIReqCode */ - CARD8 driReqType; /* always X_DRIDestroySurface */ - CARD16 length B16; - CARD32 screen B32; - CARD32 drawable B32; +typedef struct _AppleDRIDestroySurface { + CARD8 reqType; /* always DRIReqCode */ + CARD8 driReqType; /* always X_DRIDestroySurface */ + CARD16 length B16; + CARD32 screen B32; + CARD32 drawable B32; } xAppleDRIDestroySurfaceReq; + #define sz_xAppleDRIDestroySurfaceReq 12 -typedef struct _AppleDRINotify -{ - BYTE type; /* always eventBase + event type */ - BYTE kind; - CARD16 sequenceNumber B16; - CARD32 time B32; /* time of change */ - CARD32 pad1 B32; - CARD32 arg B32; - CARD32 pad3 B32; - CARD32 pad4 B32; - CARD32 pad5 B32; - CARD32 pad6 B32; +typedef struct _AppleDRINotify { + BYTE type; /* always eventBase + event type */ + BYTE kind; + CARD16 sequenceNumber B16; + CARD32 time B32; /* time of change */ + CARD32 pad1 B32; + CARD32 arg B32; + CARD32 pad3 B32; + CARD32 pad4 B32; + CARD32 pad5 B32; + CARD32 pad6 B32; } xAppleDRINotifyEvent; -#define sz_xAppleDRINotifyEvent 32 +#define sz_xAppleDRINotifyEvent 32 -typedef struct -{ - CARD8 reqType; - CARD8 driReqType; - CARD16 length B16; - CARD32 screen B32; - CARD32 drawable B32; - BOOL doubleSwap; - CARD8 pad1, pad2, pad3; +typedef struct { + CARD8 reqType; + CARD8 driReqType; + CARD16 length B16; + CARD32 screen B32; + CARD32 drawable B32; + BOOL doubleSwap; + CARD8 pad1, pad2, pad3; } xAppleDRICreateSharedBufferReq; #define sz_xAppleDRICreateSharedBufferReq 16 -typedef struct -{ - BYTE type; - BYTE data1; - CARD16 sequenceNumber B16; - CARD32 length B32; - CARD32 stringLength B32; /* 0 on error */ - CARD32 width B32; - CARD32 height B32; - CARD32 pad1 B32; - CARD32 pad2 B32; - CARD32 pad3 B32; +typedef struct { + BYTE type; + BYTE data1; + CARD16 sequenceNumber B16; + CARD32 length B32; + CARD32 stringLength B32; /* 0 on error */ + CARD32 width B32; + CARD32 height B32; + CARD32 pad1 B32; + CARD32 pad2 B32; + CARD32 pad3 B32; } xAppleDRICreateSharedBufferReply; #define sz_xAppleDRICreateSharedBufferReply 32 -typedef struct -{ - CARD8 reqType; - CARD8 driReqType; - CARD16 length B16; - CARD32 screen B32; - CARD32 drawable B32; +typedef struct { + CARD8 reqType; + CARD8 driReqType; + CARD16 length B16; + CARD32 screen B32; + CARD32 drawable B32; } xAppleDRISwapBuffersReq; #define sz_xAppleDRISwapBuffersReq 12 -typedef struct -{ - CARD8 reqType; /*1 */ - CARD8 driReqType; /*2 */ - CARD16 length B16; /*4 */ - CARD32 screen B32; /*8 */ - CARD32 drawable B32; /*12 */ +typedef struct { + CARD8 reqType; /*1 */ + CARD8 driReqType; /*2 */ + CARD16 length B16; /*4 */ + CARD32 screen B32; /*8 */ + CARD32 drawable B32; /*12 */ } xAppleDRICreatePixmapReq; #define sz_xAppleDRICreatePixmapReq 12 -typedef struct -{ - BYTE type; /*1 */ - BOOL pad1; /*2 */ - CARD16 sequenceNumber B16; /*4 */ - CARD32 length B32; /*8 */ - CARD32 width B32; /*12 */ - CARD32 height B32; /*16 */ - CARD32 pitch B32; /*20 */ - CARD32 bpp B32; /*24 */ - CARD32 size B32; /*28 */ - CARD32 stringLength B32; /*32 */ +typedef struct { + BYTE type; /*1 */ + BOOL pad1; /*2 */ + CARD16 sequenceNumber B16; /*4 */ + CARD32 length B32; /*8 */ + CARD32 width B32; /*12 */ + CARD32 height B32; /*16 */ + CARD32 pitch B32; /*20 */ + CARD32 bpp B32; /*24 */ + CARD32 size B32; /*28 */ + CARD32 stringLength B32; /*32 */ } xAppleDRICreatePixmapReply; #define sz_xAppleDRICreatePixmapReply 32 -typedef struct -{ - CARD8 reqType; /*1 */ - CARD8 driReqType; /*2 */ - CARD16 length B16; /*4 */ - CARD32 drawable B32; /*8 */ +typedef struct { + CARD8 reqType; /*1 */ + CARD8 driReqType; /*2 */ + CARD16 length B16; /*4 */ + CARD32 drawable B32; /*8 */ } xAppleDRIDestroyPixmapReq; #define sz_xAppleDRIDestroyPixmapReq 8 @@ -255,12 +248,12 @@ typedef struct void AppleDRISendEvent( #if NeedFunctionPrototypes - int /* type */ , - unsigned int /* mask */ , - int /* which */ , - int /* arg */ + int /* type */ , + unsigned int /* mask */ , + int /* which */ , + int /* arg */ #endif - ); + ); -#endif /* _APPLEDRI_SERVER_ */ -#endif /* _APPLEDRISTR_H_ */ +#endif /* _APPLEDRI_SERVER_ */ +#endif /* _APPLEDRISTR_H_ */ diff --git a/xorg-server/hw/xquartz/xpr/dri.c b/xorg-server/hw/xquartz/xpr/dri.c index a58f2c76d..0ce1d0771 100644 --- a/xorg-server/hw/xquartz/xpr/dri.c +++ b/xorg-server/hw/xquartz/xpr/dri.c @@ -75,12 +75,16 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #include static DevPrivateKeyRec DRIScreenPrivKeyRec; + #define DRIScreenPrivKey (&DRIScreenPrivKeyRec) static DevPrivateKeyRec DRIWindowPrivKeyRec; + #define DRIWindowPrivKey (&DRIWindowPrivKeyRec) static DevPrivateKeyRec DRIPixmapPrivKeyRec; + #define DRIPixmapPrivKey (&DRIPixmapPrivKeyRec) static DevPrivateKeyRec DRIPixmapBufferPrivKeyRec; + #define DRIPixmapBufferPrivKey (&DRIPixmapBufferPrivKeyRec) static RESTYPE DRIDrawablePrivResType; @@ -96,29 +100,29 @@ typedef struct { int width; int height; char shmPath[PATH_MAX]; - int fd; /* From shm_open (for now) */ - size_t length; /* length of buffer */ - void *buffer; + int fd; /* From shm_open (for now) */ + size_t length; /* length of buffer */ + void *buffer; } DRIPixmapBuffer, *DRIPixmapBufferPtr; Bool DRIScreenInit(ScreenPtr pScreen) { - DRIScreenPrivPtr pDRIPriv; - int i; + DRIScreenPrivPtr pDRIPriv; + int i; if (!dixRegisterPrivateKey(&DRIScreenPrivKeyRec, PRIVATE_SCREEN, 0)) - return FALSE; + return FALSE; if (!dixRegisterPrivateKey(&DRIWindowPrivKeyRec, PRIVATE_WINDOW, 0)) - return FALSE; + return FALSE; if (!dixRegisterPrivateKey(&DRIPixmapPrivKeyRec, PRIVATE_PIXMAP, 0)) - return FALSE; + return FALSE; if (!dixRegisterPrivateKey(&DRIPixmapBufferPrivKeyRec, PRIVATE_PIXMAP, 0)) - return FALSE; + return FALSE; pDRIPriv = (DRIScreenPrivPtr) calloc(1, sizeof(DRIScreenPrivRec)); if (!pDRIPriv) { - dixSetPrivate(&pScreen->devPrivates, DRIScreenPrivKey, NULL); + dixSetPrivate(&pScreen->devPrivates, DRIScreenPrivKey, NULL); return FALSE; } @@ -137,7 +141,7 @@ DRIScreenInit(ScreenPtr pScreen) Bool DRIFinishScreenInit(ScreenPtr pScreen) { - DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen); + DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen); /* Wrap DRI support */ pDRIPriv->wrap.ValidateTree = pScreen->ValidateTree; @@ -167,7 +171,7 @@ DRICloseScreen(ScreenPtr pScreen) if (pDRIPriv && pDRIPriv->directRenderingSupport) { free(pDRIPriv); - dixSetPrivate(&pScreen->devPrivates, DRIScreenPrivKey, NULL); + dixSetPrivate(&pScreen->devPrivates, DRIScreenPrivKey, NULL); } } @@ -175,7 +179,7 @@ Bool DRIExtensionInit(void) { DRIDrawablePrivResType = CreateNewResourceType(DRIDrawablePrivDelete, - "DRIDrawable"); + "DRIDrawable"); return DRIDrawablePrivResType != 0; } @@ -193,7 +197,7 @@ DRIReset(void) } Bool -DRIQueryDirectRenderingCapable(ScreenPtr pScreen, Bool* isCapable) +DRIQueryDirectRenderingCapable(ScreenPtr pScreen, Bool *isCapable) { DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen); @@ -213,7 +217,8 @@ DRIAuthConnection(ScreenPtr pScreen, unsigned int magic) DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen); - if (drmAuthMagic(pDRIPriv->drmFD, magic)) return FALSE; + if (drmAuthMagic(pDRIPriv->drmFD, magic)) + return FALSE; #endif return TRUE; } @@ -246,12 +251,13 @@ DRIUpdateSurface(DRIDrawablePrivPtr pDRIDrawablePriv, DrawablePtr pDraw) wc.shape_nrects = RegionNumRects(&pWin->clipList); wc.shape_rects = RegionRects(&pWin->clipList); - wc.shape_tx = - (pTopWin->drawable.x - pTopWin->borderWidth); - wc.shape_ty = - (pTopWin->drawable.y - pTopWin->borderWidth); + wc.shape_tx = -(pTopWin->drawable.x - pTopWin->borderWidth); + wc.shape_ty = -(pTopWin->drawable.y - pTopWin->borderWidth); flags |= XP_BOUNDS | XP_SHAPE; - } else if (pDraw->type == DRAWABLE_PIXMAP) { + } + else if (pDraw->type == DRAWABLE_PIXMAP) { wc.x = 0; wc.y = 0; wc.width = pDraw->width; @@ -265,7 +271,8 @@ DRIUpdateSurface(DRIDrawablePrivPtr pDRIDrawablePriv, DrawablePtr pDraw) /* Return NULL if an error occurs. */ static DRIDrawablePrivPtr -CreateSurfaceForWindow(ScreenPtr pScreen, WindowPtr pWin, xp_window_id *widPtr) { +CreateSurfaceForWindow(ScreenPtr pScreen, WindowPtr pWin, xp_window_id * widPtr) +{ DRIDrawablePrivPtr pDRIDrawablePriv; xp_window_id wid = 0; @@ -274,50 +281,49 @@ CreateSurfaceForWindow(ScreenPtr pScreen, WindowPtr pWin, xp_window_id *widPtr) pDRIDrawablePriv = DRI_DRAWABLE_PRIV_FROM_WINDOW(pWin); if (pDRIDrawablePriv == NULL) { - xp_error err; - xp_window_changes wc; - - /* allocate a DRI Window Private record */ - if (!(pDRIDrawablePriv = malloc(sizeof(*pDRIDrawablePriv)))) { - return NULL; - } - - pDRIDrawablePriv->pDraw = (DrawablePtr)pWin; - pDRIDrawablePriv->pScreen = pScreen; - pDRIDrawablePriv->refCount = 0; - pDRIDrawablePriv->drawableIndex = -1; - pDRIDrawablePriv->notifiers = NULL; - - /* find the physical window */ - wid = x_cvt_vptr_to_uint(RootlessFrameForWindow(pWin, TRUE)); - - if (wid == 0) { - free(pDRIDrawablePriv); - return NULL; - } - - /* allocate the physical surface */ - err = xp_create_surface(wid, &pDRIDrawablePriv->sid); - - if (err != Success) { - free(pDRIDrawablePriv); - return NULL; - } - - /* Make it visible */ - wc.stack_mode = XP_MAPPED_ABOVE; - wc.sibling = 0; - err = xp_configure_surface(pDRIDrawablePriv->sid, XP_STACKING, &wc); - - if (err != Success) { - xp_destroy_surface(pDRIDrawablePriv->sid); - free(pDRIDrawablePriv); - return NULL; - } - - /* save private off of preallocated index */ - dixSetPrivate(&pWin->devPrivates, DRIWindowPrivKey, - pDRIDrawablePriv); + xp_error err; + xp_window_changes wc; + + /* allocate a DRI Window Private record */ + if (!(pDRIDrawablePriv = malloc(sizeof(*pDRIDrawablePriv)))) { + return NULL; + } + + pDRIDrawablePriv->pDraw = (DrawablePtr) pWin; + pDRIDrawablePriv->pScreen = pScreen; + pDRIDrawablePriv->refCount = 0; + pDRIDrawablePriv->drawableIndex = -1; + pDRIDrawablePriv->notifiers = NULL; + + /* find the physical window */ + wid = x_cvt_vptr_to_uint(RootlessFrameForWindow(pWin, TRUE)); + + if (wid == 0) { + free(pDRIDrawablePriv); + return NULL; + } + + /* allocate the physical surface */ + err = xp_create_surface(wid, &pDRIDrawablePriv->sid); + + if (err != Success) { + free(pDRIDrawablePriv); + return NULL; + } + + /* Make it visible */ + wc.stack_mode = XP_MAPPED_ABOVE; + wc.sibling = 0; + err = xp_configure_surface(pDRIDrawablePriv->sid, XP_STACKING, &wc); + + if (err != Success) { + xp_destroy_surface(pDRIDrawablePriv->sid); + free(pDRIDrawablePriv); + return NULL; + } + + /* save private off of preallocated index */ + dixSetPrivate(&pWin->devPrivates, DRIWindowPrivKey, pDRIDrawablePriv); } *widPtr = wid; @@ -327,111 +333,109 @@ CreateSurfaceForWindow(ScreenPtr pScreen, WindowPtr pWin, xp_window_id *widPtr) /* Return NULL if an error occurs. */ static DRIDrawablePrivPtr -CreateSurfaceForPixmap(ScreenPtr pScreen, PixmapPtr pPix) { +CreateSurfaceForPixmap(ScreenPtr pScreen, PixmapPtr pPix) +{ DRIDrawablePrivPtr pDRIDrawablePriv; - + pDRIDrawablePriv = DRI_DRAWABLE_PRIV_FROM_PIXMAP(pPix); if (pDRIDrawablePriv == NULL) { - xp_error err; - - /* allocate a DRI Window Private record */ - if (!(pDRIDrawablePriv = calloc(1, sizeof(*pDRIDrawablePriv)))) { - return NULL; - } - - pDRIDrawablePriv->pDraw = (DrawablePtr)pPix; - pDRIDrawablePriv->pScreen = pScreen; - pDRIDrawablePriv->refCount = 0; - pDRIDrawablePriv->drawableIndex = -1; - pDRIDrawablePriv->notifiers = NULL; - - /* Passing a null window id to Xplugin in 10.3+ asks for - an accelerated offscreen surface. */ - - err = xp_create_surface(0, &pDRIDrawablePriv->sid); - if (err != Success) { - free(pDRIDrawablePriv); - return NULL; - } - - /* - * The DRIUpdateSurface will be called to resize the surface - * after this function, if the export is successful. - */ - - /* save private off of preallocated index */ - dixSetPrivate(&pPix->devPrivates, DRIPixmapPrivKey, - pDRIDrawablePriv); - } - + xp_error err; + + /* allocate a DRI Window Private record */ + if (!(pDRIDrawablePriv = calloc(1, sizeof(*pDRIDrawablePriv)))) { + return NULL; + } + + pDRIDrawablePriv->pDraw = (DrawablePtr) pPix; + pDRIDrawablePriv->pScreen = pScreen; + pDRIDrawablePriv->refCount = 0; + pDRIDrawablePriv->drawableIndex = -1; + pDRIDrawablePriv->notifiers = NULL; + + /* Passing a null window id to Xplugin in 10.3+ asks for + an accelerated offscreen surface. */ + + err = xp_create_surface(0, &pDRIDrawablePriv->sid); + if (err != Success) { + free(pDRIDrawablePriv); + return NULL; + } + + /* + * The DRIUpdateSurface will be called to resize the surface + * after this function, if the export is successful. + */ + + /* save private off of preallocated index */ + dixSetPrivate(&pPix->devPrivates, DRIPixmapPrivKey, pDRIDrawablePriv); + } + return pDRIDrawablePriv; } - Bool DRICreateSurface(ScreenPtr pScreen, Drawable id, DrawablePtr pDrawable, xp_client_id client_id, - xp_surface_id *surface_id, unsigned int ret_key[2], + xp_surface_id * surface_id, unsigned int ret_key[2], void (*notify) (void *arg, void *data), void *notify_data) { - DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen); - xp_window_id wid = 0; - DRIDrawablePrivPtr pDRIDrawablePriv; + DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen); + xp_window_id wid = 0; + DRIDrawablePrivPtr pDRIDrawablePriv; if (pDrawable->type == DRAWABLE_WINDOW) { - pDRIDrawablePriv = CreateSurfaceForWindow(pScreen, - (WindowPtr)pDrawable, &wid); + pDRIDrawablePriv = CreateSurfaceForWindow(pScreen, + (WindowPtr) pDrawable, &wid); - if(NULL == pDRIDrawablePriv) - return FALSE; /*error*/ + if (NULL == pDRIDrawablePriv) + return FALSE; /*error */ } #if MAC_OS_X_VERSION_MAX_ALLOWED >= 1030 else if (pDrawable->type == DRAWABLE_PIXMAP) { - pDRIDrawablePriv = CreateSurfaceForPixmap(pScreen, - (PixmapPtr)pDrawable); + pDRIDrawablePriv = CreateSurfaceForPixmap(pScreen, + (PixmapPtr) pDrawable); - if(NULL == pDRIDrawablePriv) - return FALSE; /*error*/ + if (NULL == pDRIDrawablePriv) + return FALSE; /*error */ } #endif else { - /* We handle GLXPbuffers in a different way (via CGL). */ + /* We handle GLXPbuffers in a different way (via CGL). */ return FALSE; } - - + /* Finish initialization of new surfaces */ if (pDRIDrawablePriv->refCount == 0) { - unsigned int key[2] = {0}; + unsigned int key[2] = { 0 }; xp_error err; /* try to give the client access to the surface */ if (client_id != 0) { - /* - * Xplugin accepts a 0 wid if the surface id is offscreen, such - * as for a pixmap. - */ - err = xp_export_surface(wid, pDRIDrawablePriv->sid, - client_id, key); + /* + * Xplugin accepts a 0 wid if the surface id is offscreen, such + * as for a pixmap. + */ + err = xp_export_surface(wid, pDRIDrawablePriv->sid, client_id, key); if (err != Success) { xp_destroy_surface(pDRIDrawablePriv->sid); free(pDRIDrawablePriv); - - /* - * Now set the dix privates to NULL that were previously set. - * This prevents reusing an invalid pointer. - */ - if(pDrawable->type == DRAWABLE_WINDOW) { - WindowPtr pWin = (WindowPtr)pDrawable; - - dixSetPrivate(&pWin->devPrivates, DRIWindowPrivKey, NULL); - } else if(pDrawable->type == DRAWABLE_PIXMAP) { - PixmapPtr pPix = (PixmapPtr)pDrawable; - - dixSetPrivate(&pPix->devPrivates, DRIPixmapPrivKey, NULL); - } - + + /* + * Now set the dix privates to NULL that were previously set. + * This prevents reusing an invalid pointer. + */ + if (pDrawable->type == DRAWABLE_WINDOW) { + WindowPtr pWin = (WindowPtr) pDrawable; + + dixSetPrivate(&pWin->devPrivates, DRIWindowPrivKey, NULL); + } + else if (pDrawable->type == DRAWABLE_PIXMAP) { + PixmapPtr pPix = (PixmapPtr) pDrawable; + + dixSetPrivate(&pPix->devPrivates, DRIPixmapPrivKey, NULL); + } + return FALSE; } } @@ -445,10 +449,11 @@ DRICreateSurface(ScreenPtr pScreen, Drawable id, if (surface_hash == NULL) surface_hash = x_hash_table_new(NULL, NULL, NULL, NULL); x_hash_table_insert(surface_hash, - x_cvt_uint_to_vptr(pDRIDrawablePriv->sid), pDRIDrawablePriv); + x_cvt_uint_to_vptr(pDRIDrawablePriv->sid), + pDRIDrawablePriv); /* track this in case this window is destroyed */ - AddResource(id, DRIDrawablePrivResType, (pointer)pDrawable); + AddResource(id, DRIDrawablePrivResType, (pointer) pDrawable); /* Initialize shape */ DRIUpdateSurface(pDRIDrawablePriv, pDrawable); @@ -475,38 +480,40 @@ Bool DRIDestroySurface(ScreenPtr pScreen, Drawable id, DrawablePtr pDrawable, void (*notify) (void *, void *), void *notify_data) { - DRIDrawablePrivPtr pDRIDrawablePriv; + DRIDrawablePrivPtr pDRIDrawablePriv; if (pDrawable->type == DRAWABLE_WINDOW) { - pDRIDrawablePriv = DRI_DRAWABLE_PRIV_FROM_WINDOW((WindowPtr)pDrawable); - } else if (pDrawable->type == DRAWABLE_PIXMAP) { - pDRIDrawablePriv = DRI_DRAWABLE_PRIV_FROM_PIXMAP((PixmapPtr)pDrawable); - } else { + pDRIDrawablePriv = DRI_DRAWABLE_PRIV_FROM_WINDOW((WindowPtr) pDrawable); + } + else if (pDrawable->type == DRAWABLE_PIXMAP) { + pDRIDrawablePriv = DRI_DRAWABLE_PRIV_FROM_PIXMAP((PixmapPtr) pDrawable); + } + else { return FALSE; } if (pDRIDrawablePriv != NULL) { - /* - * This doesn't seem to be used, because notify is NULL in all callers. - */ + /* + * This doesn't seem to be used, because notify is NULL in all callers. + */ if (notify != NULL) { - pDRIDrawablePriv->notifiers = x_hook_remove(pDRIDrawablePriv->notifiers, - notify, notify_data); + pDRIDrawablePriv->notifiers = + x_hook_remove(pDRIDrawablePriv->notifiers, notify, notify_data); } - --pDRIDrawablePriv->refCount; + --pDRIDrawablePriv->refCount; - /* - * Check if the drawable privates still have a reference to the - * surface. - */ + /* + * Check if the drawable privates still have a reference to the + * surface. + */ if (pDRIDrawablePriv->refCount <= 0) { /* - * This calls back to DRIDrawablePrivDelete which - * frees the private area and dispatches events, if needed. - */ + * This calls back to DRIDrawablePrivDelete which + * frees the private area and dispatches events, if needed. + */ FreeResourceByType(id, DRIDrawablePrivResType, FALSE); } } @@ -521,38 +528,38 @@ DRIDestroySurface(ScreenPtr pScreen, Drawable id, DrawablePtr pDrawable, Bool DRIDrawablePrivDelete(pointer pResource, XID id) { - DrawablePtr pDrawable = (DrawablePtr)pResource; - DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pDrawable->pScreen); - DRIDrawablePrivPtr pDRIDrawablePriv = NULL; - WindowPtr pWin = NULL; - PixmapPtr pPix = NULL; + DrawablePtr pDrawable = (DrawablePtr) pResource; + DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pDrawable->pScreen); + DRIDrawablePrivPtr pDRIDrawablePriv = NULL; + WindowPtr pWin = NULL; + PixmapPtr pPix = NULL; if (pDrawable->type == DRAWABLE_WINDOW) { - pWin = (WindowPtr)pDrawable; + pWin = (WindowPtr) pDrawable; pDRIDrawablePriv = DRI_DRAWABLE_PRIV_FROM_WINDOW(pWin); - } else if (pDrawable->type == DRAWABLE_PIXMAP) { - pPix = (PixmapPtr)pDrawable; + } + else if (pDrawable->type == DRAWABLE_PIXMAP) { + pPix = (PixmapPtr) pDrawable; pDRIDrawablePriv = DRI_DRAWABLE_PRIV_FROM_PIXMAP(pPix); } if (pDRIDrawablePriv == NULL) { - /* - * We reuse __func__ and the resource type for the GLXPixmap code. - * Attempt to free a pixmap buffer associated with the resource - * if possible. - */ - return DRIFreePixmapImp(pDrawable); - } - + /* + * We reuse __func__ and the resource type for the GLXPixmap code. + * Attempt to free a pixmap buffer associated with the resource + * if possible. + */ + return DRIFreePixmapImp(pDrawable); + } + if (pDRIDrawablePriv->drawableIndex != -1) { /* release drawable table entry */ pDRIPriv->DRIDrawables[pDRIDrawablePriv->drawableIndex] = NULL; } if (pDRIDrawablePriv->sid != 0) { - DRISurfaceNotify(pDRIDrawablePriv->sid, AppleDRISurfaceNotifyDestroyed); + DRISurfaceNotify(pDRIDrawablePriv->sid, AppleDRISurfaceNotifyDestroyed); } - if (pDRIDrawablePriv->notifiers != NULL) x_hook_free(pDRIDrawablePriv->notifiers); @@ -560,9 +567,10 @@ DRIDrawablePrivDelete(pointer pResource, XID id) free(pDRIDrawablePriv); if (pDrawable->type == DRAWABLE_WINDOW) { - dixSetPrivate(&pWin->devPrivates, DRIWindowPrivKey, NULL); - } else if (pDrawable->type == DRAWABLE_PIXMAP) { - dixSetPrivate(&pPix->devPrivates, DRIPixmapPrivKey, NULL); + dixSetPrivate(&pWin->devPrivates, DRIWindowPrivKey, NULL); + } + else if (pDrawable->type == DRAWABLE_PIXMAP) { + dixSetPrivate(&pPix->devPrivates, DRIPixmapPrivKey, NULL); } --pDRIPriv->nrWindows; @@ -583,7 +591,7 @@ DRIWindowExposures(WindowPtr pWin, RegionPtr prgn, RegionPtr bsreg) pScreen->WindowExposures = pDRIPriv->wrap.WindowExposures; - (*pScreen->WindowExposures)(pWin, prgn, bsreg); + (*pScreen->WindowExposures) (pWin, prgn, bsreg); pScreen->WindowExposures = DRIWindowExposures; } @@ -596,17 +604,17 @@ DRICopyWindow(WindowPtr pWin, DDXPointRec ptOldOrg, RegionPtr prgnSrc) DRIDrawablePrivPtr pDRIDrawablePriv; if (pDRIPriv->nrWindows > 0) { - pDRIDrawablePriv = DRI_DRAWABLE_PRIV_FROM_WINDOW(pWin); - if (pDRIDrawablePriv != NULL) { + pDRIDrawablePriv = DRI_DRAWABLE_PRIV_FROM_WINDOW(pWin); + if (pDRIDrawablePriv != NULL) { DRIUpdateSurface(pDRIDrawablePriv, &pWin->drawable); - } + } } /* unwrap */ pScreen->CopyWindow = pDRIPriv->wrap.CopyWindow; /* call lower layers */ - (*pScreen->CopyWindow)(pWin, ptOldOrg, prgnSrc); + (*pScreen->CopyWindow) (pWin, ptOldOrg, prgnSrc); /* rewrap */ pScreen->CopyWindow = DRICopyWindow; @@ -623,7 +631,7 @@ DRIValidateTree(WindowPtr pParent, WindowPtr pChild, VTKind kind) pScreen->ValidateTree = pDRIPriv->wrap.ValidateTree; /* call lower layers */ - returnValue = (*pScreen->ValidateTree)(pParent, pChild, kind); + returnValue = (*pScreen->ValidateTree) (pParent, pChild, kind); /* rewrap */ pScreen->ValidateTree = DRIValidateTree; @@ -639,7 +647,8 @@ DRIPostValidateTree(WindowPtr pParent, WindowPtr pChild, VTKind kind) if (pParent) { pScreen = pParent->drawable.pScreen; - } else { + } + else { pScreen = pChild->drawable.pScreen; } pDRIPriv = DRI_SCREEN_PRIV(pScreen); @@ -649,7 +658,7 @@ DRIPostValidateTree(WindowPtr pParent, WindowPtr pChild, VTKind kind) pScreen->PostValidateTree = pDRIPriv->wrap.PostValidateTree; /* call lower layers */ - (*pScreen->PostValidateTree)(pParent, pChild, kind); + (*pScreen->PostValidateTree) (pParent, pChild, kind); /* rewrap */ pScreen->PostValidateTree = DRIPostValidateTree; @@ -661,7 +670,7 @@ DRIClipNotify(WindowPtr pWin, int dx, int dy) { ScreenPtr pScreen = pWin->drawable.pScreen; DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen); - DRIDrawablePrivPtr pDRIDrawablePriv; + DRIDrawablePrivPtr pDRIDrawablePriv; if ((pDRIDrawablePriv = DRI_DRAWABLE_PRIV_FROM_WINDOW(pWin))) { DRIUpdateSurface(pDRIDrawablePriv, &pWin->drawable); @@ -670,7 +679,7 @@ DRIClipNotify(WindowPtr pWin, int dx, int dy) if (pDRIPriv->wrap.ClipNotify) { pScreen->ClipNotify = pDRIPriv->wrap.ClipNotify; - (*pScreen->ClipNotify)(pWin, dx, dy); + (*pScreen->ClipNotify) (pWin, dx, dy); pScreen->ClipNotify = DRIClipNotify; } @@ -687,9 +696,7 @@ DRIGetWrappedFuncs(ScreenPtr pScreen) } void -DRIQueryVersion(int *majorVersion, - int *minorVersion, - int *patchVersion) +DRIQueryVersion(int *majorVersion, int *minorVersion, int *patchVersion) { *majorVersion = APPLE_DRI_MAJOR_VERSION; *minorVersion = APPLE_DRI_MINOR_VERSION; @@ -700,7 +707,7 @@ DRIQueryVersion(int *majorVersion, * Note: this also cleans up the hash table in addition to notifying clients. * The sid/surface-id should not be used after this, because it will be * invalid. - */ + */ void DRISurfaceNotify(xp_surface_id id, int kind) { @@ -710,8 +717,7 @@ DRISurfaceNotify(xp_surface_id id, int kind) arg.id = id; arg.kind = kind; - if (surface_hash != NULL) - { + if (surface_hash != NULL) { pDRIDrawablePriv = x_hash_table_lookup(surface_hash, x_cvt_uint_to_vptr(id), NULL); } @@ -719,24 +725,22 @@ DRISurfaceNotify(xp_surface_id id, int kind) if (pDRIDrawablePriv == NULL) return; - if (kind == AppleDRISurfaceNotifyDestroyed) - { - x_hash_table_remove(surface_hash, x_cvt_uint_to_vptr(id)); + if (kind == AppleDRISurfaceNotifyDestroyed) { + x_hash_table_remove(surface_hash, x_cvt_uint_to_vptr(id)); } x_hook_run(pDRIDrawablePriv->notifiers, &arg); - if (kind == AppleDRISurfaceNotifyDestroyed) - { - xp_error error; - - error = xp_destroy_surface(pDRIDrawablePriv->sid); - - if(error) - ErrorF("%s: xp_destroy_surface failed: %d\n", __func__, error); - - /* Guard against reuse, even though we are freeing after this. */ - pDRIDrawablePriv->sid = 0; + if (kind == AppleDRISurfaceNotifyDestroyed) { + xp_error error; + + error = xp_destroy_surface(pDRIDrawablePriv->sid); + + if (error) + ErrorF("%s: xp_destroy_surface failed: %d\n", __func__, error); + + /* Guard against reuse, even though we are freeing after this. */ + pDRIDrawablePriv->sid = 0; FreeResourceByType(pDRIDrawablePriv->pDraw->id, DRIDrawablePrivResType, FALSE); @@ -747,137 +751,140 @@ DRISurfaceNotify(xp_surface_id id, int kind) * This creates a shared memory buffer for use with GLXPixmaps * and AppleSGLX. */ -Bool DRICreatePixmap(ScreenPtr pScreen, Drawable id, - DrawablePtr pDrawable, char *path, - size_t pathmax) +Bool +DRICreatePixmap(ScreenPtr pScreen, Drawable id, + DrawablePtr pDrawable, char *path, size_t pathmax) { DRIPixmapBufferPtr shared; PixmapPtr pPix; - - if(pDrawable->type != DRAWABLE_PIXMAP) - return FALSE; - pPix = (PixmapPtr)pDrawable; + if (pDrawable->type != DRAWABLE_PIXMAP) + return FALSE; + + pPix = (PixmapPtr) pDrawable; shared = malloc(sizeof(*shared)); - if(NULL == shared) { + if (NULL == shared) { FatalError("failed to allocate DRIPixmapBuffer in %s\n", __func__); } - + shared->pDrawable = pDrawable; shared->refCount = 1; - if(pDrawable->bitsPerPixel >= 24) { - shared->bytesPerPixel = 4; - } else if(pDrawable->bitsPerPixel <= 16) { - shared->bytesPerPixel = 2; + if (pDrawable->bitsPerPixel >= 24) { + shared->bytesPerPixel = 4; } - + else if (pDrawable->bitsPerPixel <= 16) { + shared->bytesPerPixel = 2; + } + shared->width = pDrawable->width; shared->height = pDrawable->height; - - if(-1 == snprintf(shared->shmPath, sizeof(shared->shmPath), - "%d_0x%lx", getpid(), - (unsigned long)id)) { + + if (-1 == snprintf(shared->shmPath, sizeof(shared->shmPath), + "%d_0x%lx", getpid(), (unsigned long) id)) { FatalError("buffer overflow in %s\n", __func__); } - - shared->fd = shm_open(shared->shmPath, - O_RDWR | O_EXCL | O_CREAT, + + shared->fd = shm_open(shared->shmPath, + O_RDWR | O_EXCL | O_CREAT, S_IRUSR | S_IWUSR | S_IROTH | S_IWOTH); - - if(-1 == shared->fd) { - free(shared); + + if (-1 == shared->fd) { + free(shared); return FALSE; - } - + } + shared->length = shared->width * shared->height * shared->bytesPerPixel; - - if(-1 == ftruncate(shared->fd, shared->length)) { - ErrorF("failed to ftruncate (extend) file."); - shm_unlink(shared->shmPath); - close(shared->fd); - free(shared); - return FALSE; + + if (-1 == ftruncate(shared->fd, shared->length)) { + ErrorF("failed to ftruncate (extend) file."); + shm_unlink(shared->shmPath); + close(shared->fd); + free(shared); + return FALSE; } shared->buffer = mmap(NULL, shared->length, PROT_READ | PROT_WRITE, MAP_FILE | MAP_SHARED, shared->fd, 0); - - if(MAP_FAILED == shared->buffer) { - ErrorF("failed to mmap shared memory."); - shm_unlink(shared->shmPath); - close(shared->fd); - free(shared); - return FALSE; - } - + + if (MAP_FAILED == shared->buffer) { + ErrorF("failed to mmap shared memory."); + shm_unlink(shared->shmPath); + close(shared->fd); + free(shared); + return FALSE; + } + strlcpy(path, shared->shmPath, pathmax); - + dixSetPrivate(&pPix->devPrivates, DRIPixmapBufferPrivKey, shared); - AddResource(id, DRIDrawablePrivResType, (pointer)pDrawable); + AddResource(id, DRIDrawablePrivResType, (pointer) pDrawable); return TRUE; } - -Bool DRIGetPixmapData(DrawablePtr pDrawable, int *width, int *height, - int *pitch, int *bpp, void **ptr) { +Bool +DRIGetPixmapData(DrawablePtr pDrawable, int *width, int *height, + int *pitch, int *bpp, void **ptr) +{ PixmapPtr pPix; DRIPixmapBufferPtr shared; - if(pDrawable->type != DRAWABLE_PIXMAP) - return FALSE; + if (pDrawable->type != DRAWABLE_PIXMAP) + return FALSE; - pPix = (PixmapPtr)pDrawable; + pPix = (PixmapPtr) pDrawable; shared = dixLookupPrivate(&pPix->devPrivates, DRIPixmapBufferPrivKey); - if(NULL == shared) - return FALSE; + if (NULL == shared) + return FALSE; assert(pDrawable->width == shared->width); assert(pDrawable->height == shared->height); - + *width = shared->width; *height = shared->height; *bpp = shared->bytesPerPixel; *pitch = shared->width * shared->bytesPerPixel; - *ptr = shared->buffer; + *ptr = shared->buffer; return TRUE; } static Bool -DRIFreePixmapImp(DrawablePtr pDrawable) { +DRIFreePixmapImp(DrawablePtr pDrawable) +{ DRIPixmapBufferPtr shared; PixmapPtr pPix; - if(pDrawable->type != DRAWABLE_PIXMAP) - return FALSE; + if (pDrawable->type != DRAWABLE_PIXMAP) + return FALSE; - pPix = (PixmapPtr)pDrawable; + pPix = (PixmapPtr) pDrawable; shared = dixLookupPrivate(&pPix->devPrivates, DRIPixmapBufferPrivKey); - if(NULL == shared) - return FALSE; + if (NULL == shared) + return FALSE; close(shared->fd); munmap(shared->buffer, shared->length); shm_unlink(shared->shmPath); free(shared); - dixSetPrivate(&pPix->devPrivates, DRIPixmapBufferPrivKey, (pointer)NULL); + dixSetPrivate(&pPix->devPrivates, DRIPixmapBufferPrivKey, (pointer) NULL); return TRUE; } -void -DRIDestroyPixmap(DrawablePtr pDrawable) { - if(DRIFreePixmapImp(pDrawable)) - FreeResourceByType(pDrawable->id, DRIDrawablePrivResType, FALSE); +void +DRIDestroyPixmap(DrawablePtr pDrawable) +{ + if (DRIFreePixmapImp(pDrawable)) + FreeResourceByType(pDrawable->id, DRIDrawablePrivResType, FALSE); } diff --git a/xorg-server/hw/xquartz/xpr/dri.h b/xorg-server/hw/xquartz/xpr/dri.h index 48fea3668..b4342617c 100644 --- a/xorg-server/hw/xquartz/xpr/dri.h +++ b/xorg-server/hw/xquartz/xpr/dri.h @@ -43,8 +43,7 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #include "appledri.h" #include -typedef void (*ClipNotifyPtr)( WindowPtr, int, int ); - +typedef void (*ClipNotifyPtr) (WindowPtr, int, int); /* * These functions can be wrapped by the DRI. Each of these have @@ -52,11 +51,11 @@ typedef void (*ClipNotifyPtr)( WindowPtr, int, int ); * overridden by the driver in its [driver]DRIScreenInit function. */ typedef struct { - WindowExposuresProcPtr WindowExposures; - CopyWindowProcPtr CopyWindow; - ValidateTreeProcPtr ValidateTree; - PostValidateTreeProcPtr PostValidateTree; - ClipNotifyProcPtr ClipNotify; + WindowExposuresProcPtr WindowExposures; + CopyWindowProcPtr CopyWindow; + ValidateTreeProcPtr ValidateTree; + PostValidateTreeProcPtr PostValidateTree; + ClipNotifyProcPtr ClipNotify; } DRIWrappedFuncsRec, *DRIWrappedFuncsPtr; typedef struct { @@ -74,8 +73,7 @@ extern Bool DRIExtensionInit(void); extern void DRIReset(void); -extern Bool DRIQueryDirectRenderingCapable(ScreenPtr pScreen, - Bool *isCapable); +extern Bool DRIQueryDirectRenderingCapable(ScreenPtr pScreen, Bool *isCapable); extern Bool DRIAuthConnection(ScreenPtr pScreen, unsigned int magic); @@ -83,55 +81,43 @@ extern Bool DRICreateSurface(ScreenPtr pScreen, Drawable id, DrawablePtr pDrawable, xp_client_id client_id, - xp_surface_id *surface_id, + xp_surface_id * surface_id, unsigned int key[2], void (*notify) (void *arg, void *data), void *notify_data); extern Bool DRIDestroySurface(ScreenPtr pScreen, - Drawable id, - DrawablePtr pDrawable, - void (*notify) (void *arg, void *data), - void *notify_data); + Drawable id, + DrawablePtr pDrawable, + void (*notify) (void *arg, void *data), + void *notify_data); -extern Bool DRIDrawablePrivDelete(pointer pResource, - XID id); +extern Bool DRIDrawablePrivDelete(pointer pResource, XID id); extern DRIWrappedFuncsRec *DRIGetWrappedFuncs(ScreenPtr pScreen); extern void DRICopyWindow(WindowPtr pWin, - DDXPointRec ptOldOrg, - RegionPtr prgnSrc); + DDXPointRec ptOldOrg, RegionPtr prgnSrc); -extern int DRIValidateTree(WindowPtr pParent, - WindowPtr pChild, - VTKind kind); +extern int DRIValidateTree(WindowPtr pParent, WindowPtr pChild, VTKind kind); extern void DRIPostValidateTree(WindowPtr pParent, - WindowPtr pChild, - VTKind kind); + WindowPtr pChild, VTKind kind); -extern void DRIClipNotify(WindowPtr pWin, - int dx, - int dy); +extern void DRIClipNotify(WindowPtr pWin, int dx, int dy); -extern void DRIWindowExposures(WindowPtr pWin, - RegionPtr prgn, - RegionPtr bsreg); +extern void DRIWindowExposures(WindowPtr pWin, RegionPtr prgn, RegionPtr bsreg); -extern void DRISurfaceNotify (xp_surface_id id, int kind); +extern void DRISurfaceNotify(xp_surface_id id, int kind); extern void DRIQueryVersion(int *majorVersion, - int *minorVersion, - int *patchVersion); + int *minorVersion, int *patchVersion); extern Bool DRICreatePixmap(ScreenPtr pScreen, Drawable id, - DrawablePtr pDrawable, char *path, - size_t pathmax); + DrawablePtr pDrawable, char *path, size_t pathmax); extern Bool DRIGetPixmapData(DrawablePtr pDrawable, int *width, int *height, - int *pitch, int *bpp, void **ptr); - + int *pitch, int *bpp, void **ptr); extern void DRIDestroyPixmap(DrawablePtr pDrawable); diff --git a/xorg-server/hw/xquartz/xpr/driWrap.c b/xorg-server/hw/xquartz/xpr/driWrap.c index c38761555..eca31b263 100644 --- a/xorg-server/hw/xquartz/xpr/driWrap.c +++ b/xorg-server/hw/xquartz/xpr/driWrap.c @@ -1,537 +1,552 @@ -/* -Copyright (c) 2009 Apple Computer, Inc. -All Rights Reserved. - -Permission is hereby granted, free of charge, to any person obtaining a -copy of this software and associated documentation files (the -"Software"), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sub license, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to -the following conditions: - -The above copyright notice and this permission notice (including the -next paragraph) shall be included in all copies or substantial portions -of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. -IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR -ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, -TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -*/ -#ifdef HAVE_DIX_CONFIG_H -#include -#endif - -#include -#include "mi.h" -#include "scrnintstr.h" -#include "gcstruct.h" -#include "pixmapstr.h" -#include "windowstr.h" -#include "dixfontstr.h" -#include "mivalidate.h" -#include "driWrap.h" -#include "dri.h" - -#include - -typedef struct { - GCOps *originalOps; -} DRIGCRec; - -typedef struct { - GCOps *originalOps; - CreateGCProcPtr CreateGC; -} DRIWrapScreenRec; - -typedef struct { - Bool didSave; - int devKind; - DevUnion devPrivate; -} DRISavedDrawableState; - -static DevPrivateKeyRec driGCKeyRec; -#define driGCKey (&driGCKeyRec) - -static DevPrivateKeyRec driWrapScreenKeyRec; -#define driWrapScreenKey (&driWrapScreenKeyRec) - -static GCOps driGCOps; - -#define wrap(priv, real, member, func) { \ - priv->member = real->member; \ - real->member = func; \ - } - -#define unwrap(priv, real, member) { \ - real->member = priv->member; \ - } - -static DRIGCRec * -DRIGetGCPriv(GCPtr pGC) { - return dixLookupPrivate(&pGC->devPrivates, driGCKey); -} - -static void -DRIUnwrapGC(GCPtr pGC) { - DRIGCRec *pGCPriv = DRIGetGCPriv(pGC); - - pGC->ops = pGCPriv->originalOps; -} - -static void -DRIWrapGC(GCPtr pGC) { - pGC->ops = &driGCOps; -} - -static void -DRISurfaceSetDrawable(DrawablePtr pDraw, - DRISavedDrawableState *saved) { - saved->didSave = FALSE; - - if(pDraw->type == DRAWABLE_PIXMAP) { - int pitch, width, height, bpp; - void *buffer; - - if(DRIGetPixmapData(pDraw, &width, &height, &pitch, &bpp, &buffer)) { - PixmapPtr pPix = (PixmapPtr)pDraw; - - saved->devKind = pPix->devKind; - saved->devPrivate.ptr = pPix->devPrivate.ptr; - saved->didSave = TRUE; - - pPix->devKind = pitch; - pPix->devPrivate.ptr = buffer; - } - } -} - -static void -DRISurfaceRestoreDrawable(DrawablePtr pDraw, - DRISavedDrawableState *saved) { - PixmapPtr pPix = (PixmapPtr)pDraw; - - if(!saved->didSave) - return; - - pPix->devKind = saved->devKind; - pPix->devPrivate.ptr = saved->devPrivate.ptr; -} - -static void -DRIFillSpans(DrawablePtr dst, GCPtr pGC, int nInit, - DDXPointPtr pptInit, int *pwidthInit, - int sorted) { - DRISavedDrawableState saved; - - DRISurfaceSetDrawable(dst, &saved); - - DRIUnwrapGC(pGC); - - pGC->ops->FillSpans(dst, pGC, nInit, pptInit, pwidthInit, sorted); - - DRIWrapGC(pGC); - - DRISurfaceRestoreDrawable(dst, &saved); -} - -static void -DRISetSpans(DrawablePtr dst, GCPtr pGC, char *pSrc, - DDXPointPtr pptInit, int *pwidthInit, - int nspans, int sorted) { - DRISavedDrawableState saved; - - DRISurfaceSetDrawable(dst, &saved); - - DRIUnwrapGC(pGC); - - pGC->ops->SetSpans(dst, pGC, pSrc, pptInit, pwidthInit, nspans, sorted); - - DRIWrapGC(pGC); - - DRISurfaceRestoreDrawable(dst, &saved); -} - -static void -DRIPutImage(DrawablePtr dst, GCPtr pGC, - int depth, int x, int y, int w, int h, - int leftPad, int format, char *pBits) { - DRISavedDrawableState saved; - - DRISurfaceSetDrawable(dst, &saved); - - DRIUnwrapGC(pGC); - - pGC->ops->PutImage(dst, pGC, depth, x, y, w, h, leftPad, format, pBits); - - DRIWrapGC(pGC); - - DRISurfaceRestoreDrawable(dst, &saved); -} - -static RegionPtr -DRICopyArea(DrawablePtr pSrc, DrawablePtr dst, GCPtr pGC, - int srcx, int srcy, int w, int h, - int dstx, int dsty) { - RegionPtr pReg; - DRISavedDrawableState pSrcSaved, dstSaved; - - DRISurfaceSetDrawable(pSrc, &pSrcSaved); - DRISurfaceSetDrawable(dst, &dstSaved); - - DRIUnwrapGC(pGC); - - pReg = pGC->ops->CopyArea(pSrc, dst, pGC, srcx, srcy, w, h, dstx, dsty); - - DRIWrapGC(pGC); - - DRISurfaceRestoreDrawable(pSrc, &pSrcSaved); - DRISurfaceRestoreDrawable(dst, &dstSaved); - - return pReg; -} - -static RegionPtr -DRICopyPlane(DrawablePtr pSrc, DrawablePtr dst, - GCPtr pGC, int srcx, int srcy, - int w, int h, int dstx, int dsty, - unsigned long plane) { - RegionPtr pReg; - DRISavedDrawableState pSrcSaved, dstSaved; - - DRISurfaceSetDrawable(pSrc, &pSrcSaved); - DRISurfaceSetDrawable(dst, &dstSaved); - - - DRIUnwrapGC(pGC); - - pReg = pGC->ops->CopyPlane(pSrc, dst, pGC, srcx, srcy, w, h, dstx, dsty, - plane); - - DRIWrapGC(pGC); - - DRISurfaceRestoreDrawable(pSrc, &pSrcSaved); - DRISurfaceRestoreDrawable(dst, &dstSaved); - - return pReg; -} - -static void -DRIPolyPoint(DrawablePtr dst, GCPtr pGC, - int mode, int npt, DDXPointPtr pptInit) { - DRISavedDrawableState saved; - - DRISurfaceSetDrawable(dst, &saved); - - DRIUnwrapGC(pGC); - - pGC->ops->PolyPoint(dst, pGC, mode, npt, pptInit); - - DRIWrapGC(pGC); - - DRISurfaceRestoreDrawable(dst, &saved); -} - -static void -DRIPolylines(DrawablePtr dst, GCPtr pGC, - int mode, int npt, DDXPointPtr pptInit) { - DRISavedDrawableState saved; - - DRISurfaceSetDrawable(dst, &saved); - - DRIUnwrapGC(pGC); - - pGC->ops->Polylines(dst, pGC, mode, npt, pptInit); - - DRIWrapGC(pGC); - - DRISurfaceRestoreDrawable(dst, &saved); -} - -static void -DRIPolySegment(DrawablePtr dst, GCPtr pGC, - int nseg, xSegment *pSeg) { - DRISavedDrawableState saved; - - DRISurfaceSetDrawable(dst, &saved); - - DRIUnwrapGC(pGC); - - pGC->ops->PolySegment(dst, pGC, nseg, pSeg); - - DRIWrapGC(pGC); - - DRISurfaceRestoreDrawable(dst, &saved); -} - -static void -DRIPolyRectangle(DrawablePtr dst, GCPtr pGC, - int nRects, xRectangle *pRects) { - DRISavedDrawableState saved; - - DRISurfaceSetDrawable(dst, &saved); - - DRIUnwrapGC(pGC); - - pGC->ops->PolyRectangle(dst, pGC, nRects, pRects); - - DRIWrapGC(pGC); - - DRISurfaceRestoreDrawable(dst, &saved); -} -static void -DRIPolyArc(DrawablePtr dst, GCPtr pGC, int narcs, xArc *parcs) { - DRISavedDrawableState saved; - - DRISurfaceSetDrawable(dst, &saved); - - DRIUnwrapGC(pGC); - - pGC->ops->PolyArc(dst, pGC, narcs, parcs); - - DRIWrapGC(pGC); - - DRISurfaceRestoreDrawable(dst, &saved); -} - -static void -DRIFillPolygon(DrawablePtr dst, GCPtr pGC, - int shape, int mode, int count, - DDXPointPtr pptInit) { - DRISavedDrawableState saved; - - DRISurfaceSetDrawable(dst, &saved); - - DRIUnwrapGC(pGC); - - pGC->ops->FillPolygon(dst, pGC, shape, mode, count, pptInit); - - DRIWrapGC(pGC); - - DRISurfaceRestoreDrawable(dst, &saved); -} - -static void -DRIPolyFillRect(DrawablePtr dst, GCPtr pGC, - int nRectsInit, xRectangle *pRectsInit) { - DRISavedDrawableState saved; - - DRISurfaceSetDrawable(dst, &saved); - - DRIUnwrapGC(pGC); - - pGC->ops->PolyFillRect(dst, pGC, nRectsInit, pRectsInit); - - DRIWrapGC(pGC); - - DRISurfaceRestoreDrawable(dst, &saved); -} - -static void -DRIPolyFillArc(DrawablePtr dst, GCPtr pGC, - int narcsInit, xArc *parcsInit) { - DRISavedDrawableState saved; - - DRISurfaceSetDrawable(dst, &saved); - - DRIUnwrapGC(pGC); - - pGC->ops->PolyFillArc(dst, pGC, narcsInit, parcsInit); - - DRIWrapGC(pGC); - - DRISurfaceRestoreDrawable(dst, &saved); -} - -static int -DRIPolyText8(DrawablePtr dst, GCPtr pGC, - int x, int y, int count, char *chars) { - int ret; - DRISavedDrawableState saved; - - DRISurfaceSetDrawable(dst, &saved); - - DRIUnwrapGC(pGC); - - ret = pGC->ops->PolyText8(dst, pGC, x, y, count, chars); - - DRIWrapGC(pGC); - - DRISurfaceRestoreDrawable(dst, &saved); - - return ret; -} - -static int -DRIPolyText16(DrawablePtr dst, GCPtr pGC, - int x, int y, int count, unsigned short *chars) { - int ret; - DRISavedDrawableState saved; - - DRISurfaceSetDrawable(dst, &saved); - - DRIUnwrapGC(pGC); - - ret = pGC->ops->PolyText16(dst, pGC, x, y, count, chars); - - DRIWrapGC(pGC); - - DRISurfaceRestoreDrawable(dst, &saved); - - return ret; -} - -static void -DRIImageText8(DrawablePtr dst, GCPtr pGC, - int x, int y, int count, char *chars) { - DRISavedDrawableState saved; - - DRISurfaceSetDrawable(dst, &saved); - - DRIUnwrapGC(pGC); - - pGC->ops->ImageText8(dst, pGC, x, y, count, chars); - - DRIWrapGC(pGC); - - DRISurfaceRestoreDrawable(dst, &saved); -} - -static void -DRIImageText16(DrawablePtr dst, GCPtr pGC, - int x, int y, int count, unsigned short *chars) { - DRISavedDrawableState saved; - - DRISurfaceSetDrawable(dst, &saved); - - DRIUnwrapGC(pGC); - - pGC->ops->ImageText16(dst, pGC, x, y, count, chars); - - DRIWrapGC(pGC); - - DRISurfaceRestoreDrawable(dst, &saved); -} - -static void -DRIImageGlyphBlt(DrawablePtr dst, GCPtr pGC, - int x, int y, unsigned int nglyphInit, - CharInfoPtr *ppciInit, pointer unused) { - DRISavedDrawableState saved; - - DRISurfaceSetDrawable(dst, &saved); - - DRIUnwrapGC(pGC); - - pGC->ops->ImageGlyphBlt(dst, pGC, x, y, nglyphInit, ppciInit, unused); - - DRIWrapGC(pGC); - - DRISurfaceRestoreDrawable(dst, &saved); -} - -static void DRIPolyGlyphBlt(DrawablePtr dst, GCPtr pGC, - int x, int y, unsigned int nglyph, - CharInfoPtr *ppci, pointer pglyphBase) { - DRISavedDrawableState saved; - - DRISurfaceSetDrawable(dst, &saved); - - DRIUnwrapGC(pGC); - - pGC->ops->PolyGlyphBlt(dst, pGC, x, y, nglyph, ppci, pglyphBase); - - DRIWrapGC(pGC); - - DRISurfaceRestoreDrawable(dst, &saved); -} - -static void -DRIPushPixels(GCPtr pGC, PixmapPtr pBitMap, DrawablePtr dst, - int dx, int dy, int xOrg, int yOrg) { - DRISavedDrawableState bitMapSaved, dstSaved; - - DRISurfaceSetDrawable(&pBitMap->drawable, &bitMapSaved); - DRISurfaceSetDrawable(dst, &dstSaved); - - DRIUnwrapGC(pGC); - - pGC->ops->PushPixels(pGC, pBitMap, dst, dx, dy, xOrg, yOrg); - - DRIWrapGC(pGC); - - DRISurfaceRestoreDrawable(&pBitMap->drawable, &bitMapSaved); - DRISurfaceRestoreDrawable(dst, &dstSaved); -} - - -static GCOps driGCOps = { - DRIFillSpans, - DRISetSpans, - DRIPutImage, - DRICopyArea, - DRICopyPlane, - DRIPolyPoint, - DRIPolylines, - DRIPolySegment, - DRIPolyRectangle, - DRIPolyArc, - DRIFillPolygon, - DRIPolyFillRect, - DRIPolyFillArc, - DRIPolyText8, - DRIPolyText16, - DRIImageText8, - DRIImageText16, - DRIImageGlyphBlt, - DRIPolyGlyphBlt, - DRIPushPixels -}; - - -static Bool -DRICreateGC(GCPtr pGC) { - ScreenPtr pScreen = pGC->pScreen; - DRIWrapScreenRec *pScreenPriv; - DRIGCRec *pGCPriv; - Bool ret; - - pScreenPriv = dixLookupPrivate(&pScreen->devPrivates, driWrapScreenKey); - - pGCPriv = DRIGetGCPriv(pGC); - - unwrap(pScreenPriv, pScreen, CreateGC); - ret = pScreen->CreateGC(pGC); - - if(ret) { - pGCPriv->originalOps = pGC->ops; - pGC->ops = &driGCOps; - } - - wrap(pScreenPriv, pScreen, CreateGC, DRICreateGC); - - return ret; -} - - -/* Return false if an error occurred. */ -Bool -DRIWrapInit(ScreenPtr pScreen) { - DRIWrapScreenRec *pScreenPriv; - - if(!dixRegisterPrivateKey(&driGCKeyRec, PRIVATE_GC, sizeof(DRIGCRec))) - return FALSE; - - if(!dixRegisterPrivateKey(&driWrapScreenKeyRec, PRIVATE_SCREEN, sizeof(DRIWrapScreenRec))) - return FALSE; - - pScreenPriv = dixGetPrivateAddr(&pScreen->devPrivates, &driWrapScreenKeyRec); - pScreenPriv->CreateGC = pScreen->CreateGC; - pScreen->CreateGC = DRICreateGC; - - return TRUE; -} +/* +Copyright (c) 2009 Apple Computer, Inc. +All Rights Reserved. + +Permission is hereby granted, free of charge, to any person obtaining a +copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sub license, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice (including the +next paragraph) shall be included in all copies or substantial portions +of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. +IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR +ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +*/ +#ifdef HAVE_DIX_CONFIG_H +#include +#endif + +#include +#include "mi.h" +#include "scrnintstr.h" +#include "gcstruct.h" +#include "pixmapstr.h" +#include "windowstr.h" +#include "dixfontstr.h" +#include "mivalidate.h" +#include "driWrap.h" +#include "dri.h" + +#include + +typedef struct { + GCOps *originalOps; +} DRIGCRec; + +typedef struct { + GCOps *originalOps; + CreateGCProcPtr CreateGC; +} DRIWrapScreenRec; + +typedef struct { + Bool didSave; + int devKind; + DevUnion devPrivate; +} DRISavedDrawableState; + +static DevPrivateKeyRec driGCKeyRec; + +#define driGCKey (&driGCKeyRec) + +static DevPrivateKeyRec driWrapScreenKeyRec; + +#define driWrapScreenKey (&driWrapScreenKeyRec) + +static GCOps driGCOps; + +#define wrap(priv, real, member, func) { \ + priv->member = real->member; \ + real->member = func; \ + } + +#define unwrap(priv, real, member) { \ + real->member = priv->member; \ + } + +static DRIGCRec * +DRIGetGCPriv(GCPtr pGC) +{ + return dixLookupPrivate(&pGC->devPrivates, driGCKey); +} + +static void +DRIUnwrapGC(GCPtr pGC) +{ + DRIGCRec *pGCPriv = DRIGetGCPriv(pGC); + + pGC->ops = pGCPriv->originalOps; +} + +static void +DRIWrapGC(GCPtr pGC) +{ + pGC->ops = &driGCOps; +} + +static void +DRISurfaceSetDrawable(DrawablePtr pDraw, DRISavedDrawableState * saved) +{ + saved->didSave = FALSE; + + if (pDraw->type == DRAWABLE_PIXMAP) { + int pitch, width, height, bpp; + void *buffer; + + if (DRIGetPixmapData(pDraw, &width, &height, &pitch, &bpp, &buffer)) { + PixmapPtr pPix = (PixmapPtr) pDraw; + + saved->devKind = pPix->devKind; + saved->devPrivate.ptr = pPix->devPrivate.ptr; + saved->didSave = TRUE; + + pPix->devKind = pitch; + pPix->devPrivate.ptr = buffer; + } + } +} + +static void +DRISurfaceRestoreDrawable(DrawablePtr pDraw, DRISavedDrawableState * saved) +{ + PixmapPtr pPix = (PixmapPtr) pDraw; + + if (!saved->didSave) + return; + + pPix->devKind = saved->devKind; + pPix->devPrivate.ptr = saved->devPrivate.ptr; +} + +static void +DRIFillSpans(DrawablePtr dst, GCPtr pGC, int nInit, + DDXPointPtr pptInit, int *pwidthInit, int sorted) +{ + DRISavedDrawableState saved; + + DRISurfaceSetDrawable(dst, &saved); + + DRIUnwrapGC(pGC); + + pGC->ops->FillSpans(dst, pGC, nInit, pptInit, pwidthInit, sorted); + + DRIWrapGC(pGC); + + DRISurfaceRestoreDrawable(dst, &saved); +} + +static void +DRISetSpans(DrawablePtr dst, GCPtr pGC, char *pSrc, + DDXPointPtr pptInit, int *pwidthInit, int nspans, int sorted) +{ + DRISavedDrawableState saved; + + DRISurfaceSetDrawable(dst, &saved); + + DRIUnwrapGC(pGC); + + pGC->ops->SetSpans(dst, pGC, pSrc, pptInit, pwidthInit, nspans, sorted); + + DRIWrapGC(pGC); + + DRISurfaceRestoreDrawable(dst, &saved); +} + +static void +DRIPutImage(DrawablePtr dst, GCPtr pGC, + int depth, int x, int y, int w, int h, + int leftPad, int format, char *pBits) +{ + DRISavedDrawableState saved; + + DRISurfaceSetDrawable(dst, &saved); + + DRIUnwrapGC(pGC); + + pGC->ops->PutImage(dst, pGC, depth, x, y, w, h, leftPad, format, pBits); + + DRIWrapGC(pGC); + + DRISurfaceRestoreDrawable(dst, &saved); +} + +static RegionPtr +DRICopyArea(DrawablePtr pSrc, DrawablePtr dst, GCPtr pGC, + int srcx, int srcy, int w, int h, int dstx, int dsty) +{ + RegionPtr pReg; + DRISavedDrawableState pSrcSaved, dstSaved; + + DRISurfaceSetDrawable(pSrc, &pSrcSaved); + DRISurfaceSetDrawable(dst, &dstSaved); + + DRIUnwrapGC(pGC); + + pReg = pGC->ops->CopyArea(pSrc, dst, pGC, srcx, srcy, w, h, dstx, dsty); + + DRIWrapGC(pGC); + + DRISurfaceRestoreDrawable(pSrc, &pSrcSaved); + DRISurfaceRestoreDrawable(dst, &dstSaved); + + return pReg; +} + +static RegionPtr +DRICopyPlane(DrawablePtr pSrc, DrawablePtr dst, + GCPtr pGC, int srcx, int srcy, + int w, int h, int dstx, int dsty, unsigned long plane) +{ + RegionPtr pReg; + DRISavedDrawableState pSrcSaved, dstSaved; + + DRISurfaceSetDrawable(pSrc, &pSrcSaved); + DRISurfaceSetDrawable(dst, &dstSaved); + + DRIUnwrapGC(pGC); + + pReg = pGC->ops->CopyPlane(pSrc, dst, pGC, srcx, srcy, w, h, dstx, dsty, + plane); + + DRIWrapGC(pGC); + + DRISurfaceRestoreDrawable(pSrc, &pSrcSaved); + DRISurfaceRestoreDrawable(dst, &dstSaved); + + return pReg; +} + +static void +DRIPolyPoint(DrawablePtr dst, GCPtr pGC, int mode, int npt, DDXPointPtr pptInit) +{ + DRISavedDrawableState saved; + + DRISurfaceSetDrawable(dst, &saved); + + DRIUnwrapGC(pGC); + + pGC->ops->PolyPoint(dst, pGC, mode, npt, pptInit); + + DRIWrapGC(pGC); + + DRISurfaceRestoreDrawable(dst, &saved); +} + +static void +DRIPolylines(DrawablePtr dst, GCPtr pGC, int mode, int npt, DDXPointPtr pptInit) +{ + DRISavedDrawableState saved; + + DRISurfaceSetDrawable(dst, &saved); + + DRIUnwrapGC(pGC); + + pGC->ops->Polylines(dst, pGC, mode, npt, pptInit); + + DRIWrapGC(pGC); + + DRISurfaceRestoreDrawable(dst, &saved); +} + +static void +DRIPolySegment(DrawablePtr dst, GCPtr pGC, int nseg, xSegment * pSeg) +{ + DRISavedDrawableState saved; + + DRISurfaceSetDrawable(dst, &saved); + + DRIUnwrapGC(pGC); + + pGC->ops->PolySegment(dst, pGC, nseg, pSeg); + + DRIWrapGC(pGC); + + DRISurfaceRestoreDrawable(dst, &saved); +} + +static void +DRIPolyRectangle(DrawablePtr dst, GCPtr pGC, int nRects, xRectangle *pRects) +{ + DRISavedDrawableState saved; + + DRISurfaceSetDrawable(dst, &saved); + + DRIUnwrapGC(pGC); + + pGC->ops->PolyRectangle(dst, pGC, nRects, pRects); + + DRIWrapGC(pGC); + + DRISurfaceRestoreDrawable(dst, &saved); +} + +static void +DRIPolyArc(DrawablePtr dst, GCPtr pGC, int narcs, xArc * parcs) +{ + DRISavedDrawableState saved; + + DRISurfaceSetDrawable(dst, &saved); + + DRIUnwrapGC(pGC); + + pGC->ops->PolyArc(dst, pGC, narcs, parcs); + + DRIWrapGC(pGC); + + DRISurfaceRestoreDrawable(dst, &saved); +} + +static void +DRIFillPolygon(DrawablePtr dst, GCPtr pGC, + int shape, int mode, int count, DDXPointPtr pptInit) +{ + DRISavedDrawableState saved; + + DRISurfaceSetDrawable(dst, &saved); + + DRIUnwrapGC(pGC); + + pGC->ops->FillPolygon(dst, pGC, shape, mode, count, pptInit); + + DRIWrapGC(pGC); + + DRISurfaceRestoreDrawable(dst, &saved); +} + +static void +DRIPolyFillRect(DrawablePtr dst, GCPtr pGC, + int nRectsInit, xRectangle *pRectsInit) +{ + DRISavedDrawableState saved; + + DRISurfaceSetDrawable(dst, &saved); + + DRIUnwrapGC(pGC); + + pGC->ops->PolyFillRect(dst, pGC, nRectsInit, pRectsInit); + + DRIWrapGC(pGC); + + DRISurfaceRestoreDrawable(dst, &saved); +} + +static void +DRIPolyFillArc(DrawablePtr dst, GCPtr pGC, int narcsInit, xArc * parcsInit) +{ + DRISavedDrawableState saved; + + DRISurfaceSetDrawable(dst, &saved); + + DRIUnwrapGC(pGC); + + pGC->ops->PolyFillArc(dst, pGC, narcsInit, parcsInit); + + DRIWrapGC(pGC); + + DRISurfaceRestoreDrawable(dst, &saved); +} + +static int +DRIPolyText8(DrawablePtr dst, GCPtr pGC, int x, int y, int count, char *chars) +{ + int ret; + DRISavedDrawableState saved; + + DRISurfaceSetDrawable(dst, &saved); + + DRIUnwrapGC(pGC); + + ret = pGC->ops->PolyText8(dst, pGC, x, y, count, chars); + + DRIWrapGC(pGC); + + DRISurfaceRestoreDrawable(dst, &saved); + + return ret; +} + +static int +DRIPolyText16(DrawablePtr dst, GCPtr pGC, + int x, int y, int count, unsigned short *chars) +{ + int ret; + DRISavedDrawableState saved; + + DRISurfaceSetDrawable(dst, &saved); + + DRIUnwrapGC(pGC); + + ret = pGC->ops->PolyText16(dst, pGC, x, y, count, chars); + + DRIWrapGC(pGC); + + DRISurfaceRestoreDrawable(dst, &saved); + + return ret; +} + +static void +DRIImageText8(DrawablePtr dst, GCPtr pGC, int x, int y, int count, char *chars) +{ + DRISavedDrawableState saved; + + DRISurfaceSetDrawable(dst, &saved); + + DRIUnwrapGC(pGC); + + pGC->ops->ImageText8(dst, pGC, x, y, count, chars); + + DRIWrapGC(pGC); + + DRISurfaceRestoreDrawable(dst, &saved); +} + +static void +DRIImageText16(DrawablePtr dst, GCPtr pGC, + int x, int y, int count, unsigned short *chars) +{ + DRISavedDrawableState saved; + + DRISurfaceSetDrawable(dst, &saved); + + DRIUnwrapGC(pGC); + + pGC->ops->ImageText16(dst, pGC, x, y, count, chars); + + DRIWrapGC(pGC); + + DRISurfaceRestoreDrawable(dst, &saved); +} + +static void +DRIImageGlyphBlt(DrawablePtr dst, GCPtr pGC, + int x, int y, unsigned int nglyphInit, + CharInfoPtr * ppciInit, pointer unused) +{ + DRISavedDrawableState saved; + + DRISurfaceSetDrawable(dst, &saved); + + DRIUnwrapGC(pGC); + + pGC->ops->ImageGlyphBlt(dst, pGC, x, y, nglyphInit, ppciInit, unused); + + DRIWrapGC(pGC); + + DRISurfaceRestoreDrawable(dst, &saved); +} + +static void +DRIPolyGlyphBlt(DrawablePtr dst, GCPtr pGC, + int x, int y, unsigned int nglyph, + CharInfoPtr * ppci, pointer pglyphBase) +{ + DRISavedDrawableState saved; + + DRISurfaceSetDrawable(dst, &saved); + + DRIUnwrapGC(pGC); + + pGC->ops->PolyGlyphBlt(dst, pGC, x, y, nglyph, ppci, pglyphBase); + + DRIWrapGC(pGC); + + DRISurfaceRestoreDrawable(dst, &saved); +} + +static void +DRIPushPixels(GCPtr pGC, PixmapPtr pBitMap, DrawablePtr dst, + int dx, int dy, int xOrg, int yOrg) +{ + DRISavedDrawableState bitMapSaved, dstSaved; + + DRISurfaceSetDrawable(&pBitMap->drawable, &bitMapSaved); + DRISurfaceSetDrawable(dst, &dstSaved); + + DRIUnwrapGC(pGC); + + pGC->ops->PushPixels(pGC, pBitMap, dst, dx, dy, xOrg, yOrg); + + DRIWrapGC(pGC); + + DRISurfaceRestoreDrawable(&pBitMap->drawable, &bitMapSaved); + DRISurfaceRestoreDrawable(dst, &dstSaved); +} + +static GCOps driGCOps = { + DRIFillSpans, + DRISetSpans, + DRIPutImage, + DRICopyArea, + DRICopyPlane, + DRIPolyPoint, + DRIPolylines, + DRIPolySegment, + DRIPolyRectangle, + DRIPolyArc, + DRIFillPolygon, + DRIPolyFillRect, + DRIPolyFillArc, + DRIPolyText8, + DRIPolyText16, + DRIImageText8, + DRIImageText16, + DRIImageGlyphBlt, + DRIPolyGlyphBlt, + DRIPushPixels +}; + +static Bool +DRICreateGC(GCPtr pGC) +{ + ScreenPtr pScreen = pGC->pScreen; + DRIWrapScreenRec *pScreenPriv; + DRIGCRec *pGCPriv; + Bool ret; + + pScreenPriv = dixLookupPrivate(&pScreen->devPrivates, driWrapScreenKey); + + pGCPriv = DRIGetGCPriv(pGC); + + unwrap(pScreenPriv, pScreen, CreateGC); + ret = pScreen->CreateGC(pGC); + + if (ret) { + pGCPriv->originalOps = pGC->ops; + pGC->ops = &driGCOps; + } + + wrap(pScreenPriv, pScreen, CreateGC, DRICreateGC); + + return ret; +} + +/* Return false if an error occurred. */ +Bool +DRIWrapInit(ScreenPtr pScreen) +{ + DRIWrapScreenRec *pScreenPriv; + + if (!dixRegisterPrivateKey(&driGCKeyRec, PRIVATE_GC, sizeof(DRIGCRec))) + return FALSE; + + if (!dixRegisterPrivateKey + (&driWrapScreenKeyRec, PRIVATE_SCREEN, sizeof(DRIWrapScreenRec))) + return FALSE; + + pScreenPriv = + dixGetPrivateAddr(&pScreen->devPrivates, &driWrapScreenKeyRec); + pScreenPriv->CreateGC = pScreen->CreateGC; + pScreen->CreateGC = DRICreateGC; + + return TRUE; +} diff --git a/xorg-server/hw/xquartz/xpr/dristruct.h b/xorg-server/hw/xquartz/xpr/dristruct.h index 19d78a973..13d590b1f 100644 --- a/xorg-server/hw/xquartz/xpr/dristruct.h +++ b/xorg-server/hw/xquartz/xpr/dristruct.h @@ -46,15 +46,14 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #define DRI_DRAWABLE_PRIV_FROM_PIXMAP(pPix) ((DRIDrawablePrivPtr) \ dixLookupPrivate(&(pPix)->devPrivates, DRIPixmapPrivKey)) -typedef struct _DRIDrawablePrivRec -{ - xp_surface_id sid; - int drawableIndex; - DrawablePtr pDraw; - ScreenPtr pScreen; - int refCount; - unsigned int key[2]; - x_list *notifiers; /* list of (FUN . DATA) */ +typedef struct _DRIDrawablePrivRec { + xp_surface_id sid; + int drawableIndex; + DrawablePtr pDraw; + ScreenPtr pScreen; + int refCount; + unsigned int key[2]; + x_list *notifiers; /* list of (FUN . DATA) */ } DRIDrawablePrivRec, *DRIDrawablePrivPtr; #define DRI_SCREEN_PRIV(pScreen) ((DRIScreenPrivPtr) \ @@ -64,13 +63,11 @@ typedef struct _DRIDrawablePrivRec dixLookupPrivate(&screenInfo.screens[screenIndex]->devPrivates, \ DRIScreenPrivKey)) - -typedef struct _DRIScreenPrivRec -{ - Bool directRenderingSupport; - int nrWindows; - DRIWrappedFuncsRec wrap; - DrawablePtr DRIDrawables[DRI_MAX_DRAWABLES]; +typedef struct _DRIScreenPrivRec { + Bool directRenderingSupport; + int nrWindows; + DRIWrappedFuncsRec wrap; + DrawablePtr DRIDrawables[DRI_MAX_DRAWABLES]; } DRIScreenPrivRec, *DRIScreenPrivPtr; -#endif /* DRI_STRUCT_H */ +#endif /* DRI_STRUCT_H */ diff --git a/xorg-server/hw/xquartz/xpr/x-hash.c b/xorg-server/hw/xquartz/xpr/x-hash.c index 7c6a67bd1..a3ff66177 100644 --- a/xorg-server/hw/xquartz/xpr/x-hash.c +++ b/xorg-server/hw/xquartz/xpr/x-hash.c @@ -65,13 +65,13 @@ static const unsigned int bucket_sizes[] = { #define N_BUCKET_SIZES (sizeof (bucket_sizes) / sizeof (bucket_sizes[0])) static inline unsigned int -hash_table_total_buckets (x_hash_table *h) +hash_table_total_buckets(x_hash_table * h) { return bucket_sizes[h->bucket_index]; } static inline void -hash_table_destroy_item (x_hash_table *h, void *k, void *v) +hash_table_destroy_item(x_hash_table * h, void *k, void *v) { if (h->destroy_key != 0) (*h->destroy_key) (k); @@ -81,7 +81,7 @@ hash_table_destroy_item (x_hash_table *h, void *k, void *v) } static inline size_t -hash_table_hash_key (x_hash_table *h, void *k) +hash_table_hash_key(x_hash_table * h, void *k) { if (h->hash_key != 0) return (*h->hash_key) (k); @@ -90,7 +90,7 @@ hash_table_hash_key (x_hash_table *h, void *k) } static inline int -hash_table_compare_keys (x_hash_table *h, void *k1, void *k2) +hash_table_compare_keys(x_hash_table * h, void *k1, void *k2) { if (h->compare_keys == 0) return k1 == k2; @@ -99,7 +99,7 @@ hash_table_compare_keys (x_hash_table *h, void *k1, void *k2) } static void -hash_table_split (x_hash_table *h) +hash_table_split(x_hash_table * h) { x_list **new, **old; x_list *node, *item, *next; @@ -110,28 +110,25 @@ hash_table_split (x_hash_table *h) if (h->bucket_index == N_BUCKET_SIZES - 1) return; - old_size = hash_table_total_buckets (h); + old_size = hash_table_total_buckets(h); old = h->buckets; h->bucket_index++; - new_size = hash_table_total_buckets (h); - new = calloc (new_size, sizeof (x_list *)); + new_size = hash_table_total_buckets(h); + new = calloc(new_size, sizeof(x_list *)); - if (new == 0) - { + if (new == 0) { h->bucket_index--; return; } - for (i = 0; i < old_size; i++) - { - for (node = old[i]; node != 0; node = next) - { + for (i = 0; i < old_size; i++) { + for (node = old[i]; node != 0; node = next) { next = node->next; item = node->data; - b = hash_table_hash_key (h, ITEM_KEY (item)) % new_size; + b = hash_table_hash_key(h, ITEM_KEY(item)) % new_size; node->next = new[b]; new[b] = node; @@ -139,30 +136,27 @@ hash_table_split (x_hash_table *h) } h->buckets = new; - free (old); + free(old); } -X_EXTERN x_hash_table * -X_PFX (hash_table_new) (x_hash_fun *hash, - x_compare_fun *compare, - x_destroy_fun *key_destroy, - x_destroy_fun *value_destroy) -{ +X_EXTERN x_hash_table *X_PFX(hash_table_new) (x_hash_fun * hash, + x_compare_fun * compare, + x_destroy_fun * key_destroy, + x_destroy_fun * value_destroy) { x_hash_table *h; - h = calloc (1, sizeof (x_hash_table)); + h = calloc(1, sizeof(x_hash_table)); if (h == 0) return 0; h->bucket_index = 0; - h->buckets = calloc (hash_table_total_buckets (h), sizeof (x_list *)); + h->buckets = calloc(hash_table_total_buckets(h), sizeof(x_list *)); - if (h->buckets == 0) - { - free (h); + if (h->buckets == 0) { + free(h); return 0; } - + h->hash_key = hash; h->compare_keys = compare; h->destroy_key = key_destroy; @@ -172,66 +166,57 @@ X_PFX (hash_table_new) (x_hash_fun *hash, } X_EXTERN void -X_PFX (hash_table_free) (x_hash_table *h) -{ + X_PFX(hash_table_free) (x_hash_table * h) { int n, i; x_list *node, *item; - assert (h != NULL); + assert(h != NULL); - n = hash_table_total_buckets (h); + n = hash_table_total_buckets(h); - for (i = 0; i < n; i++) - { - for (node = h->buckets[i]; node != 0; node = node->next) - { + for (i = 0; i < n; i++) { + for (node = h->buckets[i]; node != 0; node = node->next) { item = node->data; - hash_table_destroy_item (h, ITEM_KEY (item), ITEM_VALUE (item)); - ITEM_FREE (item); + hash_table_destroy_item(h, ITEM_KEY(item), ITEM_VALUE(item)); + ITEM_FREE(item); } - X_PFX (list_free) (h->buckets[i]); + X_PFX(list_free) (h->buckets[i]); } - free (h->buckets); - free (h); + free(h->buckets); + free(h); } X_EXTERN unsigned int -X_PFX (hash_table_size) (x_hash_table *h) -{ - assert (h != NULL); + X_PFX(hash_table_size) (x_hash_table * h) { + assert(h != NULL); return h->total_keys; } static void -hash_table_modify (x_hash_table *h, void *k, void *v, int replace) +hash_table_modify(x_hash_table * h, void *k, void *v, int replace) { size_t hash_value; x_list *node, *item; - assert (h != NULL); + assert(h != NULL); - hash_value = hash_table_hash_key (h, k); + hash_value = hash_table_hash_key(h, k); - for (node = h->buckets[hash_value % hash_table_total_buckets (h)]; - node != 0; node = node->next) - { + for (node = h->buckets[hash_value % hash_table_total_buckets(h)]; + node != 0; node = node->next) { item = node->data; - if (hash_table_compare_keys (h, ITEM_KEY (item), k)) - { - if (replace) - { - hash_table_destroy_item (h, ITEM_KEY (item), - ITEM_VALUE (item)); + if (hash_table_compare_keys(h, ITEM_KEY(item), k)) { + if (replace) { + hash_table_destroy_item(h, ITEM_KEY(item), ITEM_VALUE(item)); item->next = k; - ITEM_VALUE (item) = v; + ITEM_VALUE(item) = v; } - else - { - hash_table_destroy_item (h, k, ITEM_VALUE (item)); - ITEM_VALUE (item) = v; + else { + hash_table_destroy_item(h, k, ITEM_VALUE(item)); + ITEM_VALUE(item) = v; } return; } @@ -240,78 +225,69 @@ hash_table_modify (x_hash_table *h, void *k, void *v, int replace) /* Key isn't already in the table. Insert it. */ if (h->total_keys + 1 - > hash_table_total_buckets (h) * SPLIT_THRESHOLD_FACTOR) - { - hash_table_split (h); + > hash_table_total_buckets(h) * SPLIT_THRESHOLD_FACTOR) { + hash_table_split(h); } - hash_value = hash_value % hash_table_total_buckets (h); - h->buckets[hash_value] = X_PFX (list_prepend) (h->buckets[hash_value], - ITEM_NEW (k, v)); + hash_value = hash_value % hash_table_total_buckets(h); + h->buckets[hash_value] = X_PFX(list_prepend) (h->buckets[hash_value], + ITEM_NEW(k, v)); h->total_keys++; } X_EXTERN void -X_PFX (hash_table_insert) (x_hash_table *h, void *k, void *v) -{ - hash_table_modify (h, k, v, 0); + X_PFX(hash_table_insert) (x_hash_table * h, void *k, void *v) { + hash_table_modify(h, k, v, 0); } X_EXTERN void -X_PFX (hash_table_replace) (x_hash_table *h, void *k, void *v) -{ - hash_table_modify (h, k, v, 1); + X_PFX(hash_table_replace) (x_hash_table * h, void *k, void *v) { + hash_table_modify(h, k, v, 1); } X_EXTERN void -X_PFX (hash_table_remove) (x_hash_table *h, void *k) -{ + X_PFX(hash_table_remove) (x_hash_table * h, void *k) { size_t hash_value; x_list **ptr, *item; - assert (h != NULL); + assert(h != NULL); - hash_value = hash_table_hash_key (h, k); + hash_value = hash_table_hash_key(h, k); - for (ptr = &h->buckets[hash_value % hash_table_total_buckets (h)]; - *ptr != 0; ptr = &((*ptr)->next)) - { + for (ptr = &h->buckets[hash_value % hash_table_total_buckets(h)]; + *ptr != 0; ptr = &((*ptr)->next)) { item = (*ptr)->data; - if (hash_table_compare_keys (h, ITEM_KEY (item), k)) - { - hash_table_destroy_item (h, ITEM_KEY (item), ITEM_VALUE (item)); - ITEM_FREE (item); + if (hash_table_compare_keys(h, ITEM_KEY(item), k)) { + hash_table_destroy_item(h, ITEM_KEY(item), ITEM_VALUE(item)); + ITEM_FREE(item); item = *ptr; *ptr = item->next; - X_PFX (list_free_1) (item); + X_PFX(list_free_1) (item); h->total_keys--; return; } } } -X_EXTERN void * -X_PFX (hash_table_lookup) (x_hash_table *h, void *k, void **k_ret) -{ +X_EXTERN void *X_PFX(hash_table_lookup) (x_hash_table * h, void *k, + void **k_ret) { size_t hash_value; x_list *node, *item; - assert (h != NULL); + assert(h != NULL); - hash_value = hash_table_hash_key (h, k); + hash_value = hash_table_hash_key(h, k); - for (node = h->buckets[hash_value % hash_table_total_buckets (h)]; - node != 0; node = node->next) - { + for (node = h->buckets[hash_value % hash_table_total_buckets(h)]; + node != 0; node = node->next) { item = node->data; - if (hash_table_compare_keys (h, ITEM_KEY (item), k)) - { + if (hash_table_compare_keys(h, ITEM_KEY(item), k)) { if (k_ret != 0) - *k_ret = ITEM_KEY (item); + *k_ret = ITEM_KEY(item); - return ITEM_VALUE (item); + return ITEM_VALUE(item); } } @@ -322,22 +298,20 @@ X_PFX (hash_table_lookup) (x_hash_table *h, void *k, void **k_ret) } X_EXTERN void -X_PFX (hash_table_foreach) (x_hash_table *h, - x_hash_foreach_fun *fun, void *data) -{ + +X_PFX(hash_table_foreach) (x_hash_table * h, + x_hash_foreach_fun * fun, void *data) { int i, n; x_list *node, *item; - assert (h != NULL); + assert(h != NULL); - n = hash_table_total_buckets (h); + n = hash_table_total_buckets(h); - for (i = 0; i < n; i++) - { - for (node = h->buckets[i]; node != 0; node = node->next) - { + for (i = 0; i < n; i++) { + for (node = h->buckets[i]; node != 0; node = node->next) { item = node->data; - (*fun) (ITEM_KEY (item), ITEM_VALUE (item), data); + (*fun) (ITEM_KEY(item), ITEM_VALUE(item), data); } } } diff --git a/xorg-server/hw/xquartz/xpr/x-hash.h b/xorg-server/hw/xquartz/xpr/x-hash.h index f876b6b71..c4543346a 100644 --- a/xorg-server/hw/xquartz/xpr/x-hash.h +++ b/xorg-server/hw/xquartz/xpr/x-hash.h @@ -43,49 +43,45 @@ typedef void (x_hash_foreach_fun) (void *k, void *v, void *data); /* for X_PFX and X_EXTERN */ #include "x-list.h" -X_EXTERN x_hash_table *X_PFX (hash_table_new) (x_hash_fun *hash, - x_compare_fun *compare, - x_destroy_fun *key_destroy, - x_destroy_fun *value_destroy); -X_EXTERN void X_PFX (hash_table_free) (x_hash_table *h); - -X_EXTERN unsigned int X_PFX (hash_table_size) (x_hash_table *h); - -X_EXTERN void X_PFX (hash_table_insert) (x_hash_table *h, void *k, void *v); -X_EXTERN void X_PFX (hash_table_replace) (x_hash_table *h, void *k, void *v); -X_EXTERN void X_PFX (hash_table_remove) (x_hash_table *h, void *k); -X_EXTERN void *X_PFX (hash_table_lookup) (x_hash_table *h, - void *k, void **k_ret); -X_EXTERN void X_PFX (hash_table_foreach) (x_hash_table *h, - x_hash_foreach_fun *fun, - void *data); +X_EXTERN x_hash_table *X_PFX(hash_table_new) (x_hash_fun * hash, + x_compare_fun * compare, + x_destroy_fun * key_destroy, + x_destroy_fun * value_destroy); +X_EXTERN void X_PFX(hash_table_free) (x_hash_table * h); + +X_EXTERN unsigned int X_PFX(hash_table_size) (x_hash_table * h); + +X_EXTERN void X_PFX(hash_table_insert) (x_hash_table * h, void *k, void *v); +X_EXTERN void X_PFX(hash_table_replace) (x_hash_table * h, void *k, void *v); +X_EXTERN void X_PFX(hash_table_remove) (x_hash_table * h, void *k); +X_EXTERN void *X_PFX(hash_table_lookup) (x_hash_table * h, + void *k, void **k_ret); +X_EXTERN void X_PFX(hash_table_foreach) (x_hash_table * h, + x_hash_foreach_fun * fun, void *data); /* Conversion between unsigned int (e.g. xp_resource_id) and void pointer */ /* Forward declarations */ -static __inline__ void * -X_PFX (cvt_uint_to_vptr) (unsigned int val) __attribute__((always_inline)); +static __inline__ void *X_PFX(cvt_uint_to_vptr) (unsigned int val) + __attribute__ ((always_inline)); static __inline__ unsigned int -X_PFX (cvt_vptr_to_uint) (void * val) __attribute__((always_inline)); + X_PFX(cvt_vptr_to_uint) (void *val) __attribute__ ((always_inline)); /* Implementations */ -static __inline__ void * -X_PFX (cvt_uint_to_vptr) (unsigned int val) -{ - return (void*)((unsigned long)(val)); +static __inline__ void *X_PFX(cvt_uint_to_vptr) (unsigned int val) { + return (void *) ((unsigned long) (val)); } static __inline__ unsigned int -X_PFX (cvt_vptr_to_uint) (void * val) -{ - size_t sv = (size_t)val; - unsigned int uv = (unsigned int)sv; - - /* If this assert fails, chances are val actually is a pointer, - or there's been memory corruption */ - assert(sv == uv); - - return uv; + X_PFX(cvt_vptr_to_uint) (void *val) { + size_t sv = (size_t) val; + unsigned int uv = (unsigned int) sv; + + /* If this assert fails, chances are val actually is a pointer, + or there's been memory corruption */ + assert(sv == uv); + + return uv; } -#endif /* X_HASH_H */ +#endif /* X_HASH_H */ diff --git a/xorg-server/hw/xquartz/xpr/x-hook.c b/xorg-server/hw/xquartz/xpr/x-hook.c index c65b6fc68..fd34658e7 100644 --- a/xorg-server/hw/xquartz/xpr/x-hook.c +++ b/xorg-server/hw/xquartz/xpr/x-hook.c @@ -1,120 +1,111 @@ -/* x-hook.c - - Copyright (c) 2003 Apple Computer, Inc. All rights reserved. - - Permission is hereby granted, free of charge, to any person - obtaining a copy of this software and associated documentation files - (the "Software"), to deal in the Software without restriction, - including without limitation the rights to use, copy, modify, merge, - publish, distribute, sublicense, and/or sell copies of the Software, - and to permit persons to whom the Software is furnished to do so, - subject to the following conditions: - - The above copyright notice and this permission notice shall be - included in all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - NONINFRINGEMENT. IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT - HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, - WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - DEALINGS IN THE SOFTWARE. - - Except as contained in this notice, the name(s) of the above - copyright holders shall not be used in advertising or otherwise to - promote the sale, use or other dealings in this Software without - prior written authorization. */ - -#ifdef HAVE_DIX_CONFIG_H -#include -#endif - -#include "x-hook.h" -#include -#include -#include "os.h" - -#define CELL_NEW(f,d) X_PFX (list_prepend) ((x_list *) (f), (d)) -#define CELL_FREE(c) X_PFX (list_free_1) (c) -#define CELL_FUN(c) ((x_hook_function *) ((c)->next)) -#define CELL_DATA(c) ((c)->data) - -X_EXTERN x_list * -X_PFX (hook_add) (x_list *lst, x_hook_function *fun, void *data) -{ - return X_PFX (list_prepend) (lst, CELL_NEW (fun, data)); -} - -X_EXTERN x_list * -X_PFX (hook_remove) (x_list *lst, x_hook_function *fun, void *data) -{ - x_list *node, *cell; - x_list *to_delete = NULL; - - for (node = lst; node != NULL; node = node->next) - { - cell = node->data; - if (CELL_FUN (cell) == fun && CELL_DATA (cell) == data) - to_delete = X_PFX (list_prepend) (to_delete, cell); - } - - for (node = to_delete; node != NULL; node = node->next) - { - cell = node->data; - lst = X_PFX (list_remove) (lst, cell); - CELL_FREE (cell); - } - - X_PFX (list_free) (to_delete); - return lst; -} - -X_EXTERN void -X_PFX (hook_run) (x_list *lst, void *arg) -{ - x_list *node, *cell; - x_hook_function **fun; - void **data; - int length, i; - - if(!lst) - return; - - length = X_PFX (list_length) (lst); - fun = malloc(sizeof (x_hook_function *) * length); - data = malloc(sizeof (void *) * length); - - if(!fun || !data) { - FatalError("Failed to allocate memory in %s\n", __func__); - } - - for (i = 0, node = lst; node != NULL; node = node->next, i++) - { - cell = node->data; - fun[i] = CELL_FUN (cell); - data[i] = CELL_DATA (cell); - } - - for (i = 0; i < length; i++) - { - (*fun[i]) (arg, data[i]); - } - - free(fun); - free(data); -} - -X_EXTERN void -X_PFX (hook_free) (x_list *lst) -{ - x_list *node; - - for (node = lst; node != NULL; node = node->next) - { - CELL_FREE (node->data); - } - - X_PFX (list_free) (lst); -} +/* x-hook.c + + Copyright (c) 2003 Apple Computer, Inc. All rights reserved. + + Permission is hereby granted, free of charge, to any person + obtaining a copy of this software and associated documentation files + (the "Software"), to deal in the Software without restriction, + including without limitation the rights to use, copy, modify, merge, + publish, distribute, sublicense, and/or sell copies of the Software, + and to permit persons to whom the Software is furnished to do so, + subject to the following conditions: + + The above copyright notice and this permission notice shall be + included in all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + NONINFRINGEMENT. IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT + HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + DEALINGS IN THE SOFTWARE. + + Except as contained in this notice, the name(s) of the above + copyright holders shall not be used in advertising or otherwise to + promote the sale, use or other dealings in this Software without + prior written authorization. */ + +#ifdef HAVE_DIX_CONFIG_H +#include +#endif + +#include "x-hook.h" +#include +#include +#include "os.h" + +#define CELL_NEW(f,d) X_PFX (list_prepend) ((x_list *) (f), (d)) +#define CELL_FREE(c) X_PFX (list_free_1) (c) +#define CELL_FUN(c) ((x_hook_function *) ((c)->next)) +#define CELL_DATA(c) ((c)->data) + +X_EXTERN x_list *X_PFX(hook_add) (x_list * lst, x_hook_function * fun, + void *data) { + return X_PFX(list_prepend) (lst, CELL_NEW(fun, data)); +} + +X_EXTERN x_list *X_PFX(hook_remove) (x_list * lst, x_hook_function * fun, + void *data) { + x_list *node, *cell; + x_list *to_delete = NULL; + + for (node = lst; node != NULL; node = node->next) { + cell = node->data; + if (CELL_FUN(cell) == fun && CELL_DATA(cell) == data) + to_delete = X_PFX(list_prepend) (to_delete, cell); + } + + for (node = to_delete; node != NULL; node = node->next) { + cell = node->data; + lst = X_PFX(list_remove) (lst, cell); + CELL_FREE(cell); + } + + X_PFX(list_free) (to_delete); + return lst; +} + +X_EXTERN void + X_PFX(hook_run) (x_list * lst, void *arg) { + x_list *node, *cell; + x_hook_function **fun; + void **data; + int length, i; + + if (!lst) + return; + + length = X_PFX(list_length) (lst); + fun = malloc(sizeof(x_hook_function *) * length); + data = malloc(sizeof(void *) * length); + + if (!fun || !data) { + FatalError("Failed to allocate memory in %s\n", __func__); + } + + for (i = 0, node = lst; node != NULL; node = node->next, i++) { + cell = node->data; + fun[i] = CELL_FUN(cell); + data[i] = CELL_DATA(cell); + } + + for (i = 0; i < length; i++) { + (*fun[i]) (arg, data[i]); + } + + free(fun); + free(data); +} + +X_EXTERN void + X_PFX(hook_free) (x_list * lst) { + x_list *node; + + for (node = lst; node != NULL; node = node->next) { + CELL_FREE(node->data); + } + + X_PFX(list_free) (lst); +} diff --git a/xorg-server/hw/xquartz/xpr/x-hook.h b/xorg-server/hw/xquartz/xpr/x-hook.h index 392352d50..da3407f92 100644 --- a/xorg-server/hw/xquartz/xpr/x-hook.h +++ b/xorg-server/hw/xquartz/xpr/x-hook.h @@ -32,11 +32,13 @@ #include "x-list.h" -typedef void x_hook_function (void *arg, void *data); +typedef void x_hook_function(void *arg, void *data); -X_EXTERN x_list *X_PFX (hook_add) (x_list *lst, x_hook_function *fun, void *data); -X_EXTERN x_list *X_PFX (hook_remove) (x_list *lst, x_hook_function *fun, void *data); -X_EXTERN void X_PFX (hook_run) (x_list *lst, void *arg); -X_EXTERN void X_PFX (hook_free) (x_list *lst); +X_EXTERN x_list *X_PFX(hook_add) (x_list * lst, x_hook_function * fun, + void *data); +X_EXTERN x_list *X_PFX(hook_remove) (x_list * lst, x_hook_function * fun, + void *data); +X_EXTERN void X_PFX(hook_run) (x_list * lst, void *arg); +X_EXTERN void X_PFX(hook_free) (x_list * lst); -#endif /* X_HOOK_H */ +#endif /* X_HOOK_H */ diff --git a/xorg-server/hw/xquartz/xpr/x-list.c b/xorg-server/hw/xquartz/xpr/x-list.c index 77c9309aa..757ff4cb0 100644 --- a/xorg-server/hw/xquartz/xpr/x-list.c +++ b/xorg-server/hw/xquartz/xpr/x-list.c @@ -50,57 +50,51 @@ static x_list *freelist; static pthread_mutex_t freelist_lock = PTHREAD_MUTEX_INITIALIZER; static inline void -list_free_1 (x_list *node) +list_free_1(x_list * node) { node->next = freelist; freelist = node; } X_EXTERN void -X_PFX (list_free_1) (x_list *node) -{ - assert (node != NULL); + X_PFX(list_free_1) (x_list * node) { + assert(node != NULL); - pthread_mutex_lock (&freelist_lock); + pthread_mutex_lock(&freelist_lock); - list_free_1 (node); + list_free_1(node); - pthread_mutex_unlock (&freelist_lock); + pthread_mutex_unlock(&freelist_lock); } X_EXTERN void -X_PFX (list_free) (x_list *lst) -{ + X_PFX(list_free) (x_list * lst) { x_list *next; - pthread_mutex_lock (&freelist_lock); + pthread_mutex_lock(&freelist_lock); - for (; lst != NULL; lst = next) - { + for (; lst != NULL; lst = next) { next = lst->next; - list_free_1 (lst); + list_free_1(lst); } - pthread_mutex_unlock (&freelist_lock); + pthread_mutex_unlock(&freelist_lock); } -X_EXTERN x_list * -X_PFX (list_prepend) (x_list *lst, void *data) -{ +X_EXTERN x_list *X_PFX(list_prepend) (x_list * lst, void *data) { x_list *node; - pthread_mutex_lock (&freelist_lock); + pthread_mutex_lock(&freelist_lock); - if (freelist == NULL) - { + if (freelist == NULL) { x_list_block *b; int i; - b = malloc (sizeof (x_list_block)); + b = malloc(sizeof(x_list_block)); assert(b != NULL); for (i = 0; i < NODES_PER_BLOCK - 1; i++) - b->l[i].next = &(b->l[i+1]); + b->l[i].next = &(b->l[i + 1]); b->l[i].next = NULL; freelist = b->l; @@ -109,7 +103,7 @@ X_PFX (list_prepend) (x_list *lst, void *data) node = freelist; freelist = node->next; - pthread_mutex_unlock (&freelist_lock); + pthread_mutex_unlock(&freelist_lock); node->next = lst; node->data = data; @@ -117,29 +111,24 @@ X_PFX (list_prepend) (x_list *lst, void *data) return node; } -X_EXTERN x_list * -X_PFX (list_append) (x_list *lst, void *data) -{ +X_EXTERN x_list *X_PFX(list_append) (x_list * lst, void *data) { x_list *head = lst; if (lst == NULL) - return X_PFX (list_prepend) (NULL, data); + return X_PFX(list_prepend) (NULL, data); while (lst->next != NULL) lst = lst->next; - lst->next = X_PFX (list_prepend) (NULL, data); + lst->next = X_PFX(list_prepend) (NULL, data); return head; } -X_EXTERN x_list * -X_PFX (list_reverse) (x_list *lst) -{ +X_EXTERN x_list *X_PFX(list_reverse) (x_list * lst) { x_list *head = NULL, *next; - - while (lst != NULL) - { + + while (lst != NULL) { next = lst->next; lst->next = head; head = lst; @@ -149,11 +138,8 @@ X_PFX (list_reverse) (x_list *lst) return head; } -X_EXTERN x_list * -X_PFX (list_find) (x_list *lst, void *data) -{ - for (; lst != NULL; lst = lst->next) - { +X_EXTERN x_list *X_PFX(list_find) (x_list * lst, void *data) { + for (; lst != NULL; lst = lst->next) { if (lst->data == data) return lst; } @@ -161,26 +147,22 @@ X_PFX (list_find) (x_list *lst, void *data) return NULL; } -X_EXTERN x_list * -X_PFX (list_nth) (x_list *lst, int n) -{ +X_EXTERN x_list *X_PFX(list_nth) (x_list * lst, int n) { while (n-- > 0 && lst != NULL) lst = lst->next; return lst; } -X_EXTERN x_list * -X_PFX (list_pop) (x_list *lst, void **data_ret) -{ +X_EXTERN x_list *X_PFX(list_pop) (x_list * lst, void **data_ret) { void *data = NULL; - if (lst != NULL) - { + if (lst != NULL) { x_list *tem = lst; + data = lst->data; lst = lst->next; - X_PFX (list_free_1) (tem); + X_PFX(list_free_1) (tem); } if (data_ret != NULL) @@ -189,61 +171,50 @@ X_PFX (list_pop) (x_list *lst, void **data_ret) return lst; } -X_EXTERN x_list * -X_PFX (list_filter) (x_list *lst, - int (*pred) (void *item, void *data), void *data) -{ +X_EXTERN x_list *X_PFX(list_filter) (x_list * lst, + int (*pred) (void *item, void *data), + void *data) { x_list *ret = NULL, *node; - for (node = lst; node != NULL; node = node->next) - { + for (node = lst; node != NULL; node = node->next) { if ((*pred) (node->data, data)) - ret = X_PFX (list_prepend) (ret, node->data); + ret = X_PFX(list_prepend) (ret, node->data); } - return X_PFX (list_reverse) (ret); + return X_PFX(list_reverse) (ret); } -X_EXTERN x_list * -X_PFX (list_map) (x_list *lst, - void *(*fun) (void *item, void *data), void *data) -{ +X_EXTERN x_list *X_PFX(list_map) (x_list * lst, + void *(*fun) (void *item, void *data), + void *data) { x_list *ret = NULL, *node; - for (node = lst; node != NULL; node = node->next) - { - X_PFX (list_prepend) (ret, fun (node->data, data)); + for (node = lst; node != NULL; node = node->next) { + X_PFX(list_prepend) (ret, fun(node->data, data)); } - return X_PFX (list_reverse) (ret); + return X_PFX(list_reverse) (ret); } -X_EXTERN x_list * -X_PFX (list_copy) (x_list *lst) -{ +X_EXTERN x_list *X_PFX(list_copy) (x_list * lst) { x_list *copy = NULL; - for (; lst != NULL; lst = lst->next) - { - copy = X_PFX (list_prepend) (copy, lst->data); + for (; lst != NULL; lst = lst->next) { + copy = X_PFX(list_prepend) (copy, lst->data); } - return X_PFX (list_reverse) (copy); + return X_PFX(list_reverse) (copy); } -X_EXTERN x_list * -X_PFX (list_remove) (x_list *lst, void *data) -{ +X_EXTERN x_list *X_PFX(list_remove) (x_list * lst, void *data) { x_list **ptr, *node; - for (ptr = &lst; *ptr != NULL;) - { + for (ptr = &lst; *ptr != NULL;) { node = *ptr; - if (node->data == data) - { + if (node->data == data) { *ptr = node->next; - X_PFX (list_free_1) (node); + X_PFX(list_free_1) (node); } else ptr = &((*ptr)->next); @@ -253,8 +224,7 @@ X_PFX (list_remove) (x_list *lst, void *data) } X_EXTERN unsigned int -X_PFX (list_length) (x_list *lst) -{ + X_PFX(list_length) (x_list * lst) { unsigned int n; n = 0; @@ -265,19 +235,17 @@ X_PFX (list_length) (x_list *lst) } X_EXTERN void -X_PFX (list_foreach) (x_list *lst, - void (*fun) (void *data, void *user_data), - void *user_data) -{ - for (; lst != NULL; lst = lst->next) - { + +X_PFX(list_foreach) (x_list * lst, + void (*fun) (void *data, void *user_data), + void *user_data) { + for (; lst != NULL; lst = lst->next) { (*fun) (lst->data, user_data); } } static x_list * -list_sort_1 (x_list *lst, int length, - int (*less) (const void *, const void *)) +list_sort_1(x_list * lst, int length, int (*less) (const void *, const void *)) { x_list *mid, *ptr; x_list *out_head, *out; @@ -299,20 +267,19 @@ list_sort_1 (x_list *lst, int length, /* Sort each sub-list. */ - lst = list_sort_1 (lst, mid_point, less); - mid = list_sort_1 (mid, length - mid_point, less); + lst = list_sort_1(lst, mid_point, less); + mid = list_sort_1(mid, length - mid_point, less); /* Then merge them back together. */ - assert (lst != NULL && mid != NULL); + assert(lst != NULL && mid != NULL); if ((*less) (mid->data, lst->data)) out = out_head = mid, mid = mid->next; else out = out_head = lst, lst = lst->next; - while (lst != NULL && mid != NULL) - { + while (lst != NULL && mid != NULL) { if ((*less) (mid->data, lst->data)) out = out->next = mid, mid = mid->next; else @@ -327,12 +294,11 @@ list_sort_1 (x_list *lst, int length, return out_head; } -X_EXTERN x_list * -X_PFX (list_sort) (x_list *lst, int (*less) (const void *, const void *)) -{ +X_EXTERN x_list *X_PFX(list_sort) (x_list * lst, + int (*less) (const void *, const void *)) { int length; - length = X_PFX (list_length) (lst); + length = X_PFX(list_length) (lst); - return list_sort_1 (lst, length, less); + return list_sort_1(lst, length, less); } diff --git a/xorg-server/hw/xquartz/xpr/xprAppleWM.c b/xorg-server/hw/xquartz/xpr/xprAppleWM.c index b6b9a5fc8..77b9fa3e8 100644 --- a/xorg-server/hw/xquartz/xpr/xprAppleWM.c +++ b/xorg-server/hw/xquartz/xpr/xprAppleWM.c @@ -43,9 +43,8 @@ #include "quartz.h" #include "x-hash.h" -static int xprSetWindowLevel( - WindowPtr pWin, - int level) +static int +xprSetWindowLevel(WindowPtr pWin, int level) { xp_window_id wid; xp_window_changes wc; @@ -56,25 +55,25 @@ static int xprSetWindowLevel( if (level < 0 || level >= AppleWMNumWindowLevels) { return BadValue; } - - wid = x_cvt_vptr_to_uint(RootlessFrameForWindow (pWin, TRUE)); + + wid = x_cvt_vptr_to_uint(RootlessFrameForWindow(pWin, TRUE)); if (wid == 0) return BadWindow; - RootlessStopDrawing (pWin, FALSE); + RootlessStopDrawing(pWin, FALSE); winRec = WINREC(pWin); - - if(!winRec) + + if (!winRec) return BadWindow; - - if(XQuartzIsRootless) + + if (XQuartzIsRootless) wc.window_level = normal_window_levels[level]; - else if(XQuartzShieldingWindowLevel) + else if (XQuartzShieldingWindowLevel) wc.window_level = XQuartzShieldingWindowLevel + 1; else wc.window_level = rooted_window_levels[level]; - - if (xp_configure_window (wid, XP_WINDOW_LEVEL, &wc) != Success) { + + if (xp_configure_window(wid, XP_WINDOW_LEVEL, &wc) != Success) { return BadValue; } @@ -84,52 +83,54 @@ static int xprSetWindowLevel( } #if defined(XPLUGIN_VERSION) && XPLUGIN_VERSION >= 3 -static int xprAttachTransient(WindowPtr pWinChild, WindowPtr pWinParent) { - xp_window_id child_wid, parent_wid; +static int +xprAttachTransient(WindowPtr pWinChild, WindowPtr pWinParent) +{ + xp_window_id child_wid, parent_wid; xp_window_changes wc; child_wid = x_cvt_vptr_to_uint(RootlessFrameForWindow(pWinChild, TRUE)); if (child_wid == 0) return BadWindow; - if(pWinParent) { - parent_wid = x_cvt_vptr_to_uint(RootlessFrameForWindow(pWinParent, TRUE)); + if (pWinParent) { + parent_wid = + x_cvt_vptr_to_uint(RootlessFrameForWindow(pWinParent, TRUE)); if (parent_wid == 0) return BadWindow; - } else { + } + else { parent_wid = 0; } - + wc.transient_for = parent_wid; - RootlessStopDrawing (pWinChild, FALSE); + RootlessStopDrawing(pWinChild, FALSE); if (xp_configure_window(child_wid, XP_ATTACH_TRANSIENT, &wc) != Success) { return BadValue; } - return Success; + return Success; } #endif -static int xprFrameDraw( - WindowPtr pWin, - xp_frame_class class, - xp_frame_attr attr, - const BoxRec *outer, - const BoxRec *inner, - unsigned int title_len, - const unsigned char *title_bytes) +static int +xprFrameDraw(WindowPtr pWin, + xp_frame_class class, + xp_frame_attr attr, + const BoxRec * outer, + const BoxRec * inner, + unsigned int title_len, const unsigned char *title_bytes) { xp_window_id wid; - wid = x_cvt_vptr_to_uint(RootlessFrameForWindow (pWin, FALSE)); + wid = x_cvt_vptr_to_uint(RootlessFrameForWindow(pWin, FALSE)); if (wid == 0) return BadWindow; - if (xp_frame_draw (wid, class, attr, outer, inner, - title_len, title_bytes) != Success) - { + if (xp_frame_draw(wid, class, attr, outer, inner, + title_len, title_bytes) != Success) { return BadValue; } @@ -155,8 +156,8 @@ static AppleWMProcsRec xprAppleWMProcs = { #endif }; - -void xprAppleWMInit(void) +void +xprAppleWMInit(void) { AppleWMExtensionInit(&xprAppleWMProcs); } diff --git a/xorg-server/hw/xquartz/xpr/xprCursor.c b/xorg-server/hw/xquartz/xpr/xprCursor.c index 2b31865a5..b0afa8c0e 100644 --- a/xorg-server/hw/xquartz/xpr/xprCursor.c +++ b/xorg-server/hw/xquartz/xpr/xprCursor.c @@ -51,12 +51,13 @@ #include "x-hash.h" typedef struct { - int cursorVisible; - QueryBestSizeProcPtr QueryBestSize; - miPointerSpriteFuncPtr spriteFuncs; + int cursorVisible; + QueryBestSizeProcPtr QueryBestSize; + miPointerSpriteFuncPtr spriteFuncs; } QuartzCursorScreenRec, *QuartzCursorScreenPtr; static DevPrivateKeyRec darwinCursorScreenKeyRec; + #define darwinCursorScreenKey (&darwinCursorScreenKeyRec) #define CURSOR_PRIV(pScreen) ((QuartzCursorScreenPtr) \ @@ -85,22 +86,22 @@ load_cursor(CursorPtr src, int screen) hot_y = src->bits->yhot; #ifdef ARGB_CURSOR - if (src->bits->argb != NULL) - { + if (src->bits->argb != NULL) { #if BITMAP_BIT_ORDER == MSBFirst - rowbytes = src->bits->width * sizeof (CARD32); + rowbytes = src->bits->width * sizeof(CARD32); data = (uint32_t *) src->bits->argb; #else - const uint32_t *be_data=(uint32_t *) src->bits->argb; + const uint32_t *be_data = (uint32_t *) src->bits->argb; unsigned i; - rowbytes = src->bits->width * sizeof (CARD32); + + rowbytes = src->bits->width * sizeof(CARD32); data = malloc(rowbytes * src->bits->height); free_data = TRUE; - if(!data) { + if (!data) { FatalError("Failed to allocate memory in %s\n", __func__); } - for(i=0;i<(src->bits->width*src->bits->height);i++) - data[i]=ntohl(be_data[i]); + for (i = 0; i < (src->bits->width * src->bits->height); i++) + data[i] = ntohl(be_data[i]); #endif } else @@ -123,42 +124,43 @@ load_cursor(CursorPtr src, int screen) rowbytes = ((src->bits->width * 4) + 31) & ~31; data = malloc(rowbytes * src->bits->height); free_data = TRUE; - if(!data) { + if (!data) { FatalError("Failed to allocate memory in %s\n", __func__); } - - if (!src->bits->emptyMask) - { + + if (!src->bits->emptyMask) { ycount = src->bits->height; - srow = src->bits->source; mrow = src->bits->mask; + srow = src->bits->source; + mrow = src->bits->mask; drow = data; - while (ycount-- > 0) - { + while (ycount-- > 0) { xcount = bits_to_bytes(src->bits->width); - sptr = srow; mptr = mrow; + sptr = srow; + mptr = mrow; dptr = drow; - while (xcount-- > 0) - { + while (xcount-- > 0) { uint8_t s, m; int i; - s = *sptr++; m = *mptr++; - for (i = 0; i < 8; i++) - { + s = *sptr++; + m = *mptr++; + for (i = 0; i < 8; i++) { #if BITMAP_BIT_ORDER == MSBFirst if (m & 128) *dptr++ = (s & 128) ? fg_color : bg_color; else *dptr++ = 0; - s <<= 1; m <<= 1; + s <<= 1; + m <<= 1; #else if (m & 1) *dptr++ = (s & 1) ? fg_color : bg_color; else *dptr++ = 0; - s >>= 1; m >>= 1; + s >>= 1; + m >>= 1; #endif } } @@ -168,19 +170,17 @@ load_cursor(CursorPtr src, int screen) drow = (uint32_t *) ((char *) drow + rowbytes); } } - else - { + else { memset(data, 0, src->bits->height * rowbytes); } } err = xp_set_cursor(width, height, hot_x, hot_y, data, rowbytes); - if(free_data) + if (free_data) free(data); return err == Success; } - /* =========================================================================== @@ -196,7 +196,7 @@ load_cursor(CursorPtr src, int screen) static Bool QuartzRealizeCursor(DeviceIntPtr pDev, ScreenPtr pScreen, CursorPtr pCursor) { - if(pCursor == NULL || pCursor->bits == NULL) + if (pCursor == NULL || pCursor->bits == NULL) return FALSE; /* FIXME: cache ARGB8888 representation? */ @@ -204,7 +204,6 @@ QuartzRealizeCursor(DeviceIntPtr pDev, ScreenPtr pScreen, CursorPtr pCursor) return TRUE; } - /* * QuartzUnrealizeCursor * Free the storage space associated with a realized cursor. @@ -215,33 +214,29 @@ QuartzUnrealizeCursor(DeviceIntPtr pDev, ScreenPtr pScreen, CursorPtr pCursor) return TRUE; } - /* * QuartzSetCursor * Set the cursor sprite and position. */ static void -QuartzSetCursor(DeviceIntPtr pDev, ScreenPtr pScreen, CursorPtr pCursor, int x, int y) +QuartzSetCursor(DeviceIntPtr pDev, ScreenPtr pScreen, CursorPtr pCursor, int x, + int y) { QuartzCursorScreenPtr ScreenPriv = CURSOR_PRIV(pScreen); if (!XQuartzServerVisible) return; - if (pCursor == NULL) - { - if (ScreenPriv->cursorVisible) - { + if (pCursor == NULL) { + if (ScreenPriv->cursorVisible) { xp_hide_cursor(); ScreenPriv->cursorVisible = FALSE; } } - else - { + else { load_cursor(pCursor, pScreen->myNum); - if (!ScreenPriv->cursorVisible) - { + if (!ScreenPriv->cursorVisible) { xp_show_cursor(); ScreenPriv->cursorVisible = TRUE; } @@ -274,7 +269,6 @@ QuartzCursorOffScreen(ScreenPtr *pScreen, int *x, int *y) return FALSE; } - /* * QuartzCrossScreen */ @@ -284,7 +278,6 @@ QuartzCrossScreen(ScreenPtr pScreen, Bool entering) return; } - /* * QuartzWarpCursor * Change the cursor position without generating an event or motion history. @@ -294,8 +287,7 @@ QuartzCrossScreen(ScreenPtr pScreen, Bool entering) static void QuartzWarpCursor(DeviceIntPtr pDev, ScreenPtr pScreen, int x, int y) { - if (XQuartzServerVisible) - { + if (XQuartzServerVisible) { int sx, sy; sx = pScreen->x + darwinMainScreenX; @@ -308,7 +300,6 @@ QuartzWarpCursor(DeviceIntPtr pDev, ScreenPtr pScreen, int x, int y) miPointerUpdateSprite(pDev); } - static miPointerScreenFuncRec quartzScreenFuncsRec = { QuartzCursorOffScreen, QuartzCrossScreen, @@ -317,7 +308,6 @@ static miPointerScreenFuncRec quartzScreenFuncsRec = { NULL }; - /* =========================================================================== @@ -336,15 +326,13 @@ QuartzCursorQueryBestSize(int class, unsigned short *width, { QuartzCursorScreenPtr ScreenPriv = CURSOR_PRIV(pScreen); - if (class == CursorShape) - { + if (class == CursorShape) { /* FIXME: query window server? */ *width = 32; *height = 32; } - else - { - (*ScreenPriv->QueryBestSize)(class, width, height, pScreen); + else { + (*ScreenPriv->QueryBestSize) (class, width, height, pScreen); } } @@ -363,7 +351,7 @@ QuartzInitCursor(ScreenPtr pScreen) return FALSE; if (!dixRegisterPrivateKey(&darwinCursorScreenKeyRec, PRIVATE_SCREEN, 0)) - return FALSE; + return FALSE; ScreenPriv = calloc(1, sizeof(QuartzCursorScreenRec)); if (ScreenPriv == NULL) @@ -384,7 +372,7 @@ QuartzInitCursor(ScreenPtr pScreen) PointPriv->spriteFuncs->UnrealizeCursor = QuartzUnrealizeCursor; PointPriv->spriteFuncs->SetCursor = QuartzSetCursor; PointPriv->spriteFuncs->MoveCursor = QuartzMoveCursor; - + ScreenPriv->cursorVisible = TRUE; return TRUE; } @@ -398,7 +386,6 @@ QuartzSuspendXCursor(ScreenPtr pScreen) { } - /* * QuartzResumeXCursor * X server is showing. Restore the X cursor. @@ -410,7 +397,7 @@ QuartzResumeXCursor(ScreenPtr pScreen) CursorPtr pCursor; /* TODO: Tablet? */ - + pWin = GetSpriteWindow(darwinPointer); if (pWin->drawable.pScreen != pScreen) return; diff --git a/xorg-server/hw/xquartz/xpr/xprEvent.c b/xorg-server/hw/xquartz/xpr/xprEvent.c index 4e7ece64f..7f4b077c3 100644 --- a/xorg-server/hw/xquartz/xpr/xprEvent.c +++ b/xorg-server/hw/xquartz/xpr/xprEvent.c @@ -55,24 +55,25 @@ #include "rootlessWindow.h" #include "xprEvent.h" -Bool QuartzModeEventHandler(int screenNum, XQuartzEvent *e, DeviceIntPtr dev) { - switch(e->subtype) { - case kXquartzWindowState: - DEBUG_LOG("kXquartzWindowState\n"); - RootlessNativeWindowStateChanged(xprGetXWindow(e->data[0]), - e->data[1]); - return TRUE; - - case kXquartzWindowMoved: - DEBUG_LOG("kXquartzWindowMoved\n"); - RootlessNativeWindowMoved(xprGetXWindow(e->data[0])); - return TRUE; - - case kXquartzBringAllToFront: - DEBUG_LOG("kXquartzBringAllToFront\n"); - RootlessOrderAllWindows(e->data[0]); - return TRUE; - default: - return FALSE; +Bool +QuartzModeEventHandler(int screenNum, XQuartzEvent * e, DeviceIntPtr dev) +{ + switch (e->subtype) { + case kXquartzWindowState: + DEBUG_LOG("kXquartzWindowState\n"); + RootlessNativeWindowStateChanged(xprGetXWindow(e->data[0]), e->data[1]); + return TRUE; + + case kXquartzWindowMoved: + DEBUG_LOG("kXquartzWindowMoved\n"); + RootlessNativeWindowMoved(xprGetXWindow(e->data[0])); + return TRUE; + + case kXquartzBringAllToFront: + DEBUG_LOG("kXquartzBringAllToFront\n"); + RootlessOrderAllWindows(e->data[0]); + return TRUE; + default: + return FALSE; } } diff --git a/xorg-server/hw/xquartz/xpr/xprFrame.c b/xorg-server/hw/xquartz/xpr/xprFrame.c index 98f1cc3ed..ed81c4b48 100644 --- a/xorg-server/hw/xquartz/xpr/xprFrame.c +++ b/xorg-server/hw/xquartz/xpr/xprFrame.c @@ -73,37 +73,51 @@ static pthread_rwlock_t window_hash_rwlock; #endif /* Prototypes for static functions */ -static Bool xprCreateFrame(RootlessWindowPtr pFrame, ScreenPtr pScreen, +static Bool +xprCreateFrame(RootlessWindowPtr pFrame, ScreenPtr pScreen, int newX, int newY, RegionPtr pShape); -static void xprDestroyFrame(RootlessFrameID wid); -static void xprMoveFrame(RootlessFrameID wid, ScreenPtr pScreen, int newX, int newY); -static void xprResizeFrame(RootlessFrameID wid, ScreenPtr pScreen, +static void +xprDestroyFrame(RootlessFrameID wid); +static void +xprMoveFrame(RootlessFrameID wid, ScreenPtr pScreen, int newX, int newY); +static void +xprResizeFrame(RootlessFrameID wid, ScreenPtr pScreen, int newX, int newY, unsigned int newW, unsigned int newH, unsigned int gravity); -static void xprRestackFrame(RootlessFrameID wid, RootlessFrameID nextWid); -static void xprReshapeFrame(RootlessFrameID wid, RegionPtr pShape); -static void xprUnmapFrame(RootlessFrameID wid); -static void xprStartDrawing(RootlessFrameID wid, char **pixelData, int *bytesPerRow); -static void xprStopDrawing(RootlessFrameID wid, Bool flush); -static void xprUpdateRegion(RootlessFrameID wid, RegionPtr pDamage); -static void xprDamageRects(RootlessFrameID wid, int nrects, const BoxRec *rects, +static void +xprRestackFrame(RootlessFrameID wid, RootlessFrameID nextWid); +static void +xprReshapeFrame(RootlessFrameID wid, RegionPtr pShape); +static void +xprUnmapFrame(RootlessFrameID wid); +static void +xprStartDrawing(RootlessFrameID wid, char **pixelData, int *bytesPerRow); +static void +xprStopDrawing(RootlessFrameID wid, Bool flush); +static void +xprUpdateRegion(RootlessFrameID wid, RegionPtr pDamage); +static void +xprDamageRects(RootlessFrameID wid, int nrects, const BoxRec * rects, int shift_x, int shift_y); -static void xprSwitchWindow(RootlessWindowPtr pFrame, WindowPtr oldWin); -static Bool xprDoReorderWindow(RootlessWindowPtr pFrame); -static void xprHideWindow(RootlessFrameID wid); -static void xprUpdateColormap(RootlessFrameID wid, ScreenPtr pScreen); -static void xprCopyWindow(RootlessFrameID wid, int dstNrects, const BoxRec *dstRects, +static void +xprSwitchWindow(RootlessWindowPtr pFrame, WindowPtr oldWin); +static Bool +xprDoReorderWindow(RootlessWindowPtr pFrame); +static void +xprHideWindow(RootlessFrameID wid); +static void +xprUpdateColormap(RootlessFrameID wid, ScreenPtr pScreen); +static void +xprCopyWindow(RootlessFrameID wid, int dstNrects, const BoxRec * dstRects, int dx, int dy); - static inline xp_error xprConfigureWindow(xp_window_id id, unsigned int mask, - const xp_window_changes *values) + const xp_window_changes * values) { return xp_configure_window(id, mask, values); } - static void xprSetNativeProperty(RootlessWindowPtr pFrame) { @@ -112,20 +126,22 @@ xprSetNativeProperty(RootlessWindowPtr pFrame) long data; err = xp_get_native_window(x_cvt_vptr_to_uint(pFrame->wid), &native_id); - if (err == Success) - { + if (err == Success) { /* FIXME: move this to AppleWM extension */ data = native_id; - dixChangeWindowProperty(serverClient, pFrame->win, xa_native_window_id(), - XA_INTEGER, 32, PropModeReplace, 1, &data, TRUE); + dixChangeWindowProperty(serverClient, pFrame->win, + xa_native_window_id(), XA_INTEGER, 32, + PropModeReplace, 1, &data, TRUE); } } static xp_error -xprColormapCallback(void *data, int first_color, int n_colors, uint32_t *colors) +xprColormapCallback(void *data, int first_color, int n_colors, + uint32_t * colors) { - return (RootlessResolveColormap (data, first_color, n_colors, colors) ? XP_Success : XP_BadMatch); + return (RootlessResolveColormap(data, first_color, n_colors, colors) ? + XP_Success : XP_BadMatch); } /* @@ -147,8 +163,7 @@ xprCreateFrame(RootlessWindowPtr pFrame, ScreenPtr pScreen, wc.bit_gravity = XP_GRAVITY_NONE; mask |= XP_BOUNDS; - if (pWin->drawable.depth == 8) - { + if (pWin->drawable.depth == 8) { wc.depth = XP_DEPTH_INDEX8; wc.colormap = xprColormapCallback; wc.colormap_data = pScreen; @@ -162,35 +177,34 @@ xprCreateFrame(RootlessWindowPtr pFrame, ScreenPtr pScreen, wc.depth = XP_DEPTH_NIL; mask |= XP_DEPTH; - if (pShape != NULL) - { + if (pShape != NULL) { wc.shape_nrects = RegionNumRects(pShape); wc.shape_rects = RegionRects(pShape); wc.shape_tx = wc.shape_ty = 0; mask |= XP_SHAPE; } - pFrame->level = !IsRoot (pWin) ? AppleWMWindowLevelNormal : AppleWMNumWindowLevels; + pFrame->level = + !IsRoot(pWin) ? AppleWMWindowLevelNormal : AppleWMNumWindowLevels; - if(XQuartzIsRootless) + if (XQuartzIsRootless) wc.window_level = normal_window_levels[pFrame->level]; - else if(XQuartzShieldingWindowLevel) + else if (XQuartzShieldingWindowLevel) wc.window_level = XQuartzShieldingWindowLevel + 1; else wc.window_level = rooted_window_levels[pFrame->level]; mask |= XP_WINDOW_LEVEL; - err = xp_create_window(mask, &wc, (xp_window_id *) &pFrame->wid); + err = xp_create_window(mask, &wc, (xp_window_id *) & pFrame->wid); - if (err != Success) - { + if (err != Success) { return FALSE; } #ifdef HAVE_LIBDISPATCH - dispatch_async(window_hash_serial_q, ^{ - x_hash_table_insert(window_hash, pFrame->wid, pFrame); - }); + dispatch_async(window_hash_serial_q, ^ { + x_hash_table_insert(window_hash, pFrame->wid, pFrame);} + ); #else pthread_rwlock_wrlock(&window_hash_rwlock); x_hash_table_insert(window_hash, pFrame->wid, pFrame); @@ -202,7 +216,6 @@ xprCreateFrame(RootlessWindowPtr pFrame, ScreenPtr pScreen, return TRUE; } - /* * Destroy a frame. */ @@ -212,9 +225,8 @@ xprDestroyFrame(RootlessFrameID wid) xp_error err; #ifdef HAVE_LIBDISPATCH - dispatch_async(window_hash_serial_q, ^{ - x_hash_table_remove(window_hash, wid); - }); + dispatch_async(window_hash_serial_q, ^ { + x_hash_table_remove(window_hash, wid);}); #else pthread_rwlock_wrlock(&window_hash_rwlock); x_hash_table_remove(window_hash, wid); @@ -223,10 +235,10 @@ xprDestroyFrame(RootlessFrameID wid) err = xp_destroy_window(x_cvt_vptr_to_uint(wid)); if (err != Success) - FatalError("Could not destroy window %d (%d).", (int)x_cvt_vptr_to_uint(wid), (int)err); + FatalError("Could not destroy window %d (%d).", + (int) x_cvt_vptr_to_uint(wid), (int) err); } - /* * Move a frame on screen. */ @@ -241,7 +253,6 @@ xprMoveFrame(RootlessFrameID wid, ScreenPtr pScreen, int newX, int newY) xprConfigureWindow(x_cvt_vptr_to_uint(wid), XP_ORIGIN, &wc); } - /* * Resize and move a frame. */ @@ -264,43 +275,46 @@ xprResizeFrame(RootlessFrameID wid, ScreenPtr pScreen, xprConfigureWindow(x_cvt_vptr_to_uint(wid), XP_BOUNDS, &wc); } - /* * Change frame stacking. */ -static void xprRestackFrame(RootlessFrameID wid, RootlessFrameID nextWid) { +static void +xprRestackFrame(RootlessFrameID wid, RootlessFrameID nextWid) +{ xp_window_changes wc; unsigned int mask = XP_STACKING; + #ifdef HAVE_LIBDISPATCH __block #endif - RootlessWindowRec *winRec; + RootlessWindowRec * winRec; /* Stack frame below nextWid it if it exists, or raise frame above everything otherwise. */ - if(nextWid == NULL) { + if (nextWid == NULL) { wc.stack_mode = XP_MAPPED_ABOVE; wc.sibling = 0; - } else { + } + else { wc.stack_mode = XP_MAPPED_BELOW; wc.sibling = x_cvt_vptr_to_uint(nextWid); } #ifdef HAVE_LIBDISPATCH - dispatch_sync(window_hash_serial_q, ^{ - winRec = x_hash_table_lookup(window_hash, wid, NULL); - }); + dispatch_sync(window_hash_serial_q, ^ { + winRec = x_hash_table_lookup(window_hash, wid, NULL);} + ); #else pthread_rwlock_rdlock(&window_hash_rwlock); winRec = x_hash_table_lookup(window_hash, wid, NULL); pthread_rwlock_unlock(&window_hash_rwlock); #endif - - if(winRec) { - if(XQuartzIsRootless) + + if (winRec) { + if (XQuartzIsRootless) wc.window_level = normal_window_levels[winRec->level]; - else if(XQuartzShieldingWindowLevel) + else if (XQuartzShieldingWindowLevel) wc.window_level = XQuartzShieldingWindowLevel + 1; else wc.window_level = rooted_window_levels[winRec->level]; @@ -310,7 +324,6 @@ static void xprRestackFrame(RootlessFrameID wid, RootlessFrameID nextWid) { xprConfigureWindow(x_cvt_vptr_to_uint(wid), mask, &wc); } - /* * Change the frame's shape. */ @@ -319,13 +332,11 @@ xprReshapeFrame(RootlessFrameID wid, RegionPtr pShape) { xp_window_changes wc; - if (pShape != NULL) - { + if (pShape != NULL) { wc.shape_nrects = RegionNumRects(pShape); wc.shape_rects = RegionRects(pShape); } - else - { + else { wc.shape_nrects = -1; wc.shape_rects = NULL; } @@ -335,7 +346,6 @@ xprReshapeFrame(RootlessFrameID wid, RegionPtr pShape) xprConfigureWindow(x_cvt_vptr_to_uint(wid), XP_SHAPE, &wc); } - /* * Unmap a frame. */ @@ -350,7 +360,6 @@ xprUnmapFrame(RootlessFrameID wid) xprConfigureWindow(x_cvt_vptr_to_uint(wid), XP_STACKING, &wc); } - /* * Start drawing to a frame. * Prepare for direct access to its backing buffer. @@ -362,15 +371,17 @@ xprStartDrawing(RootlessFrameID wid, char **pixelData, int *bytesPerRow) unsigned int rowbytes[2]; xp_error err; - err = xp_lock_window(x_cvt_vptr_to_uint(wid), NULL, NULL, data, rowbytes, NULL); + err = + xp_lock_window(x_cvt_vptr_to_uint(wid), NULL, NULL, data, rowbytes, + NULL); if (err != Success) - FatalError("Could not lock window %d for drawing (%d).", (int)x_cvt_vptr_to_uint(wid), (int)err); + FatalError("Could not lock window %d for drawing (%d).", + (int) x_cvt_vptr_to_uint(wid), (int) err); *pixelData = data[0]; *bytesPerRow = rowbytes[0]; } - /* * Stop drawing to a frame. */ @@ -383,11 +394,11 @@ xprStopDrawing(RootlessFrameID wid, Bool flush) /* This should be a FatalError, but we started tripping over it. Make it a * FatalError after http://xquartz.macosforge.org/trac/ticket/482 is fixed. */ - if(err != Success) - ErrorF("Could not unlock window %d after drawing (%d).", (int)x_cvt_vptr_to_uint(wid), (int)err); + if (err != Success) + ErrorF("Could not unlock window %d after drawing (%d).", + (int) x_cvt_vptr_to_uint(wid), (int) err); } - /* * Flush drawing updates to the screen. */ @@ -397,18 +408,16 @@ xprUpdateRegion(RootlessFrameID wid, RegionPtr pDamage) xp_flush_window(x_cvt_vptr_to_uint(wid)); } - /* * Mark damaged rectangles as requiring redisplay to screen. */ static void -xprDamageRects(RootlessFrameID wid, int nrects, const BoxRec *rects, +xprDamageRects(RootlessFrameID wid, int nrects, const BoxRec * rects, int shift_x, int shift_y) { xp_mark_window(x_cvt_vptr_to_uint(wid), nrects, rects, shift_x, shift_y); } - /* * Called after the window associated with a frame has been switched * to a new top-level parent. @@ -421,31 +430,29 @@ xprSwitchWindow(RootlessWindowPtr pFrame, WindowPtr oldWin) xprSetNativeProperty(pFrame); } - /* * Called to check if the frame should be reordered when it is restacked. */ -static Bool xprDoReorderWindow(RootlessWindowPtr pFrame) +static Bool +xprDoReorderWindow(RootlessWindowPtr pFrame) { WindowPtr pWin = pFrame->win; return AppleWMDoReorderWindow(pWin); } - /* * Copy area in frame to another part of frame. * Used to accelerate scrolling. */ static void -xprCopyWindow(RootlessFrameID wid, int dstNrects, const BoxRec *dstRects, +xprCopyWindow(RootlessFrameID wid, int dstNrects, const BoxRec * dstRects, int dx, int dy) { xp_copy_window(x_cvt_vptr_to_uint(wid), x_cvt_vptr_to_uint(wid), dstNrects, dstRects, dx, dy); } - static RootlessFrameProcsRec xprRootlessProcs = { xprCreateFrame, xprDestroyFrame, @@ -466,7 +473,6 @@ static RootlessFrameProcsRec xprRootlessProcs = { xprCopyWindow }; - /* * Initialize XPR implementation */ @@ -480,15 +486,16 @@ xprInit(ScreenPtr pScreen) assert((window_hash = x_hash_table_new(NULL, NULL, NULL, NULL))); #ifdef HAVE_LIBDISPATCH - assert((window_hash_serial_q = dispatch_queue_create(BUNDLE_ID_PREFIX".X11.xpr_window_hash", NULL))); + assert((window_hash_serial_q = + dispatch_queue_create(BUNDLE_ID_PREFIX ".X11.xpr_window_hash", + NULL))); #else assert(0 == pthread_rwlock_init(&window_hash_rwlock, NULL)); #endif - + return TRUE; } - /* * Given the id of a physical window, try to find the top-level (or root) * X window that it represents. @@ -498,11 +505,14 @@ xprGetXWindow(xp_window_id wid) { #ifdef HAVE_LIBDISPATCH RootlessWindowRec *winRec __block; - dispatch_sync(window_hash_serial_q, ^{ - winRec = x_hash_table_lookup(window_hash, x_cvt_uint_to_vptr(wid), NULL); - }); + + dispatch_sync(window_hash_serial_q, ^ { + winRec = + x_hash_table_lookup(window_hash, x_cvt_uint_to_vptr(wid), + NULL);}); #else RootlessWindowRec *winRec; + pthread_rwlock_rdlock(&window_hash_rwlock); winRec = x_hash_table_lookup(window_hash, x_cvt_uint_to_vptr(wid), NULL); pthread_rwlock_unlock(&window_hash_rwlock); @@ -529,7 +539,6 @@ xprIsX11Window(int windowNumber) return ret; } - /* * xprHideWindows * Hide or unhide all top level windows. This is called for application hide/ @@ -544,6 +553,7 @@ xprHideWindows(Bool hide) for (screen = 0; screen < screenInfo.numScreens; screen++) { RootlessFrameID prevWid = NULL; + pRoot = screenInfo.screens[screen]->root; for (pWin = pRoot->firstChild; pWin; pWin = pWin->nextSib) { @@ -552,7 +562,8 @@ xprHideWindows(Bool hide) if (winRec != NULL) { if (hide) { xprUnmapFrame(winRec->wid); - } else { + } + else { BoxRec box; xprRestackFrame(winRec->wid, prevWid); @@ -577,32 +588,35 @@ xprHideWindows(Bool hide) Bool no_configure_window; static inline int -configure_window (xp_window_id id, unsigned int mask, - const xp_window_changes *values) +configure_window(xp_window_id id, unsigned int mask, + const xp_window_changes * values) { - if (!no_configure_window) - return xp_configure_window (id, mask, values); - else - return XP_Success; + if (!no_configure_window) + return xp_configure_window(id, mask, values); + else + return XP_Success; } - static -void xprUpdateColormap(RootlessFrameID wid, ScreenPtr pScreen) + void +xprUpdateColormap(RootlessFrameID wid, ScreenPtr pScreen) { - /* This is how we tell xp that the colormap may have changed. */ - xp_window_changes wc; - wc.colormap = xprColormapCallback; - wc.colormap_data = pScreen; + /* This is how we tell xp that the colormap may have changed. */ + xp_window_changes wc; - configure_window(MAKE_WINDOW_ID(wid), XP_COLORMAP, &wc); + wc.colormap = xprColormapCallback; + wc.colormap_data = pScreen; + + configure_window(MAKE_WINDOW_ID(wid), XP_COLORMAP, &wc); } static -void xprHideWindow(RootlessFrameID wid) + void +xprHideWindow(RootlessFrameID wid) { - xp_window_changes wc; - wc.stack_mode = XP_UNMAPPED; - wc.sibling = 0; - configure_window(MAKE_WINDOW_ID(wid), XP_STACKING, &wc); + xp_window_changes wc; + + wc.stack_mode = XP_UNMAPPED; + wc.sibling = 0; + configure_window(MAKE_WINDOW_ID(wid), XP_STACKING, &wc); } diff --git a/xorg-server/hw/xquartz/xpr/xprScreen.c b/xorg-server/hw/xquartz/xpr/xprScreen.c index 002355eca..185369e6b 100644 --- a/xorg-server/hw/xquartz/xpr/xprScreen.c +++ b/xorg-server/hw/xquartz/xpr/xprScreen.c @@ -51,7 +51,7 @@ #include "rootlessCommon.h" #ifdef DAMAGE -# include "damage.h" +#include "damage.h" #endif /* 10.4's deferred update makes X slower.. have to live with the tearing @@ -65,61 +65,67 @@ static const char *xprOpenGLBundle = "glxCGL.bundle"; * eventHandler * Callback handler for Xplugin events. */ -static void eventHandler(unsigned int type, const void *arg, - unsigned int arg_size, void *data) { - +static void +eventHandler(unsigned int type, const void *arg, + unsigned int arg_size, void *data) +{ + switch (type) { - case XP_EVENT_DISPLAY_CHANGED: - DEBUG_LOG("XP_EVENT_DISPLAY_CHANGED\n"); - DarwinSendDDXEvent(kXquartzDisplayChanged, 0); - break; - - case XP_EVENT_WINDOW_STATE_CHANGED: - if (arg_size >= sizeof(xp_window_state_event)) { - const xp_window_state_event *ws_arg = arg; - - DEBUG_LOG("XP_EVENT_WINDOW_STATE_CHANGED: id=%d, state=%d\n", ws_arg->id, ws_arg->state); - DarwinSendDDXEvent(kXquartzWindowState, 2, - ws_arg->id, ws_arg->state); - } else { - DEBUG_LOG("XP_EVENT_WINDOW_STATE_CHANGED: ignored\n"); - } - break; - - case XP_EVENT_WINDOW_MOVED: - DEBUG_LOG("XP_EVENT_WINDOW_MOVED\n"); - if (arg_size == sizeof(xp_window_id)) { - xp_window_id id = * (xp_window_id *) arg; - DarwinSendDDXEvent(kXquartzWindowMoved, 1, id); - } - break; - - case XP_EVENT_SURFACE_DESTROYED: - DEBUG_LOG("XP_EVENT_SURFACE_DESTROYED\n"); - case XP_EVENT_SURFACE_CHANGED: - DEBUG_LOG("XP_EVENT_SURFACE_CHANGED\n"); - if (arg_size == sizeof(xp_surface_id)) { - int kind; - - if (type == XP_EVENT_SURFACE_DESTROYED) - kind = AppleDRISurfaceNotifyDestroyed; - else - kind = AppleDRISurfaceNotifyChanged; - - DRISurfaceNotify(*(xp_surface_id *) arg, kind); - } - break; + case XP_EVENT_DISPLAY_CHANGED: + DEBUG_LOG("XP_EVENT_DISPLAY_CHANGED\n"); + DarwinSendDDXEvent(kXquartzDisplayChanged, 0); + break; + + case XP_EVENT_WINDOW_STATE_CHANGED: + if (arg_size >= sizeof(xp_window_state_event)) { + const xp_window_state_event *ws_arg = arg; + + DEBUG_LOG("XP_EVENT_WINDOW_STATE_CHANGED: id=%d, state=%d\n", + ws_arg->id, ws_arg->state); + DarwinSendDDXEvent(kXquartzWindowState, 2, ws_arg->id, + ws_arg->state); + } + else { + DEBUG_LOG("XP_EVENT_WINDOW_STATE_CHANGED: ignored\n"); + } + break; + + case XP_EVENT_WINDOW_MOVED: + DEBUG_LOG("XP_EVENT_WINDOW_MOVED\n"); + if (arg_size == sizeof(xp_window_id)) { + xp_window_id id = *(xp_window_id *) arg; + + DarwinSendDDXEvent(kXquartzWindowMoved, 1, id); + } + break; + + case XP_EVENT_SURFACE_DESTROYED: + DEBUG_LOG("XP_EVENT_SURFACE_DESTROYED\n"); + case XP_EVENT_SURFACE_CHANGED: + DEBUG_LOG("XP_EVENT_SURFACE_CHANGED\n"); + if (arg_size == sizeof(xp_surface_id)) { + int kind; + + if (type == XP_EVENT_SURFACE_DESTROYED) + kind = AppleDRISurfaceNotifyDestroyed; + else + kind = AppleDRISurfaceNotifyChanged; + + DRISurfaceNotify(*(xp_surface_id *) arg, kind); + } + break; #ifdef XP_EVENT_SPACE_CHANGED - case XP_EVENT_SPACE_CHANGED: - DEBUG_LOG("XP_EVENT_SPACE_CHANGED\n"); - if(arg_size == sizeof(uint32_t)) { - uint32_t space_id = *(uint32_t *)arg; - DarwinSendDDXEvent(kXquartzSpaceChanged, 1, space_id); - } - break; + case XP_EVENT_SPACE_CHANGED: + DEBUG_LOG("XP_EVENT_SPACE_CHANGED\n"); + if (arg_size == sizeof(uint32_t)) { + uint32_t space_id = *(uint32_t *) arg; + + DarwinSendDDXEvent(kXquartzSpaceChanged, 1, space_id); + } + break; #endif - default: - ErrorF("Unknown XP_EVENT type (%d) in xprScreen:eventHandler\n", type); + default: + ErrorF("Unknown XP_EVENT type (%d) in xprScreen:eventHandler\n", type); } } @@ -132,7 +138,7 @@ displayAtIndex(int index) { CGError err; CGDisplayCount cnt; - CGDirectDisplayID dpy[index+1]; + CGDirectDisplayID dpy[index + 1]; err = CGGetActiveDisplayList(index + 1, dpy, &cnt); if (err == kCGErrorSuccess && cnt == index + 1) @@ -153,19 +159,18 @@ displayScreenBounds(CGDirectDisplayID id) frame = CGDisplayBounds(id); DEBUG_LOG(" %dx%d @ (%d,%d).\n", - (int)frame.size.width, (int)frame.size.height, - (int)frame.origin.x, (int)frame.origin.y); - + (int) frame.size.width, (int) frame.size.height, + (int) frame.origin.x, (int) frame.origin.y); + /* Remove menubar to help standard X11 window managers. */ - if (XQuartzIsRootless && - frame.origin.x == 0 && frame.origin.y == 0) { + if (XQuartzIsRootless && frame.origin.x == 0 && frame.origin.y == 0) { frame.origin.y += aquaMenuBarHeight; frame.size.height -= aquaMenuBarHeight; } DEBUG_LOG(" %dx%d @ (%d,%d).\n", - (int)frame.size.width, (int)frame.size.height, - (int)frame.origin.x, (int)frame.origin.y); + (int) frame.size.width, (int) frame.size.height, + (int) frame.origin.x, (int) frame.origin.y); return frame; } @@ -176,7 +181,8 @@ displayScreenBounds(CGDirectDisplayID id) * with PseudoramiX. */ static void -xprAddPseudoramiXScreens(int *x, int *y, int *width, int *height, ScreenPtr pScreen) +xprAddPseudoramiXScreens(int *x, int *y, int *width, int *height, + ScreenPtr pScreen) { CGDisplayCount i, displayCount; CGDirectDisplayID *displayList = NULL; @@ -184,10 +190,11 @@ xprAddPseudoramiXScreens(int *x, int *y, int *width, int *height, ScreenPtr pScr // Find all the CoreGraphics displays CGGetActiveDisplayList(0, NULL, &displayCount); - DEBUG_LOG("displayCount: %d\n", (int)displayCount); + DEBUG_LOG("displayCount: %d\n", (int) displayCount); - if(!displayCount) { - ErrorF("CoreGraphics has reported no connected displays. Creating a stub 800x600 display.\n"); + if (!displayCount) { + ErrorF + ("CoreGraphics has reported no connected displays. Creating a stub 800x600 display.\n"); *x = *y = 0; *width = 800; *height = 600; @@ -204,7 +211,7 @@ xprAddPseudoramiXScreens(int *x, int *y, int *width, int *height, ScreenPtr pScr displayCount = 1; displayList = malloc(displayCount * sizeof(CGDirectDisplayID)); - if(!displayList) + if (!displayList) FatalError("Unable to allocate memory for list of displays.\n"); CGGetActiveDisplayList(displayCount, displayList, &displayCount); QuartzCopyDisplayIDs(pScreen, displayCount, displayList); @@ -212,6 +219,7 @@ xprAddPseudoramiXScreens(int *x, int *y, int *width, int *height, ScreenPtr pScr /* Get the union of all screens */ for (i = 0; i < displayCount; i++) { CGDirectDisplayID dpy = displayList[i]; + frame = displayScreenBounds(dpy); unionRect = CGRectUnion(unionRect, frame); } @@ -226,8 +234,7 @@ xprAddPseudoramiXScreens(int *x, int *y, int *width, int *height, ScreenPtr pScr *x, *y, *width, *height); /* Tell PseudoramiX about the real screens. */ - for (i = 0; i < displayCount; i++) - { + for (i = 0; i < displayCount; i++) { CGDirectDisplayID dpy = displayList[i]; frame = displayScreenBounds(dpy); @@ -235,7 +242,7 @@ xprAddPseudoramiXScreens(int *x, int *y, int *width, int *height, ScreenPtr pScr frame.origin.y -= unionRect.origin.y; DEBUG_LOG(" placed at X11 coordinate (%d,%d).\n", - (int)frame.origin.x, (int)frame.origin.y); + (int) frame.origin.x, (int) frame.origin.y); PseudoramiXAddScreen(frame.origin.x, frame.origin.y, frame.size.width, frame.size.height); @@ -263,20 +270,18 @@ xprDisplayInit(void) if (noPseudoramiXExtension) darwinScreensFound = displayCount; else - darwinScreensFound = 1; + darwinScreensFound = 1; if (xp_init(XP_BACKGROUND_EVENTS | XP_NO_DEFERRED_UPDATES) != Success) FatalError("Could not initialize the Xplugin library."); xp_select_events(XP_EVENT_DISPLAY_CHANGED - | XP_EVENT_WINDOW_STATE_CHANGED - | XP_EVENT_WINDOW_MOVED + | XP_EVENT_WINDOW_STATE_CHANGED | XP_EVENT_WINDOW_MOVED #ifdef XP_EVENT_SPACE_CHANGED | XP_EVENT_SPACE_CHANGED #endif | XP_EVENT_SURFACE_CHANGED - | XP_EVENT_SURFACE_DESTROYED, - eventHandler, NULL); + | XP_EVENT_SURFACE_DESTROYED, eventHandler, NULL); AppleDRIExtensionInit(); xprAppleWMInit(); @@ -297,81 +302,92 @@ xprAddScreen(int index, ScreenPtr pScreen) int depth = darwinDesiredDepth; DEBUG_LOG("index=%d depth=%d\n", index, depth); - - if(depth == -1) { + + if (depth == -1) { #if MAC_OS_X_VERSION_MIN_REQUIRED < 1060 - depth = CGDisplaySamplesPerPixel(kCGDirectMainDisplay) * CGDisplayBitsPerSample(kCGDirectMainDisplay); + depth = + CGDisplaySamplesPerPixel(kCGDirectMainDisplay) * + CGDisplayBitsPerSample(kCGDirectMainDisplay); #else CGDisplayModeRef modeRef; CFStringRef encStrRef; - + modeRef = CGDisplayCopyDisplayMode(kCGDirectMainDisplay); - if(!modeRef) + if (!modeRef) goto have_depth; encStrRef = CGDisplayModeCopyPixelEncoding(modeRef); CFRelease(modeRef); - if(!encStrRef) + if (!encStrRef) goto have_depth; - - if(CFStringCompare(encStrRef, CFSTR(IO32BitDirectPixels), kCFCompareCaseInsensitive) == kCFCompareEqualTo) { + + if (CFStringCompare + (encStrRef, CFSTR(IO32BitDirectPixels), + kCFCompareCaseInsensitive) == kCFCompareEqualTo) { depth = 24; - } else if(CFStringCompare(encStrRef, CFSTR(IO16BitDirectPixels), kCFCompareCaseInsensitive) == kCFCompareEqualTo) { + } + else if (CFStringCompare + (encStrRef, CFSTR(IO16BitDirectPixels), + kCFCompareCaseInsensitive) == kCFCompareEqualTo) { depth = 15; - } else if(CFStringCompare(encStrRef, CFSTR(IO8BitIndexedPixels), kCFCompareCaseInsensitive) == kCFCompareEqualTo) { + } + else if (CFStringCompare + (encStrRef, CFSTR(IO8BitIndexedPixels), + kCFCompareCaseInsensitive) == kCFCompareEqualTo) { depth = 8; } CFRelease(encStrRef); #endif } - + #if MAC_OS_X_VERSION_MIN_REQUIRED >= 1060 -have_depth: + have_depth: #endif - switch(depth) { - case 8: // pseudo-working - dfb->visuals = PseudoColorMask; - dfb->preferredCVC = PseudoColor; - dfb->depth = 8; - dfb->bitsPerRGB = 8; - dfb->bitsPerPixel = 8; - dfb->redMask = 0; - dfb->greenMask = 0; - dfb->blueMask = 0; - break; - case 15: - dfb->visuals = TrueColorMask; //LARGE_VISUALS; - dfb->preferredCVC = TrueColor; - dfb->depth = 15; - dfb->bitsPerRGB = 5; - dfb->bitsPerPixel = 16; - dfb->redMask = RM_ARGB(0,5,5,5); - dfb->greenMask = GM_ARGB(0,5,5,5); - dfb->blueMask = BM_ARGB(0,5,5,5); - break; + switch (depth) { + case 8: // pseudo-working + dfb->visuals = PseudoColorMask; + dfb->preferredCVC = PseudoColor; + dfb->depth = 8; + dfb->bitsPerRGB = 8; + dfb->bitsPerPixel = 8; + dfb->redMask = 0; + dfb->greenMask = 0; + dfb->blueMask = 0; + break; + case 15: + dfb->visuals = TrueColorMask; //LARGE_VISUALS; + dfb->preferredCVC = TrueColor; + dfb->depth = 15; + dfb->bitsPerRGB = 5; + dfb->bitsPerPixel = 16; + dfb->redMask = RM_ARGB(0, 5, 5, 5); + dfb->greenMask = GM_ARGB(0, 5, 5, 5); + dfb->blueMask = BM_ARGB(0, 5, 5, 5); + break; // case 24: - default: - if(depth != 24) - ErrorF("Unsupported color depth requested. Defaulting to 24bit. (depth=%d darwinDesiredDepth=%d)\n", depth, darwinDesiredDepth); - dfb->visuals = TrueColorMask; //LARGE_VISUALS; - dfb->preferredCVC = TrueColor; - dfb->depth = 24; - dfb->bitsPerRGB = 8; - dfb->bitsPerPixel = 32; - dfb->redMask = RM_ARGB(0,8,8,8); - dfb->greenMask = GM_ARGB(0,8,8,8); - dfb->blueMask = BM_ARGB(0,8,8,8); - break; + default: + if (depth != 24) + ErrorF + ("Unsupported color depth requested. Defaulting to 24bit. (depth=%d darwinDesiredDepth=%d)\n", + depth, darwinDesiredDepth); + dfb->visuals = TrueColorMask; //LARGE_VISUALS; + dfb->preferredCVC = TrueColor; + dfb->depth = 24; + dfb->bitsPerRGB = 8; + dfb->bitsPerPixel = 32; + dfb->redMask = RM_ARGB(0, 8, 8, 8); + dfb->greenMask = GM_ARGB(0, 8, 8, 8); + dfb->blueMask = BM_ARGB(0, 8, 8, 8); + break; } - if (noPseudoramiXExtension) - { + if (noPseudoramiXExtension) { CGDirectDisplayID dpy; CGRect frame; ErrorF("Warning: noPseudoramiXExtension!\n"); - + dpy = displayAtIndex(index); QuartzCopyDisplayIDs(pScreen, 1, &dpy); @@ -379,12 +395,12 @@ have_depth: dfb->x = frame.origin.x; dfb->y = frame.origin.y; - dfb->width = frame.size.width; + dfb->width = frame.size.width; dfb->height = frame.size.height; } - else - { - xprAddPseudoramiXScreens(&dfb->x, &dfb->y, &dfb->width, &dfb->height, pScreen); + else { + xprAddPseudoramiXScreens(&dfb->x, &dfb->y, &dfb->width, &dfb->height, + pScreen); } /* Passing zero width (pitch) makes miCreateScreenResources set the -- cgit v1.2.3