diff --git a/GL/Makefile.am b/GL/Makefile.am index b9337ba69..df9f533e2 100644 --- a/GL/Makefile.am +++ b/GL/Makefile.am @@ -1,16 +1,16 @@ -SUBDIRS = glx mesa - # someone could get really crazy someday and add support for the SI... # xwin/darwin/xfree86 have their accel support under the DDX -APPLE_EXTRAS = \ - apple/aglGlx.c \ - apple/indirect.c +if BUILD_DARWIN +DARWIN_SUBDIRS = apple +endif +SUBDIRS = glx mesa $(DARWIN_SUBDIRS) + WINDOWS_EXTRAS = \ windows/ChangeLog \ windows/glwindows.h \ windows/glwrap.c \ windows/indirect.c -EXTRA_DIST = symlink-mesa.sh $(APPLE_EXTRAS) $(WINDOWS_EXTRAS) +EXTRA_DIST = symlink-mesa.sh $(WINDOWS_EXTRAS) diff --git a/GL/apple/Makefile.am b/GL/apple/Makefile.am new file mode 100644 index 000000000..2b2d10cbc --- /dev/null +++ b/GL/apple/Makefile.am @@ -0,0 +1,15 @@ +AM_CFLAGS = -I$(top_srcdir) \ + -I$(top_srcdir)/hw/darwin/quartz \ + -I$(top_srcdir)/GL/glx \ + -I$(top_srcdir)/hw/darwin/quartz/cr \ + -I$(top_srcdir)/GL/include + +if HAVE_AGL_FRAMEWORK +noinst_LIBRARIES = libAGLcore.a +libAGLcore_a_SOURCES = aglGlx.c \ + $(top_srcdir)/hw/darwin/quartz/xpr/x-list.c \ + $(top_srcdir)/hw/darwin/quartz/xpr/x-list.h \ + $(top_srcdir)/hw/darwin/quartz/xpr/x-hash.c \ + $(top_srcdir)/hw/darwin/quartz/xpr/x-hash.h \ + $(top_srcdir)/hw/dmx/glxProxy/compsize.c +endif diff --git a/GL/apple/indirect.c b/GL/apple/indirect.c index 8cba1c63d..ba541862e 100644 --- a/GL/apple/indirect.c +++ b/GL/apple/indirect.c @@ -1,11 +1,10 @@ /* * GLX implementation that uses Apple's OpenGL.framework * (Indirect rendering path) - */ -/* - * Copyright (c) 2002 Greg Parker. All Rights Reserved. - * Copyright (c) 2002 Apple Computer, Inc. + * + * Copyright (c) 2007 Apple Inc. * Copyright (c) 2004 Torrey T. Lyons. All Rights Reserved. + * Copyright (c) 2002 Greg Parker. All Rights Reserved. * * Portions of this file are copied from Mesa's xf86glx.c, * which contains the following copyright: @@ -39,11 +38,12 @@ #include "dri.h" #include "quartz.h" -#include +//#include #include #include // X11 and X11's glx +#include #include #include #include @@ -61,11 +61,16 @@ #include "x-hash.h" #include "x-list.h" +#include + #include "glcontextmodes.h" +#include +#include // ggs: needed to call back to glx with visual configs extern void GlxSetVisualConfigs(int nconfigs, __GLXvisualConfig *configs, void **configprivs); +#define GLAQUA_DEBUG 1 // Write debugging output, or not #ifdef GLAQUA_DEBUG @@ -74,60 +79,116 @@ extern void GlxSetVisualConfigs(int nconfigs, __GLXvisualConfig *configs, void * #define GLAQUA_DEBUG_MSG(a, ...) #endif - -// The following GL functions don't have an EXT suffix in OpenGL.framework. -GLboolean glAreTexturesResidentEXT(GLsizei a, const GLuint *b, GLboolean *c) { - return glAreTexturesResident(a, b, c); -} -void glDeleteTexturesEXT(GLsizei d, const GLuint *e) { - glDeleteTextures(d, e); -} -void glGenTexturesEXT(GLsizei f, GLuint *g) { - glGenTextures(f, g); -} -GLboolean glIsTextureEXT(GLuint h) { - return glIsTexture(h); -} +static void setup_dispatch_table(void); // some prototypes -static Bool glAquaScreenProbe(int screen); +static __GLXscreen * __glXAquaScreenProbe(ScreenPtr pScreen); static Bool glAquaInitVisuals(VisualPtr *visualp, DepthPtr *depthp, int *nvisualp, int *ndepthp, int *rootDepthp, VisualID *defaultVisp, unsigned long sizes, int bitsPerRGB); static void glAquaSetVisualConfigs(int nconfigs, __GLXvisualConfig *configs, void **privates); + static __GLinterface *glAquaCreateContext(__GLimports *imports, __GLcontextModes *mode, __GLinterface *shareGC); -static void glAquaCreateBuffer(__GLXdrawablePrivate *glxPriv); static void glAquaResetExtension(void); +static void __glXAquaContextDestroy(__GLXcontext *baseContext); +static int __glXAquaContextMakeCurrent(__GLXcontext *baseContext); +static int __glXAquaContextLoseCurrent(__GLXcontext *baseContext); +static int __glXAquaContextForceCurrent(__GLXcontext *baseContext); +static int __glXAquaContextCopy(__GLXcontext *baseDst, __GLXcontext *baseSrc, unsigned long mask); +static __GLXdrawable * __glXAquaContextCreateDrawable(__GLXcontext *context, DrawablePtr pDraw, XID drawId); -/* - * This structure is statically allocated in the __glXScreens[] - * structure. This struct is not used anywhere other than in - * __glXScreenInit to initialize each of the active screens - * (__glXActiveScreens[]). Several of the fields must be initialized by - * the screenProbe routine before they are copied to the active screens - * struct. In particular, the contextCreate, modes, numVisuals, - * and numUsableVisuals fields must be initialized. - */ -static __GLXscreenInfo __glDDXScreenInfo = { - glAquaScreenProbe, /* Must be generic and handle all screens */ - glAquaCreateContext, /* Substitute screen's createContext routine */ - glAquaCreateBuffer, /* Substitute screen's createBuffer routine */ - NULL, /* Set up modes in probe */ - NULL, /* Set up pVisualPriv in probe */ - 0, /* Set up numVisuals in probe */ - 0, /* Set up numUsableVisuals in probe */ - "Vendor String", /* GLXvendor is overwritten by __glXScreenInit */ - "Version String", /* GLXversion is overwritten by __glXScreenInit */ - "Extensions String", /* GLXextensions is overwritten by __glXScreenInit */ - NULL /* WrappedPositionWindow is overwritten */ +static CGLPixelFormatObj makeFormat(__GLcontextModes *mode); + +__GLXprovider __glXMesaProvider = { + __glXAquaScreenProbe, + "Core OpenGL", + NULL }; -void *__glXglDDXScreenInfo(void) { - return &__glDDXScreenInfo; +__GLXprovider * +GlxGetMesaProvider (void) +{ + ErrorF("GlxGetMesaProvider\n"); + return &__glXMesaProvider; +} + +typedef struct __GLXAquaScreen __GLXAquaScreen; +typedef struct __GLXAquaContext __GLXAquaContext; +typedef struct __GLXAquaDrawable __GLXAquaDrawable; + +struct __GLXAquaScreen { + __GLXscreen base; + int index; + int num_vis; + __GLcontextModes *modes; +}; + +static __GLXAquaScreen glAquaScreens[MAXSCREENS]; + +struct __GLXAquaContext { + __GLXcontext base; + CGLContextObj ctx; + CGLPixelFormatObj pixelFormat; + xp_surface_id sid; + unsigned isAttached :1; +}; + +struct __GLXAquaDrawable { + __GLXdrawable base; + DrawablePtr pDraw; + xp_surface_id sid; +}; + +static __GLXcontext * +__glXAquaScreenCreateContext(__GLXscreen *screen, + __GLcontextModes *modes, + __GLXcontext *baseShareContext) +{ + __GLXAquaContext *context; + __GLXAquaContext *shareContext = (__GLXAquaContext *) baseShareContext; + CGLError gl_err; + + GLAQUA_DEBUG_MSG("glXAquaScreenCreateContext\n"); + + context = malloc (sizeof (__GLXAquaContext)); + if (context == NULL) return NULL; + + memset(context, 0, sizeof *context); + + context->base.pGlxScreen = screen; + context->base.modes = modes; + + context->base.destroy = __glXAquaContextDestroy; + context->base.makeCurrent = __glXAquaContextMakeCurrent; + context->base.loseCurrent = __glXAquaContextLoseCurrent; + context->base.copy = __glXAquaContextCopy; + context->base.forceCurrent = __glXAquaContextForceCurrent; + context->base.createDrawable = __glXAquaContextCreateDrawable; + + context->pixelFormat = makeFormat(modes); + if (!context->pixelFormat) { + free(context); + return NULL; + } + + context->ctx = NULL; + gl_err = CGLCreateContext(context->pixelFormat, + shareContext ? shareContext->ctx : NULL, + &context->ctx); + + if (gl_err != 0) { + ErrorF("CGLCreateContext error: %s\n", CGLErrorString(gl_err)); + CGLDestroyPixelFormat(context->pixelFormat); + free(context); + return NULL; + } + setup_dispatch_table(); + GLAQUA_DEBUG_MSG("glAquaCreateContext done\n"); + return &context->base; } static __GLXextensionInfo __glDDXExtensionInfo = { @@ -138,118 +199,43 @@ static __GLXextensionInfo __glDDXExtensionInfo = { }; void *__glXglDDXExtensionInfo(void) { + GLAQUA_DEBUG_MSG("glXAglDDXExtensionInfo\n"); return &__glDDXExtensionInfo; } -// prototypes - -static GLboolean glAquaDestroyContext(__GLcontext *gc); -static GLboolean glAquaLoseCurrent(__GLcontext *gc); -static GLboolean glAquaMakeCurrent(__GLcontext *gc); -static GLboolean glAquaShareContext(__GLcontext *gc, __GLcontext *gcShare); -static GLboolean glAquaCopyContext(__GLcontext *dst, const __GLcontext *src, - GLuint mask); -static GLboolean glAquaForceCurrent(__GLcontext *gc); - -/* Drawing surface notification callbacks */ -static GLboolean glAquaNotifyResize(__GLcontext *gc); -static void glAquaNotifyDestroy(__GLcontext *gc); -static void glAquaNotifySwapBuffers(__GLcontext *gc); - -/* Dispatch table override control for external agents like libGLS */ -static struct __GLdispatchStateRec* glAquaDispatchExec(__GLcontext *gc); -static void glAquaBeginDispatchOverride(__GLcontext *gc); -static void glAquaEndDispatchOverride(__GLcontext *gc); - -static __GLexports glAquaExports = { - glAquaDestroyContext, - glAquaLoseCurrent, - glAquaMakeCurrent, - glAquaShareContext, - glAquaCopyContext, - glAquaForceCurrent, - - glAquaNotifyResize, - glAquaNotifyDestroy, - glAquaNotifySwapBuffers, - - glAquaDispatchExec, - glAquaBeginDispatchOverride, - glAquaEndDispatchOverride -}; - -typedef struct { - int num_vis; - __GLcontextModes *modes; - void **priv; - - // wrapped screen functions - RealizeWindowProcPtr RealizeWindow; - UnrealizeWindowProcPtr UnrealizeWindow; -} glAquaScreenRec; - -static glAquaScreenRec glAquaScreens[MAXSCREENS]; - -// __GLdrawablePrivate->private -typedef struct { - DrawablePtr pDraw; - xp_surface_id sid; -} GLAquaDrawableRec; - -struct __GLcontextRec { - struct __GLinterfaceRec interface; // required to be first - - CGLContextObj ctx; - CGLPixelFormatObj pixelFormat; - - /* set when attached */ - xp_surface_id sid; - - unsigned isAttached :1; -}; - /* maps from surface id -> list of __GLcontext */ static x_hash_table *surface_hash; - -// Context manipulation; return GL_FALSE on failure -static GLboolean glAquaDestroyContext(__GLcontext *gc) -{ +static void __glXAquaContextDestroy(__GLXcontext *baseContext) { x_list *lst; - GLAQUA_DEBUG_MSG("glAquaDestroyContext (ctx 0x%x)\n", - (unsigned int) gc->ctx); + __GLXAquaContext *context = (__GLXAquaContext *) baseContext; - if (gc != NULL) - { - if (gc->sid != 0 && surface_hash != NULL) - { - lst = x_hash_table_lookup(surface_hash, (void *) gc->sid, NULL); - lst = x_list_remove(lst, gc); - x_hash_table_insert(surface_hash, (void *) gc->sid, lst); - } + GLAQUA_DEBUG_MSG("glAquaContextDestroy (ctx 0x%x)\n", + (unsigned int) baseContext); + if (context != NULL) { + if (context->sid != 0 && surface_hash != NULL) { + lst = x_hash_table_lookup(surface_hash, (void *) context->sid, NULL); + lst = x_list_remove(lst, context); + x_hash_table_insert(surface_hash, (void *) context->sid, lst); + } - if (gc->ctx != NULL) - CGLDestroyContext(gc->ctx); + if (context->ctx != NULL) CGLDestroyContext(context->ctx); - if (gc->pixelFormat != NULL) - CGLDestroyPixelFormat(gc->pixelFormat); - - free(gc); + if (context->pixelFormat != NULL) CGLDestroyPixelFormat(context->pixelFormat); + + free(context); } - - return GL_TRUE; } -static GLboolean glAquaLoseCurrent(__GLcontext *gc) -{ +static int __glXAquaContextLoseCurrent(__GLXcontext *baseContext) { CGLError gl_err; - GLAQUA_DEBUG_MSG("glAquaLoseCurrent (ctx 0x%x)\n", (unsigned int) gc->ctx); + GLAQUA_DEBUG_MSG("glAquaLoseCurrent (ctx 0x%p)\n", baseContext); gl_err = CGLSetCurrentContext(NULL); if (gl_err != 0) - ErrorF("CGLSetCurrentContext error: %s\n", CGLErrorString(gl_err)); + ErrorF("CGLSetCurrentContext error: %s\n", CGLErrorString(gl_err)); __glXLastContext = NULL; // Mesa does this; why? @@ -258,141 +244,139 @@ static GLboolean glAquaLoseCurrent(__GLcontext *gc) /* Called when a surface is destroyed as a side effect of destroying the window it's attached to. */ -static void surface_notify(void *_arg, void *data) -{ - DRISurfaceNotifyArg *arg = _arg; - GLAquaDrawableRec *aquaPriv = data; - __GLcontext *gc; +static void surface_notify(void *_arg, void *data) { + DRISurfaceNotifyArg *arg = (DRISurfaceNotifyArg *)_arg; + __GLXAquaDrawable *draw = (__GLXAquaDrawable *)data; + __GLXAquaContext *context; x_list *lst; - - switch (arg->kind) - { + if(_arg == NULL || data == NULL) { + ErrorF("surface_notify called with bad params"); + return; + } + + GLAQUA_DEBUG_MSG("surface_notify(%p, %p)\n", _arg, data); + switch (arg->kind) { case AppleDRISurfaceNotifyDestroyed: if (surface_hash != NULL) x_hash_table_remove(surface_hash, (void *) arg->id); - - aquaPriv->pDraw = NULL; - aquaPriv->sid = 0; + draw->base->pDraw = NULL; + draw->sid = 0; break; case AppleDRISurfaceNotifyChanged: - if (surface_hash != NULL) - { + if (surface_hash != NULL) { lst = x_hash_table_lookup(surface_hash, (void *) arg->id, NULL); for (; lst != NULL; lst = lst->next) { - gc = lst->data; - xp_update_gl_context(gc->ctx); + context = lst->data; + xp_update_gl_context(context->ctx); } } break; + default: + ErrorF("surface_notify: unknown kind %d\n", arg->kind); + break; } } -static void unattach(__GLcontext *gc) -{ - x_list *lst; - - if (gc->isAttached) - { - GLAQUA_DEBUG_MSG("unattaching\n"); - - if (surface_hash != NULL) - { - lst = x_hash_table_lookup(surface_hash, (void *) gc->sid, NULL); - lst = x_list_remove(lst, gc); - x_hash_table_insert(surface_hash, (void *) gc->sid, lst); - } - - CGLClearDrawable(gc->ctx); - gc->isAttached = FALSE; - gc->sid = 0; - } -} - -static void attach(__GLcontext *gc, __GLdrawablePrivate *glPriv) -{ - __GLXdrawablePrivate *glxPriv; - GLAquaDrawableRec *aquaPriv; +static void attach(__GLXAquaContext *context, __GLXAquaDrawable *draw) { DrawablePtr pDraw; + GLAQUA_DEBUG_MSG("attach(%p, %p)\n", context, draw); + pDraw = draw->base.pDraw; - glxPriv = (__GLXdrawablePrivate *)glPriv->other; - aquaPriv = (GLAquaDrawableRec *)glPriv->private; - pDraw = glxPriv->pDraw; - - if (aquaPriv->sid == 0) - { - if (!quartzProcs->CreateSurface(pDraw->pScreen, pDraw->id, pDraw, - 0, &aquaPriv->sid, NULL, - surface_notify, aquaPriv)) - { + if (draw->sid == 0) { +// if (!quartzProcs->CreateSurface(pDraw->pScreen, pDraw->id, pDraw, + if (!DRICreateSurface(pDraw->pScreen, pDraw->id, pDraw, + 0, &draw->sid, NULL, + surface_notify, draw)) return; - } - aquaPriv->pDraw = pDraw; - } + draw->pDraw = pDraw; + } - if (!gc->isAttached || gc->sid != aquaPriv->sid) - { + if (!context->isAttached || context->sid != draw->sid) { x_list *lst; - if (xp_attach_gl_context(gc->ctx, aquaPriv->sid) != Success) - { - quartzProcs->DestroySurface(pDraw->pScreen, pDraw->id, pDraw, - surface_notify, aquaPriv); + if (xp_attach_gl_context(context->ctx, draw->sid) != Success) { +// quartzProcs->DestroySurface(pDraw->pScreen, pDraw->id, pDraw, + DRIDestroySurface(pDraw->pScreen, pDraw->id, pDraw, + surface_notify, draw); if (surface_hash != NULL) - x_hash_table_remove(surface_hash, (void *) aquaPriv->sid); + x_hash_table_remove(surface_hash, (void *) draw->sid); - aquaPriv->sid = 0; + draw->sid = 0; return; } - gc->isAttached = TRUE; - gc->sid = aquaPriv->sid; + context->isAttached = TRUE; + context->sid = draw->sid; if (surface_hash == NULL) surface_hash = x_hash_table_new(NULL, NULL, NULL, NULL); - lst = x_hash_table_lookup(surface_hash, (void *) gc->sid, NULL); - if (x_list_find(lst, gc) == NULL) - { - lst = x_list_prepend(lst, gc); - x_hash_table_insert(surface_hash, (void *) gc->sid, lst); + lst = x_hash_table_lookup(surface_hash, (void *) context->sid, NULL); + if (x_list_find(lst, context) == NULL) { + lst = x_list_prepend(lst, context); + x_hash_table_insert(surface_hash, (void *) context->sid, lst); } GLAQUA_DEBUG_MSG("attached 0x%x to 0x%x\n", (unsigned int) pDraw->id, - (unsigned int) aquaPriv->sid); + (unsigned int) draw->sid); + } +} + +static void unattach(__GLXAquaContext *context) { + x_list *lst; + GLAQUA_DEBUG_MSG("unattach\n"); + if (context == NULL) { + ErrorF("Tried to unattach a null context\n"); + return; + } + if (context->isAttached) { + GLAQUA_DEBUG_MSG("unattaching\n"); + + if (surface_hash != NULL) { + lst = x_hash_table_lookup(surface_hash, (void *) context->sid, NULL); + lst = x_list_remove(lst, context); + x_hash_table_insert(surface_hash, (void *) context->sid, lst); + } + + CGLClearDrawable(context->ctx); + context->isAttached = FALSE; + context->sid = 0; } } -static GLboolean glAquaMakeCurrent(__GLcontext *gc) -{ - __GLdrawablePrivate *glPriv = gc->interface.imports.getDrawablePrivate(gc); +static int __glXAquaContextMakeCurrent(__GLXcontext *baseContext) { CGLError gl_err; + __GLXAquaContext *context = (__GLXAquaContext *) baseContext; + __GLXAquaDrawable *drawPriv = (__GLXAquaDrawable *) context->base.drawPriv; + __GLXAquaDrawable *readPriv = (__GLXAquaDrawable *) context->base.readPriv; - GLAQUA_DEBUG_MSG("glAquaMakeCurrent (ctx 0x%x)\n", (unsigned int) gc->ctx); + GLAQUA_DEBUG_MSG("glAquaMakeCurrent (ctx 0x%p)\n", baseContext); + + attach(context, drawPriv); - attach(gc, glPriv); - - gl_err = CGLSetCurrentContext(gc->ctx); + gl_err = CGLSetCurrentContext(context->ctx); if (gl_err != 0) ErrorF("CGLSetCurrentContext error: %s\n", CGLErrorString(gl_err)); - + return gl_err == 0; } static GLboolean glAquaShareContext(__GLcontext *gc, __GLcontext *gcShare) { GLAQUA_DEBUG_MSG("glAquaShareContext unimplemented\n"); - return GL_TRUE; } -static GLboolean glAquaCopyContext(__GLcontext *dst, const __GLcontext *src, - GLuint mask) +static int __glXAquaContextCopy(__GLXcontext *baseDst, __GLXcontext *baseSrc, unsigned long mask) { CGLError gl_err; - GLAQUA_DEBUG_MSG("glAquaCopyContext\n"); + __GLXAquaContext *dst = (__GLXAquaContext *) baseDst; + __GLXAquaContext *src = (__GLXAquaContext *) baseSrc; + + GLAQUA_DEBUG_MSG("GLXAquaContextCopy\n"); gl_err = CGLCopyContext(src->ctx, dst->ctx, mask); if (gl_err != 0) @@ -401,14 +385,13 @@ static GLboolean glAquaCopyContext(__GLcontext *dst, const __GLcontext *src, return gl_err == 0; } -static GLboolean glAquaForceCurrent(__GLcontext *gc) +static int __glXAquaContextForceCurrent(__GLXcontext *baseContext) { CGLError gl_err; + __GLXAquaContext *context = (__GLXAquaContext *) baseContext; + GLAQUA_DEBUG_MSG("glAquaForceCurrent (ctx %p)\n", context->ctx); - GLAQUA_DEBUG_MSG("glAquaForceCurrent (ctx 0x%x)\n", - (unsigned int) gc->ctx); - - gl_err = CGLSetCurrentContext(gc->ctx); + gl_err = CGLSetCurrentContext(context->ctx); if (gl_err != 0) ErrorF("CGLSetCurrentContext error: %s\n", CGLErrorString(gl_err)); @@ -417,45 +400,41 @@ static GLboolean glAquaForceCurrent(__GLcontext *gc) /* Drawing surface notification callbacks */ -static GLboolean glAquaNotifyResize(__GLcontext *gc) -{ - GLAQUA_DEBUG_MSG("unimplemented glAquaNotifyResize"); +static GLboolean __glXAquaDrawableResize(__GLXdrawable *base) { + GLAQUA_DEBUG_MSG("unimplemented glAquaDrawableResize\n"); return GL_TRUE; } -static void glAquaNotifyDestroy(__GLcontext *gc) -{ +static void glAquaNotifyDestroy(__GLcontext *gc) { GLAQUA_DEBUG_MSG("unimplemented glAquaNotifyDestroy"); } -static void glAquaNotifySwapBuffers(__GLcontext *gc) -{ - GLAQUA_DEBUG_MSG("unimplemented glAquaNotifySwapBuffers"); +static GLboolean __glXAquaDrawableSwapBuffers(__GLXdrawable *base) { + __GLXAquaDrawable *glxPriv = (__GLXAquaDrawable *) base; + CGLError gl_err; + __GLXAquaContext * drawableCtx; +// GLAQUA_DEBUG_MSG("glAquaDrawableSwapBuffers(%p)\n",base); + + if(!base) { + ErrorF("glXAquaDrawbleSwapBuffers passed NULL\n"); + return GL_FALSE; + } + + drawableCtx = (__GLXAquaContext *)base->drawGlxc; + + if (drawableCtx != NULL && drawableCtx->ctx != NULL) { + gl_err = CGLFlushDrawable(drawableCtx->ctx); + if (gl_err != 0) + ErrorF("CGLFlushDrawable error: %s\n", CGLErrorString(gl_err)); + } + return GL_TRUE; } -/* Dispatch table override control for external agents like libGLS */ -static struct __GLdispatchStateRec* glAquaDispatchExec(__GLcontext *gc) -{ - GLAQUA_DEBUG_MSG("unimplemented glAquaDispatchExec"); - return NULL; -} - -static void glAquaBeginDispatchOverride(__GLcontext *gc) -{ - GLAQUA_DEBUG_MSG("unimplemented glAquaBeginDispatchOverride"); -} - -static void glAquaEndDispatchOverride(__GLcontext *gc) -{ - GLAQUA_DEBUG_MSG("unimplemented glAquaEndDispatchOverride"); -} - -static CGLPixelFormatObj makeFormat(__GLcontextModes *mode) -{ +static CGLPixelFormatObj makeFormat(__GLcontextModes *mode) { int i; CGLPixelFormatAttribute attr[64]; // currently uses max of 30 CGLPixelFormatObj result; - long n_formats; + GLint n_formats; CGLError gl_err; GLAQUA_DEBUG_MSG("makeFormat\n"); @@ -491,10 +470,12 @@ static CGLPixelFormatObj makeFormat(__GLcontextModes *mode) attr[i++] = mode->accumRedBits + mode->accumGreenBits + mode->accumBlueBits + mode->accumAlphaBits; } + if (mode->haveDepthBuffer) { attr[i++] = kCGLPFADepthSize; attr[i++] = mode->depthBits; } + if (mode->haveStencilBuffer) { attr[i++] = kCGLPFAStencilSize; attr[i++] = mode->stencilBits; @@ -521,129 +502,6 @@ static CGLPixelFormatObj makeFormat(__GLcontextModes *mode) return result; } -static __GLinterface *glAquaCreateContext(__GLimports *imports, - __GLcontextModes *mode, - __GLinterface *shareGC) -{ - __GLcontext *result; - __GLcontext *sharectx = (__GLcontext *)shareGC; - CGLError gl_err; - - GLAQUA_DEBUG_MSG("glAquaCreateContext\n"); - - result = (__GLcontext *)calloc(1, sizeof(__GLcontext)); - if (!result) return NULL; - - result->interface.imports = *imports; - result->interface.exports = glAquaExports; - - result->pixelFormat = makeFormat(mode); - if (!result->pixelFormat) { - free(result); - return NULL; - } - - result->ctx = NULL; - gl_err = CGLCreateContext(result->pixelFormat, - sharectx ? sharectx->ctx : NULL, - &result->ctx); - - if (gl_err != 0) { - ErrorF("CGLCreateContext error: %s\n", CGLErrorString(gl_err)); - CGLDestroyPixelFormat(result->pixelFormat); - free(result); - return NULL; - } - - GLAQUA_DEBUG_MSG("glAquaCreateContext done\n"); - return (__GLinterface *)result; -} - -Bool -glAquaRealizeWindow(WindowPtr pWin) -{ - // If this window has GL contexts, tell them to reattach - Bool result; - ScreenPtr pScreen = pWin->drawable.pScreen; - glAquaScreenRec *screenPriv = &glAquaScreens[pScreen->myNum]; - __GLXdrawablePrivate *glxPriv; - - GLAQUA_DEBUG_MSG("glAquaRealizeWindow\n"); - - // Allow the window to be created (RootlessRealizeWindow is inside our wrap) - pScreen->RealizeWindow = screenPriv->RealizeWindow; - result = pScreen->RealizeWindow(pWin); - pScreen->RealizeWindow = glAquaRealizeWindow; - - // The Aqua window will already have been created (windows are - // realized from top down) - - // Re-attach this window's GL contexts, if any. - glxPriv = __glXFindDrawablePrivate(pWin->drawable.id); - if (glxPriv) { - __GLXcontext *gx; - __GLcontext *gc; - __GLdrawablePrivate *glPriv = &glxPriv->glPriv; - GLAQUA_DEBUG_MSG("glAquaRealizeWindow is GL drawable!\n"); - - // GL contexts bound to this window for drawing - for (gx = glxPriv->drawGlxc; gx != NULL; gx = gx->next) { - gc = (__GLcontext *)gx->gc; - attach(gc, glPriv); - } - - // GL contexts bound to this window for reading - for (gx = glxPriv->readGlxc; gx != NULL; gx = gx->next) { - gc = (__GLcontext *)gx->gc; - attach(gc, glPriv); - } - } - - return result; -} - -Bool -glAquaUnrealizeWindow(WindowPtr pWin) -{ - // If this window has GL contexts, tell them to unattach - Bool result; - ScreenPtr pScreen = pWin->drawable.pScreen; - glAquaScreenRec *screenPriv = &glAquaScreens[pScreen->myNum]; - __GLXdrawablePrivate *glxPriv; - - GLAQUA_DEBUG_MSG("glAquaUnrealizeWindow\n"); - - // The Aqua window may have already been destroyed (windows - // are unrealized from top down) - - // Unattach this window's GL contexts, if any. - glxPriv = __glXFindDrawablePrivate(pWin->drawable.id); - if (glxPriv) { - __GLXcontext *gx; - __GLcontext *gc; - GLAQUA_DEBUG_MSG("glAquaUnealizeWindow is GL drawable!\n"); - - // GL contexts bound to this window for drawing - for (gx = glxPriv->drawGlxc; gx != NULL; gx = gx->next) { - gc = (__GLcontext *)gx->gc; - unattach(gc); - } - - // GL contexts bound to this window for reading - for (gx = glxPriv->readGlxc; gx != NULL; gx = gx->next) { - gc = (__GLcontext *)gx->gc; - unattach(gc); - } - } - - pScreen->UnrealizeWindow = screenPriv->UnrealizeWindow; - result = pScreen->UnrealizeWindow(pWin); - pScreen->UnrealizeWindow = glAquaUnrealizeWindow; - - return result; -} - - // Originally copied from Mesa static int numConfigs = 0; @@ -821,15 +679,15 @@ static Bool init_visuals(int *nvisualp, VisualPtr *visualp, /* Alloc space for the list of new GLX visuals */ pNewVisualConfigs = (__GLXvisualConfig *) - __glXMalloc(numNewConfigs * sizeof(__GLXvisualConfig)); + malloc(numNewConfigs * sizeof(__GLXvisualConfig)); if (!pNewVisualConfigs) { return FALSE; } /* Alloc space for the list of new GLX visual privates */ - pNewVisualPriv = (void **) __glXMalloc(numNewConfigs * sizeof(void *)); + pNewVisualPriv = (void **) malloc(numNewConfigs * sizeof(void *)); if (!pNewVisualPriv) { - __glXFree(pNewVisualConfigs); + free(pNewVisualConfigs); return FALSE; } @@ -879,40 +737,40 @@ static Bool init_visuals(int *nvisualp, VisualPtr *visualp, numConfigs = 0; /* Alloc temp space for the list of orig VisualIDs for each new visual */ - orig_vid = (VisualID *)__glXMalloc(numNewVisuals * sizeof(VisualID)); + orig_vid = (VisualID *)malloc(numNewVisuals * sizeof(VisualID)); if (!orig_vid) { - __glXFree(pNewVisualPriv); - __glXFree(pNewVisualConfigs); + free(pNewVisualPriv); + free(pNewVisualConfigs); return FALSE; } /* Alloc space for the list of glXVisuals */ modes = _gl_context_modes_create(numNewVisuals, sizeof(__GLcontextModes)); if (modes == NULL) { - __glXFree(orig_vid); - __glXFree(pNewVisualPriv); - __glXFree(pNewVisualConfigs); + free(orig_vid); + free(pNewVisualPriv); + free(pNewVisualConfigs); return FALSE; } /* Alloc space for the list of glXVisualPrivates */ - glXVisualPriv = (void **)__glXMalloc(numNewVisuals * sizeof(void *)); + glXVisualPriv = (void **)malloc(numNewVisuals * sizeof(void *)); if (!glXVisualPriv) { _gl_context_modes_destroy( modes ); - __glXFree(orig_vid); - __glXFree(pNewVisualPriv); - __glXFree(pNewVisualConfigs); + free(orig_vid); + free(pNewVisualPriv); + free(pNewVisualConfigs); return FALSE; } /* Alloc space for the new list of the X server's visuals */ - pVisualNew = (VisualPtr)__glXMalloc(numNewVisuals * sizeof(VisualRec)); + pVisualNew = (VisualPtr)malloc(numNewVisuals * sizeof(VisualRec)); if (!pVisualNew) { - __glXFree(glXVisualPriv); + free(glXVisualPriv); _gl_context_modes_destroy( modes ); - __glXFree(orig_vid); - __glXFree(pNewVisualPriv); - __glXFree(pNewVisualConfigs); + free(orig_vid); + free(pNewVisualPriv); + free(pNewVisualConfigs); return FALSE; } @@ -1007,7 +865,7 @@ static Bool init_visuals(int *nvisualp, VisualPtr *visualp, /* Save the GLX visuals in the screen structure */ glAquaScreens[screenInfo.numScreens-1].num_vis = numNewVisuals; - glAquaScreens[screenInfo.numScreens-1].priv = glXVisualPriv; + // glAquaScreens[screenInfo.numScreens-1].priv = glXVisualPriv; /* Set up depth's VisualIDs */ for (i = 0; i < ndepth; i++) { @@ -1022,7 +880,7 @@ static Bool init_visuals(int *nvisualp, VisualPtr *visualp, numVids++; /* Allocate a new list of VisualIDs for this depth */ - pVids = (VisualID *)__glXMalloc(numVids * sizeof(VisualID)); + pVids = (VisualID *)malloc(numVids * sizeof(VisualID)); /* Initialize the new list of VisualIDs for this depth */ for (j = 0; j < pdepth[i].numVids; j++) @@ -1031,7 +889,7 @@ static Bool init_visuals(int *nvisualp, VisualPtr *visualp, pVids[n++] = pVisualNew[k].vid; /* Update this depth's list of VisualIDs */ - __glXFree(pdepth[i].vids); + free(pdepth[i].vids); pdepth[i].vids = pVids; pdepth[i].numVids = numVids; } @@ -1041,21 +899,22 @@ static Bool init_visuals(int *nvisualp, VisualPtr *visualp, *visualp = pVisualNew; /* Free the old list of the X server's visuals */ - __glXFree(pVisual); + free(pVisual); /* Clean up temporary allocations */ - __glXFree(orig_vid); - __glXFree(pNewVisualPriv); - __glXFree(pNewVisualConfigs); + free(orig_vid); + free(pNewVisualPriv); + free(pNewVisualConfigs); /* Free the private list created by DDX HW driver */ if (visualPrivates) - xfree(visualPrivates); + free(visualPrivates); visualPrivates = NULL; return TRUE; } +Bool enable_stereo = FALSE; /* based on code in i830_dri.c This ends calling glAquaSetVisualConfigs to set the static numconfigs, etc. */ @@ -1066,20 +925,22 @@ glAquaInitVisualConfigs(void) __GLXvisualConfig *lclVisualConfigs = NULL; void **lclVisualPrivates = NULL; - int depth, aux, buffers, stencil, accum; + int stereo, depth, aux, buffers, stencil, accum; int i = 0; GLAQUA_DEBUG_MSG("glAquaInitVisualConfigs "); /* count num configs: + 2 stereo (on, off) (optional) 2 Z buffer (0, 24 bit) 2 AUX buffer (0, 2) 2 buffers (single, double) 2 stencil (0, 8 bit) 2 accum (0, 64 bit) - = 32 configs */ + = 64 configs with stereo, or 32 without */ - lclNumConfigs = 2 * 2 * 2 * 2 * 2; /* 32 */ + if (enable_stereo) lclNumConfigs = 2 * 2 * 2 * 2 * 2 * 2; /* 64 */ + else lclNumConfigs = 2 * 2 * 2 * 2 * 2; /* 32 */ /* alloc */ lclVisualConfigs = xcalloc(sizeof(__GLXvisualConfig), lclNumConfigs); @@ -1088,54 +949,55 @@ glAquaInitVisualConfigs(void) /* fill in configs */ if (NULL != lclVisualConfigs) { i = 0; /* current buffer */ - for (depth = 0; depth < 2; depth++) { + for (stereo = 0; stereo < (enable_stereo ? 2 : 1); stereo++) { + for (depth = 0; depth < 2; depth++) { for (aux = 0; aux < 2; aux++) { - for (buffers = 0; buffers < 2; buffers++) { - for (stencil = 0; stencil < 2; stencil++) { - for (accum = 0; accum < 2; accum++) { - lclVisualConfigs[i].vid = -1; - lclVisualConfigs[i].class = -1; - lclVisualConfigs[i].rgba = TRUE; - lclVisualConfigs[i].redSize = -1; - lclVisualConfigs[i].greenSize = -1; - lclVisualConfigs[i].blueSize = -1; - lclVisualConfigs[i].redMask = -1; - lclVisualConfigs[i].greenMask = -1; - lclVisualConfigs[i].blueMask = -1; - lclVisualConfigs[i].alphaMask = 0; - if (accum) { - lclVisualConfigs[i].accumRedSize = 16; - lclVisualConfigs[i].accumGreenSize = 16; - lclVisualConfigs[i].accumBlueSize = 16; - lclVisualConfigs[i].accumAlphaSize = 16; - } - else { - lclVisualConfigs[i].accumRedSize = 0; - lclVisualConfigs[i].accumGreenSize = 0; - lclVisualConfigs[i].accumBlueSize = 0; - lclVisualConfigs[i].accumAlphaSize = 0; - } - lclVisualConfigs[i].doubleBuffer = buffers ? TRUE : FALSE; - lclVisualConfigs[i].stereo = FALSE; - lclVisualConfigs[i].bufferSize = -1; - - lclVisualConfigs[i].depthSize = depth? 24 : 0; - lclVisualConfigs[i].stencilSize = stencil ? 8 : 0; - lclVisualConfigs[i].auxBuffers = aux ? 2 : 0; - lclVisualConfigs[i].level = 0; - lclVisualConfigs[i].visualRating = GLX_NONE_EXT; - lclVisualConfigs[i].transparentPixel = 0; - lclVisualConfigs[i].transparentRed = 0; - lclVisualConfigs[i].transparentGreen = 0; - lclVisualConfigs[i].transparentBlue = 0; - lclVisualConfigs[i].transparentAlpha = 0; - lclVisualConfigs[i].transparentIndex = 0; - i++; - } - } - } + for (buffers = 0; buffers < 2; buffers++) { + for (stencil = 0; stencil < 2; stencil++) { + for (accum = 0; accum < 2; accum++) { + lclVisualConfigs[i].vid = -1; + lclVisualConfigs[i].class = -1; + lclVisualConfigs[i].rgba = TRUE; + lclVisualConfigs[i].redSize = -1; + lclVisualConfigs[i].greenSize = -1; + lclVisualConfigs[i].blueSize = -1; + lclVisualConfigs[i].redMask = -1; + lclVisualConfigs[i].greenMask = -1; + lclVisualConfigs[i].blueMask = -1; + lclVisualConfigs[i].alphaMask = 0; + if (accum) { + lclVisualConfigs[i].accumRedSize = 16; + lclVisualConfigs[i].accumGreenSize = 16; + lclVisualConfigs[i].accumBlueSize = 16; + lclVisualConfigs[i].accumAlphaSize = 16; + } else { + lclVisualConfigs[i].accumRedSize = 0; + lclVisualConfigs[i].accumGreenSize = 0; + lclVisualConfigs[i].accumBlueSize = 0; + lclVisualConfigs[i].accumAlphaSize = 0; + } + lclVisualConfigs[i].doubleBuffer = buffers ? TRUE : FALSE; + lclVisualConfigs[i].stereo = stereo ? TRUE : FALSE; + lclVisualConfigs[i].bufferSize = -1; + + lclVisualConfigs[i].depthSize = depth? 24 : 0; + lclVisualConfigs[i].stencilSize = stencil ? 8 : 0; + lclVisualConfigs[i].auxBuffers = aux ? 2 : 0; + lclVisualConfigs[i].level = 0; + lclVisualConfigs[i].visualRating = GLX_NONE_EXT; + lclVisualConfigs[i].transparentPixel = 0; + lclVisualConfigs[i].transparentRed = 0; + lclVisualConfigs[i].transparentGreen = 0; + lclVisualConfigs[i].transparentBlue = 0; + lclVisualConfigs[i].transparentAlpha = 0; + lclVisualConfigs[i].transparentIndex = 0; + i++; + } + } + } } - } + } + } } if (i != lclNumConfigs) GLAQUA_DEBUG_MSG("glAquaInitVisualConfigs failed to alloc visual configs"); @@ -1171,7 +1033,7 @@ static Bool glAquaInitVisuals(VisualPtr *visualp, DepthPtr *depthp, *ndepthp, *depthp, *rootDepthp); } - +#if 0 static void fixup_visuals(int screen) { ScreenPtr pScreen = screenInfo.screens[screen]; @@ -1204,27 +1066,35 @@ static void fixup_visuals(int screen) } } } +#endif +static void __glXAquaScreenDestroy(__GLXscreen *screen) { -static void init_screen_visuals(int screen) -{ - ScreenPtr pScreen = screenInfo.screens[screen]; - __GLcontextModes *modes; - int *used; - int i, j; + GLAQUA_DEBUG_MSG("glXAquaScreenDestroy(%p)\n", screen); + __glXScreenDestroy(screen); + free(screen); +} + +static void init_screen_visuals(__GLXAquaScreen *screen) { + ScreenPtr pScreen = screen->base.pScreen; + + __GLcontextModes *modes; + int *used; + int i, j; + GLAQUA_DEBUG_MSG("init_screen_visuals\n"); /* FIXME: Change 'used' to be a array of bits (rather than of ints), * FIXME: create a stack array of 8 or 16 bytes. If 'numVisuals' is less * FIXME: than 64 or 128 the stack array can be used instead of calling - * FIXME: __glXMalloc / __glXFree. If nothing else, convert 'used' to + * FIXME: malloc / free. If nothing else, convert 'used' to * FIXME: array of bytes instead of ints! */ - used = (int *)__glXMalloc(pScreen->numVisuals * sizeof(int)); - __glXMemset(used, 0, pScreen->numVisuals * sizeof(int)); + used = (int *)malloc(pScreen->numVisuals * sizeof(int)); + memset(used, 0, pScreen->numVisuals * sizeof(int)); i = 0; - for ( modes = glAquaScreens[screen].modes + for ( modes = screen -> base.modes ; modes != NULL ; modes = modes->next ) { const int vis_class = _gl_convert_to_x_visual_type( modes->visualType ); @@ -1261,102 +1131,70 @@ static void init_screen_visuals(int screen) i++; } - __glXFree(used); + free(used); } -static Bool glAquaScreenProbe(int screen) -{ - ScreenPtr pScreen; - glAquaScreenRec *screenPriv; +static __GLXscreen * __glXAquaScreenProbe(ScreenPtr pScreen) { + __GLXAquaScreen *screen; + GLAQUA_DEBUG_MSG("glXAquaScreenProbe\n"); + if (screen == NULL) return NULL; - GLAQUA_DEBUG_MSG("glAquaScreenProbe\n"); + screen = malloc(sizeof *screen); - /* - * Set up the current screen's visuals. - */ - __glDDXScreenInfo.modes = glAquaScreens[screen].modes; - __glDDXScreenInfo.pVisualPriv = glAquaScreens[screen].priv; - __glDDXScreenInfo.numVisuals = - __glDDXScreenInfo.numUsableVisuals = glAquaScreens[screen].num_vis; + __glXScreenInit(&screen->base, pScreen); - /* - * Set the current screen's createContext routine. This could be - * wrapped by a DDX GLX context creation routine. - */ - __glDDXScreenInfo.createContext = glAquaCreateContext; + screen->base.destroy = __glXAquaScreenDestroy; + screen->base.createContext = __glXAquaScreenCreateContext; + screen->base.pScreen = pScreen; - /* - * The ordering of the rgb compenents might have been changed by the - * driver after mi initialized them. - */ - fixup_visuals(screen); + init_screen_visuals(screen); - /* - * Find the GLX visuals that are supported by this screen and create - * XMesa's visuals. - */ - init_screen_visuals(screen); - - /* - * Wrap RealizeWindow and UnrealizeWindow on this screen - */ - pScreen = screenInfo.screens[screen]; - screenPriv = &glAquaScreens[screen]; - screenPriv->RealizeWindow = pScreen->RealizeWindow; - pScreen->RealizeWindow = glAquaRealizeWindow; - screenPriv->UnrealizeWindow = pScreen->UnrealizeWindow; - pScreen->UnrealizeWindow = glAquaUnrealizeWindow; - - return TRUE; + return &screen->base; } -static GLboolean glAquaSwapBuffers(__GLXdrawablePrivate *glxPriv) -{ - // swap buffers on only *one* of the contexts - // (e.g. the last one for drawing) - __GLcontext *gc = (__GLcontext *)glxPriv->drawGlxc->gc; - CGLError gl_err; - - GLAQUA_DEBUG_MSG("glAquaSwapBuffers\n"); - - if (gc != NULL && gc->ctx != NULL) - { - gl_err = CGLFlushDrawable(gc->ctx); - if (gl_err != 0) - ErrorF("CGLFlushDrawable error: %s\n", CGLErrorString(gl_err)); - } - - return GL_TRUE; -} - -static void glAquaDestroyDrawablePrivate(__GLdrawablePrivate *glPriv) -{ +static void __glXAquaDrawableDestroy(__GLXdrawable *base) { GLAQUA_DEBUG_MSG("glAquaDestroyDrawablePrivate\n"); /* It doesn't work to call DRIDestroySurface here, the drawable's already gone.. But dri.c notices the window destruction and frees the surface itself. */ - free(glPriv->private); - glPriv->private = NULL; + free(base); } -static void glAquaCreateBuffer(__GLXdrawablePrivate *glxPriv) +static __GLXdrawable * +__glXAquaContextCreateDrawable(__GLXcontext *context, + DrawablePtr pDraw, + XID drawId) { - GLAquaDrawableRec *aquaPriv = malloc(sizeof(GLAquaDrawableRec)); - __GLdrawablePrivate *glPriv = &glxPriv->glPriv; + __GLXAquaDrawable *glxPriv; + __GLXscreen *pGlxScreen; - aquaPriv->sid = 0; - aquaPriv->pDraw = NULL; + GLAQUA_DEBUG_MSG("glAquaContextCreateDrawable(%p,%p,%d)\n", context, pDraw, drawId); + if (glxPriv == NULL) return NULL; + glxPriv = xalloc(sizeof *glxPriv); - GLAQUA_DEBUG_MSG("glAquaCreateBuffer\n"); + memset(glxPriv, 0, sizeof *glxPriv); - // replace swapBuffers (original is never called) - glxPriv->swapBuffers = glAquaSwapBuffers; + if (!__glXDrawableInit(&glxPriv->base, context, pDraw, drawId)) { + xfree(glxPriv); + return NULL; + } - // stash private data - glPriv->private = aquaPriv; - glPriv->freePrivate = glAquaDestroyDrawablePrivate; + glxPriv->base.destroy = __glXAquaDrawableDestroy; + glxPriv->base.resize = __glXAquaDrawableResize; + glxPriv->base.swapBuffers = __glXAquaDrawableSwapBuffers; + + pGlxScreen = __glXActiveScreens[pDraw->pScreen->myNum]; + + if (glxPriv->base.type == DRAWABLE_WINDOW) { + VisualID vid = wVisual((WindowPtr)pDraw); + + glxPriv->base.modes = _gl_context_modes_find_visual(pGlxScreen->modes, vid); + } else + glxPriv->base.modes = glxPriv->base.pGlxPixmap->modes; + + return &glxPriv->base; } static void glAquaResetExtension(void) @@ -1377,3 +1215,1239 @@ GLuint __glFloorLog2(GLuint val) } return c; } + +static void setup_dispatch_table(void) { + struct _glapi_table *disp=_glapi_get_dispatch(); + + SET_NewList(disp, glNewList); + SET_EndList(disp, glEndList); + SET_CallList(disp, glCallList); + SET_CallLists(disp, glCallLists); + SET_DeleteLists(disp, glDeleteLists); + SET_GenLists(disp, glGenLists); + SET_ListBase(disp, glListBase); + SET_Begin(disp, glBegin); + SET_Bitmap(disp, glBitmap); + SET_Color3b(disp, glColor3b); + SET_Color3bv(disp, glColor3bv); + SET_Color3d(disp, glColor3d); + SET_Color3dv(disp, glColor3dv); + SET_Color3f(disp, glColor3f); + SET_Color3fv(disp, glColor3fv); + SET_Color3i(disp, glColor3i); + SET_Color3iv(disp, glColor3iv); + SET_Color3s(disp, glColor3s); + SET_Color3sv(disp, glColor3sv); + SET_Color3ub(disp, glColor3ub); + SET_Color3ubv(disp, glColor3ubv); + SET_Color3ui(disp, glColor3ui); + SET_Color3uiv(disp, glColor3uiv); + SET_Color3us(disp, glColor3us); + SET_Color3usv(disp, glColor3usv); + SET_Color4b(disp, glColor4b); + SET_Color4bv(disp, glColor4bv); + SET_Color4d(disp, glColor4d); + SET_Color4dv(disp, glColor4dv); + SET_Color4f(disp, glColor4f); + SET_Color4fv(disp, glColor4fv); + SET_Color4i(disp, glColor4i); + SET_Color4iv(disp, glColor4iv); + SET_Color4s(disp, glColor4s); + SET_Color4sv(disp, glColor4sv); + SET_Color4ub(disp, glColor4ub); + SET_Color4ubv(disp, glColor4ubv); + SET_Color4ui(disp, glColor4ui); + SET_Color4uiv(disp, glColor4uiv); + SET_Color4us(disp, glColor4us); + SET_Color4usv(disp, glColor4usv); + SET_EdgeFlag(disp, glEdgeFlag); + SET_EdgeFlagv(disp, glEdgeFlagv); + SET_End(disp, glEnd); + SET_Indexd(disp, glIndexd); + SET_Indexdv(disp, glIndexdv); + SET_Indexf(disp, glIndexf); + SET_Indexfv(disp, glIndexfv); + SET_Indexi(disp, glIndexi); + SET_Indexiv(disp, glIndexiv); + SET_Indexs(disp, glIndexs); + SET_Indexsv(disp, glIndexsv); + SET_Normal3b(disp, glNormal3b); + SET_Normal3bv(disp, glNormal3bv); + SET_Normal3d(disp, glNormal3d); + SET_Normal3dv(disp, glNormal3dv); + SET_Normal3f(disp, glNormal3f); + SET_Normal3fv(disp, glNormal3fv); + SET_Normal3i(disp, glNormal3i); + SET_Normal3iv(disp, glNormal3iv); + SET_Normal3s(disp, glNormal3s); + SET_Normal3sv(disp, glNormal3sv); + SET_RasterPos2d(disp, glRasterPos2d); + SET_RasterPos2dv(disp, glRasterPos2dv); + SET_RasterPos2f(disp, glRasterPos2f); + SET_RasterPos2fv(disp, glRasterPos2fv); + SET_RasterPos2i(disp, glRasterPos2i); + SET_RasterPos2iv(disp, glRasterPos2iv); + SET_RasterPos2s(disp, glRasterPos2s); + SET_RasterPos2sv(disp, glRasterPos2sv); + SET_RasterPos3d(disp, glRasterPos3d); + SET_RasterPos3dv(disp, glRasterPos3dv); + SET_RasterPos3f(disp, glRasterPos3f); + SET_RasterPos3fv(disp, glRasterPos3fv); + SET_RasterPos3i(disp, glRasterPos3i); + SET_RasterPos3iv(disp, glRasterPos3iv); + SET_RasterPos3s(disp, glRasterPos3s); + SET_RasterPos3sv(disp, glRasterPos3sv); + SET_RasterPos4d(disp, glRasterPos4d); + SET_RasterPos4dv(disp, glRasterPos4dv); + SET_RasterPos4f(disp, glRasterPos4f); + SET_RasterPos4fv(disp, glRasterPos4fv); + SET_RasterPos4i(disp, glRasterPos4i); + SET_RasterPos4iv(disp, glRasterPos4iv); + SET_RasterPos4s(disp, glRasterPos4s); + SET_RasterPos4sv(disp, glRasterPos4sv); + SET_Rectd(disp, glRectd); + SET_Rectdv(disp, glRectdv); + SET_Rectf(disp, glRectf); + SET_Rectfv(disp, glRectfv); + SET_Recti(disp, glRecti); + SET_Rectiv(disp, glRectiv); + SET_Rects(disp, glRects); + SET_Rectsv(disp, glRectsv); + SET_TexCoord1d(disp, glTexCoord1d); + SET_TexCoord1dv(disp, glTexCoord1dv); + SET_TexCoord1f(disp, glTexCoord1f); + SET_TexCoord1fv(disp, glTexCoord1fv); + SET_TexCoord1i(disp, glTexCoord1i); + SET_TexCoord1iv(disp, glTexCoord1iv); + SET_TexCoord1s(disp, glTexCoord1s); + SET_TexCoord1sv(disp, glTexCoord1sv); + SET_TexCoord2d(disp, glTexCoord2d); + SET_TexCoord2dv(disp, glTexCoord2dv); + SET_TexCoord2f(disp, glTexCoord2f); + SET_TexCoord2fv(disp, glTexCoord2fv); + SET_TexCoord2i(disp, glTexCoord2i); + SET_TexCoord2iv(disp, glTexCoord2iv); + SET_TexCoord2s(disp, glTexCoord2s); + SET_TexCoord2sv(disp, glTexCoord2sv); + SET_TexCoord3d(disp, glTexCoord3d); + SET_TexCoord3dv(disp, glTexCoord3dv); + SET_TexCoord3f(disp, glTexCoord3f); + SET_TexCoord3fv(disp, glTexCoord3fv); + SET_TexCoord3i(disp, glTexCoord3i); + SET_TexCoord3iv(disp, glTexCoord3iv); + SET_TexCoord3s(disp, glTexCoord3s); + SET_TexCoord3sv(disp, glTexCoord3sv); + SET_TexCoord4d(disp, glTexCoord4d); + SET_TexCoord4dv(disp, glTexCoord4dv); + SET_TexCoord4f(disp, glTexCoord4f); + SET_TexCoord4fv(disp, glTexCoord4fv); + SET_TexCoord4i(disp, glTexCoord4i); + SET_TexCoord4iv(disp, glTexCoord4iv); + SET_TexCoord4s(disp, glTexCoord4s); + SET_TexCoord4sv(disp, glTexCoord4sv); + SET_Vertex2d(disp, glVertex2d); + SET_Vertex2dv(disp, glVertex2dv); + SET_Vertex2f(disp, glVertex2f); + SET_Vertex2fv(disp, glVertex2fv); + SET_Vertex2i(disp, glVertex2i); + SET_Vertex2iv(disp, glVertex2iv); + SET_Vertex2s(disp, glVertex2s); + SET_Vertex2sv(disp, glVertex2sv); + SET_Vertex3d(disp, glVertex3d); + SET_Vertex3dv(disp, glVertex3dv); + SET_Vertex3f(disp, glVertex3f); + SET_Vertex3fv(disp, glVertex3fv); + SET_Vertex3i(disp, glVertex3i); + SET_Vertex3iv(disp, glVertex3iv); + SET_Vertex3s(disp, glVertex3s); + SET_Vertex3sv(disp, glVertex3sv); + SET_Vertex4d(disp, glVertex4d); + SET_Vertex4dv(disp, glVertex4dv); + SET_Vertex4f(disp, glVertex4f); + SET_Vertex4fv(disp, glVertex4fv); + SET_Vertex4i(disp, glVertex4i); + SET_Vertex4iv(disp, glVertex4iv); + SET_Vertex4s(disp, glVertex4s); + SET_Vertex4sv(disp, glVertex4sv); + SET_ClipPlane(disp, glClipPlane); + SET_ColorMaterial(disp, glColorMaterial); + SET_CullFace(disp, glCullFace); + SET_Fogf(disp, glFogf); + SET_Fogfv(disp, glFogfv); + SET_Fogi(disp, glFogi); + SET_Fogiv(disp, glFogiv); + SET_FrontFace(disp, glFrontFace); + SET_Hint(disp, glHint); + SET_Lightf(disp, glLightf); + SET_Lightfv(disp, glLightfv); + SET_Lighti(disp, glLighti); + SET_Lightiv(disp, glLightiv); + SET_LightModelf(disp, glLightModelf); + SET_LightModelfv(disp, glLightModelfv); + SET_LightModeli(disp, glLightModeli); + SET_LightModeliv(disp, glLightModeliv); + SET_LineStipple(disp, glLineStipple); + SET_LineWidth(disp, glLineWidth); + SET_Materialf(disp, glMaterialf); + SET_Materialfv(disp, glMaterialfv); + SET_Materiali(disp, glMateriali); + SET_Materialiv(disp, glMaterialiv); + SET_PointSize(disp, glPointSize); + SET_PolygonMode(disp, glPolygonMode); + SET_PolygonStipple(disp, glPolygonStipple); + SET_Scissor(disp, glScissor); + SET_ShadeModel(disp, glShadeModel); + SET_TexParameterf(disp, glTexParameterf); + SET_TexParameterfv(disp, glTexParameterfv); + SET_TexParameteri(disp, glTexParameteri); + SET_TexParameteriv(disp, glTexParameteriv); + SET_TexImage1D(disp, glTexImage1D); + SET_TexImage2D(disp, glTexImage2D); + SET_TexEnvf(disp, glTexEnvf); + SET_TexEnvfv(disp, glTexEnvfv); + SET_TexEnvi(disp, glTexEnvi); + SET_TexEnviv(disp, glTexEnviv); + SET_TexGend(disp, glTexGend); + SET_TexGendv(disp, glTexGendv); + SET_TexGenf(disp, glTexGenf); + SET_TexGenfv(disp, glTexGenfv); + SET_TexGeni(disp, glTexGeni); + SET_TexGeniv(disp, glTexGeniv); + SET_FeedbackBuffer(disp, glFeedbackBuffer); + SET_SelectBuffer(disp, glSelectBuffer); + SET_RenderMode(disp, glRenderMode); + SET_InitNames(disp, glInitNames); + SET_LoadName(disp, glLoadName); + SET_PassThrough(disp, glPassThrough); + SET_PopName(disp, glPopName); + SET_PushName(disp, glPushName); + SET_DrawBuffer(disp, glDrawBuffer); + SET_Clear(disp, glClear); + SET_ClearAccum(disp, glClearAccum); + SET_ClearIndex(disp, glClearIndex); + SET_ClearColor(disp, glClearColor); + SET_ClearStencil(disp, glClearStencil); + SET_ClearDepth(disp, glClearDepth); + SET_StencilMask(disp, glStencilMask); + SET_ColorMask(disp, glColorMask); + SET_DepthMask(disp, glDepthMask); + SET_IndexMask(disp, glIndexMask); + SET_Accum(disp, glAccum); + SET_Disable(disp, glDisable); + SET_Enable(disp, glEnable); + SET_Finish(disp, glFinish); + SET_Flush(disp, glFlush); + SET_PopAttrib(disp, glPopAttrib); + SET_PushAttrib(disp, glPushAttrib); + SET_Map1d(disp, glMap1d); + SET_Map1f(disp, glMap1f); + SET_Map2d(disp, glMap2d); + SET_Map2f(disp, glMap2f); + SET_MapGrid1d(disp, glMapGrid1d); + SET_MapGrid1f(disp, glMapGrid1f); + SET_MapGrid2d(disp, glMapGrid2d); + SET_MapGrid2f(disp, glMapGrid2f); + SET_EvalCoord1d(disp, glEvalCoord1d); + SET_EvalCoord1dv(disp, glEvalCoord1dv); + SET_EvalCoord1f(disp, glEvalCoord1f); + SET_EvalCoord1fv(disp, glEvalCoord1fv); + SET_EvalCoord2d(disp, glEvalCoord2d); + SET_EvalCoord2dv(disp, glEvalCoord2dv); + SET_EvalCoord2f(disp, glEvalCoord2f); + SET_EvalCoord2fv(disp, glEvalCoord2fv); + SET_EvalMesh1(disp, glEvalMesh1); + SET_EvalPoint1(disp, glEvalPoint1); + SET_EvalMesh2(disp, glEvalMesh2); + SET_EvalPoint2(disp, glEvalPoint2); + SET_AlphaFunc(disp, glAlphaFunc); + SET_BlendFunc(disp, glBlendFunc); + SET_LogicOp(disp, glLogicOp); + SET_StencilFunc(disp, glStencilFunc); + SET_StencilOp(disp, glStencilOp); + SET_DepthFunc(disp, glDepthFunc); + SET_PixelZoom(disp, glPixelZoom); + SET_PixelTransferf(disp, glPixelTransferf); + SET_PixelTransferi(disp, glPixelTransferi); + SET_PixelStoref(disp, glPixelStoref); + SET_PixelStorei(disp, glPixelStorei); + SET_PixelMapfv(disp, glPixelMapfv); + SET_PixelMapuiv(disp, glPixelMapuiv); + SET_PixelMapusv(disp, glPixelMapusv); + SET_ReadBuffer(disp, glReadBuffer); + SET_CopyPixels(disp, glCopyPixels); + SET_ReadPixels(disp, glReadPixels); + SET_DrawPixels(disp, glDrawPixels); + SET_GetBooleanv(disp, glGetBooleanv); + SET_GetClipPlane(disp, glGetClipPlane); + SET_GetDoublev(disp, glGetDoublev); + SET_GetError(disp, glGetError); + SET_GetFloatv(disp, glGetFloatv); + SET_GetIntegerv(disp, glGetIntegerv); + SET_GetLightfv(disp, glGetLightfv); + SET_GetLightiv(disp, glGetLightiv); + SET_GetMapdv(disp, glGetMapdv); + SET_GetMapfv(disp, glGetMapfv); + SET_GetMapiv(disp, glGetMapiv); + SET_GetMaterialfv(disp, glGetMaterialfv); + SET_GetMaterialiv(disp, glGetMaterialiv); + SET_GetPixelMapfv(disp, glGetPixelMapfv); + SET_GetPixelMapuiv(disp, glGetPixelMapuiv); + SET_GetPixelMapusv(disp, glGetPixelMapusv); + SET_GetPolygonStipple(disp, glGetPolygonStipple); + SET_GetString(disp, glGetString); + SET_GetTexEnvfv(disp, glGetTexEnvfv); + SET_GetTexEnviv(disp, glGetTexEnviv); + SET_GetTexGendv(disp, glGetTexGendv); + SET_GetTexGenfv(disp, glGetTexGenfv); + SET_GetTexGeniv(disp, glGetTexGeniv); + SET_GetTexImage(disp, glGetTexImage); + SET_GetTexParameterfv(disp, glGetTexParameterfv); + SET_GetTexParameteriv(disp, glGetTexParameteriv); + SET_GetTexLevelParameterfv(disp, glGetTexLevelParameterfv); + SET_GetTexLevelParameteriv(disp, glGetTexLevelParameteriv); + SET_IsEnabled(disp, glIsEnabled); + SET_IsList(disp, glIsList); + SET_DepthRange(disp, glDepthRange); + SET_Frustum(disp, glFrustum); + SET_LoadIdentity(disp, glLoadIdentity); + SET_LoadMatrixf(disp, glLoadMatrixf); + SET_LoadMatrixd(disp, glLoadMatrixd); + SET_MatrixMode(disp, glMatrixMode); + SET_MultMatrixf(disp, glMultMatrixf); + SET_MultMatrixd(disp, glMultMatrixd); + SET_Ortho(disp, glOrtho); + SET_PopMatrix(disp, glPopMatrix); + SET_PushMatrix(disp, glPushMatrix); + SET_Rotated(disp, glRotated); + SET_Rotatef(disp, glRotatef); + SET_Scaled(disp, glScaled); + SET_Scalef(disp, glScalef); + SET_Translated(disp, glTranslated); + SET_Translatef(disp, glTranslatef); + SET_Viewport(disp, glViewport); + SET_ArrayElement(disp, glArrayElement); + SET_BindTexture(disp, glBindTexture); + SET_ColorPointer(disp, glColorPointer); + SET_DisableClientState(disp, glDisableClientState); + SET_DrawArrays(disp, glDrawArrays); + SET_DrawElements(disp, glDrawElements); + SET_EdgeFlagPointer(disp, glEdgeFlagPointer); + SET_EnableClientState(disp, glEnableClientState); + SET_IndexPointer(disp, glIndexPointer); + SET_Indexub(disp, glIndexub); + SET_Indexubv(disp, glIndexubv); + SET_InterleavedArrays(disp, glInterleavedArrays); + SET_NormalPointer(disp, glNormalPointer); + SET_PolygonOffset(disp, glPolygonOffset); + SET_TexCoordPointer(disp, glTexCoordPointer); + SET_VertexPointer(disp, glVertexPointer); + SET_AreTexturesResident(disp, glAreTexturesResident); + SET_CopyTexImage1D(disp, glCopyTexImage1D); + SET_CopyTexImage2D(disp, glCopyTexImage2D); + SET_CopyTexSubImage1D(disp, glCopyTexSubImage1D); + SET_CopyTexSubImage2D(disp, glCopyTexSubImage2D); + SET_DeleteTextures(disp, glDeleteTextures); + SET_GenTextures(disp, glGenTextures); + SET_GetPointerv(disp, glGetPointerv); + SET_IsTexture(disp, glIsTexture); + SET_PrioritizeTextures(disp, glPrioritizeTextures); + SET_TexSubImage1D(disp, glTexSubImage1D); + SET_TexSubImage2D(disp, glTexSubImage2D); + SET_PopClientAttrib(disp, glPopClientAttrib); + SET_PushClientAttrib(disp, glPushClientAttrib); + SET_BlendColor(disp, glBlendColor); + SET_BlendEquation(disp, glBlendEquation); + SET_DrawRangeElements(disp, glDrawRangeElements); + SET_ColorTable(disp, glColorTable); + SET_ColorTableParameterfv(disp, glColorTableParameterfv); + SET_ColorTableParameteriv(disp, glColorTableParameteriv); + SET_CopyColorTable(disp, glCopyColorTable); + SET_GetColorTable(disp, glGetColorTable); + SET_GetColorTableParameterfv(disp, glGetColorTableParameterfv); + SET_GetColorTableParameteriv(disp, glGetColorTableParameteriv); + SET_ColorSubTable(disp, glColorSubTable); + SET_CopyColorSubTable(disp, glCopyColorSubTable); + SET_ConvolutionFilter1D(disp, glConvolutionFilter1D); + SET_ConvolutionFilter2D(disp, glConvolutionFilter2D); + SET_ConvolutionParameterf(disp, glConvolutionParameterf); + SET_ConvolutionParameterfv(disp, glConvolutionParameterfv); + SET_ConvolutionParameteri(disp, glConvolutionParameteri); + SET_ConvolutionParameteriv(disp, glConvolutionParameteriv); + SET_CopyConvolutionFilter1D(disp, glCopyConvolutionFilter1D); + SET_CopyConvolutionFilter2D(disp, glCopyConvolutionFilter2D); + SET_GetConvolutionFilter(disp, glGetConvolutionFilter); + SET_GetConvolutionParameterfv(disp, glGetConvolutionParameterfv); + SET_GetConvolutionParameteriv(disp, glGetConvolutionParameteriv); + SET_GetSeparableFilter(disp, glGetSeparableFilter); + SET_SeparableFilter2D(disp, glSeparableFilter2D); + SET_GetHistogram(disp, glGetHistogram); + SET_GetHistogramParameterfv(disp, glGetHistogramParameterfv); + SET_GetHistogramParameteriv(disp, glGetHistogramParameteriv); + SET_GetMinmax(disp, glGetMinmax); + SET_GetMinmaxParameterfv(disp, glGetMinmaxParameterfv); + SET_GetMinmaxParameteriv(disp, glGetMinmaxParameteriv); + SET_Histogram(disp, glHistogram); + SET_Minmax(disp, glMinmax); + SET_ResetHistogram(disp, glResetHistogram); + SET_ResetMinmax(disp, glResetMinmax); + SET_TexImage3D(disp, glTexImage3D); + SET_TexSubImage3D(disp, glTexSubImage3D); + SET_CopyTexSubImage3D(disp, glCopyTexSubImage3D); + SET_ActiveTextureARB(disp, glActiveTextureARB); + SET_ClientActiveTextureARB(disp, glClientActiveTextureARB); + SET_MultiTexCoord1dARB(disp, glMultiTexCoord1dARB); + SET_MultiTexCoord1dvARB(disp, glMultiTexCoord1dvARB); + SET_MultiTexCoord1fARB(disp, glMultiTexCoord1fARB); + SET_MultiTexCoord1fvARB(disp, glMultiTexCoord1fvARB); + SET_MultiTexCoord1iARB(disp, glMultiTexCoord1iARB); + SET_MultiTexCoord1ivARB(disp, glMultiTexCoord1ivARB); + SET_MultiTexCoord1sARB(disp, glMultiTexCoord1sARB); + SET_MultiTexCoord1svARB(disp, glMultiTexCoord1svARB); + SET_MultiTexCoord2dARB(disp, glMultiTexCoord2dARB); + SET_MultiTexCoord2dvARB(disp, glMultiTexCoord2dvARB); + SET_MultiTexCoord2fARB(disp, glMultiTexCoord2fARB); + SET_MultiTexCoord2fvARB(disp, glMultiTexCoord2fvARB); + SET_MultiTexCoord2iARB(disp, glMultiTexCoord2iARB); + SET_MultiTexCoord2ivARB(disp, glMultiTexCoord2ivARB); + SET_MultiTexCoord2sARB(disp, glMultiTexCoord2sARB); + SET_MultiTexCoord2svARB(disp, glMultiTexCoord2svARB); + SET_MultiTexCoord3dARB(disp, glMultiTexCoord3dARB); + SET_MultiTexCoord3dvARB(disp, glMultiTexCoord3dvARB); + SET_MultiTexCoord3fARB(disp, glMultiTexCoord3fARB); + SET_MultiTexCoord3fvARB(disp, glMultiTexCoord3fvARB); + SET_MultiTexCoord3iARB(disp, glMultiTexCoord3iARB); + SET_MultiTexCoord3ivARB(disp, glMultiTexCoord3ivARB); + SET_MultiTexCoord3sARB(disp, glMultiTexCoord3sARB); + SET_MultiTexCoord3svARB(disp, glMultiTexCoord3svARB); + SET_MultiTexCoord4dARB(disp, glMultiTexCoord4dARB); + SET_MultiTexCoord4dvARB(disp, glMultiTexCoord4dvARB); + SET_MultiTexCoord4fARB(disp, glMultiTexCoord4fARB); + SET_MultiTexCoord4fvARB(disp, glMultiTexCoord4fvARB); + SET_MultiTexCoord4iARB(disp, glMultiTexCoord4iARB); + SET_MultiTexCoord4ivARB(disp, glMultiTexCoord4ivARB); + SET_MultiTexCoord4sARB(disp, glMultiTexCoord4sARB); + SET_MultiTexCoord4svARB(disp, glMultiTexCoord4svARB); + SET_LoadTransposeMatrixfARB(disp, glLoadTransposeMatrixfARB); + SET_LoadTransposeMatrixdARB(disp, glLoadTransposeMatrixdARB); + SET_MultTransposeMatrixfARB(disp, glMultTransposeMatrixfARB); + SET_MultTransposeMatrixdARB(disp, glMultTransposeMatrixdARB); + SET_SampleCoverageARB(disp, glSampleCoverageARB); + SET_DrawBuffersARB(disp, glDrawBuffersARB); +/* SET_PolygonOffsetEXT(disp, glPolygonOffsetEXT); + SET_GetTexFilterFuncSGIS(disp, glGetTexFilterFuncSGIS); + SET_TexFilterFuncSGIS(disp, glTexFilterFuncSGIS); + SET_GetHistogramEXT(disp, glGetHistogramEXT); + SET_GetHistogramParameterfvEXT(disp, glGetHistogramParameterfvEXT); + SET_GetHistogramParameterivEXT(disp, glGetHistogramParameterivEXT); + SET_GetMinmaxEXT(disp, glGetMinmaxEXT); + SET_GetMinmaxParameterfvEXT(disp, glGetMinmaxParameterfvEXT); + SET_GetMinmaxParameterivEXT(disp, glGetMinmaxParameterivEXT); + SET_GetConvolutionFilterEXT(disp, glGetConvolutionFilterEXT); + SET_GetConvolutionParameterfvEXT(disp, glGetConvolutionParameterfvEXT); + SET_GetConvolutionParameterivEXT(disp, glGetConvolutionParameterivEXT); + SET_GetSeparableFilterEXT(disp, glGetSeparableFilterEXT); + SET_GetColorTableSGI(disp, glGetColorTableSGI); + SET_GetColorTableParameterfvSGI(disp, glGetColorTableParameterfvSGI); + SET_GetColorTableParameterivSGI(disp, glGetColorTableParameterivSGI); + SET_PixelTexGenSGIX(disp, glPixelTexGenSGIX); + SET_PixelTexGenParameteriSGIS(disp, glPixelTexGenParameteriSGIS); + SET_PixelTexGenParameterivSGIS(disp, glPixelTexGenParameterivSGIS); + SET_PixelTexGenParameterfSGIS(disp, glPixelTexGenParameterfSGIS); + SET_PixelTexGenParameterfvSGIS(disp, glPixelTexGenParameterfvSGIS); + SET_GetPixelTexGenParameterivSGIS(disp, glGetPixelTexGenParameterivSGIS); + SET_GetPixelTexGenParameterfvSGIS(disp, glGetPixelTexGenParameterfvSGIS); + SET_TexImage4DSGIS(disp, glTexImage4DSGIS); + SET_TexSubImage4DSGIS(disp, glTexSubImage4DSGIS); */ + SET_AreTexturesResidentEXT(disp, glAreTexturesResident); + SET_GenTexturesEXT(disp, glGenTextures); + SET_IsTextureEXT(disp, glIsTexture); +/* SET_DetailTexFuncSGIS(disp, glDetailTexFuncSGIS); + SET_GetDetailTexFuncSGIS(disp, glGetDetailTexFuncSGIS); + SET_SharpenTexFuncSGIS(disp, glSharpenTexFuncSGIS); + SET_GetSharpenTexFuncSGIS(disp, glGetSharpenTexFuncSGIS); + SET_SampleMaskSGIS(disp, glSampleMaskSGIS); + SET_SamplePatternSGIS(disp, glSamplePatternSGIS); + SET_ColorPointerEXT(disp, glColorPointerEXT); + SET_EdgeFlagPointerEXT(disp, glEdgeFlagPointerEXT); + SET_IndexPointerEXT(disp, glIndexPointerEXT); + SET_NormalPointerEXT(disp, glNormalPointerEXT); + SET_TexCoordPointerEXT(disp, glTexCoordPointerEXT); + SET_VertexPointerEXT(disp, glVertexPointerEXT); + SET_SpriteParameterfSGIX(disp, glSpriteParameterfSGIX); + SET_SpriteParameterfvSGIX(disp, glSpriteParameterfvSGIX); + SET_SpriteParameteriSGIX(disp, glSpriteParameteriSGIX); + SET_SpriteParameterivSGIX(disp, glSpriteParameterivSGIX); + SET_PointParameterfEXT(disp, glPointParameterfEXT); + SET_PointParameterfvEXT(disp, glPointParameterfvEXT); + SET_GetInstrumentsSGIX(disp, glGetInstrumentsSGIX); + SET_InstrumentsBufferSGIX(disp, glInstrumentsBufferSGIX); + SET_PollInstrumentsSGIX(disp, glPollInstrumentsSGIX); + SET_ReadInstrumentsSGIX(disp, glReadInstrumentsSGIX); + SET_StartInstrumentsSGIX(disp, glStartInstrumentsSGIX); + SET_StopInstrumentsSGIX(disp, glStopInstrumentsSGIX); + SET_FrameZoomSGIX(disp, glFrameZoomSGIX); + SET_TagSampleBufferSGIX(disp, glTagSampleBufferSGIX); + SET_ReferencePlaneSGIX(disp, glReferencePlaneSGIX); + SET_FlushRasterSGIX(disp, glFlushRasterSGIX); + SET_GetListParameterfvSGIX(disp, glGetListParameterfvSGIX); + SET_GetListParameterivSGIX(disp, glGetListParameterivSGIX); + SET_ListParameterfSGIX(disp, glListParameterfSGIX); + SET_ListParameterfvSGIX(disp, glListParameterfvSGIX); + SET_ListParameteriSGIX(disp, glListParameteriSGIX); + SET_ListParameterivSGIX(disp, glListParameterivSGIX); + SET_FragmentColorMaterialSGIX(disp, glFragmentColorMaterialSGIX); + SET_FragmentLightfSGIX(disp, glFragmentLightfSGIX); + SET_FragmentLightfvSGIX(disp, glFragmentLightfvSGIX); + SET_FragmentLightiSGIX(disp, glFragmentLightiSGIX); + SET_FragmentLightivSGIX(disp, glFragmentLightivSGIX); + SET_FragmentLightModelfSGIX(disp, glFragmentLightModelfSGIX); + SET_FragmentLightModelfvSGIX(disp, glFragmentLightModelfvSGIX); + SET_FragmentLightModeliSGIX(disp, glFragmentLightModeliSGIX); + SET_FragmentLightModelivSGIX(disp, glFragmentLightModelivSGIX); + SET_FragmentMaterialfSGIX(disp, glFragmentMaterialfSGIX); + SET_FragmentMaterialfvSGIX(disp, glFragmentMaterialfvSGIX); + SET_FragmentMaterialiSGIX(disp, glFragmentMaterialiSGIX); + SET_FragmentMaterialivSGIX(disp, glFragmentMaterialivSGIX); + SET_GetFragmentLightfvSGIX(disp, glGetFragmentLightfvSGIX); + SET_GetFragmentLightivSGIX(disp, glGetFragmentLightivSGIX); + SET_GetFragmentMaterialfvSGIX(disp, glGetFragmentMaterialfvSGIX); + SET_GetFragmentMaterialivSGIX(disp, glGetFragmentMaterialivSGIX); + SET_LightEnviSGIX(disp, glLightEnviSGIX); + SET_VertexWeightfEXT(disp, glVertexWeightfEXT); + SET_VertexWeightfvEXT(disp, glVertexWeightfvEXT); + SET_VertexWeightPointerEXT(disp, glVertexWeightPointerEXT); + SET_FlushVertexArrayRangeNV(disp, glFlushVertexArrayRangeNV); + SET_VertexArrayRangeNV(disp, glVertexArrayRangeNV); + SET_CombinerParameterfvNV(disp, glCombinerParameterfvNV); + SET_CombinerParameterfNV(disp, glCombinerParameterfNV); + SET_CombinerParameterivNV(disp, glCombinerParameterivNV); + SET_CombinerParameteriNV(disp, glCombinerParameteriNV); + SET_CombinerInputNV(disp, glCombinerInputNV); + SET_CombinerOutputNV(disp, glCombinerOutputNV); + SET_FinalCombinerInputNV(disp, glFinalCombinerInputNV); + SET_GetCombinerInputParameterfvNV(disp, glGetCombinerInputParameterfvNV); + SET_GetCombinerInputParameterivNV(disp, glGetCombinerInputParameterivNV); + SET_GetCombinerOutputParameterfvNV(disp, glGetCombinerOutputParameterfvNV); + SET_GetCombinerOutputParameterivNV(disp, glGetCombinerOutputParameterivNV); + SET_GetFinalCombinerInputParameterfvNV(disp, glGetFinalCombinerInputParameterfvNV); + SET_GetFinalCombinerInputParameterivNV(disp, glGetFinalCombinerInputParameterivNV); + SET_ResizeBuffersMESA(disp, glResizeBuffersMESA); + SET_WindowPos2dMESA(disp, glWindowPos2dMESA); + SET_WindowPos2dvMESA(disp, glWindowPos2dvMESA); + SET_WindowPos2fMESA(disp, glWindowPos2fMESA); + SET_WindowPos2fvMESA(disp, glWindowPos2fvMESA); + SET_WindowPos2iMESA(disp, glWindowPos2iMESA); + SET_WindowPos2ivMESA(disp, glWindowPos2ivMESA); + SET_WindowPos2sMESA(disp, glWindowPos2sMESA); + SET_WindowPos2svMESA(disp, glWindowPos2svMESA); + SET_WindowPos3dMESA(disp, glWindowPos3dMESA); + SET_WindowPos3dvMESA(disp, glWindowPos3dvMESA); + SET_WindowPos3fMESA(disp, glWindowPos3fMESA); + SET_WindowPos3fvMESA(disp, glWindowPos3fvMESA); + SET_WindowPos3iMESA(disp, glWindowPos3iMESA); + SET_WindowPos3ivMESA(disp, glWindowPos3ivMESA); + SET_WindowPos3sMESA(disp, glWindowPos3sMESA); + SET_WindowPos3svMESA(disp, glWindowPos3svMESA); + SET_WindowPos4dMESA(disp, glWindowPos4dMESA); + SET_WindowPos4dvMESA(disp, glWindowPos4dvMESA); + SET_WindowPos4fMESA(disp, glWindowPos4fMESA); + SET_WindowPos4fvMESA(disp, glWindowPos4fvMESA); + SET_WindowPos4iMESA(disp, glWindowPos4iMESA); + SET_WindowPos4ivMESA(disp, glWindowPos4ivMESA); + SET_WindowPos4sMESA(disp, glWindowPos4sMESA); + SET_WindowPos4svMESA(disp, glWindowPos4svMESA); + SET_BlendFuncSeparateEXT(disp, glBlendFuncSeparateEXT); + SET_IndexMaterialEXT(disp, glIndexMaterialEXT); + SET_IndexFuncEXT(disp, glIndexFuncEXT); + SET_LockArraysEXT(disp, glLockArraysEXT); + SET_UnlockArraysEXT(disp, glUnlockArraysEXT); + SET_CullParameterdvEXT(disp, glCullParameterdvEXT); + SET_CullParameterfvEXT(disp, glCullParameterfvEXT); + SET_HintPGI(disp, glHintPGI); + SET_FogCoordfEXT(disp, glFogCoordfEXT); + SET_FogCoordfvEXT(disp, glFogCoordfvEXT); + SET_FogCoorddEXT(disp, glFogCoorddEXT); + SET_FogCoorddvEXT(disp, glFogCoorddvEXT); + SET_FogCoordPointerEXT(disp, glFogCoordPointerEXT); + SET_GetColorTableEXT(disp, glGetColorTableEXT); + SET_GetColorTableParameterivEXT(disp, glGetColorTableParameterivEXT); + SET_GetColorTableParameterfvEXT(disp, glGetColorTableParameterfvEXT); + SET_TbufferMask3DFX(disp, glTbufferMask3DFX); + SET_CompressedTexImage3DARB(disp, glCompressedTexImage3DARB); + SET_CompressedTexImage2DARB(disp, glCompressedTexImage2DARB); + SET_CompressedTexImage1DARB(disp, glCompressedTexImage1DARB); + SET_CompressedTexSubImage3DARB(disp, glCompressedTexSubImage3DARB); + SET_CompressedTexSubImage2DARB(disp, glCompressedTexSubImage2DARB); + SET_CompressedTexSubImage1DARB(disp, glCompressedTexSubImage1DARB); + SET_GetCompressedTexImageARB(disp, glGetCompressedTexImageARB); + SET_SecondaryColor3bEXT(disp, glSecondaryColor3bEXT); + SET_SecondaryColor3bvEXT(disp, glSecondaryColor3bvEXT); + SET_SecondaryColor3dEXT(disp, glSecondaryColor3dEXT); + SET_SecondaryColor3dvEXT(disp, glSecondaryColor3dvEXT); + SET_SecondaryColor3fEXT(disp, glSecondaryColor3fEXT); + SET_SecondaryColor3fvEXT(disp, glSecondaryColor3fvEXT); + SET_SecondaryColor3iEXT(disp, glSecondaryColor3iEXT); + SET_SecondaryColor3ivEXT(disp, glSecondaryColor3ivEXT); + SET_SecondaryColor3sEXT(disp, glSecondaryColor3sEXT); + SET_SecondaryColor3svEXT(disp, glSecondaryColor3svEXT); + SET_SecondaryColor3ubEXT(disp, glSecondaryColor3ubEXT); + SET_SecondaryColor3ubvEXT(disp, glSecondaryColor3ubvEXT); + SET_SecondaryColor3uiEXT(disp, glSecondaryColor3uiEXT); + SET_SecondaryColor3uivEXT(disp, glSecondaryColor3uivEXT); + SET_SecondaryColor3usEXT(disp, glSecondaryColor3usEXT); + SET_SecondaryColor3usvEXT(disp, glSecondaryColor3usvEXT); + SET_SecondaryColorPointerEXT(disp, glSecondaryColorPointerEXT); + SET_AreProgramsResidentNV(disp, glAreProgramsResidentNV); + SET_BindProgramNV(disp, glBindProgramNV); + SET_DeleteProgramsNV(disp, glDeleteProgramsNV); + SET_ExecuteProgramNV(disp, glExecuteProgramNV); + SET_GenProgramsNV(disp, glGenProgramsNV); + SET_GetProgramParameterdvNV(disp, glGetProgramParameterdvNV); + SET_GetProgramParameterfvNV(disp, glGetProgramParameterfvNV); + SET_GetProgramivNV(disp, glGetProgramivNV); + SET_GetProgramStringNV(disp, glGetProgramStringNV); + SET_GetTrackMatrixivNV(disp, glGetTrackMatrixivNV); + SET_GetVertexAttribdvARB(disp, glGetVertexAttribdvARB); + SET_GetVertexAttribfvARB(disp, glGetVertexAttribfvARB); + SET_GetVertexAttribivARB(disp, glGetVertexAttribivARB); + SET_GetVertexAttribPointervNV(disp, glGetVertexAttribPointervNV); + SET_IsProgramNV(disp, glIsProgramNV); + SET_LoadProgramNV(disp, glLoadProgramNV); + SET_ProgramParameter4dNV(disp, glProgramParameter4dNV); + SET_ProgramParameter4dvNV(disp, glProgramParameter4dvNV); + SET_ProgramParameter4fNV(disp, glProgramParameter4fNV); + SET_ProgramParameter4fvNV(disp, glProgramParameter4fvNV); + SET_ProgramParameters4dvNV(disp, glProgramParameters4dvNV); + SET_ProgramParameters4fvNV(disp, glProgramParameters4fvNV); + SET_RequestResidentProgramsNV(disp, glRequestResidentProgramsNV); + SET_TrackMatrixNV(disp, glTrackMatrixNV); + SET_VertexAttribPointerNV(disp, glVertexAttribPointerNV); + SET_VertexAttrib1dARB(disp, glVertexAttrib1dARB); + SET_VertexAttrib1dvARB(disp, glVertexAttrib1dvARB); + SET_VertexAttrib1fARB(disp, glVertexAttrib1fARB); + SET_VertexAttrib1fvARB(disp, glVertexAttrib1fvARB); + SET_VertexAttrib1sARB(disp, glVertexAttrib1sARB); + SET_VertexAttrib1svARB(disp, glVertexAttrib1svARB); + SET_VertexAttrib2dARB(disp, glVertexAttrib2dARB); + SET_VertexAttrib2dvARB(disp, glVertexAttrib2dvARB); + SET_VertexAttrib2fARB(disp, glVertexAttrib2fARB); + SET_VertexAttrib2fvARB(disp, glVertexAttrib2fvARB); + SET_VertexAttrib2sARB(disp, glVertexAttrib2sARB); + SET_VertexAttrib2svARB(disp, glVertexAttrib2svARB); + SET_VertexAttrib3dARB(disp, glVertexAttrib3dARB); + SET_VertexAttrib3dvARB(disp, glVertexAttrib3dvARB); + SET_VertexAttrib3fARB(disp, glVertexAttrib3fARB); + SET_VertexAttrib3fvARB(disp, glVertexAttrib3fvARB); + SET_VertexAttrib3sARB(disp, glVertexAttrib3sARB); + SET_VertexAttrib3svARB(disp, glVertexAttrib3svARB); + SET_VertexAttrib4dARB(disp, glVertexAttrib4dARB); + SET_VertexAttrib4dvARB(disp, glVertexAttrib4dvARB); + SET_VertexAttrib4fARB(disp, glVertexAttrib4fARB); + SET_VertexAttrib4fvARB(disp, glVertexAttrib4fvARB); + SET_VertexAttrib4sARB(disp, glVertexAttrib4sARB); + SET_VertexAttrib4svARB(disp, glVertexAttrib4svARB); + SET_VertexAttrib4NubARB(disp, glVertexAttrib4NubARB); + SET_VertexAttrib4NubvARB(disp, glVertexAttrib4NubvARB); + SET_VertexAttribs1dvNV(disp, glVertexAttribs1dvNV); + SET_VertexAttribs1fvNV(disp, glVertexAttribs1fvNV); + SET_VertexAttribs1svNV(disp, glVertexAttribs1svNV); + SET_VertexAttribs2dvNV(disp, glVertexAttribs2dvNV); + SET_VertexAttribs2fvNV(disp, glVertexAttribs2fvNV); + SET_VertexAttribs2svNV(disp, glVertexAttribs2svNV); + SET_VertexAttribs3dvNV(disp, glVertexAttribs3dvNV); + SET_VertexAttribs3fvNV(disp, glVertexAttribs3fvNV); + SET_VertexAttribs3svNV(disp, glVertexAttribs3svNV); + SET_VertexAttribs4dvNV(disp, glVertexAttribs4dvNV); + SET_VertexAttribs4fvNV(disp, glVertexAttribs4fvNV); + SET_VertexAttribs4svNV(disp, glVertexAttribs4svNV); + SET_VertexAttribs4ubvNV(disp, glVertexAttribs4ubvNV); + SET_PointParameteriNV(disp, glPointParameteriNV); + SET_PointParameterivNV(disp, glPointParameterivNV); + SET_MultiDrawArraysEXT(disp, glMultiDrawArraysEXT); + SET_MultiDrawElementsEXT(disp, glMultiDrawElementsEXT); + SET_ActiveStencilFaceEXT(disp, glActiveStencilFaceEXT); + SET_DeleteFencesNV(disp, glDeleteFencesNV); + SET_GenFencesNV(disp, glGenFencesNV); + SET_IsFenceNV(disp, glIsFenceNV); + SET_TestFenceNV(disp, glTestFenceNV); + SET_GetFenceivNV(disp, glGetFenceivNV); + SET_FinishFenceNV(disp, glFinishFenceNV); + SET_SetFenceNV(disp, glSetFenceNV); + SET_VertexAttrib4bvARB(disp, glVertexAttrib4bvARB); + SET_VertexAttrib4ivARB(disp, glVertexAttrib4ivARB); + SET_VertexAttrib4ubvARB(disp, glVertexAttrib4ubvARB); + SET_VertexAttrib4usvARB(disp, glVertexAttrib4usvARB); + SET_VertexAttrib4uivARB(disp, glVertexAttrib4uivARB); + SET_VertexAttrib4NbvARB(disp, glVertexAttrib4NbvARB); + SET_VertexAttrib4NsvARB(disp, glVertexAttrib4NsvARB); + SET_VertexAttrib4NivARB(disp, glVertexAttrib4NivARB); + SET_VertexAttrib4NusvARB(disp, glVertexAttrib4NusvARB); + SET_VertexAttrib4NuivARB(disp, glVertexAttrib4NuivARB); + SET_VertexAttribPointerARB(disp, glVertexAttribPointerARB); + SET_EnableVertexAttribArrayARB(disp, glEnableVertexAttribArrayARB); + SET_DisableVertexAttribArrayARB(disp, glDisableVertexAttribArrayARB); + SET_ProgramStringARB(disp, glProgramStringARB); + SET_ProgramEnvParameter4dARB(disp, glProgramEnvParameter4dARB); + SET_ProgramEnvParameter4dvARB(disp, glProgramEnvParameter4dvARB); + SET_ProgramEnvParameter4fARB(disp, glProgramEnvParameter4fARB); + SET_ProgramEnvParameter4fvARB(disp, glProgramEnvParameter4fvARB); + SET_ProgramLocalParameter4dARB(disp, glProgramLocalParameter4dARB); + SET_ProgramLocalParameter4dvARB(disp, glProgramLocalParameter4dvARB); + SET_ProgramLocalParameter4fARB(disp, glProgramLocalParameter4fARB); + SET_ProgramLocalParameter4fvARB(disp, glProgramLocalParameter4fvARB); + SET_GetProgramEnvParameterdvARB(disp, glGetProgramEnvParameterdvARB); + SET_GetProgramEnvParameterfvARB(disp, glGetProgramEnvParameterfvARB); + SET_GetProgramLocalParameterdvARB(disp, glGetProgramLocalParameterdvARB); + SET_GetProgramLocalParameterfvARB(disp, glGetProgramLocalParameterfvARB); + SET_GetProgramivARB(disp, glGetProgramivARB); + SET_GetProgramStringARB(disp, glGetProgramStringARB); + SET_ProgramNamedParameter4fNV(disp, glProgramNamedParameter4fNV); + SET_ProgramNamedParameter4dNV(disp, glProgramNamedParameter4dNV); + SET_ProgramNamedParameter4fvNV(disp, glProgramNamedParameter4fvNV); + SET_ProgramNamedParameter4dvNV(disp, glProgramNamedParameter4dvNV); + SET_GetProgramNamedParameterfvNV(disp, glGetProgramNamedParameterfvNV); + SET_GetProgramNamedParameterdvNV(disp, glGetProgramNamedParameterdvNV); + SET_BindBufferARB(disp, glBindBufferARB); + SET_BufferDataARB(disp, glBufferDataARB); + SET_BufferSubDataARB(disp, glBufferSubDataARB); + SET_DeleteBuffersARB(disp, glDeleteBuffersARB); + SET_GenBuffersARB(disp, glGenBuffersARB); + SET_GetBufferParameterivARB(disp, glGetBufferParameterivARB); + SET_GetBufferPointervARB(disp, glGetBufferPointervARB); + SET_GetBufferSubDataARB(disp, glGetBufferSubDataARB); + SET_IsBufferARB(disp, glIsBufferARB); + SET_MapBufferARB(disp, glMapBufferARB); + SET_UnmapBufferARB(disp, glUnmapBufferARB); + SET_DepthBoundsEXT(disp, glDepthBoundsEXT); + SET_GenQueriesARB(disp, glGenQueriesARB); + SET_DeleteQueriesARB(disp, glDeleteQueriesARB); + SET_IsQueryARB(disp, glIsQueryARB); + SET_BeginQueryARB(disp, glBeginQueryARB); + SET_EndQueryARB(disp, glEndQueryARB); + SET_GetQueryivARB(disp, glGetQueryivARB); + SET_GetQueryObjectivARB(disp, glGetQueryObjectivARB); + SET_GetQueryObjectuivARB(disp, glGetQueryObjectuivARB); + SET_MultiModeDrawArraysIBM(disp, glMultiModeDrawArraysIBM); + SET_MultiModeDrawElementsIBM(disp, glMultiModeDrawElementsIBM); + SET_BlendEquationSeparateEXT(disp, glBlendEquationSeparateEXT); + SET_DeleteObjectARB(disp, glDeleteObjectARB); + SET_GetHandleARB(disp, glGetHandleARB); + SET_DetachObjectARB(disp, glDetachObjectARB); + SET_CreateShaderObjectARB(disp, glCreateShaderObjectARB); + SET_ShaderSourceARB(disp, glShaderSourceARB); + SET_CompileShaderARB(disp, glCompileShaderARB); + SET_CreateProgramObjectARB(disp, glCreateProgramObjectARB); + SET_AttachObjectARB(disp, glAttachObjectARB); + SET_LinkProgramARB(disp, glLinkProgramARB); + SET_UseProgramObjectARB(disp, glUseProgramObjectARB); + SET_ValidateProgramARB(disp, glValidateProgramARB); + SET_Uniform1fARB(disp, glUniform1fARB); + SET_Uniform2fARB(disp, glUniform2fARB); + SET_Uniform3fARB(disp, glUniform3fARB); + SET_Uniform4fARB(disp, glUniform4fARB); + SET_Uniform1iARB(disp, glUniform1iARB); + SET_Uniform2iARB(disp, glUniform2iARB); + SET_Uniform3iARB(disp, glUniform3iARB); + SET_Uniform4iARB(disp, glUniform4iARB); + SET_Uniform1fvARB(disp, glUniform1fvARB); + SET_Uniform2fvARB(disp, glUniform2fvARB); + SET_Uniform3fvARB(disp, glUniform3fvARB); + SET_Uniform4fvARB(disp, glUniform4fvARB); + SET_Uniform1ivARB(disp, glUniform1ivARB); + SET_Uniform2ivARB(disp, glUniform2ivARB); + SET_Uniform3ivARB(disp, glUniform3ivARB); + SET_Uniform4ivARB(disp, glUniform4ivARB); + SET_UniformMatrix2fvARB(disp, glUniformMatrix2fvARB); + SET_UniformMatrix3fvARB(disp, glUniformMatrix3fvARB); + SET_UniformMatrix4fvARB(disp, glUniformMatrix4fvARB); + SET_GetObjectParameterfvARB(disp, glGetObjectParameterfvARB); + SET_GetObjectParameterivARB(disp, glGetObjectParameterivARB); + SET_GetInfoLogARB(disp, glGetInfoLogARB); + SET_GetAttachedObjectsARB(disp, glGetAttachedObjectsARB); + SET_GetUniformLocationARB(disp, glGetUniformLocationARB); + SET_GetActiveUniformARB(disp, glGetActiveUniformARB); + SET_GetUniformfvARB(disp, glGetUniformfvARB); + SET_GetUniformivARB(disp, glGetUniformivARB); + SET_GetShaderSourceARB(disp, glGetShaderSourceARB); + SET_BindAttribLocationARB(disp, glBindAttribLocationARB); + SET_GetActiveAttribARB(disp, glGetActiveAttribARB); + SET_GetAttribLocationARB(disp, glGetAttribLocationARB); + SET_GetVertexAttribdvNV(disp, glGetVertexAttribdvNV); + SET_GetVertexAttribfvNV(disp, glGetVertexAttribfvNV); + SET_GetVertexAttribivNV(disp, glGetVertexAttribivNV); + SET_VertexAttrib1dNV(disp, glVertexAttrib1dNV); + SET_VertexAttrib1dvNV(disp, glVertexAttrib1dvNV); + SET_VertexAttrib1fNV(disp, glVertexAttrib1fNV); + SET_VertexAttrib1fvNV(disp, glVertexAttrib1fvNV); + SET_VertexAttrib1sNV(disp, glVertexAttrib1sNV); + SET_VertexAttrib1svNV(disp, glVertexAttrib1svNV); + SET_VertexAttrib2dNV(disp, glVertexAttrib2dNV); + SET_VertexAttrib2dvNV(disp, glVertexAttrib2dvNV); + SET_VertexAttrib2fNV(disp, glVertexAttrib2fNV); + SET_VertexAttrib2fvNV(disp, glVertexAttrib2fvNV); + SET_VertexAttrib2sNV(disp, glVertexAttrib2sNV); + SET_VertexAttrib2svNV(disp, glVertexAttrib2svNV); + SET_VertexAttrib3dNV(disp, glVertexAttrib3dNV); + SET_VertexAttrib3dvNV(disp, glVertexAttrib3dvNV); + SET_VertexAttrib3fNV(disp, glVertexAttrib3fNV); + SET_VertexAttrib3fvNV(disp, glVertexAttrib3fvNV); + SET_VertexAttrib3sNV(disp, glVertexAttrib3sNV); + SET_VertexAttrib3svNV(disp, glVertexAttrib3svNV); + SET_VertexAttrib4dNV(disp, glVertexAttrib4dNV); + SET_VertexAttrib4dvNV(disp, glVertexAttrib4dvNV); + SET_VertexAttrib4fNV(disp, glVertexAttrib4fNV); + SET_VertexAttrib4fvNV(disp, glVertexAttrib4fvNV); + SET_VertexAttrib4sNV(disp, glVertexAttrib4sNV); + SET_VertexAttrib4svNV(disp, glVertexAttrib4svNV); + SET_VertexAttrib4ubNV(disp, glVertexAttrib4ubNV); + SET_VertexAttrib4ubvNV(disp, glVertexAttrib4ubvNV); + SET_GenFragmentShadersATI(disp, glGenFragmentShadersATI); + SET_BindFragmentShaderATI(disp, glBindFragmentShaderATI); + SET_DeleteFragmentShaderATI(disp, glDeleteFragmentShaderATI); + SET_BeginFragmentShaderATI(disp, glBeginFragmentShaderATI); + SET_EndFragmentShaderATI(disp, glEndFragmentShaderATI); + SET_PassTexCoordATI(disp, glPassTexCoordATI); + SET_SampleMapATI(disp, glSampleMapATI); + SET_ColorFragmentOp1ATI(disp, glColorFragmentOp1ATI); + SET_ColorFragmentOp2ATI(disp, glColorFragmentOp2ATI); + SET_ColorFragmentOp3ATI(disp, glColorFragmentOp3ATI); + SET_AlphaFragmentOp1ATI(disp, glAlphaFragmentOp1ATI); + SET_AlphaFragmentOp2ATI(disp, glAlphaFragmentOp2ATI); + SET_AlphaFragmentOp3ATI(disp, glAlphaFragmentOp3ATI); + SET_SetFragmentShaderConstantATI(disp, glSetFragmentShaderConstantATI); + SET_IsRenderbufferEXT(disp, glIsRenderbufferEXT); + SET_BindRenderbufferEXT(disp, glBindRenderbufferEXT); + SET_DeleteRenderbuffersEXT(disp, glDeleteRenderbuffersEXT); + SET_GenRenderbuffersEXT(disp, glGenRenderbuffersEXT); + SET_RenderbufferStorageEXT(disp, glRenderbufferStorageEXT); + SET_GetRenderbufferParameterivEXT(disp, glGetRenderbufferParameterivEXT); + SET_IsFramebufferEXT(disp, glIsFramebufferEXT); + SET_BindFramebufferEXT(disp, glBindFramebufferEXT); + SET_DeleteFramebuffersEXT(disp, glDeleteFramebuffersEXT); + SET_GenFramebuffersEXT(disp, glGenFramebuffersEXT); + SET_CheckFramebufferStatusEXT(disp, glCheckFramebufferStatusEXT); + SET_FramebufferTexture1DEXT(disp, glFramebufferTexture1DEXT); + SET_FramebufferTexture2DEXT(disp, glFramebufferTexture2DEXT); + SET_FramebufferTexture3DEXT(disp, glFramebufferTexture3DEXT); + SET_FramebufferRenderbufferEXT(disp, glFramebufferRenderbufferEXT); + SET_GetFramebufferAttachmentParameterivEXT(disp, glGetFramebufferAttachmentParameterivEXT); + SET_GenerateMipmapEXT(disp, glGenerateMipmapEXT); + SET_StencilFuncSeparate(disp, glStencilFuncSeparate); + SET_StencilOpSeparate(disp, glStencilOpSeparate); + SET_StencilMaskSeparate(disp, glStencilMaskSeparate); + SET_GetQueryObjecti64vEXT(disp, glGetQueryObjecti64vEXT); + SET_GetQueryObjectui64vEXT(disp, glGetQueryObjectui64vEXT); + SET_BlitFramebufferEXT(disp, glBlitFramebufferEXT); + SET_LoadTransposeMatrixfARB(disp, glLoadTransposeMatrixfARB); + SET_LoadTransposeMatrixdARB(disp, glLoadTransposeMatrixdARB); + SET_MultTransposeMatrixfARB(disp, glMultTransposeMatrixfARB); + SET_MultTransposeMatrixdARB(disp, glMultTransposeMatrixdARB); + SET_SampleCoverageARB(disp, glSampleCoverageARB); + SET_DrawBuffersARB(disp, glDrawBuffersARB); + SET_PolygonOffsetEXT(disp, glPolygonOffsetEXT); + SET_GetTexFilterFuncSGIS(disp, glGetTexFilterFuncSGIS); + SET_TexFilterFuncSGIS(disp, glTexFilterFuncSGIS); + SET_GetHistogramEXT(disp, glGetHistogramEXT); + SET_GetHistogramParameterfvEXT(disp, glGetHistogramParameterfvEXT); + SET_GetHistogramParameterivEXT(disp, glGetHistogramParameterivEXT); + SET_GetMinmaxEXT(disp, glGetMinmaxEXT); + SET_GetMinmaxParameterfvEXT(disp, glGetMinmaxParameterfvEXT); + SET_GetMinmaxParameterivEXT(disp, glGetMinmaxParameterivEXT); + SET_GetConvolutionFilterEXT(disp, glGetConvolutionFilterEXT); + SET_GetConvolutionParameterfvEXT(disp, glGetConvolutionParameterfvEXT); + SET_GetConvolutionParameterivEXT(disp, glGetConvolutionParameterivEXT); + SET_GetSeparableFilterEXT(disp, glGetSeparableFilterEXT); + SET_GetColorTableSGI(disp, glGetColorTableSGI); + SET_GetColorTableParameterfvSGI(disp, glGetColorTableParameterfvSGI); + SET_GetColorTableParameterivSGI(disp, glGetColorTableParameterivSGI); + SET_PixelTexGenSGIX(disp, glPixelTexGenSGIX); + SET_PixelTexGenParameteriSGIS(disp, glPixelTexGenParameteriSGIS); + SET_PixelTexGenParameterivSGIS(disp, glPixelTexGenParameterivSGIS); + SET_PixelTexGenParameterfSGIS(disp, glPixelTexGenParameterfSGIS); + SET_PixelTexGenParameterfvSGIS(disp, glPixelTexGenParameterfvSGIS); + SET_GetPixelTexGenParameterivSGIS(disp, glGetPixelTexGenParameterivSGIS); + SET_GetPixelTexGenParameterfvSGIS(disp, glGetPixelTexGenParameterfvSGIS); + SET_TexImage4DSGIS(disp, glTexImage4DSGIS); + SET_TexSubImage4DSGIS(disp, glTexSubImage4DSGIS); + SET_AreTexturesResidentEXT(disp, glAreTexturesResidentEXT); + SET_GenTexturesEXT(disp, glGenTexturesEXT); + SET_IsTextureEXT(disp, glIsTextureEXT); + SET_DetailTexFuncSGIS(disp, glDetailTexFuncSGIS); + SET_GetDetailTexFuncSGIS(disp, glGetDetailTexFuncSGIS); + SET_SharpenTexFuncSGIS(disp, glSharpenTexFuncSGIS); + SET_GetSharpenTexFuncSGIS(disp, glGetSharpenTexFuncSGIS); + SET_SampleMaskSGIS(disp, glSampleMaskSGIS); + SET_SamplePatternSGIS(disp, glSamplePatternSGIS); + SET_ColorPointerEXT(disp, glColorPointerEXT); + SET_EdgeFlagPointerEXT(disp, glEdgeFlagPointerEXT); + SET_IndexPointerEXT(disp, glIndexPointerEXT); + SET_NormalPointerEXT(disp, glNormalPointerEXT); + SET_TexCoordPointerEXT(disp, glTexCoordPointerEXT); + SET_VertexPointerEXT(disp, glVertexPointerEXT); + SET_SpriteParameterfSGIX(disp, glSpriteParameterfSGIX); + SET_SpriteParameterfvSGIX(disp, glSpriteParameterfvSGIX); + SET_SpriteParameteriSGIX(disp, glSpriteParameteriSGIX); + SET_SpriteParameterivSGIX(disp, glSpriteParameterivSGIX); + SET_PointParameterfEXT(disp, glPointParameterfEXT); + SET_PointParameterfvEXT(disp, glPointParameterfvEXT); + SET_GetInstrumentsSGIX(disp, glGetInstrumentsSGIX); + SET_InstrumentsBufferSGIX(disp, glInstrumentsBufferSGIX); + SET_PollInstrumentsSGIX(disp, glPollInstrumentsSGIX); + SET_ReadInstrumentsSGIX(disp, glReadInstrumentsSGIX); + SET_StartInstrumentsSGIX(disp, glStartInstrumentsSGIX); + SET_StopInstrumentsSGIX(disp, glStopInstrumentsSGIX); + SET_FrameZoomSGIX(disp, glFrameZoomSGIX); + SET_TagSampleBufferSGIX(disp, glTagSampleBufferSGIX); + SET_ReferencePlaneSGIX(disp, glReferencePlaneSGIX); + SET_FlushRasterSGIX(disp, glFlushRasterSGIX); + SET_GetListParameterfvSGIX(disp, glGetListParameterfvSGIX); + SET_GetListParameterivSGIX(disp, glGetListParameterivSGIX); + SET_ListParameterfSGIX(disp, glListParameterfSGIX); + SET_ListParameterfvSGIX(disp, glListParameterfvSGIX); + SET_ListParameteriSGIX(disp, glListParameteriSGIX); + SET_ListParameterivSGIX(disp, glListParameterivSGIX); + SET_FragmentColorMaterialSGIX(disp, glFragmentColorMaterialSGIX); + SET_FragmentLightfSGIX(disp, glFragmentLightfSGIX); + SET_FragmentLightfvSGIX(disp, glFragmentLightfvSGIX); + SET_FragmentLightiSGIX(disp, glFragmentLightiSGIX); + SET_FragmentLightivSGIX(disp, glFragmentLightivSGIX); + SET_FragmentLightModelfSGIX(disp, glFragmentLightModelfSGIX); + SET_FragmentLightModelfvSGIX(disp, glFragmentLightModelfvSGIX); + SET_FragmentLightModeliSGIX(disp, glFragmentLightModeliSGIX); + SET_FragmentLightModelivSGIX(disp, glFragmentLightModelivSGIX); + SET_FragmentMaterialfSGIX(disp, glFragmentMaterialfSGIX); + SET_FragmentMaterialfvSGIX(disp, glFragmentMaterialfvSGIX); + SET_FragmentMaterialiSGIX(disp, glFragmentMaterialiSGIX); + SET_FragmentMaterialivSGIX(disp, glFragmentMaterialivSGIX); + SET_GetFragmentLightfvSGIX(disp, glGetFragmentLightfvSGIX); + SET_GetFragmentLightivSGIX(disp, glGetFragmentLightivSGIX); + SET_GetFragmentMaterialfvSGIX(disp, glGetFragmentMaterialfvSGIX); + SET_GetFragmentMaterialivSGIX(disp, glGetFragmentMaterialivSGIX); + SET_LightEnviSGIX(disp, glLightEnviSGIX); + SET_VertexWeightfEXT(disp, glVertexWeightfEXT); + SET_VertexWeightfvEXT(disp, glVertexWeightfvEXT); + SET_VertexWeightPointerEXT(disp, glVertexWeightPointerEXT); + SET_FlushVertexArrayRangeNV(disp, glFlushVertexArrayRangeNV); + SET_VertexArrayRangeNV(disp, glVertexArrayRangeNV); + SET_CombinerParameterfvNV(disp, glCombinerParameterfvNV); + SET_CombinerParameterfNV(disp, glCombinerParameterfNV); + SET_CombinerParameterivNV(disp, glCombinerParameterivNV); + SET_CombinerParameteriNV(disp, glCombinerParameteriNV); + SET_CombinerInputNV(disp, glCombinerInputNV); + SET_CombinerOutputNV(disp, glCombinerOutputNV); + SET_FinalCombinerInputNV(disp, glFinalCombinerInputNV); + SET_GetCombinerInputParameterfvNV(disp, glGetCombinerInputParameterfvNV); + SET_GetCombinerInputParameterivNV(disp, glGetCombinerInputParameterivNV); + SET_GetCombinerOutputParameterfvNV(disp, glGetCombinerOutputParameterfvNV); + SET_GetCombinerOutputParameterivNV(disp, glGetCombinerOutputParameterivNV); + SET_GetFinalCombinerInputParameterfvNV(disp, glGetFinalCombinerInputParameterfvNV); + SET_GetFinalCombinerInputParameterivNV(disp, glGetFinalCombinerInputParameterivNV); + SET_ResizeBuffersMESA(disp, glResizeBuffersMESA); + SET_WindowPos2dMESA(disp, glWindowPos2dMESA); + SET_WindowPos2dvMESA(disp, glWindowPos2dvMESA); + SET_WindowPos2fMESA(disp, glWindowPos2fMESA); + SET_WindowPos2fvMESA(disp, glWindowPos2fvMESA); + SET_WindowPos2iMESA(disp, glWindowPos2iMESA); + SET_WindowPos2ivMESA(disp, glWindowPos2ivMESA); + SET_WindowPos2sMESA(disp, glWindowPos2sMESA); + SET_WindowPos2svMESA(disp, glWindowPos2svMESA); + SET_WindowPos3dMESA(disp, glWindowPos3dMESA); + SET_WindowPos3dvMESA(disp, glWindowPos3dvMESA); + SET_WindowPos3fMESA(disp, glWindowPos3fMESA); + SET_WindowPos3fvMESA(disp, glWindowPos3fvMESA); + SET_WindowPos3iMESA(disp, glWindowPos3iMESA); + SET_WindowPos3ivMESA(disp, glWindowPos3ivMESA); + SET_WindowPos3sMESA(disp, glWindowPos3sMESA); + SET_WindowPos3svMESA(disp, glWindowPos3svMESA); + SET_WindowPos4dMESA(disp, glWindowPos4dMESA); + SET_WindowPos4dvMESA(disp, glWindowPos4dvMESA); + SET_WindowPos4fMESA(disp, glWindowPos4fMESA); + SET_WindowPos4fvMESA(disp, glWindowPos4fvMESA); + SET_WindowPos4iMESA(disp, glWindowPos4iMESA); + SET_WindowPos4ivMESA(disp, glWindowPos4ivMESA); + SET_WindowPos4sMESA(disp, glWindowPos4sMESA); + SET_WindowPos4svMESA(disp, glWindowPos4svMESA); + SET_BlendFuncSeparateEXT(disp, glBlendFuncSeparateEXT); + SET_IndexMaterialEXT(disp, glIndexMaterialEXT); + SET_IndexFuncEXT(disp, glIndexFuncEXT); + SET_LockArraysEXT(disp, glLockArraysEXT); + SET_UnlockArraysEXT(disp, glUnlockArraysEXT); + SET_CullParameterdvEXT(disp, glCullParameterdvEXT); + SET_CullParameterfvEXT(disp, glCullParameterfvEXT); + SET_HintPGI(disp, glHintPGI); + SET_FogCoordfEXT(disp, glFogCoordfEXT); + SET_FogCoordfvEXT(disp, glFogCoordfvEXT); + SET_FogCoorddEXT(disp, glFogCoorddEXT); + SET_FogCoorddvEXT(disp, glFogCoorddvEXT); + SET_FogCoordPointerEXT(disp, glFogCoordPointerEXT); + SET_GetColorTableEXT(disp, glGetColorTableEXT); + SET_GetColorTableParameterivEXT(disp, glGetColorTableParameterivEXT); + SET_GetColorTableParameterfvEXT(disp, glGetColorTableParameterfvEXT); + SET_TbufferMask3DFX(disp, glTbufferMask3DFX); + SET_CompressedTexImage3DARB(disp, glCompressedTexImage3DARB); + SET_CompressedTexImage2DARB(disp, glCompressedTexImage2DARB); + SET_CompressedTexImage1DARB(disp, glCompressedTexImage1DARB); + SET_CompressedTexSubImage3DARB(disp, glCompressedTexSubImage3DARB); + SET_CompressedTexSubImage2DARB(disp, glCompressedTexSubImage2DARB); + SET_CompressedTexSubImage1DARB(disp, glCompressedTexSubImage1DARB); + SET_GetCompressedTexImageARB(disp, glGetCompressedTexImageARB); + SET_SecondaryColor3bEXT(disp, glSecondaryColor3bEXT); + SET_SecondaryColor3bvEXT(disp, glSecondaryColor3bvEXT); + SET_SecondaryColor3dEXT(disp, glSecondaryColor3dEXT); + SET_SecondaryColor3dvEXT(disp, glSecondaryColor3dvEXT); + SET_SecondaryColor3fEXT(disp, glSecondaryColor3fEXT); + SET_SecondaryColor3fvEXT(disp, glSecondaryColor3fvEXT); + SET_SecondaryColor3iEXT(disp, glSecondaryColor3iEXT); + SET_SecondaryColor3ivEXT(disp, glSecondaryColor3ivEXT); + SET_SecondaryColor3sEXT(disp, glSecondaryColor3sEXT); + SET_SecondaryColor3svEXT(disp, glSecondaryColor3svEXT); + SET_SecondaryColor3ubEXT(disp, glSecondaryColor3ubEXT); + SET_SecondaryColor3ubvEXT(disp, glSecondaryColor3ubvEXT); + SET_SecondaryColor3uiEXT(disp, glSecondaryColor3uiEXT); + SET_SecondaryColor3uivEXT(disp, glSecondaryColor3uivEXT); + SET_SecondaryColor3usEXT(disp, glSecondaryColor3usEXT); + SET_SecondaryColor3usvEXT(disp, glSecondaryColor3usvEXT); + SET_SecondaryColorPointerEXT(disp, glSecondaryColorPointerEXT); + SET_AreProgramsResidentNV(disp, glAreProgramsResidentNV); + SET_BindProgramNV(disp, glBindProgramNV); + SET_DeleteProgramsNV(disp, glDeleteProgramsNV); + SET_ExecuteProgramNV(disp, glExecuteProgramNV); + SET_GenProgramsNV(disp, glGenProgramsNV); + SET_GetProgramParameterdvNV(disp, glGetProgramParameterdvNV); + SET_GetProgramParameterfvNV(disp, glGetProgramParameterfvNV); + SET_GetProgramivNV(disp, glGetProgramivNV); + SET_GetProgramStringNV(disp, glGetProgramStringNV); + SET_GetTrackMatrixivNV(disp, glGetTrackMatrixivNV); + SET_GetVertexAttribdvARB(disp, glGetVertexAttribdvARB); + SET_GetVertexAttribfvARB(disp, glGetVertexAttribfvARB); + SET_GetVertexAttribivARB(disp, glGetVertexAttribivARB); + SET_GetVertexAttribPointervNV(disp, glGetVertexAttribPointervNV); + SET_IsProgramNV(disp, glIsProgramNV); + SET_LoadProgramNV(disp, glLoadProgramNV); + SET_ProgramParameter4dNV(disp, glProgramParameter4dNV); + SET_ProgramParameter4dvNV(disp, glProgramParameter4dvNV); + SET_ProgramParameter4fNV(disp, glProgramParameter4fNV); + SET_ProgramParameter4fvNV(disp, glProgramParameter4fvNV); + SET_ProgramParameters4dvNV(disp, glProgramParameters4dvNV); + SET_ProgramParameters4fvNV(disp, glProgramParameters4fvNV); + SET_RequestResidentProgramsNV(disp, glRequestResidentProgramsNV); + SET_TrackMatrixNV(disp, glTrackMatrixNV); + SET_VertexAttribPointerNV(disp, glVertexAttribPointerNV); + SET_VertexAttrib1dARB(disp, glVertexAttrib1dARB); + SET_VertexAttrib1dvARB(disp, glVertexAttrib1dvARB); + SET_VertexAttrib1fARB(disp, glVertexAttrib1fARB); + SET_VertexAttrib1fvARB(disp, glVertexAttrib1fvARB); + SET_VertexAttrib1sARB(disp, glVertexAttrib1sARB); + SET_VertexAttrib1svARB(disp, glVertexAttrib1svARB); + SET_VertexAttrib2dARB(disp, glVertexAttrib2dARB); + SET_VertexAttrib2dvARB(disp, glVertexAttrib2dvARB); + SET_VertexAttrib2fARB(disp, glVertexAttrib2fARB); + SET_VertexAttrib2fvARB(disp, glVertexAttrib2fvARB); + SET_VertexAttrib2sARB(disp, glVertexAttrib2sARB); + SET_VertexAttrib2svARB(disp, glVertexAttrib2svARB); + SET_VertexAttrib3dARB(disp, glVertexAttrib3dARB); + SET_VertexAttrib3dvARB(disp, glVertexAttrib3dvARB); + SET_VertexAttrib3fARB(disp, glVertexAttrib3fARB); + SET_VertexAttrib3fvARB(disp, glVertexAttrib3fvARB); + SET_VertexAttrib3sARB(disp, glVertexAttrib3sARB); + SET_VertexAttrib3svARB(disp, glVertexAttrib3svARB); + SET_VertexAttrib4dARB(disp, glVertexAttrib4dARB); + SET_VertexAttrib4dvARB(disp, glVertexAttrib4dvARB); + SET_VertexAttrib4fARB(disp, glVertexAttrib4fARB); + SET_VertexAttrib4fvARB(disp, glVertexAttrib4fvARB); + SET_VertexAttrib4sARB(disp, glVertexAttrib4sARB); + SET_VertexAttrib4svARB(disp, glVertexAttrib4svARB); + SET_VertexAttrib4NubARB(disp, glVertexAttrib4NubARB); + SET_VertexAttrib4NubvARB(disp, glVertexAttrib4NubvARB); + SET_VertexAttribs1dvNV(disp, glVertexAttribs1dvNV); + SET_VertexAttribs1fvNV(disp, glVertexAttribs1fvNV); + SET_VertexAttribs1svNV(disp, glVertexAttribs1svNV); + SET_VertexAttribs2dvNV(disp, glVertexAttribs2dvNV); + SET_VertexAttribs2fvNV(disp, glVertexAttribs2fvNV); + SET_VertexAttribs2svNV(disp, glVertexAttribs2svNV); + SET_VertexAttribs3dvNV(disp, glVertexAttribs3dvNV); + SET_VertexAttribs3fvNV(disp, glVertexAttribs3fvNV); + SET_VertexAttribs3svNV(disp, glVertexAttribs3svNV); + SET_VertexAttribs4dvNV(disp, glVertexAttribs4dvNV); + SET_VertexAttribs4fvNV(disp, glVertexAttribs4fvNV); + SET_VertexAttribs4svNV(disp, glVertexAttribs4svNV); + SET_VertexAttribs4ubvNV(disp, glVertexAttribs4ubvNV); + SET_PointParameteriNV(disp, glPointParameteriNV); + SET_PointParameterivNV(disp, glPointParameterivNV); + SET_MultiDrawArraysEXT(disp, glMultiDrawArraysEXT); + SET_MultiDrawElementsEXT(disp, glMultiDrawElementsEXT); + SET_ActiveStencilFaceEXT(disp, glActiveStencilFaceEXT); + SET_DeleteFencesNV(disp, glDeleteFencesNV); + SET_GenFencesNV(disp, glGenFencesNV); + SET_IsFenceNV(disp, glIsFenceNV); + SET_TestFenceNV(disp, glTestFenceNV); + SET_GetFenceivNV(disp, glGetFenceivNV); + SET_FinishFenceNV(disp, glFinishFenceNV); + SET_SetFenceNV(disp, glSetFenceNV); + SET_VertexAttrib4bvARB(disp, glVertexAttrib4bvARB); + SET_VertexAttrib4ivARB(disp, glVertexAttrib4ivARB); + SET_VertexAttrib4ubvARB(disp, glVertexAttrib4ubvARB); + SET_VertexAttrib4usvARB(disp, glVertexAttrib4usvARB); + SET_VertexAttrib4uivARB(disp, glVertexAttrib4uivARB); + SET_VertexAttrib4NbvARB(disp, glVertexAttrib4NbvARB); + SET_VertexAttrib4NsvARB(disp, glVertexAttrib4NsvARB); + SET_VertexAttrib4NivARB(disp, glVertexAttrib4NivARB); + SET_VertexAttrib4NusvARB(disp, glVertexAttrib4NusvARB); + SET_VertexAttrib4NuivARB(disp, glVertexAttrib4NuivARB); + SET_VertexAttribPointerARB(disp, glVertexAttribPointerARB); + SET_EnableVertexAttribArrayARB(disp, glEnableVertexAttribArrayARB); + SET_DisableVertexAttribArrayARB(disp, glDisableVertexAttribArrayARB); + SET_ProgramStringARB(disp, glProgramStringARB); + SET_ProgramEnvParameter4dARB(disp, glProgramEnvParameter4dARB); + SET_ProgramEnvParameter4dvARB(disp, glProgramEnvParameter4dvARB); + SET_ProgramEnvParameter4fARB(disp, glProgramEnvParameter4fARB); + SET_ProgramEnvParameter4fvARB(disp, glProgramEnvParameter4fvARB); + SET_ProgramLocalParameter4dARB(disp, glProgramLocalParameter4dARB); + SET_ProgramLocalParameter4dvARB(disp, glProgramLocalParameter4dvARB); + SET_ProgramLocalParameter4fARB(disp, glProgramLocalParameter4fARB); + SET_ProgramLocalParameter4fvARB(disp, glProgramLocalParameter4fvARB); + SET_GetProgramEnvParameterdvARB(disp, glGetProgramEnvParameterdvARB); + SET_GetProgramEnvParameterfvARB(disp, glGetProgramEnvParameterfvARB); + SET_GetProgramLocalParameterdvARB(disp, glGetProgramLocalParameterdvARB); + SET_GetProgramLocalParameterfvARB(disp, glGetProgramLocalParameterfvARB); + SET_GetProgramivARB(disp, glGetProgramivARB); + SET_GetProgramStringARB(disp, glGetProgramStringARB); + SET_ProgramNamedParameter4fNV(disp, glProgramNamedParameter4fNV); + SET_ProgramNamedParameter4dNV(disp, glProgramNamedParameter4dNV); + SET_ProgramNamedParameter4fvNV(disp, glProgramNamedParameter4fvNV); + SET_ProgramNamedParameter4dvNV(disp, glProgramNamedParameter4dvNV); + SET_GetProgramNamedParameterfvNV(disp, glGetProgramNamedParameterfvNV); + SET_GetProgramNamedParameterdvNV(disp, glGetProgramNamedParameterdvNV); + SET_BindBufferARB(disp, glBindBufferARB); + SET_BufferDataARB(disp, glBufferDataARB); + SET_BufferSubDataARB(disp, glBufferSubDataARB); + SET_DeleteBuffersARB(disp, glDeleteBuffersARB); + SET_GenBuffersARB(disp, glGenBuffersARB); + SET_GetBufferParameterivARB(disp, glGetBufferParameterivARB); + SET_GetBufferPointervARB(disp, glGetBufferPointervARB); + SET_GetBufferSubDataARB(disp, glGetBufferSubDataARB); + SET_IsBufferARB(disp, glIsBufferARB); + SET_MapBufferARB(disp, glMapBufferARB); + SET_UnmapBufferARB(disp, glUnmapBufferARB); + SET_DepthBoundsEXT(disp, glDepthBoundsEXT); + SET_GenQueriesARB(disp, glGenQueriesARB); + SET_DeleteQueriesARB(disp, glDeleteQueriesARB); + SET_IsQueryARB(disp, glIsQueryARB); + SET_BeginQueryARB(disp, glBeginQueryARB); + SET_EndQueryARB(disp, glEndQueryARB); + SET_GetQueryivARB(disp, glGetQueryivARB); + SET_GetQueryObjectivARB(disp, glGetQueryObjectivARB); + SET_GetQueryObjectuivARB(disp, glGetQueryObjectuivARB); + SET_MultiModeDrawArraysIBM(disp, glMultiModeDrawArraysIBM); + SET_MultiModeDrawElementsIBM(disp, glMultiModeDrawElementsIBM); + SET_BlendEquationSeparateEXT(disp, glBlendEquationSeparateEXT); + SET_DeleteObjectARB(disp, glDeleteObjectARB); + SET_GetHandleARB(disp, glGetHandleARB); + SET_DetachObjectARB(disp, glDetachObjectARB); + SET_CreateShaderObjectARB(disp, glCreateShaderObjectARB); + SET_ShaderSourceARB(disp, glShaderSourceARB); + SET_CompileShaderARB(disp, glCompileShaderARB); + SET_CreateProgramObjectARB(disp, glCreateProgramObjectARB); + SET_AttachObjectARB(disp, glAttachObjectARB); + SET_LinkProgramARB(disp, glLinkProgramARB); + SET_UseProgramObjectARB(disp, glUseProgramObjectARB); + SET_ValidateProgramARB(disp, glValidateProgramARB); + SET_Uniform1fARB(disp, glUniform1fARB); + SET_Uniform2fARB(disp, glUniform2fARB); + SET_Uniform3fARB(disp, glUniform3fARB); + SET_Uniform4fARB(disp, glUniform4fARB); + SET_Uniform1iARB(disp, glUniform1iARB); + SET_Uniform2iARB(disp, glUniform2iARB); + SET_Uniform3iARB(disp, glUniform3iARB); + SET_Uniform4iARB(disp, glUniform4iARB); + SET_Uniform1fvARB(disp, glUniform1fvARB); + SET_Uniform2fvARB(disp, glUniform2fvARB); + SET_Uniform3fvARB(disp, glUniform3fvARB); + SET_Uniform4fvARB(disp, glUniform4fvARB); + SET_Uniform1ivARB(disp, glUniform1ivARB); + SET_Uniform2ivARB(disp, glUniform2ivARB); + SET_Uniform3ivARB(disp, glUniform3ivARB); + SET_Uniform4ivARB(disp, glUniform4ivARB); + SET_UniformMatrix2fvARB(disp, glUniformMatrix2fvARB); + SET_UniformMatrix3fvARB(disp, glUniformMatrix3fvARB); + SET_UniformMatrix4fvARB(disp, glUniformMatrix4fvARB); + SET_GetObjectParameterfvARB(disp, glGetObjectParameterfvARB); + SET_GetObjectParameterivARB(disp, glGetObjectParameterivARB); + SET_GetInfoLogARB(disp, glGetInfoLogARB); + SET_GetAttachedObjectsARB(disp, glGetAttachedObjectsARB); + SET_GetUniformLocationARB(disp, glGetUniformLocationARB); + SET_GetActiveUniformARB(disp, glGetActiveUniformARB); + SET_GetUniformfvARB(disp, glGetUniformfvARB); + SET_GetUniformivARB(disp, glGetUniformivARB); + SET_GetShaderSourceARB(disp, glGetShaderSourceARB); + SET_BindAttribLocationARB(disp, glBindAttribLocationARB); + SET_GetActiveAttribARB(disp, glGetActiveAttribARB); + SET_GetAttribLocationARB(disp, glGetAttribLocationARB); + SET_GetVertexAttribdvNV(disp, glGetVertexAttribdvNV); + SET_GetVertexAttribfvNV(disp, glGetVertexAttribfvNV); + SET_GetVertexAttribivNV(disp, glGetVertexAttribivNV); + SET_VertexAttrib1dNV(disp, glVertexAttrib1dNV); + SET_VertexAttrib1dvNV(disp, glVertexAttrib1dvNV); + SET_VertexAttrib1fNV(disp, glVertexAttrib1fNV); + SET_VertexAttrib1fvNV(disp, glVertexAttrib1fvNV); + SET_VertexAttrib1sNV(disp, glVertexAttrib1sNV); + SET_VertexAttrib1svNV(disp, glVertexAttrib1svNV); + SET_VertexAttrib2dNV(disp, glVertexAttrib2dNV); + SET_VertexAttrib2dvNV(disp, glVertexAttrib2dvNV); + SET_VertexAttrib2fNV(disp, glVertexAttrib2fNV); + SET_VertexAttrib2fvNV(disp, glVertexAttrib2fvNV); + SET_VertexAttrib2sNV(disp, glVertexAttrib2sNV); + SET_VertexAttrib2svNV(disp, glVertexAttrib2svNV); + SET_VertexAttrib3dNV(disp, glVertexAttrib3dNV); + SET_VertexAttrib3dvNV(disp, glVertexAttrib3dvNV); + SET_VertexAttrib3fNV(disp, glVertexAttrib3fNV); + SET_VertexAttrib3fvNV(disp, glVertexAttrib3fvNV); + SET_VertexAttrib3sNV(disp, glVertexAttrib3sNV); + SET_VertexAttrib3svNV(disp, glVertexAttrib3svNV); + SET_VertexAttrib4dNV(disp, glVertexAttrib4dNV); + SET_VertexAttrib4dvNV(disp, glVertexAttrib4dvNV); + SET_VertexAttrib4fNV(disp, glVertexAttrib4fNV); + SET_VertexAttrib4fvNV(disp, glVertexAttrib4fvNV); + SET_VertexAttrib4sNV(disp, glVertexAttrib4sNV); + SET_VertexAttrib4svNV(disp, glVertexAttrib4svNV); + SET_VertexAttrib4ubNV(disp, glVertexAttrib4ubNV); + SET_VertexAttrib4ubvNV(disp, glVertexAttrib4ubvNV); + SET_GenFragmentShadersATI(disp, glGenFragmentShadersATI); + SET_BindFragmentShaderATI(disp, glBindFragmentShaderATI); + SET_DeleteFragmentShaderATI(disp, glDeleteFragmentShaderATI); + SET_BeginFragmentShaderATI(disp, glBeginFragmentShaderATI); + SET_EndFragmentShaderATI(disp, glEndFragmentShaderATI); + SET_PassTexCoordATI(disp, glPassTexCoordATI); + SET_SampleMapATI(disp, glSampleMapATI); + SET_ColorFragmentOp1ATI(disp, glColorFragmentOp1ATI); + SET_ColorFragmentOp2ATI(disp, glColorFragmentOp2ATI); + SET_ColorFragmentOp3ATI(disp, glColorFragmentOp3ATI); + SET_AlphaFragmentOp1ATI(disp, glAlphaFragmentOp1ATI); + SET_AlphaFragmentOp2ATI(disp, glAlphaFragmentOp2ATI); + SET_AlphaFragmentOp3ATI(disp, glAlphaFragmentOp3ATI); + SET_SetFragmentShaderConstantATI(disp, glSetFragmentShaderConstantATI); + SET_IsRenderbufferEXT(disp, glIsRenderbufferEXT); + SET_BindRenderbufferEXT(disp, glBindRenderbufferEXT); + SET_DeleteRenderbuffersEXT(disp, glDeleteRenderbuffersEXT); + SET_GenRenderbuffersEXT(disp, glGenRenderbuffersEXT); + SET_RenderbufferStorageEXT(disp, glRenderbufferStorageEXT); + SET_GetRenderbufferParameterivEXT(disp, glGetRenderbufferParameterivEXT); + SET_IsFramebufferEXT(disp, glIsFramebufferEXT); + SET_BindFramebufferEXT(disp, glBindFramebufferEXT); + SET_DeleteFramebuffersEXT(disp, glDeleteFramebuffersEXT); + SET_GenFramebuffersEXT(disp, glGenFramebuffersEXT); + SET_CheckFramebufferStatusEXT(disp, glCheckFramebufferStatusEXT); + SET_FramebufferTexture1DEXT(disp, glFramebufferTexture1DEXT); + SET_FramebufferTexture2DEXT(disp, glFramebufferTexture2DEXT); + SET_FramebufferTexture3DEXT(disp, glFramebufferTexture3DEXT); + SET_FramebufferRenderbufferEXT(disp, glFramebufferRenderbufferEXT); + SET_GetFramebufferAttachmentParameterivEXT(disp, glGetFramebufferAttachmentParameterivEXT); + SET_GenerateMipmapEXT(disp, glGenerateMipmapEXT); + SET_StencilFuncSeparate(disp, glStencilFuncSeparate); + SET_StencilOpSeparate(disp, glStencilOpSeparate); + SET_StencilMaskSeparate(disp, glStencilMaskSeparate); + SET_GetQueryObjecti64vEXT(disp, glGetQueryObjecti64vEXT); + SET_GetQueryObjectui64vEXT(disp, glGetQueryObjectui64vEXT); + SET_BlitFramebufferEXT(disp, glBlitFramebufferEXT); */ + +} diff --git a/GL/glx/glxbyteorder.h b/GL/glx/glxbyteorder.h index b9d738dba..cdf6b15f0 100644 --- a/GL/glx/glxbyteorder.h +++ b/GL/glx/glxbyteorder.h @@ -39,6 +39,11 @@ #include #elif defined(USE_SYS_ENDIAN_H) #include +#elif defined(__APPLE__) +#include +#define bswap_16 OSSwapInt16 +#define bswap_32 OSSwapInt32 +#define bswap_64 OSSwapInt64 #else #define bswap_16(value) \ ((((value) & 0xff) << 8) | ((value) >> 8)) diff --git a/Xext/security.c b/Xext/security.c index bd397a9ab..7202d3947 100644 --- a/Xext/security.c +++ b/Xext/security.c @@ -1187,6 +1187,7 @@ CALLBACK(SecurityCheckMapAccess) if (STATEPTR(rec->client) && (TRUSTLEVEL(rec->client) != XSecurityClientTrusted) && (pWin->drawable.class == InputOnly) && + pWin->parent && pWin->parent->parent && (TRUSTLEVEL(wClient(pWin->parent)) == XSecurityClientTrusted)) rec->rval = FALSE; diff --git a/Xext/xtest.c b/Xext/xtest.c index c9b511e69..94d8974b6 100644 --- a/Xext/xtest.c +++ b/Xext/xtest.c @@ -441,6 +441,8 @@ ProcXTestFakeInput(client) (root->drawable.pScreen, ev->u.keyButtonPointer.rootX, ev->u.keyButtonPointer.rootY, FALSE); + dev->valuator->lastx = ev->u.keyButtonPointer.rootX; + dev->valuator->lasty = ev->u.keyButtonPointer.rootY; break; case ButtonPress: case ButtonRelease: diff --git a/config/config.c b/config/config.c index 76191abd4..6c4014352 100644 --- a/config/config.c +++ b/config/config.c @@ -303,15 +303,15 @@ configSetup(void) if (!configData) configData = (struct config_data *) xcalloc(sizeof(struct config_data), 1); if (!configData) { - ErrorF("[dbus] failed to allocate data struct.\n"); + ErrorF("[dbus] failed to allocate data struct\n"); return FALSE; } dbus_error_init(&error); configData->connection = dbus_bus_get(DBUS_BUS_SYSTEM, &error); if (!configData->connection || dbus_error_is_set(&error)) { - ErrorF("[dbus] some kind of error occurred: %s (%s)\n", error.name, - error.message); + DebugF("[dbus] some kind of error occurred while connecting: %s (%s)\n", + error.name, error.message); dbus_error_free(&error); xfree(configData); configData = NULL; diff --git a/configure.ac b/configure.ac index 36315769a..a7d5c6f78 100644 --- a/configure.ac +++ b/configure.ac @@ -280,6 +280,7 @@ case $host_cpu in use_x86_asm="yes" I386_VIDEO=yes case $host_os in + darwin*) use_x86_asm="no" ;; *linux*) DEFAULT_INT10=vm86 ;; *freebsd*) AC_DEFINE(USE_DEV_IO) ;; *netbsd*) AC_DEFINE(USE_I386_IOPL) @@ -305,6 +306,7 @@ case $host_cpu in use_x86_asm="yes" I386_VIDEO=yes case $host_os in + darwin*) use_x86_asm="no" ;; *freebsd*) AC_DEFINE(USE_DEV_IO, 1, [BSD /dev/io]) ;; *netbsd*) AC_DEFINE(USE_I386_IOPL, 1, [BSD i386 iopl]) SYS_LIBS=-lx86_64 @@ -473,6 +475,10 @@ AC_ARG_WITH(rgb-path, AS_HELP_STRING([--with-rgb-path=PATH], [Path to RG AC_ARG_WITH(dri-driver-path, AS_HELP_STRING([--with-dri-driver-path=PATH], [Path to DRI drivers (default: ${libdir}/dri)]), [ DRI_DRIVER_PATH="$withval" ], [ DRI_DRIVER_PATH="${libdir}/dri" ]) +APPLE_APPLICATIONS_DIR="${bindir}/Applications" +AC_ARG_WITH(apple-applications-dir,AS_HELP_STRING([--with-apple-applications-dir=PATH], [Path to the Applications directory (default: ${bindir}/Applications)]), + [ APPLE_APPLICATIONS_DIR="${withval}" ]. + [ APPLE_APPLICATIONS_DIR="${bindir}/Applications" ]) AC_ARG_ENABLE(builddocs, AS_HELP_STRING([--enable-builddocs], [Build docs (default: disabled)]), [BUILDDOCS=$enableval], [BUILDDOCS=no]) @@ -495,6 +501,7 @@ AC_ARG_ENABLE(xres, AS_HELP_STRING([--disable-xres], [Build XRes exten AC_ARG_ENABLE(xtrap, AS_HELP_STRING([--disable-xtrap], [Build XTrap extension (default: enabled)]), [XTRAP=$enableval], [XTRAP=yes]) AC_ARG_ENABLE(record, AS_HELP_STRING([--disable-record], [Build Record extension (default: enabled)]), [RECORD=$enableval], [RECORD=yes]) AC_ARG_ENABLE(xv, AS_HELP_STRING([--disable-xv], [Build Xv extension (default: enabled)]), [XV=$enableval], [XV=yes]) +AC_ARG_ENABLE(quartz, AS_HELP_STRING([--enable-quartz], [Build with darwin quartz support (default: auto)]), [XQUARTZ=$enableval], [XQUARTZ=auto]) AC_ARG_ENABLE(xvmc, AS_HELP_STRING([--disable-xvmc], [Build XvMC extension (default: enabled)]), [XVMC=$enableval], [XVMC=yes]) AC_ARG_ENABLE(dga, AS_HELP_STRING([--disable-dga], [Build DGA extension (default: auto)]), [DGA=$enableval], [DGA=auto]) AC_ARG_ENABLE(screensaver, AS_HELP_STRING([--disable-screensaver], [Build ScreenSaver extension (default: enabled)]), [SCREENSAVER=$enableval], [SCREENSAVER=yes]) @@ -526,7 +533,7 @@ AC_ARG_ENABLE(xfree86-utils, AS_HELP_STRING([--enable-xfree86-utils], [Build dnl DDXes. AC_ARG_ENABLE(xorg, AS_HELP_STRING([--enable-xorg], [Build Xorg server (default: auto)]), [XORG=$enableval], [XORG=auto]) -AC_ARG_ENABLE(dmx, AS_HELP_STRING([--enable-dmx], [Build DMX server (default: auto)]), [DMX=$enableval], [DMX=auto]) +AC_ARG_ENABLE(dmx, AS_HELP_STRING([--enable-dmx], [Build DMX server (default: no)]), [DMX=$enableval], [DMX=no]) AC_ARG_ENABLE(xvfb, AS_HELP_STRING([--enable-xvfb], [Build Xvfb server (default: yes)]), [XVFB=$enableval], [XVFB=yes]) AC_ARG_ENABLE(xnest, AS_HELP_STRING([--enable-xnest], [Build Xnest server (default: auto)]), [XNEST=$enableval], [XNEST=auto]) AC_ARG_ENABLE(xwin, AS_HELP_STRING([--enable-xwin], [Build XWin server (default: auto)]), [XWIN=$enableval], [XWIN=auto]) @@ -534,6 +541,10 @@ AC_ARG_ENABLE(xprint, AS_HELP_STRING([--enable-xprint], [Build Xprint ex AC_ARG_ENABLE(xgl, AS_HELP_STRING([--enable-xgl], [Build Xgl server (default: no)]), [XGL=$enableval], [XGL=no]) AC_ARG_ENABLE(xglx, AS_HELP_STRING([--enable-xglx], [Build Xglx xgl module (default: no)]), [XGLX=$enableval], [XGLX=no]) AC_ARG_ENABLE(xegl, AS_HELP_STRING([--enable-xegl], [Build Xegl xgl module (default: no)]), [XEGL=$enableval], [XEGL=no]) +dnl legacy fb support +AC_ARG_ENABLE(mfb, AS_HELP_STRING([--enable-mfb], [Build legacy mono framebuffer support (default: enabled)]), [MFB=$enableval], [MFB=$XORG]) +AC_ARG_ENABLE(cfb, AS_HELP_STRING([--enable-cfb], [Build legacy color framebuffer support (default: enabled)]), [CFB=$enableval], [CFB=$XORG]) +AC_ARG_ENABLE(afb, AS_HELP_STRING([--enable-afb], [Build legacy advanced framebuffer support (default: enabled)]), [AFB=$enableval], [AFB=$XORG]) dnl kdrive and its subsystems AC_ARG_ENABLE(kdrive, AS_HELP_STRING([--enable-kdrive], [Build kdrive servers (default: no)]), [KDRIVE=$enableval], [KDRIVE=no]) AC_ARG_ENABLE(xephyr, AS_HELP_STRING([--enable-xephyr], [Build the kdrive Xephyr server (default: auto)]), [XEPHYR=$enableval], [XEPHYR=auto]) @@ -1021,6 +1032,9 @@ if test "x$GCC" = "xyes"; then LD_EXPORT_SYMBOLS_FLAG="-rdynamic" fi case $host_os in + darwin*) + LD_EXPORT_SYMBOLS_FLAG="" + ;; openbsd*) LD_EXPORT_SYMBOLS_FLAG="-Wl,--export-dynamic" ;; @@ -1078,7 +1092,19 @@ AC_DEFINE([SVR4],1,[Define to 1 on systems derived from System V Release 4]) AC_MSG_RESULT([yes])], AC_MSG_RESULT([no])) XSERVER_CFLAGS="$XSERVER_CFLAGS $CORE_INCS $XEXT_INC $COMPOSITE_INC $DAMAGE_INC $FIXES_INC $XI_INC $MI_INC $MIEXT_SHADOW_INC $MIEXT_LAYER_INC $MIEXT_DAMAGE_INC $RENDER_INC $RANDR_INC $FB_INC" -AC_DEFINE_UNQUOTED(X_BYTE_ORDER,[$ENDIAN],[Endian order]) +AC_DEFINE_UNQUOTED(_X_BYTE_ORDER,[$ENDIAN],[Endian order]) +AH_VERBATIM([X_BYTE_ORDER],[ +/* Deal with multiple architecture compiles on Mac OS X */ +#ifndef __APPLE_CC__ +#define X_BYTE_ORDER _X_BYTE_ORDER +#else +#ifdef __BIG_ENDIAN__ +#define X_BYTE_ORDER X_BIG_ENDIAN +#else +#define X_BYTE_ORDER X_LITTLE_ENDIAN +#endif +#endif +]) AC_SUBST([XSERVER_LIBS]) @@ -1169,7 +1195,6 @@ if test "x$XORG" = xauto; then XORG="yes" case $host_os in cygwin*) XORG="no" ;; - darwin*) XORG="no" ;; esac fi AC_MSG_RESULT([$XORG]) @@ -1246,43 +1271,70 @@ if test "x$XORG" = xyes -o "x$XGL" = xyes; then XORG_CFLAGS="$XORGSERVER_CFLAGS -DHAVE_XORG_CONFIG_H" XORG_LIBS="$COMPOSITE_LIB $MI_LIB $FIXES_LIB $XEXTXORG_LIB $GLX_LIBS $RENDER_LIB $RANDR_LIB $DAMAGE_LIB $MIEXT_DAMAGE_LIB $MIEXT_SHADOW_LIB $XI_LIB $XKB_LIB $XPSTUBS_LIB $SELINUX_LIB $OS_LIB" - if test "x$DGA" = xauto; then - PKG_CHECK_MODULES(DGA, xf86dgaproto, [DGA=yes], [DGA=no]) - fi - if test "x$DGA" = xyes; then - XORG_MODULES="$XORG_MODULES xf86dgaproto" - AC_DEFINE(DGA, 1, [Support DGA extension]) - AC_DEFINE(XFreeXDGA, 1, [Build XDGA support]) - fi - - if test "x$XF86MISC" = xauto; then - PKG_CHECK_MODULES(XF86MISC, xf86miscproto, [XF86MISC=yes], [XF86MISC=no]) - fi - if test "x$XF86MISC" = xyes; then - XORG_MODULES="$XORG_MODULES xf86miscproto" - AC_DEFINE(XF86MISC, 1, [Support XFree86 miscellaneous extensions]) - fi - - if test "x$XF86VIDMODE" = xauto; then - PKG_CHECK_MODULES(XF86VIDMODE, xf86vidmodeproto, [XF86VIDMODE=yes], [XF86VIDMODE=no]) - fi - if test "x$XF86VIDMODE" = xyes; then - XORG_MODULES="$XORG_MODULES xf86vidmodeproto" - AC_DEFINE(XF86VIDMODE, 1, [Support XFree86 Video Mode extension]) - fi - - if test -n "$XORG_MODULES"; then - PKG_CHECK_MODULES(XORG_MODULES, [$XORG_MODULES]) - XORG_CFLAGS="$XORG_CFLAGS $XORG_MODULES_CFLAGS" - XORG_LIBS="$XORG_LIBS $XORG_MODULES_LIBS" - fi - dnl Check to see if dlopen is in default libraries (like Solaris, which dnl has it in libc), or if libdl is needed to get it. AC_CHECK_FUNC([dlopen], [], AC_CHECK_LIB([dl], [dlopen], XORG_LIBS="$XORG_LIBS -ldl")) case $host_os in + darwin*) + XORG_OS="Darwin" + build_darwin=yes + if test "X$XQUARTZ" = Xauto; then + AC_CACHE_CHECK([for Carbon framework],xorg_cv_Carbon_framework,[ + save_LDFLAGS=$LDFLAGS + LDFLAGS="$LDFLAGS -framework Carbon" + AC_LINK_IFELSE([char FSFindFolder(); +int main() { +FSFindFolder(); +return 0;} + ],[xorg_cv_Carbon_framework=yes], + [xorg_cv_Carbon_framework=no]) + LDFLAGS=$save_LDFLAGS]) + if test "X$xorg_cv_Carbon_framework" = Xyes; then + AC_DEFINE([DARWIN_WITH_QUARTZ],[1], + [Have Quartz]) + XQUARTZ=yes + else + XQUARTZ=no + fi + fi +# glxAGL / glxCGL don't work yet +# AC_CACHE_CHECK([for AGL framework],xorg_cv_AGL_framework,[ +# save_LDFLAGS=$LDFLAGS +# LDFLAGS="$LDFLAGS -framework AGL" +# AC_LINK_IFELSE([char aglEnable(); +#int main() { +#aglEnable(); +#return 0;} +# ],[xorg_cv_AGL_framework=yes], +# [xorg_cv_AGL_framework=no]) +# LDFLAGS=$save_LDFLAGS +# ]) + xorg_cv_AGL_framework=no + DARWIN_LIBS="$FB_LIB $MI_LIB $FIXES_LIB $XEXT_LIB $DBE_LIB $XTRAP_LIB $RECORD_LIB $GLX_LIBS $RENDER_LIB $RANDR_LIB $DAMAGE_LIB $MIEXT_DAMAGE_LIB $MIEXT_SHADOW_LIB $XI_LIB $XKB_LIB $XKB_STUB_LIB $COMPOSITE_LIB $XPSTUBS_LIB $OS_LIB" + AC_SUBST([DARWIN_LIBS]) + AC_CHECK_LIB([Xplugin],[xp_init],[:]) + AC_SUBST([APPLE_APPLICATIONS_DIR]) + CFLAGS="${CFLAGS} -D__DARWIN__" + PLIST_VERSION_STRING=$VENDOR_VERSION_STRING + AC_SUBST([PLIST_VERSION_STRING]) + PLIST_VENDOR_WEB=$VENDOR_WEB + AC_SUBST([PLIST_VENDOR_WEB]) + # Not sure that we should be disabling all these... + if test "x$XF86MISC" = xyes || test "x$XF86MISC" = xauto; then + AC_MSG_NOTICE([Disabling XF86Misc extension]) + XF86MISC=no + fi + if test "x$XF86VIDMODE" = xyes || test "x$XF86VIDMODE" = xauto; then + AC_MSG_NOTICE([Disabling XF86VidMode extension]) + XF86VIDMODE=no + fi + if test "x$DGA" = xyes || test "x$DGA" = xauto; then + AC_MSG_NOTICE([Disabling DGA extension]) + DGA=no + fi + ;; linux*) if test "x$LNXAPM" = xyes; then XORG_CFLAGS="$XORG_CFLAGS -DXF86PM" @@ -1405,11 +1457,14 @@ dnl has it in libc), or if libdl is needed to get it. case $host_cpu in i*86) - xorg_bus_ix86pci=yes + case $host_os in + darwin*) ;; + *) xorg_bus_ix86pci=yes ;; + esac ;; powerpc*) case $host_os in - linux*|freebsd*|netbsd*|openbsd*|kfreebsd*-gnu) + darwin*|linux*|freebsd*|netbsd*|openbsd*|kfreebsd*-gnu) ;; *) xorg_bus_ppcpci="yes" @@ -1422,7 +1477,7 @@ dnl has it in libc), or if libdl is needed to get it. ;; x86_64*|amd64*) case $host_os in - freebsd*|kfreebsd*-gnu) + darwin*|freebsd*|kfreebsd*-gnu) # FreeBSD uses the system pci interface ;; *) @@ -1435,6 +1490,37 @@ dnl has it in libc), or if libdl is needed to get it. if test "x$XORG_OS_PCI" = x ; then XORG_OS_PCI=$XORG_OS fi + if test "x$DGA" = xauto; then + PKG_CHECK_MODULES(DGA, xf86dgaproto, [DGA=yes], [DGA=no]) + fi + if test "x$DGA" = xyes; then + XORG_MODULES="$XORG_MODULES xf86dgaproto" + AC_DEFINE(DGA, 1, [Support DGA extension]) + AC_DEFINE(XFreeXDGA, 1, [Build XDGA support]) + fi + + if test "x$XF86MISC" = xauto; then + PKG_CHECK_MODULES(XF86MISC, xf86miscproto, [XF86MISC=yes], [XF86MISC=no]) + fi + if test "x$XF86MISC" = xyes; then + XORG_MODULES="$XORG_MODULES xf86miscproto" + AC_DEFINE(XF86MISC, 1, [Support XFree86 miscellaneous extensions]) + fi + + if test "x$XF86VIDMODE" = xauto; then + PKG_CHECK_MODULES(XF86VIDMODE, xf86vidmodeproto, [XF86VIDMODE=yes], [XF86VIDMODE=no]) + fi + if test "x$XF86VIDMODE" = xyes; then + XORG_MODULES="$XORG_MODULES xf86vidmodeproto" + AC_DEFINE(XF86VIDMODE, 1, [Support XFree86 Video Mode extension]) + fi + + if test -n "$XORG_MODULES"; then + PKG_CHECK_MODULES(XORG_MODULES, [$XORG_MODULES]) + XORG_CFLAGS="$XORG_CFLAGS $XORG_MODULES_CFLAGS" + XORG_LIBS="$XORG_LIBS $XORG_MODULES_LIBS" + fi + AC_SUBST([XORG_LIBS]) AC_SUBST([XORG_INCS]) AC_SUBST([XORG_OS]) @@ -1495,11 +1581,23 @@ AM_CONDITIONAL([LINUX_ALPHA], [test "x$linux_alpha" = xyes]) AM_CONDITIONAL([LNXACPI], [test "x$linux_acpi" = xyes]) AM_CONDITIONAL([SOLARIS_USL_CONSOLE], [test "x$solaris_usl_console" = xyes]) AM_CONDITIONAL([SOLARIS_ASM_INLINE], [test "x$solaris_asm_inline" = xyes]) -AM_CONDITIONAL(MFB, [test "x$XORG" = xyes]) -AM_CONDITIONAL(CFB, [test "x$XORG" = xyes]) -AM_CONDITIONAL(AFB, [test "x$XORG" = xyes]) +AM_CONDITIONAL([BUILD_DARWIN],[test "X$build_darwin" = Xyes]) +AM_CONDITIONAL([XQUARTZ],[test "X$XQUARTZ" = Xyes]) AM_CONDITIONAL(DGA, [test "x$DGA" = xyes]) +dnl legacy fb support +test "x$MFB" = xauto && MFB="$XORG" +test "x$CFB" = xauto && CFB="$XORG" +test "x$AFB" = xauto && AFB="$XORG" +AM_CONDITIONAL(MFB, [test "x$MFB" = xyes]) +AM_CONDITIONAL(CFB, [test "x$CFB" = xyes]) +AM_CONDITIONAL(AFB, [test "x$AFB" = xyes]) +if test "x$MFB" = xyes -o "x$CFB" = xyes -o "x$AFB" = xyes; then + if test "x$XORG" != xyes; then + AC_MSG_ERROR([legacy fb support requires the Xorg server]) + fi +fi + dnl Xprint DDX AC_MSG_CHECKING([whether to build Xprint DDX]) @@ -1508,7 +1606,7 @@ AC_MSG_RESULT([$XPRINT]) if test "x$XPRINT" = xyes; then PKG_CHECK_MODULES([XPRINT], [printproto x11 xfont $XDMCP_MODULES xau]) XPRINT_EXTENSIONS="$XEXT_LIB $DBE_LIB $XTRAP_LIB $RECORD_LIB $RENDER_LIB $COMPOSITE_LIB $RANDR_LIB $XI_LIB $FIXES_LIB $DAMAGE_LIB $XI_LIB $GLX_LIBS" - XPRINT_LIBS="$XPRINT_LIBS $DIX_LIB $CONFIG_LIB $XKB_LIB $XKB_STUB_LIB $XPRINT_EXTENSIONS $MI_LIB $MIEXT_DAMAGE_LIB $CWRAP_LIB $OS_LIB $LIBS" + XPRINT_LIBS="$DIX_LIB $CONFIG_LIB $XKB_LIB $XKB_STUB_LIB $XPRINT_EXTENSIONS $MI_LIB $MIEXT_DAMAGE_LIB $CWRAP_LIB $OS_LIB $LIBS $XPRINT_LIBS" AC_SUBST([XPRINT_CFLAGS]) AC_SUBST([XPRINT_LIBS]) @@ -1622,6 +1720,21 @@ AM_CONDITIONAL(XWIN_PRIMARYFB, [test "x$XWIN" = xyes && false]) AM_CONDITIONAL(XWIN_RANDR, [test "x$XWIN" = xyes]) AM_CONDITIONAL(XWIN_XV, [test "x$XWIN" = xyes && test "x$XV" = xyes]) +dnl Darwin / OS X DDX +AM_CONDITIONAL(HAVE_X_PLUGIN, [test "x$ac_cv_lib_Xplugin_xp_init" = xyes]) +AM_CONDITIONAL(HAVE_AGL_FRAMEWORK, [test "x$xorg_cv_AGL_framework" = xyes]) +# Support for objc in autotools is minimal and not +# documented. +OBJC='$(CC)' +OBJCLD='$(CCLD)' +OBJCLINK='$(LINK)' +OBJCFLAGS='$(CFLAGS)' +AC_SUBST([OBJC]) +AC_SUBST([OBJCCLD]) +AC_SUBST([OBJCLINK]) +AC_SUBST([OBJCFLAGS]) +# internal, undocumented automake func follows :( +_AM_DEPENDENCIES([OBJC]) dnl kdrive DDX @@ -1751,11 +1864,6 @@ AM_CONDITIONAL(XFAKESERVER, [test "x$KDRIVE" = xyes && test "x$XFAKE" = xyes]) AM_CONDITIONAL(KDRIVEVESA, [test x"$ac_cv_header_sys_vm86_h" = xyes]) AM_CONDITIONAL(KDRIVEFBDEV, [test x"$ac_cv_header_linux_fb_h" = xyes]) -dnl XDarwin DDX (FIXME) -AM_CONDITIONAL(XQUARTZ, false) -AM_CONDITIONAL(HAVE_X_PLUGIN, false) -AM_CONDITIONAL(HAVE_AGL_FRAMEWORK, false) - dnl these only go in xkb-config.h (which is shared by the Xorg and Xnest servers) AC_DEFINE(__XKBDEFRULES__, "xorg", [Default XKB rules]) AC_DEFINE_DIR(XKB_BASE_DIRECTORY, XKBPATH, [Path to XKB data]) @@ -1860,6 +1968,7 @@ XORG_RELEASE_VERSION AC_OUTPUT([ Makefile GL/Makefile +GL/apple/Makefile GL/glx/Makefile GL/mesa/Makefile GL/mesa/glapi/Makefile @@ -1893,6 +2002,8 @@ miext/damage/Makefile miext/shadow/Makefile miext/cw/Makefile miext/rootless/Makefile +miext/rootless/safeAlpha/Makefile +miext/rootless/accel/Makefile os/Makefile randr/Makefile render/Makefile @@ -1919,6 +2030,7 @@ hw/xfree86/fbdevhw/Makefile hw/xfree86/i2c/Makefile hw/xfree86/int10/Makefile hw/xfree86/loader/Makefile +hw/xfree86/modes/Makefile hw/xfree86/os-support/Makefile hw/xfree86/os-support/bsd/Makefile hw/xfree86/os-support/bus/Makefile @@ -1969,6 +2081,19 @@ hw/xgl/glxext/module/Makefile hw/xnest/Makefile hw/xwin/Makefile hw/darwin/Makefile +hw/darwin/bundle/Makefile +hw/darwin/bundle/Dutch.lproj/Makefile +hw/darwin/bundle/English.lproj/Makefile +hw/darwin/bundle/French.lproj/Makefile +hw/darwin/bundle/German.lproj/Makefile +hw/darwin/bundle/Japanese.lproj/Makefile +hw/darwin/bundle/Portuguese.lproj/Makefile +hw/darwin/bundle/Spanish.lproj/Makefile +hw/darwin/bundle/Swedish.lproj/Makefile +hw/darwin/bundle/ko.lproj/Makefile +hw/darwin/iokit/Makefile +hw/darwin/quartz/Makefile +hw/darwin/utils/Makefile hw/kdrive/Makefile hw/kdrive/ati/Makefile hw/kdrive/chips/Makefile diff --git a/dix/dixfonts.c b/dix/dixfonts.c index d5b42dcf6..5f087a31a 100644 --- a/dix/dixfonts.c +++ b/dix/dixfonts.c @@ -64,6 +64,7 @@ Equipment Corporation. #include "opaque.h" #include "dixfontstr.h" #include "closestr.h" +#include "dixfont.h" #ifdef DEBUG #include diff --git a/doc/Makefile.am b/doc/Makefile.am index 0ac533e18..ce1979d4f 100644 --- a/doc/Makefile.am +++ b/doc/Makefile.am @@ -1,25 +1,35 @@ appmandir = $(APP_MAN_DIR) +filemandir = $(FILE_MAN_DIR) # Xserver.man covers options generic to all X servers built in this tree +# (i.e. those handled in the os/utils.c options processing instead of in +# the DDX-level options processing) appman_PRE = Xserver.man.pre +fileman_PRE = SecurityPolicy.man.pre appman_PROCESSED = $(appman_PRE:man.pre=man) +fileman_PROCESSED = $(fileman_PRE:man.pre=man) appman_DATA = $(appman_PRE:man.pre=@APP_MAN_SUFFIX@) +fileman_DATA = $(fileman_PRE:man.pre=@FILE_MAN_SUFFIX@) -BUILT_SOURCES = $(appman_PROCESSED) +BUILT_SOURCES = $(appman_PROCESSED) $(fileman_PROCESSED) -CLEANFILES = $(appman_PROCESSED) $(appman_DATA) +CLEANFILES = $(appman_PROCESSED) $(appman_DATA) \ + $(fileman_PROCESSED) $(fileman_DATA) include $(top_srcdir)/cpprules.in .man.$(APP_MAN_SUFFIX): cp $< $@ +.man.$(FILE_MAN_SUFFIX): + cp $< $@ + EXTRAMANDEFS = -D__default_font_path__="`echo $(COMPILEDDEFAULTFONTPATH) | sed -e 's/,/, /g'`" # Docs about X server internals that we ship with source but don't install DEVEL_DOCS = smartsched -EXTRA_DIST = $(DEVEL_DOCS) $(appman_PRE) +EXTRA_DIST = $(DEVEL_DOCS) $(appman_PRE) $(fileman_PRE) diff --git a/doc/SecurityPolicy.man.pre b/doc/SecurityPolicy.man.pre new file mode 100644 index 000000000..f5aff0c6c --- /dev/null +++ b/doc/SecurityPolicy.man.pre @@ -0,0 +1,258 @@ +.\" Split out of Xserver.man, which was covered by this notice: +.\" Copyright 1984 - 1991, 1993, 1994, 1998 The Open Group +.\" +.\" Permission to use, copy, modify, distribute, and sell this software and its +.\" documentation for any purpose is hereby granted without fee, provided that +.\" the above copyright notice appear in all copies and that both that +.\" copyright notice and this permission notice appear in supporting +.\" documentation. +.\" +.\" 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 OPEN GROUP 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 of The Open Group shall +.\" not be used in advertising or otherwise to promote the sale, use or +.\" other dealings in this Software without prior written authorization +.\" from The Open Group. +.\" $XFree86: xc/programs/Xserver/Xserver.man,v 3.31 2004/01/10 22:27:46 dawes Exp $ +.\" shorthand for double quote that works everywhere. +.ds q \N'34' +.TH SecurityPolicy __filemansuffix__ __xorgversion__ +.SH NAME +SecurityPolicy \- X Window System SECURITY Extension Policy file format +.SH DESCRIPTION +The SECURITY extension to the X Window System uses a policy file to determine +which operations should be allowed or denied. The default location for this +file is +.IR __projectroot__/lib/xserver/SecurityPolicy . +.PP +The syntax of the security policy file is as follows. +Notation: "*" means zero or more occurrences of the preceding element, +and "+" means one or more occurrences. To interpret , ignore +the text after the /; it is used to distinguish between instances of + in the next section. +.PP +.nf + ::= * + + ::= '\en' + + ::= | | | + + ::= # * '\en' + + ::= '\en' + + ::= sitepolicy '\en' + + ::= property '\en' + + ::= + + ::= any | root | + + ::= | + + ::= = + + ::= [ | | ]* + + ::= r | w | d + + ::= a | i | e + + ::= | | + + ::= " * " + + ::= ' * ' + + ::= + + + ::= [ ' ' | '\et' ]* + +Character sets: + + ::= any character except '\en' + ::= any character except " + ::= any character except ' + ::= any character except those in +.fi +.PP +The semantics associated with the above syntax are as follows. +.PP +, the first line in the file, specifies the file format +version. If the server does not recognize the version , it +ignores the rest of the file. The version string for the file format +described here is "version-1" . +.PP +Once past the , lines that do not match the above syntax +are ignored. +.PP + lines are ignored. +.PP + lines are currently ignored. They are intended to +specify the site policies used by the XC-QUERY-SECURITY-1 +authorization method. +.PP + lines specify how the server should react to untrusted +client requests that affect the X Window property named . +The rest of this section describes the interpretation of an +. +.PP +For an to apply to a given instance of , + must be on a window that is in the set of windows +specified by . If is any, the rule applies to + on any window. If is root, the rule applies to + only on root windows. +.PP +If is , the following apply. If is a , the rule applies when the window also +has that , regardless of its value. If is a , must also have +the value specified by . In this case, the property must +have type STRING and format 8, and should contain one or more +null-terminated strings. If any of the strings match , the +rule applies. +.PP +The definition of string matching is simple case-sensitive string +comparison with one elaboration: the occurrence of the character '*' in + is a wildcard meaning "any string." A can +contain multiple wildcards anywhere in the string. For example, "x*" +matches strings that begin with x, "*x" matches strings that end with +x, "*x*" matches strings containing x, and "x*y*" matches strings that +start with x and subsequently contain y. +.PP +There may be multiple lines for a given . +The rules are tested in the order that they appear in the file. The +first rule that applies is used. +.PP + specify operations that untrusted clients may attempt, and +the actions that the server should take in response to those operations. +.PP + can be r (read), w (write), or d (delete). The following +table shows how X Protocol property requests map to these operations +in the X.Org server implementation. +.PP +.nf +GetProperty r, or r and d if delete = True +ChangeProperty w +RotateProperties r and w +DeleteProperty d +ListProperties none, untrusted clients can always list all properties +.fi +.PP + can be a (allow), i (ignore), or e (error). Allow means +execute the request as if it had been issued by a trusted client. +Ignore means treat the request as a no-op. In the case of +GetProperty, ignore means return an empty property value if the +property exists, regardless of its actual value. Error means do not +execute the request and return a BadAtom error with the atom set to +the property name. Error is the default action for all properties, +including those not listed in the security policy file. +.PP +An applies to all s that follow it, until the next + is encountered. Thus, irwad means ignore read and write, +allow delete. +.PP +GetProperty and RotateProperties may do multiple operations (r and d, +or r and w). If different actions apply to the operations, the most +severe action is applied to the whole request; there is no partial +request execution. The severity ordering is: allow < ignore < error. +Thus, if the for a property are ired (ignore read, error +delete), and an untrusted client attempts GetProperty on that property +with delete = True, an error is returned, but the property value is +not. Similarly, if any of the properties in a RotateProperties do not +allow both read and write, an error is returned without changing any +property values. +.PP +Here is an example security policy file. +.PP +.ta 3i 4i +.nf +version-1 + +XCOMM Allow reading of application resources, but not writing. +property RESOURCE_MANAGER root ar iw +property SCREEN_RESOURCES root ar iw + +XCOMM Ignore attempts to use cut buffers. Giving errors causes apps to crash, +XCOMM and allowing access may give away too much information. +property CUT_BUFFER0 root irw +property CUT_BUFFER1 root irw +property CUT_BUFFER2 root irw +property CUT_BUFFER3 root irw +property CUT_BUFFER4 root irw +property CUT_BUFFER5 root irw +property CUT_BUFFER6 root irw +property CUT_BUFFER7 root irw + +XCOMM If you are using Motif, you probably want these. +property _MOTIF_DEFAULT_BINDINGS root ar iw +property _MOTIF_DRAG_WINDOW root ar iw +property _MOTIF_DRAG_TARGETS any ar iw +property _MOTIF_DRAG_ATOMS any ar iw +property _MOTIF_DRAG_ATOM_PAIRS any ar iw + +XCOMM The next two rules let xwininfo -tree work when untrusted. +property WM_NAME any ar + +XCOMM Allow read of WM_CLASS, but only for windows with WM_NAME. +XCOMM This might be more restrictive than necessary, but demonstrates +XCOMM the facility, and is also an attempt to +XCOMM say "top level windows only." +property WM_CLASS WM_NAME ar + +XCOMM These next three let xlsclients work untrusted. Think carefully +XCOMM before including these; giving away the client machine name and command +XCOMM may be exposing too much. +property WM_STATE WM_NAME ar +property WM_CLIENT_MACHINE WM_NAME ar +property WM_COMMAND WM_NAME ar + +XCOMM To let untrusted clients use the standard colormaps created by +XCOMM xstdcmap, include these lines. +property RGB_DEFAULT_MAP root ar +property RGB_BEST_MAP root ar +property RGB_RED_MAP root ar +property RGB_GREEN_MAP root ar +property RGB_BLUE_MAP root ar +property RGB_GRAY_MAP root ar + +XCOMM To let untrusted clients use the color management database created +XCOMM by xcmsdb, include these lines. +property XDCCC_LINEAR_RGB_CORRECTION root ar +property XDCCC_LINEAR_RGB_MATRICES root ar +property XDCCC_GRAY_SCREENWHITEPOINT root ar +property XDCCC_GRAY_CORRECTION root ar + +XCOMM To let untrusted clients use the overlay visuals that many vendors +XCOMM support, include this line. +property SERVER_OVERLAY_VISUALS root ar + +XCOMM Dumb examples to show other capabilities. + +XCOMM oddball property names and explicit specification of error conditions +property "property with spaces" 'property with "' aw er ed + +XCOMM Allow deletion of Woo-Hoo if window also has property OhBoy with value +XCOMM ending in "son". Reads and writes will cause an error. +property Woo-Hoo OhBoy = "*son" ad + +.fi +.SH FILES +.TP 30 +.I __projectroot__/lib/xserver/SecurityPolicy +Default X server security policy +.SH "SEE ALSO" +.PP +\fIXserver\fp(__appmansuffix__), +.I "Security Extension Specification" diff --git a/doc/Xserver.man.pre b/doc/Xserver.man.pre index aa931a88a..aac3b51c3 100644 --- a/doc/Xserver.man.pre +++ b/doc/Xserver.man.pre @@ -414,221 +414,8 @@ X servers that support the SECURITY extension accept the following option: causes the server to attempt to read and interpret filename as a security policy file with the format described below. The file is read at server startup and reread at each server reset. -.PP -The syntax of the security policy file is as follows. -Notation: "*" means zero or more occurrences of the preceding element, -and "+" means one or more occurrences. To interpret , ignore -the text after the /; it is used to distinguish between instances of - in the next section. -.PP -.nf - ::= * - - ::= '\en' - - ::= | | | - - ::= # * '\en' - - ::= '\en' - - ::= sitepolicy '\en' - - ::= property '\en' - - ::= - - ::= any | root | - - ::= | - - ::= = - - ::= [ | | ]* - - ::= r | w | d - - ::= a | i | e - - ::= | | - - ::= " * " - - ::= ' * ' - - ::= + - - ::= [ ' ' | '\et' ]* - -Character sets: - - ::= any character except '\en' - ::= any character except " - ::= any character except ' - ::= any character except those in -.fi -.PP -The semantics associated with the above syntax are as follows. -.PP -, the first line in the file, specifies the file format -version. If the server does not recognize the version , it -ignores the rest of the file. The version string for the file format -described here is "version-1" . -.PP -Once past the , lines that do not match the above syntax -are ignored. -.PP - lines are ignored. -.PP - lines are currently ignored. They are intended to -specify the site policies used by the XC-QUERY-SECURITY-1 -authorization method. -.PP - lines specify how the server should react to untrusted -client requests that affect the X Window property named . -The rest of this section describes the interpretation of an -. -.PP -For an to apply to a given instance of , - must be on a window that is in the set of windows -specified by . If is any, the rule applies to - on any window. If is root, the rule applies to - only on root windows. -.PP -If is , the following apply. If is a , the rule applies when the window also -has that , regardless of its value. If is a , must also have -the value specified by . In this case, the property must -have type STRING and format 8, and should contain one or more -null-terminated strings. If any of the strings match , the -rule applies. -.PP -The definition of string matching is simple case-sensitive string -comparison with one elaboration: the occurrence of the character '*' in - is a wildcard meaning "any string." A can -contain multiple wildcards anywhere in the string. For example, "x*" -matches strings that begin with x, "*x" matches strings that end with -x, "*x*" matches strings containing x, and "x*y*" matches strings that -start with x and subsequently contain y. -.PP -There may be multiple lines for a given . -The rules are tested in the order that they appear in the file. The -first rule that applies is used. -.PP - specify operations that untrusted clients may attempt, and -the actions that the server should take in response to those operations. -.PP - can be r (read), w (write), or d (delete). The following -table shows how X Protocol property requests map to these operations -in The Open Group server implementation. -.PP -.nf -GetProperty r, or r and d if delete = True -ChangeProperty w -RotateProperties r and w -DeleteProperty d -ListProperties none, untrusted clients can always list all properties -.fi -.PP - can be a (allow), i (ignore), or e (error). Allow means -execute the request as if it had been issued by a trusted client. -Ignore means treat the request as a no-op. In the case of -GetProperty, ignore means return an empty property value if the -property exists, regardless of its actual value. Error means do not -execute the request and return a BadAtom error with the atom set to -the property name. Error is the default action for all properties, -including those not listed in the security policy file. -.PP -An applies to all s that follow it, until the next - is encountered. Thus, irwad means ignore read and write, -allow delete. -.PP -GetProperty and RotateProperties may do multiple operations (r and d, -or r and w). If different actions apply to the operations, the most -severe action is applied to the whole request; there is no partial -request execution. The severity ordering is: allow < ignore < error. -Thus, if the for a property are ired (ignore read, error -delete), and an untrusted client attempts GetProperty on that property -with delete = True, an error is returned, but the property value is -not. Similarly, if any of the properties in a RotateProperties do not -allow both read and write, an error is returned without changing any -property values. -.PP -Here is an example security policy file. -.PP -.ta 3i 4i -.nf -version-1 - -XCOMM Allow reading of application resources, but not writing. -property RESOURCE_MANAGER root ar iw -property SCREEN_RESOURCES root ar iw - -XCOMM Ignore attempts to use cut buffers. Giving errors causes apps to crash, -XCOMM and allowing access may give away too much information. -property CUT_BUFFER0 root irw -property CUT_BUFFER1 root irw -property CUT_BUFFER2 root irw -property CUT_BUFFER3 root irw -property CUT_BUFFER4 root irw -property CUT_BUFFER5 root irw -property CUT_BUFFER6 root irw -property CUT_BUFFER7 root irw - -XCOMM If you are using Motif, you probably want these. -property _MOTIF_DEFAULT_BINDINGS root ar iw -property _MOTIF_DRAG_WINDOW root ar iw -property _MOTIF_DRAG_TARGETS any ar iw -property _MOTIF_DRAG_ATOMS any ar iw -property _MOTIF_DRAG_ATOM_PAIRS any ar iw - -XCOMM The next two rules let xwininfo -tree work when untrusted. -property WM_NAME any ar - -XCOMM Allow read of WM_CLASS, but only for windows with WM_NAME. -XCOMM This might be more restrictive than necessary, but demonstrates -XCOMM the facility, and is also an attempt to -XCOMM say "top level windows only." -property WM_CLASS WM_NAME ar - -XCOMM These next three let xlsclients work untrusted. Think carefully -XCOMM before including these; giving away the client machine name and command -XCOMM may be exposing too much. -property WM_STATE WM_NAME ar -property WM_CLIENT_MACHINE WM_NAME ar -property WM_COMMAND WM_NAME ar - -XCOMM To let untrusted clients use the standard colormaps created by -XCOMM xstdcmap, include these lines. -property RGB_DEFAULT_MAP root ar -property RGB_BEST_MAP root ar -property RGB_RED_MAP root ar -property RGB_GREEN_MAP root ar -property RGB_BLUE_MAP root ar -property RGB_GRAY_MAP root ar - -XCOMM To let untrusted clients use the color management database created -XCOMM by xcmsdb, include these lines. -property XDCCC_LINEAR_RGB_CORRECTION root ar -property XDCCC_LINEAR_RGB_MATRICES root ar -property XDCCC_GRAY_SCREENWHITEPOINT root ar -property XDCCC_GRAY_CORRECTION root ar - -XCOMM To let untrusted clients use the overlay visuals that many vendors -XCOMM support, include this line. -property SERVER_OVERLAY_VISUALS root ar - -XCOMM Dumb examples to show other capabilities. - -XCOMM oddball property names and explicit specification of error conditions -property "property with spaces" 'property with "' aw er ed - -XCOMM Allow deletion of Woo-Hoo if window also has property OhBoy with value -XCOMM ending in "son". Reads and writes will cause an error. -property Woo-Hoo OhBoy = "*son" ad - -.fi +The syntax of the security policy file is described in +\fISecurityPolicy\fP(__filemansuffix__). .SH "NETWORK CONNECTIONS" The X server supports client connections via a platform-dependent subset of the following transport types: TCP\/IP, Unix Domain sockets, DECnet, @@ -757,6 +544,9 @@ Error log file for display number \fBn\fP if run from \fIinit\fP(__adminmansuffi .TP 30 .I __projectroot__/lib/X11/xdm/xdm-errors Default error log file if the server is run from \fIxdm\fP(1) +.TP 30 +.I __projectroot__/lib/xserver/SecurityPolicy +Default X server security policy .SH "SEE ALSO" General information: \fIX\fP(__miscmansuffix__) .PP @@ -771,6 +561,7 @@ Fonts: \fIbdftopcf\fP(1), \fImkfontdir\fP(1), \fImkfontscale\fP(1), .PP Security: \fIXsecurity\fP(__miscmansuffix__), \fIxauth\fP(1), \fIXau\fP(1), \fIxdm\fP(1), \fIxhost\fP(1), \fIxfwp\fP(1), +\fISecurityPolicy\fP(__filemansuffix__), .I "Security Extension Specification" .PP Starting the server: \fIxdm\fP(1), \fIxinit\fP(1) diff --git a/hw/Makefile.am b/hw/Makefile.am index d00d6fb3f..99df8e230 100644 --- a/hw/Makefile.am +++ b/hw/Makefile.am @@ -1,10 +1,18 @@ if DMX +if BUILD_DARWIN +# Darwin does not need the dmx subdir +else DMX_SUBDIRS = dmx endif +endif if XORG +if BUILD_DARWIN +# Darwin does not need the xfree86 subdir +else XORG_SUBDIRS = xfree86 endif +endif if XVFB XVFB_SUBDIRS = vfb @@ -30,12 +38,15 @@ if XPRINT XPRINT_SUBDIRS = xprint endif -# need to add darwin support here +if BUILD_DARWIN +DARWIN_SUBDIRS = darwin +endif SUBDIRS = \ $(XORG_SUBDIRS) \ $(XGL_SUBDIRS) \ $(XWIN_SUBDIRS) \ + $(DARWIN_SUBDIRS) \ $(XVFB_SUBDIRS) \ $(XNEST_SUBDIRS) \ $(DMX_SUBDIRS) \ diff --git a/hw/darwin/Makefile.am b/hw/darwin/Makefile.am index 7efd056c5..75d028ea5 100644 --- a/hw/darwin/Makefile.am +++ b/hw/darwin/Makefile.am @@ -3,7 +3,7 @@ libdarwin_XINPUT_SRCS = darwinXinput.c AM_CFLAGS = @XORG_CFLAGS@ @DIX_CFLAGS@ AM_CPPFLAGS = @XORG_CFLAGS@ @DIX_CFLAGS@ -INCLUDES = @XORG_INCS@ +INCLUDES = @XORG_INCS@ -I../../miext/rootless DEFS = @DEFS@ -DUSE_NEW_CLUT @@ -17,65 +17,106 @@ SUBDIRS = \ utils \ . - darwinappdir = @APPLE_APPLICATIONS_DIR@/XDarwin.app - libdarwinShared_a_SOURCES = darwin.c \ darwinEvents.c \ darwinKeyboard.c \ $(darwin_XINPUT_SRCS) -bin_PROGRAMS = XDarwin +bin_PROGRAMS = XDarwin Xquartz XDarwin_SOURCES = \ $(top_srcdir)/fb/fbcmap.c \ $(top_srcdir)/mi/miinitext.c \ $(top_srcdir)/Xi/stubs.c + +Xquartz_SOURCES = \ + $(top_srcdir)/fb/fbcmap.c \ + $(top_srcdir)/mi/miinitext.c \ + $(top_srcdir)/Xi/stubs.c \ + apple/X11Application.m \ + apple/X11Controller.m \ + quartz/Xserver.m \ + quartz/Preferences.m \ + quartz/applewm.c \ + quartz/keysym2ucs.c \ + quartz/pseudoramiX.c \ + quartz/quartz.c \ + quartz/quartzAudio.c \ + quartz/quartzCocoa.m \ + quartz/quartzKeyboard.c \ + quartz/quartzPasteboard.c \ + quartz/quartzStartup.c \ + quartz/xpr/appledri.c \ + quartz/xpr/dri.c \ + quartz/xpr/xprAppleWM.c \ + quartz/xpr/xprCursor.c \ + quartz/xpr/xprFrame.c \ + quartz/xpr/xprScreen.c \ + quartz/xpr/x-hash.c \ + quartz/xpr/x-hook.c \ + quartz/xpr/x-list.c + XDarwin_LDADD = \ $(top_builddir)/dix/dixfonts.lo \ $(top_builddir)/dix/libdix.la \ $(top_builddir)/config/libconfig.a \ - $(top_builddir)/os/libos.la \ ./libdarwinShared.a \ ./iokit/libiokit.a \ - $(top_builddir)/dix/libxpstubs.la \ $(top_builddir)/miext/shadow/libshadow.la \ - $(top_builddir)/fb/libfb.la \ - $(top_builddir)/composite/libcomposite.la \ - $(top_builddir)/damageext/libdamageext.la \ - $(top_builddir)/miext/damage/libdamage.la \ - $(top_builddir)/xfixes/libxfixes.la \ $(top_builddir)/miext/cw/libcw.la \ - $(top_builddir)/Xext/libXext.la \ - $(top_builddir)/xkb/libxkb.la \ - $(top_builddir)/xkb/libxkbstubs.la \ - $(top_builddir)/Xi/libXi.la \ - $(top_builddir)/dbe/libdbe.la \ - $(top_builddir)/record/librecord.la \ - $(top_builddir)/XTrap/libxtrap.la \ - $(XGLX_LIBS) \ + $(DARWIN_LIBS) \ $(top_builddir)/miext/rootless/librootless.la \ $(top_builddir)/miext/rootless/safeAlpha/libsafeAlpha.la \ $(top_builddir)/miext/rootless/accel/librlAccel.la \ @XORG_LIBS@ \ - -lXau -lXdmcp -lXfont -lfreetype + $(XSERVER_LIBS) + +Xquartz_LDADD = \ + $(top_builddir)/dix/dixfonts.lo \ + $(top_builddir)/dix/libdix.la \ + $(top_builddir)/config/libconfig.a \ + ./libdarwinShared.a \ + $(top_builddir)/miext/shadow/libshadow.la \ + $(top_builddir)/miext/cw/libcw.la \ + $(DARWIN_LIBS) \ + $(top_builddir)/miext/rootless/librootless.la \ + $(top_builddir)/miext/rootless/safeAlpha/libsafeAlpha.la \ + $(top_builddir)/miext/rootless/accel/librlAccel.la \ + @XORG_LIBS@ \ + $(XSERVER_LIBS) -lXplugin XDarwin_LDFLAGS = \ - -XCClinker -Objc \ - -Wl,-u,_miDCInitialize \ - -Wl,-framework,IOKit + -XCClinker -Objc \ + -Wl,-u,_miDCInitialize \ + -Wl,-framework,IOKit + +Xquartz_LDFLAGS = \ + -XCClinker -Objc \ + -Wl,-u,_miDCInitialize \ + -Wl,-framework,Carbon \ + -Wl,-framework,OpenGL \ + -Wl,-framework,Cocoa \ + -Wl,-framework,CoreAudio \ + -Wl,-framework,IOKit XDarwin_CFLAGS = -DINXDARWIN +Xquartz_CFLAGS = -DINXQUARTZ -DHAS_CG_MACH_PORT -DHAS_KL_API -DHAVE_XORG_CONFIG_H + if XQUARTZ macosdir = $(darwinappdir)/Contents/MacOS DEFS += -DDARWIN_WITH_QUARTZ -DXFree86Server macos_PROGRAMS = XDarwinApp +macos_SCRIPTS = x11app + +x11app: + cd apple && xcodebuild XDarwinApp_SOURCES = \ - $(top_srcdir)/fb/fbcmap.c \ - $(top_srcdir)/mi/miinitext.c \ + $(top_srcdir)/fb/fbcmap.c \ + $(top_srcdir)/mi/miinitext.c \ $(top_srcdir)/Xi/stubs.c XDarwinApp_LDADD = \ @@ -86,28 +127,14 @@ XDarwinApp_LDADD = \ ./quartz/XApplication.o \ ./libdarwinShared.a \ ./quartz/libXQuartz.a \ - $(top_builddir)/dix/libxpstubs.la \ $(top_builddir)/miext/shadow/libshadow.la \ - $(top_builddir)/fb/libfb.la \ - $(top_builddir)/composite/libcomposite.la \ - $(top_builddir)/damageext/libdamageext.la \ - $(top_builddir)/miext/damage/libdamage.la \ - $(top_builddir)/xfixes/libxfixes.la \ $(top_builddir)/miext/cw/libcw.la \ - $(top_builddir)/Xext/libXext.la \ - $(top_builddir)/xkb/libxkb.la \ - $(top_builddir)/xkb/libxkbstubs.la \ - $(top_builddir)/Xi/libXi.la \ - $(top_builddir)/dbe/libdbe.la \ - $(top_builddir)/record/librecord.la \ - $(top_builddir)/XTrap/libxtrap.la \ - $(XGLX_LIBS) \ + $(DARWIN_LIBS) \ $(top_builddir)/miext/rootless/librootless.la \ $(top_builddir)/miext/rootless/safeAlpha/libsafeAlpha.la \ $(top_builddir)/miext/rootless/accel/librlAccel.la \ @XORG_LIBS@ \ - -lXau -lXdmcp -lXfont -lfreetype \ - $(top_builddir)/fb/libfb.la + $(XSERVER_LIBS) XDarwinApp_LDFLAGS = \ -XCClinker -Objc \ @@ -118,21 +145,24 @@ XDarwinApp_LDFLAGS = \ -Wl,-framework,CoreAudio \ -Wl,-framework,IOKit +XDarwinApp_CFLAGS = -DINXDARWINAPP HOOK_TARGETS = xquartz-install-hook crplugindir = $(darwinappdir)/Contents/Resources/cr.bundle/Contents/MacOS crplugin_LTLIBRARIES = cr.la -cr_la_SOURCES = +cr_la_SOURCES = \ + quartz/cr/crAppleWM.m \ + quartz/cr/crFrame.m \ + quartz/cr/crScreen.m \ + quartz/fullscreen/quartzCursor.c \ + quartz/cr/XView.m + cr_la_LIBADD = \ - quartz/cr/crAppleWM.o \ - quartz/cr/crFrame.o \ - quartz/cr/crScreen.o \ - quartz/fullscreen/quartzCursor.o \ - quartz/cr/XView.o \ $(top_builddir)/miext/rootless/librootless.la \ $(top_builddir)/miext/rootless/safeAlpha/libsafeAlpha.la \ $(top_builddir)/miext/rootless/accel/librlAccel.la + cr_la_LDFLAGS = -shrext '' -Wl,-framework,ApplicationServices \ -Wl,-framework,Cocoa \ -Wl,-framework,Carbon \ @@ -143,10 +173,11 @@ cr_la_DEPENDENCIES = XDarwinApp fullscreenplugindir = $(darwinappdir)/Contents/Resources/fullscreen.bundle/Contents/MacOS fullscreenplugin_LTLIBRARIES = fullscreen.la -fullscreen_la_SOURCES = +fullscreen_la_SOURCES = \ + quartz/fullscreen/fullscreen.c \ + quartz/fullscreen/quartzCursor.c + fullscreen_la_LIBADD = \ - quartz/fullscreen/fullscreen.o \ - quartz/fullscreen/quartzCursor.o \ $(top_builddir)/miext/shadow/libshadow.la fullscreen_la_LDFLAGS = -shrext '' -Wl,-framework,ApplicationServices \ @@ -175,20 +206,22 @@ if HAVE_X_PLUGIN xprplugindir = $(darwinappdir)/Contents/Resources/xpr.bundle/Contents/MacOS xprplugin_LTLIBRARIES = xpr.la -xpr_la_SOURCES = +xpr_la_SOURCES = \ + quartz/xpr/appledri.c \ + quartz/xpr/dri.c \ + quartz/xpr/xprAppleWM.c \ + quartz/xpr/xprCursor.c \ + quartz/xpr/xprFrame.c \ + quartz/xpr/xprScreen.c \ + quartz/xpr/x-hash.c \ + quartz/xpr/x-hook.c \ + quartz/xpr/x-list.c + xpr_la_LIBADD = \ - quartz/xpr/appledri.o \ - quartz/xpr/dri.o \ - quartz/xpr/xprAppleWM.o \ - quartz/xpr/xprCursor.o \ - quartz/xpr/xprFrame.o \ - quartz/xpr/xprScreen.o \ - quartz/xpr/x-hash.o \ - quartz/xpr/x-hook.o \ - quartz/xpr/x-list.o \ $(top_builddir)/miext/rootless/librootless.la \ $(top_builddir)/miext/rootless/safeAlpha/libsafeAlpha.la \ $(top_builddir)/miext/rootless/accel/librlAccel.la + xpr_la_LDFLAGS = -shrext '' -Wl,-framework,ApplicationServices \ -lXplugin \ -XCClinker -bundle_loader -XCClinker XDarwinApp \ @@ -242,6 +275,7 @@ install-data-hook: $(HOOK_TARGETS) xquartz-install-hook: mv $(DESTDIR)$(macosdir)/XDarwinApp $(DESTDIR)$(macosdir)/XDarwin + cd apple && xcodebuild CFLAGS="$(XSERVERCFLAGS_CFLAGS)" LDFLAGS="$(XSERVERCFLAGS_LIBS)" EXTRA_DIST = \ darwin.c \ diff --git a/hw/darwin/README.apple b/hw/darwin/README.apple new file mode 100644 index 000000000..68bc692c9 --- /dev/null +++ b/hw/darwin/README.apple @@ -0,0 +1,41 @@ +This directory contains a port of the XDarwin code to the modular X.org +codebase to be compiled on Darwin/OS X; this would not have been possible +without the help of Torrey Lyons and Peter O'Gorman, to whom I am +grateful for their patches, time and moral support. + +The server builds 4 targets: + +* XDarwin: this server runs on Darwin systems without Quartz + (i.e. non-OS X); it has not been well-tested. + +* XDarwinApp: this builds XDarwin.app, which is a full X server using + Quartz. It has loadable module support for AGL and CGL, and well as + fullscreen and rootless support. + +* Xquartz: this server runs on Quartz-based systems, and is meant to + work with X11.app + +* x11app: this builds a version of Apple's X11.app using patches by + Torrey Lyons; most, but not all, functionality of Apple's original + X11.app is present in this release. + +Known issues: + +* AGL and CGL support for 3D indirect acceleration does not work; + indirect.c needs to be rewritten. + +* Fullscreen mode does not work; I don't know why. + +* The keyboard and mouse do not work at all; they worked in X11R7.1, + and I believe that they were broken by the events changes in dix/. + +* Some features in X11.app are not yet implemented; these are marked + with #ifdef DARWIN_DDX_MISSING in the code. + +* The build system code could probably be cleaned up slightly. + +* Most testing of this code has occurred under 10.5, but it should + also work under 10.4. + +Any patches or code contributions would be most welcome and may be +sent to me at bbyer@apple.com. diff --git a/hw/darwin/apple/English.lproj/InfoPlist.strings b/hw/darwin/apple/English.lproj/InfoPlist.strings new file mode 100644 index 000000000..88e1f04ac Binary files /dev/null and b/hw/darwin/apple/English.lproj/InfoPlist.strings differ diff --git a/hw/darwin/apple/English.lproj/main.nib/.svn/entries b/hw/darwin/apple/English.lproj/main.nib/.svn/entries new file mode 100644 index 000000000..95a15f220 --- /dev/null +++ b/hw/darwin/apple/English.lproj/main.nib/.svn/entries @@ -0,0 +1,65 @@ +8 + +dir +29110 +svn+ssh://src.apple.com/svn/BSD/X11server/trunk/darwin/apple/English.lproj/main.nib +svn+ssh://src.apple.com/svn/BSD + + + +2007-02-03T03:06:20.842932Z +28761 +bbyer + + +svn:special svn:externals svn:needs-lock + + + + + + + + + + + +e92bca22-270c-0410-9cea-e3f1106b6a1c + +info.nib +file + + + + +2007-02-27T01:00:07.000000Z +456347804c516786b1d1339ce2ef50a2 +2007-02-03T03:06:20.842932Z +28761 +bbyer + +keyedobjects.nib +file + + + + +2007-02-27T01:00:07.000000Z +eb3010372b09768c846df0d996cfdd8d +2007-02-03T03:06:20.842932Z +28761 +bbyer +has-props + +classes.nib +file + + + + +2007-02-27T01:00:07.000000Z +0ae2660c3afabbd5aa02fc34712c96e6 +2007-02-03T03:06:20.842932Z +28761 +bbyer + diff --git a/hw/darwin/apple/English.lproj/main.nib/.svn/format b/hw/darwin/apple/English.lproj/main.nib/.svn/format new file mode 100644 index 000000000..45a4fb75d --- /dev/null +++ b/hw/darwin/apple/English.lproj/main.nib/.svn/format @@ -0,0 +1 @@ +8 diff --git a/hw/darwin/apple/English.lproj/main.nib/.svn/prop-base/keyedobjects.nib.svn-base b/hw/darwin/apple/English.lproj/main.nib/.svn/prop-base/keyedobjects.nib.svn-base new file mode 100644 index 000000000..5e9587e65 --- /dev/null +++ b/hw/darwin/apple/English.lproj/main.nib/.svn/prop-base/keyedobjects.nib.svn-base @@ -0,0 +1,5 @@ +K 13 +svn:mime-type +V 24 +application/octet-stream +END diff --git a/hw/darwin/apple/English.lproj/main.nib/.svn/text-base/classes.nib.svn-base b/hw/darwin/apple/English.lproj/main.nib/.svn/text-base/classes.nib.svn-base new file mode 100644 index 000000000..a82159bd5 --- /dev/null +++ b/hw/darwin/apple/English.lproj/main.nib/.svn/text-base/classes.nib.svn-base @@ -0,0 +1,318 @@ + + + + + IBClasses + + + CLASS + IBLibraryObjectTemplate + LANGUAGE + ObjC + OUTLETS + + draggedView + NSView + representedObject + NSObject + + SUPERCLASS + NSView + + + CLASS + IBInspector + LANGUAGE + ObjC + OUTLETS + + inspectorView + NSView + + SUPERCLASS + NSObject + + + CLASS + NSDateFormatter + LANGUAGE + ObjC + SUPERCLASS + NSFormatter + + + ACTIONS + + apps_table_cancel + id + apps_table_delete + id + apps_table_done + id + apps_table_duplicate + id + apps_table_new + id + apps_table_show + id + bring_to_front + id + close_window + id + enable_fullscreen_changed + id + minimize_window + id + next_window + id + prefs_changed + id + prefs_show + id + previous_window + id + toggle_fullscreen + id + x11_help + id + zoom_window + id + + CLASS + X11Controller + LANGUAGE + ObjC + OUTLETS + + apps_separator + id + apps_table + id + depth + id + dock_apps_menu + id + dock_menu + id + dock_window_separator + id + enable_auth + id + enable_fullscreen + id + enable_keyequivs + id + enable_tcp + id + fake_buttons + id + prefs_panel + id + sync_keymap + id + toggle_fullscreen_item + id + use_sysbeep + id + window_separator + id + x11_about_item + id + + SUPERCLASS + NSObject + + + CLASS + NSNumberFormatter + LANGUAGE + ObjC + SUPERCLASS + NSFormatter + + + CLASS + NSFormatter + LANGUAGE + ObjC + SUPERCLASS + NSObject + + + ACTIONS + + alignCenter: + id + alignJustified: + id + alignLeft: + id + alignRight: + id + arrangeInFront: + id + centerSelectionInVisibleArea: + id + changeFont: + id + checkSpelling: + id + clear: + id + clearRecentDocuments: + id + complete: + id + copy: + id + copyFont: + id + copyRuler: + id + cut: + id + delete: + id + deminiaturize: + id + fax: + id + hide: + id + hideOtherApplications: + id + loosenKerning: + id + lowerBaseline: + id + makeKeyAndOrderFront: + id + miniaturize: + id + newDocument: + id + openDocument: + id + orderBack: + id + orderFront: + id + orderFrontColorPanel: + id + orderFrontHelpPanel: + id + orderOut: + id + outline: + id + paste: + id + pasteAsPlainText: + id + pasteAsRichText: + id + pasteFont: + id + pasteRuler: + id + pause: + id + performClose: + id + performFindPanelAction: + id + performMiniaturize: + id + performZoom: + id + play: + id + print: + id + printDocument: + id + raiseBaseline: + id + record: + id + redo: + id + resume: + id + revertDocumentToSaved: + id + run: + id + runPageLayout: + id + runToolbarCustomizationPalette: + id + saveAllDocuments: + id + saveDocument: + id + saveDocumentAs: + id + saveDocumentTo: + id + selectAll: + id + selectText: + id + showGuessPanel: + id + showHelp: + id + start: + id + startSpeaking: + id + stop: + id + stopSpeaking: + id + subscript: + id + superscript: + id + terminate: + id + tightenKerning: + id + toggleContinuousSpellChecking: + id + toggleRuler: + id + toggleToolbarShown: + id + turnOffKerning: + id + turnOffLigatures: + id + underline: + id + undo: + id + unhideAllApplications: + id + unscript: + id + useAllLigatures: + id + useStandardKerning: + id + useStandardLigatures: + id + + CLASS + FirstResponder + LANGUAGE + ObjC + SUPERCLASS + NSObject + + + IBVersion + 1 + + diff --git a/hw/darwin/apple/English.lproj/main.nib/.svn/text-base/info.nib.svn-base b/hw/darwin/apple/English.lproj/main.nib/.svn/text-base/info.nib.svn-base new file mode 100644 index 000000000..88bc6260d --- /dev/null +++ b/hw/darwin/apple/English.lproj/main.nib/.svn/text-base/info.nib.svn-base @@ -0,0 +1,18 @@ + + + + + IBFramework Version + 588 + IBOpenObjects + + 244 + 29 + 423 + + IBSystem Version + 9A356 + targetFramework + IBCocoaFramework + + diff --git a/hw/darwin/apple/English.lproj/main.nib/.svn/text-base/keyedobjects.nib.svn-base b/hw/darwin/apple/English.lproj/main.nib/.svn/text-base/keyedobjects.nib.svn-base new file mode 100644 index 000000000..8b31450ff Binary files /dev/null and b/hw/darwin/apple/English.lproj/main.nib/.svn/text-base/keyedobjects.nib.svn-base differ diff --git a/hw/darwin/apple/English.lproj/main.nib/classes.nib b/hw/darwin/apple/English.lproj/main.nib/classes.nib new file mode 100644 index 000000000..a82159bd5 --- /dev/null +++ b/hw/darwin/apple/English.lproj/main.nib/classes.nib @@ -0,0 +1,318 @@ + + + + + IBClasses + + + CLASS + IBLibraryObjectTemplate + LANGUAGE + ObjC + OUTLETS + + draggedView + NSView + representedObject + NSObject + + SUPERCLASS + NSView + + + CLASS + IBInspector + LANGUAGE + ObjC + OUTLETS + + inspectorView + NSView + + SUPERCLASS + NSObject + + + CLASS + NSDateFormatter + LANGUAGE + ObjC + SUPERCLASS + NSFormatter + + + ACTIONS + + apps_table_cancel + id + apps_table_delete + id + apps_table_done + id + apps_table_duplicate + id + apps_table_new + id + apps_table_show + id + bring_to_front + id + close_window + id + enable_fullscreen_changed + id + minimize_window + id + next_window + id + prefs_changed + id + prefs_show + id + previous_window + id + toggle_fullscreen + id + x11_help + id + zoom_window + id + + CLASS + X11Controller + LANGUAGE + ObjC + OUTLETS + + apps_separator + id + apps_table + id + depth + id + dock_apps_menu + id + dock_menu + id + dock_window_separator + id + enable_auth + id + enable_fullscreen + id + enable_keyequivs + id + enable_tcp + id + fake_buttons + id + prefs_panel + id + sync_keymap + id + toggle_fullscreen_item + id + use_sysbeep + id + window_separator + id + x11_about_item + id + + SUPERCLASS + NSObject + + + CLASS + NSNumberFormatter + LANGUAGE + ObjC + SUPERCLASS + NSFormatter + + + CLASS + NSFormatter + LANGUAGE + ObjC + SUPERCLASS + NSObject + + + ACTIONS + + alignCenter: + id + alignJustified: + id + alignLeft: + id + alignRight: + id + arrangeInFront: + id + centerSelectionInVisibleArea: + id + changeFont: + id + checkSpelling: + id + clear: + id + clearRecentDocuments: + id + complete: + id + copy: + id + copyFont: + id + copyRuler: + id + cut: + id + delete: + id + deminiaturize: + id + fax: + id + hide: + id + hideOtherApplications: + id + loosenKerning: + id + lowerBaseline: + id + makeKeyAndOrderFront: + id + miniaturize: + id + newDocument: + id + openDocument: + id + orderBack: + id + orderFront: + id + orderFrontColorPanel: + id + orderFrontHelpPanel: + id + orderOut: + id + outline: + id + paste: + id + pasteAsPlainText: + id + pasteAsRichText: + id + pasteFont: + id + pasteRuler: + id + pause: + id + performClose: + id + performFindPanelAction: + id + performMiniaturize: + id + performZoom: + id + play: + id + print: + id + printDocument: + id + raiseBaseline: + id + record: + id + redo: + id + resume: + id + revertDocumentToSaved: + id + run: + id + runPageLayout: + id + runToolbarCustomizationPalette: + id + saveAllDocuments: + id + saveDocument: + id + saveDocumentAs: + id + saveDocumentTo: + id + selectAll: + id + selectText: + id + showGuessPanel: + id + showHelp: + id + start: + id + startSpeaking: + id + stop: + id + stopSpeaking: + id + subscript: + id + superscript: + id + terminate: + id + tightenKerning: + id + toggleContinuousSpellChecking: + id + toggleRuler: + id + toggleToolbarShown: + id + turnOffKerning: + id + turnOffLigatures: + id + underline: + id + undo: + id + unhideAllApplications: + id + unscript: + id + useAllLigatures: + id + useStandardKerning: + id + useStandardLigatures: + id + + CLASS + FirstResponder + LANGUAGE + ObjC + SUPERCLASS + NSObject + + + IBVersion + 1 + + diff --git a/hw/darwin/apple/English.lproj/main.nib/info.nib b/hw/darwin/apple/English.lproj/main.nib/info.nib new file mode 100644 index 000000000..88bc6260d --- /dev/null +++ b/hw/darwin/apple/English.lproj/main.nib/info.nib @@ -0,0 +1,18 @@ + + + + + IBFramework Version + 588 + IBOpenObjects + + 244 + 29 + 423 + + IBSystem Version + 9A356 + targetFramework + IBCocoaFramework + + diff --git a/hw/darwin/apple/English.lproj/main.nib/keyedobjects.nib b/hw/darwin/apple/English.lproj/main.nib/keyedobjects.nib new file mode 100644 index 000000000..8b31450ff Binary files /dev/null and b/hw/darwin/apple/English.lproj/main.nib/keyedobjects.nib differ diff --git a/hw/darwin/apple/Info.plist b/hw/darwin/apple/Info.plist new file mode 100644 index 000000000..ae47e9590 --- /dev/null +++ b/hw/darwin/apple/Info.plist @@ -0,0 +1,71 @@ + + + + + CFBundleDevelopmentRegion + English + CFBundleDocumentTypes + + + CFBundleTypeExtensions + + x11app + + CFBundleTypeIconFile + X11.icns + CFBundleTypeName + X11 Application + CFBundleTypeOSTypes + + **** + + CFBundleTypeRole + Viewer + LSIsAppleDefaultForType + + + + CFBundleTypeExtensions + + tool + * + + CFBundleTypeName + UNIX Application + CFBundleTypeOSTypes + + **** + + CFBundleTypeRole + Viewer + + + CFBundleExecutable + X11 + CFBundleGetInfoString + X11 + CFBundleIconFile + X11.icns + CFBundleIdentifier + org.x.X11 + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + X11 + CFBundlePackageType + APPL + CFBundleShortVersionString + 2.0 + CFBundleSignature + ???? + CSResourcesFileMapped + + NSHumanReadableCopyright + Copyright © 2003-2007, Apple Inc. +Copyright © 2003, XFree86 Project, Inc. + NSMainNibFile + main + NSPrincipalClass + X11Application + + diff --git a/hw/darwin/apple/X11.icns b/hw/darwin/apple/X11.icns new file mode 100644 index 000000000..4c4717726 Binary files /dev/null and b/hw/darwin/apple/X11.icns differ diff --git a/hw/darwin/apple/X11.xcodeproj/project.pbxproj b/hw/darwin/apple/X11.xcodeproj/project.pbxproj new file mode 100644 index 000000000..2fef99ba0 --- /dev/null +++ b/hw/darwin/apple/X11.xcodeproj/project.pbxproj @@ -0,0 +1,320 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 42; + objects = { + +/* Begin PBXBuildFile section */ + 527F24190B5D938C007840A7 /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 0867D6AAFE840B52C02AAC07 /* InfoPlist.strings */; }; + 527F241A0B5D938C007840A7 /* main.nib in Resources */ = {isa = PBXBuildFile; fileRef = 02345980000FD03B11CA0E72 /* main.nib */; }; + 527F241B0B5D938C007840A7 /* X11.icns in Resources */ = {isa = PBXBuildFile; fileRef = 50459C5F038587C60ECA21EC /* X11.icns */; }; + 527F241D0B5D938C007840A7 /* bundle-main.c in Sources */ = {isa = PBXBuildFile; fileRef = 50EE2AB703849F0B0ECA21EC /* bundle-main.c */; }; + 527F241F0B5D938C007840A7 /* CoreFoundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 50F4F0A7039D6ACA0E82C0CB /* CoreFoundation.framework */; }; + 527F24200B5D938C007840A7 /* SystemConfiguration.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 570C5748047186C400ACF82F /* SystemConfiguration.framework */; }; + 527F24370B5D9D89007840A7 /* Info.plist in Resources */ = {isa = PBXBuildFile; fileRef = 527F24260B5D938C007840A7 /* Info.plist */; }; +/* End PBXBuildFile section */ + +/* Begin PBXFileReference section */ + 0867D6ABFE840B52C02AAC07 /* English */ = {isa = PBXFileReference; fileEncoding = 10; lastKnownFileType = text.plist.strings; name = English; path = English.lproj/InfoPlist.strings; sourceTree = ""; }; + 1870340FFE93FCAF11CA0CD7 /* English */ = {isa = PBXFileReference; lastKnownFileType = wrapper.nib; name = English; path = English.lproj/main.nib; sourceTree = ""; }; + 50459C5F038587C60ECA21EC /* X11.icns */ = {isa = PBXFileReference; lastKnownFileType = image.icns; path = X11.icns; sourceTree = ""; }; + 50EE2AB703849F0B0ECA21EC /* bundle-main.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; path = "bundle-main.c"; sourceTree = ""; }; + 50F4F0A7039D6ACA0E82C0CB /* CoreFoundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreFoundation.framework; path = /System/Library/Frameworks/CoreFoundation.framework; sourceTree = ""; }; + 527F24260B5D938C007840A7 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.xml; path = Info.plist; sourceTree = ""; }; + 527F24270B5D938C007840A7 /* X11.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = X11.app; sourceTree = BUILT_PRODUCTS_DIR; }; + 570C5748047186C400ACF82F /* SystemConfiguration.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = SystemConfiguration.framework; path = /System/Library/Frameworks/SystemConfiguration.framework; sourceTree = ""; }; +/* End PBXFileReference section */ + +/* Begin PBXFrameworksBuildPhase section */ + 527F241E0B5D938C007840A7 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + 527F241F0B5D938C007840A7 /* CoreFoundation.framework in Frameworks */, + 527F24200B5D938C007840A7 /* SystemConfiguration.framework in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + 195DF8CFFE9D517E11CA2CBB /* Products */ = { + isa = PBXGroup; + children = ( + 527F24270B5D938C007840A7 /* X11.app */, + ); + name = Products; + sourceTree = ""; + }; + 20286C29FDCF999611CA2CEA /* X11 */ = { + isa = PBXGroup; + children = ( + 20286C2AFDCF999611CA2CEA /* Sources */, + 20286C2CFDCF999611CA2CEA /* Resources */, + 20286C32FDCF999611CA2CEA /* External Frameworks and Libraries */, + 195DF8CFFE9D517E11CA2CBB /* Products */, + 527F24260B5D938C007840A7 /* Info.plist */, + ); + name = X11; + sourceTree = ""; + }; + 20286C2AFDCF999611CA2CEA /* Sources */ = { + isa = PBXGroup; + children = ( + 50EE2AB703849F0B0ECA21EC /* bundle-main.c */, + ); + name = Sources; + sourceTree = ""; + }; + 20286C2CFDCF999611CA2CEA /* Resources */ = { + isa = PBXGroup; + children = ( + 50459C5F038587C60ECA21EC /* X11.icns */, + 0867D6AAFE840B52C02AAC07 /* InfoPlist.strings */, + 02345980000FD03B11CA0E72 /* main.nib */, + ); + name = Resources; + sourceTree = ""; + }; + 20286C32FDCF999611CA2CEA /* External Frameworks and Libraries */ = { + isa = PBXGroup; + children = ( + 50F4F0A7039D6ACA0E82C0CB /* CoreFoundation.framework */, + 570C5748047186C400ACF82F /* SystemConfiguration.framework */, + ); + name = "External Frameworks and Libraries"; + sourceTree = ""; + }; +/* End PBXGroup section */ + +/* Begin PBXHeadersBuildPhase section */ + 527F24170B5D938C007840A7 /* Headers */ = { + isa = PBXHeadersBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXHeadersBuildPhase section */ + +/* Begin PBXNativeTarget section */ + 527F24160B5D938C007840A7 /* X11 */ = { + isa = PBXNativeTarget; + buildConfigurationList = 527F24220B5D938C007840A7 /* Build configuration list for PBXNativeTarget "X11" */; + buildPhases = ( + 527F24170B5D938C007840A7 /* Headers */, + 527F24180B5D938C007840A7 /* Resources */, + 527F241C0B5D938C007840A7 /* Sources */, + 527F241E0B5D938C007840A7 /* Frameworks */, + 527F24210B5D938C007840A7 /* Rez */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = X11; + productName = X11; + productReference = 527F24270B5D938C007840A7 /* X11.app */; + productType = "com.apple.product-type.application"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + 20286C28FDCF999611CA2CEA /* Project object */ = { + isa = PBXProject; + buildConfigurationList = 527F24080B5D8FFC007840A7 /* Build configuration list for PBXProject "X11" */; + compatibilityVersion = "Xcode 2.4"; + hasScannedForEncodings = 1; + mainGroup = 20286C29FDCF999611CA2CEA /* X11 */; + projectDirPath = ""; + projectRoot = ""; + shouldCheckCompatibility = 1; + targets = ( + 527F24160B5D938C007840A7 /* X11 */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXResourcesBuildPhase section */ + 527F24180B5D938C007840A7 /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 527F24370B5D9D89007840A7 /* Info.plist in Resources */, + 527F24190B5D938C007840A7 /* InfoPlist.strings in Resources */, + 527F241A0B5D938C007840A7 /* main.nib in Resources */, + 527F241B0B5D938C007840A7 /* X11.icns in Resources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXResourcesBuildPhase section */ + +/* Begin PBXRezBuildPhase section */ + 527F24210B5D938C007840A7 /* Rez */ = { + isa = PBXRezBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXRezBuildPhase section */ + +/* Begin PBXSourcesBuildPhase section */ + 527F241C0B5D938C007840A7 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 527F241D0B5D938C007840A7 /* bundle-main.c in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin PBXVariantGroup section */ + 02345980000FD03B11CA0E72 /* main.nib */ = { + isa = PBXVariantGroup; + children = ( + 1870340FFE93FCAF11CA0CD7 /* English */, + ); + name = main.nib; + sourceTree = ""; + }; + 0867D6AAFE840B52C02AAC07 /* InfoPlist.strings */ = { + isa = PBXVariantGroup; + children = ( + 0867D6ABFE840B52C02AAC07 /* English */, + ); + name = InfoPlist.strings; + sourceTree = ""; + }; +/* End PBXVariantGroup section */ + +/* Begin XCBuildConfiguration section */ + 527F24090B5D8FFC007840A7 /* Development */ = { + isa = XCBuildConfiguration; + buildSettings = { + DSTROOT = "$(DSTROOT)"; + SKIP_INSTALL = YES; + }; + name = Development; + }; + 527F240A0B5D8FFC007840A7 /* Deployment */ = { + isa = XCBuildConfiguration; + buildSettings = { + DSTROOT = "$(DSTROOT)"; + SKIP_INSTALL = YES; + }; + name = Deployment; + }; + 527F240B0B5D8FFC007840A7 /* Default */ = { + isa = XCBuildConfiguration; + buildSettings = { + DSTROOT = "$(DSTROOT)"; + SKIP_INSTALL = YES; + }; + name = Default; + }; + 527F24230B5D938C007840A7 /* Development */ = { + isa = XCBuildConfiguration; + buildSettings = { + ARCHS = "$(NATIVE_ARCH_32_BIT)"; + COPY_PHASE_STRIP = NO; + DSTROOT = "$(DSTROOT)"; + FRAMEWORK_SEARCH_PATHS = ""; + GCC_SYMBOLS_PRIVATE_EXTERN = NO; + HEADER_SEARCH_PATHS = ""; + INFOPLIST_FILE = Info.plist; + INSTALL_PATH = $DSTROOT/Applications/Utilties; + LIBRARY_SEARCH_PATHS = ""; + OTHER_CFLAGS = "$(CFLAGS)"; + OTHER_LDFLAGS = "$(LDFLAGS)"; + OTHER_REZFLAGS = ""; + PRODUCT_NAME = X11; + SECTORDER_FLAGS = ""; + WARNING_CFLAGS = ( + "-Wmost", + "-Wno-four-char-constants", + "-Wno-unknown-pragmas", + ); + WRAPPER_EXTENSION = app; + }; + name = Development; + }; + 527F24240B5D938C007840A7 /* Deployment */ = { + isa = XCBuildConfiguration; + buildSettings = { + COPY_PHASE_STRIP = YES; + DSTROOT = "$(DSTROOT)"; + FRAMEWORK_SEARCH_PATHS = ""; + GCC_SYMBOLS_PRIVATE_EXTERN = NO; + HEADER_SEARCH_PATHS = ""; + INFOPLIST_FILE = Info.plist; + INSTALL_PATH = $DSTROOT/Applications/Utilties; + LIBRARY_SEARCH_PATHS = ""; + OTHER_CFLAGS = "$(CFLAGS)"; + OTHER_LDFLAGS = "$(LDFLAGS)"; + OTHER_REZFLAGS = ""; + PRODUCT_NAME = X11; + SECTORDER_FLAGS = ""; + WARNING_CFLAGS = ( + "-Wmost", + "-Wno-four-char-constants", + "-Wno-unknown-pragmas", + ); + WRAPPER_EXTENSION = app; + }; + name = Deployment; + }; + 527F24250B5D938C007840A7 /* Default */ = { + isa = XCBuildConfiguration; + buildSettings = { + DSTROOT = "$(DSTROOT)"; + FRAMEWORK_SEARCH_PATHS = ""; + GCC_SYMBOLS_PRIVATE_EXTERN = NO; + HEADER_SEARCH_PATHS = ""; + INFOPLIST_FILE = Info.plist; + INSTALL_PATH = $DSTROOT/Applications/Utilties; + LIBRARY_SEARCH_PATHS = ""; + OTHER_CFLAGS = "$(CFLAGS)"; + OTHER_LDFLAGS = "$(LDFLAGS)"; + OTHER_REZFLAGS = ""; + PRODUCT_NAME = X11; + SECTORDER_FLAGS = ""; + WARNING_CFLAGS = ( + "-Wmost", + "-Wno-four-char-constants", + "-Wno-unknown-pragmas", + ); + WRAPPER_EXTENSION = app; + }; + name = Default; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + 527F24080B5D8FFC007840A7 /* Build configuration list for PBXProject "X11" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 527F24090B5D8FFC007840A7 /* Development */, + 527F240A0B5D8FFC007840A7 /* Deployment */, + 527F240B0B5D8FFC007840A7 /* Default */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Default; + }; + 527F24220B5D938C007840A7 /* Build configuration list for PBXNativeTarget "X11" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 527F24230B5D938C007840A7 /* Development */, + 527F24240B5D938C007840A7 /* Deployment */, + 527F24250B5D938C007840A7 /* Default */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Default; + }; +/* End XCConfigurationList section */ + }; + rootObject = 20286C28FDCF999611CA2CEA /* Project object */; +} diff --git a/hw/darwin/apple/X11Application.h b/hw/darwin/apple/X11Application.h new file mode 100644 index 000000000..b9d2af8bf --- /dev/null +++ b/hw/darwin/apple/X11Application.h @@ -0,0 +1,104 @@ +/* X11Application.h -- subclass of NSApplication to multiplex events + $Id: X11Application.h,v 1.26 2003/08/08 19:16:13 jharper Exp $ + + Copyright (c) 2002-2007 Apple 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. */ + +#ifndef X11APPLICATION_H +#define X11APPLICATION_H 1 + +#if __OBJC__ + +#import +#import "X11Controller.h" + +@interface X11Application : NSApplication { + X11Controller *_controller; + + unsigned int _x_active :1; +} + +- (void) set_controller:controller; +- (void) set_window_menu:(NSArray *)list; + +- (int) prefs_get_integer:(NSString *)key default:(int)def; +- (const char *) prefs_get_string:(NSString *)key default:(const char *)def; +- (float) prefs_get_float:(NSString *)key default:(float)def; +- (int) prefs_get_boolean:(NSString *)key default:(int)def; +- (NSArray *) prefs_get_array:(NSString *)key; +- (void) prefs_set_integer:(NSString *)key value:(int)value; +- (void) prefs_set_float:(NSString *)key value:(float)value; +- (void) prefs_set_boolean:(NSString *)key value:(int)value; +- (void) prefs_set_array:(NSString *)key value:(NSArray *)value; +- (void) prefs_set_string:(NSString *)key value:(NSString *)value; +- (void) prefs_synchronize; + +- (BOOL) x_active; + +@end + +extern X11Application *X11App; + +#endif /* __OBJC__ */ + +extern void X11ApplicationSetWindowMenu (int nitems, const char **items, + const char *shortcuts); +extern void X11ApplicationSetWindowMenuCheck (int idx); +extern void X11ApplicationSetFrontProcess (void); +extern void X11ApplicationSetCanQuit (int state); +extern void X11ApplicationServerReady (void); +extern void X11ApplicationShowHideMenubar (int state); + +extern void X11ApplicationMain (int argc, const char *argv[], + void (*server_thread) (void *), + void *server_arg); + +extern int X11EnableKeyEquivalents; +extern int quartzHasRoot, quartzEnableRootless; + +#define APP_PREFS "com.apple.x11" + +#define PREFS_APPSMENU "apps_menu" +#define PREFS_FAKEBUTTONS "enable_fake_buttons" +#define PREFS_SYSBEEP "enable_system_beep" +#define PREFS_KEYEQUIVS "enable_key_equivalents" +#define PREFS_KEYMAP_FILE "keymap_file" +#define PREFS_SYNC_KEYMAP "sync_keymap" +#define PREFS_DEPTH "depth" +#define PREFS_NO_AUTH "no_auth" +#define PREFS_NO_TCP "nolisten_tcp" +#define PREFS_DONE_XINIT_CHECK "done_xinit_check" +#define PREFS_NO_QUIT_ALERT "no_quit_alert" +#define PREFS_FAKE_BUTTON2 "fake_button2" +#define PREFS_FAKE_BUTTON3 "fake_button3" +#define PREFS_ROOTLESS "rootless" +#define PREFS_FULLSCREEN_HOTKEYS "fullscreen_hotkeys" +#define PREFS_SWAP_ALT_META "swap_alt_meta" +#define PREFS_XP_OPTIONS "xp_options" +#define PREFS_ENABLE_STEREO "enable_stereo" + +#endif /* X11APPLICATION_H */ diff --git a/hw/darwin/apple/X11Application.m b/hw/darwin/apple/X11Application.m new file mode 100644 index 000000000..cfc975037 --- /dev/null +++ b/hw/darwin/apple/X11Application.m @@ -0,0 +1,972 @@ +/* X11Application.m -- subclass of NSApplication to multiplex events + + Copyright (c) 2002-2007 Apple Inc. + + 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. */ + +#include "../quartz/quartzCommon.h" + +#import "X11Application.h" +#include + +/* ouch! */ +#define BOOL X_BOOL +# include "darwin.h" +# include "../quartz/quartz.h" +# define _APPLEWM_SERVER_ +# include "X11/extensions/applewm.h" +# include "micmap.h" +#undef BOOL + +#include "xf86Version.h" + +#include +#include +#include + +#define DEFAULTS_FILE "/etc/X11/xserver/Xquartz.plist" + +int X11EnableKeyEquivalents = TRUE; +int quartzHasRoot = FALSE, quartzEnableRootless = TRUE; + +extern int darwinFakeButtons, input_check_flag; +// extern Bool enable_stereo; +Bool enable_stereo; //<-- this needs to go back to being an extern once glxCGL is fixed + +extern xEvent *darwinEvents; + +X11Application *X11App; + +#define ALL_KEY_MASKS (NSShiftKeyMask | NSControlKeyMask | NSAlternateKeyMask | NSCommandKeyMask) + +@implementation X11Application + +typedef struct message_struct message; +struct message_struct { + mach_msg_header_t hdr; + SEL selector; + NSObject *arg; +}; + +static mach_port_t _port; + +static void send_nsevent (NSEventType type, NSEvent *e); + +/* Quartz mode initialization routine. This is often dynamically loaded + but is statically linked into this X server. */ +extern Bool QuartzModeBundleInit(void); + +static void init_ports (void) { + kern_return_t r; + NSPort *p; + + if (_port != MACH_PORT_NULL) return; + + r = mach_port_allocate (mach_task_self (), MACH_PORT_RIGHT_RECEIVE, &_port); + if (r != KERN_SUCCESS) return; + + p = [NSMachPort portWithMachPort:_port]; + [p setDelegate:NSApp]; + [p scheduleInRunLoop:[NSRunLoop currentRunLoop] forMode:NSDefaultRunLoopMode]; +} + +static void message_kit_thread (SEL selector, NSObject *arg) { + message msg; + kern_return_t r; + + msg.hdr.msgh_bits = MACH_MSGH_BITS (MACH_MSG_TYPE_MAKE_SEND, 0); + msg.hdr.msgh_size = sizeof (msg); + msg.hdr.msgh_remote_port = _port; + msg.hdr.msgh_local_port = MACH_PORT_NULL; + msg.hdr.msgh_reserved = 0; + msg.hdr.msgh_id = 0; + + msg.selector = selector; + msg.arg = [arg retain]; + + r = mach_msg (&msg.hdr, MACH_SEND_MSG, msg.hdr.msgh_size, + 0, MACH_PORT_NULL, 0, MACH_PORT_NULL); + if (r != KERN_SUCCESS) + ErrorF("%s: mach_msg failed: %x\n", __FUNCTION__, r); +} + +- (void) handleMachMessage:(void *)_msg { + message *msg = _msg; + + [self performSelector:msg->selector withObject:msg->arg]; + [msg->arg release]; +} + +- (void) set_controller:obj { + if (_controller == nil) _controller = [obj retain]; +} + +- (void) dealloc { + if (_controller != nil) [_controller release]; + + if (_port != MACH_PORT_NULL) + mach_port_deallocate (mach_task_self (), _port); + + [super dealloc]; +} + +- (void) orderFrontStandardAboutPanel: (id) sender { + NSMutableDictionary *dict; + NSDictionary *infoDict; + NSString *tem; + + dict = [NSMutableDictionary dictionaryWithCapacity:2]; + infoDict = [[NSBundle mainBundle] infoDictionary]; + + [dict setObject: NSLocalizedString (@"The X Window System", @"About panel") + forKey:@"ApplicationName"]; + + tem = [infoDict objectForKey:@"CFBundleShortVersionString"]; + + [dict setObject:[NSString stringWithFormat:@"X11.app %@ - X.org X11R7.3", tem] + forKey:@"ApplicationVersion"]; + + [self orderFrontStandardAboutPanelWithOptions: dict]; +} + +- (void) activateX:(BOOL)state { + /* Create a TSM document that supports full Unicode input, and + have it activated while X is active (unless using the old + keymapping files) */ + static TSMDocumentID x11_document; + + if (state) { + QuartzMessageServerThread (kXDarwinActivate, 0); + + if (!_x_active) { + if (x11_document == 0 && darwinKeymapFile == NULL) { + OSType types[1]; + types[0] = kUnicodeDocument; + NewTSMDocument (1, types, &x11_document, 0); + } + + if (x11_document != 0) ActivateTSMDocument (x11_document); + } + } else { + QuartzMessageServerThread (kXDarwinDeactivate, 0); + + if (_x_active && x11_document != 0) + DeactivateTSMDocument (x11_document); + } + + _x_active = state; +} + +- (void) became_key:(NSWindow *)win { + [self activateX:NO]; +} + +- (void) sendEvent:(NSEvent *)e { + NSEventType type; + BOOL for_appkit, for_x; + + type = [e type]; + + /* By default pass down the responder chain and to X. */ + for_appkit = YES; + for_x = YES; + + switch (type) { + case NSLeftMouseDown: case NSRightMouseDown: case NSOtherMouseDown: + case NSLeftMouseUp: case NSRightMouseUp: case NSOtherMouseUp: + if ([e window] != nil) { + /* Pointer event has a window. Probably something for the kit. */ + + for_x = NO; + + if (_x_active) [self activateX:NO]; + } else if ([self modalWindow] == nil) { + /* Must be an X window. Tell appkit it doesn't have focus. */ + + for_appkit = NO; + + if ([self isActive]) { + [self deactivate]; + + if (!_x_active && quartzProcs->IsX11Window([e window], [e windowNumber])) + [self activateX:YES]; + } + } + break; + + case NSKeyDown: case NSKeyUp: + if (_x_active) { + static int swallow_up; + + /* No kit window is focused, so send it to X. */ + + for_appkit = NO; + + if (type == NSKeyDown) { + /* Before that though, see if there are any global + shortcuts bound to it. */ + + if (X11EnableKeyEquivalents + && [[self mainMenu] performKeyEquivalent:e]) { + swallow_up = [e keyCode]; + for_x = NO; + } else if (!quartzEnableRootless + && ([e modifierFlags] & ALL_KEY_MASKS) + == (NSCommandKeyMask | NSAlternateKeyMask) + && ([e keyCode] == 0 /*a*/ + || [e keyCode] == 53 /*Esc*/)) { + swallow_up = 0; + for_x = NO; +#ifdef DARWIN_DDX_MISSING + QuartzMessageServerThread (kXDarwinToggleFullscreen, 0); +#endif + } + } else { + /* If we saw a key equivalent on the down, don't pass + the up through to X. */ + + if (swallow_up != 0 && [e keyCode] == swallow_up) { + swallow_up = 0; + for_x = NO; + } + } + } + else for_x = NO; + break; + + case NSFlagsChanged: + /* For the l33t X users who remap modifier keys to normal keysyms. */ + if (!_x_active) + for_x = NO; + break; + + case NSAppKitDefined: + switch ([e subtype]) { + case NSApplicationActivatedEventType: + for_x = NO; + if ([self modalWindow] == nil) { + for_appkit = NO; + + /* FIXME: hack to avoid having to pass the event to appkit, + which would cause it to raise one of its windows. */ + _appFlags._active = YES; + + [self activateX:YES]; +#ifdef DARWIN_DDX_MISSING + if ([e data2] & 0x10) QuartzMessageServerThread (kXDarwinBringAllToFront, 0); +#endif + } + break; + + case 18: /* ApplicationDidReactivate */ + if (quartzHasRoot) for_appkit = NO; + break; + + case NSApplicationDeactivatedEventType: + for_x = NO; + [self activateX:NO]; + break; + } + break; + + default: break; /* for gcc */ + } + + if (for_appkit) [super sendEvent:e]; + if (for_x) send_nsevent (type, e); +} + +- (void) set_window_menu:(NSArray *)list { + [_controller set_window_menu:list]; +} + +- (void) set_window_menu_check:(NSNumber *)n { + [_controller set_window_menu_check:n]; +} + +- (void) set_apps_menu:(NSArray *)list { + [_controller set_apps_menu:list]; +} + +- (void) set_front_process:unused { + [NSApp activateIgnoringOtherApps:YES]; + + if ([self modalWindow] == nil) [self activateX:YES]; +} + +- (void) set_can_quit:(NSNumber *)state { + [_controller set_can_quit:[state boolValue]]; +} + +- (void) server_ready:unused { + [_controller server_ready]; +} + +- (void) show_hide_menubar:(NSNumber *)state { + if ([state boolValue]) ShowMenuBar (); + else HideMenuBar (); +} + + +/* user preferences */ + +/* Note that these functions only work for arrays whose elements + can be toll-free-bridged between NS and CF worlds. */ + +static const void *cfretain (CFAllocatorRef a, const void *b) { + return CFRetain (b); +} + +static void cfrelease (CFAllocatorRef a, const void *b) { + CFRelease (b); +} + +static CFMutableArrayRef nsarray_to_cfarray (NSArray *in) { + CFMutableArrayRef out; + CFArrayCallBacks cb; + NSObject *ns; + const CFTypeRef *cf; + int i, count; + + memset (&cb, 0, sizeof (cb)); + cb.version = 0; + cb.retain = cfretain; + cb.release = cfrelease; + + count = [in count]; + out = CFArrayCreateMutable (NULL, count, &cb); + + for (i = 0; i < count; i++) { + ns = [in objectAtIndex:i]; + + if ([ns isKindOfClass:[NSArray class]]) + cf = (CFTypeRef) nsarray_to_cfarray ((NSArray *) ns); + else + cf = CFRetain ((CFTypeRef) ns); + + CFArrayAppendValue (out, cf); + CFRelease (cf); + } + + return out; +} + +static NSMutableArray * cfarray_to_nsarray (CFArrayRef in) { + NSMutableArray *out; + const CFTypeRef *cf; + NSObject *ns; + int i, count; + + count = CFArrayGetCount (in); + out = [[NSMutableArray alloc] initWithCapacity:count]; + + for (i = 0; i < count; i++) { + cf = CFArrayGetValueAtIndex (in, i); + + if (CFGetTypeID (cf) == CFArrayGetTypeID ()) + ns = cfarray_to_nsarray ((CFArrayRef) cf); + else + ns = [(id)cf retain]; + + [out addObject:ns]; + [ns release]; + } + + return out; +} + +- (CFPropertyListRef) prefs_get:(NSString *)key { + CFPropertyListRef value; + + value = CFPreferencesCopyAppValue ((CFStringRef) key, CFSTR (APP_PREFS)); + + if (value == NULL) { + static CFDictionaryRef defaults; + + if (defaults == NULL) { + CFStringRef error = NULL; + CFDataRef data; + CFURLRef url; + SInt32 error_code; + + url = (CFURLCreateFromFileSystemRepresentation + (NULL, (unsigned char *)DEFAULTS_FILE, strlen (DEFAULTS_FILE), false)); + if (CFURLCreateDataAndPropertiesFromResource (NULL, url, &data, + NULL, NULL, &error_code)) { + defaults = (CFPropertyListCreateFromXMLData + (NULL, data, kCFPropertyListMutableContainersAndLeaves, &error)); + if (error != NULL) CFRelease (error); + CFRelease (data); + } + CFRelease (url); + + if (defaults != NULL) { + NSMutableArray *apps, *elt; + int count, i; + NSString *name, *nname; + + /* Localize the names in the default apps menu. */ + + apps = [(NSDictionary *)defaults objectForKey:@PREFS_APPSMENU]; + if (apps != nil) { + count = [apps count]; + for (i = 0; i < count; i++) { + elt = [apps objectAtIndex:i]; + if (elt != nil && [elt isKindOfClass:[NSArray class]]) { + name = [elt objectAtIndex:0]; + if (name != nil) { + nname = NSLocalizedString (name, nil); + if (nname != nil && nname != name) + [elt replaceObjectAtIndex:0 withObject:nname]; + } + } + } + } + } + } + + if (defaults != NULL) value = CFDictionaryGetValue (defaults, key); + if (value != NULL) CFRetain (value); + } + + return value; +} + +- (int) prefs_get_integer:(NSString *)key default:(int)def { + CFPropertyListRef value; + int ret; + + value = [self prefs_get:key]; + + if (value != NULL && CFGetTypeID (value) == CFNumberGetTypeID ()) + CFNumberGetValue (value, kCFNumberIntType, &ret); + else if (value != NULL && CFGetTypeID (value) == CFStringGetTypeID ()) + ret = CFStringGetIntValue (value); + else + ret = def; + + if (value != NULL) CFRelease (value); + + return ret; +} + +- (const char *) prefs_get_string:(NSString *)key default:(const char *)def { + CFPropertyListRef value; + const char *ret = NULL; + + value = [self prefs_get:key]; + + if (value != NULL && CFGetTypeID (value) == CFStringGetTypeID ()) { + NSString *s = (NSString *) value; + + ret = [s UTF8String]; + } + + if (value != NULL) CFRelease (value); + + return ret != NULL ? ret : def; +} + +- (float) prefs_get_float:(NSString *)key default:(float)def { + CFPropertyListRef value; + float ret = def; + + value = [self prefs_get:key]; + + if (value != NULL + && CFGetTypeID (value) == CFNumberGetTypeID () + && CFNumberIsFloatType (value)) + CFNumberGetValue (value, kCFNumberFloatType, &ret); + else if (value != NULL && CFGetTypeID (value) == CFStringGetTypeID ()) + ret = CFStringGetDoubleValue (value); + + if (value != NULL) CFRelease (value); + + return ret; +} + +- (int) prefs_get_boolean:(NSString *)key default:(int)def { + CFPropertyListRef value; + int ret = def; + + value = [self prefs_get:key]; + + if (value != NULL) { + if (CFGetTypeID (value) == CFNumberGetTypeID ()) + CFNumberGetValue (value, kCFNumberIntType, &ret); + else if (CFGetTypeID (value) == CFBooleanGetTypeID ()) + ret = CFBooleanGetValue (value); + else if (CFGetTypeID (value) == CFStringGetTypeID ()) { + const char *tem = [(NSString *) value lossyCString]; + if (strcasecmp (tem, "true") == 0 || strcasecmp (tem, "yes") == 0) + ret = YES; + else + ret = NO; + } + + CFRelease (value); + } + return ret; +} + +- (NSArray *) prefs_get_array:(NSString *)key { + NSArray *ret = nil; + CFPropertyListRef value; + + value = [self prefs_get:key]; + + if (value != NULL) { + if (CFGetTypeID (value) == CFArrayGetTypeID ()) + ret = [cfarray_to_nsarray (value) autorelease]; + + CFRelease (value); + } + + return ret; +} + +- (void) prefs_set_integer:(NSString *)key value:(int)value { + CFNumberRef x; + + x = CFNumberCreate (NULL, kCFNumberIntType, &value); + + CFPreferencesSetValue ((CFStringRef) key, (CFTypeRef) x, CFSTR (APP_PREFS), + kCFPreferencesCurrentUser, kCFPreferencesAnyHost); + + CFRelease (x); +} + +- (void) prefs_set_float:(NSString *)key value:(float)value { + CFNumberRef x; + + x = CFNumberCreate (NULL, kCFNumberFloatType, &value); + + CFPreferencesSetValue ((CFStringRef) key, (CFTypeRef) x, CFSTR (APP_PREFS), + kCFPreferencesCurrentUser, kCFPreferencesAnyHost); + + CFRelease (x); +} + +- (void) prefs_set_boolean:(NSString *)key value:(int)value { + CFPreferencesSetValue ((CFStringRef) key, + (CFTypeRef) value ? kCFBooleanTrue + : kCFBooleanFalse, CFSTR (APP_PREFS), + kCFPreferencesCurrentUser, kCFPreferencesAnyHost); + +} + +- (void) prefs_set_array:(NSString *)key value:(NSArray *)value { + CFArrayRef cfarray; + + cfarray = nsarray_to_cfarray (value); + CFPreferencesSetValue ((CFStringRef) key, + (CFTypeRef) cfarray, + CFSTR (APP_PREFS), + kCFPreferencesCurrentUser, kCFPreferencesAnyHost); + CFRelease (cfarray); +} + +- (void) prefs_set_string:(NSString *)key value:(NSString *)value { + CFPreferencesSetValue ((CFStringRef) key, (CFTypeRef) value, + CFSTR (APP_PREFS), kCFPreferencesCurrentUser, + kCFPreferencesAnyHost); +} + +- (void) prefs_synchronize { + CFPreferencesAppSynchronize (kCFPreferencesCurrentApplication); +} + +- (void) read_defaults { + const char *tem; + + quartzUseSysBeep = [self prefs_get_boolean:@PREFS_SYSBEEP + default:quartzUseSysBeep]; + quartzEnableRootless = [self prefs_get_boolean:@PREFS_ROOTLESS + default:quartzEnableRootless]; +#ifdef DARWIN_DDX_MISSING + quartzFullscreenDisableHotkeys = ![self prefs_get_boolean: + @PREFS_FULLSCREEN_HOTKEYS default: + !quartzFullscreenDisableHotkeys]; + quartzXpluginOptions = [self prefs_get_integer:@PREFS_XP_OPTIONS + default:quartzXpluginOptions]; +#endif + + darwinSwapAltMeta = [self prefs_get_boolean:@PREFS_SWAP_ALT_META + default:darwinSwapAltMeta]; + darwinFakeButtons = [self prefs_get_boolean:@PREFS_FAKEBUTTONS + default:darwinFakeButtons]; + if (darwinFakeButtons) { + const char *fake2, *fake3; + + fake2 = [self prefs_get_string:@PREFS_FAKE_BUTTON2 default:NULL]; + fake3 = [self prefs_get_string:@PREFS_FAKE_BUTTON3 default:NULL]; + + if (fake2 != NULL) darwinFakeMouse2Mask = DarwinParseModifierList(fake2); + if (fake3 != NULL) darwinFakeMouse3Mask = DarwinParseModifierList(fake3); + + } + + X11EnableKeyEquivalents = [self prefs_get_boolean:@PREFS_KEYEQUIVS + default:X11EnableKeyEquivalents]; + + darwinSyncKeymap = [self prefs_get_boolean:@PREFS_SYNC_KEYMAP + default:darwinSyncKeymap]; + + tem = [self prefs_get_string:@PREFS_KEYMAP_FILE default:NULL]; + + if (tem != NULL) darwinKeymapFile = strdup (tem); + else darwinKeymapFile = NULL; + + darwinDesiredDepth = [self prefs_get_integer:@PREFS_DEPTH + default:darwinDesiredDepth]; + + enable_stereo = [self prefs_get_boolean:@PREFS_ENABLE_STEREO + default:false]; +} + +/* This will end up at the end of the responder chain. */ +- (void) copy:sender { + QuartzMessageServerThread (kXDarwinPasteboardNotify, 1, + AppleWMCopyToPasteboard); +} + +- (BOOL) x_active { + return _x_active; +} + +@end + +static NSArray * +array_with_strings_and_numbers (int nitems, const char **items, + const char *numbers) { + NSMutableArray *array, *subarray; + NSString *string, *number; + int i; + + /* (Can't autorelease on the X server thread) */ + + array = [[NSMutableArray alloc] initWithCapacity:nitems]; + + for (i = 0; i < nitems; i++) { + subarray = [[NSMutableArray alloc] initWithCapacity:2]; + + string = [[NSString alloc] initWithUTF8String:items[i]]; + [subarray addObject:string]; + [string release]; + + if (numbers[i] != 0) { + number = [[NSString alloc] initWithFormat:@"%d", numbers[i]]; + [subarray addObject:number]; + [number release]; + } else + [subarray addObject:@""]; + + [array addObject:subarray]; + [subarray release]; + } + + return array; +} + +void X11ApplicationSetWindowMenu (int nitems, const char **items, + const char *shortcuts) { + NSArray *array; + array = array_with_strings_and_numbers (nitems, items, shortcuts); + + /* Send the array of strings over to the appkit thread */ + + message_kit_thread (@selector (set_window_menu:), array); + [array release]; +} + +void X11ApplicationSetWindowMenuCheck (int idx) { + NSNumber *n; + + n = [[NSNumber alloc] initWithInt:idx]; + + message_kit_thread (@selector (set_window_menu_check:), n); + + [n release]; +} + +void X11ApplicationSetFrontProcess (void) { + message_kit_thread (@selector (set_front_process:), nil); +} + +void X11ApplicationSetCanQuit (int state) { + NSNumber *n; + + n = [[NSNumber alloc] initWithBool:state]; + + message_kit_thread (@selector (set_can_quit:), n); + + [n release]; +} + +void X11ApplicationServerReady (void) { + message_kit_thread (@selector (server_ready:), nil); +} + +void X11ApplicationShowHideMenubar (int state) { + NSNumber *n; + + n = [[NSNumber alloc] initWithBool:state]; + + message_kit_thread (@selector (show_hide_menubar:), n); + + [n release]; +} + +static void * create_thread (void *func, void *arg) { + pthread_attr_t attr; + pthread_t tid; + + pthread_attr_init (&attr); + pthread_attr_setscope (&attr, PTHREAD_SCOPE_SYSTEM); + pthread_attr_setdetachstate (&attr, PTHREAD_CREATE_DETACHED); + pthread_create (&tid, &attr, func, arg); + pthread_attr_destroy (&attr); + + return (void *) tid; +} + +static void check_xinitrc (void) { + char *tem, buf[1024]; + NSString *msg; + + if ([X11App prefs_get_boolean:@PREFS_DONE_XINIT_CHECK default:NO]) + return; + + tem = getenv ("HOME"); + if (tem == NULL) goto done; + + snprintf (buf, sizeof (buf), "%s/.xinitrc", tem); + if (access (buf, F_OK) != 0) + goto done; + + /* FIXME: put localized strings into Resources/English.lproj */ + + msg = NSLocalizedString (@"You have an existing ~/.xinitrc file.\n\n\ +Windows displayed by X11 applications may not have titlebars, or may look \ +different to windows displayed by native applications.\n\n\ +Would you like to move aside the existing file and use the standard X11 \ +environment?", @"Startup xinitrc dialog"); + + if (NSRunAlertPanel (nil, msg, NSLocalizedString (@"Yes", @""), + NSLocalizedString (@"No", @""), nil) + == NSAlertDefaultReturn) { + char buf2[1024]; + int i = -1; + + snprintf (buf2, sizeof (buf2), "%s.old", buf); + + for (i = 1; access (buf2, F_OK) == 0; i++) + snprintf (buf2, sizeof (buf2), "%s.old.%d", buf, i); + + rename (buf, buf2); + } + + done: + [X11App prefs_set_boolean:@PREFS_DONE_XINIT_CHECK value:YES]; + [X11App prefs_synchronize]; +} + +void X11ApplicationMain (int argc, const char *argv[], + void (*server_thread) (void *), void *server_arg) { + NSAutoreleasePool *pool; + +#ifdef DEBUG + while (access ("/tmp/x11-block", F_OK) == 0) sleep (1); +#endif + + pool = [[NSAutoreleasePool alloc] init]; + + X11App = (X11Application *) [X11Application sharedApplication]; + + init_ports (); + + [NSApp read_defaults]; + + [NSBundle loadNibNamed:@"main" owner:NSApp]; + + [[NSNotificationCenter defaultCenter] addObserver:NSApp + selector:@selector (became_key:) + name:NSWindowDidBecomeKeyNotification object:nil]; + + check_xinitrc (); + + /* + * The xpr Quartz mode is statically linked into this server. + * Initialize all the Quartz functions. + */ + QuartzModeBundleInit(); + + /* Calculate the height of the menubar so we can avoid it. */ + aquaMenuBarHeight = NSHeight([[NSScreen mainScreen] frame]) - + NSMaxY([[NSScreen mainScreen] visibleFrame]) - 1; + + if (!create_thread (server_thread, server_arg)) { + ErrorF("can't create secondary thread\n"); + exit(1); + } + + [NSApp run]; +} + + +/* event conversion */ + +static inline unsigned short +convert_flags (unsigned int nsflags) { + unsigned int xflags = 0; + + if (nsflags == ~0) return 0xffff; + + if (nsflags & NSAlphaShiftKeyMask) xflags |= LockMask; + if (nsflags & NSShiftKeyMask) xflags |= ShiftMask; + if (nsflags & NSControlKeyMask) xflags |= ControlMask; + if (nsflags & NSAlternateKeyMask) xflags |= Mod1Mask; + if (nsflags & NSCommandKeyMask) xflags |= Mod2Mask; + /* FIXME: secondaryfn? */ + + return xflags; +} + +/* Sends a null byte down darwinEventWriteFD, which will cause the + Dispatch() event loop to check out event queue */ +void DarwinPokeEQ(void) { + char nullbyte=0; + input_check_flag++; + // bushing: oh, i ... er ... christ. + write(darwinEventWriteFD, &nullbyte, 1); +} + +void DarwinSendPointerEvents(int ev_type, int ev_button, int pointer_x, int pointer_y) { + int i; + int valuators[2] = {pointer_x, pointer_y}; + int num_events = GetPointerEvents(darwinEvents, darwinPointer, ev_type, ev_button, + POINTER_ABSOLUTE, 0, 2, valuators); + + for(i=0; i 0.0f ? 4 : 5; + int valuators[2] = {pointer_x, pointer_y}; + + for (count = fabs(count); count > 0.0; count = count - 1.0f) { + int num_events = GetPointerEvents(darwinEvents, darwinPointer, ButtonPress, ev_button, + POINTER_ABSOLUTE, 0, 2, valuators); + for(i=0; iIsX11Window([e window], [e windowNumber])) { + fprintf(stderr, "Dropping event because it's not a window\n"); + break; + } + button_state |= (1 << ev_button); + DarwinSendPointerEvents(ev_type, ev_button, pointer_x, pointer_y); + } else if (ev_type==ButtonRelease && (button_state & (1 << ev_button)) == 0) break; + */ + DarwinSendPointerEvents(ev_type, ev_button, pointer_x, pointer_y); + break; + case NSScrollWheel: + DarwinSendScrollEvents([e deltaY], pointer_x, pointer_y); + break; + + case NSKeyDown: // do we need to translate these keyCodes? + case NSKeyUp: + DarwinSendKeyboardEvents((type == NSKeyDown)?KeyPress:KeyRelease, [e keyCode]); + break; + + case NSFlagsChanged: + bzero(&xe, sizeof(xe)); + xe.u.u.type = kXDarwinUpdateModifiers; + xe.u.clientMessage.u.l.longs0 = [e modifierFlags]; + DarwinEQEnqueue (&xe); + DarwinPokeEQ(); + break; + default: break; /* for gcc */ + } +} diff --git a/hw/darwin/apple/X11Controller.h b/hw/darwin/apple/X11Controller.h new file mode 100644 index 000000000..954d0abb9 --- /dev/null +++ b/hw/darwin/apple/X11Controller.h @@ -0,0 +1,86 @@ +/* X11Controller.h -- connect the IB ui + $Id: X11Controller.h,v 1.21 2003/07/24 17:52:29 jharper Exp $ + + Copyright (c) 2002 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. */ + +#ifndef X11CONTROLLER_H +#define X11CONTROLLER_H 1 + +#if __OBJC__ + +#import +#include "../quartz/xpr/x-list.h" + +@interface X11Controller : NSObject +{ + NSPanel *prefs_panel; + + NSButton *fake_buttons; + NSButton *enable_fullscreen; + NSButton *use_sysbeep; + NSButton *enable_keyequivs; + NSButton *sync_keymap; + NSButton *enable_auth; + NSButton *enable_tcp; + NSPopUpButton *depth; + + NSMenuItem *x11_about_item; + NSMenuItem *window_separator; + NSMenuItem *dock_window_separator; + NSMenuItem *apps_separator; + NSMenuItem *toggle_fullscreen_item; + NSMenu *dock_apps_menu; + NSTableView *apps_table; + + NSArray *apps; + NSMutableArray *table_apps; + + NSMenu *dock_menu; + + int checked_window_item; + x_list *pending_apps; + + BOOL finished_launching; + BOOL can_quit; +} + +- (void) set_window_menu:(NSArray *)list; +- (void) set_window_menu_check:(NSNumber *)n; +- (void) set_apps_menu:(NSArray *)list; +- (void) set_can_quit:(BOOL)state; +- (void) server_ready; + +@end + +#endif /* __OBJC__ */ + +extern void X11ControllerMain (int argc, const char *argv[], + void (*server_thread) (void *), + void *server_arg); + +#endif /* X11CONTROLLER_H */ diff --git a/hw/darwin/apple/X11Controller.m b/hw/darwin/apple/X11Controller.m new file mode 100644 index 000000000..3dc965b69 --- /dev/null +++ b/hw/darwin/apple/X11Controller.m @@ -0,0 +1,752 @@ +/* X11Controller.m -- connect the IB ui, also the NSApp delegate + $Id: X11Controller.m,v 1.40 2006/09/06 21:19:32 jharper Exp $ + + Copyright (c) 2002-2007 Apple 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. */ + +#define DEFAULT_PATH "/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/X11/bin" + +#include "../quartz/quartzCommon.h" + +#import "X11Controller.h" +#import "X11Application.h" +#import + +/* ouch! */ +#define BOOL X_BOOL +//# include "Xproto.h" +#include "opaque.h" +# include "darwin.h" +# include "../quartz/quartz.h" +# define _APPLEWM_SERVER_ +# include "X11/extensions/applewm.h" +# include "../quartz/applewmExt.h" +//# include "X.h" +#undef BOOL + +#include +#include +#include +#include +#include + +#define TRACE() fprintf (stderr, "%s\n", __FUNCTION__) + +@implementation X11Controller + +- (void) awakeFromNib +{ + X11Application *xapp = NSApp; + NSArray *array; + + /* Point X11Application at ourself. */ + [xapp set_controller:self]; + + array = [xapp prefs_get_array:@PREFS_APPSMENU]; + if (array != nil) + { + int count; + + /* convert from [TITLE1 COMMAND1 TITLE2 COMMAND2 ...] + to [[TITLE1 COMMAND1] [TITLE2 COMMAND2] ...] format. */ + + count = [array count]; + if (count > 0 + && ![[array objectAtIndex:0] isKindOfClass:[NSArray class]]) + { + int i; + NSMutableArray *copy, *sub; + + copy = [NSMutableArray arrayWithCapacity:(count / 2)]; + + for (i = 0; i < count / 2; i++) + { + sub = [[NSMutableArray alloc] initWithCapacity:3]; + [sub addObject:[array objectAtIndex:i*2]]; + [sub addObject:[array objectAtIndex:i*2+1]]; + [sub addObject:@""]; + [copy addObject:sub]; + [sub release]; + } + + array = copy; + } + + [self set_apps_menu:array]; + } +} + +- (void) item_selected:sender +{ + [NSApp activateIgnoringOtherApps:YES]; + + QuartzMessageServerThread (kXDarwinControllerNotify, 2, + AppleWMWindowMenuItem, [sender tag]); +} + +- (void) remove_window_menu +{ + NSMenu *menu; + int first, count, i; + + /* Work backwards so we don't mess up the indices */ + menu = [window_separator menu]; + first = [menu indexOfItem:window_separator] + 1; + count = [menu numberOfItems]; + for (i = count - 1; i >= first; i--) + [menu removeItemAtIndex:i]; + + menu = [dock_window_separator menu]; + count = [menu indexOfItem:dock_window_separator]; + for (i = 0; i < count; i++) + [dock_menu removeItemAtIndex:0]; +} + +- (void) install_window_menu:(NSArray *)list +{ + NSMenu *menu; + NSMenuItem *item; + int first, count, i; + + menu = [window_separator menu]; + first = [menu indexOfItem:window_separator] + 1; + count = [list count]; + for (i = 0; i < count; i++) + { + NSString *name, *shortcut; + + name = [[list objectAtIndex:i] objectAtIndex:0]; + shortcut = [[list objectAtIndex:i] objectAtIndex:1]; + + item = (NSMenuItem *) [menu addItemWithTitle:name action:@selector + (item_selected:) keyEquivalent:shortcut]; + [item setTarget:self]; + [item setTag:i]; + [item setEnabled:YES]; + + item = (NSMenuItem *) [dock_menu insertItemWithTitle:name + action:@selector + (item_selected:) keyEquivalent:shortcut + atIndex:i]; + [item setTarget:self]; + [item setTag:i]; + [item setEnabled:YES]; + } + + if (checked_window_item >= 0 && checked_window_item < count) + { + item = (NSMenuItem *) [menu itemAtIndex:first + checked_window_item]; + [item setState:NSOnState]; + item = (NSMenuItem *) [dock_menu itemAtIndex:checked_window_item]; + [item setState:NSOnState]; + } +} + +- (void) remove_apps_menu +{ + NSMenu *menu; + NSMenuItem *item; + int i; + + if (apps == nil || apps_separator == nil) return; + + menu = [apps_separator menu]; + + if (menu != nil) + { + for (i = [menu numberOfItems] - 1; i >= 0; i--) + { + item = (NSMenuItem *) [menu itemAtIndex:i]; + if ([item tag] != 0) + [menu removeItemAtIndex:i]; + } + } + + if (dock_apps_menu != nil) + { + for (i = [dock_apps_menu numberOfItems] - 1; i >= 0; i--) + { + item = (NSMenuItem *) [dock_apps_menu itemAtIndex:i]; + if ([item tag] != 0) + [dock_apps_menu removeItemAtIndex:i]; + } + } + + [apps release]; + apps = nil; +} + +- (void) prepend_apps_item:(NSArray *)list index:(int)i menu:(NSMenu *)menu +{ + NSString *title, *shortcut = @""; + NSArray *group; + NSMenuItem *item; + + group = [list objectAtIndex:i]; + title = [group objectAtIndex:0]; + if ([group count] >= 3) + shortcut = [group objectAtIndex:2]; + + if ([title length] != 0) + { + item = (NSMenuItem *) [menu insertItemWithTitle:title + action:@selector (app_selected:) + keyEquivalent:shortcut atIndex:0]; + [item setTarget:self]; + [item setEnabled:YES]; + } + else + { + item = (NSMenuItem *) [NSMenuItem separatorItem]; + [menu insertItem:item atIndex:0]; + } + + [item setTag:i+1]; /* can't be zero, so add one */ +} + +- (void) install_apps_menu:(NSArray *)list +{ + NSMenu *menu; + int i, count; + + count = [list count]; + + if (count == 0 || apps_separator == nil) return; + + menu = [apps_separator menu]; + + for (i = count - 1; i >= 0; i--) + { + if (menu != nil) + [self prepend_apps_item:list index:i menu:menu]; + if (dock_apps_menu != nil) + [self prepend_apps_item:list index:i menu:dock_apps_menu]; + } + + apps = [list retain]; +} + +- (void) set_window_menu:(NSArray *)list +{ + [self remove_window_menu]; + [self install_window_menu:list]; + + QuartzMessageServerThread (kXDarwinControllerNotify, 1, + AppleWMWindowMenuNotify); +} + +- (void) set_window_menu_check:(NSNumber *)nn +{ + NSMenu *menu; + NSMenuItem *item; + int first, count; + int n = [nn intValue]; + + menu = [window_separator menu]; + first = [menu indexOfItem:window_separator] + 1; + count = [menu numberOfItems] - first; + + if (checked_window_item >= 0 && checked_window_item < count) + { + item = (NSMenuItem *) [menu itemAtIndex:first + checked_window_item]; + [item setState:NSOffState]; + item = (NSMenuItem *) [dock_menu itemAtIndex:checked_window_item]; + [item setState:NSOffState]; + } + if (n >= 0 && n < count) + { + item = (NSMenuItem *) [menu itemAtIndex:first + n]; + [item setState:NSOnState]; + item = (NSMenuItem *) [dock_menu itemAtIndex:n]; + [item setState:NSOnState]; + } + checked_window_item = n; +} + +- (void) set_apps_menu:(NSArray *)list +{ + [self remove_apps_menu]; + [self install_apps_menu:list]; +} + +- (void) launch_client:(NSString *)filename +{ + const char *command = [filename UTF8String]; + const char *shell; + const char *argv[5]; + int child1, child2 = 0; + int status; + + shell = getenv("SHELL"); + if (shell == NULL) shell = "/bin/bash"; + + argv[0] = shell; + argv[1] = "-l"; + argv[2] = "-c"; + argv[3] = command; + argv[4] = NULL; + + /* Do the fork-twice trick to avoid having to reap zombies */ + + child1 = fork(); + + switch (child1) { + case -1: /* error */ + break; + + case 0: /* child1 */ + child2 = fork(); + + switch (child2) { + int max_files, i; + char buf[1024], *temp; + + case -1: /* error */ + _exit(1); + + case 0: /* child2 */ + /* close all open files except for standard streams */ + max_files = sysconf(_SC_OPEN_MAX); + for (i = 3; i < max_files; i++) close(i); + + /* ensure stdin is on /dev/null */ + close(0); + open("/dev/null", O_RDONLY); + + /* Setup environment */ + temp = getenv("DISPLAY"); + if (temp == NULL || temp[0] == 0) { + snprintf(buf, sizeof(buf), ":%s", display); + setenv("DISPLAY", buf, TRUE); + } + + temp = getenv("PATH"); + if (temp == NULL || temp[0] == 0) + setenv ("PATH", DEFAULT_PATH, TRUE); + else if (strnstr(temp, "/usr/X11/bin", sizeof(temp)) == NULL) { + snprintf(buf, sizeof(buf), "%s:/usr/X11/bin", temp); + setenv("PATH", buf, TRUE); + } + /* cd $HOME */ + temp = getenv("HOME"); + if (temp != NULL && temp[0]!=0) chdir(temp); + + execvp(argv[0], (char **const) argv); + + _exit(2); + + default: /* parent (child1) */ + _exit(0); + } + break; + + default: /* parent */ + waitpid(child1, &status, 0); + } +} + +- (void) app_selected:sender +{ + int tag; + NSString *item; + + tag = [sender tag] - 1; + if (apps == nil || tag < 0 || tag >= [apps count]) + return; + + item = [[apps objectAtIndex:tag] objectAtIndex:1]; + + [self launch_client:item]; +} + +- (IBAction) apps_table_show:sender +{ + NSArray *columns; + + if (table_apps == nil) { + table_apps = [[NSMutableArray alloc] initWithCapacity:1]; + + if (apps != nil)[table_apps addObjectsFromArray:apps]; + } + + columns = [apps_table tableColumns]; + [[columns objectAtIndex:0] setIdentifier:@"0"]; + [[columns objectAtIndex:1] setIdentifier:@"1"]; + [[columns objectAtIndex:2] setIdentifier:@"2"]; + + [apps_table setDataSource:self]; + [apps_table selectRow:0 byExtendingSelection:NO]; + + [[apps_table window] makeKeyAndOrderFront:sender]; +} + +- (IBAction) apps_table_cancel:sender +{ + [[apps_table window] orderOut:sender]; + [apps_table reloadData]; + + [table_apps release]; + table_apps = nil; +} + +- (IBAction) apps_table_done:sender +{ + [apps_table deselectAll:sender]; /* flush edits? */ + + [self remove_apps_menu]; + [self install_apps_menu:table_apps]; + + [NSApp prefs_set_array:@PREFS_APPSMENU value:table_apps]; + [NSApp prefs_synchronize]; + + [[apps_table window] orderOut:sender]; + + [table_apps release]; + table_apps = nil; +} + +- (IBAction) apps_table_new:sender +{ + NSMutableArray *item; + + int row = [apps_table selectedRow], i; + + if (row < 0) row = 0; + else row = row + 1; + + i = row; + if (i > [table_apps count]) + return; /* avoid exceptions */ + + [apps_table deselectAll:sender]; + + item = [[NSMutableArray alloc] initWithCapacity:3]; + [item addObject:@""]; + [item addObject:@""]; + [item addObject:@""]; + + [table_apps insertObject:item atIndex:i]; + [item release]; + + [apps_table reloadData]; + [apps_table selectRow:row byExtendingSelection:NO]; +} + +- (IBAction) apps_table_duplicate:sender +{ + int row = [apps_table selectedRow], i; + NSObject *item; + + if (row < 0) { + [self apps_table_new:sender]; + return; + } + + i = row; + if (i > [table_apps count] - 1) return; /* avoid exceptions */ + + [apps_table deselectAll:sender]; + + item = [[table_apps objectAtIndex:i] mutableCopy]; + [table_apps insertObject:item atIndex:i]; + [item release]; + + [apps_table reloadData]; + [apps_table selectRow:row+1 byExtendingSelection:NO]; +} + +- (IBAction) apps_table_delete:sender +{ + int row = [apps_table selectedRow]; + + if (row >= 0) + { + int i = row; + + if (i > [table_apps count] - 1) return; /* avoid exceptions */ + + [apps_table deselectAll:sender]; + + [table_apps removeObjectAtIndex:i]; + } + + [apps_table reloadData]; + + row = MIN (row, [table_apps count] - 1); + if (row >= 0) + [apps_table selectRow:row byExtendingSelection:NO]; +} + +- (int) numberOfRowsInTableView:(NSTableView *)tableView +{ + if (table_apps == nil) return 0; + + return [table_apps count]; +} + +- (id) tableView:(NSTableView *)tableView +objectValueForTableColumn:(NSTableColumn *)tableColumn row:(int)row +{ + NSArray *item; + int col; + + if (table_apps == nil) return nil; + + col = [[tableColumn identifier] intValue]; + + item = [table_apps objectAtIndex:row]; + if ([item count] > col) + return [item objectAtIndex:col]; + else + return @""; +} + +- (void) tableView:(NSTableView *)tableView setObjectValue:(id)object + forTableColumn:(NSTableColumn *)tableColumn row:(int)row +{ + NSMutableArray *item; + int col; + + if (table_apps == nil) return; + + col = [[tableColumn identifier] intValue]; + + item = [table_apps objectAtIndex:row]; + [item replaceObjectAtIndex:col withObject:object]; +} + +- (void) hide_window:sender +{ + if ([X11App x_active]) + QuartzMessageServerThread (kXDarwinControllerNotify, 1, AppleWMHideWindow); + else + NSBeep (); /* FIXME: something here */ +} + +- (IBAction)bring_to_front:sender +{ + QuartzMessageServerThread(kXDarwinControllerNotify, 1, AppleWMBringAllToFront); +} + +- (IBAction)close_window:sender +{ + if ([X11App x_active]) + QuartzMessageServerThread (kXDarwinControllerNotify, 1, AppleWMCloseWindow); + else + [[NSApp keyWindow] performClose:sender]; +} + +- (IBAction)minimize_window:sender +{ + if ([X11App x_active]) + QuartzMessageServerThread (kXDarwinControllerNotify, 1, AppleWMMinimizeWindow); + else + [[NSApp keyWindow] performMiniaturize:sender]; +} + +- (IBAction)zoom_window:sender +{ + if ([X11App x_active]) + QuartzMessageServerThread (kXDarwinControllerNotify, 1, AppleWMZoomWindow); + else + [[NSApp keyWindow] performZoom:sender]; +} + +- (IBAction) next_window:sender +{ + QuartzMessageServerThread (kXDarwinControllerNotify, 1, AppleWMNextWindow); +} + +- (IBAction) previous_window:sender +{ + QuartzMessageServerThread (kXDarwinControllerNotify, 1, AppleWMPreviousWindow); +} + +- (IBAction) enable_fullscreen_changed:sender +{ + int value = ![enable_fullscreen intValue]; + +#ifdef DARWIN_DDX_MISSING + QuartzMessageServerThread (kXDarwinSetRootless, 1, value); +#endif + + [NSApp prefs_set_boolean:@PREFS_ROOTLESS value:value]; + [NSApp prefs_synchronize]; +} + +- (IBAction) toggle_fullscreen:sender +{ +#ifdef DARWIN_DDX_MISSING + QuartzMessageServerThread (kXDarwinToggleFullscreen, 0); +#endif +} + +- (void) set_can_quit:(BOOL)state +{ + can_quit = state; +} + +- (IBAction)prefs_changed:sender +{ + darwinFakeButtons = [fake_buttons intValue]; + quartzUseSysBeep = [use_sysbeep intValue]; + X11EnableKeyEquivalents = [enable_keyequivs intValue]; + darwinSyncKeymap = [sync_keymap intValue]; + + /* after adding prefs here, also add to [X11Application read_defaults] + and below */ + + [NSApp prefs_set_boolean:@PREFS_FAKEBUTTONS value:darwinFakeButtons]; + [NSApp prefs_set_boolean:@PREFS_SYSBEEP value:quartzUseSysBeep]; + [NSApp prefs_set_boolean:@PREFS_KEYEQUIVS value:X11EnableKeyEquivalents]; + [NSApp prefs_set_boolean:@PREFS_SYNC_KEYMAP value:darwinSyncKeymap]; + [NSApp prefs_set_boolean:@PREFS_NO_AUTH value:![enable_auth intValue]]; + [NSApp prefs_set_boolean:@PREFS_NO_TCP value:![enable_tcp intValue]]; + [NSApp prefs_set_integer:@PREFS_DEPTH value:[depth selectedTag]]; + + [NSApp prefs_synchronize]; +} + +- (IBAction) prefs_show:sender +{ + [fake_buttons setIntValue:darwinFakeButtons]; + [use_sysbeep setIntValue:quartzUseSysBeep]; + [enable_keyequivs setIntValue:X11EnableKeyEquivalents]; + [sync_keymap setIntValue:darwinSyncKeymap]; + [sync_keymap setEnabled:darwinKeymapFile == NULL]; + + [enable_auth setIntValue:![NSApp prefs_get_boolean:@PREFS_NO_AUTH default:NO]]; + [enable_tcp setIntValue:![NSApp prefs_get_boolean:@PREFS_NO_TCP default:NO]]; + [depth selectItemAtIndex:[depth indexOfItemWithTag:[NSApp prefs_get_integer:@PREFS_DEPTH default:-1]]]; + + [enable_fullscreen setIntValue:!quartzEnableRootless]; + + [prefs_panel makeKeyAndOrderFront:sender]; +} + +- (IBAction) quit:sender +{ + QuartzMessageServerThread (kXDarwinQuit, 0); +} + +- (IBAction) x11_help:sender +{ + AHLookupAnchor (CFSTR ("Mac Help"), CFSTR ("mchlp2276")); +} + +- (BOOL) validateMenuItem:(NSMenuItem *)item +{ + NSMenu *menu = [item menu]; + + if (item == toggle_fullscreen_item) + return !quartzEnableRootless; + else if (menu == [window_separator menu] || menu == dock_menu + || (menu == [x11_about_item menu] && [item tag] == 42)) + return (AppleWMSelectedEvents () & AppleWMControllerNotifyMask) != 0; + else + return TRUE; +} + +- (void) applicationDidHide:(NSNotification *)notify +{ + QuartzMessageServerThread (kXDarwinControllerNotify, 1, AppleWMHideAll); +} + +- (void) applicationDidUnhide:(NSNotification *)notify +{ + QuartzMessageServerThread (kXDarwinControllerNotify, 1, AppleWMShowAll); +} + +- (NSApplicationTerminateReply) applicationShouldTerminate:sender +{ + NSString *msg; + + if (can_quit || [X11App prefs_get_boolean:@PREFS_NO_QUIT_ALERT default:NO]) + return NSTerminateNow; + + /* Make sure we're frontmost. */ + [NSApp activateIgnoringOtherApps:YES]; + + msg = NSLocalizedString (@"Are you sure you want to quit X11?\n\nIf you quit X11, any X11 applications you are running will stop immediately and you will lose any changes you have not saved.", @"Dialog when quitting"); + + /* FIXME: safe to run the alert in here? Or should we return Later + and then run the alert on a timer? It seems to work here, so.. */ + + return (NSRunAlertPanel (nil, msg, NSLocalizedString (@"Quit", @""), + NSLocalizedString (@"Cancel", @""), nil) + == NSAlertDefaultReturn) ? NSTerminateNow : NSTerminateCancel; +} + +- (void) applicationWillTerminate:(NSNotification *)aNotification +{ + [X11App prefs_synchronize]; + + /* shutdown the X server, it will exit () for us. */ + QuartzMessageServerThread (kXDarwinQuit, 0); + + /* In case it doesn't, exit anyway after a while. */ + while (sleep (10) != 0) ; + exit (1); +} + +- (void) server_ready +{ + x_list *node; + + finished_launching = YES; + + for (node = pending_apps; node != NULL; node = node->next) + { + NSString *filename = node->data; + [self launch_client:filename]; + [filename release]; + } + + x_list_free (pending_apps); + pending_apps = NULL; +} + +- (BOOL) application:(NSApplication *)app openFile:(NSString *)filename +{ + const char *name = [filename UTF8String]; + + if (finished_launching) + [self launch_client:filename]; + else if (name[0] != ':') /* ignore display names */ + pending_apps = x_list_prepend (pending_apps, [filename retain]); + + /* FIXME: report failures. */ + return YES; +} + +@end + +void X11ControllerMain (int argc, const char *argv[], + void (*server_thread) (void *), void *server_arg) +{ + X11ApplicationMain (argc, argv, server_thread, server_arg); +} diff --git a/hw/darwin/apple/Xquartz.man b/hw/darwin/apple/Xquartz.man new file mode 100644 index 000000000..edac30ee9 --- /dev/null +++ b/hw/darwin/apple/Xquartz.man @@ -0,0 +1,158 @@ +.\" $XFree86: xc/programs/Xserver/hw/darwin/XDarwin.man,v 1.4 2002/01/09 18:01:58 torrey Exp $ +.\" +.TH XQUARTZ 1 __vendorversion__ +.SH NAME +Xquartz \- X window system server for Quartz operating system +.SH SYNOPSIS +.B Xquartz +[ options ] ... +.SH DESCRIPTION +.I Xquartz +is the X window server for Mac OS X provided by Apple. +.I Xquartz +runs in parallel with Aqua in rootless mode. In rootless mode, the X +window system and Mac OS X share your display. The root window of the +X11 display is the size of the screen and contains all the other +windows. The X11 root window is not displayed in rootless mode as Mac +OS X handles the desktop background. +.SH OPTIONS +.PP +In addition to the normal server options described in the \fIXserver(1)\fP +manual page, \fIXquartz\fP accepts the following command line switches: +.TP 8 +.B \-fakebuttons +Emulates a 3 button mouse using modifier keys. By default, the Command modifier +is used to emulate button 2 and Option is used for button 3. Thus, clicking the +first mouse button while holding down Command will act like clicking +button 2. Holding down Option will simulate button 3. +.TP 8 +.B \-nofakebuttons +Do not emulate a 3 button mouse. This is the default. +.TP 8 +.B "\-fakemouse2 \fImodifiers\fP" +Change the modifier keys used to emulate the second mouse button. By default, +Command is used to emulate the second button. Any combination of the following +modifier names may be used: Shift, Option, Control, Command, Fn. For example, +.B \-fakemouse2 """Option,Shift"" +will set holding Option, Shift and clicking on button one as equivalent to +clicking the second mouse button. +.TP 8 +.B "\-fakemouse3 \fImodifiers\fP" +Change the modifier keys used to emulate the third mouse button. By default, +Option is used to emulate the third button. Any combination of the following +modifier names may be used: Shift, Option, Control, Command, Fn. For example, +.B \-fakemouse3 """Control,Shift"" +will set holding Control, Shift and clicking on button one as equivalent to +clicking the third mouse button. +.TP 8 +.B "\-swapAltMeta" +Swaps the meaning of the Alt and Meta modifier keys. +.TP 8 +.B "\-keymap \fIfile\fP" +On startup \fIXquartz\fP translates a Darwin keymapping into an X keymap. +The default is to read this keymapping from USA.keymapping. With this option +the keymapping will be read from \fIfile\fP instead. If the file's path is +not specified, it will be searched for in Library/Keyboards/ underneath the +following directories (in order): ~, /, /Network, /System. +.TP 8 +.B \-nokeymap +On startup \fIXquartz\fP translates a Darwin keymapping into an X keymap. +With this option \fIXquartz\fP queries the kernel for the current keymapping +instead of reading it from a file. This will often fail on newer kernels. +.TP 8 +.B "\-depth \fIdepth\fP" +Specifies the color bit depth to use. Currently only 15, and 24 color +bits per pixel are supported. If not specified, defaults to the depth +of the main display. +.SH CUSTOMIZATION +\fIXquartz\fP can also be customized using the defaults(1) command. The available options are: +.TP 8 +.B defaults write com.apple.x11 enable_fake_buttons -boolean true +Equivalent to the \fB-fakebuttons\fP command line option. +.TP 8 +.B defaults write com.apple.x11 fake_button2 \fImodifiers\fP +Equivalent to the \fB-fakemouse2\fP option. +.TP 8 +.B defaults write com.apple.x11 fake_button3 \fImodifiers\fP +Equivalent to the \fB-fakemouse3\fP option. +.TP 8 +.B defaults write com.apple.x11 swap_alt_meta -boolean true +Equivalent to the \fB-swapAltMeta\fP option. +.TP 8 +.B defaults write com.apple.x11 keymap_file \fIfilename\fP +Equivalent to the \fB-keymap\fP option. +.TP 8 +.B defaults write com.apple.x11 no_quit_alert -boolean true +Disables the alert dialog displayed when attempting to quit X11. +.TP 8 +.B defaults write com.apple.x11 no_auth -boolean true +Stops the X server requiring that clients authenticate themselves when +connecting. See Xsecurity(__miscmansuffix__). +.TP 8 +.B defaults write com.apple.x11 nolisten_tcp -boolean true +Prevents the X server accepting remote connections. +.TP 8 +.B defaults write com.apple.x11 xinit_kills_server -boolean false +Stops the X server exiting when the xinitrc script terminates. +.TP 8 +.B defaults write com.apple.x11 fullscreen_hotkeys -boolean false +Allows system hotkeys to be handled while in X11 fullscreen mode. +.TP 8 +.B defaults write com.apple.x11 enable_system_beep -boolean false +Don't use the standard system beep effect for X11 alerts. +.TP 8 +.B defaults write com.apple.x11 enable_key_equivalents -boolean false +Disable menu keyboard equivalents while X11 windows are focused. +.TP 8 +.B defaults write com.apple.x11 depth \fIdepth\fP +Equivalent to the \fB-depth\fP option. +.SH "SEE ALSO" +.PP +X(__miscmansuffix__), XFree86(1), Xserver(1), xdm(1), xinit(1) +.PP +.SH AUTHORS +XFree86 was originally ported to Mac OS X Server by John Carmack. Dave +Zarzycki used this as the basis of his port of XFree86 4.0 to Darwin 1.0. +Torrey T. Lyons improved and integrated this code into the XFree86 +Project's mainline for the 4.0.2 release. +.PP +The following members of the XonX Team contributed to the following +releases (in alphabetical order): +.TP 4 +XFree86 4.1.0: +.br +Rob Braun - Darwin x86 support +.br +Torrey T. Lyons - Project Lead +.br +Andreas Monitzer - Cocoa version of XDarwin front end +.br +Gregory Robert Parker - Original Quartz implementation +.br +Christoph Pfisterer - Dynamic shared X libraries +.br +Toshimitsu Tanaka - Japanese localization +.TP 4 +XFree86 4.2.0: +.br +Rob Braun - Darwin x86 support +.br +Pablo Di Noto - Spanish localization +.br +Paul Edens - Dutch localization +.br +Kyunghwan Kim - Korean localization +.br +Mario Klebsch - Non-US keyboard support +.br +Torrey T. Lyons - Project Lead +.br +Andreas Monitzer - German localization +.br +Patrik Montgomery - Swedish localization +.br +Greg Parker - Rootless support +.br +Toshimitsu Tanaka - Japanese localization +.br +Olivier Verdier - French localization diff --git a/hw/darwin/apple/bundle-main.c b/hw/darwin/apple/bundle-main.c new file mode 100644 index 000000000..a35e1e37f --- /dev/null +++ b/hw/darwin/apple/bundle-main.c @@ -0,0 +1,912 @@ +/* bundle-main.c -- X server launcher + $Id: bundle-main.c,v 1.17 2003/09/11 00:17:10 jharper Exp $ + + Copyright (c) 2002-2007 Apple 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. + + Parts of this file are derived from xdm, which has this copyright: + + Copyright 1988, 1998 The Open Group + + Permission to use, copy, modify, distribute, and sell this software + and its documentation for any purpose is hereby granted without fee, + provided that the above copyright notice appear in all copies and + that both that copyright notice and this permission notice appear in + supporting documentation. + + 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 OPEN GROUP 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 of The Open Group shall + not be used in advertising or otherwise to promote the sale, use or + other dealings in this Software without prior written authorization + from The Open Group. */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +#include +#include + +#define X_SERVER "/usr/X11/bin/Xquartz" +#define XTERM_PATH "/usr/X11/bin/xterm" +#define WM_PATH "/usr/X11/bin/quartz-wm" +#define DEFAULT_XINITRC "/etc/X11/xinit/xinitrc" +#define DEFAULT_PATH "/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/X11/bin" + +/* what xinit does */ +#ifndef SHELL +# define SHELL "sh" +#endif + +#undef FALSE +#define FALSE 0 +#undef TRUE +#define TRUE 1 + +#define MAX_DISPLAYS 64 + +static int server_pid = -1, client_pid = -1; +static int xinit_kills_server = FALSE; +static jmp_buf exit_continuation; +static const char *server_name = NULL; +static Display *server_dpy; + +static char *auth_file; + +typedef struct addr_list_struct addr_list; + +struct addr_list_struct { + addr_list *next; + Xauth auth; +}; + +static addr_list *addresses; + + +/* Utility functions. */ + +/* Return the current host name. Matches what Xlib does. */ +static char * +host_name (void) +{ +#ifdef NEED_UTSNAME + static struct utsname name; + + uname(&name); + + return name.nodename; +#else + static char buf[100]; + + gethostname(buf, sizeof(buf)); + + return buf; +#endif +} + +static int +read_boolean_pref (CFStringRef name, int default_) +{ + int value; + Boolean ok; + + value = CFPreferencesGetAppBooleanValue (name, + CFSTR ("com.apple.x11"), &ok); + return ok ? value : default_; +} + +static inline int +binary_equal (const void *a, const void *b, int length) +{ + return memcmp (a, b, length) == 0; +} + +static inline void * +binary_dup (const void *a, int length) +{ + void *b = malloc (length); + if (b != NULL) + memcpy (b, a, length); + return b; +} + +static inline void +binary_free (void *data, int length) +{ + if (data != NULL) + free (data); +} + + +/* Functions for managing the authentication entries. */ + +/* Returns true if something matching AUTH is in our list of auth items */ +static int +check_auth_item (Xauth *auth) +{ + addr_list *a; + + for (a = addresses; a != NULL; a = a->next) + { + if (a->auth.family == auth->family + && a->auth.address_length == auth->address_length + && binary_equal (a->auth.address, auth->address, auth->address_length) + && a->auth.number_length == auth->number_length + && binary_equal (a->auth.number, auth->number, auth->number_length) + && a->auth.name_length == auth->name_length + && binary_equal (a->auth.name, auth->name, auth->name_length)) + { + return TRUE; + } + } + + return FALSE; +} + +/* Add one item to our list of auth items. */ +static void +add_auth_item (Xauth *auth) +{ + addr_list *a = malloc (sizeof (addr_list)); + + a->auth.family = auth->family; + a->auth.address_length = auth->address_length; + a->auth.address = binary_dup (auth->address, auth->address_length); + a->auth.number_length = auth->number_length; + a->auth.number = binary_dup (auth->number, auth->number_length); + a->auth.name_length = auth->name_length; + a->auth.name = binary_dup (auth->name, auth->name_length); + a->auth.data_length = auth->data_length; + a->auth.data = binary_dup (auth->data, auth->data_length); + + a->next = addresses; + addresses = a; +} + +/* Free all allocated auth items. */ +static void +free_auth_items (void) +{ + addr_list *a; + + while ((a = addresses) != NULL) + { + addresses = a->next; + + binary_free (a->auth.address, a->auth.address_length); + binary_free (a->auth.number, a->auth.number_length); + binary_free (a->auth.name, a->auth.name_length); + binary_free (a->auth.data, a->auth.data_length); + free (a); + } +} + +/* Add the unix domain auth item. */ +static void +define_local (Xauth *auth) +{ + char *host = host_name (); + +#ifdef DEBUG + fprintf (stderr, "x11: hostname is %s\n", host); +#endif + + auth->family = FamilyLocal; + auth->address_length = strlen (host); + auth->address = host; + + add_auth_item (auth); +} + +/* Add the tcp auth item. */ +static void +define_named (Xauth *auth, const char *name) +{ + struct ifaddrs *addrs, *ptr; + + if (getifaddrs (&addrs) != 0) + return; + + for (ptr = addrs; ptr != NULL; ptr = ptr->ifa_next) + { + if (ptr->ifa_addr->sa_family != AF_INET) + continue; + + auth->family = FamilyInternet; + auth->address_length = sizeof (struct in_addr); + auth->address = (char *) &(((struct sockaddr_in *) ptr->ifa_addr)->sin_addr); + +#ifdef DEBUG + fprintf (stderr, "x11: ipaddr is %d.%d.%d.%d\n", + (unsigned char) auth->address[0], + (unsigned char) auth->address[1], + (unsigned char) auth->address[2], + (unsigned char) auth->address[3]); +#endif + + add_auth_item (auth); + } + + freeifaddrs (addrs); +} + +/* Parse the display number from NAME and add it to AUTH. */ +static void +set_auth_number (Xauth *auth, const char *name) +{ + char *colon; + char *dot, *number; + + colon = strrchr(name, ':'); + if (colon != NULL) + { + colon++; + dot = strchr(colon, '.'); + + if (dot != NULL) + auth->number_length = dot - colon; + else + auth->number_length = strlen (colon); + + number = malloc (auth->number_length + 1); + if (number != NULL) + { + strncpy (number, colon, auth->number_length); + number[auth->number_length] = '\0'; + } + else + { + auth->number_length = 0; + } + + auth->number = number; + } +} + +/* Put 128 bits of random data into DATA. If possible, it will be "high + quality" */ +static int +generate_mit_magic_cookie (char data[16]) +{ + int fd, ret, i; + long *ldata = (long *) data; + + fd = open ("/dev/random", O_RDONLY); + if (fd > 0) { + ret = read (fd, data, 16); + close (fd); + if (ret == 16) return TRUE; + } + + /* fall back to the usual crappy rng */ + + srand48 (getpid () ^ time (NULL)); + + for (i = 0; i < 4; i++) + ldata[i] = lrand48 (); + + return TRUE; +} + +/* Create the keys we'll be using for the display named NAME. */ +static int +make_auth_keys (const char *name) +{ + Xauth auth; + char key[16]; + + if (auth_file == NULL) + return FALSE; + + auth.name = "MIT-MAGIC-COOKIE-1"; + auth.name_length = strlen (auth.name); + + if (!generate_mit_magic_cookie (key)) + { + auth_file = NULL; + return FALSE; + } + + auth.data = key; + auth.data_length = 16; + + set_auth_number (&auth, name); + + define_named (&auth, host_name ()); + define_local (&auth); + + free (auth.number); + + return TRUE; +} + +/* If ADD-ENTRIES is true, merge our auth entries into the existing + Xauthority file. If ADD-ENTRIES is false, remove our entries. */ +static int +write_auth_file (int add_entries) +{ + char *home, newname[1024]; + int fd, ret; + FILE *new_fh, *old_fh; + addr_list *addr; + Xauth *auth; + + if (auth_file == NULL) + return FALSE; + + home = getenv ("HOME"); + if (home == NULL) + { + auth_file = NULL; + return FALSE; + } + + snprintf (newname, sizeof (newname), "%s/.XauthorityXXXXXX", home); + mktemp (newname); + + if (XauLockAuth (auth_file, 1, 2, 10) != LOCK_SUCCESS) + { + /* FIXME: do something here? */ + + auth_file = NULL; + return FALSE; + } + + fd = open (newname, O_WRONLY | O_CREAT | O_TRUNC, 0600); + if (fd >= 0) + { + new_fh = fdopen (fd, "w"); + if (new_fh != NULL) + { + if (add_entries) + { + for (addr = addresses; addr != NULL; addr = addr->next) + { + XauWriteAuth (new_fh, &addr->auth); + } + } + + old_fh = fopen (auth_file, "r"); + if (old_fh != NULL) + { + while ((auth = XauReadAuth (old_fh)) != NULL) + { + if (!check_auth_item (auth)) + XauWriteAuth (new_fh, auth); + XauDisposeAuth (auth); + } + fclose (old_fh); + } + + fclose (new_fh); + unlink (auth_file); + + ret = rename (newname, auth_file); + + if (ret != 0) + auth_file = NULL; + + XauUnlockAuth (auth_file); + return ret == 0; + } + + close (fd); + } + + XauUnlockAuth (auth_file); + auth_file = NULL; + return FALSE; +} + + +/* Subprocess management functions. */ + +static int +start_server (char **xargv) +{ + int child; + + child = fork (); + + switch (child) + { + case -1: /* error */ + perror ("fork"); + return FALSE; + + case 0: /* child */ + execv (X_SERVER, xargv); + perror ("Couldn't exec " X_SERVER); + _exit (1); + + default: /* parent */ + server_pid = child; + return TRUE; + } +} + +static int +wait_for_server (void) +{ + int count = 100; + + while (count-- > 0) + { + int status; + + server_dpy = XOpenDisplay (server_name); + if (server_dpy != NULL) + return TRUE; + + if (waitpid (server_pid, &status, WNOHANG) == server_pid) + return FALSE; + + sleep (1); + } + + return FALSE; +} + +static int +start_client (void) +{ + int child; + + child = fork(); + + switch (child) { + char *temp, buf[1024]; + + case -1: /* error */ + perror("fork"); + return FALSE; + + case 0: /* child */ + /* Setup environment */ + temp = getenv("DISPLAY"); + if (temp != NULL && temp[0] != 0) + setenv("DISPLAY", server_name, TRUE); + + temp = getenv("PATH"); + if (temp == NULL || temp[0] == 0) + setenv ("PATH", DEFAULT_PATH, TRUE); + else if (strnstr(temp, "/usr/X11/bin", sizeof(temp)) == NULL) { + snprintf(buf, sizeof(buf), "%s:/usr/X11/bin", temp); + setenv("PATH", buf, TRUE); + } + + /* First try value of $XINITRC, if set. */ + temp = getenv("XINITRC"); + if (temp != NULL && temp[0] != 0 && access(temp, R_OK) == 0) + execlp (SHELL, SHELL, temp, NULL); + + /* Then look for .xinitrc in user's home directory. */ + temp = getenv("HOME"); + if (temp != NULL && temp[0] != 0) { + chdir(temp); + snprintf (buf, sizeof (buf), "%s/.xinitrc", temp); + if (access(buf, R_OK) == 0) + execlp(SHELL, SHELL, buf, NULL); + } + + /* Then try the default xinitrc in the lib directory. */ + + if (access(DEFAULT_XINITRC, R_OK) == 0) + execlp(SHELL, SHELL, DEFAULT_XINITRC, NULL); + + /* Then fallback to hardcoding an xterm and the window manager. */ + + // system(XTERM_PATH " &"); + execl(WM_PATH, WM_PATH, NULL); + + perror("exec"); + _exit(1); + + default: /* parent */ + client_pid = child; + return TRUE; + } +} + +static void +sigchld_handler (int sig) +{ + int pid, status; + + again: + pid = waitpid (WAIT_ANY, &status, WNOHANG); + + if (pid > 0) + { + if (pid == server_pid) + { + server_pid = -1; + + if (client_pid >= 0) + kill (client_pid, SIGTERM); + } + else if (pid == client_pid) + { + client_pid = -1; + + if (server_pid >= 0 && xinit_kills_server) + kill (server_pid, SIGTERM); + } + goto again; + } + + if (server_pid == -1 && client_pid == -1) + longjmp (exit_continuation, 1); + + signal (SIGCHLD, sigchld_handler); +} + + +/* Server utilities. */ + +static Boolean +display_exists_p (int number) +{ + char buf[64]; + void *conn; + char *fullname = NULL; + int idisplay, iscreen; + char *conn_auth_name, *conn_auth_data; + int conn_auth_namelen, conn_auth_datalen; +#ifdef USE_XTRANS_INTERNALS + extern void *_X11TransConnectDisplay (); + extern void _XDisconnectDisplay (); +#endif + /* Since connecting to the display waits for a few seconds if the + display doesn't exist, check for trivial non-existence - if the + socket in /tmp exists or not.. (note: if the socket exists, the + server may still not, so we need to try to connect in that case..) */ + + sprintf (buf, "/tmp/.X11-unix/X%d", number); + if (access (buf, F_OK) != 0) + return FALSE; +#ifdef USE_XTRANS_INTERNALS + /* This is a private function that we shouldn't really be calling, + but it's the best way to see if the server exists (without + needing to hold the necessary authentication to use it) */ + + sprintf (buf, ":%d", number); + conn = _X11TransConnectDisplay (buf, &fullname, &idisplay, &iscreen, + &conn_auth_name, &conn_auth_namelen, + &conn_auth_data, &conn_auth_datalen); + if (conn == NULL) + return FALSE; + + _XDisconnectDisplay (conn); +#endif + return TRUE; +} + + +/* Monitoring when the system's ip addresses change. */ + +static Boolean pending_timer; + +static void +timer_callback (CFRunLoopTimerRef timer, void *info) +{ + pending_timer = FALSE; + + /* Update authentication names. Need to write .Xauthority file first + without the existing entries, then again with the new entries.. */ + + write_auth_file (FALSE); + + free_auth_items (); + make_auth_keys (server_name); + + write_auth_file (TRUE); +} + +/* This function is called when the system's ip addresses may have changed. */ +static void +ipaddr_callback (SCDynamicStoreRef store, CFArrayRef changed_keys, void *info) +{ +#if DEBUG + if (changed_keys != NULL) { + fprintf (stderr, "x11: changed sc keys: "); + CFShow (changed_keys); + } +#endif + + if (auth_file != NULL && !pending_timer) + { + CFRunLoopTimerRef timer; + + timer = CFRunLoopTimerCreate (NULL, CFAbsoluteTimeGetCurrent () + 1.0, + 0.0, 0, 0, timer_callback, NULL); + CFRunLoopAddTimer (CFRunLoopGetCurrent (), timer, + kCFRunLoopDefaultMode); + CFRelease (timer); + + pending_timer = TRUE; + } +} + +/* This code adapted from "Living in a Dynamic TCP/IP Environment" technote. */ +static Boolean +install_ipaddr_source (void) +{ + CFRunLoopSourceRef source = NULL; + + SCDynamicStoreContext context = {0}; + SCDynamicStoreRef ref; + + ref = SCDynamicStoreCreate (NULL, + CFSTR ("AddIPAddressListChangeCallbackSCF"), + ipaddr_callback, &context); + + if (ref != NULL) + { + const void *keys[4], *patterns[2]; + int i; + + keys[0] = SCDynamicStoreKeyCreateNetworkGlobalEntity (NULL, kSCDynamicStoreDomainState, kSCEntNetIPv4); + keys[1] = SCDynamicStoreKeyCreateNetworkGlobalEntity (NULL, kSCDynamicStoreDomainState, kSCEntNetIPv6); + keys[2] = SCDynamicStoreKeyCreateComputerName (NULL); + keys[3] = SCDynamicStoreKeyCreateHostNames (NULL); + + patterns[0] = SCDynamicStoreKeyCreateNetworkInterfaceEntity (NULL, kSCDynamicStoreDomainState, kSCCompAnyRegex, kSCEntNetIPv4); + patterns[1] = SCDynamicStoreKeyCreateNetworkInterfaceEntity (NULL, kSCDynamicStoreDomainState, kSCCompAnyRegex, kSCEntNetIPv6); + + if (keys[0] != NULL && keys[1] != NULL && keys[2] != NULL + && keys[3] != NULL && patterns[0] != NULL && patterns[1] != NULL) + { + CFArrayRef key_array, pattern_array; + + key_array = CFArrayCreate (NULL, keys, 4, &kCFTypeArrayCallBacks); + pattern_array = CFArrayCreate (NULL, patterns, 2, &kCFTypeArrayCallBacks); + + if (key_array != NULL || pattern_array != NULL) + { + SCDynamicStoreSetNotificationKeys (ref, key_array, pattern_array); + source = SCDynamicStoreCreateRunLoopSource (NULL, ref, 0); + } + + if (key_array != NULL) + CFRelease (key_array); + if (pattern_array != NULL) + CFRelease (pattern_array); + } + + + for (i = 0; i < 4; i++) + if (keys[i] != NULL) + CFRelease (keys[i]); + for (i = 0; i < 2; i++) + if (patterns[i] != NULL) + CFRelease (patterns[i]); + + CFRelease (ref); + } + + if (source != NULL) + { + CFRunLoopAddSource (CFRunLoopGetCurrent (), + source, kCFRunLoopDefaultMode); + CFRelease (source); + } + + return source != NULL; +} + + +/* Entrypoint. */ + +void +termination_signal_handler (int unused_sig) +{ + signal (SIGTERM, SIG_DFL); + signal (SIGHUP, SIG_DFL); + signal (SIGINT, SIG_DFL); + signal (SIGQUIT, SIG_DFL); + + longjmp (exit_continuation, 1); +} + +int +main (int argc, char **argv) +{ + char **xargv; + int i, j; + int fd; + + xargv = alloca (sizeof (char *) * (argc + 32)); + + if (!read_boolean_pref (CFSTR ("no_auth"), FALSE)) + auth_file = XauFileName (); + + /* The standard X11 behaviour is for the server to quit when the first + client exits. But it can be useful for debugging (and to mimic our + behaviour in the beta releases) to not do that. */ + + xinit_kills_server = read_boolean_pref (CFSTR ("xinit_kills_server"), TRUE); + + for (i = 1; i < argc; i++) + { + if (argv[i][0] == ':') + server_name = argv[i]; + } + + if (server_name == NULL) + { + static char name[8]; + + /* No display number specified, so search for the first unused. + + There's a big old race condition here if two servers start at + the same time, but that's fairly unlikely. We could create + lockfiles or something, but that's seems more likely to cause + problems than the race condition itself.. */ + + for (i = 0; i < MAX_DISPLAYS; i++) + { + if (!display_exists_p (i)) + break; + } + + if (i == MAX_DISPLAYS) + { + fprintf (stderr, "%s: couldn't allocate a display number", argv[0]); + exit (1); + } + + sprintf (name, ":%d", i); + server_name = name; + } + + if (auth_file != NULL) + { + /* Create new Xauth keys and add them to the .Xauthority file */ + + make_auth_keys (server_name); + write_auth_file (TRUE); + } + + /* Construct our new argv */ + + i = j = 0; + + xargv[i++] = argv[j++]; + + if (auth_file != NULL) + { + xargv[i++] = "-auth"; + xargv[i++] = auth_file; + } + + /* By default, don't listen on tcp sockets if Xauth is disabled. */ + + if (read_boolean_pref (CFSTR ("nolisten_tcp"), auth_file == NULL)) + { + xargv[i++] = "-nolisten"; + xargv[i++] = "tcp"; + } + + while (j < argc) + { + if (argv[j++][0] != ':') + xargv[i++] = argv[j-1]; + } + + xargv[i++] = (char *) server_name; + xargv[i++] = NULL; + + /* Detach from any controlling terminal and connect stdin to /dev/null */ + +#ifdef TIOCNOTTY + fd = open ("/dev/tty", O_RDONLY); + if (fd != -1) + { + ioctl (fd, TIOCNOTTY, 0); + close (fd); + } +#endif + + fd = open ("/dev/null", O_RDWR, 0); + if (fd >= 0) + { + dup2 (fd, 0); + if (fd > 0) + close (fd); + } + + if (!start_server (xargv)) + return 1; + + if (!wait_for_server ()) + { + kill (server_pid, SIGTERM); + return 1; + } + + if (!start_client ()) + { + kill (server_pid, SIGTERM); + return 1; + } + + signal (SIGCHLD, sigchld_handler); + + signal (SIGTERM, termination_signal_handler); + signal (SIGHUP, termination_signal_handler); + signal (SIGINT, termination_signal_handler); + signal (SIGQUIT, termination_signal_handler); + + if (setjmp (exit_continuation) == 0) + { + if (install_ipaddr_source ()) + CFRunLoopRun (); + else + while (1) pause (); + } + + signal (SIGCHLD, SIG_IGN); + + if (client_pid >= 0) kill (client_pid, SIGTERM); + if (server_pid >= 0) kill (server_pid, SIGTERM); + + if (auth_file != NULL) + { + /* Remove our Xauth keys */ + + write_auth_file (FALSE); + } + + free_auth_items (); + + return 0; +} diff --git a/hw/darwin/darwin.c b/hw/darwin/darwin.c index e33c3211c..7da8626ab 100644 --- a/hw/darwin/darwin.c +++ b/hw/darwin/darwin.c @@ -204,6 +204,12 @@ DarwinPrintBanner() } +void DDXRingBell(int volume, int pitch, int duration) +{ + // FIXME -- make some noise, yo +} + + /* * DarwinSaveScreen * X screensaver support. Not implemented. diff --git a/hw/darwin/darwin.h b/hw/darwin/darwin.h index 48a2224f1..fc4a58a95 100644 --- a/hw/darwin/darwin.h +++ b/hw/darwin/darwin.h @@ -58,6 +58,10 @@ Bool DarwinEQInit(DevicePtr pKbd, DevicePtr pPtr); void DarwinEQEnqueue(const xEvent *e); void DarwinEQPointerPost(xEvent *e); void DarwinEQSwitchScreen(ScreenPtr pScreen, Bool fromDIX); +void DarwinPokeEQ(void); +void DarwinSendPointerEvents(int ev_type, int ev_button, int pointer_x, int pointer_y); +void DarwinSendKeyboardEvents(int ev_type, int keycode); +void DarwinSendScrollEvents(float count, int pointer_x, int pointer_y); // From darwinKeyboard.c int DarwinModifierNXKeyToNXKeycode(int key, int side); diff --git a/hw/darwin/darwinEvents.c b/hw/darwin/darwinEvents.c index 6b902df05..ac03e5a70 100644 --- a/hw/darwin/darwinEvents.c +++ b/hw/darwin/darwinEvents.c @@ -1,9 +1,9 @@ /* - * Darwin event queue and event handling - */ -/* -Copyright (c) 2002-2004 Torrey T. Lyons. All Rights Reserved. +Darwin event queue and event handling + +Copyright 2007 Apple Inc. Copyright 2004 Kaleb S. KEITHLEY. All Rights Reserved. +Copyright (c) 2002-2004 Torrey T. Lyons. All Rights Reserved. This file is based on mieq.c by Keith Packard, which contains the following copyright: @@ -61,6 +61,8 @@ typedef struct _Event { ScreenPtr pScreen; } EventRec, *EventPtr; +int input_check_zero, input_check_flag; + typedef struct _EventQueue { HWEventQueueType head, tail; /* long for SetInputCheck */ CARD32 lastEventTime; /* to avoid time running backwards */ @@ -72,7 +74,7 @@ typedef struct _EventQueue { } EventQueueRec, *EventQueuePtr; static EventQueueRec darwinEventQueue; - +xEvent *darwinEvents; /* * DarwinPressModifierMask @@ -177,18 +179,16 @@ static void DarwinSimulateMouseClick( } -Bool -DarwinEQInit( - DevicePtr pKbd, - DevicePtr pPtr) -{ +Bool DarwinEQInit(DevicePtr pKbd, DevicePtr pPtr) { + darwinEvents = (xEvent *)malloc(sizeof(xEvent) * GetMaximumEventsNum()); + mieqInit(); darwinEventQueue.head = darwinEventQueue.tail = 0; darwinEventQueue.lastEventTime = GetTimeInMillis (); darwinEventQueue.pKbd = pKbd; darwinEventQueue.pPtr = pPtr; darwinEventQueue.pEnqueueScreen = screenInfo.screens[0]; darwinEventQueue.pDequeueScreen = darwinEventQueue.pEnqueueScreen; - SetInputCheck (&darwinEventQueue.head, &darwinEventQueue.tail); + SetInputCheck(&input_check_zero, &input_check_flag); return TRUE; } @@ -199,11 +199,10 @@ DarwinEQInit( * DarwinEQEnqueue - called from event gathering thread * ProcessInputEvents - called from X server thread * DarwinEQEnqueue should never be called from more than one thread. + * + * This should be deprecated in favor of miEQEnqueue -- BB */ -void -DarwinEQEnqueue( - const xEvent *e) -{ +void DarwinEQEnqueue(const xEvent *e) { HWEventQueueType oldtail, newtail; char byte = 0; @@ -213,13 +212,12 @@ DarwinEQEnqueue( // This is difficult to do in a thread-safe way and rarely useful. newtail = oldtail + 1; - if (newtail == QUEUE_SIZE) - newtail = 0; + if (newtail == QUEUE_SIZE) newtail = 0; /* Toss events which come in late */ - if (newtail == darwinEventQueue.head) - return; + if (newtail == darwinEventQueue.head) return; darwinEventQueue.events[oldtail].event = *e; + /* * Make sure that event times don't go backwards - this * is "unnecessary", but very useful @@ -244,20 +242,13 @@ DarwinEQEnqueue( * DarwinEQPointerPost * Post a pointer event. Used by the mipointer.c routines. */ -void -DarwinEQPointerPost( - xEvent *e) -{ +void DarwinEQPointerPost(xEvent *e) { (*darwinEventQueue.pPtr->processInputProc) (e, (DeviceIntPtr)darwinEventQueue.pPtr, 1); } -void -DarwinEQSwitchScreen( - ScreenPtr pScreen, - Bool fromDIX) -{ +void DarwinEQSwitchScreen(ScreenPtr pScreen, Bool fromDIX) { darwinEventQueue.pEnqueueScreen = pScreen; if (fromDIX) darwinEventQueue.pDequeueScreen = pScreen; @@ -268,8 +259,7 @@ DarwinEQSwitchScreen( * ProcessInputEvents * Read and process events from the event queue until it is empty. */ -void ProcessInputEvents(void) -{ +void ProcessInputEvents(void) { EventRec *e; int x, y; xEvent xe; @@ -277,12 +267,15 @@ void ProcessInputEvents(void) // button number and modifier mask of currently pressed fake button static int darwinFakeMouseButtonDown = 0; static int darwinFakeMouseButtonMask = 0; + input_check_flag=0; + + // ErrorF("calling mieqProcessInputEvents\n"); + mieqProcessInputEvents(); // Empty the signaling pipe x = sizeof(xe); - while (x == sizeof(xe)) { + while (x == sizeof(xe)) x = read(darwinEventReadFD, &xe, sizeof(xe)); - } while (darwinEventQueue.head != darwinEventQueue.tail) { @@ -298,10 +291,16 @@ void ProcessInputEvents(void) dixScreenOrigins[miPointerCurrentScreen()->myNum].x; xe.u.keyButtonPointer.rootY -= darwinMainScreenY + dixScreenOrigins[miPointerCurrentScreen()->myNum].y; + + /* ErrorF("old rootX = (%d,%d) darwinMainScreen = (%d,%d) dixScreenOrigins[%d]=(%d,%d)\n", + xe.u.keyButtonPointer.rootX, xe.u.keyButtonPointer.rootY, + darwinMainScreenX, darwinMainScreenY, + miPointerCurrentScreen()->myNum, + dixScreenOrigins[miPointerCurrentScreen()->myNum].x, + dixScreenOrigins[miPointerCurrentScreen()->myNum].y); */ + + //Assumption - screen switching can only occur on motion events - /* - * Assumption - screen switching can only occur on motion events - */ if (e->pScreen != darwinEventQueue.pDequeueScreen) { darwinEventQueue.pDequeueScreen = e->pScreen; diff --git a/hw/darwin/quartz/Makefile.am b/hw/darwin/quartz/Makefile.am new file mode 100644 index 000000000..993cdb0ec --- /dev/null +++ b/hw/darwin/quartz/Makefile.am @@ -0,0 +1,54 @@ +noinst_LIBRARIES = libXQuartz.a + +AM_CFLAGS = @XORG_CFLAGS@ @DIX_CFLAGS@ +AM_OBJCFLAGS = @XORG_CFLAGS@ @DIX_CFLAGS@ + +INCLUDES = -I$(srcdir) -I$(srcdir)/.. @XORG_INCS@ +AM_DEFS = -DHAS_CG_MACH_PORT -DHAS_KL_API +if HAVE_X_PLUGIN +AM_DEFS += -DBUILD_XPR +endif +DEFS = @DEFS@ $(AM_DEFS) -DXBINDIR=\"${bindir}\" + +libXQuartz_a_SOURCES = \ + Preferences.m \ + XApplication.m \ + XServer.m \ + applewm.c \ + keysym2ucs.c \ + quartz.c \ + quartzAudio.c \ + quartzCocoa.m \ + quartzPasteboard.c \ + quartzKeyboard.c \ + quartzStartup.c \ + pseudoramiX.c + +bin_PROGRAMS = XDarwinStartup + +XDarwinStartup_SOURCES = XDarwinStartup.c +XDarwinStartup_LDFLAGS = -Wl,-framework,CoreFoundation \ + -Wl,-framework,ApplicationServices +XDarwinStartupCFLAGS = -DXBINDIR="${bindir}" +XDARWINROOT = @APPLE_APPLICATIONS_DIR@ +BINDIR = $(bindir) +install-exec-local: + -(cd $(DESTDIR)$(BINDIR); rm X; $(LN_S) XDarwinStartup X) + +man1_MANS = XDarwinStartup.man + +EXTRA_DIST = \ + applewmExt.h \ + keysym2ucs.h \ + Preferences.h \ + pseudoramiX.h \ + quartzAudio.h \ + quartzCommon.h \ + quartzCursor.c \ + quartzCursor.h \ + quartz.h \ + quartzPasteboard.h \ + XApplication.h \ + XDarwin.pbproj/project.pbxproj \ + XServer.h \ + XDarwinStartup.man diff --git a/hw/darwin/quartz/Preferences.m b/hw/darwin/quartz/Preferences.m index 6c14f4982..eb78fd32a 100644 --- a/hw/darwin/quartz/Preferences.m +++ b/hw/darwin/quartz/Preferences.m @@ -31,7 +31,9 @@ * authorization. */ /* $XFree86: xc/programs/Xserver/hw/darwin/quartz/Preferences.m,v 1.5 2004/06/08 22:58:10 torrey Exp $ */ - +#ifdef HAVE_XORG_CONFIG_H +#include +#endif #import "quartzCommon.h" #define BOOL xBOOL @@ -44,7 +46,7 @@ // Macros to build the path name #ifndef XBINDIR -#define XBINDIR /usr/X11R6/bin +#define XBINDIR /usr/X11/bin #endif #define STR(s) #s #define XSTRPATH(s) STR(s) diff --git a/hw/darwin/quartz/XDarwin.pbproj/project.pbxproj b/hw/darwin/quartz/XDarwin.pbproj/project.pbxproj index 90002db56..0ad831423 100644 --- a/hw/darwin/quartz/XDarwin.pbproj/project.pbxproj +++ b/hw/darwin/quartz/XDarwin.pbproj/project.pbxproj @@ -387,7 +387,7 @@ CFBundleIconFile XDarwin.icns CFBundleIdentifier - org.xfree86.XDarwin + org.x.x11 CFBundleInfoDictionaryVersion 6.0 CFBundleName diff --git a/hw/darwin/quartz/XDarwinStartup.c b/hw/darwin/quartz/XDarwinStartup.c index 8697776bf..8041e32d5 100644 --- a/hw/darwin/quartz/XDarwinStartup.c +++ b/hw/darwin/quartz/XDarwinStartup.c @@ -48,7 +48,7 @@ // Macros to build the path name #ifndef XBINDIR -#define XBINDIR /usr/X11R6/bin +#define XBINDIR /usr/X11/bin #endif #define STR(s) #s #define XSTRPATH(s) STR(s) "/" @@ -124,7 +124,7 @@ int main( // Otherwise query LaunchServices for the location of the XDarwin application theStatus = LSFindApplicationForInfo(kLSUnknownCreator, - CFSTR("org.xfree86.XDarwin"), + CFSTR("org.x.x11"), NULL, NULL, &appURL); if (theStatus) { fprintf(stderr, "Could not find the XDarwin application. (Error = 0x%lx)\n", theStatus); diff --git a/hw/darwin/quartz/XServer.m b/hw/darwin/quartz/XServer.m index a5a1011e9..32bfbf58f 100644 --- a/hw/darwin/quartz/XServer.m +++ b/hw/darwin/quartz/XServer.m @@ -36,18 +36,20 @@ */ /* $XdotOrg: xc/programs/Xserver/hw/darwin/quartz/XServer.m,v 1.3 2004/07/30 19:12:17 torrey Exp $ */ /* $XFree86: xc/programs/Xserver/hw/darwin/quartz/XServer.m,v 1.19 2003/11/24 05:39:01 torrey Exp $ */ - +#ifdef HAVE_XORG_CONFIG_H +#include +#endif #include "quartzCommon.h" #define BOOL xBOOL -#include "X.h" -#include "Xproto.h" +#include "X11/X.h" +#include "X11/Xproto.h" #include "os.h" #include "opaque.h" #include "darwin.h" #include "quartz.h" #define _APPLEWM_SERVER_ -#include "applewm.h" +#include "X11/extensions/applewm.h" #include "applewmExt.h" #undef BOOL @@ -830,13 +832,13 @@ static io_connect_t root_port; chdir(tem); /* Setup environment */ - snprintf(buf, sizeof(buf), ":%s", display); - setenv("DISPLAY", buf, TRUE); +// snprintf(buf, sizeof(buf), ":%s", display); +// setenv("DISPLAY", buf, TRUE); tem = getenv("PATH"); if (tem != NULL && tem[0] != NULL) - snprintf(buf, sizeof(buf), "%s:/usr/X11R6/bin", tem); + snprintf(buf, sizeof(buf), "%s:/usr/X11/bin", tem); else - snprintf(buf, sizeof(buf), "/bin:/usr/bin:/usr/X11R6/bin"); + snprintf(buf, sizeof(buf), "/bin:/usr/bin:/usr/X11/bin"); setenv("PATH", buf, TRUE); execvp(argv[0], (char **const) argv); diff --git a/hw/darwin/quartz/applewm.c b/hw/darwin/quartz/applewm.c index 224d6c5e0..cc11cfa4c 100644 --- a/hw/darwin/quartz/applewm.c +++ b/hw/darwin/quartz/applewm.c @@ -24,7 +24,9 @@ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. **************************************************************************/ - +#ifdef HAVE_XORG_CONFIG_H +#include +#endif #include "quartzCommon.h" #define NEED_REPLIES @@ -43,7 +45,7 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #include #include "darwin.h" #define _APPLEWM_SERVER_ -#include "applewmstr.h" +#include "X11/extensions/applewmstr.h" #include "applewmExt.h" #define DEFINE_ATOM_HELPER(func,atom_name) \ @@ -444,7 +446,11 @@ ProcAppleWMSetWindowMenu( } } +#ifdef INXQUARTZ + X11ApplicationSetWindowMenu (nitems, items, shortcuts); +#else QuartzSetWindowMenu (nitems, items, shortcuts); +#endif free(items); free(shortcuts); @@ -460,10 +466,12 @@ ProcAppleWMSetWindowMenuCheck( REQUEST(xAppleWMSetWindowMenuCheckReq); REQUEST_SIZE_MATCH(xAppleWMSetWindowMenuCheckReq); - +#ifdef INXQUARTZ + X11ApplicationSetWindowMenuCheck(stuff->index); +#else QuartzMessageMainThread(kQuartzSetWindowMenuCheck, &stuff->index, sizeof(stuff->index)); - +#endif return (client->noClientException); } @@ -473,9 +481,11 @@ ProcAppleWMSetFrontProcess( ) { REQUEST_SIZE_MATCH(xAppleWMSetFrontProcessReq); - +#ifdef INXQUARTZ + X11ApplicationSetFrontProcess(); +#else QuartzMessageMainThread(kQuartzSetFrontProcess, NULL, 0); - +#endif return (client->noClientException); } @@ -514,9 +524,12 @@ ProcAppleWMSetCanQuit( REQUEST(xAppleWMSetCanQuitReq); REQUEST_SIZE_MATCH(xAppleWMSetCanQuitReq); - +#ifdef INXQUARTZ + X11ApplicationSetCanQuit(stuff->state); +#else QuartzMessageMainThread(kQuartzSetCanQuit, &stuff->state, sizeof(stuff->state)); +#endif return (client->noClientException); } diff --git a/hw/darwin/quartz/cr/XView.m b/hw/darwin/quartz/cr/XView.m index 5feac6b42..8bcd1a76f 100644 --- a/hw/darwin/quartz/cr/XView.m +++ b/hw/darwin/quartz/cr/XView.m @@ -30,7 +30,9 @@ * use or other dealings in this Software without prior written authorization. */ /* $XFree86: xc/programs/Xserver/hw/darwin/quartz/cr/XView.m,v 1.1 2003/06/07 05:49:07 torrey Exp $ */ - +#ifdef HAVE_XORG_CONFIG_H +#include +#endif #import "XView.h" diff --git a/hw/darwin/quartz/cr/crAppleWM.m b/hw/darwin/quartz/cr/crAppleWM.m index a2e97ff81..0741d4e58 100644 --- a/hw/darwin/quartz/cr/crAppleWM.m +++ b/hw/darwin/quartz/cr/crAppleWM.m @@ -27,17 +27,19 @@ * use or other dealings in this Software without prior written authorization. */ /* $XFree86: xc/programs/Xserver/hw/darwin/quartz/xpr/xprFrame.c,v 1.2 2003/06/30 01:45:13 torrey Exp $ */ - -#include "quartzCommon.h" -#include "cr.h" +#ifdef HAVE_XORG_CONFIG_H +#include +#endif +#include "quartz/quartzCommon.h" +#include "quartz/cr/cr.h" #undef BOOL #define BOOL xBOOL #include "rootless.h" -#include "X.h" +#include "X11/X.h" #define _APPLEWM_SERVER_ -#include "applewm.h" -#include "applewmExt.h" +#include "X11/extensions/applewm.h" +#include "quartz/applewmExt.h" #undef BOOL #define StdDocumentStyleMask (NSTitledWindowMask | \ diff --git a/hw/darwin/quartz/cr/crFrame.m b/hw/darwin/quartz/cr/crFrame.m index 79d55a4d1..2b8e57d0a 100644 --- a/hw/darwin/quartz/cr/crFrame.m +++ b/hw/darwin/quartz/cr/crFrame.m @@ -29,14 +29,16 @@ */ /* $XdotOrg: xc/programs/Xserver/hw/darwin/quartz/cr/crFrame.m,v 1.2 2004/04/23 19:15:51 eich Exp $ */ /* $XFree86: xc/programs/Xserver/hw/darwin/quartz/cr/crFrame.m,v 1.9 2004/03/19 02:05:29 torrey Exp $ */ - -#include "quartzCommon.h" -#include "cr.h" +#ifdef HAVE_XORG_CONFIG_H +#include +#endif +#include "quartz/quartzCommon.h" +#include "quartz/cr/cr.h" #undef BOOL #define BOOL xBOOL #include "rootless.h" -#include "applewmExt.h" +#include "quartz/applewmExt.h" #include "windowstr.h" #undef BOOL diff --git a/hw/darwin/quartz/cr/crScreen.m b/hw/darwin/quartz/cr/crScreen.m index 21a79e006..9dd130e01 100644 --- a/hw/darwin/quartz/cr/crScreen.m +++ b/hw/darwin/quartz/cr/crScreen.m @@ -29,19 +29,21 @@ * use or other dealings in this Software without prior written authorization. */ /* $XFree86: xc/programs/Xserver/hw/darwin/quartz/cr/crScreen.m,v 1.5 2003/11/12 20:21:52 torrey Exp $ */ - -#include "quartzCommon.h" -#include "cr.h" +#ifdef HAVE_XORG_CONFIG_H +#include +#endif +#include "quartz/quartzCommon.h" +#include "quartz/cr/cr.h" #undef BOOL #define BOOL xBOOL #include "darwin.h" -#include "quartz.h" -#include "quartzCursor.h" +#include "quartz/quartz.h" +#include "quartz/quartzCursor.h" #include "rootless.h" -#include "safeAlpha.h" -#include "pseudoramiX.h" -#include "applewmExt.h" +#include "safeAlpha/safeAlpha.h" +#include "quartz/pseudoramiX.h" +#include "quartz/applewmExt.h" #include "regionstr.h" #include "scrnintstr.h" diff --git a/hw/darwin/quartz/fullscreen/fullscreen.c b/hw/darwin/quartz/fullscreen/fullscreen.c index a4881f9d9..02f6e89a8 100644 --- a/hw/darwin/quartz/fullscreen/fullscreen.c +++ b/hw/darwin/quartz/fullscreen/fullscreen.c @@ -25,11 +25,13 @@ * holders shall not be used in advertising or otherwise to promote the sale, * use or other dealings in this Software without prior written authorization. */ - -#include "quartzCommon.h" +#ifdef HAVE_XORG_CONFIG_H +#include +#endif +#include "quartz/quartzCommon.h" #include "darwin.h" -#include "quartz.h" -#include "quartzCursor.h" +#include "quartz/quartz.h" +#include "quartz/quartzCursor.h" #include "colormapst.h" #include "scrnintstr.h" #include "micmap.h" diff --git a/hw/darwin/quartz/fullscreen/quartzCursor.c b/hw/darwin/quartz/fullscreen/quartzCursor.c index e2333e2ea..77fa008f2 100644 --- a/hw/darwin/quartz/fullscreen/quartzCursor.c +++ b/hw/darwin/quartz/fullscreen/quartzCursor.c @@ -29,9 +29,11 @@ * holders shall not be used in advertising or otherwise to promote the sale, * use or other dealings in this Software without prior written authorization. */ - -#include "quartzCommon.h" -#include "quartzCursor.h" +#ifdef HAVE_XORG_CONFIG_H +#include +#endif +#include "quartz/quartzCommon.h" +#include "quartz/quartzCursor.h" #include "darwin.h" #include diff --git a/hw/darwin/quartz/pseudoramiX.c b/hw/darwin/quartz/pseudoramiX.c index a003daf43..7ba6d5a15 100644 --- a/hw/darwin/quartz/pseudoramiX.c +++ b/hw/darwin/quartz/pseudoramiX.c @@ -34,7 +34,9 @@ Equipment Corporation. ******************************************************************/ #include "pseudoramiX.h" - +#ifdef HAVE_XORG_CONFIG_H +#include +#endif #include "extnsionst.h" #include "dixstruct.h" #include "window.h" diff --git a/hw/darwin/quartz/quartz.c b/hw/darwin/quartz/quartz.c index 36a8bea08..038b21eff 100644 --- a/hw/darwin/quartz/quartz.c +++ b/hw/darwin/quartz/quartz.c @@ -29,14 +29,16 @@ * 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_XORG_CONFIG_H +#include +#endif #include "quartzCommon.h" #include "quartz.h" #include "darwin.h" #include "quartzAudio.h" #include "pseudoramiX.h" #define _APPLEWM_SERVER_ -#include "applewm.h" +#include "X11/extensions/applewm.h" #include "applewmExt.h" // X headers @@ -158,7 +160,11 @@ void DarwinModeInitInput( int argc, char **argv ) { +#ifdef INXQUARTZ + X11ApplicationServerReady(); +#else QuartzMessageMainThread(kQuartzServerStarted, NULL, 0); +#endif // Do final display mode specific initialization before handling events if (quartzProcs->InitInput) @@ -272,7 +278,9 @@ static void QuartzHide(void) } } quartzServerVisible = FALSE; +#ifndef INXQUARTZ QuartzMessageMainThread(kQuartzServerHidden, NULL, 0); +#endif } diff --git a/hw/darwin/quartz/quartzAudio.c b/hw/darwin/quartz/quartzAudio.c index b477b037b..16b9c2ba8 100644 --- a/hw/darwin/quartz/quartzAudio.c +++ b/hw/darwin/quartz/quartzAudio.c @@ -35,7 +35,9 @@ * 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_XORG_CONFIG_H +#include +#endif #include "quartzCommon.h" #include "quartzAudio.h" @@ -44,6 +46,7 @@ #include "inputstr.h" #include +#include void NSBeep(); diff --git a/hw/darwin/quartz/quartzCocoa.m b/hw/darwin/quartz/quartzCocoa.m index 3cb191f22..c54c18acb 100644 --- a/hw/darwin/quartz/quartzCocoa.m +++ b/hw/darwin/quartz/quartzCocoa.m @@ -35,6 +35,9 @@ * use or other dealings in this Software without prior written authorization. */ /* $XFree86: xc/programs/Xserver/hw/darwin/quartz/quartzCocoa.m,v 1.5 2004/06/08 22:58:10 torrey Exp $ */ +#ifdef HAVE_XORG_CONFIG_H +#include +#endif #include "quartzCommon.h" diff --git a/hw/darwin/quartz/quartzCursor.c b/hw/darwin/quartz/quartzCursor.c index e2333e2ea..6ed6a7677 100644 --- a/hw/darwin/quartz/quartzCursor.c +++ b/hw/darwin/quartz/quartzCursor.c @@ -30,6 +30,9 @@ * use or other dealings in this Software without prior written authorization. */ +#ifdef HAVE_XORG_CONFIG_H +#include +#endif #include "quartzCommon.h" #include "quartzCursor.h" #include "darwin.h" @@ -90,7 +93,9 @@ static pthread_cond_t cursorCondition; /* Acquire lock and tell the main thread to change cursor */ \ pthread_mutex_lock(&cursorMutex); \ currentCursor = (CCrsrHandle) (cursorH); \ +#ifndef INXQUARTZ QuartzMessageMainThread(kQuartzCursorUpdate, NULL, 0); \ +#endif \ /* Wait for the main thread to change the cursor */ \ pthread_cond_wait(&cursorCondition, &cursorMutex); \ diff --git a/hw/darwin/quartz/quartzCursor.h b/hw/darwin/quartz/quartzCursor.h index 56cc94d49..57fac68a5 100644 --- a/hw/darwin/quartz/quartzCursor.h +++ b/hw/darwin/quartz/quartzCursor.h @@ -36,6 +36,7 @@ #include "screenint.h" Bool QuartzInitCursor(ScreenPtr pScreen); +void QuartzReallySetCursor(void); void QuartzSuspendXCursor(ScreenPtr pScreen); void QuartzResumeXCursor(ScreenPtr pScreen, int x, int y); diff --git a/hw/darwin/quartz/quartzKeyboard.c b/hw/darwin/quartz/quartzKeyboard.c index fc12522be..bd2cc25ea 100644 --- a/hw/darwin/quartz/quartzKeyboard.c +++ b/hw/darwin/quartz/quartzKeyboard.c @@ -33,13 +33,16 @@ prior written authorization. */ +#ifdef HAVE_XORG_CONFIG_H +#include +#endif #include "quartzCommon.h" #include #include #include "darwinKeyboard.h" -#include "keysym.h" +#include "X11/keysym.h" #include "keysym2ucs.h" #ifdef HAS_KL_API diff --git a/hw/darwin/quartz/quartzPasteboard.c b/hw/darwin/quartz/quartzPasteboard.c index e92fe5c79..a3536fc56 100644 --- a/hw/darwin/quartz/quartzPasteboard.c +++ b/hw/darwin/quartz/quartzPasteboard.c @@ -30,6 +30,9 @@ * use or other dealings in this Software without prior written authorization. */ +#ifdef HAVE_XORG_CONFIG_H +#include +#endif #include "quartzPasteboard.h" #include diff --git a/hw/darwin/quartz/quartzStartup.c b/hw/darwin/quartz/quartzStartup.c index 277e5935f..76392e44c 100644 --- a/hw/darwin/quartz/quartzStartup.c +++ b/hw/darwin/quartz/quartzStartup.c @@ -37,21 +37,37 @@ #include "quartz.h" #include "opaque.h" #include "micmap.h" - -int NSApplicationMain(int argc, char *argv[]); +#include char **envpGlobal; // argcGlobal and argvGlobal // are from dix/globals.c +#ifdef INXQUARTZ +void X11ControllerMain(int argc, char *argv[], void (*server_thread) (void *), void *server_arg); +# ifdef GLXEXT +void GlxExtensionInit(void); +void GlxWrapInitVisuals(miInitVisualsProcPtr *); +# endif + +static void server_thread (void *arg) { + extern int main (int argc, char **argv, char **envp); + exit (main (argcGlobal, argvGlobal, envpGlobal)); +} +#else +int NSApplicationMain(int argc, char *argv[]); +typedef Bool (*QuartzModeBundleInitPtr)(void); + +# ifdef GLXEXT // GLX bundle function pointers typedef void (*GlxExtensionInitPtr)(void); static GlxExtensionInitPtr GlxExtensionInit = NULL; - typedef void (*GlxWrapInitVisualsPtr)(miInitVisualsProcPtr *); static GlxWrapInitVisualsPtr GlxWrapInitVisuals = NULL; - -typedef Bool (*QuartzModeBundleInitPtr)(void); - +void * __DarwinglXMesaProvider = NULL; +typedef void (*GlxPushProviderPtr)(void *); +GlxPushProviderPtr GlxPushProvider = NULL; +# endif +#endif /* * DarwinHandleGUI @@ -71,7 +87,9 @@ void DarwinHandleGUI( int fd[2]; if (been_here) { +#ifdef INXDARWINAPP QuartzReadPreferences(); +#endif return; } been_here = TRUE; @@ -106,11 +124,27 @@ void DarwinHandleGUI( } } +#ifdef INXQUARTZ + /* Initially I ran the X server on the main thread, and received + events on the second thread. But now we may be using Carbon, + that needs to run on the main thread. (Otherwise, when it's + prebound, it will initialize itself on the wrong thread) + + grr.. but doing that means that if the X thread gets scheduled + before the main thread when we're _not_ prebound, things fail, + so initialize by hand. */ + extern void _InitHLTB(void); + + _InitHLTB(); + + X11ControllerMain(argc, argv, server_thread, NULL); +#else main_exit = NSApplicationMain(argc, argv); +#endif exit(main_exit); } - +#ifndef INXQUARTZ /* * QuartzLoadDisplayBundle * Try to load the appropriate bundle containing the back end display code. @@ -168,7 +202,7 @@ Bool QuartzLoadDisplayBundle( return TRUE; } - +#ifdef GLXEXT /* * LoadGlxBundle * The Quartz mode X server needs to dynamically load the appropriate @@ -186,7 +220,7 @@ static void LoadGlxBundle(void) // Choose the bundle to load ErrorF("Loading GLX bundle "); - if (quartzUseAGL) { + if (/*quartzUseAGL*/0) { bundleName = CFStringCreateWithCStringNoCopy(kCFAllocatorDefault, quartzOpenGLBundle, kCFStringEncodingASCII, @@ -213,6 +247,14 @@ static void LoadGlxBundle(void) } // Find the GLX init functions + + + __DarwinglXMesaProvider = (void *) CFBundleGetDataPointerForName( + glxBundle, CFSTR("__glXMesaProvider")); + + GlxPushProvider = (void *) CFBundleGetFunctionPointerForName( + glxBundle, CFSTR("GlxPushProvider")); + GlxExtensionInit = (void *) CFBundleGetFunctionPointerForName( glxBundle, CFSTR("GlxExtensionInit")); @@ -227,7 +269,26 @@ static void LoadGlxBundle(void) CFRelease(bundleName); CFRelease(bundleURL); } +# endif +#else +Bool QuartzLoadDisplayBundle(const char *dpyBundleName) +{ + return TRUE; + } + +#endif + +#ifdef GLXEXT +void DarwinGlxPushProvider(void *impl) +{ +#ifndef INXQUARTZ + if (!GlxExtensionInit) + LoadGlxBundle(); +#endif + + GlxPushProvider(impl); +} /* * DarwinGlxExtensionInit @@ -235,9 +296,10 @@ static void LoadGlxBundle(void) */ void DarwinGlxExtensionInit(void) { +#ifndef INXQUARTZ if (!GlxExtensionInit) LoadGlxBundle(); - +#endif GlxExtensionInit(); } @@ -248,12 +310,13 @@ void DarwinGlxExtensionInit(void) void DarwinGlxWrapInitVisuals( miInitVisualsProcPtr *procPtr) { +#ifndef INXQUARTZ if (!GlxWrapInitVisuals) LoadGlxBundle(); - +#endif GlxWrapInitVisuals(procPtr); } - +#endif int DarwinModeProcessArgument( int argc, char *argv[], int i ) { diff --git a/hw/darwin/quartz/xpr/appledri.c b/hw/darwin/quartz/xpr/appledri.c index dd688cae3..ef68c867b 100644 --- a/hw/darwin/quartz/xpr/appledri.c +++ b/hw/darwin/quartz/xpr/appledri.c @@ -35,6 +35,9 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * */ +#ifdef HAVE_XORG_CONFIG_H +#include +#endif #define NEED_REPLIES #define NEED_EVENTS #include diff --git a/hw/darwin/quartz/xpr/appledri.h b/hw/darwin/quartz/xpr/appledri.h new file mode 100644 index 000000000..9c630373d --- /dev/null +++ b/hw/darwin/quartz/xpr/appledri.h @@ -0,0 +1,107 @@ +/* $XFree86: xc/lib/GL/dri/xf86dri.h,v 1.7 2000/12/07 20:26:02 dawes Exp $ */ +/************************************************************************** + +Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas. +Copyright 2000 VA Linux Systems, Inc. +Copyright (c) 2002 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. + +**************************************************************************/ + +/* + * Authors: + * Kevin E. Martin + * Jens Owen + * Rickard E. (Rik) Faith + * + */ + +#ifndef _APPLEDRI_H_ +#define _APPLEDRI_H_ + +#include + +#define X_AppleDRIQueryVersion 0 +#define X_AppleDRIQueryDirectRenderingCapable 1 +#define X_AppleDRICreateSurface 2 +#define X_AppleDRIDestroySurface 3 +#define X_AppleDRIAuthConnection 4 +/* Requests up to and including 18 were used in a previous version */ + +/* Events */ +#define AppleDRIObsoleteEvent1 0 +#define AppleDRIObsoleteEvent2 1 +#define AppleDRIObsoleteEvent3 2 +#define AppleDRISurfaceNotify 3 +#define AppleDRINumberEvents 4 + +/* Errors */ +#define AppleDRIClientNotLocal 0 +#define AppleDRIOperationNotSupported 1 +#define AppleDRINumberErrors (AppleDRIOperationNotSupported + 1) + +/* Kinds of SurfaceNotify events: */ +#define AppleDRISurfaceNotifyChanged 0 +#define AppleDRISurfaceNotifyDestroyed 1 + +#ifndef _APPLEDRI_SERVER_ + +typedef struct { + int type; /* of event */ + unsigned long serial; /* # of last request processed by server */ + Bool send_event; /* true if this came frome a SendEvent request */ + Display *display; /* Display the event was read from */ + Window window; /* window of event */ + Time time; /* server timestamp when event happened */ + int kind; /* subtype of event */ + int arg; +} XAppleDRINotifyEvent; + +_XFUNCPROTOBEGIN + +Bool XAppleDRIQueryExtension (Display *dpy, int *event_base, int *error_base); + +Bool XAppleDRIQueryVersion (Display *dpy, int *majorVersion, + int *minorVersion, int *patchVersion); + +Bool XAppleDRIQueryDirectRenderingCapable (Display *dpy, int screen, + Bool *isCapable); + +void *XAppleDRISetSurfaceNotifyHandler (void (*fun) (Display *dpy, + unsigned uid, int kind)); + +Bool XAppleDRIAuthConnection (Display *dpy, int screen, unsigned int magic); + +Bool XAppleDRICreateSurface (Display *dpy, int screen, Drawable drawable, + unsigned int client_id, unsigned int key[2], + unsigned int* uid); + +Bool XAppleDRIDestroySurface (Display *dpy, int screen, Drawable drawable); + +Bool XAppleDRISynchronizeSurfaces (Display *dpy); + +_XFUNCPROTOEND + +#endif /* _APPLEDRI_SERVER_ */ +#endif /* _APPLEDRI_H_ */ + diff --git a/hw/darwin/quartz/xpr/appledristr.h b/hw/darwin/quartz/xpr/appledristr.h new file mode 100644 index 000000000..36a2e891e --- /dev/null +++ b/hw/darwin/quartz/xpr/appledristr.h @@ -0,0 +1,176 @@ +/* $XFree86: xc/lib/GL/dri/xf86dristr.h,v 1.9 2001/03/21 16:01:08 dawes Exp $ */ +/************************************************************************** + +Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas. +Copyright 2000 VA Linux Systems, Inc. +Copyright (c) 2002 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. + +**************************************************************************/ + +/* + * Authors: + * Kevin E. Martin + * Jens Owen + * Rickard E. (Rik) Fiath + * + */ + +#ifndef _APPLEDRISTR_H_ +#define _APPLEDRISTR_H_ + +#include "appledri.h" + +#define APPLEDRINAME "Apple-DRI" + +#define APPLE_DRI_MAJOR_VERSION 1 /* current version numbers */ +#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; +} 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; +} xAppleDRIQueryVersionReply; +#define sz_xAppleDRIQueryVersionReply 32 + +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; +} 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; +} 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; +} 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; +} 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; +} 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; +} xAppleDRIDestroySurfaceReq; +#define sz_xAppleDRIDestroySurfaceReq 12 + +typedef struct _AppleDRINotify { + BYTE type; /* always eventBase + event type */ + BYTE kind; + CARD16 sequenceNumber B16; + Time time B32; /* time of change */ + CARD16 pad1 B16; + CARD32 arg B32; + CARD32 pad3 B32; +} xAppleDRINotifyEvent; +#define sz_xAppleDRINotifyEvent 20 + +#ifdef _APPLEDRI_SERVER_ + +void AppleDRISendEvent ( +#if NeedFunctionPrototypes + int /* type */, + unsigned int /* mask */, + int /* which */, + int /* arg */ +#endif +); + +#endif /* _APPLEDRI_SERVER_ */ +#endif /* _APPLEDRISTR_H_ */ diff --git a/hw/darwin/quartz/xpr/dri.c b/hw/darwin/quartz/xpr/dri.c index 9aeaaa588..08ee38221 100644 --- a/hw/darwin/quartz/xpr/dri.c +++ b/hw/darwin/quartz/xpr/dri.c @@ -33,6 +33,9 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * Rickard E. (Rik) Faith * */ +#ifdef HAVE_XORG_CONFIG_H +#include +#endif #include #include diff --git a/hw/darwin/quartz/xpr/x-hash.c b/hw/darwin/quartz/xpr/x-hash.c index a7024b2da..40e530fe0 100644 --- a/hw/darwin/quartz/xpr/x-hash.c +++ b/hw/darwin/quartz/xpr/x-hash.c @@ -27,7 +27,9 @@ 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_XORG_CONFIG_H +#include +#endif #include "x-hash.h" #include "x-list.h" #include diff --git a/hw/darwin/quartz/xpr/x-hook.c b/hw/darwin/quartz/xpr/x-hook.c index dcd34fdc5..7a0496763 100644 --- a/hw/darwin/quartz/xpr/x-hook.c +++ b/hw/darwin/quartz/xpr/x-hook.c @@ -28,7 +28,9 @@ promote the sale, use or other dealings in this Software without prior written authorization. */ /* $XFree86: $ */ - +#ifdef HAVE_XORG_CONFIG_H +#include +#endif #include "x-hook.h" #include #include diff --git a/hw/darwin/quartz/xpr/x-list.c b/hw/darwin/quartz/xpr/x-list.c index b9f23928b..a973e03f3 100644 --- a/hw/darwin/quartz/xpr/x-list.c +++ b/hw/darwin/quartz/xpr/x-list.c @@ -27,7 +27,9 @@ 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_XORG_CONFIG_H +#include +#endif #include "x-list.h" #include #include diff --git a/hw/darwin/quartz/xpr/xprAppleWM.c b/hw/darwin/quartz/xpr/xprAppleWM.c index 21746f6e9..fdf404c2d 100644 --- a/hw/darwin/quartz/xpr/xprAppleWM.c +++ b/hw/darwin/quartz/xpr/xprAppleWM.c @@ -27,14 +27,15 @@ * 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_XORG_CONFIG_H +#include +#endif #include "xpr.h" -#include "applewmExt.h" +#include "quartz/applewmExt.h" #include "rootless.h" #include "Xplugin.h" #include - static int xprSetWindowLevel( WindowPtr pWin, int level) diff --git a/hw/darwin/quartz/xpr/xprCursor.c b/hw/darwin/quartz/xpr/xprCursor.c index cb949dadc..e7f23b78b 100644 --- a/hw/darwin/quartz/xpr/xprCursor.c +++ b/hw/darwin/quartz/xpr/xprCursor.c @@ -30,8 +30,10 @@ * holders shall not be used in advertising or otherwise to promote the sale, * use or other dealings in this Software without prior written authorization. */ - -#include "quartzCommon.h" +#ifdef HAVE_XORG_CONFIG_H +#include +#endif +#include "quartz/quartzCommon.h" #include "xpr.h" #include "darwin.h" #include "Xplugin.h" diff --git a/hw/darwin/quartz/xpr/xprFrame.c b/hw/darwin/quartz/xpr/xprFrame.c index ed02d4b62..b71b2a606 100644 --- a/hw/darwin/quartz/xpr/xprFrame.c +++ b/hw/darwin/quartz/xpr/xprFrame.c @@ -27,13 +27,15 @@ * 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_XORG_CONFIG_H +#include +#endif #include "xpr.h" #include "rootlessCommon.h" #include "Xplugin.h" #include "x-hash.h" #include "x-list.h" -#include "applewmExt.h" +#include "quartz/applewmExt.h" #include "propertyst.h" #include "dix.h" diff --git a/hw/darwin/quartz/xpr/xprScreen.c b/hw/darwin/quartz/xpr/xprScreen.c index 1755ca6f7..67a0737ef 100644 --- a/hw/darwin/quartz/xpr/xprScreen.c +++ b/hw/darwin/quartz/xpr/xprScreen.c @@ -27,18 +27,20 @@ * holders shall not be used in advertising or otherwise to promote the sale, * use or other dealings in this Software without prior written authorization. */ - -#include "quartzCommon.h" -#include "quartz.h" +#ifdef HAVE_XORG_CONFIG_H +#include +#endif +#include "quartz/quartzCommon.h" +#include "quartz/quartz.h" #include "xpr.h" -#include "pseudoramiX.h" +#include "quartz/pseudoramiX.h" #include "darwin.h" #include "rootless.h" -#include "safeAlpha.h" +#include "safeAlpha/safeAlpha.h" #include "dri.h" #include "globals.h" #include "Xplugin.h" -#include "applewmExt.h" +#include "quartz/applewmExt.h" #ifdef DAMAGE # include "damage.h" @@ -47,7 +49,6 @@ // Name of GLX bundle for native OpenGL static const char *xprOpenGLBundle = "glxCGL.bundle"; - /* * eventHandler * Callback handler for Xplugin events. @@ -98,7 +99,6 @@ eventHandler(unsigned int type, const void *arg, } } - /* * displayScreenBounds * Return the display ID for a particular display index. @@ -117,7 +117,6 @@ displayAtIndex(int index) return kCGNullDirectDisplay; } - /* * displayScreenBounds * Return the bounds of a particular display. @@ -140,7 +139,6 @@ displayScreenBounds(CGDirectDisplayID id) return frame; } - /* * xprAddPseudoramiXScreens * Add a single virtual screen encompassing all the physical screens @@ -196,7 +194,6 @@ xprAddPseudoramiXScreens(int *x, int *y, int *width, int *height) xfree(displayList); } - /* * xprDisplayInit * Find number of CoreGraphics displays and initialize Xplugin. @@ -219,9 +216,7 @@ xprDisplayInit(void) darwinScreensFound = 1; if (xp_init(XP_IN_BACKGROUND) != Success) - { FatalError("Could not initialize the Xplugin library."); - } xp_select_events(XP_EVENT_DISPLAY_CHANGED | XP_EVENT_WINDOW_STATE_CHANGED @@ -234,7 +229,6 @@ xprDisplayInit(void) xprAppleWMInit(); } - /* * xprAddScreen * Init the framebuffer and record pixmap parameters for the screen. @@ -304,7 +298,6 @@ xprAddScreen(int index, ScreenPtr pScreen) return TRUE; } - /* * xprSetupScreen * Setup the screen for rootless access. @@ -341,7 +334,6 @@ xprSetupScreen(int index, ScreenPtr pScreen) return DRIFinishScreenInit(pScreen); } - /* * xprUpdateScreen * Update screen after configuation change. @@ -358,7 +350,6 @@ xprUpdateScreen(ScreenPtr pScreen) RootlessUpdateScreenPixmap(pScreen); } - /* * xprInitInput * Finalize xpr specific setup. @@ -375,7 +366,6 @@ xprInitInput(int argc, char **argv) AppleWMSetScreenOrigin(WindowTable[i]); } - /* * Quartz display mode function list. */ @@ -401,7 +391,6 @@ static QuartzModeProcsRec xprModeProcs = { DRIDestroySurface }; - /* * QuartzModeBundleInit * Initialize the display mode bundle after loading. diff --git a/hw/darwin/utils/Makefile.am b/hw/darwin/utils/Makefile.am new file mode 100644 index 000000000..11a26111e --- /dev/null +++ b/hw/darwin/utils/Makefile.am @@ -0,0 +1,11 @@ +bin_PROGRAMS = dumpkeymap + +dumpkeymap_SOURCES = dumpkeymap.c + +dumpkeymap_LDFLAGS = -Wl,-framework,IOKit + +man1_MANS = dumpkeymap.man + +EXTRA_DIST = \ + README.txt \ + dumpkeymap.man diff --git a/hw/kdrive/ephyr/hostx.c b/hw/kdrive/ephyr/hostx.c index 573f77489..36d3cbd46 100644 --- a/hw/kdrive/ephyr/hostx.c +++ b/hw/kdrive/ephyr/hostx.c @@ -656,7 +656,7 @@ hostx_paint_debug_rect(int x, int y, void hostx_load_keymap(void) { - KeySym *keymap; + XID *keymap; int host_width, min_keycode, max_keycode, width; int i,j; @@ -677,7 +677,7 @@ hostx_load_keymap(void) */ width = (host_width > 4) ? 4 : host_width; - ephyrKeySyms.map = (KeySym *)calloc(sizeof(KeySym), + ephyrKeySyms.map = (CARD32 *)calloc(sizeof(CARD32), (max_keycode - min_keycode + 1) * width); if (!ephyrKeySyms.map) @@ -685,7 +685,7 @@ hostx_load_keymap(void) for (i=0; i<(max_keycode - min_keycode+1); i++) for (j=0; jname); -#endif - if (!ki || !ki->dixdev || !ki->dixdev->kbdfeed || !ki->dixdev->key) return; @@ -1947,9 +1942,6 @@ KdEnqueueKeyboardEvent(KdKeyboardInfo *ki, } nEvents = GetKeyboardEvents(kdEvents, ki->dixdev, type, key_code); -#ifdef DEBUG - ErrorF("KdEnqueueKeyboardEvent: got %d events from GKE\n", nEvents); -#endif for (i = 0; i < nEvents; i++) KdQueueEvent(ki->dixdev, kdEvents + i); } @@ -2009,12 +2001,6 @@ KdEnqueuePointerEvent(KdPointerInfo *pi, unsigned long flags, int rx, int ry, } z = rz; -#ifdef DEBUG - ErrorF("sending motion notification for (%d, %d, %d)\n", x, y, z); - ErrorF(" comes from (%d, %d, %d)\n", rx, ry, rz); - ErrorF(" is %s\n", (flags & KD_MOUSE_DELTA) ? "relative" : "absolute"); -#endif - if (flags & KD_MOUSE_DELTA) dixflags = POINTER_RELATIVE & POINTER_ACCELERATE; else @@ -2028,9 +2014,6 @@ KdEnqueuePointerEvent(KdPointerInfo *pi, unsigned long flags, int rx, int ry, button <<= 1, n++) { if (((pi->buttonState & button) ^ (buttons & button)) && !(buttons & button)) { -#ifdef DEBUG - ErrorF(" posting button release %d\n", n); -#endif _KdEnqueuePointerEvent(pi, ButtonRelease, x, y, z, n, dixflags, FALSE); } @@ -2039,9 +2022,6 @@ KdEnqueuePointerEvent(KdPointerInfo *pi, unsigned long flags, int rx, int ry, button <<= 1, n++) { if (((pi->buttonState & button) ^ (buttons & button)) && (buttons & button)) { -#ifdef DEBUG - ErrorF(" posting button press %d\n", n); -#endif _KdEnqueuePointerEvent(pi, ButtonPress, x, y, z, n, dixflags, FALSE); } @@ -2057,11 +2037,6 @@ _KdEnqueuePointerEvent (KdPointerInfo *pi, int type, int x, int y, int z, int nEvents = 0, i = 0; int valuators[3] = { x, y, z }; -#ifdef DEBUG - ErrorF("mouse enqueuing event from device %s (%d, %d, %d; %d)\n", - pi->name, x, y, z, b); -#endif - /* TRUE from KdHandlePointerEvent, means 'we swallowed the event'. */ if (!force && KdHandlePointerEvent(pi, type, x, y, z, b, absrel)) return; diff --git a/hw/xfree86/Makefile.am b/hw/xfree86/Makefile.am index 0c1306f09..b66906380 100644 --- a/hw/xfree86/Makefile.am +++ b/hw/xfree86/Makefile.am @@ -8,16 +8,24 @@ if XF86UTILS XF86UTILS_SUBDIR = utils endif +if MFB +MFB_SUBDIR = xf1bpp xf4bpp +endif + +if CFB +CFB_SUBDIR = xf8_16bpp xf8_32bpp +endif + DOC_SUBDIR = doc SUBDIRS = common ddc dummylib i2c x86emu int10 fbdevhw os-support parser rac \ - ramdac shadowfb vbe vgahw xaa xf1bpp xf4bpp xf8_16bpp \ - xf8_32bpp loader scanpci dixmods exa \ + ramdac shadowfb vbe vgahw xaa $(MFB_SUBDIR) $(CFB_SUBDIR) \ + loader scanpci dixmods exa modes \ $(DRI_SUBDIR) $(XF86UTILS_SUBDIR) $(DOC_SUBDIR) DIST_SUBDIRS = common ddc dummylib i2c x86emu int10 fbdevhw os-support \ parser rac ramdac shadowfb vbe vgahw xaa xf1bpp xf4bpp \ - xf8_16bpp xf8_32bpp loader scanpci dixmods dri exa \ + xf8_16bpp xf8_32bpp loader scanpci dixmods dri exa modes \ utils doc bin_PROGRAMS = Xorg @@ -47,6 +55,9 @@ XORG_LIBS = \ rac/librac.a \ parser/libxf86config.a \ dixmods/libdixmods.la \ + modes/libxf86modes.a \ + ddc/libddc.a \ + i2c/libi2c.a \ @XORG_LIBS@ Xorg_DEPENDENCIES = \ diff --git a/hw/xfree86/common/xf86Init.c b/hw/xfree86/common/xf86Init.c index ff878d59c..221ab9ae8 100644 --- a/hw/xfree86/common/xf86Init.c +++ b/hw/xfree86/common/xf86Init.c @@ -36,6 +36,7 @@ #endif #include +#include #undef HAS_UTSNAME #if !defined(WIN32) && !defined(__UNIXOS2__) diff --git a/hw/xfree86/common/xf86Mode.c b/hw/xfree86/common/xf86Mode.c index d5085b542..fc905dfac 100644 --- a/hw/xfree86/common/xf86Mode.c +++ b/hw/xfree86/common/xf86Mode.c @@ -368,6 +368,7 @@ xf86HandleBuiltinMode(ScrnInfoPtr scrp, return MODE_OK; } +#if 0 /** Calculates the horizontal sync rate of a mode */ _X_EXPORT double xf86ModeHSync(DisplayModePtr mode) @@ -411,6 +412,7 @@ xf86SetModeDefaultName(DisplayModePtr mode) mode->name = XNFprintf("%dx%d", mode->HDisplay, mode->VDisplay); } +#endif /* * xf86LookupMode @@ -680,6 +682,7 @@ xf86LookupMode(ScrnInfoPtr scrp, DisplayModePtr modep, } +#if 0 /* * xf86SetModeCrtc * @@ -733,7 +736,9 @@ xf86SetModeCrtc(DisplayModePtr p, int adjustFlags) p->CrtcHAdjusted = FALSE; p->CrtcVAdjusted = FALSE; } +#endif +#if 0 /** * Allocates and returns a copy of pMode, including pointers within pMode. */ @@ -814,6 +819,7 @@ xf86ModesEqual(DisplayModePtr pMode1, DisplayModePtr pMode2) return FALSE; } } +#endif /* * xf86CheckModeForMonitor @@ -2040,6 +2046,7 @@ add(char **p, char *new) strcat(*p, new); } +#if 0 _X_EXPORT void xf86PrintModeline(int scrnIndex,DisplayModePtr mode) { @@ -2075,6 +2082,7 @@ xf86PrintModeline(int scrnIndex,DisplayModePtr mode) mode->VTotal, flags); xfree(flags); } +#endif _X_EXPORT void xf86PrintModes(ScrnInfoPtr scrp) @@ -2145,6 +2153,7 @@ xf86PrintModes(ScrnInfoPtr scrp) } while (p != NULL && p != scrp->modes); } +#if 0 /** * Adds the new mode into the mode list, and returns the new list * @@ -2168,3 +2177,4 @@ xf86ModesAdd(DisplayModePtr modes, DisplayModePtr new) return modes; } +#endif diff --git a/hw/xfree86/ddc/Makefile.am b/hw/xfree86/ddc/Makefile.am index a04b5e8fe..04d3e445c 100644 --- a/hw/xfree86/ddc/Makefile.am +++ b/hw/xfree86/ddc/Makefile.am @@ -1,11 +1,9 @@ sdk_HEADERS = edid.h vdif.h xf86DDC.h -module_LTLIBRARIES = libddc.la +noinst_LIBRARIES = libddc.a -libddc_la_LDFLAGS = -avoid-version -libddc_la_SOURCES = xf86DDC.c edid.c interpret_edid.c print_edid.c \ - interpret_vdif.c print_vdif.c ddcProperty.c \ - edid_modes.c +libddc_a_SOURCES = xf86DDC.c edid.c interpret_edid.c print_edid.c \ + interpret_vdif.c print_vdif.c ddcProperty.c INCLUDES = $(XORG_INCS) -I$(srcdir)/../i2c diff --git a/hw/xfree86/ddc/ddcProperty.c b/hw/xfree86/ddc/ddcProperty.c index 13083dd50..37efb5bd9 100644 --- a/hw/xfree86/ddc/ddcProperty.c +++ b/hw/xfree86/ddc/ddcProperty.c @@ -31,6 +31,7 @@ #include "property.h" #include "propertyst.h" #include "xf86DDC.h" +#include "xf86_ansic.h" #define EDID1_ATOM_NAME "XFree86_DDC_EDID1_RAWDATA" #define EDID2_ATOM_NAME "XFree86_DDC_EDID2_RAWDATA" diff --git a/hw/xfree86/ddc/xf86DDC.c b/hw/xfree86/ddc/xf86DDC.c index dd64bd56f..4ce585c9f 100644 --- a/hw/xfree86/ddc/xf86DDC.c +++ b/hw/xfree86/ddc/xf86DDC.c @@ -15,6 +15,8 @@ static const OptionInfoRec *DDCAvailableOptions(void *unused); +#if DDC_MODULE + static MODULESETUPPROTO(ddcSetup); static XF86ModuleVersionInfo ddcVersRec = @@ -57,6 +59,8 @@ ddcSetup(pointer module, pointer opts, int *errmaj, int *errmin) return (pointer)1; } +#endif + #define RETRIES 4 static unsigned char *EDIDRead_DDC1( diff --git a/hw/xfree86/dixmods/Makefile.am b/hw/xfree86/dixmods/Makefile.am index c34ddd6e3..58099bce9 100644 --- a/hw/xfree86/dixmods/Makefile.am +++ b/hw/xfree86/dixmods/Makefile.am @@ -14,12 +14,23 @@ if DBE DBEMOD = libdbe.la endif -module_LTLIBRARIES = libafb.la \ - libcfb.la \ - libcfb32.la \ +if AFB +AFBMOD = libafb.la +endif + +if CFB +CFBMOD = libcfb.la libcfb32.la +endif + +if MFB +MFBMOD = libmfb.la +endif + +module_LTLIBRARIES = $(AFBMOD) \ + $(CFBMOD) \ libfb.la \ libwfb.la \ - libmfb.la \ + $(MFBMOD) \ libshadow.la extsmoduledir = $(moduledir)/extensions diff --git a/hw/xfree86/dri/dri.c b/hw/xfree86/dri/dri.c index 5337f9a4a..c183e2a1f 100644 --- a/hw/xfree86/dri/dri.c +++ b/hw/xfree86/dri/dri.c @@ -204,6 +204,7 @@ DRIScreenInit(ScreenPtr pScreen, DRIInfoPtr pDRIInfo, int *pDRMFD) pDRIPriv->directRenderingSupport = TRUE; pDRIPriv->pDriverInfo = pDRIInfo; pDRIPriv->nrWindows = 0; + pDRIPriv->nrWindowsVisible = 0; pDRIPriv->fullscreen = NULL; pDRIPriv->createDummyCtx = pDRIInfo->createDummyCtx; @@ -1006,6 +1007,93 @@ DRITransitionTo2d(ScreenPtr pScreen) } +static int +DRIDCNTreeTraversal(WindowPtr pWin, pointer data) +{ + DRIDrawablePrivPtr pDRIDrawablePriv = DRI_DRAWABLE_PRIV_FROM_WINDOW(pWin); + + if (pDRIDrawablePriv) { + ScreenPtr pScreen = pWin->drawable.pScreen; + DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen); + + if (REGION_NUM_RECTS(&pWin->clipList) > 0) { + WindowPtr *pDRIWindows = (WindowPtr*)data; + int i = 0; + + while (pDRIWindows[i]) + i++; + + pDRIWindows[i] = pWin; + + pDRIPriv->nrWalked++; + } + + if (pDRIPriv->nrWindows == pDRIPriv->nrWalked) + return WT_STOPWALKING; + } + + return WT_WALKCHILDREN; +} + +static void +DRIDriverClipNotify(ScreenPtr pScreen) +{ + DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen); + + if (pDRIPriv->pDriverInfo->ClipNotify) { + WindowPtr *pDRIWindows = xcalloc(sizeof(WindowPtr), pDRIPriv->nrWindows); + DRIInfoPtr pDRIInfo = pDRIPriv->pDriverInfo; + + if (pDRIPriv->nrWindows > 0) { + pDRIPriv->nrWalked = 0; + TraverseTree(WindowTable[pScreen->myNum], DRIDCNTreeTraversal, + (pointer)pDRIWindows); + } + + pDRIInfo->ClipNotify(pScreen, pDRIWindows, pDRIPriv->nrWindows); + + xfree(pDRIWindows); + } +} + +static void +DRIIncreaseNumberVisible(ScreenPtr pScreen) +{ + DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen); + + switch (++pDRIPriv->nrWindowsVisible) { + case 1: + DRITransitionTo3d( pScreen ); + break; + case 2: + DRITransitionToSharedBuffers( pScreen ); + break; + default: + break; + } + + DRIDriverClipNotify(pScreen); +} + +static void +DRIDecreaseNumberVisible(ScreenPtr pScreen) +{ + DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen); + + switch (--pDRIPriv->nrWindowsVisible) { + case 0: + DRITransitionTo2d( pScreen ); + break; + case 1: + DRITransitionToPrivateBuffers( pScreen ); + break; + default: + break; + } + + DRIDriverClipNotify(pScreen); +} + Bool DRICreateDrawable(ScreenPtr pScreen, Drawable id, DrawablePtr pDrawable, drm_drawable_t * hHWDrawable) @@ -1040,21 +1128,16 @@ DRICreateDrawable(ScreenPtr pScreen, Drawable id, pDRIDrawablePriv->pScreen = pScreen; pDRIDrawablePriv->refCount = 1; pDRIDrawablePriv->drawableIndex = -1; + pDRIDrawablePriv->nrects = REGION_NUM_RECTS(&pWin->clipList); /* save private off of preallocated index */ pWin->devPrivates[DRIWindowPrivIndex].ptr = (pointer)pDRIDrawablePriv; - switch (++pDRIPriv->nrWindows) { - case 1: - DRITransitionTo3d( pScreen ); - break; - case 2: - DRITransitionToSharedBuffers( pScreen ); - break; - default: - break; - } + pDRIPriv->nrWindows++; + + if (pDRIDrawablePriv->nrects) + DRIIncreaseNumberVisible(pScreen); /* track this in case this window is destroyed */ AddResource(id, DRIDrawablePrivResType, (pointer)pWin); @@ -1126,19 +1209,14 @@ DRIDrawablePrivDelete(pointer pResource, XID id) pDRIDrawablePriv->hwDrawable)) { return FALSE; } + xfree(pDRIDrawablePriv); pWin->devPrivates[DRIWindowPrivIndex].ptr = NULL; - switch (--pDRIPriv->nrWindows) { - case 0: - DRITransitionTo2d( pDrawable->pScreen ); - break; - case 1: - DRITransitionToPrivateBuffers( pDrawable->pScreen ); - break; - default: - break; - } + pDRIPriv->nrWindows--; + + if (REGION_NUM_RECTS(&pWin->clipList)) + DRIDecreaseNumberVisible(pDrawable->pScreen); } else { /* pixmap (or for GLX 1.3, a PBuffer) */ /* NOT_DONE */ @@ -1276,7 +1354,7 @@ DRIGetDrawableInfo(ScreenPtr pScreen, *backX = *X; *backY = *Y; - if (pDRIPriv->nrWindows == 1 && *numClipRects) { + if (pDRIPriv->nrWindowsVisible == 1 && *numClipRects) { /* Use a single cliprect. */ int x0 = *X; @@ -1652,7 +1730,7 @@ DRICopyWindow(WindowPtr pWin, DDXPointRec ptOldOrg, RegionPtr prgnSrc) if(!pDRIPriv) return; - if(pDRIPriv->nrWindows > 0) { + if(pDRIPriv->nrWindowsVisible > 0) { RegionRec reg; REGION_NULL(pScreen, ®); @@ -1844,19 +1922,28 @@ DRIClipNotify(WindowPtr pWin, int dx, int dy) if(!pDRIPriv) return; if ((pDRIDrawablePriv = DRI_DRAWABLE_PRIV_FROM_WINDOW(pWin))) { + int nrects = REGION_NUM_RECTS(&pWin->clipList); if(!pDRIPriv->windowsTouched) { DRILockTree(pScreen); pDRIPriv->windowsTouched = TRUE; } + if (nrects && !pDRIDrawablePriv->nrects) + DRIIncreaseNumberVisible(pScreen); + else if (!nrects && pDRIDrawablePriv->nrects) + DRIDecreaseNumberVisible(pScreen); + else + DRIDriverClipNotify(pScreen); + + pDRIDrawablePriv->nrects = nrects; + pDRIPriv->pSAREA->drawableTable[pDRIDrawablePriv->drawableIndex].stamp = DRIDrawableValidationStamp++; drmUpdateDrawableInfo(pDRIPriv->drmFD, pDRIDrawablePriv->hwDrawable, DRM_DRAWABLE_CLIPRECTS, - REGION_NUM_RECTS(&pWin->clipList), - REGION_RECTS(&pWin->clipList)); + nrects, REGION_RECTS(&pWin->clipList)); } /* call lower wrapped functions */ diff --git a/hw/xfree86/dri/dri.h b/hw/xfree86/dri/dri.h index dca0edde8..f65c57160 100644 --- a/hw/xfree86/dri/dri.h +++ b/hw/xfree86/dri/dri.h @@ -107,7 +107,7 @@ typedef struct { */ #define DRIINFO_MAJOR_VERSION 5 -#define DRIINFO_MINOR_VERSION 0 +#define DRIINFO_MINOR_VERSION 1 #define DRIINFO_PATCH_VERSION 0 typedef struct { @@ -173,6 +173,9 @@ typedef struct { /* New with DRI version 4.1.0 */ void (*TransitionSingleToMulti3D)(ScreenPtr pScreen); void (*TransitionMultiToSingle3D)(ScreenPtr pScreen); + + /* New with DRI version 5.1.0 */ + void (*ClipNotify)(ScreenPtr pScreen, WindowPtr *ppWin, int num); } DRIInfoRec, *DRIInfoPtr; diff --git a/hw/xfree86/dri/dristruct.h b/hw/xfree86/dri/dristruct.h index 340c59a2e..9c42ff9cc 100644 --- a/hw/xfree86/dri/dristruct.h +++ b/hw/xfree86/dri/dristruct.h @@ -53,6 +53,7 @@ typedef struct _DRIDrawablePrivRec int drawableIndex; ScreenPtr pScreen; int refCount; + int nrects; } DRIDrawablePrivRec, *DRIDrawablePrivPtr; struct _DRIContextPrivRec @@ -87,6 +88,8 @@ typedef struct _DRIScreenPrivRec void** partial3DContextStore; /* parital 3D context */ DRIInfoPtr pDriverInfo; int nrWindows; + int nrWindowsVisible; + int nrWalked; drm_clip_rect_t private_buffer_rect; /* management of private buffers */ DrawablePtr fullscreen; /* pointer to fullscreen drawable */ drm_clip_rect_t fullscreen_rect; /* fake rect for fullscreen mode */ diff --git a/hw/xfree86/i2c/Makefile.am b/hw/xfree86/i2c/Makefile.am index e73fcaeb8..a16d88071 100644 --- a/hw/xfree86/i2c/Makefile.am +++ b/hw/xfree86/i2c/Makefile.am @@ -1,4 +1,4 @@ -module_LTLIBRARIES = libi2c.la +noinst_LIBRARIES = libi2c.a multimediadir = $(moduledir)/multimedia multimedia_LTLIBRARIES = \ @@ -10,8 +10,7 @@ multimedia_LTLIBRARIES = \ tda9885_drv.la \ uda1380_drv.la -libi2c_la_LDFLAGS = -avoid-version -libi2c_la_SOURCES = xf86i2c.c xf86i2cmodule.c +libi2c_a_SOURCES = xf86i2c.c INCLUDES = $(XORG_INCS) diff --git a/hw/xfree86/loader/Makefile.am b/hw/xfree86/loader/Makefile.am index 206600214..ceb66a231 100644 --- a/hw/xfree86/loader/Makefile.am +++ b/hw/xfree86/loader/Makefile.am @@ -2,7 +2,7 @@ noinst_LIBRARIES = libloader.a INCLUDES = $(XORG_INCS) -I$(srcdir)/../parser -I$(srcdir)/../dixmods/extmod \ -I$(srcdir)/../vbe -I$(top_srcdir)/miext/cw -I$(srcdir)/../int10 \ - -I$(srcdir)/../ddc -I$(srcdir)/../i2c + -I$(srcdir)/../ddc -I$(srcdir)/../i2c -I$(srcdir)/../modes #AM_LDFLAGS = -r AM_CFLAGS = -DIN_LOADER $(DIX_CFLAGS) $(XORG_CFLAGS) diff --git a/hw/xfree86/loader/loadmod.c b/hw/xfree86/loader/loadmod.c index ec0f181db..e4892123b 100644 --- a/hw/xfree86/loader/loadmod.c +++ b/hw/xfree86/loader/loadmod.c @@ -768,7 +768,7 @@ LoadSubModule(ModuleDescPtr parent, const char *module, submod = doLoadModule(module, NULL, subdirlist, patternlist, options, modreq, errmaj, errmin, LD_FLAG_GLOBAL); - if (submod) { + if (submod && submod != (ModuleDescPtr) 1) { parent->child = AddSibling(parent->child, submod); submod->parent = parent; } @@ -799,7 +799,7 @@ LoadSubModuleLocal(ModuleDescPtr parent, const char *module, submod = doLoadModule(module, NULL, subdirlist, patternlist, options, modreq, errmaj, errmin, 0); - if (submod) { + if (submod && submod != (ModuleDescPtr) 1) { parent->child = AddSibling(parent->child, submod); submod->parent = parent; } @@ -838,6 +838,11 @@ DuplicateModule(ModuleDescPtr mod, ModuleDescPtr parent) return ret; } +static const char *compiled_in_modules[] = { + "ddc", + "i2c", + NULL +}; static ModuleDescPtr doLoadModule(const char *module, const char *path, const char **subdirlist, @@ -856,9 +861,17 @@ doLoadModule(const char *module, const char *path, const char **subdirlist, PatternPtr patterns = NULL; int noncanonical = 0; char *m = NULL; + char **cim; xf86MsgVerb(X_INFO, 3, "LoadModule: \"%s\"", module); + for (cim = compiled_in_modules; *cim; cim++) + if (!strcmp (module, *cim)) + { + xf86MsgVerb(X_INFO, 3, "Module alread ybuilt-in"); + return (ModuleDescPtr) 1; + } + patterns = InitPatterns(patternlist); name = LoaderGetCanonicalName(module, patterns); noncanonical = (name && strcmp(module, name) != 0); @@ -1108,6 +1121,9 @@ UnloadDriver(ModuleDescPtr mod) static void UnloadModuleOrDriver(ModuleDescPtr mod) { + if (mod == (ModuleDescPtr) 1) + return; + if (mod == NULL || mod->name == NULL) return; @@ -1156,6 +1172,8 @@ FreeModuleDesc(ModuleDescPtr head) { ModuleDescPtr sibs, prev; + if (head == (ModuleDescPtr) 1) + return; /* * only free it if it's not marked as in use. In use means that it may * be unloaded someday, and UnloadModule or UnloadDriver will free it @@ -1338,7 +1356,7 @@ LoaderGetCanonicalName(const char *modname, PatternPtr patterns) unsigned long LoaderGetModuleVersion(ModuleDescPtr mod) { - if (!mod || !mod->VersionInfo) + if (!mod || mod == (ModuleDescPtr) 1 || !mod->VersionInfo) return 0; return MODULE_VERSION_NUMERIC(mod->VersionInfo->majorversion, diff --git a/hw/xfree86/loader/xf86sym.c b/hw/xfree86/loader/xf86sym.c index 1cb7dae08..6337265a8 100644 --- a/hw/xfree86/loader/xf86sym.c +++ b/hw/xfree86/loader/xf86sym.c @@ -89,6 +89,13 @@ #include "xf86sbusBus.h" #endif #include "compiler.h" +#include "xf86Crtc.h" +#include "xf86Modes.h" +#ifdef RANDR +#include "xf86RandR12.h" +#endif +#include "xf86DDC.h" +#include "edid.h" #ifndef HAS_GLIBC_SIGSETJMP #if defined(setjmp) && defined(__GNU_LIBRARY__) && \ @@ -1161,4 +1168,85 @@ _X_HIDDEN void *xfree86LookupTab[] = { /* Pci.c */ SYMVAR(pciNumBuses) + + /* modes */ + SYMFUNC(xf86CrtcConfigInit) + SYMFUNC(xf86CrtcConfigPrivateIndex) + SYMFUNC(xf86CrtcCreate) + SYMFUNC(xf86CrtcDestroy) + SYMFUNC(xf86CrtcInUse) + SYMFUNC(xf86CrtcRotate) + SYMFUNC(xf86CrtcSetMode) + SYMFUNC(xf86CrtcSetSizeRange) + SYMFUNC(xf86CVTMode) + SYMFUNC(xf86DisableUnusedFunctions) + SYMFUNC(xf86DPMSSet) + SYMFUNC(xf86DuplicateMode) + SYMFUNC(xf86DuplicateModes) + SYMFUNC(xf86GetDefaultModes) + SYMFUNC(xf86GetMonitorModes) + SYMFUNC(xf86InitialConfiguration) + SYMFUNC(xf86ModeHSync) + SYMFUNC(xf86ModesAdd) + SYMFUNC(xf86ModesEqual) + SYMFUNC(xf86ModeVRefresh) + SYMFUNC(xf86OutputCreate) + SYMFUNC(xf86OutputDestroy) + SYMFUNC(xf86OutputGetEDID) + SYMFUNC(xf86OutputGetEDIDModes) + SYMFUNC(xf86OutputRename) + SYMFUNC(xf86OutputSetEDID) + SYMFUNC(xf86PrintModeline) + SYMFUNC(xf86ProbeOutputModes) + SYMFUNC(xf86PruneInvalidModes) + SYMFUNC(xf86SetModeCrtc) + SYMFUNC(xf86SetModeDefaultName) + SYMFUNC(xf86SetScrnInfoModes) + SYMFUNC(xf86ValidateModesClocks) + SYMFUNC(xf86ValidateModesFlags) + SYMFUNC(xf86ValidateModesSize) + SYMFUNC(xf86ValidateModesSync) + SYMFUNC(xf86ValidateModesUserConfig) + SYMFUNC(xf86DiDGAInit) + SYMFUNC(xf86DiDGAReInit) + SYMFUNC(xf86DDCGetModes) + SYMFUNC(xf86SaveScreen) +#ifdef RANDR + SYMFUNC(xf86RandR12CreateScreenResources) + SYMFUNC(xf86RandR12GetOriginalVirtualSize) + SYMFUNC(xf86RandR12GetRotation) + SYMFUNC(xf86RandR12Init) + SYMFUNC(xf86RandR12PreInit) + SYMFUNC(xf86RandR12SetConfig) + SYMFUNC(xf86RandR12SetRotations) +#endif + + SYMFUNC(xf86DoEDID_DDC1) + SYMFUNC(xf86DoEDID_DDC2) + SYMFUNC(xf86InterpretEDID) + SYMFUNC(xf86PrintEDID) + SYMFUNC(xf86InterpretVdif) + SYMFUNC(xf86print_vdif) + SYMFUNC(xf86DDCMonitorSet) + SYMFUNC(xf86SetDDCproperties) + + SYMFUNC(xf86CreateI2CBusRec) + SYMFUNC(xf86CreateI2CDevRec) + SYMFUNC(xf86DestroyI2CBusRec) + SYMFUNC(xf86DestroyI2CDevRec) + SYMFUNC(xf86I2CBusInit) + SYMFUNC(xf86I2CDevInit) + SYMFUNC(xf86I2CFindBus) + SYMFUNC(xf86I2CFindDev) + SYMFUNC(xf86I2CGetScreenBuses) + SYMFUNC(xf86I2CProbeAddress) + SYMFUNC(xf86I2CReadByte) + SYMFUNC(xf86I2CReadBytes) + SYMFUNC(xf86I2CReadStatus) + SYMFUNC(xf86I2CReadWord) + SYMFUNC(xf86I2CWriteByte) + SYMFUNC(xf86I2CWriteBytes) + SYMFUNC(xf86I2CWriteRead) + SYMFUNC(xf86I2CWriteVec) + SYMFUNC(xf86I2CWriteWord) }; diff --git a/hw/xfree86/modes/Makefile.am b/hw/xfree86/modes/Makefile.am new file mode 100644 index 000000000..e0b613666 --- /dev/null +++ b/hw/xfree86/modes/Makefile.am @@ -0,0 +1,27 @@ +noinst_LIBRARIES = libxf86modes.a + +libxf86modes_a_SOURCES = \ + xf86Crtc.c \ + xf86Crtc.h \ + xf86cvt.c \ + xf86DiDGA.c \ + xf86EdidModes.c \ + xf86Modes.c \ + xf86Modes.h \ + xf86RandR12.c \ + xf86RandR12.h \ + xf86Rename.h \ + xf86Rotate.c + +INCLUDES = $(XORG_INCS) -I$(srcdir)/../ddc -I$(srcdir)/../i2c \ + -I$(srcdir)/../loader -I$(srcdir)/../rac -I$(srcdir)/../parser \ + -I$(srcdir)/../scanpci -I$(srcdir)/../vbe -I$(srcdir)/../int10 \ + -I$(srcdir)/../vgahw -I$(srcdir)/../dixmods/extmod + +sdk_HEADERS = \ + xf86Crtc.h \ + xf86Modes.h \ + xf86RandR12.h \ + xf86Rename.h + +AM_CFLAGS = $(DIX_CFLAGS) $(XORG_CFLAGS) diff --git a/hw/xfree86/modes/xf86Crtc.c b/hw/xfree86/modes/xf86Crtc.c new file mode 100644 index 000000000..2ffa9567c --- /dev/null +++ b/hw/xfree86/modes/xf86Crtc.c @@ -0,0 +1,1749 @@ +/* + * Copyright © 2006 Keith Packard + * + * Permission to use, copy, modify, distribute, and sell this software and its + * documentation for any purpose is hereby granted without fee, provided that + * the above copyright notice appear in all copies and that both that copyright + * notice and this permission notice appear in supporting documentation, and + * that the name of the copyright holders not be used in advertising or + * publicity pertaining to distribution of the software without specific, + * written prior permission. The copyright holders make no representations + * about the suitability of this software for any purpose. It is provided "as + * is" without express or implied warranty. + * + * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO + * EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, + * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * OF THIS SOFTWARE. + */ + +#ifdef HAVE_XORG_CONFIG_H +#include +#else +#ifdef HAVE_CONFIG_H +#include +#endif +#endif + +#include +#include +#include + +#include "xf86.h" +#include "xf86DDC.h" +#include "xf86Crtc.h" +#include "xf86Modes.h" +#include "xf86RandR12.h" +#include "X11/extensions/render.h" +#define DPMS_SERVER +#include "X11/extensions/dpms.h" +#include "X11/Xatom.h" +#ifdef RENDER +#include "picturestr.h" +#endif + +/* + * Initialize xf86CrtcConfig structure + */ + +int xf86CrtcConfigPrivateIndex = -1; + +void +xf86CrtcConfigInit (ScrnInfoPtr scrn, + const xf86CrtcConfigFuncsRec *funcs) +{ + xf86CrtcConfigPtr config; + + if (xf86CrtcConfigPrivateIndex == -1) + xf86CrtcConfigPrivateIndex = xf86AllocateScrnInfoPrivateIndex(); + config = xnfcalloc (1, sizeof (xf86CrtcConfigRec)); + + config->funcs = funcs; + + scrn->privates[xf86CrtcConfigPrivateIndex].ptr = config; +} + +void +xf86CrtcSetSizeRange (ScrnInfoPtr scrn, + int minWidth, int minHeight, + int maxWidth, int maxHeight) +{ + xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(scrn); + + config->minWidth = minWidth; + config->minHeight = minHeight; + config->maxWidth = maxWidth; + config->maxHeight = maxHeight; +} + +/* + * Crtc functions + */ +xf86CrtcPtr +xf86CrtcCreate (ScrnInfoPtr scrn, + const xf86CrtcFuncsRec *funcs) +{ + xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(scrn); + xf86CrtcPtr crtc, *crtcs; + + crtc = xcalloc (sizeof (xf86CrtcRec), 1); + if (!crtc) + return NULL; + crtc->scrn = scrn; + crtc->funcs = funcs; +#ifdef RANDR_12_INTERFACE + crtc->randr_crtc = NULL; +#endif + crtc->rotation = RR_Rotate_0; + crtc->desiredRotation = RR_Rotate_0; + if (xf86_config->crtc) + crtcs = xrealloc (xf86_config->crtc, + (xf86_config->num_crtc + 1) * sizeof (xf86CrtcPtr)); + else + crtcs = xalloc ((xf86_config->num_crtc + 1) * sizeof (xf86CrtcPtr)); + if (!crtcs) + { + xfree (crtc); + return NULL; + } + xf86_config->crtc = crtcs; + xf86_config->crtc[xf86_config->num_crtc++] = crtc; + return crtc; +} + +void +xf86CrtcDestroy (xf86CrtcPtr crtc) +{ + xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(crtc->scrn); + int c; + + (*crtc->funcs->destroy) (crtc); + for (c = 0; c < xf86_config->num_crtc; c++) + if (xf86_config->crtc[c] == crtc) + { + memmove (&xf86_config->crtc[c], + &xf86_config->crtc[c+1], + xf86_config->num_crtc - (c + 1)); + xf86_config->num_crtc--; + break; + } + xfree (crtc); +} + + +/** + * Return whether any outputs are connected to the specified pipe + */ + +Bool +xf86CrtcInUse (xf86CrtcPtr crtc) +{ + ScrnInfoPtr pScrn = crtc->scrn; + xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(pScrn); + int o; + + for (o = 0; o < xf86_config->num_output; o++) + if (xf86_config->output[o]->crtc == crtc) + return TRUE; + return FALSE; +} + +void +xf86CrtcSetScreenSubpixelOrder (ScreenPtr pScreen) +{ +#ifdef RENDER + int subpixel_order = SubPixelUnknown; + Bool has_none = FALSE; + ScrnInfoPtr scrn = xf86Screens[pScreen->myNum]; + xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(scrn); + int c, o; + + for (c = 0; c < xf86_config->num_crtc; c++) + { + xf86CrtcPtr crtc = xf86_config->crtc[c]; + + for (o = 0; o < xf86_config->num_output; o++) + { + xf86OutputPtr output = xf86_config->output[o]; + + if (output->crtc == crtc) + { + switch (output->subpixel_order) { + case SubPixelNone: + has_none = TRUE; + break; + case SubPixelUnknown: + break; + default: + subpixel_order = output->subpixel_order; + break; + } + } + if (subpixel_order != SubPixelUnknown) + break; + } + if (subpixel_order != SubPixelUnknown) + { + static const int circle[4] = { + SubPixelHorizontalRGB, + SubPixelVerticalRGB, + SubPixelHorizontalBGR, + SubPixelVerticalBGR, + }; + int rotate; + int c; + for (rotate = 0; rotate < 4; rotate++) + if (crtc->rotation & (1 << rotate)) + break; + for (c = 0; c < 4; c++) + if (circle[c] == subpixel_order) + break; + c = (c + rotate) & 0x3; + if ((crtc->rotation & RR_Reflect_X) && !(c & 1)) + c ^= 2; + if ((crtc->rotation & RR_Reflect_Y) && (c & 1)) + c ^= 2; + subpixel_order = circle[c]; + break; + } + } + if (subpixel_order == SubPixelUnknown && has_none) + subpixel_order = SubPixelNone; + PictureSetSubpixelOrder (pScreen, subpixel_order); +#endif +} + +/** + * Sets the given video mode on the given crtc + */ +Bool +xf86CrtcSetMode (xf86CrtcPtr crtc, DisplayModePtr mode, Rotation rotation, + int x, int y) +{ + ScrnInfoPtr scrn = crtc->scrn; + xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(scrn); + int i; + Bool ret = FALSE; + Bool didLock = FALSE; + DisplayModePtr adjusted_mode; + DisplayModeRec saved_mode; + int saved_x, saved_y; + Rotation saved_rotation; + + adjusted_mode = xf86DuplicateMode(mode); + + crtc->enabled = xf86CrtcInUse (crtc); + + if (!crtc->enabled) + { + /* XXX disable crtc? */ + return TRUE; + } + + didLock = crtc->funcs->lock (crtc); + + saved_mode = crtc->mode; + saved_x = crtc->x; + saved_y = crtc->y; + saved_rotation = crtc->rotation; + /* Update crtc values up front so the driver can rely on them for mode + * setting. + */ + crtc->mode = *mode; + crtc->x = x; + crtc->y = y; + crtc->rotation = rotation; + + /* XXX short-circuit changes to base location only */ + + /* Pass our mode to the outputs and the CRTC to give them a chance to + * adjust it according to limitations or output properties, and also + * a chance to reject the mode entirely. + */ + for (i = 0; i < xf86_config->num_output; i++) { + xf86OutputPtr output = xf86_config->output[i]; + + if (output->crtc != crtc) + continue; + + if (!output->funcs->mode_fixup(output, mode, adjusted_mode)) { + goto done; + } + } + + if (!crtc->funcs->mode_fixup(crtc, mode, adjusted_mode)) { + goto done; + } + + if (!xf86CrtcRotate (crtc, mode, rotation)) { + goto done; + } + + /* Prepare the outputs and CRTCs before setting the mode. */ + for (i = 0; i < xf86_config->num_output; i++) { + xf86OutputPtr output = xf86_config->output[i]; + + if (output->crtc != crtc) + continue; + + /* Disable the output as the first thing we do. */ + output->funcs->prepare(output); + } + + crtc->funcs->prepare(crtc); + + /* Set up the DPLL and any output state that needs to adjust or depend + * on the DPLL. + */ + crtc->funcs->mode_set(crtc, mode, adjusted_mode, x, y); + for (i = 0; i < xf86_config->num_output; i++) + { + xf86OutputPtr output = xf86_config->output[i]; + if (output->crtc == crtc) + output->funcs->mode_set(output, mode, adjusted_mode); + } + + /* Now, enable the clocks, plane, pipe, and outputs that we set up. */ + crtc->funcs->commit(crtc); + for (i = 0; i < xf86_config->num_output; i++) + { + xf86OutputPtr output = xf86_config->output[i]; + if (output->crtc == crtc) + output->funcs->commit(output); + } + + /* XXX free adjustedmode */ + ret = TRUE; + if (scrn->pScreen) + xf86CrtcSetScreenSubpixelOrder (scrn->pScreen); + +done: + if (!ret) { + crtc->x = saved_x; + crtc->y = saved_y; + crtc->rotation = saved_rotation; + crtc->mode = saved_mode; + } + + if (didLock) + crtc->funcs->unlock (crtc); + + return ret; +} + +/* + * Output functions + */ + +extern XF86ConfigPtr xf86configptr; + +typedef enum { + OPTION_PREFERRED_MODE, + OPTION_POSITION, + OPTION_BELOW, + OPTION_RIGHT_OF, + OPTION_ABOVE, + OPTION_LEFT_OF, + OPTION_ENABLE, + OPTION_DISABLE, + OPTION_MIN_CLOCK, + OPTION_MAX_CLOCK, + OPTION_IGNORE, + OPTION_ROTATE, +} OutputOpts; + +static OptionInfoRec xf86OutputOptions[] = { + {OPTION_PREFERRED_MODE, "PreferredMode", OPTV_STRING, {0}, FALSE }, + {OPTION_POSITION, "Position", OPTV_STRING, {0}, FALSE }, + {OPTION_BELOW, "Below", OPTV_STRING, {0}, FALSE }, + {OPTION_RIGHT_OF, "RightOf", OPTV_STRING, {0}, FALSE }, + {OPTION_ABOVE, "Above", OPTV_STRING, {0}, FALSE }, + {OPTION_LEFT_OF, "LeftOf", OPTV_STRING, {0}, FALSE }, + {OPTION_ENABLE, "Enable", OPTV_BOOLEAN, {0}, FALSE }, + {OPTION_DISABLE, "Disable", OPTV_BOOLEAN, {0}, FALSE }, + {OPTION_MIN_CLOCK, "MinClock", OPTV_FREQ, {0}, FALSE }, + {OPTION_MAX_CLOCK, "MaxClock", OPTV_FREQ, {0}, FALSE }, + {OPTION_IGNORE, "Ignore", OPTV_BOOLEAN, {0}, FALSE }, + {OPTION_ROTATE, "Rotate", OPTV_STRING, {0}, FALSE }, + {-1, NULL, OPTV_NONE, {0}, FALSE }, +}; + +static void +xf86OutputSetMonitor (xf86OutputPtr output) +{ + char *option_name; + static const char monitor_prefix[] = "monitor-"; + char *monitor; + + if (!output->name) + return; + + if (output->options) + xfree (output->options); + + output->options = xnfalloc (sizeof (xf86OutputOptions)); + memcpy (output->options, xf86OutputOptions, sizeof (xf86OutputOptions)); + + option_name = xnfalloc (strlen (monitor_prefix) + + strlen (output->name) + 1); + strcpy (option_name, monitor_prefix); + strcat (option_name, output->name); + monitor = xf86findOptionValue (output->scrn->options, option_name); + if (!monitor) + monitor = output->name; + else + xf86MarkOptionUsedByName (output->scrn->options, option_name); + xfree (option_name); + output->conf_monitor = xf86findMonitor (monitor, + xf86configptr->conf_monitor_lst); + if (output->conf_monitor) + xf86ProcessOptions (output->scrn->scrnIndex, + output->conf_monitor->mon_option_lst, + output->options); +} + +static Bool +xf86OutputEnabled (xf86OutputPtr output) +{ + /* Check to see if this output was disabled in the config file */ + if (xf86ReturnOptValBool (output->options, OPTION_ENABLE, TRUE) == FALSE || + xf86ReturnOptValBool (output->options, OPTION_DISABLE, FALSE) == TRUE) + { + return FALSE; + } + return TRUE; +} + +static Bool +xf86OutputIgnored (xf86OutputPtr output) +{ + return xf86ReturnOptValBool (output->options, OPTION_IGNORE, FALSE); +} + +static char *direction[4] = { + "normal", + "left", + "inverted", + "right" +}; + +static Rotation +xf86OutputInitialRotation (xf86OutputPtr output) +{ + char *rotate_name = xf86GetOptValString (output->options, + OPTION_ROTATE); + int i; + + if (!rotate_name) + return RR_Rotate_0; + + for (i = 0; i < 4; i++) + if (xf86nameCompare (direction[i], rotate_name) == 0) + return (1 << i); + return RR_Rotate_0; +} + +xf86OutputPtr +xf86OutputCreate (ScrnInfoPtr scrn, + const xf86OutputFuncsRec *funcs, + const char *name) +{ + xf86OutputPtr output, *outputs; + xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(scrn); + int len; + + if (name) + len = strlen (name) + 1; + else + len = 0; + + output = xcalloc (sizeof (xf86OutputRec) + len, 1); + if (!output) + return NULL; + output->scrn = scrn; + output->funcs = funcs; + if (name) + { + output->name = (char *) (output + 1); + strcpy (output->name, name); + } + output->subpixel_order = SubPixelUnknown; +#ifdef RANDR_12_INTERFACE + output->randr_output = NULL; +#endif + if (name) + { + xf86OutputSetMonitor (output); + if (xf86OutputIgnored (output)) + { + xfree (output); + return FALSE; + } + } + + + if (xf86_config->output) + outputs = xrealloc (xf86_config->output, + (xf86_config->num_output + 1) * sizeof (xf86OutputPtr)); + else + outputs = xalloc ((xf86_config->num_output + 1) * sizeof (xf86OutputPtr)); + if (!outputs) + { + xfree (output); + return NULL; + } + + xf86_config->output = outputs; + xf86_config->output[xf86_config->num_output++] = output; + + return output; +} + +Bool +xf86OutputRename (xf86OutputPtr output, const char *name) +{ + int len = strlen(name) + 1; + char *newname = xalloc (len); + + if (!newname) + return FALSE; /* so sorry... */ + + strcpy (newname, name); + if (output->name && output->name != (char *) (output + 1)) + xfree (output->name); + output->name = newname; + xf86OutputSetMonitor (output); + if (xf86OutputIgnored (output)) + return FALSE; + return TRUE; +} + +void +xf86OutputDestroy (xf86OutputPtr output) +{ + ScrnInfoPtr scrn = output->scrn; + xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(scrn); + int o; + + (*output->funcs->destroy) (output); + while (output->probed_modes) + xf86DeleteMode (&output->probed_modes, output->probed_modes); + for (o = 0; o < xf86_config->num_output; o++) + if (xf86_config->output[o] == output) + { + memmove (&xf86_config->output[o], + &xf86_config->output[o+1], + xf86_config->num_output - (o + 1)); + xf86_config->num_output--; + break; + } + if (output->name && output->name != (char *) (output + 1)) + xfree (output->name); + xfree (output); +} + +static DisplayModePtr +xf86DefaultMode (xf86OutputPtr output, int width, int height) +{ + DisplayModePtr target_mode = NULL; + DisplayModePtr mode; + int target_diff = 0; + int target_preferred = 0; + int mm_height; + + mm_height = output->mm_height; + if (!mm_height) + mm_height = 203; /* 768 pixels at 96dpi */ + /* + * Pick a mode closest to 96dpi + */ + for (mode = output->probed_modes; mode; mode = mode->next) + { + int dpi; + int preferred = (mode->type & M_T_PREFERRED) != 0; + int diff; + + if (xf86ModeWidth (mode, output->initial_rotation) > width || + xf86ModeHeight (mode, output->initial_rotation) > height) + continue; + + /* yes, use VDisplay here, not xf86ModeHeight */ + dpi = (mode->VDisplay * 254) / (mm_height * 10); + diff = dpi - 96; + diff = diff < 0 ? -diff : diff; + if (target_mode == NULL || (preferred > target_preferred) || + (preferred == target_preferred && diff < target_diff)) + { + target_mode = mode; + target_diff = diff; + target_preferred = preferred; + } + } + return target_mode; +} + +static DisplayModePtr +xf86ClosestMode (xf86OutputPtr output, + DisplayModePtr match, Rotation match_rotation, + int width, int height) +{ + DisplayModePtr target_mode = NULL; + DisplayModePtr mode; + int target_diff = 0; + + /* + * Pick a mode closest to the specified mode + */ + for (mode = output->probed_modes; mode; mode = mode->next) + { + int dx, dy; + int diff; + + if (xf86ModeWidth (mode, output->initial_rotation) > width || + xf86ModeHeight (mode, output->initial_rotation) > height) + continue; + + /* exact matches are preferred */ + if (output->initial_rotation == match_rotation && + xf86ModesEqual (mode, match)) + return mode; + + dx = xf86ModeWidth (match, match_rotation) - xf86ModeWidth (mode, output->initial_rotation); + dy = xf86ModeHeight (match, match_rotation) - xf86ModeHeight (mode, output->initial_rotation); + diff = dx * dx + dy * dy; + if (target_mode == NULL || diff < target_diff) + { + target_mode = mode; + target_diff = diff; + } + } + return target_mode; +} + +static Bool +xf86OutputHasPreferredMode (xf86OutputPtr output, int width, int height) +{ + DisplayModePtr mode; + + for (mode = output->probed_modes; mode; mode = mode->next) + { + if (xf86ModeWidth (mode, output->initial_rotation) > width || + xf86ModeHeight (mode, output->initial_rotation) > height) + continue; + + if (mode->type & M_T_PREFERRED) + return TRUE; + } + return FALSE; +} + +static int +xf86PickCrtcs (ScrnInfoPtr scrn, + xf86CrtcPtr *best_crtcs, + DisplayModePtr *modes, + int n, + int width, + int height) +{ + xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(scrn); + int c, o; + xf86OutputPtr output; + xf86CrtcPtr crtc; + xf86CrtcPtr *crtcs; + xf86CrtcPtr best_crtc; + int best_score; + int score; + int my_score; + + if (n == config->num_output) + return 0; + output = config->output[n]; + + /* + * Compute score with this output disabled + */ + best_crtcs[n] = NULL; + best_crtc = NULL; + best_score = xf86PickCrtcs (scrn, best_crtcs, modes, n+1, width, height); + if (modes[n] == NULL) + return best_score; + + crtcs = xalloc (config->num_output * sizeof (xf86CrtcPtr)); + if (!crtcs) + return best_score; + + my_score = 1; + /* Score outputs that are known to be connected higher */ + if (output->status == XF86OutputStatusConnected) + my_score++; + /* Score outputs with preferred modes higher */ + if (xf86OutputHasPreferredMode (output, width, height)) + my_score++; + /* + * Select a crtc for this output and + * then attempt to configure the remaining + * outputs + */ + for (c = 0; c < config->num_crtc; c++) + { + if ((output->possible_crtcs & (1 << c)) == 0) + continue; + + crtc = config->crtc[c]; + /* + * Check to see if some other output is + * using this crtc + */ + for (o = 0; o < n; o++) + if (best_crtcs[o] == crtc) + break; + if (o < n) + { + /* + * If the two outputs desire the same mode, + * see if they can be cloned + */ + if (xf86ModesEqual (modes[o], modes[n]) && + config->output[0]->initial_rotation == config->output[n]->initial_rotation && + config->output[o]->initial_x == config->output[n]->initial_x && + config->output[o]->initial_y == config->output[n]->initial_y) + { + if ((output->possible_clones & (1 << o)) == 0) + continue; /* nope, try next CRTC */ + } + else + continue; /* different modes, can't clone */ + } + crtcs[n] = crtc; + memcpy (crtcs, best_crtcs, n * sizeof (xf86CrtcPtr)); + score = my_score + xf86PickCrtcs (scrn, crtcs, modes, n+1, width, height); + if (score > best_score) + { + best_crtc = crtc; + best_score = score; + memcpy (best_crtcs, crtcs, config->num_output * sizeof (xf86CrtcPtr)); + } + } + xfree (crtcs); + return best_score; +} + + +/* + * Compute the virtual size necessary to place all of the available + * crtcs in the specified configuration. + * + * canGrow indicates that the driver can make the screen larger than its initial + * configuration. If FALSE, this function will enlarge the screen to include + * the largest available mode. + */ + +static void +xf86DefaultScreenLimits (ScrnInfoPtr scrn, int *widthp, int *heightp, + Bool canGrow) +{ + xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(scrn); + int width = 0, height = 0; + int o; + int c; + int s; + + for (c = 0; c < config->num_crtc; c++) + { + int crtc_width = 0, crtc_height = 0; + xf86CrtcPtr crtc = config->crtc[c]; + + if (crtc->enabled) + { + crtc_width = crtc->x + xf86ModeWidth (&crtc->desiredMode, crtc->desiredRotation); + crtc_height = crtc->y + xf86ModeHeight (&crtc->desiredMode, crtc->desiredRotation); + } + if (!canGrow) { + for (o = 0; o < config->num_output; o++) + { + xf86OutputPtr output = config->output[o]; + + for (s = 0; s < config->num_crtc; s++) + if (output->possible_crtcs & (1 << s)) + { + DisplayModePtr mode; + for (mode = output->probed_modes; mode; mode = mode->next) + { + if (mode->HDisplay > crtc_width) + crtc_width = mode->HDisplay; + if (mode->VDisplay > crtc_width) + crtc_width = mode->VDisplay; + if (mode->VDisplay > crtc_height) + crtc_height = mode->VDisplay; + if (mode->HDisplay > crtc_height) + crtc_height = mode->HDisplay; + } + } + } + } + if (crtc_width > width) + width = crtc_width; + if (crtc_height > height) + height = crtc_height; + } + if (config->maxWidth && width > config->maxWidth) width = config->maxWidth; + if (config->maxHeight && height > config->maxHeight) height = config->maxHeight; + if (config->minWidth && width < config->minWidth) width = config->minWidth; + if (config->minHeight && height < config->minHeight) height = config->minHeight; + *widthp = width; + *heightp = height; +} + +#define POSITION_UNSET -100000 + +static Bool +xf86InitialOutputPositions (ScrnInfoPtr scrn, DisplayModePtr *modes) +{ + xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(scrn); + int o; + int min_x, min_y; + + for (o = 0; o < config->num_output; o++) + { + xf86OutputPtr output = config->output[o]; + + output->initial_x = output->initial_y = POSITION_UNSET; + } + + /* + * Loop until all outputs are set + */ + for (;;) + { + Bool any_set = FALSE; + Bool keep_going = FALSE; + + for (o = 0; o < config->num_output; o++) + { + static const OutputOpts relations[] = { + OPTION_BELOW, OPTION_RIGHT_OF, OPTION_ABOVE, OPTION_LEFT_OF + }; + xf86OutputPtr output = config->output[o]; + xf86OutputPtr relative; + char *relative_name; + char *position; + OutputOpts relation; + int r; + + if (output->initial_x != POSITION_UNSET) + continue; + position = xf86GetOptValString (output->options, + OPTION_POSITION); + /* + * Absolute position wins + */ + if (position) + { + int x, y; + if (sscanf (position, "%d %d", &x, &y) == 2) + { + output->initial_x = x; + output->initial_y = y; + } + else + { + xf86DrvMsg (scrn->scrnIndex, X_ERROR, + "Output %s position not of form \"x y\"\n", + output->name); + output->initial_x = output->initial_y = 0; + } + any_set = TRUE; + continue; + } + /* + * Next comes relative positions + */ + relation = 0; + relative_name = NULL; + for (r = 0; r < 4; r++) + { + relation = relations[r]; + relative_name = xf86GetOptValString (output->options, + relation); + if (relative_name) + break; + } + if (relative_name) + { + int or; + relative = NULL; + for (or = 0; or < config->num_output; or++) + { + xf86OutputPtr out_rel = config->output[or]; + XF86ConfMonitorPtr rel_mon = out_rel->conf_monitor; + char *name; + + if (rel_mon) + name = rel_mon->mon_identifier; + else + name = out_rel->name; + if (!strcmp (relative_name, name)) + { + relative = config->output[or]; + break; + } + } + if (!relative) + { + xf86DrvMsg (scrn->scrnIndex, X_ERROR, + "Cannot position output %s relative to unknown output %s\n", + output->name, relative_name); + output->initial_x = 0; + output->initial_y = 0; + any_set = TRUE; + continue; + } + if (relative->initial_x == POSITION_UNSET) + { + keep_going = TRUE; + continue; + } + output->initial_x = relative->initial_x; + output->initial_y = relative->initial_y; + switch (relation) { + case OPTION_BELOW: + output->initial_y += xf86ModeHeight (modes[or], relative->initial_rotation); + break; + case OPTION_RIGHT_OF: + output->initial_x += xf86ModeWidth (modes[or], relative->initial_rotation); + break; + case OPTION_ABOVE: + output->initial_y -= xf86ModeHeight (modes[or], relative->initial_rotation); + break; + case OPTION_LEFT_OF: + output->initial_x -= xf86ModeWidth (modes[or], relative->initial_rotation); + break; + default: + break; + } + any_set = TRUE; + continue; + } + + /* Nothing set, just stick them at 0,0 */ + output->initial_x = 0; + output->initial_y = 0; + any_set = TRUE; + } + if (!keep_going) + break; + if (!any_set) + { + for (o = 0; o < config->num_output; o++) + { + xf86OutputPtr output = config->output[o]; + if (output->initial_x == POSITION_UNSET) + { + xf86DrvMsg (scrn->scrnIndex, X_ERROR, + "Output position loop. Moving %s to 0,0\n", + output->name); + output->initial_x = output->initial_y = 0; + break; + } + } + } + } + + /* + * normalize positions + */ + min_x = 1000000; + min_y = 1000000; + for (o = 0; o < config->num_output; o++) + { + xf86OutputPtr output = config->output[o]; + + if (output->initial_x < min_x) + min_x = output->initial_x; + if (output->initial_y < min_y) + min_y = output->initial_y; + } + + for (o = 0; o < config->num_output; o++) + { + xf86OutputPtr output = config->output[o]; + + output->initial_x -= min_x; + output->initial_y -= min_y; + } + return TRUE; +} + +/* + * XXX walk the monitor mode list and prune out duplicates that + * are inserted by xf86DDCMonitorSet. In an ideal world, that + * function would do this work by itself. + */ + +static void +xf86PruneDuplicateMonitorModes (MonPtr Monitor) +{ + DisplayModePtr master, clone, next; + + for (master = Monitor->Modes; + master && master != Monitor->Last; + master = master->next) + { + for (clone = master->next; clone && clone != Monitor->Modes; clone = next) + { + next = clone->next; + if (xf86ModesEqual (master, clone)) + { + if (Monitor->Last == clone) + Monitor->Last = clone->prev; + xf86DeleteMode (&Monitor->Modes, clone); + } + } + } +} + +/** Return - 0 + if a should be earlier, same or later than b in list + */ +static int +xf86ModeCompare (DisplayModePtr a, DisplayModePtr b) +{ + int diff; + + diff = ((b->type & M_T_PREFERRED) != 0) - ((a->type & M_T_PREFERRED) != 0); + if (diff) + return diff; + diff = b->HDisplay * b->VDisplay - a->HDisplay * a->VDisplay; + if (diff) + return diff; + diff = b->Clock - a->Clock; + return diff; +} + +/** + * Insertion sort input in-place and return the resulting head + */ +static DisplayModePtr +xf86SortModes (DisplayModePtr input) +{ + DisplayModePtr output = NULL, i, o, n, *op, prev; + + /* sort by preferred status and pixel area */ + while (input) + { + i = input; + input = input->next; + for (op = &output; (o = *op); op = &o->next) + if (xf86ModeCompare (o, i) > 0) + break; + i->next = *op; + *op = i; + } + /* prune identical modes */ + for (o = output; o && (n = o->next); o = n) + { + if (!strcmp (o->name, n->name) && xf86ModesEqual (o, n)) + { + o->next = n->next; + xfree (n->name); + xfree (n); + n = o; + } + } + /* hook up backward links */ + prev = NULL; + for (o = output; o; o = o->next) + { + o->prev = prev; + prev = o; + } + return output; +} + +#define DEBUG_REPROBE 1 + +void +xf86ProbeOutputModes (ScrnInfoPtr scrn, int maxX, int maxY) +{ + xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(scrn); + int o; + + if (maxX == 0 || maxY == 0) + xf86RandR12GetOriginalVirtualSize (scrn, &maxX, &maxY); + + /* Elide duplicate modes before defaulting code uses them */ + xf86PruneDuplicateMonitorModes (scrn->monitor); + + /* Probe the list of modes for each output. */ + for (o = 0; o < config->num_output; o++) + { + xf86OutputPtr output = config->output[o]; + DisplayModePtr mode; + DisplayModePtr config_modes = NULL, output_modes, default_modes; + char *preferred_mode; + xf86MonPtr edid_monitor; + XF86ConfMonitorPtr conf_monitor; + MonRec mon_rec; + int min_clock = 0; + int max_clock = 0; + double clock; + enum { sync_config, sync_edid, sync_default } sync_source = sync_default; + + while (output->probed_modes != NULL) + xf86DeleteMode(&output->probed_modes, output->probed_modes); + + /* + * Check connection status + */ + output->status = (*output->funcs->detect)(output); + + if (output->status == XF86OutputStatusDisconnected) + continue; + + memset (&mon_rec, '\0', sizeof (mon_rec)); + + conf_monitor = output->conf_monitor; + + if (conf_monitor) + { + int i; + + for (i = 0; i < conf_monitor->mon_n_hsync; i++) + { + mon_rec.hsync[mon_rec.nHsync].lo = conf_monitor->mon_hsync[i].lo; + mon_rec.hsync[mon_rec.nHsync].hi = conf_monitor->mon_hsync[i].hi; + mon_rec.nHsync++; + sync_source = sync_config; + } + for (i = 0; i < conf_monitor->mon_n_vrefresh; i++) + { + mon_rec.vrefresh[mon_rec.nVrefresh].lo = conf_monitor->mon_vrefresh[i].lo; + mon_rec.vrefresh[mon_rec.nVrefresh].hi = conf_monitor->mon_vrefresh[i].hi; + mon_rec.nVrefresh++; + sync_source = sync_config; + } + config_modes = xf86GetMonitorModes (scrn, conf_monitor); + } + + output_modes = (*output->funcs->get_modes) (output); + + edid_monitor = output->MonInfo; + + if (edid_monitor) + { + int i; + Bool set_hsync = mon_rec.nHsync == 0; + Bool set_vrefresh = mon_rec.nVrefresh == 0; + + for (i = 0; i < sizeof (edid_monitor->det_mon) / sizeof (edid_monitor->det_mon[0]); i++) + { + if (edid_monitor->det_mon[i].type == DS_RANGES) + { + struct monitor_ranges *ranges = &edid_monitor->det_mon[i].section.ranges; + if (set_hsync && ranges->max_h) + { + mon_rec.hsync[mon_rec.nHsync].lo = ranges->min_h; + mon_rec.hsync[mon_rec.nHsync].hi = ranges->max_h; + mon_rec.nHsync++; + if (sync_source == sync_default) + sync_source = sync_edid; + } + if (set_vrefresh && ranges->max_v) + { + mon_rec.vrefresh[mon_rec.nVrefresh].lo = ranges->min_v; + mon_rec.vrefresh[mon_rec.nVrefresh].hi = ranges->max_v; + mon_rec.nVrefresh++; + if (sync_source == sync_default) + sync_source = sync_edid; + } + if (ranges->max_clock > max_clock) + max_clock = ranges->max_clock; + } + } + } + + if (xf86GetOptValFreq (output->options, OPTION_MIN_CLOCK, + OPTUNITS_KHZ, &clock)) + min_clock = (int) clock; + if (xf86GetOptValFreq (output->options, OPTION_MAX_CLOCK, + OPTUNITS_KHZ, &clock)) + max_clock = (int) clock; + + /* + * These limits will end up setting a 1024x768@60Hz mode by default, + * which seems like a fairly good mode to use when nothing else is + * specified + */ + if (mon_rec.nHsync == 0) + { + mon_rec.hsync[0].lo = 31.0; + mon_rec.hsync[0].hi = 55.0; + mon_rec.nHsync = 1; + } + if (mon_rec.nVrefresh == 0) + { + mon_rec.vrefresh[0].lo = 58.0; + mon_rec.vrefresh[0].hi = 62.0; + mon_rec.nVrefresh = 1; + } + default_modes = xf86GetDefaultModes (output->interlaceAllowed, + output->doubleScanAllowed); + + if (sync_source == sync_config) + { + /* + * Check output and config modes against sync range from config file + */ + xf86ValidateModesSync (scrn, output_modes, &mon_rec); + xf86ValidateModesSync (scrn, config_modes, &mon_rec); + } + /* + * Check default modes against sync range + */ + xf86ValidateModesSync (scrn, default_modes, &mon_rec); + /* + * Check default modes against monitor max clock + */ + if (max_clock) + xf86ValidateModesClocks(scrn, default_modes, + &min_clock, &max_clock, 1); + + output->probed_modes = NULL; + output->probed_modes = xf86ModesAdd (output->probed_modes, config_modes); + output->probed_modes = xf86ModesAdd (output->probed_modes, output_modes); + output->probed_modes = xf86ModesAdd (output->probed_modes, default_modes); + + /* + * Check all modes against max size + */ + if (maxX && maxY) + xf86ValidateModesSize (scrn, output->probed_modes, + maxX, maxY, 0); + + /* + * Check all modes against output + */ + for (mode = output->probed_modes; mode != NULL; mode = mode->next) + if (mode->status == MODE_OK) + mode->status = (*output->funcs->mode_valid)(output, mode); + + xf86PruneInvalidModes(scrn, &output->probed_modes, TRUE); + + output->probed_modes = xf86SortModes (output->probed_modes); + + /* Check for a configured preference for a particular mode */ + preferred_mode = xf86GetOptValString (output->options, + OPTION_PREFERRED_MODE); + + if (preferred_mode) + { + for (mode = output->probed_modes; mode; mode = mode->next) + { + if (!strcmp (preferred_mode, mode->name)) + { + if (mode != output->probed_modes) + { + if (mode->prev) + mode->prev->next = mode->next; + if (mode->next) + mode->next->prev = mode->prev; + mode->next = output->probed_modes; + output->probed_modes->prev = mode; + mode->prev = NULL; + output->probed_modes = mode; + } + mode->type |= M_T_PREFERRED; + break; + } + } + } + + output->initial_rotation = xf86OutputInitialRotation (output); + +#ifdef DEBUG_REPROBE + if (output->probed_modes != NULL) { + xf86DrvMsg(scrn->scrnIndex, X_INFO, + "Printing probed modes for output %s\n", + output->name); + } else { + xf86DrvMsg(scrn->scrnIndex, X_INFO, + "No remaining probed modes for output %s\n", + output->name); + } +#endif + for (mode = output->probed_modes; mode != NULL; mode = mode->next) + { + /* The code to choose the best mode per pipe later on will require + * VRefresh to be set. + */ + mode->VRefresh = xf86ModeVRefresh(mode); + xf86SetModeCrtc(mode, INTERLACE_HALVE_V); + +#ifdef DEBUG_REPROBE + xf86PrintModeline(scrn->scrnIndex, mode); +#endif + } + } +} + + +/** + * Copy one of the output mode lists to the ScrnInfo record + */ + +/* XXX where does this function belong? Here? */ +void +xf86RandR12GetOriginalVirtualSize(ScrnInfoPtr scrn, int *x, int *y); + +void +xf86SetScrnInfoModes (ScrnInfoPtr scrn) +{ + xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(scrn); + xf86OutputPtr output; + xf86CrtcPtr crtc; + DisplayModePtr last, mode; + + output = config->output[config->compat_output]; + if (!output->crtc) + { + int o; + + output = NULL; + for (o = 0; o < config->num_output; o++) + if (config->output[o]->crtc) + { + config->compat_output = o; + output = config->output[o]; + break; + } + /* no outputs are active, punt and leave things as they are */ + if (!output) + return; + } + crtc = output->crtc; + + /* Clear any existing modes from scrn->modes */ + while (scrn->modes != NULL) + xf86DeleteMode(&scrn->modes, scrn->modes); + + /* Set scrn->modes to the mode list for the 'compat' output */ + scrn->modes = xf86DuplicateModes(scrn, output->probed_modes); + + for (mode = scrn->modes; mode; mode = mode->next) + if (xf86ModesEqual (mode, &crtc->desiredMode)) + break; + + if (scrn->modes != NULL) { + /* For some reason, scrn->modes is circular, unlike the other mode + * lists. How great is that? + */ + for (last = scrn->modes; last && last->next; last = last->next) + ; + last->next = scrn->modes; + scrn->modes->prev = last; + if (mode) { + while (scrn->modes != mode) + scrn->modes = scrn->modes->next; + } + } + scrn->currentMode = scrn->modes; +} + +/** + * Construct default screen configuration + * + * Given auto-detected (and, eventually, configured) values, + * construct a usable configuration for the system + * + * canGrow indicates that the driver can resize the screen to larger than its + * initially configured size via the config->funcs->resize hook. If TRUE, this + * function will set virtualX and virtualY to match the initial configuration + * and leave config->max{Width,Height} alone. If FALSE, it will bloat + * virtual[XY] to include the largest modes and set config->max{Width,Height} + * accordingly. + */ + +Bool +xf86InitialConfiguration (ScrnInfoPtr scrn, Bool canGrow) +{ + xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(scrn); + int o, c; + DisplayModePtr target_mode = NULL; + Rotation target_rotation = RR_Rotate_0; + xf86CrtcPtr *crtcs; + DisplayModePtr *modes; + Bool *enabled; + int width; + int height; + + if (scrn->display->virtualX) + width = scrn->display->virtualX; + else + width = config->maxWidth; + if (scrn->display->virtualY) + height = scrn->display->virtualY; + else + height = config->maxHeight; + + xf86ProbeOutputModes (scrn, width, height); + + crtcs = xnfcalloc (config->num_output, sizeof (xf86CrtcPtr)); + modes = xnfcalloc (config->num_output, sizeof (DisplayModePtr)); + enabled = xnfcalloc (config->num_output, sizeof (Bool)); + + for (o = 0; o < config->num_output; o++) + { + xf86OutputPtr output = config->output[o]; + + modes[o] = NULL; + enabled[o] = (xf86OutputEnabled (output) && + output->status != XF86OutputStatusDisconnected); + } + + /* + * Let outputs with preferred modes drive screen size + */ + for (o = 0; o < config->num_output; o++) + { + xf86OutputPtr output = config->output[o]; + + if (enabled[o] && + xf86OutputHasPreferredMode (output, width, height)) + { + target_mode = xf86DefaultMode (output, width, height); + target_rotation = output->initial_rotation; + if (target_mode) + { + modes[o] = target_mode; + config->compat_output = o; + break; + } + } + } + if (!target_mode) + { + for (o = 0; o < config->num_output; o++) + { + xf86OutputPtr output = config->output[o]; + if (enabled[o]) + { + target_mode = xf86DefaultMode (output, width, height); + target_rotation = output->initial_rotation; + if (target_mode) + { + modes[o] = target_mode; + config->compat_output = o; + break; + } + } + } + } + for (o = 0; o < config->num_output; o++) + { + xf86OutputPtr output = config->output[o]; + + if (enabled[o] && !modes[o]) + modes[o] = xf86ClosestMode (output, target_mode, target_rotation, width, height); + } + + /* + * Set the position of each output + */ + if (!xf86InitialOutputPositions (scrn, modes)) + { + xfree (crtcs); + xfree (modes); + return FALSE; + } + + /* + * Assign CRTCs to fit output configuration + */ + if (!xf86PickCrtcs (scrn, crtcs, modes, 0, width, height)) + { + xfree (crtcs); + xfree (modes); + return FALSE; + } + + /* XXX override xf86 common frame computation code */ + + scrn->display->frameX0 = 0; + scrn->display->frameY0 = 0; + + for (c = 0; c < config->num_crtc; c++) + { + xf86CrtcPtr crtc = config->crtc[c]; + + crtc->enabled = FALSE; + memset (&crtc->desiredMode, '\0', sizeof (crtc->desiredMode)); + } + + /* + * Set initial configuration + */ + for (o = 0; o < config->num_output; o++) + { + xf86OutputPtr output = config->output[o]; + DisplayModePtr mode = modes[o]; + xf86CrtcPtr crtc = crtcs[o]; + + if (mode && crtc) + { + crtc->desiredMode = *mode; + crtc->desiredRotation = output->initial_rotation; + crtc->enabled = TRUE; + crtc->x = output->initial_x; + crtc->y = output->initial_y; + output->crtc = crtc; + } + } + + if (scrn->display->virtualX == 0) + { + /* + * Expand virtual size to cover the current config and potential mode + * switches, if the driver can't enlarge the screen later. + */ + xf86DefaultScreenLimits (scrn, &width, &height, canGrow); + + scrn->display->virtualX = width; + scrn->display->virtualY = height; + } + + if (width > scrn->virtualX) + scrn->virtualX = width; + if (height > scrn->virtualY) + scrn->virtualY = height; + + /* + * Make sure the configuration isn't too small. + */ + if (width < config->minWidth || height < config->minHeight) + return FALSE; + + /* + * Limit the crtc config to virtual[XY] if the driver can't grow the + * desktop. + */ + if (!canGrow) + { + xf86CrtcSetSizeRange (scrn, config->minWidth, config->minHeight, + width, height); + } + + /* Mirror output modes to scrn mode list */ + xf86SetScrnInfoModes (scrn); + + xfree (crtcs); + xfree (modes); + return TRUE; +} + +/** + * Set the DPMS power mode of all outputs and CRTCs. + * + * If the new mode is off, it will turn off outputs and then CRTCs. + * Otherwise, it will affect CRTCs before outputs. + */ +void +xf86DPMSSet(ScrnInfoPtr scrn, int mode, int flags) +{ + xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(scrn); + int i; + + if (!scrn->vtSema) + return; + + if (mode == DPMSModeOff) { + for (i = 0; i < config->num_output; i++) { + xf86OutputPtr output = config->output[i]; + if (output->crtc != NULL) + (*output->funcs->dpms) (output, mode); + } + } + + for (i = 0; i < config->num_crtc; i++) { + xf86CrtcPtr crtc = config->crtc[i]; + if (crtc->enabled) + (*crtc->funcs->dpms) (crtc, mode); + } + + if (mode != DPMSModeOff) { + for (i = 0; i < config->num_output; i++) { + xf86OutputPtr output = config->output[i]; + if (output->crtc != NULL) + (*output->funcs->dpms) (output, mode); + } + } +} + +/** + * Implement the screensaver by just calling down into the driver DPMS hooks. + * + * Even for monitors with no DPMS support, by the definition of our DPMS hooks, + * the outputs will still get disabled (blanked). + */ +Bool +xf86SaveScreen(ScreenPtr pScreen, int mode) +{ + ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; + + if (xf86IsUnblank(mode)) + xf86DPMSSet(pScrn, DPMSModeOn, 0); + else + xf86DPMSSet(pScrn, DPMSModeOff, 0); + + return TRUE; +} + +/** + * Disable all inactive crtcs and outputs + */ +void +xf86DisableUnusedFunctions(ScrnInfoPtr pScrn) +{ + xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(pScrn); + int o, c; + + for (o = 0; o < xf86_config->num_output; o++) + { + xf86OutputPtr output = xf86_config->output[o]; + if (!output->crtc) + (*output->funcs->dpms)(output, DPMSModeOff); + } + + for (c = 0; c < xf86_config->num_crtc; c++) + { + xf86CrtcPtr crtc = xf86_config->crtc[c]; + + if (!crtc->enabled) + { + crtc->funcs->dpms(crtc, DPMSModeOff); + memset(&crtc->mode, 0, sizeof(crtc->mode)); + } + } +} + +#ifdef RANDR_12_INTERFACE + +#define EDID_ATOM_NAME "EDID_DATA" + +/** + * Set the RandR EDID property + */ +static void +xf86OutputSetEDIDProperty (xf86OutputPtr output, void *data, int data_len) +{ + Atom edid_atom = MakeAtom(EDID_ATOM_NAME, sizeof(EDID_ATOM_NAME), TRUE); + + /* This may get called before the RandR resources have been created */ + if (output->randr_output == NULL) + return; + + if (data_len != 0) { + RRChangeOutputProperty(output->randr_output, edid_atom, XA_INTEGER, 8, + PropModeReplace, data_len, data, FALSE); + } else { + RRDeleteOutputProperty(output->randr_output, edid_atom); + } +} + +#endif + +/** + * Set the EDID information for the specified output + */ +void +xf86OutputSetEDID (xf86OutputPtr output, xf86MonPtr edid_mon) +{ + ScrnInfoPtr scrn = output->scrn; + xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(scrn); + int i; +#ifdef RANDR_12_INTERFACE + int size; +#endif + + if (output->MonInfo != NULL) + xfree(output->MonInfo); + + output->MonInfo = edid_mon; + + /* Debug info for now, at least */ + xf86DrvMsg(scrn->scrnIndex, X_INFO, "EDID for output %s\n", output->name); + xf86PrintEDID(edid_mon); + + /* Set the DDC properties for the 'compat' output */ + if (output == config->output[config->compat_output]) + xf86SetDDCproperties(scrn, edid_mon); + +#ifdef RANDR_12_INTERFACE + /* Set the RandR output properties */ + size = 0; + if (edid_mon) + { + if (edid_mon->ver.version == 1) + size = 128; + else if (edid_mon->ver.version == 2) + size = 256; + } + xf86OutputSetEDIDProperty (output, edid_mon ? edid_mon->rawData : NULL, size); +#endif + + if (edid_mon) + { + /* Pull out a phyiscal size from a detailed timing if available. */ + for (i = 0; i < 4; i++) { + if (edid_mon->det_mon[i].type == DT && + edid_mon->det_mon[i].section.d_timings.h_size != 0 && + edid_mon->det_mon[i].section.d_timings.v_size != 0) + { + output->mm_width = edid_mon->det_mon[i].section.d_timings.h_size; + output->mm_height = edid_mon->det_mon[i].section.d_timings.v_size; + break; + } + } + + /* if no mm size is available from a detailed timing, check the max size field */ + if ((!output->mm_width || !output->mm_height) && + (edid_mon->features.hsize && edid_mon->features.vsize)) + { + output->mm_width = edid_mon->features.hsize * 10; + output->mm_height = edid_mon->features.vsize * 10; + } + } +} + +/** + * Return the list of modes supported by the EDID information + * stored in 'output' + */ +DisplayModePtr +xf86OutputGetEDIDModes (xf86OutputPtr output) +{ + ScrnInfoPtr scrn = output->scrn; + xf86MonPtr edid_mon = output->MonInfo; + + if (!edid_mon) + return NULL; + return xf86DDCGetModes(scrn->scrnIndex, edid_mon); +} + +xf86MonPtr +xf86OutputGetEDID (xf86OutputPtr output, I2CBusPtr pDDCBus) +{ + ScrnInfoPtr scrn = output->scrn; + + return xf86DoEDID_DDC2 (scrn->scrnIndex, pDDCBus); +} + +static char *_xf86ConnectorNames[] = { "None", "VGA", "DVI-I", "DVI-D", + "DVI-A", "Composite", "S-Video", + "Component", "LFP", "Proprietary" }; +char * +xf86ConnectorGetName(xf86ConnectorType connector) +{ + return _xf86ConnectorNames[connector]; +} diff --git a/hw/xfree86/modes/xf86Crtc.h b/hw/xfree86/modes/xf86Crtc.h new file mode 100644 index 000000000..537df3a3b --- /dev/null +++ b/hw/xfree86/modes/xf86Crtc.h @@ -0,0 +1,641 @@ +/* + * Copyright © 2006 Keith Packard + * + * Permission to use, copy, modify, distribute, and sell this software and its + * documentation for any purpose is hereby granted without fee, provided that + * the above copyright notice appear in all copies and that both that copyright + * notice and this permission notice appear in supporting documentation, and + * that the name of the copyright holders not be used in advertising or + * publicity pertaining to distribution of the software without specific, + * written prior permission. The copyright holders make no representations + * about the suitability of this software for any purpose. It is provided "as + * is" without express or implied warranty. + * + * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO + * EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, + * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * OF THIS SOFTWARE. + */ +#ifndef _XF86CRTC_H_ +#define _XF86CRTC_H_ + +#include +#include "randrstr.h" +#if XF86_MODES_RENAME +#include "xf86Rename.h" +#endif +#include "xf86Modes.h" +#include "damage.h" + +/* Compat definitions for older X Servers. */ +#ifndef M_T_PREFERRED +#define M_T_PREFERRED 0x08 +#endif +#ifndef M_T_DRIVER +#define M_T_DRIVER 0x40 +#endif + +typedef struct _xf86Crtc xf86CrtcRec, *xf86CrtcPtr; +typedef struct _xf86Output xf86OutputRec, *xf86OutputPtr; + +/* define a standard for connector types */ +typedef enum _xf86ConnectorType { + XF86ConnectorNone, + XF86ConnectorVGA, + XF86ConnectorDVI_I, + XF86ConnectorDVI_D, + XF86ConnectorDVI_A, + XF86ConnectorComposite, + XF86ConnectorSvideo, + XF86ConnectorComponent, + XF86ConnectorLFP, + XF86ConnectorProprietary, +} xf86ConnectorType; + +typedef enum _xf86OutputStatus { + XF86OutputStatusConnected, + XF86OutputStatusDisconnected, + XF86OutputStatusUnknown, +} xf86OutputStatus; + +typedef struct _xf86CrtcFuncs { + /** + * Turns the crtc on/off, or sets intermediate power levels if available. + * + * Unsupported intermediate modes drop to the lower power setting. If the + * mode is DPMSModeOff, the crtc must be disabled sufficiently for it to + * be safe to call mode_set. + */ + void + (*dpms)(xf86CrtcPtr crtc, + int mode); + + /** + * Saves the crtc's state for restoration on VT switch. + */ + void + (*save)(xf86CrtcPtr crtc); + + /** + * Restore's the crtc's state at VT switch. + */ + void + (*restore)(xf86CrtcPtr crtc); + + /** + * Lock CRTC prior to mode setting, mostly for DRI. + * Returns whether unlock is needed + */ + Bool + (*lock) (xf86CrtcPtr crtc); + + /** + * Unlock CRTC after mode setting, mostly for DRI + */ + void + (*unlock) (xf86CrtcPtr crtc); + + /** + * Callback to adjust the mode to be set in the CRTC. + * + * This allows a CRTC to adjust the clock or even the entire set of + * timings, which is used for panels with fixed timings or for + * buses with clock limitations. + */ + Bool + (*mode_fixup)(xf86CrtcPtr crtc, + DisplayModePtr mode, + DisplayModePtr adjusted_mode); + + /** + * Prepare CRTC for an upcoming mode set. + */ + void + (*prepare)(xf86CrtcPtr crtc); + + /** + * Callback for setting up a video mode after fixups have been made. + */ + void + (*mode_set)(xf86CrtcPtr crtc, + DisplayModePtr mode, + DisplayModePtr adjusted_mode, + int x, int y); + + /** + * Commit mode changes to a CRTC + */ + void + (*commit)(xf86CrtcPtr crtc); + + /* Set the color ramps for the CRTC to the given values. */ + void + (*gamma_set)(xf86CrtcPtr crtc, CARD16 *red, CARD16 *green, CARD16 *blue, + int size); + + /** + * Allocate the shadow area, delay the pixmap creation until needed + */ + void * + (*shadow_allocate) (xf86CrtcPtr crtc, int width, int height); + + /** + * Create shadow pixmap for rotation support + */ + PixmapPtr + (*shadow_create) (xf86CrtcPtr crtc, void *data, int width, int height); + + /** + * Destroy shadow pixmap + */ + void + (*shadow_destroy) (xf86CrtcPtr crtc, PixmapPtr pPixmap, void *data); + + /** + * Clean up driver-specific bits of the crtc + */ + void + (*destroy) (xf86CrtcPtr crtc); +} xf86CrtcFuncsRec, *xf86CrtcFuncsPtr; + +struct _xf86Crtc { + /** + * Associated ScrnInfo + */ + ScrnInfoPtr scrn; + + /** + * Active state of this CRTC + * + * Set when this CRTC is driving one or more outputs + */ + Bool enabled; + + /** Track whether cursor is within CRTC range */ + Bool cursorInRange; + + /** Track state of cursor associated with this CRTC */ + Bool cursorShown; + + /** + * Active mode + * + * This reflects the mode as set in the CRTC currently + * It will be cleared when the VT is not active or + * during server startup + */ + DisplayModeRec mode; + Rotation rotation; + PixmapPtr rotatedPixmap; + void *rotatedData; + + /** + * Position on screen + * + * Locates this CRTC within the frame buffer + */ + int x, y; + + /** + * Desired mode + * + * This is set to the requested mode, independent of + * whether the VT is active. In particular, it receives + * the startup configured mode and saves the active mode + * on VT switch. + */ + DisplayModeRec desiredMode; + Rotation desiredRotation; + int desiredX, desiredY; + + /** crtc-specific functions */ + const xf86CrtcFuncsRec *funcs; + + /** + * Driver private + * + * Holds driver-private information + */ + void *driver_private; + +#ifdef RANDR_12_INTERFACE + /** + * RandR crtc + * + * When RandR 1.2 is available, this + * points at the associated crtc object + */ + RRCrtcPtr randr_crtc; +#else + void *randr_crtc; +#endif +}; + +typedef struct _xf86OutputFuncs { + /** + * Called to allow the output a chance to create properties after the + * RandR objects have been created. + */ + void + (*create_resources)(xf86OutputPtr output); + + /** + * Turns the output on/off, or sets intermediate power levels if available. + * + * Unsupported intermediate modes drop to the lower power setting. If the + * mode is DPMSModeOff, the output must be disabled, as the DPLL may be + * disabled afterwards. + */ + void + (*dpms)(xf86OutputPtr output, + int mode); + + /** + * Saves the output's state for restoration on VT switch. + */ + void + (*save)(xf86OutputPtr output); + + /** + * Restore's the output's state at VT switch. + */ + void + (*restore)(xf86OutputPtr output); + + /** + * Callback for testing a video mode for a given output. + * + * This function should only check for cases where a mode can't be supported + * on the output specifically, and not represent generic CRTC limitations. + * + * \return MODE_OK if the mode is valid, or another MODE_* otherwise. + */ + int + (*mode_valid)(xf86OutputPtr output, + DisplayModePtr pMode); + + /** + * Callback to adjust the mode to be set in the CRTC. + * + * This allows an output to adjust the clock or even the entire set of + * timings, which is used for panels with fixed timings or for + * buses with clock limitations. + */ + Bool + (*mode_fixup)(xf86OutputPtr output, + DisplayModePtr mode, + DisplayModePtr adjusted_mode); + + /** + * Callback for preparing mode changes on an output + */ + void + (*prepare)(xf86OutputPtr output); + + /** + * Callback for committing mode changes on an output + */ + void + (*commit)(xf86OutputPtr output); + + /** + * Callback for setting up a video mode after fixups have been made. + * + * This is only called while the output is disabled. The dpms callback + * must be all that's necessary for the output, to turn the output on + * after this function is called. + */ + void + (*mode_set)(xf86OutputPtr output, + DisplayModePtr mode, + DisplayModePtr adjusted_mode); + + /** + * Probe for a connected output, and return detect_status. + */ + xf86OutputStatus + (*detect)(xf86OutputPtr output); + + /** + * Query the device for the modes it provides. + * + * This function may also update MonInfo, mm_width, and mm_height. + * + * \return singly-linked list of modes or NULL if no modes found. + */ + DisplayModePtr + (*get_modes)(xf86OutputPtr output); + +#ifdef RANDR_12_INTERFACE + /** + * Callback when an output's property has changed. + */ + Bool + (*set_property)(xf86OutputPtr output, + Atom property, + RRPropertyValuePtr value); +#endif + /** + * Clean up driver-specific bits of the output + */ + void + (*destroy) (xf86OutputPtr output); +} xf86OutputFuncsRec, *xf86OutputFuncsPtr; + +struct _xf86Output { + /** + * Associated ScrnInfo + */ + ScrnInfoPtr scrn; + + /** + * Currently connected crtc (if any) + * + * If this output is not in use, this field will be NULL. + */ + xf86CrtcPtr crtc; + + /** + * Possible CRTCs for this output as a mask of crtc indices + */ + CARD32 possible_crtcs; + + /** + * Possible outputs to share the same CRTC as a mask of output indices + */ + CARD32 possible_clones; + + /** + * Whether this output can support interlaced modes + */ + Bool interlaceAllowed; + + /** + * Whether this output can support double scan modes + */ + Bool doubleScanAllowed; + + /** + * List of available modes on this output. + * + * This should be the list from get_modes(), plus perhaps additional + * compatible modes added later. + */ + DisplayModePtr probed_modes; + + /** + * Options parsed from the related monitor section + */ + OptionInfoPtr options; + + /** + * Configured monitor section + */ + XF86ConfMonitorPtr conf_monitor; + + /** + * Desired initial position + */ + int initial_x, initial_y; + + /** + * Desired initial rotation + */ + Rotation initial_rotation; + + /** + * Current connection status + * + * This indicates whether a monitor is known to be connected + * to this output or not, or whether there is no way to tell + */ + xf86OutputStatus status; + + /** EDID monitor information */ + xf86MonPtr MonInfo; + + /** subpixel order */ + int subpixel_order; + + /** Physical size of the currently attached output device. */ + int mm_width, mm_height; + + /** Output name */ + char *name; + + /** output-specific functions */ + const xf86OutputFuncsRec *funcs; + + /** driver private information */ + void *driver_private; + +#ifdef RANDR_12_INTERFACE + /** + * RandR 1.2 output structure. + * + * When RandR 1.2 is available, this points at the associated + * RandR output structure and is created when this output is created + */ + RROutputPtr randr_output; +#else + void *randr_output; +#endif +}; + +typedef struct _xf86CrtcConfigFuncs { + /** + * Requests that the driver resize the screen. + * + * The driver is responsible for updating scrn->virtualX and scrn->virtualY. + * If the requested size cannot be set, the driver should leave those values + * alone and return FALSE. + * + * A naive driver that cannot reallocate the screen may simply change + * virtual[XY]. A more advanced driver will want to also change the + * devPrivate.ptr and devKind of the screen pixmap, update any offscreen + * pixmaps it may have moved, and change pScrn->displayWidth. + */ + Bool + (*resize)(ScrnInfoPtr scrn, + int width, + int height); +} xf86CrtcConfigFuncsRec, *xf86CrtcConfigFuncsPtr; + +typedef struct _xf86CrtcConfig { + int num_output; + xf86OutputPtr *output; + /** + * compat_output is used whenever we deal + * with legacy code that only understands a single + * output. pScrn->modes will be loaded from this output, + * adjust frame will whack this output, etc. + */ + int compat_output; + + int num_crtc; + xf86CrtcPtr *crtc; + + int minWidth, minHeight; + int maxWidth, maxHeight; + + /* For crtc-based rotation */ + DamagePtr rotationDamage; + + /* DGA */ + unsigned int dga_flags; + unsigned long dga_address; + DGAModePtr dga_modes; + int dga_nmode; + int dga_width, dga_height, dga_stride; + DisplayModePtr dga_save_mode; + + const xf86CrtcConfigFuncsRec *funcs; + +} xf86CrtcConfigRec, *xf86CrtcConfigPtr; + +extern int xf86CrtcConfigPrivateIndex; + +#define XF86_CRTC_CONFIG_PTR(p) ((xf86CrtcConfigPtr) ((p)->privates[xf86CrtcConfigPrivateIndex].ptr)) + +/* + * Initialize xf86CrtcConfig structure + */ + +void +xf86CrtcConfigInit (ScrnInfoPtr scrn, + const xf86CrtcConfigFuncsRec *funcs); + +void +xf86CrtcSetSizeRange (ScrnInfoPtr scrn, + int minWidth, int minHeight, + int maxWidth, int maxHeight); + +/* + * Crtc functions + */ +xf86CrtcPtr +xf86CrtcCreate (ScrnInfoPtr scrn, + const xf86CrtcFuncsRec *funcs); + +void +xf86CrtcDestroy (xf86CrtcPtr crtc); + + +/** + * Allocate a crtc for the specified output + * + * Find a currently unused CRTC which is suitable for + * the specified output + */ + +xf86CrtcPtr +xf86AllocCrtc (xf86OutputPtr output); + +/** + * Free a crtc + * + * Mark the crtc as unused by any outputs + */ + +void +xf86FreeCrtc (xf86CrtcPtr crtc); + +/** + * Sets the given video mode on the given crtc + */ +Bool +xf86CrtcSetMode (xf86CrtcPtr crtc, DisplayModePtr mode, Rotation rotation, + int x, int y); + +/* + * Assign crtc rotation during mode set + */ +Bool +xf86CrtcRotate (xf86CrtcPtr crtc, DisplayModePtr mode, Rotation rotation); + +/** + * Return whether any output is assigned to the crtc + */ +Bool +xf86CrtcInUse (xf86CrtcPtr crtc); + +/* + * Output functions + */ +xf86OutputPtr +xf86OutputCreate (ScrnInfoPtr scrn, + const xf86OutputFuncsRec *funcs, + const char *name); + +Bool +xf86OutputRename (xf86OutputPtr output, const char *name); + +void +xf86OutputDestroy (xf86OutputPtr output); + +void +xf86ProbeOutputModes (ScrnInfoPtr pScrn, int maxX, int maxY); + +void +xf86SetScrnInfoModes (ScrnInfoPtr pScrn); + +Bool +xf86InitialConfiguration (ScrnInfoPtr pScrn, Bool canGrow); + +void +xf86DPMSSet(ScrnInfoPtr pScrn, int PowerManagementMode, int flags); + +Bool +xf86SaveScreen(ScreenPtr pScreen, int mode); + +void +xf86DisableUnusedFunctions(ScrnInfoPtr pScrn); + +/** + * Set the EDID information for the specified output + */ +void +xf86OutputSetEDID (xf86OutputPtr output, xf86MonPtr edid_mon); + +/** + * Return the list of modes supported by the EDID information + * stored in 'output' + */ +DisplayModePtr +xf86OutputGetEDIDModes (xf86OutputPtr output); + +xf86MonPtr +xf86OutputGetEDID (xf86OutputPtr output, I2CBusPtr pDDCBus); + +/** + * Initialize dga for this screen + */ + +Bool +xf86DiDGAInit (ScreenPtr pScreen, unsigned long dga_address); + +/** + * Re-initialize dga for this screen (as when the set of modes changes) + */ + +Bool +xf86DiDGAReInit (ScreenPtr pScreen); + +/* + * Set the subpixel order reported for the screen using + * the information from the outputs + */ + +void +xf86CrtcSetScreenSubpixelOrder (ScreenPtr pScreen); + +/* + * Get a standard string name for a connector type + */ +char * +xf86ConnectorGetName(xf86ConnectorType connector); + +#endif /* _XF86CRTC_H_ */ diff --git a/hw/xfree86/modes/xf86DiDGA.c b/hw/xfree86/modes/xf86DiDGA.c new file mode 100644 index 000000000..0964cefa7 --- /dev/null +++ b/hw/xfree86/modes/xf86DiDGA.c @@ -0,0 +1,286 @@ +/* + * Copyright © 2006 Keith Packard + * + * Permission to use, copy, modify, distribute, and sell this software and its + * documentation for any purpose is hereby granted without fee, provided that + * the above copyright notice appear in all copies and that both that copyright + * notice and this permission notice appear in supporting documentation, and + * that the name of the copyright holders not be used in advertising or + * publicity pertaining to distribution of the software without specific, + * written prior permission. The copyright holders make no representations + * about the suitability of this software for any purpose. It is provided "as + * is" without express or implied warranty. + * + * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO + * EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, + * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * OF THIS SOFTWARE. + */ + +#ifdef HAVE_XORG_CONFIG_H +#include +#else +#ifdef HAVE_CONFIG_H +#include +#endif +#endif + +#include "xf86.h" +#include "xf86DDC.h" +#include "xf86_OSproc.h" +#include "dgaproc.h" +#include "xf86Crtc.h" +#include "xf86Modes.h" +#include "gcstruct.h" +#include "scrnintstr.h" +#include "windowstr.h" + +static Bool +xf86_dga_get_modes (ScreenPtr pScreen) +{ + ScrnInfoPtr scrn = xf86Screens[pScreen->myNum]; + xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(scrn); + DGAModePtr modes, mode; + DisplayModePtr display_mode; + int bpp = scrn->bitsPerPixel >> 3; + int num; + + num = 0; + display_mode = scrn->modes; + while (display_mode) + { + num++; + display_mode = display_mode->next; + if (display_mode == scrn->modes) + break; + } + + if (!num) + return FALSE; + + modes = xalloc(num * sizeof(DGAModeRec)); + if (!modes) + return FALSE; + + num = 0; + display_mode = scrn->modes; + while (display_mode) + { + mode = modes + num++; + + mode->mode = display_mode; + mode->flags = DGA_CONCURRENT_ACCESS | DGA_PIXMAP_AVAILABLE; + mode->flags |= DGA_FILL_RECT | DGA_BLIT_RECT; + if (display_mode->Flags & V_DBLSCAN) + mode->flags |= DGA_DOUBLESCAN; + if (display_mode->Flags & V_INTERLACE) + mode->flags |= DGA_INTERLACED; + mode->byteOrder = scrn->imageByteOrder; + mode->depth = scrn->depth; + mode->bitsPerPixel = scrn->bitsPerPixel; + mode->red_mask = scrn->mask.red; + mode->green_mask = scrn->mask.green; + mode->blue_mask = scrn->mask.blue; + mode->visualClass = (bpp == 1) ? PseudoColor : TrueColor; + mode->viewportWidth = display_mode->HDisplay; + mode->viewportHeight = display_mode->VDisplay; + mode->xViewportStep = (bpp == 3) ? 2 : 1; + mode->yViewportStep = 1; + mode->viewportFlags = DGA_FLIP_RETRACE; + mode->offset = 0; + mode->address = (unsigned char *) xf86_config->dga_address; + mode->bytesPerScanline = xf86_config->dga_stride; + mode->imageWidth = xf86_config->dga_width; + mode->imageHeight = xf86_config->dga_height; + mode->pixmapWidth = mode->imageWidth; + mode->pixmapHeight = mode->imageHeight; + mode->maxViewportX = mode->imageWidth - mode->viewportWidth; + mode->maxViewportY = mode->imageHeight - mode->viewportHeight; + + display_mode = display_mode->next; + if (display_mode == scrn->modes) + break; + } + if (xf86_config->dga_modes) + xfree (xf86_config->dga_modes); + xf86_config->dga_nmode = num; + xf86_config->dga_modes = modes; + return TRUE; +} + +static Bool +xf86_dga_set_mode(ScrnInfoPtr scrn, DGAModePtr display_mode) +{ + ScreenPtr pScreen = scrn->pScreen; + xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(scrn); + + if (!display_mode) + { + if (xf86_config->dga_save_mode) + { + xf86SwitchMode(pScreen, xf86_config->dga_save_mode); + xf86_config->dga_save_mode = NULL; + } + } + else + { + if (!xf86_config->dga_save_mode) + { + xf86_config->dga_save_mode = scrn->currentMode; + xf86SwitchMode(pScreen, display_mode->mode); + } + } + return TRUE; +} + +static int +xf86_dga_get_viewport(ScrnInfoPtr scrn) +{ + return 0; +} + +static void +xf86_dga_set_viewport(ScrnInfoPtr scrn, int x, int y, int flags) +{ + scrn->AdjustFrame(scrn->pScreen->myNum, x, y, flags); +} + +static Bool +xf86_dga_get_drawable_and_gc (ScrnInfoPtr scrn, DrawablePtr *ppDrawable, GCPtr *ppGC) +{ + ScreenPtr pScreen = scrn->pScreen; + xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(scrn); + PixmapPtr pPixmap; + GCPtr pGC; + + pPixmap = GetScratchPixmapHeader (pScreen, xf86_config->dga_width, xf86_config->dga_height, + scrn->depth, scrn->bitsPerPixel, xf86_config->dga_stride, + (char *) scrn->memPhysBase + scrn->fbOffset); + if (!pPixmap) + return FALSE; + pGC = GetScratchGC (scrn->depth, pScreen); + if (!pGC) + { + FreeScratchPixmapHeader (pPixmap); + return FALSE; + } + *ppDrawable = &pPixmap->drawable; + *ppGC = pGC; + return TRUE; +} + +static void +xf86_dga_release_drawable_and_gc (ScrnInfoPtr scrn, DrawablePtr pDrawable, GCPtr pGC) +{ + FreeScratchGC (pGC); + FreeScratchPixmapHeader ((PixmapPtr) pDrawable); +} + +static void +xf86_dga_fill_rect(ScrnInfoPtr scrn, int x, int y, int w, int h, unsigned long color) +{ + GCPtr pGC; + DrawablePtr pDrawable; + XID vals[1]; + xRectangle r; + + if (!xf86_dga_get_drawable_and_gc (scrn, &pDrawable, &pGC)) + return; + vals[0] = color; + ChangeGC (pGC, GCForeground, vals); + ValidateGC (pDrawable, pGC); + r.x = x; + r.y = y; + r.width = w; + r.height = h; + pGC->ops->PolyFillRect (pDrawable, pGC, 1, &r); + xf86_dga_release_drawable_and_gc (scrn, pDrawable, pGC); +} + +static void +xf86_dga_sync(ScrnInfoPtr scrn) +{ + ScreenPtr pScreen = scrn->pScreen; + WindowPtr pRoot = WindowTable [pScreen->myNum]; + char buffer[4]; + + pScreen->GetImage (&pRoot->drawable, 0, 0, 1, 1, ZPixmap, ~0L, buffer); +} + +static void +xf86_dga_blit_rect(ScrnInfoPtr scrn, int srcx, int srcy, int w, int h, int dstx, int dsty) +{ + DrawablePtr pDrawable; + GCPtr pGC; + + if (!xf86_dga_get_drawable_and_gc (scrn, &pDrawable, &pGC)) + return; + ValidateGC (pDrawable, pGC); + pGC->ops->CopyArea (pDrawable, pDrawable, pGC, srcx, srcy, w, h, dstx, dsty); + xf86_dga_release_drawable_and_gc (scrn, pDrawable, pGC); +} + +static Bool +xf86_dga_open_framebuffer(ScrnInfoPtr scrn, + char **name, + unsigned char **mem, int *size, int *offset, int *flags) +{ + xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(scrn); + + *size = xf86_config->dga_stride * xf86_config->dga_height; + *mem = (unsigned char *) (xf86_config->dga_address); + *offset = 0; + *flags = DGA_NEED_ROOT; + + return TRUE; +} + +static void +xf86_dga_close_framebuffer(ScrnInfoPtr scrn) +{ +} + +static DGAFunctionRec xf86_dga_funcs = { + xf86_dga_open_framebuffer, + xf86_dga_close_framebuffer, + xf86_dga_set_mode, + xf86_dga_set_viewport, + xf86_dga_get_viewport, + xf86_dga_sync, + xf86_dga_fill_rect, + xf86_dga_blit_rect, + NULL +}; + +Bool +xf86DiDGAReInit (ScreenPtr pScreen) +{ + ScrnInfoPtr scrn = xf86Screens[pScreen->myNum]; + xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(scrn); + + if (!xf86_dga_get_modes (pScreen)) + return FALSE; + + return DGAReInitModes (pScreen, xf86_config->dga_modes, xf86_config->dga_nmode); +} + +Bool +xf86DiDGAInit (ScreenPtr pScreen, unsigned long dga_address) +{ + ScrnInfoPtr scrn = xf86Screens[pScreen->myNum]; + xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(scrn); + + xf86_config->dga_flags = 0; + xf86_config->dga_address = dga_address; + xf86_config->dga_width = scrn->virtualX; + xf86_config->dga_height = scrn->virtualY; + xf86_config->dga_stride = scrn->displayWidth * scrn->bitsPerPixel >> 3; + + if (!xf86_dga_get_modes (pScreen)) + return FALSE; + + return DGAInit(pScreen, &xf86_dga_funcs, xf86_config->dga_modes, xf86_config->dga_nmode); +} diff --git a/hw/xfree86/modes/xf86EdidModes.c b/hw/xfree86/modes/xf86EdidModes.c new file mode 100644 index 000000000..c4cf6870b --- /dev/null +++ b/hw/xfree86/modes/xf86EdidModes.c @@ -0,0 +1,490 @@ +/* + * Copyright 2006 Luc Verhaegen. + * + * 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 + * THE AUTHORS OR COPYRIGHT HOLDERS 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. + */ + +/** + * @file This is a copy of edid_modes.c from the X Server, for compatibility + * with old X Servers. + */ +#ifdef HAVE_XORG_CONFIG_H +#include +#else +#ifdef HAVE_CONFIG_H +#include +#endif +#endif + +#include "xf86.h" +#include "xf86DDC.h" +#include +#include "property.h" +#include "propertyst.h" +#include "xf86DDC.h" +#include "xf86Crtc.h" +#include +#include + +/* + * Quirks to work around broken EDID data from various monitors. + */ + +typedef enum { + DDC_QUIRK_NONE = 0, + /* Force detailed sync polarity to -h +v */ + DDC_QUIRK_DT_SYNC_HM_VP = 1 << 0, + /* First detailed mode is bogus, prefer largest mode at 60hz */ + DDC_QUIRK_PREFER_LARGE_60 = 1 << 1, + /* 135MHz clock is too high, drop a bit */ + DDC_QUIRK_135_CLOCK_TOO_HIGH = 1 << 2 +} ddc_quirk_t; + +static Bool quirk_dt_sync_hm_vp (int scrnIndex, xf86MonPtr DDC) +{ + /* Belinea 1924S1W */ + if (memcmp (DDC->vendor.name, "MAX", 4) == 0 && + DDC->vendor.prod_id == 1932) + return TRUE; + /* Belinea 10 20 30W */ + if (memcmp (DDC->vendor.name, "MAX", 4) == 0 && + DDC->vendor.prod_id == 2007) + return TRUE; + /* ViewSonic VX2025wm (bug #9941) */ + if (memcmp (DDC->vendor.name, "VSC", 4) == 0 && + DDC->vendor.prod_id == 58653) + return TRUE; + + return FALSE; +} + +static Bool quirk_prefer_large_60 (int scrnIndex, xf86MonPtr DDC) +{ + /* Belinea 10 15 55 */ + if (memcmp (DDC->vendor.name, "MAX", 4) == 0 && + DDC->vendor.prod_id == 1516) + return TRUE; + + return FALSE; +} + +static Bool quirk_135_clock_too_high (int scrnIndex, xf86MonPtr DDC) +{ + /* Envision Peripherals, Inc. EN-7100e. See bug #9550. */ + if (memcmp (DDC->vendor.name, "EPI", 4) == 0 && + DDC->vendor.prod_id == 59264) + return TRUE; + + return FALSE; +} + +typedef struct { + Bool (*detect) (int scrnIndex, xf86MonPtr DDC); + ddc_quirk_t quirk; + char *description; +} ddc_quirk_map_t; + +static const ddc_quirk_map_t ddc_quirks[] = { + { + quirk_dt_sync_hm_vp, DDC_QUIRK_DT_SYNC_HM_VP, + "Set detailed timing sync polarity to -h +v" + }, + { + quirk_prefer_large_60, DDC_QUIRK_PREFER_LARGE_60, + "Detailed timing is not preferred, use largest mode at 60Hz" + }, + { + quirk_135_clock_too_high, DDC_QUIRK_135_CLOCK_TOO_HIGH, + "Recommended 135MHz pixel clock is too high" + }, + { + NULL, DDC_QUIRK_NONE, + "No known quirks" + }, +}; + +/* + * TODO: + * - for those with access to the VESA DMT standard; review please. + */ +#define MODEPREFIX(name) NULL, NULL, name, 0,M_T_DRIVER +#define MODESUFFIX 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,FALSE,FALSE,0,NULL,0,0.0,0.0 + +static DisplayModeRec DDCEstablishedModes[17] = { + { MODEPREFIX("800x600"), 40000, 800, 840, 968, 1056, 0, 600, 601, 605, 628, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX }, /* 800x600@60Hz */ + { MODEPREFIX("800x600"), 36000, 800, 824, 896, 1024, 0, 600, 601, 603, 625, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX }, /* 800x600@56Hz */ + { MODEPREFIX("640x480"), 31500, 640, 656, 720, 840, 0, 480, 481, 484, 500, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* 640x480@75Hz */ + { MODEPREFIX("640x480"), 31500, 640, 664, 704, 832, 0, 480, 489, 491, 520, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* 640x480@72Hz */ + { MODEPREFIX("640x480"), 30240, 640, 704, 768, 864, 0, 480, 483, 486, 525, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* 640x480@67Hz */ + { MODEPREFIX("640x480"), 25200, 640, 656, 752, 800, 0, 480, 490, 492, 525, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* 640x480@60Hz */ + { MODEPREFIX("720x400"), 35500, 720, 738, 846, 900, 0, 400, 421, 423, 449, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* 720x400@88Hz */ + { MODEPREFIX("720x400"), 28320, 720, 738, 846, 900, 0, 400, 412, 414, 449, 0, V_NHSYNC | V_PVSYNC, MODESUFFIX }, /* 720x400@70Hz */ + { MODEPREFIX("1280x1024"), 135000, 1280, 1296, 1440, 1688, 0, 1024, 1025, 1028, 1066, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX }, /* 1280x1024@75Hz */ + { MODEPREFIX("1024x768"), 78800, 1024, 1040, 1136, 1312, 0, 768, 769, 772, 800, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX }, /* 1024x768@75Hz */ + { MODEPREFIX("1024x768"), 75000, 1024, 1048, 1184, 1328, 0, 768, 771, 777, 806, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* 1024x768@70Hz */ + { MODEPREFIX("1024x768"), 65000, 1024, 1048, 1184, 1344, 0, 768, 771, 777, 806, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* 1024x768@60Hz */ + { MODEPREFIX("1024x768"), 44900, 1024, 1032, 1208, 1264, 0, 768, 768, 776, 817, 0, V_PHSYNC | V_PVSYNC | V_INTERLACE, MODESUFFIX }, /* 1024x768@43Hz */ + { MODEPREFIX("832x624"), 57284, 832, 864, 928, 1152, 0, 624, 625, 628, 667, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* 832x624@75Hz */ + { MODEPREFIX("800x600"), 49500, 800, 816, 896, 1056, 0, 600, 601, 604, 625, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX }, /* 800x600@75Hz */ + { MODEPREFIX("800x600"), 50000, 800, 856, 976, 1040, 0, 600, 637, 643, 666, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX }, /* 800x600@72Hz */ + { MODEPREFIX("1152x864"), 108000, 1152, 1216, 1344, 1600, 0, 864, 865, 868, 900, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX }, /* 1152x864@75Hz */ +}; + +static DisplayModePtr +DDCModesFromEstablished(int scrnIndex, struct established_timings *timing, + ddc_quirk_t quirks) +{ + DisplayModePtr Modes = NULL, Mode = NULL; + CARD32 bits = (timing->t1) | (timing->t2 << 8) | + ((timing->t_manu & 0x80) << 9); + int i; + + for (i = 0; i < 17; i++) { + if (bits & (0x01 << i)) { + Mode = xf86DuplicateMode(&DDCEstablishedModes[i]); + Modes = xf86ModesAdd(Modes, Mode); + } + } + + return Modes; +} + +/* + * + */ +static DisplayModePtr +DDCModesFromStandardTiming(int scrnIndex, struct std_timings *timing, + ddc_quirk_t quirks) +{ + DisplayModePtr Modes = NULL, Mode = NULL; + int i; + + for (i = 0; i < STD_TIMINGS; i++) { + if (timing[i].hsize && timing[i].vsize && timing[i].refresh) { + Mode = xf86CVTMode(timing[i].hsize, timing[i].vsize, + timing[i].refresh, FALSE, FALSE); + Mode->type = M_T_DRIVER; + Modes = xf86ModesAdd(Modes, Mode); + } + } + + return Modes; +} + +/* + * + */ +static DisplayModePtr +DDCModeFromDetailedTiming(int scrnIndex, struct detailed_timings *timing, + int preferred, ddc_quirk_t quirks) +{ + DisplayModePtr Mode; + + /* We don't do stereo */ + if (timing->stereo) { + xf86DrvMsg(scrnIndex, X_INFO, + "%s: Ignoring: We don't handle stereo.\n", __func__); + return NULL; + } + + /* We only do seperate sync currently */ + if (timing->sync != 0x03) { + xf86DrvMsg(scrnIndex, X_INFO, + "%s: %dx%d Warning: We only handle seperate" + " sync.\n", __func__, timing->h_active, timing->v_active); + } + + Mode = xnfalloc(sizeof(DisplayModeRec)); + memset(Mode, 0, sizeof(DisplayModeRec)); + + Mode->type = M_T_DRIVER; + if (preferred) + Mode->type |= M_T_PREFERRED; + + if( ( quirks & DDC_QUIRK_135_CLOCK_TOO_HIGH ) && + timing->clock == 135000000 ) + Mode->Clock = 108880; + else + Mode->Clock = timing->clock / 1000.0; + + Mode->HDisplay = timing->h_active; + Mode->HSyncStart = timing->h_active + timing->h_sync_off; + Mode->HSyncEnd = Mode->HSyncStart + timing->h_sync_width; + Mode->HTotal = timing->h_active + timing->h_blanking; + + Mode->VDisplay = timing->v_active; + Mode->VSyncStart = timing->v_active + timing->v_sync_off; + Mode->VSyncEnd = Mode->VSyncStart + timing->v_sync_width; + Mode->VTotal = timing->v_active + timing->v_blanking; + + xf86SetModeDefaultName(Mode); + + /* We ignore h/v_size and h/v_border for now. */ + + if (timing->interlaced) + Mode->Flags |= V_INTERLACE; + + if (quirks & DDC_QUIRK_DT_SYNC_HM_VP) + Mode->Flags |= V_NHSYNC | V_PVSYNC; + else + { + if (timing->misc & 0x02) + Mode->Flags |= V_PHSYNC; + else + Mode->Flags |= V_NHSYNC; + + if (timing->misc & 0x01) + Mode->Flags |= V_PVSYNC; + else + Mode->Flags |= V_NVSYNC; + } + + return Mode; +} + +/* + * + */ +static void +DDCGuessRangesFromModes(int scrnIndex, MonPtr Monitor, DisplayModePtr Modes) +{ + DisplayModePtr Mode = Modes; + + if (!Monitor || !Modes) + return; + + /* set up the ranges for scanning through the modes */ + Monitor->nHsync = 1; + Monitor->hsync[0].lo = 1024.0; + Monitor->hsync[0].hi = 0.0; + + Monitor->nVrefresh = 1; + Monitor->vrefresh[0].lo = 1024.0; + Monitor->vrefresh[0].hi = 0.0; + + while (Mode) { + if (!Mode->HSync) + Mode->HSync = ((float) Mode->Clock ) / ((float) Mode->HTotal); + + if (!Mode->VRefresh) + Mode->VRefresh = (1000.0 * ((float) Mode->Clock)) / + ((float) (Mode->HTotal * Mode->VTotal)); + + if (Mode->HSync < Monitor->hsync[0].lo) + Monitor->hsync[0].lo = Mode->HSync; + + if (Mode->HSync > Monitor->hsync[0].hi) + Monitor->hsync[0].hi = Mode->HSync; + + if (Mode->VRefresh < Monitor->vrefresh[0].lo) + Monitor->vrefresh[0].lo = Mode->VRefresh; + + if (Mode->VRefresh > Monitor->vrefresh[0].hi) + Monitor->vrefresh[0].hi = Mode->VRefresh; + + Mode = Mode->next; + } +} + +DisplayModePtr +xf86DDCGetModes(int scrnIndex, xf86MonPtr DDC) +{ + int preferred, i; + DisplayModePtr Modes = NULL, Mode; + ddc_quirk_t quirks; + + xf86DrvMsg (scrnIndex, X_INFO, "EDID vendor \"%s\", prod id %d\n", + DDC->vendor.name, DDC->vendor.prod_id); + quirks = DDC_QUIRK_NONE; + for (i = 0; ddc_quirks[i].detect; i++) + if (ddc_quirks[i].detect (scrnIndex, DDC)) + { + xf86DrvMsg (scrnIndex, X_INFO, " EDID quirk: %s\n", + ddc_quirks[i].description); + quirks |= ddc_quirks[i].quirk; + } + + preferred = PREFERRED_TIMING_MODE(DDC->features.msc); + if (quirks & DDC_QUIRK_PREFER_LARGE_60) + preferred = 0; + + for (i = 0; i < DET_TIMINGS; i++) { + struct detailed_monitor_section *det_mon = &DDC->det_mon[i]; + + switch (det_mon->type) { + case DT: + Mode = DDCModeFromDetailedTiming(scrnIndex, + &det_mon->section.d_timings, + preferred, + quirks); + preferred = 0; + Modes = xf86ModesAdd(Modes, Mode); + break; + case DS_STD_TIMINGS: + Mode = DDCModesFromStandardTiming(scrnIndex, + det_mon->section.std_t, + quirks); + Modes = xf86ModesAdd(Modes, Mode); + break; + default: + break; + } + } + + /* Add established timings */ + Mode = DDCModesFromEstablished(scrnIndex, &DDC->timings1, quirks); + Modes = xf86ModesAdd(Modes, Mode); + + /* Add standard timings */ + Mode = DDCModesFromStandardTiming(scrnIndex, DDC->timings2, quirks); + Modes = xf86ModesAdd(Modes, Mode); + + if (quirks & DDC_QUIRK_PREFER_LARGE_60) + { + DisplayModePtr best = Modes; + for (Mode = Modes; Mode; Mode = Mode->next) + { + if (Mode == best) continue; + if (Mode->HDisplay * Mode->VDisplay > best->HDisplay * best->VDisplay) + { + best = Mode; + continue; + } + if (Mode->HDisplay * Mode->VDisplay == best->HDisplay * best->VDisplay) + { + double mode_refresh = xf86ModeVRefresh (Mode); + double best_refresh = xf86ModeVRefresh (best); + double mode_dist = fabs(mode_refresh - 60.0); + double best_dist = fabs(best_refresh - 60.0); + if (mode_dist < best_dist) + { + best = Mode; + continue; + } + } + } + if (best) + best->type |= M_T_PREFERRED; + } + return Modes; +} + +/* + * Fill out MonPtr with xf86MonPtr information. + */ +void +xf86DDCMonitorSet(int scrnIndex, MonPtr Monitor, xf86MonPtr DDC) +{ + DisplayModePtr Modes = NULL, Mode; + int i, clock; + Bool have_hsync = FALSE, have_vrefresh = FALSE; + + if (!Monitor || !DDC) + return; + + Monitor->DDC = DDC; + + Monitor->widthmm = 10 * DDC->features.hsize; + Monitor->heightmm = 10 * DDC->features.vsize; + + /* If this is a digital display, then we can use reduced blanking */ + if (DDC->features.input_type) + Monitor->reducedblanking = TRUE; + /* Allow the user to also enable this through config */ + + Modes = xf86DDCGetModes(scrnIndex, DDC); + + /* Skip EDID ranges if they were specified in the config file */ + have_hsync = (Monitor->nHsync != 0); + have_vrefresh = (Monitor->nVrefresh != 0); + + /* Go through the detailed monitor sections */ + for (i = 0; i < DET_TIMINGS; i++) { + switch (DDC->det_mon[i].type) { + case DS_RANGES: + if (!have_hsync) { + if (!Monitor->nHsync) + xf86DrvMsg(scrnIndex, X_INFO, + "Using EDID range info for horizontal sync\n"); + Monitor->hsync[Monitor->nHsync].lo = + DDC->det_mon[i].section.ranges.min_h; + Monitor->hsync[Monitor->nHsync].hi = + DDC->det_mon[i].section.ranges.max_h; + Monitor->nHsync++; + } else { + xf86DrvMsg(scrnIndex, X_INFO, + "Using hsync ranges from config file\n"); + } + + if (!have_vrefresh) { + if (!Monitor->nVrefresh) + xf86DrvMsg(scrnIndex, X_INFO, + "Using EDID range info for vertical refresh\n"); + Monitor->vrefresh[Monitor->nVrefresh].lo = + DDC->det_mon[i].section.ranges.min_v; + Monitor->vrefresh[Monitor->nVrefresh].hi = + DDC->det_mon[i].section.ranges.max_v; + Monitor->nVrefresh++; + } else { + xf86DrvMsg(scrnIndex, X_INFO, + "Using vrefresh ranges from config file\n"); + } + + clock = DDC->det_mon[i].section.ranges.max_clock * 1000; + if (clock > Monitor->maxPixClock) + Monitor->maxPixClock = clock; + + break; + default: + break; + } + } + + if (Modes) { + /* Print Modes */ + xf86DrvMsg(scrnIndex, X_INFO, "Printing DDC gathered Modelines:\n"); + + Mode = Modes; + while (Mode) { + xf86PrintModeline(scrnIndex, Mode); + Mode = Mode->next; + } + + /* Do we still need ranges to be filled in? */ + if (!Monitor->nHsync || !Monitor->nVrefresh) + DDCGuessRangesFromModes(scrnIndex, Monitor, Modes); + + /* look for last Mode */ + Mode = Modes; + + while (Mode->next) + Mode = Mode->next; + + /* add to MonPtr */ + if (Monitor->Modes) { + Monitor->Last->next = Modes; + Modes->prev = Monitor->Last; + Monitor->Last = Mode; + } else { + Monitor->Modes = Modes; + Monitor->Last = Mode; + } + } +} diff --git a/hw/xfree86/modes/xf86Modes.c b/hw/xfree86/modes/xf86Modes.c new file mode 100644 index 000000000..5b52bd76c --- /dev/null +++ b/hw/xfree86/modes/xf86Modes.c @@ -0,0 +1,664 @@ +/* -*- c-basic-offset: 4 -*- */ +/* $XdotOrg: xserver/xorg/hw/xfree86/common/xf86Mode.c,v 1.10 2006/03/07 16:00:57 libv Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86Mode.c,v 1.69 2003/10/08 14:58:28 dawes Exp $ */ +/* + * Copyright (c) 1997-2003 by The XFree86 Project, Inc. + * + * 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 COPYRIGHT HOLDER(S) OR AUTHOR(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 of the copyright holder(s) + * and author(s) shall not be used in advertising or otherwise to promote + * the sale, use or other dealings in this Software without prior written + * authorization from the copyright holder(s) and author(s). + */ + +#ifdef HAVE_XORG_CONFIG_H +#include +#else +#ifdef HAVE_CONFIG_H +#include +#endif +#endif + +#include "xf86Modes.h" +#include "xf86Priv.h" + +extern XF86ConfigPtr xf86configptr; + +/** + * @file this file contains symbols from xf86Mode.c and friends that are static + * there but we still want to use. We need to come up with better API here. + */ + +#if XORG_VERSION_CURRENT <= XORG_VERSION_NUMERIC(7,2,99,2,0) +/** + * Calculates the horizontal sync rate of a mode. + * + * Exact copy of xf86Mode.c's. + */ +double +xf86ModeHSync(DisplayModePtr mode) +{ + double hsync = 0.0; + + if (mode->HSync > 0.0) + hsync = mode->HSync; + else if (mode->HTotal > 0) + hsync = (float)mode->Clock / (float)mode->HTotal; + + return hsync; +} + +/** + * Calculates the vertical refresh rate of a mode. + * + * Exact copy of xf86Mode.c's. + */ +double +xf86ModeVRefresh(DisplayModePtr mode) +{ + double refresh = 0.0; + + if (mode->VRefresh > 0.0) + refresh = mode->VRefresh; + else if (mode->HTotal > 0 && mode->VTotal > 0) { + refresh = mode->Clock * 1000.0 / mode->HTotal / mode->VTotal; + if (mode->Flags & V_INTERLACE) + refresh *= 2.0; + if (mode->Flags & V_DBLSCAN) + refresh /= 2.0; + if (mode->VScan > 1) + refresh /= (float)(mode->VScan); + } + return refresh; +} + +int +xf86ModeWidth (DisplayModePtr mode, Rotation rotation) +{ + switch (rotation & 0xf) { + case RR_Rotate_0: + case RR_Rotate_180: + return mode->HDisplay; + case RR_Rotate_90: + case RR_Rotate_270: + return mode->VDisplay; + default: + return 0; + } +} + +int +xf86ModeHeight (DisplayModePtr mode, Rotation rotation) +{ + switch (rotation & 0xf) { + case RR_Rotate_0: + case RR_Rotate_180: + return mode->VDisplay; + case RR_Rotate_90: + case RR_Rotate_270: + return mode->HDisplay; + default: + return 0; + } +} + +/** Sets a default mode name of x on a mode. */ +void +xf86SetModeDefaultName(DisplayModePtr mode) +{ + if (mode->name != NULL) + xfree(mode->name); + + mode->name = XNFprintf("%dx%d", mode->HDisplay, mode->VDisplay); +} + +/* + * xf86SetModeCrtc + * + * Initialises the Crtc parameters for a mode. The initialisation includes + * adjustments for interlaced and double scan modes. + * + * Exact copy of xf86Mode.c's. + */ +void +xf86SetModeCrtc(DisplayModePtr p, int adjustFlags) +{ + if ((p == NULL) || ((p->type & M_T_CRTC_C) == M_T_BUILTIN)) + return; + + p->CrtcHDisplay = p->HDisplay; + p->CrtcHSyncStart = p->HSyncStart; + p->CrtcHSyncEnd = p->HSyncEnd; + p->CrtcHTotal = p->HTotal; + p->CrtcHSkew = p->HSkew; + p->CrtcVDisplay = p->VDisplay; + p->CrtcVSyncStart = p->VSyncStart; + p->CrtcVSyncEnd = p->VSyncEnd; + p->CrtcVTotal = p->VTotal; + if (p->Flags & V_INTERLACE) { + if (adjustFlags & INTERLACE_HALVE_V) { + p->CrtcVDisplay /= 2; + p->CrtcVSyncStart /= 2; + p->CrtcVSyncEnd /= 2; + p->CrtcVTotal /= 2; + } + /* Force interlaced modes to have an odd VTotal */ + /* maybe we should only do this when INTERLACE_HALVE_V is set? */ + p->CrtcVTotal |= 1; + } + + if (p->Flags & V_DBLSCAN) { + p->CrtcVDisplay *= 2; + p->CrtcVSyncStart *= 2; + p->CrtcVSyncEnd *= 2; + p->CrtcVTotal *= 2; + } + if (p->VScan > 1) { + p->CrtcVDisplay *= p->VScan; + p->CrtcVSyncStart *= p->VScan; + p->CrtcVSyncEnd *= p->VScan; + p->CrtcVTotal *= p->VScan; + } + p->CrtcVBlankStart = min(p->CrtcVSyncStart, p->CrtcVDisplay); + p->CrtcVBlankEnd = max(p->CrtcVSyncEnd, p->CrtcVTotal); + p->CrtcHBlankStart = min(p->CrtcHSyncStart, p->CrtcHDisplay); + p->CrtcHBlankEnd = max(p->CrtcHSyncEnd, p->CrtcHTotal); + + p->CrtcHAdjusted = FALSE; + p->CrtcVAdjusted = FALSE; +} + +/** + * Allocates and returns a copy of pMode, including pointers within pMode. + */ +DisplayModePtr +xf86DuplicateMode(DisplayModePtr pMode) +{ + DisplayModePtr pNew; + + pNew = xnfalloc(sizeof(DisplayModeRec)); + *pNew = *pMode; + pNew->next = NULL; + pNew->prev = NULL; + if (pNew->name == NULL) { + xf86SetModeDefaultName(pMode); + } else { + pNew->name = xnfstrdup(pMode->name); + } + + return pNew; +} + +/** + * Duplicates every mode in the given list and returns a pointer to the first + * mode. + * + * \param modeList doubly-linked mode list + */ +DisplayModePtr +xf86DuplicateModes(ScrnInfoPtr pScrn, DisplayModePtr modeList) +{ + DisplayModePtr first = NULL, last = NULL; + DisplayModePtr mode; + + for (mode = modeList; mode != NULL; mode = mode->next) { + DisplayModePtr new; + + new = xf86DuplicateMode(mode); + + /* Insert pNew into modeList */ + if (last) { + last->next = new; + new->prev = last; + } else { + first = new; + new->prev = NULL; + } + new->next = NULL; + last = new; + } + + return first; +} + +/** + * Returns true if the given modes should program to the same timings. + * + * This doesn't use Crtc values, as it might be used on ModeRecs without the + * Crtc values set. So, it's assumed that the other numbers are enough. + * + * This isn't in xf86Modes.c, but it might deserve to be there. + */ +Bool +xf86ModesEqual(DisplayModePtr pMode1, DisplayModePtr pMode2) +{ + if (pMode1->Clock == pMode2->Clock && + pMode1->HDisplay == pMode2->HDisplay && + pMode1->HSyncStart == pMode2->HSyncStart && + pMode1->HSyncEnd == pMode2->HSyncEnd && + pMode1->HTotal == pMode2->HTotal && + pMode1->HSkew == pMode2->HSkew && + pMode1->VDisplay == pMode2->VDisplay && + pMode1->VSyncStart == pMode2->VSyncStart && + pMode1->VSyncEnd == pMode2->VSyncEnd && + pMode1->VTotal == pMode2->VTotal && + pMode1->VScan == pMode2->VScan && + pMode1->Flags == pMode2->Flags) + { + return TRUE; + } else { + return FALSE; + } +} + +/* exact copy of xf86Mode.c */ +static void +add(char **p, char *new) +{ + *p = xnfrealloc(*p, strlen(*p) + strlen(new) + 2); + strcat(*p, " "); + strcat(*p, new); +} + +/** + * Print out a modeline. + * + * Convenient VRefresh printing was added, though, compared to xf86Mode.c + */ +void +xf86PrintModeline(int scrnIndex,DisplayModePtr mode) +{ + char tmp[256]; + char *flags = xnfcalloc(1, 1); + + if (mode->HSkew) { + snprintf(tmp, 256, "hskew %i", mode->HSkew); + add(&flags, tmp); + } + if (mode->VScan) { + snprintf(tmp, 256, "vscan %i", mode->VScan); + add(&flags, tmp); + } + if (mode->Flags & V_INTERLACE) add(&flags, "interlace"); + if (mode->Flags & V_CSYNC) add(&flags, "composite"); + if (mode->Flags & V_DBLSCAN) add(&flags, "doublescan"); + if (mode->Flags & V_BCAST) add(&flags, "bcast"); + if (mode->Flags & V_PHSYNC) add(&flags, "+hsync"); + if (mode->Flags & V_NHSYNC) add(&flags, "-hsync"); + if (mode->Flags & V_PVSYNC) add(&flags, "+vsync"); + if (mode->Flags & V_NVSYNC) add(&flags, "-vsync"); + if (mode->Flags & V_PCSYNC) add(&flags, "+csync"); + if (mode->Flags & V_NCSYNC) add(&flags, "-csync"); +#if 0 + if (mode->Flags & V_CLKDIV2) add(&flags, "vclk/2"); +#endif + xf86DrvMsg(scrnIndex, X_INFO, + "Modeline \"%s\"x%.01f %6.2f %i %i %i %i %i %i %i %i%s " + "(%.01f kHz)\n", + mode->name, mode->VRefresh, mode->Clock/1000., mode->HDisplay, + mode->HSyncStart, mode->HSyncEnd, mode->HTotal, + mode->VDisplay, mode->VSyncStart, mode->VSyncEnd, + mode->VTotal, flags, xf86ModeHSync(mode)); + xfree(flags); +} +#endif /* XORG_VERSION_CURRENT <= 7.2.99.2 */ + +/** + * Marks as bad any modes with unsupported flags. + * + * \param modeList doubly-linked or circular list of modes. + * \param flags flags supported by the driver. + * + * \bug only V_INTERLACE and V_DBLSCAN are supported. Is that enough? + * + * This is not in xf86Modes.c, but would be part of the proposed new API. + */ +void +xf86ValidateModesFlags(ScrnInfoPtr pScrn, DisplayModePtr modeList, + int flags) +{ + DisplayModePtr mode; + + for (mode = modeList; mode != NULL; mode = mode->next) { + if (mode->Flags & V_INTERLACE && !(flags & V_INTERLACE)) + mode->status = MODE_NO_INTERLACE; + if (mode->Flags & V_DBLSCAN && !(flags & V_DBLSCAN)) + mode->status = MODE_NO_DBLESCAN; + } +} + +/** + * Marks as bad any modes extending beyond the given max X, Y, or pitch. + * + * \param modeList doubly-linked or circular list of modes. + * + * This is not in xf86Modes.c, but would be part of the proposed new API. + */ +void +xf86ValidateModesSize(ScrnInfoPtr pScrn, DisplayModePtr modeList, + int maxX, int maxY, int maxPitch) +{ + DisplayModePtr mode; + + for (mode = modeList; mode != NULL; mode = mode->next) { + if (maxPitch > 0 && mode->HDisplay > maxPitch) + mode->status = MODE_BAD_WIDTH; + + if (maxX > 0 && mode->HDisplay > maxX) + mode->status = MODE_VIRTUAL_X; + + if (maxY > 0 && mode->VDisplay > maxY) + mode->status = MODE_VIRTUAL_Y; + + if (mode->next == modeList) + break; + } +} + +/** + * Marks as bad any modes that aren't supported by the given monitor's + * hsync and vrefresh ranges. + * + * \param modeList doubly-linked or circular list of modes. + * + * This is not in xf86Modes.c, but would be part of the proposed new API. + */ +void +xf86ValidateModesSync(ScrnInfoPtr pScrn, DisplayModePtr modeList, + MonPtr mon) +{ + DisplayModePtr mode; + + for (mode = modeList; mode != NULL; mode = mode->next) { + Bool bad; + int i; + + bad = TRUE; + for (i = 0; i < mon->nHsync; i++) { + if (xf86ModeHSync(mode) >= mon->hsync[i].lo && + xf86ModeHSync(mode) <= mon->hsync[i].hi) + { + bad = FALSE; + } + } + if (bad) + mode->status = MODE_HSYNC; + + bad = TRUE; + for (i = 0; i < mon->nVrefresh; i++) { + if (xf86ModeVRefresh(mode) >= mon->vrefresh[i].lo && + xf86ModeVRefresh(mode) <= mon->vrefresh[i].hi) + { + bad = FALSE; + } + } + if (bad) + mode->status = MODE_VSYNC; + + if (mode->next == modeList) + break; + } +} + +/** + * Marks as bad any modes extending beyond outside of the given clock ranges. + * + * \param modeList doubly-linked or circular list of modes. + * \param min pointer to minimums of clock ranges + * \param max pointer to maximums of clock ranges + * \param n_ranges number of ranges. + * + * This is not in xf86Modes.c, but would be part of the proposed new API. + */ +void +xf86ValidateModesClocks(ScrnInfoPtr pScrn, DisplayModePtr modeList, + int *min, int *max, int n_ranges) +{ + DisplayModePtr mode; + int i; + + for (mode = modeList; mode != NULL; mode = mode->next) { + Bool good = FALSE; + for (i = 0; i < n_ranges; i++) { + if (mode->Clock >= min[i] && mode->Clock <= max[i]) { + good = TRUE; + break; + } + } + if (!good) + mode->status = MODE_CLOCK_RANGE; + } +} + +/** + * If the user has specified a set of mode names to use, mark as bad any modes + * not listed. + * + * The user mode names specified are prefixes to names of modes, so "1024x768" + * will match modes named "1024x768", "1024x768x75", "1024x768-good", but + * "1024x768x75" would only match "1024x768x75" from that list. + * + * MODE_BAD is used as the rejection flag, for lack of a better flag. + * + * \param modeList doubly-linked or circular list of modes. + * + * This is not in xf86Modes.c, but would be part of the proposed new API. + */ +void +xf86ValidateModesUserConfig(ScrnInfoPtr pScrn, DisplayModePtr modeList) +{ + DisplayModePtr mode; + + if (pScrn->display->modes[0] == NULL) + return; + + for (mode = modeList; mode != NULL; mode = mode->next) { + int i; + Bool good = FALSE; + + for (i = 0; pScrn->display->modes[i] != NULL; i++) { + if (strncmp(pScrn->display->modes[i], mode->name, + strlen(pScrn->display->modes[i])) == 0) { + good = TRUE; + break; + } + } + if (!good) + mode->status = MODE_BAD; + } +} + + +/** + * Frees any modes from the list with a status other than MODE_OK. + * + * \param modeList pointer to a doubly-linked or circular list of modes. + * \param verbose determines whether the reason for mode invalidation is + * printed. + * + * This is not in xf86Modes.c, but would be part of the proposed new API. + */ +void +xf86PruneInvalidModes(ScrnInfoPtr pScrn, DisplayModePtr *modeList, + Bool verbose) +{ + DisplayModePtr mode; + + for (mode = *modeList; mode != NULL;) { + DisplayModePtr next = mode->next, first = *modeList; + + if (mode->status != MODE_OK) { + if (verbose) { + char *type = ""; + if (mode->type & M_T_BUILTIN) + type = "built-in "; + else if (mode->type & M_T_DEFAULT) + type = "default "; + xf86DrvMsg(pScrn->scrnIndex, X_INFO, + "Not using %smode \"%s\" (%s)\n", type, mode->name, + xf86ModeStatusToString(mode->status)); + } + xf86DeleteMode(modeList, mode); + } + + if (next == first) + break; + mode = next; + } +} + +/** + * Adds the new mode into the mode list, and returns the new list + * + * \param modes doubly-linked mode list. + */ +DisplayModePtr +xf86ModesAdd(DisplayModePtr modes, DisplayModePtr new) +{ + if (modes == NULL) + return new; + + if (new) { + DisplayModePtr mode = modes; + + while (mode->next) + mode = mode->next; + + mode->next = new; + new->prev = mode; + } + + return modes; +} + +/** + * Build a mode list from a list of config file modes + */ +static DisplayModePtr +xf86GetConfigModes (XF86ConfModeLinePtr conf_mode) +{ + DisplayModePtr head = NULL, prev = NULL, mode; + + for (; conf_mode; conf_mode = (XF86ConfModeLinePtr) conf_mode->list.next) + { + mode = xcalloc(1, sizeof(DisplayModeRec)); + if (!mode) + continue; + mode->name = xstrdup(conf_mode->ml_identifier); + if (!mode->name) + { + xfree (mode); + continue; + } + mode->type = 0; + mode->Clock = conf_mode->ml_clock; + mode->HDisplay = conf_mode->ml_hdisplay; + mode->HSyncStart = conf_mode->ml_hsyncstart; + mode->HSyncEnd = conf_mode->ml_hsyncend; + mode->HTotal = conf_mode->ml_htotal; + mode->VDisplay = conf_mode->ml_vdisplay; + mode->VSyncStart = conf_mode->ml_vsyncstart; + mode->VSyncEnd = conf_mode->ml_vsyncend; + mode->VTotal = conf_mode->ml_vtotal; + mode->Flags = conf_mode->ml_flags; + mode->HSkew = conf_mode->ml_hskew; + mode->VScan = conf_mode->ml_vscan; + + mode->prev = prev; + mode->next = NULL; + if (prev) + prev->next = mode; + else + head = mode; + prev = mode; + } + return head; +} + +/** + * Build a mode list from a monitor configuration + */ +DisplayModePtr +xf86GetMonitorModes (ScrnInfoPtr pScrn, XF86ConfMonitorPtr conf_monitor) +{ + DisplayModePtr modes = NULL; + XF86ConfModesLinkPtr modes_link; + + if (!conf_monitor) + return NULL; + + /* + * first we collect the mode lines from the UseModes directive + */ + for (modes_link = conf_monitor->mon_modes_sect_lst; + modes_link; + modes_link = modes_link->list.next) + { + /* If this modes link hasn't been resolved, go look it up now */ + if (!modes_link->ml_modes) + modes_link->ml_modes = xf86findModes (modes_link->ml_modes_str, + xf86configptr->conf_modes_lst); + if (modes_link->ml_modes) + modes = xf86ModesAdd (modes, + xf86GetConfigModes (modes_link->ml_modes->mon_modeline_lst)); + } + + return xf86ModesAdd (modes, + xf86GetConfigModes (conf_monitor->mon_modeline_lst)); +} + +/** + * Build a mode list containing all of the default modes + */ +DisplayModePtr +xf86GetDefaultModes (Bool interlaceAllowed, Bool doubleScanAllowed) +{ + DisplayModePtr head = NULL, prev = NULL, mode; + int i; + + for (i = 0; xf86DefaultModes[i].name != NULL; i++) + { + DisplayModePtr defMode = &xf86DefaultModes[i]; + + if (!interlaceAllowed && (defMode->Flags & V_INTERLACE)) + continue; + if (!doubleScanAllowed && (defMode->Flags & V_DBLSCAN)) + continue; + + mode = xalloc(sizeof(DisplayModeRec)); + if (!mode) + continue; + memcpy(mode,&xf86DefaultModes[i],sizeof(DisplayModeRec)); + mode->name = xstrdup(xf86DefaultModes[i].name); + if (!mode->name) + { + xfree (mode); + continue; + } + mode->prev = prev; + mode->next = NULL; + if (prev) + prev->next = mode; + else + head = mode; + prev = mode; + } + return head; +} diff --git a/hw/xfree86/modes/xf86Modes.h b/hw/xfree86/modes/xf86Modes.h new file mode 100644 index 000000000..2bd4edeba --- /dev/null +++ b/hw/xfree86/modes/xf86Modes.h @@ -0,0 +1,98 @@ +/* + * Copyright © 2006 Intel Corporation + * + * 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 (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 NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS 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. + * + * Authors: + * Eric Anholt + * + */ + +#ifndef _XF86MODES_H_ +#define _XF86MODES_H_ + +#include +#include +#include + +#include "xf86.h" +#include "xorgVersion.h" +#include "edid.h" +#include "xf86Parser.h" +#if XF86_MODES_RENAME +#include "xf86Rename.h" +#endif + +double xf86ModeHSync(DisplayModePtr mode); +double xf86ModeVRefresh(DisplayModePtr mode); + +int +xf86ModeWidth (DisplayModePtr mode, Rotation rotation); + +int +xf86ModeHeight (DisplayModePtr mode, Rotation rotation); + +DisplayModePtr xf86DuplicateMode(DisplayModePtr pMode); +DisplayModePtr xf86DuplicateModes(ScrnInfoPtr pScrn, + DisplayModePtr modeList); +void xf86SetModeDefaultName(DisplayModePtr mode); +void xf86SetModeCrtc(DisplayModePtr p, int adjustFlags); +Bool xf86ModesEqual(DisplayModePtr pMode1, DisplayModePtr pMode2); +void xf86PrintModeline(int scrnIndex,DisplayModePtr mode); +DisplayModePtr xf86ModesAdd(DisplayModePtr modes, DisplayModePtr new); + +DisplayModePtr xf86DDCGetModes(int scrnIndex, xf86MonPtr DDC); +DisplayModePtr xf86CVTMode(int HDisplay, int VDisplay, float VRefresh, + Bool Reduced, Bool Interlaced); + +void +xf86ValidateModesFlags(ScrnInfoPtr pScrn, DisplayModePtr modeList, + int flags); + +void +xf86ValidateModesClocks(ScrnInfoPtr pScrn, DisplayModePtr modeList, + int *min, int *max, int n_ranges); + +void +xf86ValidateModesSize(ScrnInfoPtr pScrn, DisplayModePtr modeList, + int maxX, int maxY, int maxPitch); + +void +xf86ValidateModesSync(ScrnInfoPtr pScrn, DisplayModePtr modeList, + MonPtr mon); + +void +xf86PruneInvalidModes(ScrnInfoPtr pScrn, DisplayModePtr *modeList, + Bool verbose); + +void +xf86ValidateModesFlags(ScrnInfoPtr pScrn, DisplayModePtr modeList, + int flags); + +void +xf86ValidateModesUserConfig(ScrnInfoPtr pScrn, DisplayModePtr modeList); + +DisplayModePtr +xf86GetMonitorModes (ScrnInfoPtr pScrn, XF86ConfMonitorPtr conf_monitor); + +DisplayModePtr +xf86GetDefaultModes (Bool interlaceAllowed, Bool doubleScanAllowed); + +#endif /* _XF86MODES_H_ */ diff --git a/hw/xfree86/modes/xf86RandR12.c b/hw/xfree86/modes/xf86RandR12.c new file mode 100644 index 000000000..052d12aa3 --- /dev/null +++ b/hw/xfree86/modes/xf86RandR12.c @@ -0,0 +1,960 @@ +/* $XdotOrg: xc/programs/Xserver/hw/xfree86/common/xf86RandR.c,v 1.3 2004/07/30 21:53:09 eich Exp $ */ +/* + * $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86RandR.c,v 1.7tsi Exp $ + * + * Copyright © 2002 Keith Packard, member of The XFree86 Project, Inc. + * + * Permission to use, copy, modify, distribute, and sell this software and its + * documentation for any purpose is hereby granted without fee, provided that + * the above copyright notice appear in all copies and that both that copyright + * notice and this permission notice appear in supporting documentation, and + * that the name of the copyright holders not be used in advertising or + * publicity pertaining to distribution of the software without specific, + * written prior permission. The copyright holders make no representations + * about the suitability of this software for any purpose. It is provided "as + * is" without express or implied warranty. + * + * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO + * EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, + * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * OF THIS SOFTWARE. + */ + +#ifdef HAVE_XORG_CONFIG_H +#include +#else +#ifdef HAVE_CONFIG_H +#include +#endif +#endif + +#include "xf86.h" +#include "os.h" +#include "mibank.h" +#include "globals.h" +#include "xf86.h" +#include "xf86Priv.h" +#include "xf86DDC.h" +#include "mipointer.h" +#include "windowstr.h" +#include +#include + +#include "xf86Crtc.h" +#include "xf86RandR12.h" + +typedef struct _xf86RandR12Info { + int virtualX; + int virtualY; + int mmWidth; + int mmHeight; + int maxX; + int maxY; + Rotation rotation; /* current mode */ + Rotation supported_rotations; /* driver supported */ +} XF86RandRInfoRec, *XF86RandRInfoPtr; + +#ifdef RANDR_12_INTERFACE +static Bool xf86RandR12Init12 (ScreenPtr pScreen); +static Bool xf86RandR12CreateScreenResources12 (ScreenPtr pScreen); +#endif + +static int xf86RandR12Index; +static int xf86RandR12Generation; + +#define XF86RANDRINFO(p) \ + ((XF86RandRInfoPtr)(p)->devPrivates[xf86RandR12Index].ptr) + +static int +xf86RandR12ModeRefresh (DisplayModePtr mode) +{ + if (mode->VRefresh) + return (int) (mode->VRefresh + 0.5); + else + return (int) (mode->Clock * 1000.0 / mode->HTotal / mode->VTotal + 0.5); +} + +static Bool +xf86RandR12GetInfo (ScreenPtr pScreen, Rotation *rotations) +{ + RRScreenSizePtr pSize; + ScrnInfoPtr scrp = XF86SCRNINFO(pScreen); + XF86RandRInfoPtr randrp = XF86RANDRINFO(pScreen); + DisplayModePtr mode; + int refresh0 = 60; + int maxX = 0, maxY = 0; + + *rotations = randrp->supported_rotations; + + if (randrp->virtualX == -1 || randrp->virtualY == -1) + { + randrp->virtualX = scrp->virtualX; + randrp->virtualY = scrp->virtualY; + } + + /* Re-probe the outputs for new monitors or modes */ + xf86ProbeOutputModes (scrp, 0, 0); + xf86SetScrnInfoModes (scrp); + xf86DiDGAReInit (pScreen); + + for (mode = scrp->modes; ; mode = mode->next) + { + int refresh = xf86RandR12ModeRefresh (mode); + if (randrp->maxX == 0 || randrp->maxY == 0) + { + if (maxX < mode->HDisplay) + maxX = mode->HDisplay; + if (maxY < mode->VDisplay) + maxY = mode->VDisplay; + } + if (mode == scrp->modes) + refresh0 = refresh; + pSize = RRRegisterSize (pScreen, + mode->HDisplay, mode->VDisplay, + randrp->mmWidth, randrp->mmHeight); + if (!pSize) + return FALSE; + RRRegisterRate (pScreen, pSize, refresh); + + if (xf86ModesEqual(mode, scrp->currentMode) && + mode->HDisplay == scrp->virtualX && + mode->VDisplay == scrp->virtualY) + { + RRSetCurrentConfig (pScreen, randrp->rotation, refresh, pSize); + } + if (mode->next == scrp->modes) + break; + } + + if (randrp->maxX == 0 || randrp->maxY == 0) + { + randrp->maxX = maxX; + randrp->maxY = maxY; + } + + if (scrp->currentMode->HDisplay != randrp->virtualX || + scrp->currentMode->VDisplay != randrp->virtualY) + { + pSize = RRRegisterSize (pScreen, + randrp->virtualX, randrp->virtualY, + randrp->mmWidth, + randrp->mmHeight); + if (!pSize) + return FALSE; + RRRegisterRate (pScreen, pSize, refresh0); + if (scrp->virtualX == randrp->virtualX && + scrp->virtualY == randrp->virtualY) + { + RRSetCurrentConfig (pScreen, randrp->rotation, refresh0, pSize); + } + } + + return TRUE; +} + +static Bool +xf86RandR12SetMode (ScreenPtr pScreen, + DisplayModePtr mode, + Bool useVirtual, + int mmWidth, + int mmHeight) +{ + ScrnInfoPtr scrp = XF86SCRNINFO(pScreen); + XF86RandRInfoPtr randrp = XF86RANDRINFO(pScreen); + int oldWidth = pScreen->width; + int oldHeight = pScreen->height; + int oldmmWidth = pScreen->mmWidth; + int oldmmHeight = pScreen->mmHeight; + WindowPtr pRoot = WindowTable[pScreen->myNum]; + DisplayModePtr currentMode = NULL; + Bool ret = TRUE; + PixmapPtr pspix = NULL; + + if (pRoot) + (*scrp->EnableDisableFBAccess) (pScreen->myNum, FALSE); + if (useVirtual) + { + scrp->virtualX = randrp->virtualX; + scrp->virtualY = randrp->virtualY; + } + else + { + scrp->virtualX = mode->HDisplay; + scrp->virtualY = mode->VDisplay; + } + + if(randrp->rotation & (RR_Rotate_90 | RR_Rotate_270)) + { + /* If the screen is rotated 90 or 270 degrees, swap the sizes. */ + pScreen->width = scrp->virtualY; + pScreen->height = scrp->virtualX; + pScreen->mmWidth = mmHeight; + pScreen->mmHeight = mmWidth; + } + else + { + pScreen->width = scrp->virtualX; + pScreen->height = scrp->virtualY; + pScreen->mmWidth = mmWidth; + pScreen->mmHeight = mmHeight; + } + if (scrp->currentMode == mode) { + /* Save current mode */ + currentMode = scrp->currentMode; + /* Reset, just so we ensure the drivers SwitchMode is called */ + scrp->currentMode = NULL; + } + /* + * We know that if the driver failed to SwitchMode to the rotated + * version, then it should revert back to it's prior mode. + */ + if (!xf86SwitchMode (pScreen, mode)) + { + ret = FALSE; + scrp->virtualX = pScreen->width = oldWidth; + scrp->virtualY = pScreen->height = oldHeight; + pScreen->mmWidth = oldmmWidth; + pScreen->mmHeight = oldmmHeight; + scrp->currentMode = currentMode; + } + /* + * Get the new Screen pixmap ptr as SwitchMode might have called + * ModifyPixmapHeader and xf86EnableDisableFBAccess will put it back... + * Unfortunately. + */ + pspix = (*pScreen->GetScreenPixmap) (pScreen); + if (pspix->devPrivate.ptr) + scrp->pixmapPrivate = pspix->devPrivate; + + /* + * Make sure the layout is correct + */ + xf86ReconfigureLayout(); + + /* + * Make sure the whole screen is visible + */ + xf86SetViewport (pScreen, pScreen->width, pScreen->height); + xf86SetViewport (pScreen, 0, 0); + if (pRoot) + (*scrp->EnableDisableFBAccess) (pScreen->myNum, TRUE); + return ret; +} + +Bool +xf86RandR12SetConfig (ScreenPtr pScreen, + Rotation rotation, + int rate, + RRScreenSizePtr pSize) +{ + ScrnInfoPtr scrp = XF86SCRNINFO(pScreen); + XF86RandRInfoPtr randrp = XF86RANDRINFO(pScreen); + DisplayModePtr mode; + int px, py; + Bool useVirtual = FALSE; + int maxX = 0, maxY = 0; + Rotation oldRotation = randrp->rotation; + + randrp->rotation = rotation; + + if (randrp->virtualX == -1 || randrp->virtualY == -1) + { + randrp->virtualX = scrp->virtualX; + randrp->virtualY = scrp->virtualY; + } + + miPointerPosition (&px, &py); + for (mode = scrp->modes; ; mode = mode->next) + { + if (randrp->maxX == 0 || randrp->maxY == 0) + { + if (maxX < mode->HDisplay) + maxX = mode->HDisplay; + if (maxY < mode->VDisplay) + maxY = mode->VDisplay; + } + if (mode->HDisplay == pSize->width && + mode->VDisplay == pSize->height && + (rate == 0 || xf86RandR12ModeRefresh (mode) == rate)) + break; + if (mode->next == scrp->modes) + { + if (pSize->width == randrp->virtualX && + pSize->height == randrp->virtualY) + { + mode = scrp->modes; + useVirtual = TRUE; + break; + } + if (randrp->maxX == 0 || randrp->maxY == 0) + { + randrp->maxX = maxX; + randrp->maxY = maxY; + } + return FALSE; + } + } + + if (randrp->maxX == 0 || randrp->maxY == 0) + { + randrp->maxX = maxX; + randrp->maxY = maxY; + } + + if (!xf86RandR12SetMode (pScreen, mode, useVirtual, pSize->mmWidth, + pSize->mmHeight)) { + randrp->rotation = oldRotation; + return FALSE; + } + + /* + * Move the cursor back where it belongs; SwitchMode repositions it + */ + if (pScreen == miPointerCurrentScreen ()) + { + px = (px >= pScreen->width ? (pScreen->width - 1) : px); + py = (py >= pScreen->height ? (pScreen->height - 1) : py); + + xf86SetViewport(pScreen, px, py); + + (*pScreen->SetCursorPosition) (pScreen, px, py, FALSE); + } + + return TRUE; +} + +static Bool +xf86RandR12ScreenSetSize (ScreenPtr pScreen, + CARD16 width, + CARD16 height, + CARD32 mmWidth, + CARD32 mmHeight) +{ + XF86RandRInfoPtr randrp = XF86RANDRINFO(pScreen); + ScrnInfoPtr pScrn = XF86SCRNINFO(pScreen); + xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(pScrn); + WindowPtr pRoot = WindowTable[pScreen->myNum]; + Bool ret = FALSE; + + if (randrp->virtualX == -1 || randrp->virtualY == -1) + { + randrp->virtualX = pScrn->virtualX; + randrp->virtualY = pScrn->virtualY; + } + if (pRoot) + (*pScrn->EnableDisableFBAccess) (pScreen->myNum, FALSE); + + /* Let the driver update virtualX and virtualY */ + if (!(*config->funcs->resize)(pScrn, width, height)) + goto finish; + + ret = TRUE; + + pScreen->width = width; + pScreen->height = height; + pScreen->mmWidth = mmWidth; + pScreen->mmHeight = mmHeight; + + xf86SetViewport (pScreen, pScreen->width-1, pScreen->height-1); + xf86SetViewport (pScreen, 0, 0); + +finish: + if (pRoot) + (*pScrn->EnableDisableFBAccess) (pScreen->myNum, TRUE); +#if RANDR_12_INTERFACE + if (WindowTable[pScreen->myNum] && ret) + RRScreenSizeNotify (pScreen); +#endif + return ret; +} + +Rotation +xf86RandR12GetRotation(ScreenPtr pScreen) +{ + XF86RandRInfoPtr randrp = XF86RANDRINFO(pScreen); + + return randrp->rotation; +} + +Bool +xf86RandR12CreateScreenResources (ScreenPtr pScreen) +{ + ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; + xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(pScrn); + XF86RandRInfoPtr randrp = XF86RANDRINFO(pScreen); + int c; + int width, height; + int mmWidth, mmHeight; +#ifdef PANORAMIX + /* XXX disable RandR when using Xinerama */ + if (!noPanoramiXExtension) + return TRUE; +#endif + + /* + * Compute size of screen + */ + width = 0; height = 0; + for (c = 0; c < config->num_crtc; c++) + { + xf86CrtcPtr crtc = config->crtc[c]; + int crtc_width = crtc->x + xf86ModeWidth (&crtc->mode, crtc->rotation); + int crtc_height = crtc->y + xf86ModeHeight (&crtc->mode, crtc->rotation); + + if (crtc->enabled && crtc_width > width) + width = crtc_width; + if (crtc->enabled && crtc_height > height) + height = crtc_height; + } + + if (width && height) + { + /* + * Compute physical size of screen + */ + if (monitorResolution) + { + mmWidth = width * 25.4 / monitorResolution; + mmHeight = height * 25.4 / monitorResolution; + } + else + { + mmWidth = pScreen->mmWidth; + mmHeight = pScreen->mmHeight; + } + xf86DrvMsg(pScrn->scrnIndex, X_INFO, + "Setting screen physical size to %d x %d\n", + mmWidth, mmHeight); + xf86RandR12ScreenSetSize (pScreen, + width, + height, + mmWidth, + mmHeight); + } + + if (randrp->virtualX == -1 || randrp->virtualY == -1) + { + randrp->virtualX = pScrn->virtualX; + randrp->virtualY = pScrn->virtualY; + } + xf86CrtcSetScreenSubpixelOrder (pScreen); +#if RANDR_12_INTERFACE + if (xf86RandR12CreateScreenResources12 (pScreen)) + return TRUE; +#endif + return TRUE; +} + + +Bool +xf86RandR12Init (ScreenPtr pScreen) +{ + rrScrPrivPtr rp; + XF86RandRInfoPtr randrp; + +#ifdef PANORAMIX + /* XXX disable RandR when using Xinerama */ + if (!noPanoramiXExtension) + return TRUE; +#endif + if (xf86RandR12Generation != serverGeneration) + { + xf86RandR12Index = AllocateScreenPrivateIndex(); + xf86RandR12Generation = serverGeneration; + } + + randrp = xalloc (sizeof (XF86RandRInfoRec)); + if (!randrp) + return FALSE; + + if (!RRScreenInit(pScreen)) + { + xfree (randrp); + return FALSE; + } + rp = rrGetScrPriv(pScreen); + rp->rrGetInfo = xf86RandR12GetInfo; + rp->rrSetConfig = xf86RandR12SetConfig; + + randrp->virtualX = -1; + randrp->virtualY = -1; + randrp->mmWidth = pScreen->mmWidth; + randrp->mmHeight = pScreen->mmHeight; + + randrp->rotation = RR_Rotate_0; /* initial rotated mode */ + + randrp->supported_rotations = RR_Rotate_0; + + randrp->maxX = randrp->maxY = 0; + + pScreen->devPrivates[xf86RandR12Index].ptr = randrp; + +#if RANDR_12_INTERFACE + if (!xf86RandR12Init12 (pScreen)) + return FALSE; +#endif + return TRUE; +} + +void +xf86RandR12SetRotations (ScreenPtr pScreen, Rotation rotations) +{ + XF86RandRInfoPtr randrp = XF86RANDRINFO(pScreen); +#if RANDR_12_INTERFACE + ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; + int c; + xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(pScrn); + + for (c = 0; c < config->num_crtc; c++) { + xf86CrtcPtr crtc = config->crtc[c]; + + RRCrtcSetRotations (crtc->randr_crtc, rotations); + } +#endif + randrp->supported_rotations = rotations; +} + +void +xf86RandR12GetOriginalVirtualSize(ScrnInfoPtr pScrn, int *x, int *y) +{ + ScreenPtr pScreen = screenInfo.screens[pScrn->scrnIndex]; + + if (xf86RandR12Generation != serverGeneration || + XF86RANDRINFO(pScreen)->virtualX == -1) + { + *x = pScrn->virtualX; + *y = pScrn->virtualY; + } else { + XF86RandRInfoPtr randrp = XF86RANDRINFO(pScreen); + + *x = randrp->virtualX; + *y = randrp->virtualY; + } +} + +#if RANDR_12_INTERFACE +static Bool +xf86RandR12CrtcNotify (RRCrtcPtr randr_crtc) +{ + ScreenPtr pScreen = randr_crtc->pScreen; + ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; + xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(pScrn); + RRModePtr randr_mode = NULL; + int x; + int y; + Rotation rotation; + int numOutputs; + RROutputPtr *randr_outputs; + RROutputPtr randr_output; + xf86CrtcPtr crtc = randr_crtc->devPrivate; + xf86OutputPtr output; + int i, j; + DisplayModePtr mode = &crtc->mode; + Bool ret; + + randr_outputs = ALLOCATE_LOCAL(config->num_output * sizeof (RROutputPtr)); + if (!randr_outputs) + return FALSE; + x = crtc->x; + y = crtc->y; + rotation = crtc->rotation; + numOutputs = 0; + randr_mode = NULL; + for (i = 0; i < config->num_output; i++) + { + output = config->output[i]; + if (output->crtc == crtc) + { + randr_output = output->randr_output; + randr_outputs[numOutputs++] = randr_output; + /* + * We make copies of modes, so pointer equality + * isn't sufficient + */ + for (j = 0; j < randr_output->numModes; j++) + { + DisplayModePtr outMode = randr_output->modes[j]->devPrivate; + if (xf86ModesEqual(mode, outMode)) + { + randr_mode = randr_output->modes[j]; + break; + } + } + } + } + ret = RRCrtcNotify (randr_crtc, randr_mode, x, y, + rotation, numOutputs, randr_outputs); + DEALLOCATE_LOCAL(randr_outputs); + return ret; +} + +static Bool +xf86RandR12CrtcSet (ScreenPtr pScreen, + RRCrtcPtr randr_crtc, + RRModePtr randr_mode, + int x, + int y, + Rotation rotation, + int num_randr_outputs, + RROutputPtr *randr_outputs) +{ + ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; + xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(pScrn); + xf86CrtcPtr crtc = randr_crtc->devPrivate; + DisplayModePtr mode = randr_mode ? randr_mode->devPrivate : NULL; + Bool changed = FALSE; + int o, ro; + xf86CrtcPtr *save_crtcs; + Bool save_enabled = crtc->enabled; + + save_crtcs = ALLOCATE_LOCAL(config->num_crtc * sizeof (xf86CrtcPtr)); + if ((mode != NULL) != crtc->enabled) + changed = TRUE; + else if (mode && !xf86ModesEqual (&crtc->mode, mode)) + changed = TRUE; + + if (rotation != crtc->rotation) + changed = TRUE; + + if (x != crtc->x || y != crtc->y) + changed = TRUE; + for (o = 0; o < config->num_output; o++) + { + xf86OutputPtr output = config->output[o]; + xf86CrtcPtr new_crtc; + + save_crtcs[o] = output->crtc; + + if (output->crtc == crtc) + new_crtc = NULL; + else + new_crtc = output->crtc; + for (ro = 0; ro < num_randr_outputs; ro++) + if (output->randr_output == randr_outputs[ro]) + { + new_crtc = crtc; + break; + } + if (new_crtc != output->crtc) + { + changed = TRUE; + output->crtc = new_crtc; + } + } + /* XXX need device-independent mode setting code through an API */ + if (changed) + { + crtc->enabled = mode != NULL; + + if (mode) + { + if (!xf86CrtcSetMode (crtc, mode, rotation, x, y)) + { + crtc->enabled = save_enabled; + for (o = 0; o < config->num_output; o++) + { + xf86OutputPtr output = config->output[o]; + output->crtc = save_crtcs[o]; + } + DEALLOCATE_LOCAL(save_crtcs); + return FALSE; + } + /* + * Save the last successful setting for EnterVT + */ + crtc->desiredMode = *mode; + crtc->desiredRotation = rotation; + crtc->desiredX = x; + crtc->desiredY = y; + } + xf86DisableUnusedFunctions (pScrn); + } + DEALLOCATE_LOCAL(save_crtcs); + return xf86RandR12CrtcNotify (randr_crtc); +} + +static Bool +xf86RandR12CrtcSetGamma (ScreenPtr pScreen, + RRCrtcPtr randr_crtc) +{ + xf86CrtcPtr crtc = randr_crtc->devPrivate; + + if (crtc->funcs->gamma_set == NULL) + return FALSE; + + crtc->funcs->gamma_set(crtc, randr_crtc->gammaRed, randr_crtc->gammaGreen, + randr_crtc->gammaBlue, randr_crtc->gammaSize); + + return TRUE; +} + +static Bool +xf86RandR12OutputSetProperty (ScreenPtr pScreen, + RROutputPtr randr_output, + Atom property, + RRPropertyValuePtr value) +{ + xf86OutputPtr output = randr_output->devPrivate; + + /* If we don't have any property handler, then we don't care what the + * user is setting properties to. + */ + if (output->funcs->set_property == NULL) + return TRUE; + + return output->funcs->set_property(output, property, value); +} + +/** + * Given a list of xf86 modes and a RandR Output object, construct + * RandR modes and assign them to the output + */ +static Bool +xf86RROutputSetModes (RROutputPtr randr_output, DisplayModePtr modes) +{ + DisplayModePtr mode; + RRModePtr *rrmodes = NULL; + int nmode = 0; + int npreferred = 0; + Bool ret = TRUE; + int pref; + + for (mode = modes; mode; mode = mode->next) + nmode++; + + if (nmode) { + rrmodes = xalloc (nmode * sizeof (RRModePtr)); + + if (!rrmodes) + return FALSE; + nmode = 0; + + for (pref = 1; pref >= 0; pref--) { + for (mode = modes; mode; mode = mode->next) { + if ((pref != 0) == ((mode->type & M_T_PREFERRED) != 0)) { + xRRModeInfo modeInfo; + RRModePtr rrmode; + + modeInfo.nameLength = strlen (mode->name); + modeInfo.width = mode->HDisplay; + modeInfo.dotClock = mode->Clock * 1000; + modeInfo.hSyncStart = mode->HSyncStart; + modeInfo.hSyncEnd = mode->HSyncEnd; + modeInfo.hTotal = mode->HTotal; + modeInfo.hSkew = mode->HSkew; + + modeInfo.height = mode->VDisplay; + modeInfo.vSyncStart = mode->VSyncStart; + modeInfo.vSyncEnd = mode->VSyncEnd; + modeInfo.vTotal = mode->VTotal; + modeInfo.modeFlags = mode->Flags; + + rrmode = RRModeGet (&modeInfo, mode->name); + if (rrmode) { + rrmode->devPrivate = mode; + rrmodes[nmode++] = rrmode; + npreferred += pref; + } + } + } + } + } + + ret = RROutputSetModes (randr_output, rrmodes, nmode, npreferred); + xfree (rrmodes); + return ret; +} + +/* + * Mirror the current mode configuration to RandR + */ +static Bool +xf86RandR12SetInfo12 (ScreenPtr pScreen) +{ + ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; + xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(pScrn); + RROutputPtr *clones; + RRCrtcPtr *crtcs; + int ncrtc; + int o, c, l; + RRCrtcPtr randr_crtc; + int nclone; + + clones = ALLOCATE_LOCAL(config->num_output * sizeof (RROutputPtr)); + crtcs = ALLOCATE_LOCAL (config->num_crtc * sizeof (RRCrtcPtr)); + for (o = 0; o < config->num_output; o++) + { + xf86OutputPtr output = config->output[o]; + + ncrtc = 0; + for (c = 0; c < config->num_crtc; c++) + if (output->possible_crtcs & (1 << c)) + crtcs[ncrtc++] = config->crtc[c]->randr_crtc; + + if (output->crtc) + randr_crtc = output->crtc->randr_crtc; + else + randr_crtc = NULL; + + if (!RROutputSetCrtcs (output->randr_output, crtcs, ncrtc)) + { + DEALLOCATE_LOCAL (crtcs); + DEALLOCATE_LOCAL (clones); + return FALSE; + } + + RROutputSetCrtc (output->randr_output, randr_crtc); + RROutputSetPhysicalSize(output->randr_output, + output->mm_width, + output->mm_height); + xf86RROutputSetModes (output->randr_output, output->probed_modes); + + switch (output->status) { + case XF86OutputStatusConnected: + RROutputSetConnection (output->randr_output, RR_Connected); + break; + case XF86OutputStatusDisconnected: + RROutputSetConnection (output->randr_output, RR_Disconnected); + break; + case XF86OutputStatusUnknown: + RROutputSetConnection (output->randr_output, RR_UnknownConnection); + break; + } + + RROutputSetSubpixelOrder (output->randr_output, output->subpixel_order); + + /* + * Valid clones + */ + nclone = 0; + for (l = 0; l < config->num_output; l++) + { + xf86OutputPtr clone = config->output[l]; + + if (l != o && (output->possible_clones & (1 << l))) + clones[nclone++] = clone->randr_output; + } + if (!RROutputSetClones (output->randr_output, clones, nclone)) + { + DEALLOCATE_LOCAL (crtcs); + DEALLOCATE_LOCAL (clones); + return FALSE; + } + } + DEALLOCATE_LOCAL (crtcs); + DEALLOCATE_LOCAL (clones); + return TRUE; +} + + + +/* + * Query the hardware for the current state, then mirror + * that to RandR + */ +static Bool +xf86RandR12GetInfo12 (ScreenPtr pScreen, Rotation *rotations) +{ + ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; + + xf86ProbeOutputModes (pScrn, 0, 0); + xf86SetScrnInfoModes (pScrn); + xf86DiDGAReInit (pScreen); + return xf86RandR12SetInfo12 (pScreen); +} + +static Bool +xf86RandR12CreateObjects12 (ScreenPtr pScreen) +{ + ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; + xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(pScrn); + int c; + int o; + + if (!RRInit ()) + return FALSE; + + /* + * Configure crtcs + */ + for (c = 0; c < config->num_crtc; c++) + { + xf86CrtcPtr crtc = config->crtc[c]; + + crtc->randr_crtc = RRCrtcCreate (crtc); + RRCrtcAttachScreen (crtc->randr_crtc, pScreen); + RRCrtcGammaSetSize (crtc->randr_crtc, 256); + } + /* + * Configure outputs + */ + for (o = 0; o < config->num_output; o++) + { + xf86OutputPtr output = config->output[o]; + + output->randr_output = RROutputCreate (output->name, + strlen (output->name), + output); + RROutputAttachScreen (output->randr_output, pScreen); + + if (output->funcs->create_resources != NULL) + output->funcs->create_resources(output); + } + return TRUE; +} + +static Bool +xf86RandR12CreateScreenResources12 (ScreenPtr pScreen) +{ + int c; + ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; + xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(pScrn); + + for (c = 0; c < config->num_crtc; c++) + xf86RandR12CrtcNotify (config->crtc[c]->randr_crtc); + + + RRScreenSetSizeRange (pScreen, config->minWidth, config->minHeight, + config->maxWidth, config->maxHeight); + return TRUE; +} + +static void +xf86RandR12PointerMoved (int scrnIndex, int x, int y) +{ +} + +static Bool +xf86RandR12Init12 (ScreenPtr pScreen) +{ + ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; + rrScrPrivPtr rp = rrGetScrPriv(pScreen); + + rp->rrGetInfo = xf86RandR12GetInfo12; + rp->rrScreenSetSize = xf86RandR12ScreenSetSize; + rp->rrCrtcSet = xf86RandR12CrtcSet; + rp->rrCrtcSetGamma = xf86RandR12CrtcSetGamma; + rp->rrOutputSetProperty = xf86RandR12OutputSetProperty; + rp->rrSetConfig = NULL; + pScrn->PointerMoved = xf86RandR12PointerMoved; + if (!xf86RandR12CreateObjects12 (pScreen)) + return FALSE; + + /* + * Configure output modes + */ + if (!xf86RandR12SetInfo12 (pScreen)) + return FALSE; + return TRUE; +} + +#endif + +Bool +xf86RandR12PreInit (ScrnInfoPtr pScrn) +{ + return TRUE; +} diff --git a/hw/xfree86/modes/xf86RandR12.h b/hw/xfree86/modes/xf86RandR12.h new file mode 100644 index 000000000..8a4668b46 --- /dev/null +++ b/hw/xfree86/modes/xf86RandR12.h @@ -0,0 +1,37 @@ +/* + * Copyright © 2006 Keith Packard + * + * Permission to use, copy, modify, distribute, and sell this software and its + * documentation for any purpose is hereby granted without fee, provided that + * the above copyright notice appear in all copies and that both that copyright + * notice and this permission notice appear in supporting documentation, and + * that the name of the copyright holders not be used in advertising or + * publicity pertaining to distribution of the software without specific, + * written prior permission. The copyright holders make no representations + * about the suitability of this software for any purpose. It is provided "as + * is" without express or implied warranty. + * + * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO + * EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, + * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * OF THIS SOFTWARE. + */ + +#ifndef _XF86_RANDR_H_ +#define _XF86_RANDR_H_ +#include +#include + +Bool xf86RandR12CreateScreenResources (ScreenPtr pScreen); +Bool xf86RandR12Init(ScreenPtr pScreen); +void xf86RandR12SetRotations (ScreenPtr pScreen, Rotation rotation); +Bool xf86RandR12SetConfig(ScreenPtr pScreen, Rotation rotation, int rate, + RRScreenSizePtr pSize); +Rotation xf86RandR12GetRotation(ScreenPtr pScreen); +void xf86RandR12GetOriginalVirtualSize(ScrnInfoPtr pScrn, int *x, int *y); +Bool xf86RandR12PreInit (ScrnInfoPtr pScrn); + +#endif /* _XF86_RANDR_H_ */ diff --git a/hw/xfree86/modes/xf86Rename.h b/hw/xfree86/modes/xf86Rename.h new file mode 100644 index 000000000..6cfa5caa1 --- /dev/null +++ b/hw/xfree86/modes/xf86Rename.h @@ -0,0 +1,80 @@ +/* + * Copyright © 2006 Keith Packard + * + * Permission to use, copy, modify, distribute, and sell this software and its + * documentation for any purpose is hereby granted without fee, provided that + * the above copyright notice appear in all copies and that both that copyright + * notice and this permission notice appear in supporting documentation, and + * that the name of the copyright holders not be used in advertising or + * publicity pertaining to distribution of the software without specific, + * written prior permission. The copyright holders make no representations + * about the suitability of this software for any purpose. It is provided "as + * is" without express or implied warranty. + * + * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO + * EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, + * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * OF THIS SOFTWARE. + */ + +#ifndef _XF86RENAME_H_ +#define _XF86RENAME_H_ + +#include "local_xf86Rename.h" + +#define xf86CrtcConfigInit XF86NAME(xf86CrtcConfigInit) +#define xf86CrtcConfigPrivateIndex XF86NAME(xf86CrtcConfigPrivateIndex) +#define xf86CrtcCreate XF86NAME(xf86CrtcCreate) +#define xf86CrtcDestroy XF86NAME(xf86CrtcDestroy) +#define xf86CrtcInUse XF86NAME(xf86CrtcInUse) +#define xf86CrtcRotate XF86NAME(xf86CrtcRotate) +#define xf86CrtcSetMode XF86NAME(xf86CrtcSetMode) +#define xf86CrtcSetSizeRange XF86NAME(xf86CrtcSetSizeRange) +#define xf86CVTMode XF86NAME(xf86CVTMode) +#define xf86DisableUnusedFunctions XF86NAME(xf86DisableUnusedFunctions) +#define xf86DPMSSet XF86NAME(xf86DPMSSet) +#define xf86DuplicateMode XF86NAME(xf86DuplicateMode) +#define xf86DuplicateModes XF86NAME(xf86DuplicateModes) +#define xf86GetDefaultModes XF86NAME(xf86GetDefaultModes) +#define xf86GetMonitorModes XF86NAME(xf86GetMonitorModes) +#define xf86InitialConfiguration XF86NAME(xf86InitialConfiguration) +#define xf86ModeHSync XF86NAME(xf86ModeHSync) +#define xf86ModesAdd XF86NAME(xf86ModesAdd) +#define xf86ModesEqual XF86NAME(xf86ModesEqual) +#define xf86ModeVRefresh XF86NAME(xf86ModeVRefresh) +#define xf86OutputCreate XF86NAME(xf86OutputCreate) +#define xf86OutputDestroy XF86NAME(xf86OutputDestroy) +#define xf86OutputGetEDID XF86NAME(xf86OutputGetEDID) +#define xf86OutputGetEDIDModes XF86NAME(xf86OutputGetEDIDModes) +#define xf86OutputRename XF86NAME(xf86OutputRename) +#define xf86OutputSetEDID XF86NAME(xf86OutputSetEDID) +#define xf86PrintModeline XF86NAME(xf86PrintModeline) +#define xf86ProbeOutputModes XF86NAME(xf86ProbeOutputModes) +#define xf86PruneInvalidModes XF86NAME(xf86PruneInvalidModes) +#define xf86SetModeCrtc XF86NAME(xf86SetModeCrtc) +#define xf86SetModeDefaultName XF86NAME(xf86SetModeDefaultName) +#define xf86SetScrnInfoModes XF86NAME(xf86SetScrnInfoModes) +#define xf86ValidateModesClocks XF86NAME(xf86ValidateModesClocks) +#define xf86ValidateModesFlags XF86NAME(xf86ValidateModesFlags) +#define xf86ValidateModesSize XF86NAME(xf86ValidateModesSize) +#define xf86ValidateModesSync XF86NAME(xf86ValidateModesSync) +#define xf86ValidateModesUserConfig XF86NAME(xf86ValidateModesUserConfig) +#define xf86DiDGAInit XF86NAME(xf86DiDGAInit) +#define xf86DiDGAReInit XF86NAME(xf86DiDGAReInit) +#define xf86DDCGetModes XF86NAME(xf86DDCGetModes) +#define xf86RandR12CreateScreenResources XF86NAME(xf86RandR12CreateScreenResources) +#define xf86RandR12GetOriginalVirtualSize XF86NAME(xf86RandR12GetOriginalVirtualSize) +#define xf86RandR12GetRotation XF86NAME(xf86RandR12GetRotation) +#define xf86RandR12Init XF86NAME(xf86RandR12Init) +#define xf86RandR12PreInit XF86NAME(xf86RandR12PreInit) +#define xf86RandR12SetConfig XF86NAME(xf86RandR12SetConfig) +#define xf86RandR12SetRotations XF86NAME(xf86RandR12SetRotations) +#define xf86SaveScreen XF86NAME(xf86SaveScreen) +#define xf86CrtcSetScreenSubpixelOrder XF86NAME(xf86CrtcSetScreenSubpixelOrder) +#define xf86ModeWidth XF86NAME(xf86ModeWidth) +#define xf86ModeHeight XF86NAME(xf86ModeHeight) + +#endif /* _XF86RENAME_H_ */ diff --git a/hw/xfree86/modes/xf86Rotate.c b/hw/xfree86/modes/xf86Rotate.c new file mode 100644 index 000000000..6826b6277 --- /dev/null +++ b/hw/xfree86/modes/xf86Rotate.c @@ -0,0 +1,427 @@ +/* + * Copyright © 2006 Keith Packard + * + * Permission to use, copy, modify, distribute, and sell this software and its + * documentation for any purpose is hereby granted without fee, provided that + * the above copyright notice appear in all copies and that both that copyright + * notice and this permission notice appear in supporting documentation, and + * that the name of the copyright holders not be used in advertising or + * publicity pertaining to distribution of the software without specific, + * written prior permission. The copyright holders make no representations + * about the suitability of this software for any purpose. It is provided "as + * is" without express or implied warranty. + * + * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO + * EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, + * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * OF THIS SOFTWARE. + */ + +#ifdef HAVE_XORG_CONFIG_H +#include +#else +#ifdef HAVE_CONFIG_H +#include +#endif +#endif + +#include +#include +#include + +#include "xf86.h" +#include "xf86DDC.h" +#include "fb.h" +#include "windowstr.h" +#include "xf86Crtc.h" +#include "xf86Modes.h" +#include "xf86RandR12.h" +#include "X11/extensions/render.h" +#define DPMS_SERVER +#include "X11/extensions/dpms.h" +#include "X11/Xatom.h" + +/* borrowed from composite extension, move to Render and publish? */ + +static VisualPtr +compGetWindowVisual (WindowPtr pWin) +{ + ScreenPtr pScreen = pWin->drawable.pScreen; + VisualID vid = wVisual (pWin); + int i; + + for (i = 0; i < pScreen->numVisuals; i++) + if (pScreen->visuals[i].vid == vid) + return &pScreen->visuals[i]; + return 0; +} + +static PictFormatPtr +compWindowFormat (WindowPtr pWin) +{ + ScreenPtr pScreen = pWin->drawable.pScreen; + + return PictureMatchVisual (pScreen, pWin->drawable.depth, + compGetWindowVisual (pWin)); +} + +static void +xf86TranslateBox (BoxPtr b, int dx, int dy) +{ + b->x1 += dx; + b->y1 += dy; + b->x2 += dx; + b->y2 += dy; +} + +static void +xf86TransformBox (BoxPtr dst, BoxPtr src, Rotation rotation, + int xoff, int yoff, + int dest_width, int dest_height) +{ + BoxRec stmp = *src; + + xf86TranslateBox (&stmp, -xoff, -yoff); + switch (rotation & 0xf) { + default: + case RR_Rotate_0: + *dst = stmp; + break; + case RR_Rotate_90: + dst->x1 = stmp.y1; + dst->y1 = dest_height - stmp.x2; + dst->x2 = stmp.y2; + dst->y2 = dest_height - stmp.x1; + break; + case RR_Rotate_180: + dst->x1 = dest_width - stmp.x2; + dst->y1 = dest_height - stmp.y2; + dst->x2 = dest_width - stmp.x1; + dst->y2 = dest_height - stmp.y1; + break; + case RR_Rotate_270: + dst->x1 = dest_width - stmp.y2; + dst->y1 = stmp.x1; + dst->y2 = stmp.x2; + dst->x2 = dest_width - stmp.y1; + break; + } + if (rotation & RR_Reflect_X) { + int x1 = dst->x1; + dst->x1 = dest_width - dst->x2; + dst->x2 = dest_width - x1; + } + if (rotation & RR_Reflect_Y) { + int y1 = dst->y1; + dst->y1 = dest_height - dst->y2; + dst->y2 = dest_height - y1; + } +} + +static void +xf86RotateCrtcRedisplay (xf86CrtcPtr crtc, RegionPtr region) +{ + ScrnInfoPtr scrn = crtc->scrn; + ScreenPtr screen = scrn->pScreen; + WindowPtr root = WindowTable[screen->myNum]; + PixmapPtr dst_pixmap = crtc->rotatedPixmap; + PictFormatPtr format = compWindowFormat (WindowTable[screen->myNum]); + int error; + PicturePtr src, dst; + PictTransform transform; + int n = REGION_NUM_RECTS(region); + BoxPtr b = REGION_RECTS(region); + XID include_inferiors = IncludeInferiors; + + src = CreatePicture (None, + &root->drawable, + format, + CPSubwindowMode, + &include_inferiors, + serverClient, + &error); + if (!src) + return; + + dst = CreatePicture (None, + &dst_pixmap->drawable, + format, + 0L, + NULL, + serverClient, + &error); + if (!dst) + return; + + memset (&transform, '\0', sizeof (transform)); + transform.matrix[2][2] = IntToxFixed(1); + transform.matrix[0][2] = IntToxFixed(crtc->x); + transform.matrix[1][2] = IntToxFixed(crtc->y); + switch (crtc->rotation & 0xf) { + default: + case RR_Rotate_0: + transform.matrix[0][0] = IntToxFixed(1); + transform.matrix[1][1] = IntToxFixed(1); + break; + case RR_Rotate_90: + transform.matrix[0][1] = IntToxFixed(-1); + transform.matrix[1][0] = IntToxFixed(1); + transform.matrix[0][2] += IntToxFixed(crtc->mode.VDisplay); + break; + case RR_Rotate_180: + transform.matrix[0][0] = IntToxFixed(-1); + transform.matrix[1][1] = IntToxFixed(-1); + transform.matrix[0][2] += IntToxFixed(crtc->mode.HDisplay); + transform.matrix[1][2] += IntToxFixed(crtc->mode.VDisplay); + break; + case RR_Rotate_270: + transform.matrix[0][1] = IntToxFixed(1); + transform.matrix[1][0] = IntToxFixed(-1); + transform.matrix[1][2] += IntToxFixed(crtc->mode.HDisplay); + break; + } + + /* handle reflection */ + if (crtc->rotation & RR_Reflect_X) + { + /* XXX figure this out */ + } + if (crtc->rotation & RR_Reflect_Y) + { + /* XXX figure this out too */ + } + + error = SetPictureTransform (src, &transform); + if (error) + return; + + while (n--) + { + BoxRec dst_box; + + xf86TransformBox (&dst_box, b, crtc->rotation, + crtc->x, crtc->y, + crtc->mode.HDisplay, crtc->mode.VDisplay); + CompositePicture (PictOpSrc, + src, NULL, dst, + dst_box.x1, dst_box.y1, 0, 0, dst_box.x1, dst_box.y1, + dst_box.x2 - dst_box.x1, + dst_box.y2 - dst_box.y1); + b++; + } + FreePicture (src, None); + FreePicture (dst, None); +} + +static void +xf86CrtcDamageShadow (xf86CrtcPtr crtc) +{ + ScrnInfoPtr pScrn = crtc->scrn; + BoxRec damage_box; + RegionRec damage_region; + ScreenPtr pScreen = pScrn->pScreen; + + damage_box.x1 = crtc->x; + damage_box.x2 = crtc->x + xf86ModeWidth (&crtc->mode, crtc->rotation); + damage_box.y1 = crtc->y; + damage_box.y2 = crtc->y + xf86ModeHeight (&crtc->mode, crtc->rotation); + REGION_INIT (pScreen, &damage_region, &damage_box, 1); + DamageDamageRegion (&(*pScreen->GetScreenPixmap)(pScreen)->drawable, + &damage_region); + REGION_UNINIT (pScreen, &damage_region); +} + +static void +xf86RotatePrepare (ScreenPtr pScreen) +{ + ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; + xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(pScrn); + int c; + + for (c = 0; c < xf86_config->num_crtc; c++) + { + xf86CrtcPtr crtc = xf86_config->crtc[c]; + + if (crtc->rotatedData && !crtc->rotatedPixmap) + { + crtc->rotatedPixmap = crtc->funcs->shadow_create (crtc, + crtc->rotatedData, + crtc->mode.HDisplay, + crtc->mode.VDisplay); + /* Hook damage to screen pixmap */ + DamageRegister (&(*pScreen->GetScreenPixmap)(pScreen)->drawable, + xf86_config->rotationDamage); + + xf86CrtcDamageShadow (crtc); + } + } +} + +static void +xf86RotateRedisplay(ScreenPtr pScreen) +{ + ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; + xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(pScrn); + DamagePtr damage = xf86_config->rotationDamage; + RegionPtr region; + + if (!damage) + return; + xf86RotatePrepare (pScreen); + region = DamageRegion(damage); + if (REGION_NOTEMPTY(pScreen, region)) + { + int c; + + for (c = 0; c < xf86_config->num_crtc; c++) + { + xf86CrtcPtr crtc = xf86_config->crtc[c]; + + if (crtc->rotation != RR_Rotate_0) + { + BoxRec box; + RegionRec crtc_damage; + + /* compute portion of damage that overlaps crtc */ + box.x1 = crtc->x; + box.x2 = crtc->x + xf86ModeWidth (&crtc->mode, crtc->rotation); + box.y1 = crtc->y; + box.y2 = crtc->y + xf86ModeHeight (&crtc->mode, crtc->rotation); + REGION_INIT(pScreen, &crtc_damage, &box, 1); + REGION_INTERSECT (pScreen, &crtc_damage, &crtc_damage, region); + + /* update damaged region */ + if (REGION_NOTEMPTY(pScreen, &crtc_damage)) + xf86RotateCrtcRedisplay (crtc, &crtc_damage); + + REGION_UNINIT (pScreen, &crtc_damage); + } + } + DamageEmpty(damage); + } +} + +static void +xf86RotateBlockHandler(pointer data, OSTimePtr pTimeout, pointer pRead) +{ + ScreenPtr pScreen = (ScreenPtr) data; + + xf86RotateRedisplay(pScreen); +} + +static void +xf86RotateWakeupHandler(pointer data, int i, pointer LastSelectMask) +{ +} + +Bool +xf86CrtcRotate (xf86CrtcPtr crtc, DisplayModePtr mode, Rotation rotation) +{ + ScrnInfoPtr pScrn = crtc->scrn; + xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(pScrn); + ScreenPtr pScreen = pScrn->pScreen; + + if (rotation == RR_Rotate_0) + { + /* Free memory from rotation */ + if (crtc->rotatedPixmap || crtc->rotatedData) + { + crtc->funcs->shadow_destroy (crtc, crtc->rotatedPixmap, crtc->rotatedData); + crtc->rotatedPixmap = NULL; + crtc->rotatedData = NULL; + } + + if (xf86_config->rotationDamage) + { + /* Free damage structure */ + DamageUnregister (&(*pScreen->GetScreenPixmap)(pScreen)->drawable, + xf86_config->rotationDamage); + DamageDestroy (xf86_config->rotationDamage); + xf86_config->rotationDamage = NULL; + /* Free block/wakeup handler */ + RemoveBlockAndWakeupHandlers (xf86RotateBlockHandler, + xf86RotateWakeupHandler, + (pointer) pScreen); + } + } + else + { + /* + * these are the size of the shadow pixmap, which + * matches the mode, not the pre-rotated copy in the + * frame buffer + */ + int width = mode->HDisplay; + int height = mode->VDisplay; + void *shadowData = crtc->rotatedData; + PixmapPtr shadow = crtc->rotatedPixmap; + int old_width = shadow ? shadow->drawable.width : 0; + int old_height = shadow ? shadow->drawable.height : 0; + + /* Allocate memory for rotation */ + if (old_width != width || old_height != height) + { + if (shadow || shadowData) + { + crtc->funcs->shadow_destroy (crtc, shadow, shadowData); + crtc->rotatedPixmap = NULL; + crtc->rotatedData = NULL; + } + shadowData = crtc->funcs->shadow_allocate (crtc, width, height); + if (!shadowData) + goto bail1; + crtc->rotatedData = shadowData; + /* shadow will be damaged in xf86RotatePrepare */ + } + else + { + /* mark shadowed area as damaged so it will be repainted */ + xf86CrtcDamageShadow (crtc); + } + + if (!xf86_config->rotationDamage) + { + /* Create damage structure */ + xf86_config->rotationDamage = DamageCreate (NULL, NULL, + DamageReportNone, + TRUE, pScreen, pScreen); + if (!xf86_config->rotationDamage) + goto bail2; + + /* Assign block/wakeup handler */ + if (!RegisterBlockAndWakeupHandlers (xf86RotateBlockHandler, + xf86RotateWakeupHandler, + (pointer) pScreen)) + { + goto bail3; + } + } + if (0) + { +bail3: + DamageDestroy (xf86_config->rotationDamage); + xf86_config->rotationDamage = NULL; + +bail2: + if (shadow || shadowData) + { + crtc->funcs->shadow_destroy (crtc, shadow, shadowData); + crtc->rotatedPixmap = NULL; + crtc->rotatedData = NULL; + } +bail1: + if (old_width && old_height) + crtc->rotatedPixmap = crtc->funcs->shadow_create (crtc, + NULL, + old_width, + old_height); + return FALSE; + } + } + + /* All done */ + return TRUE; +} diff --git a/hw/xfree86/modes/xf86cvt.c b/hw/xfree86/modes/xf86cvt.c new file mode 100644 index 000000000..69ccc4259 --- /dev/null +++ b/hw/xfree86/modes/xf86cvt.c @@ -0,0 +1,308 @@ +/* + * Copyright 2005-2006 Luc Verhaegen. + * + * 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 COPYRIGHT HOLDER(S) OR AUTHOR(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. + */ + +/** + * @file This is a copy of xf86cvt.c from the X Server, for compatibility with + * old servers (pre-1.2). + */ + +/* + * The reason for having this function in a file of its own is + * so that ../utils/cvt/cvt can link to it, and that xf86CVTMode + * code is shared directly. + */ + +#ifdef HAVE_XORG_CONFIG_H +#include +#else +#ifdef HAVE_CONFIG_H +#include +#endif +#endif + +#include "xf86.h" +#include "xf86Modes.h" + +#include + +/* + * Generate a CVT standard mode from HDisplay, VDisplay and VRefresh. + * + * These calculations are stolen from the CVT calculation spreadsheet written + * by Graham Loveridge. He seems to be claiming no copyright and there seems to + * be no license attached to this. He apparently just wants to see his name + * mentioned. + * + * This file can be found at http://www.vesa.org/Public/CVT/CVTd6r1.xls + * + * Comments and structure corresponds to the comments and structure of the xls. + * This should ease importing of future changes to the standard (not very + * likely though). + * + * About margins; i'm sure that they are to be the bit between HDisplay and + * HBlankStart, HBlankEnd and HTotal, VDisplay and VBlankStart, VBlankEnd and + * VTotal, where the overscan colour is shown. FB seems to call _all_ blanking + * outside sync "margin" for some reason. Since we prefer seeing proper + * blanking instead of the overscan colour, and since the Crtc* values will + * probably get altered after us, we will disable margins altogether. With + * these calculations, Margins will plainly expand H/VDisplay, and we don't + * want that. -- libv + * + */ +_X_EXPORT DisplayModePtr +xf86CVTMode(int HDisplay, int VDisplay, float VRefresh, Bool Reduced, + Bool Interlaced) +{ + DisplayModeRec *Mode = xnfalloc(sizeof(DisplayModeRec)); + + /* 1) top/bottom margin size (% of height) - default: 1.8 */ +#define CVT_MARGIN_PERCENTAGE 1.8 + + /* 2) character cell horizontal granularity (pixels) - default 8 */ +#define CVT_H_GRANULARITY 8 + + /* 4) Minimum vertical porch (lines) - default 3 */ +#define CVT_MIN_V_PORCH 3 + + /* 4) Minimum number of vertical back porch lines - default 6 */ +#define CVT_MIN_V_BPORCH 6 + + /* Pixel Clock step (kHz) */ +#define CVT_CLOCK_STEP 250 + + Bool Margins = FALSE; + float VFieldRate, HPeriod; + int HDisplayRnd, HMargin; + int VDisplayRnd, VMargin, VSync; + float Interlace; /* Please rename this */ + + memset(Mode, 0, sizeof(DisplayModeRec)); + + /* CVT default is 60.0Hz */ + if (!VRefresh) + VRefresh = 60.0; + + /* 1. Required field rate */ + if (Interlaced) + VFieldRate = VRefresh * 2; + else + VFieldRate = VRefresh; + + /* 2. Horizontal pixels */ + HDisplayRnd = HDisplay - (HDisplay % CVT_H_GRANULARITY); + + /* 3. Determine left and right borders */ + if (Margins) { + /* right margin is actually exactly the same as left */ + HMargin = (((float) HDisplayRnd) * CVT_MARGIN_PERCENTAGE / 100.0); + HMargin -= HMargin % CVT_H_GRANULARITY; + } else + HMargin = 0; + + /* 4. Find total active pixels */ + Mode->HDisplay = HDisplayRnd + 2*HMargin; + + /* 5. Find number of lines per field */ + if (Interlaced) + VDisplayRnd = VDisplay / 2; + else + VDisplayRnd = VDisplay; + + /* 6. Find top and bottom margins */ + /* nope. */ + if (Margins) + /* top and bottom margins are equal again. */ + VMargin = (((float) VDisplayRnd) * CVT_MARGIN_PERCENTAGE / 100.0); + else + VMargin = 0; + + Mode->VDisplay = VDisplay + 2*VMargin; + + /* 7. Interlace */ + if (Interlaced) + Interlace = 0.5; + else + Interlace = 0.0; + + /* Determine VSync Width from aspect ratio */ + if (!(VDisplay % 3) && ((VDisplay * 4 / 3) == HDisplay)) + VSync = 4; + else if (!(VDisplay % 9) && ((VDisplay * 16 / 9) == HDisplay)) + VSync = 5; + else if (!(VDisplay % 10) && ((VDisplay * 16 / 10) == HDisplay)) + VSync = 6; + else if (!(VDisplay % 4) && ((VDisplay * 5 / 4) == HDisplay)) + VSync = 7; + else if (!(VDisplay % 9) && ((VDisplay * 15 / 9) == HDisplay)) + VSync = 7; + else /* Custom */ + VSync = 10; + + if (!Reduced) { /* simplified GTF calculation */ + + /* 4) Minimum time of vertical sync + back porch interval (µs) + * default 550.0 */ +#define CVT_MIN_VSYNC_BP 550.0 + + /* 3) Nominal HSync width (% of line period) - default 8 */ +#define CVT_HSYNC_PERCENTAGE 8 + + float HBlankPercentage; + int VSyncAndBackPorch, VBackPorch; + int HBlank; + + /* 8. Estimated Horizontal period */ + HPeriod = ((float) (1000000.0 / VFieldRate - CVT_MIN_VSYNC_BP)) / + (VDisplayRnd + 2 * VMargin + CVT_MIN_V_PORCH + Interlace); + + /* 9. Find number of lines in sync + backporch */ + if (((int)(CVT_MIN_VSYNC_BP / HPeriod) + 1) < (VSync + CVT_MIN_V_PORCH)) + VSyncAndBackPorch = VSync + CVT_MIN_V_PORCH; + else + VSyncAndBackPorch = (int)(CVT_MIN_VSYNC_BP / HPeriod) + 1; + + /* 10. Find number of lines in back porch */ + VBackPorch = VSyncAndBackPorch - VSync; + + /* 11. Find total number of lines in vertical field */ + Mode->VTotal = VDisplayRnd + 2 * VMargin + VSyncAndBackPorch + Interlace + + CVT_MIN_V_PORCH; + + /* 5) Definition of Horizontal blanking time limitation */ + /* Gradient (%/kHz) - default 600 */ +#define CVT_M_FACTOR 600 + + /* Offset (%) - default 40 */ +#define CVT_C_FACTOR 40 + + /* Blanking time scaling factor - default 128 */ +#define CVT_K_FACTOR 128 + + /* Scaling factor weighting - default 20 */ +#define CVT_J_FACTOR 20 + +#define CVT_M_PRIME CVT_M_FACTOR * CVT_K_FACTOR / 256 +#define CVT_C_PRIME (CVT_C_FACTOR - CVT_J_FACTOR) * CVT_K_FACTOR / 256 + \ + CVT_J_FACTOR + + /* 12. Find ideal blanking duty cycle from formula */ + HBlankPercentage = CVT_C_PRIME - CVT_M_PRIME * HPeriod/1000.0; + + /* 13. Blanking time */ + if (HBlankPercentage < 20) + HBlankPercentage = 20; + + HBlank = Mode->HDisplay * HBlankPercentage/(100.0 - HBlankPercentage); + HBlank -= HBlank % (2*CVT_H_GRANULARITY); + + /* 14. Find total number of pixels in a line. */ + Mode->HTotal = Mode->HDisplay + HBlank; + + /* Fill in HSync values */ + Mode->HSyncEnd = Mode->HDisplay + HBlank / 2; + + Mode->HSyncStart = Mode->HSyncEnd - + (Mode->HTotal * CVT_HSYNC_PERCENTAGE) / 100; + Mode->HSyncStart += CVT_H_GRANULARITY - + Mode->HSyncStart % CVT_H_GRANULARITY; + + /* Fill in VSync values */ + Mode->VSyncStart = Mode->VDisplay + CVT_MIN_V_PORCH; + Mode->VSyncEnd = Mode->VSyncStart + VSync; + + } else { /* Reduced blanking */ + /* Minimum vertical blanking interval time (µs) - default 460 */ +#define CVT_RB_MIN_VBLANK 460.0 + + /* Fixed number of clocks for horizontal sync */ +#define CVT_RB_H_SYNC 32.0 + + /* Fixed number of clocks for horizontal blanking */ +#define CVT_RB_H_BLANK 160.0 + + /* Fixed number of lines for vertical front porch - default 3 */ +#define CVT_RB_VFPORCH 3 + + int VBILines; + + /* 8. Estimate Horizontal period. */ + HPeriod = ((float) (1000000.0 / VFieldRate - CVT_RB_MIN_VBLANK)) / + (VDisplayRnd + 2*VMargin); + + /* 9. Find number of lines in vertical blanking */ + VBILines = ((float) CVT_RB_MIN_VBLANK) / HPeriod + 1; + + /* 10. Check if vertical blanking is sufficient */ + if (VBILines < (CVT_RB_VFPORCH + VSync + CVT_MIN_V_BPORCH)) + VBILines = CVT_RB_VFPORCH + VSync + CVT_MIN_V_BPORCH; + + /* 11. Find total number of lines in vertical field */ + Mode->VTotal = VDisplayRnd + 2 * VMargin + Interlace + VBILines; + + /* 12. Find total number of pixels in a line */ + Mode->HTotal = Mode->HDisplay + CVT_RB_H_BLANK; + + /* Fill in HSync values */ + Mode->HSyncEnd = Mode->HDisplay + CVT_RB_H_BLANK / 2; + Mode->HSyncStart = Mode->HSyncEnd - CVT_RB_H_SYNC; + + /* Fill in VSync values */ + Mode->VSyncStart = Mode->VDisplay + CVT_RB_VFPORCH; + Mode->VSyncEnd = Mode->VSyncStart + VSync; + } + + /* 15/13. Find pixel clock frequency (kHz for xf86) */ + Mode->Clock = Mode->HTotal * 1000.0 / HPeriod; + Mode->Clock -= Mode->Clock % CVT_CLOCK_STEP; + + /* 16/14. Find actual Horizontal Frequency (kHz) */ + Mode->HSync = ((float) Mode->Clock) / ((float) Mode->HTotal); + + /* 17/15. Find actual Field rate */ + Mode->VRefresh = (1000.0 * ((float) Mode->Clock)) / + ((float) (Mode->HTotal * Mode->VTotal)); + + /* 18/16. Find actual vertical frame frequency */ + /* ignore - just set the mode flag for interlaced */ + if (Interlaced) + Mode->VTotal *= 2; + + { + char Name[256]; + Name[0] = 0; + + snprintf(Name, 256, "%dx%d", HDisplay, VDisplay); + + Mode->name = xnfalloc(strlen(Name) + 1); + memcpy(Mode->name, Name, strlen(Name) + 1); + } + + if (Reduced) + Mode->Flags |= V_PHSYNC | V_NVSYNC; + else + Mode->Flags |= V_NHSYNC | V_PVSYNC; + + if (Interlaced) + Mode->Flags |= V_INTERLACE; + + return Mode; +} diff --git a/hw/xfree86/os-support/bus/axpPci.c b/hw/xfree86/os-support/bus/axpPci.c index 9acc4ab5b..fc16a512e 100644 --- a/hw/xfree86/os-support/bus/axpPci.c +++ b/hw/xfree86/os-support/bus/axpPci.c @@ -217,7 +217,8 @@ axpPciInit() * only set up the root bus for each domain (hose) and the bridged * buses will be set up as they are found. */ - bus = PCI_MAKE_BUS(domain, 0); + /* make a bus with both the domain and the root bus in it */ + bus = PCI_MAKE_BUS(domain, pDomain->root_bus); pciBusInfo[bus] = xnfalloc(sizeof(pciBusInfo_t)); (void)memset(pciBusInfo[bus], 0, sizeof(pciBusInfo_t)); @@ -249,7 +250,7 @@ axpPciBusFromTag(PCITAG tag) || !(pDomain = pBusInfo->pciBusPriv) || (pDomain->domain != PCI_DOM_FROM_TAG(tag))) return -1; - bus = PCI_BUS_NO_DOMAIN(bus) + pDomain->root_bus; + bus = PCI_BUS_NO_DOMAIN(bus); /* should just be root_bus */ dfn = PCI_DFN_FROM_TAG(tag); if (_iobase(IOBASE_HOSE, -1, bus, dfn) != pDomain->hose) return -1; diff --git a/hw/xfree86/os-support/solaris/Makefile.am b/hw/xfree86/os-support/solaris/Makefile.am index 57ec89e57..d01e2e676 100644 --- a/hw/xfree86/os-support/solaris/Makefile.am +++ b/hw/xfree86/os-support/solaris/Makefile.am @@ -19,9 +19,9 @@ solaris-$(SOLARIS_INOUT_ARCH).il: solaris-${SOLARIS_INOUT_ARCH}.S noinst_LTLIBRARIES = libsolaris.la libsolaris_la_SOURCES = sun_bios.c sun_init.c \ - sun_mouse.c sun_vid.c sun_bell.c $(AGP_SRC) \ + sun_mouse.c sun_vid.c sun_bell.c $(AGP_SRC) sun_apm.c \ $(srcdir)/../shared/libc_wrapper.c \ - $(srcdir)/../shared/kmod_noop.c $(srcdir)/../shared/pm_noop.c \ + $(srcdir)/../shared/kmod_noop.c \ $(srcdir)/../shared/posix_tty.c $(srcdir)/../shared/sigiostubs.c \ $(srcdir)/../shared/stdPci.c $(srcdir)/../shared/stdResource.c \ $(VTSW_SRC) diff --git a/hw/xfree86/os-support/solaris/sun_apm.c b/hw/xfree86/os-support/solaris/sun_apm.c new file mode 100644 index 000000000..a9657fd55 --- /dev/null +++ b/hw/xfree86/os-support/solaris/sun_apm.c @@ -0,0 +1,232 @@ +/* Based on hw/xfree86/os-support/bsd/bsd_apm.c which bore no explicit + * copyright notice, so is covered by the following notice: + * + * Copyright (C) 1994-2003 The XFree86 Project, 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 XFREE86 PROJECT 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 of the XFree86 Project shall + * not be used in advertising or otherwise to promote the sale, use or other + * dealings in this Software without prior written authorization from the + * XFree86 Project. + */ + +/* Copyright 2005 Sun Microsystems, 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, and/or sell copies of the Software, and to permit persons + * to whom the Software is furnished to do so, provided that the above + * copyright notice(s) and this permission notice appear in all copies of + * the Software and that both the above copyright notice(s) and this + * permission notice appear in supporting documentation. + * + * 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 + * OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR + * HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL + * INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING + * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, + * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION + * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + * + * Except as contained in this notice, the name of a copyright holder + * shall not be used in advertising or otherwise to promote the sale, use + * or other dealings in this Software without prior written authorization + * of the copyright holder. + */ + +#ifdef HAVE_XORG_CONFIG_H +#include +#endif + +#include +#include "os.h" +#include "xf86.h" +#include "xf86Priv.h" +#define XF86_OS_PRIVS +#include "xf86_OSproc.h" +#include "xf86_OSlib.h" + +#ifndef PLEASE_FIX_THIS +#define APM_STANDBY_REQ 0xa01 +#define APM_SUSPEND_REQ 0xa02 +#define APM_NORMAL_RESUME 0xa03 +#define APM_CRIT_RESUME 0xa04 +#define APM_BATTERY_LOW 0xa05 +#define APM_POWER_CHANGE 0xa06 +#define APM_UPDATE_TIME 0xa07 +#define APM_CRIT_SUSPEND_REQ 0xa08 +#define APM_USER_STANDBY_REQ 0xa09 +#define APM_USER_SUSPEND_REQ 0xa0a +#define APM_SYS_STANDBY_RESUME 0xa0b +#define APM_IOC_NEXTEVENT 0xa0c +#define APM_IOC_RESUME 0xa0d +#define APM_IOC_SUSPEND 0xa0e +#define APM_IOC_STANDBY 0xa0f +#endif + +typedef struct apm_event_info +{ + int type; +} apm_event_info; + +/* + This may be replaced with a better device name + very soon... +*/ +#define APM_DEVICE "/dev/srn" +#define APM_DEVICE1 "/dev/apm" + +static pointer APMihPtr = NULL; +static void sunCloseAPM(void); + +static struct { + u_int apmBsd; + pmEvent xf86; +} sunToXF86Array [] = { + { APM_STANDBY_REQ, XF86_APM_SYS_STANDBY }, + { APM_SUSPEND_REQ, XF86_APM_SYS_SUSPEND }, + { APM_NORMAL_RESUME, XF86_APM_NORMAL_RESUME }, + { APM_CRIT_RESUME, XF86_APM_CRITICAL_RESUME }, + { APM_BATTERY_LOW, XF86_APM_LOW_BATTERY }, + { APM_POWER_CHANGE, XF86_APM_POWER_STATUS_CHANGE }, + { APM_UPDATE_TIME, XF86_APM_UPDATE_TIME }, + { APM_CRIT_SUSPEND_REQ, XF86_APM_CRITICAL_SUSPEND }, + { APM_USER_STANDBY_REQ, XF86_APM_USER_STANDBY }, + { APM_USER_SUSPEND_REQ, XF86_APM_USER_SUSPEND }, + { APM_SYS_STANDBY_RESUME, XF86_APM_STANDBY_RESUME }, +#ifdef APM_CAPABILITY_CHANGE + { APM_CAPABILITY_CHANGE, XF86_APM_CAPABILITY_CHANGED }, +#endif +}; + +#define numApmEvents (sizeof(sunToXF86Array) / sizeof(sunToXF86Array[0])) + +static pmEvent +sunToXF86(int type) +{ + int i; + + for (i = 0; i < numApmEvents; i++) { + if (type == sunToXF86Array[i].apmBsd) { + return sunToXF86Array[i].xf86; + } + } + return XF86_APM_UNKNOWN; +} + +/* + * APM events can be requested direclty from /dev/apm + */ +static int +sunPMGetEventFromOS(int fd, pmEvent *events, int num) +{ + struct apm_event_info sunEvent; + int i; + + for (i = 0; i < num; i++) { + + if (ioctl(fd, APM_IOC_NEXTEVENT, &sunEvent) < 0) { + if (errno != EAGAIN) { + xf86Msg(X_WARNING, "sunPMGetEventFromOS: APM_IOC_NEXTEVENT" + " errno = %d\n", errno); + } + break; + } + events[i] = sunToXF86(sunEvent.type); + } + xf86Msg(X_WARNING, "Got some events\n"); + return i; +} + +static pmWait +sunPMConfirmEventToOs(int fd, pmEvent event) +{ + switch (event) { +/* XXX: NOT CURRENTLY RETURNED FROM OS */ + case XF86_APM_SYS_STANDBY: + case XF86_APM_USER_STANDBY: + if (ioctl( fd, APM_IOC_STANDBY, NULL ) == 0) + return PM_WAIT; /* should we stop the Xserver in standby, too? */ + else + return PM_NONE; + case XF86_APM_SYS_SUSPEND: + case XF86_APM_CRITICAL_SUSPEND: + case XF86_APM_USER_SUSPEND: + xf86Msg(X_WARNING, "Got SUSPENDED\n"); + if (ioctl( fd, APM_IOC_SUSPEND, NULL ) == 0) + return PM_CONTINUE; + else { + xf86Msg(X_WARNING, "sunPMConfirmEventToOs: APM_IOC_SUSPEND" + " errno = %d\n", errno); + return PM_FAILED; + } + case XF86_APM_STANDBY_RESUME: + case XF86_APM_NORMAL_RESUME: + case XF86_APM_CRITICAL_RESUME: + case XF86_APM_STANDBY_FAILED: + case XF86_APM_SUSPEND_FAILED: + xf86Msg(X_WARNING, "Got RESUME\n"); + if (ioctl( fd, APM_IOC_RESUME, NULL ) == 0) + return PM_CONTINUE; + else { + xf86Msg(X_WARNING, "sunPMConfirmEventToOs: APM_IOC_RESUME" + " errno = %d\n", errno); + return PM_FAILED; + } + default: + return PM_NONE; + } +} + +PMClose +xf86OSPMOpen(void) +{ + int fd; + + if (APMihPtr || !xf86Info.pmFlag) { + return NULL; + } + + if ((fd = open(APM_DEVICE, O_RDWR)) == -1) { + if ((fd = open(APM_DEVICE1, O_RDWR)) == -1) { + return NULL; + } + } + xf86PMGetEventFromOs = sunPMGetEventFromOS; + xf86PMConfirmEventToOs = sunPMConfirmEventToOs; + APMihPtr = xf86AddInputHandler(fd, xf86HandlePMEvents, NULL); + return sunCloseAPM; +} + +static void +sunCloseAPM(void) +{ + int fd; + + if (APMihPtr) { + fd = xf86RemoveInputHandler(APMihPtr); + close(fd); + APMihPtr = NULL; + } +} diff --git a/hw/xfree86/os-support/xf86_OSlib.h b/hw/xfree86/os-support/xf86_OSlib.h index 97f872301..27f766d9c 100644 --- a/hw/xfree86/os-support/xf86_OSlib.h +++ b/hw/xfree86/os-support/xf86_OSlib.h @@ -130,8 +130,8 @@ typedef signed long xf86ssize_t; # include # if defined(_NEED_SYSI86) -# include # if !(defined (sun) && defined (SVR4)) +# include # include # endif # include diff --git a/hw/xfree86/parser/Makefile.am b/hw/xfree86/parser/Makefile.am index 1c1ba3f13..849ee8bab 100644 --- a/hw/xfree86/parser/Makefile.am +++ b/hw/xfree86/parser/Makefile.am @@ -36,4 +36,6 @@ EXTRA_DIST = \ cpconfig.c sdk_HEADERS = \ - $(LIBHEADERS) + $(LIBHEADERS) \ + xf86Parser.h \ + xf86Optrec.h diff --git a/hw/xfree86/ramdac/xf86Cursor.c b/hw/xfree86/ramdac/xf86Cursor.c index a903f7f02..457807698 100644 --- a/hw/xfree86/ramdac/xf86Cursor.c +++ b/hw/xfree86/ramdac/xf86Cursor.c @@ -199,10 +199,11 @@ xf86CursorEnableDisableFBAccess( pScreen->devPrivates[xf86CursorScreenIndex].ptr; if (!enable && ScreenPriv->CurrentCursor != NullCursor) { - ScreenPriv->SavedCursor = ScreenPriv->CurrentCursor; + CursorPtr currentCursor = ScreenPriv->CurrentCursor; xf86CursorSetCursor(pScreen, NullCursor, ScreenPriv->x, ScreenPriv->y); ScreenPriv->isUp = FALSE; ScreenPriv->SWCursor = TRUE; + ScreenPriv->SavedCursor = currentCursor; } if (ScreenPriv->EnableDisableFBAccess) diff --git a/hw/xprint/config/C/print/models/CANONC3200-PS/fonts/Makefile.am b/hw/xprint/config/C/print/models/CANONC3200-PS/fonts/Makefile.am index 5be5419ba..c574c5cde 100644 --- a/hw/xprint/config/C/print/models/CANONC3200-PS/fonts/Makefile.am +++ b/hw/xprint/config/C/print/models/CANONC3200-PS/fonts/Makefile.am @@ -1,6 +1,6 @@ xpcdir = @xpconfigdir@/C/print/models/CANONC3200-PS/fonts -parentdir = @xpconfigdir@/C/print/models/PSdefault/fonts +parentdir = ../../PSdefault/fonts XPFONTS = \ AvantGarde-Book.pmf \ diff --git a/hw/xprint/config/C/print/models/HPLJ4050-PS/fonts/Makefile.am b/hw/xprint/config/C/print/models/HPLJ4050-PS/fonts/Makefile.am index 2ff9ab7e7..634db1f39 100644 --- a/hw/xprint/config/C/print/models/HPLJ4050-PS/fonts/Makefile.am +++ b/hw/xprint/config/C/print/models/HPLJ4050-PS/fonts/Makefile.am @@ -1,6 +1,6 @@ xpcdir = @xpconfigdir@/C/print/models/HPLJ4050-PS/fonts -parentdir = @xpconfigdir@/C/print/models/PSdefault/fonts +parentdir = ../../PSdefault/fonts XPFONTS = \ AvantGarde-Book.pmf \ diff --git a/hw/xprint/config/C/print/models/PSdefault/fonts/Makefile.am b/hw/xprint/config/C/print/models/PSdefault/fonts/Makefile.am index e7ddb6c0f..1e8c8a781 100644 --- a/hw/xprint/config/C/print/models/PSdefault/fonts/Makefile.am +++ b/hw/xprint/config/C/print/models/PSdefault/fonts/Makefile.am @@ -18,6 +18,7 @@ dist_xpc_DATA = \ LubalinGraph-DemiOblique.pmf \ LubalinGraph-Demi.pmf \ NewCenturySchlbk-Bold.pmf \ + NewCenturySchlbk-BoldItalic.pmf \ NewCenturySchlbk-Italic.pmf \ NewCenturySchlbk-Roman.pmf \ Souvenir-DemiItalic.pmf \ diff --git a/hw/xprint/config/C/print/models/SPSPARC2/fonts/Makefile.am b/hw/xprint/config/C/print/models/SPSPARC2/fonts/Makefile.am index 8cc269459..d1ee6cf42 100644 --- a/hw/xprint/config/C/print/models/SPSPARC2/fonts/Makefile.am +++ b/hw/xprint/config/C/print/models/SPSPARC2/fonts/Makefile.am @@ -1,6 +1,6 @@ xpcdir = @xpconfigdir@/C/print/models/SPSPARC2/fonts -parentdir = @xpconfigdir@/C/print/models/PSdefault/fonts +parentdir = ../../PSdefault/fonts XPFONTS = \ Courier-Bold.pmf \ diff --git a/include/dix-config.h.in b/include/dix-config.h.in index ce68ed8b6..287585c32 100644 --- a/include/dix-config.h.in +++ b/include/dix-config.h.in @@ -35,6 +35,9 @@ /* Support Damage extension */ #undef DAMAGE +/* Build for darwin with Quartz support */ +#undef DARWIN_WITH_QUARTZ + /* Use OsVendorInit */ #undef DDXOSINIT @@ -423,7 +426,17 @@ #undef XVENDORNAME /* Endian order */ -#undef X_BYTE_ORDER +#undef _X_BYTE_ORDER +/* Deal with multiple architecture compiles on Mac OS X */ +#ifndef __APPLE_CC__ +#define X_BYTE_ORDER _X_BYTE_ORDER +#else +#ifdef __BIG_ENDIAN__ +#define X_BYTE_ORDER X_BIG_ENDIAN +#else +#define X_BYTE_ORDER X_LITTLE_ENDIAN +#endif +#endif /* Enable GNU and other extensions to the C environment for GLIBC */ #undef _GNU_SOURCE diff --git a/include/xorg-server.h.in b/include/xorg-server.h.in index 48196d8b6..7b2a4d193 100644 --- a/include/xorg-server.h.in +++ b/include/xorg-server.h.in @@ -191,7 +191,17 @@ #undef XVENDORNAME /* Endian order */ -#undef X_BYTE_ORDER +#undef _X_BYTE_ORDER +/* Deal with multiple architecture compiles on Mac OS X */ +#ifndef __APPLE_CC__ +#define X_BYTE_ORDER _X_BYTE_ORDER +#else +#ifdef __BIG_ENDIAN__ +#define X_BYTE_ORDER X_BIG_ENDIAN +#else +#define X_BYTE_ORDER X_LITTLE_ENDIAN +#endif +#endif /* BSD-compliant source */ #undef _BSD_SOURCE diff --git a/mi/miinitext.c b/mi/miinitext.c index e270bc60a..f14254051 100644 --- a/mi/miinitext.c +++ b/mi/miinitext.c @@ -345,16 +345,18 @@ extern void XFree86DGAExtensionInit(INITARGS); #endif #ifdef GLXEXT typedef struct __GLXprovider __GLXprovider; -extern __GLXprovider __glXMesaProvider; -extern void GlxPushProvider(__GLXprovider *impl); -#ifndef __DARWIN__ -extern void GlxExtensionInit(INITARGS); -extern void GlxWrapInitVisuals(miInitVisualsProcPtr *); -#else +#ifdef INXDARWINAPP +extern __GLXprovider* __DarwinglXMesaProvider; +extern void DarwinGlxPushProvider(__GLXprovider *impl); extern void DarwinGlxExtensionInit(INITARGS); extern void DarwinGlxWrapInitVisuals(miInitVisualsProcPtr *); -#endif -#endif +#else +extern __GLXprovider __glXMesaProvider; +extern void GlxPushProvider(__GLXprovider *impl); +extern void GlxExtensionInit(INITARGS); +extern void GlxWrapInitVisuals(miInitVisualsProcPtr *); +#endif // INXDARWINAPP +#endif // GLXEXT #ifdef XF86DRI extern void XFree86DRIExtensionInit(INITARGS); #endif @@ -642,15 +644,16 @@ InitExtensions(argc, argv) if (!noXFree86DRIExtension) XFree86DRIExtensionInit(); #endif #endif -#ifdef GLXEXT - GlxPushProvider(&__glXMesaProvider); -#ifndef __DARWIN__ - if (!noGlxExtension) GlxExtensionInit(); -#else +#ifdef GLXEXT +#ifdef INXDARWINAPP + DarwinGlxPushProvider(__DarwinglXMesaProvider); if (!noGlxExtension) DarwinGlxExtensionInit(); -#endif -#endif +#else + GlxPushProvider(&__glXMesaProvider); + if (!noGlxExtension) GlxExtensionInit(); +#endif // INXDARWINAPP +#endif // GLXEXT #ifdef XFIXES /* must be before Render to layer DisplayCursor correctly */ if (!noXFixesExtension) XFixesExtensionInit(); diff --git a/mi/mipointer.c b/mi/mipointer.c index c28911bc6..b94feaa91 100644 --- a/mi/mipointer.c +++ b/mi/mipointer.c @@ -70,6 +70,8 @@ static Bool miPointerSetCursorPosition(ScreenPtr pScreen, int x, int y, static Bool miPointerCloseScreen(int index, ScreenPtr pScreen); static void miPointerMove(ScreenPtr pScreen, int x, int y, unsigned long time); +static xEvent* events; /* for WarpPointer MotionNotifies */ + _X_EXPORT Bool miPointerInitialize (pScreen, spriteFuncs, screenFuncs, waitForUpdate) ScreenPtr pScreen; @@ -128,6 +130,9 @@ miPointerInitialize (pScreen, spriteFuncs, screenFuncs, waitForUpdate) miPointer.confined = FALSE; miPointer.x = 0; miPointer.y = 0; + + events = NULL; + return TRUE; } @@ -144,6 +149,8 @@ miPointerCloseScreen (index, pScreen) miPointer.pSpriteScreen = 0; pScreen->CloseScreen = pScreenPriv->CloseScreen; xfree ((pointer) pScreenPriv); + xfree ((pointer) events); + events = NULL; return (*pScreen->CloseScreen) (index, pScreen); } @@ -466,7 +473,31 @@ miPointerGetPosition(DeviceIntPtr pDev, int *x, int *y) void miPointerMove (ScreenPtr pScreen, int x, int y, unsigned long time) { + int i, nevents; + int valuators[2]; + miPointerMoved(inputInfo.pointer, pScreen, x, y, time); + + /* generate motion notify */ + valuators[0] = x; + valuators[1] = y; + + if (!events) + { + events = (xEvent*)xcalloc(sizeof(xEvent), GetMaximumEventsNum()); + + if (!events) + { + FatalError("Could not allocate event store.\n"); + return; + } + } + + nevents = GetPointerEvents(events, inputInfo.pointer, MotionNotify, 0, + POINTER_ABSOLUTE, 0, 2, valuators); + + for (i = 0; i < nevents; i++) + mieqEnqueue(inputInfo.pointer, &events[i]); } /* Move the pointer on the current screen, and update the sprite. */ @@ -474,10 +505,6 @@ void miPointerMoved (DeviceIntPtr pDev, ScreenPtr pScreen, int x, int y, unsigned long time) { - xEvent* events; - int i, nevents; - int valuators[2]; - SetupScreen(pScreen); if (pDev && (pDev->coreEvents || pDev == inputInfo.pointer) && @@ -492,23 +519,4 @@ miPointerMoved (DeviceIntPtr pDev, ScreenPtr pScreen, int x, int y, miPointer.x = x; miPointer.y = y; miPointer.pScreen = pScreen; - - /* generate motion notify */ - valuators[0] = x; - valuators[1] = y; - - events = (xEvent*)xcalloc(sizeof(xEvent), GetMaximumEventsNum()); - if (!events) - { - FatalError("Could not allocate event store.\n"); - return; - } - - nevents = GetPointerEvents(events, pDev, MotionNotify, 0, - POINTER_ABSOLUTE, 0, 2, valuators); - - for (i = 0; i < nevents; i++) - mieqEnqueue(pDev, &events[i]); - - xfree(events); } diff --git a/miext/Makefile.am b/miext/Makefile.am index 4fa584b35..f138963b4 100644 --- a/miext/Makefile.am +++ b/miext/Makefile.am @@ -2,4 +2,7 @@ SUBDIRS = damage shadow if COMPOSITE SUBDIRS += cw endif +if XQUARTZ +SUBDIRS += rootless +endif DIST_SUBDIRS = damage shadow cw rootless diff --git a/miext/rootless/Makefile.am b/miext/rootless/Makefile.am index ecf762a64..8dae6d237 100644 --- a/miext/rootless/Makefile.am +++ b/miext/rootless/Makefile.am @@ -1,14 +1,13 @@ -EXTRA_DIST = \ - accel/rlAccel.c \ - accel/rlAccel.h \ - accel/rlBlt.c \ - accel/rlCopy.c \ - accel/rlFill.c \ - accel/rlFillRect.c \ - accel/rlFillSpans.c \ - accel/rlGlyph.c \ - accel/rlSolid.c \ - README.txt \ +AM_CFLAGS = \ + $(DIX_CFLAGS) \ + $(XORG_CFLAGS) + +INCLUDES = -I$(top_srcdir)/hw/xfree86/os-support + +SUBDIRS = safeAlpha accel + +noinst_LTLIBRARIES = librootless.la +librootless_la_SOURCES = \ rootlessCommon.c \ rootlessCommon.h \ rootlessConfig.h \ @@ -17,7 +16,7 @@ EXTRA_DIST = \ rootlessScreen.c \ rootlessValTree.c \ rootlessWindow.c \ - rootlessWindow.h \ - safeAlpha/safeAlpha.h \ - safeAlpha/safeAlphaPicture.c \ - safeAlpha/safeAlphaWindow.c + rootlessWindow.h + +EXTRA_DIST = \ + README.txt diff --git a/miext/rootless/accel/Makefile.am b/miext/rootless/accel/Makefile.am new file mode 100644 index 000000000..c49d5fb47 --- /dev/null +++ b/miext/rootless/accel/Makefile.am @@ -0,0 +1,18 @@ +AM_CFLAGS = \ + $(DIX_CFLAGS) \ + $(XORG_CFLAGS) + +INCLUDES = -I$(srcdir)/.. -I$(top_srcdir)/hw/xfree86/os-support + + +noinst_LTLIBRARIES = librlAccel.la +librlAccel_la_SOURCES = rlAccel.c \ + rlBlt.c \ + rlCopy.c \ + rlFill.c \ + rlFillRect.c \ + rlFillSpans.c \ + rlGlyph.c \ + rlSolid.c + +EXTRA_DIST = rlAccel.h diff --git a/miext/rootless/accel/rlBlt.c b/miext/rootless/accel/rlBlt.c index d1e765836..2cf72eb22 100644 --- a/miext/rootless/accel/rlBlt.c +++ b/miext/rootless/accel/rlBlt.c @@ -31,6 +31,7 @@ #include #endif +#include /* For NULL */ #include "fb.h" #include "rootlessCommon.h" #include "rlAccel.h" diff --git a/miext/rootless/rootlessCommon.c b/miext/rootless/rootlessCommon.c index 8fd922d4a..9cbb7fa1b 100644 --- a/miext/rootless/rootlessCommon.c +++ b/miext/rootless/rootlessCommon.c @@ -33,6 +33,9 @@ #include #endif +#include /* For NULL */ +#include /* For CHAR_BIT */ + #include "rootlessCommon.h" unsigned int rootless_CopyBytes_threshold = 0; diff --git a/miext/rootless/rootlessGC.c b/miext/rootless/rootlessGC.c index 5341267fb..b26f52c54 100644 --- a/miext/rootless/rootlessGC.c +++ b/miext/rootless/rootlessGC.c @@ -33,6 +33,7 @@ #include #endif +#include /* For NULL */ #include "mi.h" #include "scrnintstr.h" #include "gcstruct.h" diff --git a/miext/rootless/rootlessValTree.c b/miext/rootless/rootlessValTree.c index 97348f58e..4f16530cc 100644 --- a/miext/rootless/rootlessValTree.c +++ b/miext/rootless/rootlessValTree.c @@ -93,6 +93,7 @@ Equipment Corporation. #include #endif +#include /* For NULL */ #include #include "scrnintstr.h" #include "validate.h" diff --git a/miext/rootless/rootlessWindow.c b/miext/rootless/rootlessWindow.c index e89ebf897..30b7daaab 100644 --- a/miext/rootless/rootlessWindow.c +++ b/miext/rootless/rootlessWindow.c @@ -33,6 +33,10 @@ #include #endif +#include /* For NULL */ +#include /* For CHAR_BIT */ +#include + #include "rootlessCommon.h" #include "rootlessWindow.h" @@ -325,8 +329,8 @@ RootlessEnsureFrame(WindowPtr pWin) RootlessWindowRec *winRec; #ifdef SHAPE RegionRec shape; - RegionPtr pShape = NULL; #endif + RegionPtr pShape = NULL; if (WINREC(pWin) != NULL) return WINREC(pWin); diff --git a/miext/rootless/safeAlpha/Makefile.am b/miext/rootless/safeAlpha/Makefile.am new file mode 100644 index 000000000..7592c1840 --- /dev/null +++ b/miext/rootless/safeAlpha/Makefile.am @@ -0,0 +1,12 @@ +AM_CFLAGS = \ + $(DIX_CFLAGS) \ + $(XORG_CFLAGS) + +INCLUDES = -I$(srcdir)/.. -I$(top_srcdir)/hw/xfree86/os-support + + +noinst_LTLIBRARIES = libsafeAlpha.la +libsafeAlpha_la_SOURCES = safeAlphaPicture.c \ + safeAlphaWindow.c + +EXTRA_DIST = safeAlpha.h diff --git a/miext/rootless/safeAlpha/safeAlphaPicture.c b/miext/rootless/safeAlpha/safeAlphaPicture.c index 8550cc01f..6ccc05a27 100644 --- a/miext/rootless/safeAlpha/safeAlphaPicture.c +++ b/miext/rootless/safeAlpha/safeAlphaPicture.c @@ -33,15 +33,19 @@ * Copyright © 2000 Keith Packard, member of The XFree86 Project, Inc. */ + +#ifdef HAVE_DIX_CONFIG_H +#include +#endif #ifdef RENDER +#include /* For NULL */ #include "fb.h" #include "picturestr.h" #include "mipict.h" #include "fbpict.h" #include "safeAlpha.h" #include "rootlessCommon.h" - # define mod(a,b) ((b) == 1 ? 0 : (a) >= 0 ? (a) % (b) : (b) - (-a) % (b)) diff --git a/miext/rootless/safeAlpha/safeAlphaWindow.c b/miext/rootless/safeAlpha/safeAlphaWindow.c index 8884c107e..5226782fe 100644 --- a/miext/rootless/safeAlpha/safeAlphaWindow.c +++ b/miext/rootless/safeAlpha/safeAlphaWindow.c @@ -32,6 +32,10 @@ * Copyright © 1998 Keith Packard */ + +#ifdef HAVE_DIX_CONFIG_H +#include +#endif #include "fb.h" #include "safeAlpha.h" #include "rootlessCommon.h" diff --git a/os/utils.c b/os/utils.c index 7c725e38d..612c2644a 100644 --- a/os/utils.c +++ b/os/utils.c @@ -1871,7 +1871,7 @@ Fopen(char *file, char *type) pidlist = cur; #ifdef DEBUG - ErrorF("Popen: `%s', fp = %p\n", command, iop); + ErrorF("Fopen(%s), fp = %p\n", file, iop); #endif return iop; diff --git a/randr/rrcrtc.c b/randr/rrcrtc.c index fdd1d429d..1f7462f28 100644 --- a/randr/rrcrtc.c +++ b/randr/rrcrtc.c @@ -290,6 +290,12 @@ RRCrtcSet (RRCrtcPtr crtc, RRScreenRate rate; Bool ret; + if (!mode) + { + RRCrtcNotify (crtc, NULL, x, y, rotation, 0, NULL); + return TRUE; + } + size.width = mode->mode.width; size.height = mode->mode.height; if (outputs[0]->mmWidth && outputs[0]->mmHeight) @@ -310,7 +316,10 @@ RRCrtcSet (RRCrtcPtr crtc, * Old 1.0 interface tied screen size to mode size */ if (ret) + { RRCrtcNotify (crtc, mode, x, y, rotation, 1, outputs); + RRScreenSizeNotify (pScreen); + } return ret; } #endif @@ -667,6 +676,27 @@ ProcRRSetCrtcConfig (ClientPtr client) return BadMatch; } } + /* validate clones */ + for (i = 0; i < numOutputs; i++) + { + for (j = 0; j < numOutputs; j++) + { + int k; + if (i == j) + continue; + for (k = 0; k < outputs[i]->numClones; k++) + { + if (outputs[i]->clones[k] == outputs[j]) + break; + } + if (k == outputs[i]->numClones) + { + if (outputs) + xfree (outputs); + return BadMatch; + } + } + } pScreen = crtc->pScreen; pScrPriv = rrGetScrPriv(pScreen); diff --git a/randr/rrproperty.c b/randr/rrproperty.c index 916caf030..edfed1f47 100644 --- a/randr/rrproperty.c +++ b/randr/rrproperty.c @@ -410,7 +410,7 @@ ProcRRConfigureOutputProperty (ClientPtr client) RROutputPtr output; int num_valid; - REQUEST_SIZE_MATCH(xRRConfigureOutputPropertyReq); + REQUEST_AT_LEAST_SIZE(xRRConfigureOutputPropertyReq); output = LookupOutput (client, stuff->output, DixReadAccess); diff --git a/randr/rrscreen.c b/randr/rrscreen.c index e10aa0362..168000351 100644 --- a/randr/rrscreen.c +++ b/randr/rrscreen.c @@ -26,6 +26,9 @@ extern char *ConnectionInfo; static int padlength[4] = {0, 3, 2, 1}; +static CARD16 +RR10CurrentSizeID (ScreenPtr pScreen); + /* * Edit connection information block so that new clients * see the current screen size on connect @@ -96,10 +99,7 @@ RRDeliverScreenEvent (ClientPtr client, WindowPtr pWin, ScreenPtr pScreen) rrScrPriv (pScreen); xRRScreenChangeNotifyEvent se; RRCrtcPtr crtc = pScrPriv->numCrtcs ? pScrPriv->crtcs[0] : NULL; - RROutputPtr output = pScrPriv->numOutputs ? pScrPriv->outputs[0] : NULL; - RRModePtr mode = crtc ? crtc->mode : NULL; WindowPtr pRoot = WindowTable[pScreen->myNum]; - int i; se.type = RRScreenChangeNotify + RREventBase; se.rotation = (CARD8) (crtc ? crtc->rotation : RR_Rotate_0); @@ -115,32 +115,12 @@ RRDeliverScreenEvent (ClientPtr client, WindowPtr pWin, ScreenPtr pScreen) #endif se.sequenceNumber = client->sequence; - if (mode) - { - se.sizeID = -1; - for (i = 0; i < output->numModes; i++) - if (mode == output->modes[i]) - { - se.sizeID = i; - break; - } - se.widthInPixels = mode->mode.width; - se.heightInPixels = mode->mode.height; - se.widthInMillimeters = pScreen->mmWidth; - se.heightInMillimeters = pScreen->mmHeight; - } - else - { - /* - * This "shouldn't happen", but a broken DDX can - * forget to set the current configuration on GetInfo - */ - se.sizeID = 0xffff; - se.widthInPixels = 0; - se.heightInPixels = 0; - se.widthInMillimeters = 0; - se.heightInMillimeters = 0; - } + se.sizeID = RR10CurrentSizeID (pScreen); + + se.widthInPixels = pScreen->width; + se.heightInPixels = pScreen->height; + se.widthInMillimeters = pScreen->mmWidth; + se.heightInMillimeters = pScreen->mmHeight; WriteEventsToClient (client, 1, (xEvent *) &se); } @@ -949,3 +929,27 @@ sendReply: return (client->noClientException); } +static CARD16 +RR10CurrentSizeID (ScreenPtr pScreen) +{ + CARD16 sizeID = 0xffff; + RROutputPtr output = RRFirstOutput (pScreen); + + if (output) + { + RR10DataPtr data = RR10GetData (pScreen, output); + if (data) + { + int i; + for (i = 0; i < data->nsize; i++) + if (data->sizes[i].width == pScreen->width && + data->sizes[i].height == pScreen->height) + { + sizeID = (CARD16) i; + break; + } + xfree (data); + } + } + return sizeID; +} diff --git a/xfixes/cursor.c b/xfixes/cursor.c index 86a512c25..3cdacc0e4 100755 --- a/xfixes/cursor.c +++ b/xfixes/cursor.c @@ -143,7 +143,8 @@ CursorDisplayCursor (ScreenPtr pScreen, CursorCurrent = pCursor; for (e = cursorEvents; e; e = e->next) { - if (e->eventMask & XFixesDisplayCursorNotifyMask) + if ((e->eventMask & XFixesDisplayCursorNotifyMask) && + !e->pClient->clientGone) { xXFixesCursorNotifyEvent ev; ev.type = XFixesEventBase + XFixesCursorNotify; diff --git a/xfixes/select.c b/xfixes/select.c index d1c22c552..f0a9f2f4f 100755 --- a/xfixes/select.c +++ b/xfixes/select.c @@ -78,7 +78,9 @@ XFixesSelectionCallback (CallbackListPtr *callbacks, pointer data, pointer args) } for (e = selectionEvents; e; e = e->next) { - if (e->selection == selection->selection && (e->eventMask & eventMask)) + if (e->selection == selection->selection && + (e->eventMask & eventMask) && + !e->pClient->clientGone) { xXFixesSelectionNotifyEvent ev;