summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKeith Packard <keithp@keithp.com>2008-05-04 22:24:56 -0700
committerKeith Packard <keithp@keithp.com>2008-05-04 22:24:56 -0700
commit33e5a176e62a0114cb8cca9447798c6d6b6665ed (patch)
tree8efa34606aae171fe1bad7aff993a2a94910d76e
parente48f6bcd94b310e5c79939bdb1703f9555a3cdd1 (diff)
parentefa65a0317e12c9ad34fa00fe90bf5eae9fa2670 (diff)
Merge commit 'origin/master' into transform-proposal-oldtransform-proposal
Conflicts: configure.ac exa/exa.c
-rw-r--r--.gitignore2
-rw-r--r--GL/Makefile.am7
-rw-r--r--GL/apple/Makefile.am24
-rw-r--r--GL/apple/aglGlx.c1354
-rw-r--r--GL/glx/Makefile.am5
-rw-r--r--GL/glx/glxglcore.c87
-rw-r--r--GL/glx/glxscreens.c15
-rw-r--r--GL/glx/glxutil.c58
-rw-r--r--GL/mesa/.gitignore32
-rw-r--r--GL/mesa/Makefile.am18
-rw-r--r--GL/mesa/X/Makefile.am27
-rw-r--r--GL/mesa/dummy.c0
-rw-r--r--GL/mesa/glapi/Makefile.am20
-rw-r--r--GL/mesa/main/Makefile.am86
-rw-r--r--GL/mesa/math/Makefile.am27
-rw-r--r--GL/mesa/shader/Makefile.am39
-rw-r--r--GL/mesa/shader/grammar/Makefile.am20
-rw-r--r--GL/mesa/shader/slang/Makefile.am41
-rw-r--r--GL/mesa/swrast/Makefile.am50
-rw-r--r--GL/mesa/swrast_setup/Makefile.am20
-rw-r--r--GL/mesa/tnl/Makefile.am37
-rw-r--r--GL/mesa/vbo/Makefile.am35
-rwxr-xr-xGL/symlink-mesa.sh166
-rw-r--r--Xext/EVI.c200
-rw-r--r--Xext/EVIstruct.h58
-rw-r--r--Xext/Makefile.am23
-rw-r--r--Xext/appgroup.c775
-rw-r--r--Xext/appgroup.h67
-rw-r--r--Xext/cup.c342
-rw-r--r--Xext/mitmisc.c155
-rw-r--r--Xext/sampleEVI.c123
-rw-r--r--Xext/security.c8
-rw-r--r--Xi/exevents.c2
-rw-r--r--acinclude.m442
-rw-r--r--composite/Makefile.am1
-rw-r--r--composite/compext.c193
-rw-r--r--composite/compinit.c13
-rw-r--r--composite/compint.h24
-rw-r--r--composite/compoverlay.c159
-rw-r--r--configure.ac164
-rw-r--r--dix/Makefile.am14
-rw-r--r--dix/devices.c2
-rw-r--r--dix/dispatch.c9
-rw-r--r--dix/dixutils.c3
-rw-r--r--dix/getevents.c12
-rw-r--r--dix/main.c33
-rw-r--r--dix/window.c67
-rw-r--r--exa/Makefile.am1
-rw-r--r--exa/exa.c133
-rw-r--r--exa/exa.h2
-rw-r--r--exa/exa_accel.c32
-rw-r--r--exa/exa_glyphs.c897
-rw-r--r--exa/exa_offscreen.c49
-rw-r--r--exa/exa_priv.h59
-rw-r--r--exa/exa_render.c228
-rw-r--r--fb/Makefile.am6
-rw-r--r--fb/fb.h2
-rw-r--r--fb/fbpseudocolor.c2248
-rw-r--r--fb/fbpseudocolor.h20
-rw-r--r--fb/wfbrename.h8
-rw-r--r--hw/dmx/dmx-config.h2
-rw-r--r--hw/dmx/dmxextension.c1
-rw-r--r--hw/kdrive/Makefile.am4
-rw-r--r--hw/kdrive/ati/Makefile.am4
-rw-r--r--hw/kdrive/chips/Makefile.am4
-rw-r--r--hw/kdrive/ephyr/GL/internal/dri_interface.h517
-rw-r--r--hw/kdrive/ephyr/Makefile.am107
-rw-r--r--hw/kdrive/ephyr/XF86dri.c7
-rw-r--r--hw/kdrive/ephyr/ephyr.c31
-rw-r--r--hw/kdrive/ephyr/ephyrdri.c7
-rw-r--r--hw/kdrive/ephyr/ephyrdriext.c4
-rw-r--r--hw/kdrive/ephyr/ephyrglxext.c5
-rw-r--r--hw/kdrive/ephyr/ephyrhostglx.c4
-rw-r--r--hw/kdrive/ephyr/hostx.c11
-rw-r--r--hw/kdrive/ephyr/hostx.h4
-rw-r--r--hw/kdrive/ephyr/xf86dri.h120
-rw-r--r--hw/kdrive/epson/Makefile.am4
-rw-r--r--hw/kdrive/fake/Makefile.am4
-rw-r--r--hw/kdrive/fbdev/Makefile.am4
-rw-r--r--hw/kdrive/fbdev/fbdev.c26
-rw-r--r--hw/kdrive/i810/Makefile.am4
-rw-r--r--hw/kdrive/linux/keyboard.c26
-rw-r--r--hw/kdrive/linux/tslib.c4
-rw-r--r--hw/kdrive/mach64/Makefile.am4
-rw-r--r--hw/kdrive/mga/Makefile.am4
-rw-r--r--hw/kdrive/neomagic/Makefile.am4
-rw-r--r--hw/kdrive/nvidia/Makefile.am4
-rw-r--r--hw/kdrive/pm2/Makefile.am4
-rw-r--r--hw/kdrive/r128/Makefile.am4
-rw-r--r--hw/kdrive/sdl/Makefile.am4
-rw-r--r--hw/kdrive/sis300/Makefile.am4
-rw-r--r--hw/kdrive/smi/Makefile.am4
-rw-r--r--hw/kdrive/vesa/Makefile.am4
-rw-r--r--hw/kdrive/via/Makefile.am4
-rw-r--r--hw/xfree86/common/compiler.h6
-rw-r--r--hw/xfree86/common/xf86.h1
-rw-r--r--hw/xfree86/common/xf86AutoConfig.c149
-rw-r--r--hw/xfree86/common/xf86Bus.c4
-rw-r--r--hw/xfree86/common/xf86Config.c25
-rw-r--r--hw/xfree86/common/xf86Init.c60
-rw-r--r--hw/xfree86/common/xf86Privstr.h3
-rw-r--r--hw/xfree86/common/xf86Xinput.c18
-rw-r--r--hw/xfree86/dixmods/GLcoremodule.c63
-rw-r--r--hw/xfree86/dixmods/Makefile.am6
-rw-r--r--hw/xfree86/dixmods/extmod/modinit.c27
-rw-r--r--hw/xfree86/dixmods/extmod/modinit.h26
-rw-r--r--hw/xfree86/dixmods/glxmodule.c37
-rw-r--r--hw/xfree86/doc/man/xorg.conf.man.pre8
-rw-r--r--hw/xfree86/dri/dri.c2
-rw-r--r--hw/xfree86/loader/dixsym.c12
-rw-r--r--hw/xfree86/loader/loader.c2
-rw-r--r--hw/xfree86/loader/xf86sym.c1
-rw-r--r--hw/xfree86/modes/xf86Crtc.h6
-rw-r--r--hw/xfree86/modes/xf86Rotate.c21
-rw-r--r--hw/xfree86/os-support/bsd/bsdResource.c2
-rw-r--r--hw/xfree86/os-support/bsd/i386_video.c8
-rw-r--r--hw/xfree86/os-support/bus/Pci.h8
-rw-r--r--hw/xfree86/os-support/linux/lnxResource.c1
-rw-r--r--hw/xfree86/os-support/linux/lnx_video.c4
-rw-r--r--hw/xfree86/utils/xorgcfg/expert.c50
-rw-r--r--hw/xfree86/utils/xorgcfg/loadmod.c4
-rw-r--r--hw/xfree86/x86emu/prim_ops.c2
-rw-r--r--hw/xfree86/x86emu/x86emu/prim_x86_gcc.h2
-rw-r--r--hw/xfree86/x86emu/x86emu/types.h2
-rw-r--r--hw/xnest/Args.c5
-rw-r--r--hw/xprint/Makefile.am3
-rw-r--r--hw/xprint/ps/psout.h2
-rw-r--r--hw/xquartz/GL/Makefile.am13
-rw-r--r--hw/xquartz/GL/indirect.c (renamed from GL/apple/indirect.c)58
-rw-r--r--hw/xquartz/Makefile.am15
-rw-r--r--hw/xquartz/X11Application.h5
-rw-r--r--hw/xquartz/X11Application.m100
-rw-r--r--hw/xquartz/X11Controller.h10
-rw-r--r--hw/xquartz/X11Controller.m63
-rw-r--r--hw/xquartz/applewm.c2
-rw-r--r--hw/xquartz/bundle/English.lproj/Localizable.stringsbin1094 -> 1078 bytes
-rw-r--r--hw/xquartz/darwin.c95
-rw-r--r--hw/xquartz/darwin.h39
-rw-r--r--hw/xquartz/darwinEvents.c495
-rw-r--r--hw/xquartz/darwinEvents.h41
-rw-r--r--hw/xquartz/darwinKeyboard.c1013
-rw-r--r--hw/xquartz/pseudoramiX.c37
-rw-r--r--hw/xquartz/quartz.c10
-rw-r--r--hw/xquartz/quartz.h6
-rw-r--r--hw/xquartz/quartzAudio.c2
-rw-r--r--hw/xquartz/quartzCocoa.m8
-rw-r--r--hw/xquartz/quartzCommon.h11
-rw-r--r--hw/xquartz/quartzKeyboard.c1010
-rw-r--r--hw/xquartz/quartzKeyboard.h13
-rw-r--r--hw/xquartz/quartzStartup.c93
-rw-r--r--hw/xquartz/sanitizedCarbon.h32
-rw-r--r--hw/xquartz/sanitizedCocoa.h27
-rw-r--r--hw/xquartz/threadSafety.c70
-rw-r--r--hw/xquartz/threadSafety.h (renamed from hw/xquartz/darwinKeyboard.h)43
-rw-r--r--hw/xquartz/xpr/Makefile.am25
-rw-r--r--hw/xquartz/xpr/dri.h2
-rw-r--r--hw/xquartz/xpr/xpr.h3
-rw-r--r--hw/xquartz/xpr/xprAppleWM.c2
-rw-r--r--hw/xquartz/xpr/xprCursor.c4
-rw-r--r--hw/xquartz/xpr/xprEvent.c91
-rw-r--r--hw/xquartz/xpr/xprEvent.h34
-rw-r--r--hw/xquartz/xpr/xprFrame.c43
-rw-r--r--hw/xquartz/xpr/xprScreen.c57
-rw-r--r--include/dix-config.h.in17
-rw-r--r--include/dixstruct.h4
-rw-r--r--include/globals.h16
-rw-r--r--include/servermd.h32
-rw-r--r--include/xorg-server.h.in3
-rw-r--r--mi/micoord.h2
-rw-r--r--mi/miinitext.c55
-rw-r--r--mi/mivaltree.c4
-rw-r--r--miext/rootless/Makefile.am2
-rw-r--r--miext/rootless/README.txt4
-rw-r--r--miext/rootless/accel/Makefile.am15
-rw-r--r--miext/rootless/accel/rlAccel.c147
-rw-r--r--miext/rootless/accel/rlAccel.h140
-rw-r--r--miext/rootless/accel/rlBlt.c408
-rw-r--r--miext/rootless/accel/rlCopy.c106
-rw-r--r--miext/rootless/accel/rlFill.c220
-rw-r--r--miext/rootless/accel/rlFillRect.c117
-rw-r--r--miext/rootless/accel/rlFillSpans.c105
-rw-r--r--miext/rootless/accel/rlGlyph.c169
-rw-r--r--miext/rootless/accel/rlSolid.c111
-rw-r--r--miext/rootless/rootlessConfig.h3
-rw-r--r--miext/rootless/rootlessGC.c8
-rw-r--r--miext/rootless/rootlessWindow.c62
-rw-r--r--os/connection.c3
-rw-r--r--os/utils.c12
-rw-r--r--xkb/xkbActions.c2
-rw-r--r--xorg-server.pc.in2
190 files changed, 4421 insertions, 10782 deletions
diff --git a/.gitignore b/.gitignore
index 548e78423..a6925d98f 100644
--- a/.gitignore
+++ b/.gitignore
@@ -278,6 +278,8 @@ hw/xprint/doc/Xprt.1x
hw/xprint/doc/Xprt.man
hw/xprint/dpmsstubs-wrapper.c
hw/xprint/miinitext-wrapper.c
+hw/xquartz/xpr/Xquartz
+hw/xquartz/xpr/Xquartz.1
include/dix-config.h
include/kdrive-config.h
include/xgl-config.h
diff --git a/GL/Makefile.am b/GL/Makefile.am
index 29d03f2d6..c3ac15564 100644
--- a/GL/Makefile.am
+++ b/GL/Makefile.am
@@ -1,9 +1,4 @@
-if XQUARTZ
-XQUARTZ_SUBDIRS = apple
-endif
-
-SUBDIRS = glx mesa $(XQUARTZ_SUBDIRS)
-DIST_SUBDIRS = glx mesa apple
+SUBDIRS = glx
WINDOWS_EXTRAS = \
windows/ChangeLog \
diff --git a/GL/apple/Makefile.am b/GL/apple/Makefile.am
deleted file mode 100644
index c064c03f8..000000000
--- a/GL/apple/Makefile.am
+++ /dev/null
@@ -1,24 +0,0 @@
-AM_CFLAGS = $(DIX_CFLAGS)
-AM_CPPFLAGS = \
- -I$(top_srcdir) \
- -I$(top_srcdir)/GL/glx \
- -I$(top_srcdir)/GL/include \
- -I$(top_srcdir)/GL/mesa/glapi \
- -I$(top_srcdir)/hw/xquartz \
- -I$(top_srcdir)/hw/xquartz/xpr \
- -I$(top_srcdir)/miext/damage
-
-if HAVE_AGL_FRAMEWORK
-noinst_LIBRARIES = libAGLcore.a
-libAGLcore_a_SOURCES = aglGlx.c \
- $(top_srcdir)/hw/xquartz/xpr/x-list.c \
- $(top_srcdir)/hw/xquartz/xpr/x-list.h \
- $(top_srcdir)/hw/xquartz/xpr/x-hash.c \
- $(top_srcdir)/hw/xquartz/xpr/x-hash.h \
- $(top_srcdir)/hw/dmx/glxProxy/compsize.c
-endif
-
-#noinst_LIBRARIES = libCGLcore.a
-#libCGLcore_a_SOURCES = \
-# indirect.c \
-# $(top_srcdir)/hw/dmx/glxProxy/compsize.c
diff --git a/GL/apple/aglGlx.c b/GL/apple/aglGlx.c
deleted file mode 100644
index 900a9a96e..000000000
--- a/GL/apple/aglGlx.c
+++ /dev/null
@@ -1,1354 +0,0 @@
-/*
- * GLX implementation that uses Apple's AGL.framework for OpenGL
- *
- * FIXME: This file and indirect.c are very similar. The two should be
- * merged by introducing suitable abstractions.
- */
-/*
- * Copyright (c) 2002 Greg Parker. All Rights Reserved.
- * Copyright (c) 2004 Torrey T. Lyons. All Rights Reserved.
- *
- * Large portions of this file are copied from Mesa's xf86glx.c,
- * which contains the following copyright:
- *
- * Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas.
- * 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.
- */
-
-#ifdef HAVE_DIX_CONFIG_H
-#include <dix-config.h>
-#endif
-
-#include "quartzCommon.h"
-#include <AGL/agl.h>
-#include "cr.h"
-
-// X11 and X11's glx
-#undef BOOL
-#define BOOL xBOOL
-#include "quartz.h"
-#include <miscstruct.h>
-#include <windowstr.h>
-#include <resource.h>
-#include <GL/glxint.h>
-#include <GL/glxtokens.h>
-#include <scrnintstr.h>
-#include <glxserver.h>
-#include <glxscreens.h>
-#include <glxdrawable.h>
-#include <glxcontext.h>
-#include <glxext.h>
-#include <glxutil.h>
-#include <glxscreens.h>
-#include <GL/internal/glcore.h>
-#undef BOOL
-
-#include "glcontextmodes.h"
-
-// ggs: needed to call back to glx with visual configs
-extern void GlxSetVisualConfigs(int nconfigs, __GLXvisualConfig *configs, void **configprivs);
-
-// Write debugging output, or not
-#ifdef GLAQUA_DEBUG
-#define GLAQUA_DEBUG_MSG ErrorF
-#else
-#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);
-}
-
-
-// some prototypes
-static Bool glAquaScreenProbe(int screen);
-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);
-
-
-/*
- * 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 */
-};
-
-void *__glXglDDXScreenInfo(void) {
- return &__glDDXScreenInfo;
-}
-
-static __GLXextensionInfo __glDDXExtensionInfo = {
- GL_CORE_APPLE,
- glAquaResetExtension,
- glAquaInitVisuals,
- glAquaSetVisualConfigs
-};
-
-void *__glXglDDXExtensionInfo(void) {
- 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 {
- GLboolean (*resize)(__GLdrawableBuffer *buf, GLint x, GLint y,
- GLuint width, GLuint height,
- __GLdrawablePrivate *glPriv,
- GLuint bufferMask);
-} GLAquaDrawableRec;
-
-struct __GLcontextRec {
- struct __GLinterfaceRec interface; // required to be first
-
- AGLContext ctx;
- AGLPixelFormat pixelFormat;
-
- Bool isAttached; // TRUE if ctx is really attached to a window
-};
-
-
-// Context manipulation; return GL_FALSE on failure
-static GLboolean glAquaDestroyContext(__GLcontext *gc)
-{
- GLAQUA_DEBUG_MSG("glAquaDestroyContext (ctx 0x%x)\n", gc->ctx);
-
- if (gc) {
- if (gc->ctx) aglDestroyContext(gc->ctx);
- if (gc->pixelFormat) aglDestroyPixelFormat(gc->pixelFormat);
- free(gc);
- }
-
- return GL_TRUE;
-}
-
-
-static GLboolean glAquaLoseCurrent(__GLcontext *gc)
-{
- GLAQUA_DEBUG_MSG("glAquaLoseCurrent (ctx 0x%x)\n", gc->ctx);
-
- aglSetCurrentContext(NULL);
- __glXLastContext = NULL; // Mesa does this; why?
- gc->isAttached = FALSE;
-
- return GL_TRUE;
-}
-
-
-/*
- * Attach a GL context to a GL drawable
- * If glPriv is NULL, the context is detached.
- */
-static void attach(__GLcontext *gc, __GLdrawablePrivate *glPriv)
-{
- __GLXdrawablePrivate *glxPriv;
-
- if (glPriv == NULL) {
- // attaching to nothing
- GLAQUA_DEBUG_MSG("unattaching\n");
- aglSetDrawable(gc->ctx, NULL);
- gc->isAttached = FALSE;
- return;
- }
-
- // Note that when resizing, the X11 WindowPtr already has its
- // new size and position, but the Aqua window does not.
-
- glxPriv = (__GLXdrawablePrivate *)glPriv->other;
-
- if (glxPriv->type == DRAWABLE_WINDOW) {
- WindowPtr pWin = (WindowPtr) glxPriv->pDraw;
- WindowPtr topWin = quartzProcs->TopLevelParent(pWin);
- CRWindowPtr crWinPtr;
- AGLDrawable newPort;
-
- if (glPriv->width <= 0 || glPriv->height <= 0) {
- // attach to zero size drawable - will really attach later
- GLAQUA_DEBUG_MSG("couldn't attach to zero size drawable\n");
- aglSetDrawable(gc->ctx, NULL);
- gc->isAttached = FALSE;
- return;
- }
-
- crWinPtr = (CRWindowPtr) quartzProcs->FrameForWindow(pWin, FALSE);
-
- if (crWinPtr) {
- newPort = (AGLDrawable) crWinPtr->port;
- } else {
- newPort = NULL;
- }
-
- if (newPort) {
- // FIXME: won't be a CGrafPtr if currently offscreen or fullscreen
- AGLDrawable oldPort = aglGetDrawable(gc->ctx);
- // AGLDrawable newPort = GetWindowPort(window);
-
- // Frame is GLdrawable in X11 global coordinates
- // FIXME: Does this work for multiple screens?
- GLint frame[4] = {glPriv->xOrigin, glPriv->yOrigin, glPriv->width, glPriv->height};
- GLAQUA_DEBUG_MSG("global size %d %d %d %d\n",
- frame[0], frame[1], frame[2], frame[3]);
-
- // Convert to window-local coordinates
- frame[0] -= topWin->drawable.x - topWin->borderWidth;
- frame[1] -= topWin->drawable.y - topWin->borderWidth;
-
- // AGL uses flipped coordinates
- frame[1] = topWin->drawable.height + 2*topWin->borderWidth -
- frame[1] - frame[3];
-
- GLAQUA_DEBUG_MSG("local size %d %d %d %d\n",
- frame[0], frame[1], frame[2], frame[3]);
-
- if (oldPort != newPort) {
- // FIXME: retain/release windows
- if (!aglSetDrawable(gc->ctx, newPort)) return;
- }
- if (!aglSetInteger(gc->ctx, AGL_BUFFER_RECT, frame)) return;
- if (!aglEnable(gc->ctx, AGL_BUFFER_RECT)) return;
- if (!aglSetInteger(gc->ctx, AGL_SWAP_RECT, frame)) return;
- if (!aglEnable(gc->ctx, AGL_SWAP_RECT)) return;
- if (!aglUpdateContext(gc->ctx)) return;
-
- gc->isAttached = TRUE;
- GLAQUA_DEBUG_MSG("attached context 0x%x to window 0x%x\n", gc->ctx,
- pWin->drawable.id);
- } else {
- // attach to not-yet-realized window - will really attach later
- GLAQUA_DEBUG_MSG("couldn't attach to unrealized window\n");
- aglSetDrawable(gc->ctx, NULL);
- gc->isAttached = FALSE;
- }
- } else {
- GLAQUA_DEBUG_MSG("attach: attach to non-window unimplemented\n");
- aglSetDrawable(gc->ctx, NULL);
- gc->isAttached = FALSE;
- }
-}
-
-static GLboolean glAquaMakeCurrent(__GLcontext *gc)
-{
- __GLdrawablePrivate *glPriv = gc->interface.imports.getDrawablePrivate(gc);
-
- GLAQUA_DEBUG_MSG("glAquaMakeCurrent (ctx 0x%x)\n", gc->ctx);
-
- if (!gc->isAttached) {
- attach(gc, glPriv);
- }
-
- return aglSetCurrentContext(gc->ctx);
-}
-
-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)
-{
- GLAQUA_DEBUG_MSG("glAquaCopyContext\n");
-
- return aglCopyContext(src->ctx, dst->ctx, mask);
-}
-
-static GLboolean glAquaForceCurrent(__GLcontext *gc)
-{
- // GLAQUA_DEBUG_MSG("glAquaForceCurrent (ctx 0x%x)\n", gc->ctx);
- return aglSetCurrentContext(gc->ctx);
-}
-
-/* Drawing surface notification callbacks */
-
-static GLboolean glAquaNotifyResize(__GLcontext *gc)
-{
- GLAQUA_DEBUG_MSG("unimplemented glAquaNotifyResize");
- return GL_TRUE;
-}
-
-static void glAquaNotifyDestroy(__GLcontext *gc)
-{
- GLAQUA_DEBUG_MSG("unimplemented glAquaNotifyDestroy");
-}
-
-static void glAquaNotifySwapBuffers(__GLcontext *gc)
-{
- GLAQUA_DEBUG_MSG("unimplemented glAquaNotifySwapBuffers");
-}
-
-/* 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 AGLPixelFormat makeFormat(__GLcontextModes *mode)
-{
- int i;
- GLint attr[64]; // currently uses max of 30
- AGLPixelFormat result;
-
- GLAQUA_DEBUG_MSG("makeFormat\n");
-
- i = 0;
-
- // attr [i++] = AGL_ACCELERATED; // require hwaccel - BAD for multiscreen
- // attr [i++] = AGL_NO_RECOVERY; // disable fallback renderers - BAD
-
- if (mode->stereoMode) {
- attr[i++] = AGL_STEREO;
- }
- if (mode->doubleBufferMode) {
- attr[i++] = AGL_DOUBLEBUFFER;
- }
-
- if (mode->colorIndexMode) {
- attr[i++] = AGL_BUFFER_SIZE;
- attr[i++] = mode->indexBits;
- }
-
- if (mode->rgbMode) {
- attr[i++] = AGL_RGBA;
- attr[i++] = AGL_RED_SIZE;
- attr[i++] = mode->redBits;
- attr[i++] = AGL_GREEN_SIZE;
- attr[i++] = mode->greenBits;
- attr[i++] = AGL_BLUE_SIZE;
- attr[i++] = mode->blueBits;
- attr[i++] = AGL_ALPHA_SIZE;
- attr[i++] = mode->alphaBits;
- }
-
- if (mode->haveAccumBuffer) {
- attr[i++] = AGL_ACCUM_RED_SIZE;
- attr[i++] = mode->accumRedBits;
- attr[i++] = AGL_ACCUM_GREEN_SIZE;
- attr[i++] = mode->accumGreenBits;
- attr[i++] = AGL_ACCUM_BLUE_SIZE;
- attr[i++] = mode->accumBlueBits;
- attr[i++] = AGL_ACCUM_ALPHA_SIZE;
- attr[i++] = mode->accumAlphaBits;
- }
- if (mode->haveDepthBuffer) {
- attr[i++] = AGL_DEPTH_SIZE;
- attr[i++] = mode->depthBits;
- }
- if (mode->haveStencilBuffer) {
- attr[i++] = AGL_STENCIL_SIZE;
- attr[i++] = mode->stencilBits;
- }
-
- attr[i++] = AGL_AUX_BUFFERS;
- attr[i++] = mode->numAuxBuffers;
-
- attr[i++] = AGL_LEVEL;
- attr[i++] = mode->level;
-
- // mode->pixmapMode ?
-
- attr[i++] = AGL_NONE; // end of option list
-
- GLAQUA_DEBUG_MSG("makeFormat almost done\n");
- result = aglChoosePixelFormat(NULL, 0, attr);
- GLAQUA_DEBUG_MSG("makeFormat done (0x%x)\n", result);
- return result;
-}
-
-static __GLinterface *glAquaCreateContext(__GLimports *imports,
- __GLcontextModes *mode,
- __GLinterface *shareGC)
-{
- __GLcontext *result;
- __GLcontext *sharectx = (__GLcontext *)shareGC;
-
- 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 = aglCreateContext(result->pixelFormat,
- (sharectx && sharectx->ctx) ? sharectx->ctx : NULL);
-
- if (!result->ctx) {
- aglDestroyPixelFormat(result->pixelFormat);
- free(result);
- return NULL;
- }
-
- result->isAttached = FALSE;
-
- 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->nextDrawPriv) {
- gc = (__GLcontext *)gx->gc;
- attach(gc, glPriv);
- }
-
- // GL contexts bound to this window for reading
- for (gx = glxPriv->readGlxc; gx != NULL; gx = gx->nextReadPriv) {
- 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->nextDrawPriv) {
- gc = (__GLcontext *)gx->gc;
- attach(gc, NULL);
- }
-
- // GL contexts bound to this window for reading
- for (gx = glxPriv->readGlxc; gx != NULL; gx = gx->nextReadPriv) {
- gc = (__GLcontext *)gx->gc;
- attach(gc, NULL);
- }
- }
-
- pScreen->UnrealizeWindow = screenPriv->UnrealizeWindow;
- result = pScreen->UnrealizeWindow(pWin);
- pScreen->UnrealizeWindow = glAquaUnrealizeWindow;
-
- return result;
-}
-
-
-// Originally copied from Mesa
-
-static int numConfigs = 0;
-static __GLXvisualConfig *visualConfigs = NULL;
-static void **visualPrivates = NULL;
-
-/*
- * In the case the driver defines no GLX visuals we'll use these.
- * Note that for TrueColor and DirectColor visuals, bufferSize is the
- * sum of redSize, greenSize, blueSize and alphaSize, which may be larger
- * than the nplanes/rootDepth of the server's X11 visuals
- */
-#define NUM_FALLBACK_CONFIGS 5
-static __GLXvisualConfig FallbackConfigs[NUM_FALLBACK_CONFIGS] = {
- /* [0] = RGB, double buffered, Z */
- {
- -1, /* vid */
- -1, /* class */
- True, /* rgba */
- -1, -1, -1, 0, /* rgba sizes */
- -1, -1, -1, 0, /* rgba masks */
- 0, 0, 0, 0, /* rgba accum sizes */
- True, /* doubleBuffer */
- False, /* stereo */
- -1, /* bufferSize */
- 16, /* depthSize */
- 0, /* stencilSize */
- 0, /* auxBuffers */
- 0, /* level */
- GLX_NONE, /* visualRating */
- GLX_NONE, /* transparentPixel */
- 0, 0, 0, 0, /* transparent rgba color (floats scaled to ints) */
- 0 /* transparentIndex */
- },
- /* [1] = RGB, double buffered, Z, stencil, accum */
- {
- -1, /* vid */
- -1, /* class */
- True, /* rgba */
- -1, -1, -1, 0, /* rgba sizes */
- -1, -1, -1, 0, /* rgba masks */
- 16, 16, 16, 0, /* rgba accum sizes */
- True, /* doubleBuffer */
- False, /* stereo */
- -1, /* bufferSize */
- 16, /* depthSize */
- 8, /* stencilSize */
- 0, /* auxBuffers */
- 0, /* level */
- GLX_NONE, /* visualRating */
- GLX_NONE, /* transparentPixel */
- 0, 0, 0, 0, /* transparent rgba color (floats scaled to ints) */
- 0 /* transparentIndex */
- },
- /* [2] = RGB+Alpha, double buffered, Z, stencil, accum */
- {
- -1, /* vid */
- -1, /* class */
- True, /* rgba */
- -1, -1, -1, 8, /* rgba sizes */
- -1, -1, -1, -1, /* rgba masks */
- 16, 16, 16, 16, /* rgba accum sizes */
- True, /* doubleBuffer */
- False, /* stereo */
- -1, /* bufferSize */
- 16, /* depthSize */
- 8, /* stencilSize */
- 0, /* auxBuffers */
- 0, /* level */
- GLX_NONE, /* visualRating */
- GLX_NONE, /* transparentPixel */
- 0, 0, 0, 0, /* transparent rgba color (floats scaled to ints) */
- 0 /* transparentIndex */
- },
- /* [3] = RGB+Alpha, single buffered, Z, stencil, accum */
- {
- -1, /* vid */
- -1, /* class */
- True, /* rgba */
- -1, -1, -1, 8, /* rgba sizes */
- -1, -1, -1, -1, /* rgba masks */
- 16, 16, 16, 16, /* rgba accum sizes */
- False, /* doubleBuffer */
- False, /* stereo */
- -1, /* bufferSize */
- 16, /* depthSize */
- 8, /* stencilSize */
- 0, /* auxBuffers */
- 0, /* level */
- GLX_NONE, /* visualRating */
- GLX_NONE, /* transparentPixel */
- 0, 0, 0, 0, /* transparent rgba color (floats scaled to ints) */
- 0 /* transparentIndex */
- },
- /* [4] = CI, double buffered, Z */
- {
- -1, /* vid */
- -1, /* class */
- False, /* rgba? (false = color index) */
- -1, -1, -1, 0, /* rgba sizes */
- -1, -1, -1, 0, /* rgba masks */
- 0, 0, 0, 0, /* rgba accum sizes */
- True, /* doubleBuffer */
- False, /* stereo */
- -1, /* bufferSize */
- 16, /* depthSize */
- 0, /* stencilSize */
- 0, /* auxBuffers */
- 0, /* level */
- GLX_NONE, /* visualRating */
- GLX_NONE, /* transparentPixel */
- 0, 0, 0, 0, /* transparent rgba color (floats scaled to ints) */
- 0 /* transparentIndex */
- },
-};
-
-static __GLXvisualConfig NullConfig = {
- -1, /* vid */
- -1, /* class */
- False, /* rgba */
- -1, -1, -1, 0, /* rgba sizes */
- -1, -1, -1, 0, /* rgba masks */
- 0, 0, 0, 0, /* rgba accum sizes */
- False, /* doubleBuffer */
- False, /* stereo */
- -1, /* bufferSize */
- 16, /* depthSize */
- 0, /* stencilSize */
- 0, /* auxBuffers */
- 0, /* level */
- GLX_NONE_EXT, /* visualRating */
- 0, /* transparentPixel */
- 0, 0, 0, 0, /* transparent rgba color (floats scaled to ints) */
- 0 /* transparentIndex */
-};
-
-
-static int count_bits(unsigned int n)
-{
- int bits = 0;
-
- while (n > 0) {
- if (n & 1) bits++;
- n >>= 1;
- }
- return bits;
-}
-
-
-static Bool init_visuals(int *nvisualp, VisualPtr *visualp,
- VisualID *defaultVisp,
- int ndepth, DepthPtr pdepth,
- int rootDepth)
-{
- int numRGBconfigs;
- int numCIconfigs;
- int numVisuals = *nvisualp;
- int numNewVisuals;
- int numNewConfigs;
- VisualPtr pVisual = *visualp;
- VisualPtr pVisualNew = NULL;
- VisualID *orig_vid = NULL;
- __GLcontextModes *modes;
- __GLXvisualConfig *pNewVisualConfigs = NULL;
- void **glXVisualPriv;
- void **pNewVisualPriv;
- int found_default;
- int i, j, k;
-
- GLAQUA_DEBUG_MSG("init_visuals\n");
-
- if (numConfigs > 0)
- numNewConfigs = numConfigs;
- else
- numNewConfigs = NUM_FALLBACK_CONFIGS;
-
- /* Alloc space for the list of new GLX visuals */
- pNewVisualConfigs = (__GLXvisualConfig *)
- __glXMalloc(numNewConfigs * sizeof(__GLXvisualConfig));
- if (!pNewVisualConfigs) {
- return FALSE;
- }
-
- /* Alloc space for the list of new GLX visual privates */
- pNewVisualPriv = (void **) __glXMalloc(numNewConfigs * sizeof(void *));
- if (!pNewVisualPriv) {
- __glXFree(pNewVisualConfigs);
- return FALSE;
- }
-
- /*
- ** If SetVisualConfigs was not called, then use default GLX
- ** visual configs.
- */
- if (numConfigs == 0) {
- memcpy(pNewVisualConfigs, FallbackConfigs,
- NUM_FALLBACK_CONFIGS * sizeof(__GLXvisualConfig));
- memset(pNewVisualPriv, 0, NUM_FALLBACK_CONFIGS * sizeof(void *));
- }
- else {
- /* copy driver's visual config info */
- for (i = 0; i < numConfigs; i++) {
- pNewVisualConfigs[i] = visualConfigs[i];
- pNewVisualPriv[i] = visualPrivates[i];
- }
- }
-
- /* Count the number of RGB and CI visual configs */
- numRGBconfigs = 0;
- numCIconfigs = 0;
- for (i = 0; i < numNewConfigs; i++) {
- if (pNewVisualConfigs[i].rgba)
- numRGBconfigs++;
- else
- numCIconfigs++;
- }
-
- /* Count the total number of visuals to compute */
- numNewVisuals = 0;
- for (i = 0; i < numVisuals; i++) {
- int count;
-
- count = ((pVisual[i].class == TrueColor ||
- pVisual[i].class == DirectColor)
- ? numRGBconfigs : numCIconfigs);
- if (count == 0)
- count = 1; /* preserve the existing visual */
-
- numNewVisuals += count;
- }
-
- /* Reset variables for use with the next screen/driver's visual configs */
- visualConfigs = NULL;
- numConfigs = 0;
-
- /* Alloc temp space for the list of orig VisualIDs for each new visual */
- orig_vid = (VisualID *)__glXMalloc(numNewVisuals * sizeof(VisualID));
- if (!orig_vid) {
- __glXFree(pNewVisualPriv);
- __glXFree(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);
- return FALSE;
- }
-
- /* Alloc space for the list of glXVisualPrivates */
- glXVisualPriv = (void **)__glXMalloc(numNewVisuals * sizeof(void *));
- if (!glXVisualPriv) {
- _gl_context_modes_destroy( modes );
- __glXFree(orig_vid);
- __glXFree(pNewVisualPriv);
- __glXFree(pNewVisualConfigs);
- return FALSE;
- }
-
- /* Alloc space for the new list of the X server's visuals */
- pVisualNew = (VisualPtr)__glXMalloc(numNewVisuals * sizeof(VisualRec));
- if (!pVisualNew) {
- __glXFree(glXVisualPriv);
- _gl_context_modes_destroy( modes );
- __glXFree(orig_vid);
- __glXFree(pNewVisualPriv);
- __glXFree(pNewVisualConfigs);
- return FALSE;
- }
-
- /* Initialize the new visuals */
- found_default = FALSE;
- glAquaScreens[screenInfo.numScreens-1].modes = modes;
- for (i = j = 0; i < numVisuals; i++) {
- int is_rgb = (pVisual[i].class == TrueColor ||
- pVisual[i].class == DirectColor);
-
- if (!is_rgb)
- {
- /* We don't support non-rgb visuals for GL. But we don't
- want to remove them either, so just pass them through
- with null glX configs */
-
- pVisualNew[j] = pVisual[i];
- pVisualNew[j].vid = FakeClientID(0);
-
- /* Check for the default visual */
- if (!found_default && pVisual[i].vid == *defaultVisp) {
- *defaultVisp = pVisualNew[j].vid;
- found_default = TRUE;
- }
-
- /* Save the old VisualID */
- orig_vid[j] = pVisual[i].vid;
-
- /* Initialize the glXVisual */
- _gl_copy_visual_to_context_mode( modes, & NullConfig );
- modes->visualID = pVisualNew[j].vid;
-
- j++;
-
- continue;
- }
-
- for (k = 0; k < numNewConfigs; k++) {
- if (pNewVisualConfigs[k].rgba != is_rgb)
- continue;
-
- assert( modes != NULL );
-
- /* Initialize the new visual */
- pVisualNew[j] = pVisual[i];
- pVisualNew[j].vid = FakeClientID(0);
-
- /* Check for the default visual */
- if (!found_default && pVisual[i].vid == *defaultVisp) {
- *defaultVisp = pVisualNew[j].vid;
- found_default = TRUE;
- }
-
- /* Save the old VisualID */
- orig_vid[j] = pVisual[i].vid;
-
- /* Initialize the glXVisual */
- _gl_copy_visual_to_context_mode( modes, & pNewVisualConfigs[k] );
- modes->visualID = pVisualNew[j].vid;
-
- /*
- * If the class is -1, then assume the X visual information
- * is identical to what GLX needs, and take them from the X
- * visual. NOTE: if class != -1, then all other fields MUST
- * be initialized.
- */
- if (modes->visualType == GLX_NONE) {
- modes->visualType = _gl_convert_from_x_visual_type( pVisual[i].class );
- modes->redBits = count_bits(pVisual[i].redMask);
- modes->greenBits = count_bits(pVisual[i].greenMask);
- modes->blueBits = count_bits(pVisual[i].blueMask);
- modes->alphaBits = modes->alphaBits;
- modes->redMask = pVisual[i].redMask;
- modes->greenMask = pVisual[i].greenMask;
- modes->blueMask = pVisual[i].blueMask;
- modes->alphaMask = modes->alphaMask;
- modes->rgbBits = (is_rgb)
- ? (modes->redBits + modes->greenBits +
- modes->blueBits + modes->alphaBits)
- : rootDepth;
- }
-
- /* Save the device-dependent private for this visual */
- glXVisualPriv[j] = pNewVisualPriv[k];
-
- j++;
- modes = modes->next;
- }
- }
-
- assert(j <= numNewVisuals);
-
- /* Save the GLX visuals in the screen structure */
- glAquaScreens[screenInfo.numScreens-1].num_vis = numNewVisuals;
- glAquaScreens[screenInfo.numScreens-1].priv = glXVisualPriv;
-
- /* Set up depth's VisualIDs */
- for (i = 0; i < ndepth; i++) {
- int numVids = 0;
- VisualID *pVids = NULL;
- int k, n = 0;
-
- /* Count the new number of VisualIDs at this depth */
- for (j = 0; j < pdepth[i].numVids; j++)
- for (k = 0; k < numNewVisuals; k++)
- if (pdepth[i].vids[j] == orig_vid[k])
- numVids++;
-
- /* Allocate a new list of VisualIDs for this depth */
- pVids = (VisualID *)__glXMalloc(numVids * sizeof(VisualID));
-
- /* Initialize the new list of VisualIDs for this depth */
- for (j = 0; j < pdepth[i].numVids; j++)
- for (k = 0; k < numNewVisuals; k++)
- if (pdepth[i].vids[j] == orig_vid[k])
- pVids[n++] = pVisualNew[k].vid;
-
- /* Update this depth's list of VisualIDs */
- __glXFree(pdepth[i].vids);
- pdepth[i].vids = pVids;
- pdepth[i].numVids = numVids;
- }
-
- /* Update the X server's visuals */
- *nvisualp = numNewVisuals;
- *visualp = pVisualNew;
-
- /* Free the old list of the X server's visuals */
- __glXFree(pVisual);
-
- /* Clean up temporary allocations */
- __glXFree(orig_vid);
- __glXFree(pNewVisualPriv);
- __glXFree(pNewVisualConfigs);
-
- /* Free the private list created by DDX HW driver */
- if (visualPrivates)
- xfree(visualPrivates);
- visualPrivates = NULL;
-
- return TRUE;
-}
-
-/* based on code in i830_dri.c
- This ends calling glAquaSetVisualConfigs to set the static
- numconfigs, etc. */
-static void
-glAquaInitVisualConfigs(void)
-{
- int lclNumConfigs = 0;
- __GLXvisualConfig *lclVisualConfigs = NULL;
- void **lclVisualPrivates = NULL;
-
- int depth, aux, buffers, stencil, accum;
- int i = 0;
-
- GLAQUA_DEBUG_MSG("glAquaInitVisualConfigs ");
-
- /* count num configs:
- 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 */
-
- lclNumConfigs = 2 * 2 * 2 * 2 * 2; /* 32 */
-
- /* alloc */
- lclVisualConfigs = xcalloc(sizeof(__GLXvisualConfig), lclNumConfigs);
- lclVisualPrivates = xcalloc(sizeof(void *), lclNumConfigs);
-
- /* fill in configs */
- if (NULL != lclVisualConfigs) {
- i = 0; /* current buffer */
- 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++;
- }
- }
- }
- }
- }
- }
- if (i != lclNumConfigs)
- GLAQUA_DEBUG_MSG("glAquaInitVisualConfigs failed to alloc visual configs");
-
- GlxSetVisualConfigs(lclNumConfigs, lclVisualConfigs, lclVisualPrivates);
-}
-
-
-static void glAquaSetVisualConfigs(int nconfigs, __GLXvisualConfig *configs,
- void **privates)
-{
- GLAQUA_DEBUG_MSG("glAquaSetVisualConfigs\n");
-
- numConfigs = nconfigs;
- visualConfigs = configs;
- visualPrivates = privates;
-}
-
-static Bool glAquaInitVisuals(VisualPtr *visualp, DepthPtr *depthp,
- int *nvisualp, int *ndepthp,
- int *rootDepthp, VisualID *defaultVisp,
- unsigned long sizes, int bitsPerRGB)
-{
- GLAQUA_DEBUG_MSG("glAquaInitVisuals\n");
-
- if (numConfigs == 0) /* if no configs */
- glAquaInitVisualConfigs(); /* ensure the visual configs are setup */
-
- /*
- * Setup the visuals supported by this particular screen.
- */
- return init_visuals(nvisualp, visualp, defaultVisp,
- *ndepthp, *depthp, *rootDepthp);
-}
-
-
-static void fixup_visuals(int screen)
-{
- ScreenPtr pScreen = screenInfo.screens[screen];
- glAquaScreenRec *pScr = &glAquaScreens[screen];
- int j;
- __GLcontextModes *modes;
-
- GLAQUA_DEBUG_MSG("fixup_visuals\n");
-
- for ( modes = pScr->modes ; modes != NULL ; modes = modes->next ) {
- const int vis_class = _gl_convert_to_x_visual_type( modes->visualType );
- const int nplanes = (modes->rgbBits - modes->alphaBits);
- const VisualPtr pVis = pScreen->visuals;
-
- /* Find a visual that matches the GLX visual's class and size */
- for (j = 0; j < pScreen->numVisuals; j++) {
- if (pVis[j].class == vis_class &&
- pVis[j].nplanes == nplanes) {
-
- /* Fixup the masks */
- modes->redMask = pVis[j].redMask;
- modes->greenMask = pVis[j].greenMask;
- modes->blueMask = pVis[j].blueMask;
-
- /* Recalc the sizes */
- modes->redBits = count_bits(modes->redMask);
- modes->greenBits = count_bits(modes->greenMask);
- modes->blueBits = count_bits(modes->blueMask);
- }
- }
- }
-}
-
-static void init_screen_visuals(int screen)
-{
- ScreenPtr pScreen = screenInfo.screens[screen];
- __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: array of bytes instead of ints!
- */
- used = (int *)__glXMalloc(pScreen->numVisuals * sizeof(int));
- __glXMemset(used, 0, pScreen->numVisuals * sizeof(int));
-
- i = 0;
- for ( modes = glAquaScreens[screen].modes
- ; modes != NULL
- ; modes = modes->next ) {
- const int vis_class = _gl_convert_to_x_visual_type( modes->visualType );
- const int nplanes = (modes->rgbBits - modes->alphaBits);
- const VisualPtr pVis = pScreen->visuals;
-
- for (j = 0; j < pScreen->numVisuals; j++) {
- if (pVis[j].class == vis_class &&
- pVis[j].nplanes == nplanes &&
- pVis[j].redMask == modes->redMask &&
- pVis[j].greenMask == modes->greenMask &&
- pVis[j].blueMask == modes->blueMask &&
- !used[j]) {
-
- /* Set the VisualID */
- modes->visualID = pVis[j].vid;
-
- /* Mark this visual used */
- used[j] = 1;
- break;
- }
- }
- if ( j == pScreen->numVisuals ) {
- ErrorF("No matching visual for __GLcontextMode with "
- "visual class = %d (%d), nplanes = %u\n",
- vis_class,
- (int)modes->visualType,
- (unsigned int)(modes->rgbBits - modes->alphaBits) );
- }
- else if ( modes->visualID == -1 ) {
- FatalError( "Matching visual found, but visualID still -1!\n" );
- }
-
- i++;
- }
-
- __glXFree(used);
-}
-
-static Bool glAquaScreenProbe(int screen)
-{
- ScreenPtr pScreen;
- glAquaScreenRec *screenPriv;
-
- GLAQUA_DEBUG_MSG("glAquaScreenProbe\n");
-
- /*
- * 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;
-
- /*
- * Set the current screen's createContext routine. This could be
- * wrapped by a DDX GLX context creation routine.
- */
- __glDDXScreenInfo.createContext = glAquaCreateContext;
-
- /*
- * The ordering of the rgb compenents might have been changed by the
- * driver after mi initialized them.
- */
- fixup_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;
-}
-
-
-static GLboolean glAquaResizeBuffers(__GLdrawableBuffer *buffer,
- GLint x, GLint y,
- GLuint width, GLuint height,
- __GLdrawablePrivate *glPriv,
- GLuint bufferMask)
-{
- GLAquaDrawableRec *aquaPriv = (GLAquaDrawableRec *)glPriv->private;
- __GLXdrawablePrivate *glxPriv = (__GLXdrawablePrivate *)glPriv->other;
- __GLXcontext *gx;
- __GLcontext *gc;
-
- GLAQUA_DEBUG_MSG("glAquaResizeBuffers to (%d %d %d %d)\n", x, y, width, height);
-
- // update all contexts that point at this drawable for drawing (hack?)
- for (gx = glxPriv->drawGlxc; gx != NULL; gx = gx->nextDrawPriv) {
- gc = (__GLcontext *)gx->gc;
- attach(gc, glPriv);
- }
-
- // update all contexts that point at this drawable for reading (hack?)
- for (gx = glxPriv->readGlxc; gx != NULL; gx = gx->nextReadPriv) {
- gc = (__GLcontext *)gx->gc;
- attach(gc, glPriv);
- }
-
- return aquaPriv->resize(buffer, x, y, width, height, glPriv, bufferMask);
-}
-
-
-static GLboolean glAquaSwapBuffers(__GLXdrawablePrivate *glxPriv)
-{
- // fixme AGL software renderer will use properties of current QD port (bad)
-
- // swap buffers on only *one* of the contexts
- // (e.g. the last one for drawing)
- __GLcontext *gc = (__GLcontext *)glxPriv->drawGlxc->gc;
- if (gc && gc->ctx) aglSwapBuffers(gc->ctx);
-
- return GL_TRUE;
-}
-
-static void glAquaDestroyDrawablePrivate(__GLdrawablePrivate *glPriv)
-{
- GLAQUA_DEBUG_MSG("glAquaDestroyDrawablePrivate\n");
-
- free(glPriv->private);
- glPriv->private = NULL;
-}
-
-static void glAquaCreateBuffer(__GLXdrawablePrivate *glxPriv)
-{
- GLAquaDrawableRec *aquaPriv = malloc(sizeof(GLAquaDrawableRec));
- __GLdrawablePrivate *glPriv = &glxPriv->glPriv;
-
- GLAQUA_DEBUG_MSG("glAquaCreateBuffer\n");
-
- // replace swapBuffers (original is never called)
- glxPriv->swapBuffers = glAquaSwapBuffers;
-
- // wrap front buffer resize
- aquaPriv->resize = glPriv->frontBuffer.resize;
- glPriv->frontBuffer.resize = glAquaResizeBuffers;
-
- // stash private data
- glPriv->private = aquaPriv;
- glPriv->freePrivate = glAquaDestroyDrawablePrivate;
-}
-
-
-static void glAquaResetExtension(void)
-{
- GLAQUA_DEBUG_MSG("glAquaResetExtension\n");
- aglResetLibrary();
-}
-
-
-
-// Extra goodies for glx
-
-GLuint __glFloorLog2(GLuint val)
-{
- int c = 0;
-
- while (val > 1) {
- c++;
- val >>= 1;
- }
- return c;
-}
diff --git a/GL/glx/Makefile.am b/GL/glx/Makefile.am
index 1d4719c88..9bf296c71 100644
--- a/GL/glx/Makefile.am
+++ b/GL/glx/Makefile.am
@@ -47,7 +47,12 @@ libglxdri_la_SOURCES = \
extension_string.c \
extension_string.h
+#if XQUARTZ
+XQUARTZ_libglx_la_SOURCES = glcontextmodes.c
+#endif
+
libglx_la_SOURCES = \
+ $(XQUARTZ_libglx_la_SOURCES) \
g_disptab.h \
glxbyteorder.h \
glxcmds.c \
diff --git a/GL/glx/glxglcore.c b/GL/glx/glxglcore.c
index 972ab88e6..dafa9bca7 100644
--- a/GL/glx/glxglcore.c
+++ b/GL/glx/glxglcore.c
@@ -37,7 +37,9 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#endif
#include <string.h>
+#include <dlfcn.h>
+#define _NEED_GL_CORE_IF
#include <GL/xmesa.h>
#include <GL/internal/glcore.h>
#include <glxserver.h>
@@ -48,6 +50,22 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#include "os.h"
+#define XMesaCreateVisual (*glcore->XMesaCreateVisual)
+#define XMesaDestroyVisual (*glcore->XMesaDestroyVisual)
+
+#define XMesaCreateWindowBuffer (*glcore->XMesaCreateWindowBuffer)
+#define XMesaCreatePixmapBuffer (*glcore->XMesaCreatePixmapBuffer)
+#define XMesaDestroyBuffer (*glcore->XMesaDestroyBuffer)
+#define XMesaSwapBuffers (*glcore->XMesaSwapBuffers)
+#define XMesaResizeBuffers (*glcore->XMesaResizeBuffers)
+
+#define XMesaCreateContext (*glcore->XMesaCreateContext)
+#define XMesaDestroyContext (*glcore->XMesaDestroyContext)
+#define XMesaCopyContext (*glcore->XMesaCopyContext)
+#define XMesaMakeCurrent2 (*glcore->XMesaMakeCurrent2)
+#define XMesaForceCurrent (*glcore->XMesaForceCurrent)
+#define XMesaLoseCurrent (*glcore->XMesaLoseCurrent)
+
typedef struct __GLXMESAscreen __GLXMESAscreen;
typedef struct __GLXMESAcontext __GLXMESAcontext;
typedef struct __GLXMESAdrawable __GLXMESAdrawable;
@@ -55,8 +73,11 @@ typedef struct __GLXMESAdrawable __GLXMESAdrawable;
struct __GLXMESAscreen {
__GLXscreen base;
int index;
- int num_vis;
+ int num_vis;
XMesaVisual *xm_vis;
+ void *driver;
+
+ const __GLcoreModule *glcore;
};
struct __GLXMESAcontext {
@@ -65,8 +86,9 @@ struct __GLXMESAcontext {
};
struct __GLXMESAdrawable {
- __GLXdrawable base;
- XMesaBuffer xm_buf;
+ __GLXdrawable base;
+ XMesaBuffer xm_buf;
+ __GLXMESAscreen *screen;
};
static XMesaVisual find_mesa_visual(__GLXscreen *screen, XID fbconfigID);
@@ -76,6 +98,7 @@ static void
__glXMesaDrawableDestroy(__GLXdrawable *base)
{
__GLXMESAdrawable *glxPriv = (__GLXMESAdrawable *) base;
+ const __GLcoreModule *glcore = glxPriv->screen->glcore;
if (glxPriv->xm_buf != NULL)
XMesaDestroyBuffer(glxPriv->xm_buf);
@@ -86,6 +109,7 @@ static GLboolean
__glXMesaDrawableResize(__GLXdrawable *base)
{
__GLXMESAdrawable *glxPriv = (__GLXMESAdrawable *) base;
+ const __GLcoreModule *glcore = glxPriv->screen->glcore;
XMesaResizeBuffers(glxPriv->xm_buf);
@@ -96,6 +120,7 @@ static GLboolean
__glXMesaDrawableSwapBuffers(__GLXdrawable *base)
{
__GLXMESAdrawable *glxPriv = (__GLXMESAdrawable *) base;
+ const __GLcoreModule *glcore = glxPriv->screen->glcore;
/* This is terrifying: XMesaSwapBuffers() ends up calling CopyArea
* to do the buffer swap, but this assumes that the server holds
@@ -121,6 +146,8 @@ __glXMesaScreenCreateDrawable(__GLXscreen *screen,
XID drawId,
__GLXconfig *modes)
{
+ __GLXMESAscreen *mesaScreen = (__GLXMESAscreen *) screen;
+ const __GLcoreModule *glcore = mesaScreen->glcore;
__GLXMESAdrawable *glxPriv;
XMesaVisual xm_vis;
@@ -130,6 +157,7 @@ __glXMesaScreenCreateDrawable(__GLXscreen *screen,
memset(glxPriv, 0, sizeof *glxPriv);
+ glxPriv->screen = mesaScreen;
if (!__glXDrawableInit(&glxPriv->base, screen,
pDraw, type, drawId, modes)) {
xfree(glxPriv);
@@ -166,6 +194,8 @@ static void
__glXMesaContextDestroy(__GLXcontext *baseContext)
{
__GLXMESAcontext *context = (__GLXMESAcontext *) baseContext;
+ __GLXMESAscreen *screen = (__GLXMESAscreen *) context->base.pGlxScreen;
+ const __GLcoreModule *glcore = screen->glcore;
XMesaDestroyContext(context->xmesa);
__glXContextDestroy(&context->base);
@@ -179,6 +209,8 @@ __glXMesaContextMakeCurrent(__GLXcontext *baseContext)
__GLXMESAcontext *context = (__GLXMESAcontext *) baseContext;
__GLXMESAdrawable *drawPriv = (__GLXMESAdrawable *) context->base.drawPriv;
__GLXMESAdrawable *readPriv = (__GLXMESAdrawable *) context->base.readPriv;
+ __GLXMESAscreen *screen = (__GLXMESAscreen *) context->base.pGlxScreen;
+ const __GLcoreModule *glcore = screen->glcore;
return XMesaMakeCurrent2(context->xmesa,
drawPriv->xm_buf,
@@ -189,6 +221,8 @@ static int
__glXMesaContextLoseCurrent(__GLXcontext *baseContext)
{
__GLXMESAcontext *context = (__GLXMESAcontext *) baseContext;
+ __GLXMESAscreen *screen = (__GLXMESAscreen *) context->base.pGlxScreen;
+ const __GLcoreModule *glcore = screen->glcore;
return XMesaLoseCurrent(context->xmesa);
}
@@ -200,6 +234,8 @@ __glXMesaContextCopy(__GLXcontext *baseDst,
{
__GLXMESAcontext *dst = (__GLXMESAcontext *) baseDst;
__GLXMESAcontext *src = (__GLXMESAcontext *) baseSrc;
+ __GLXMESAscreen *screen = (__GLXMESAscreen *) dst->base.pGlxScreen;
+ const __GLcoreModule *glcore = screen->glcore;
return XMesaCopyContext(src->xmesa, dst->xmesa, mask);
}
@@ -208,6 +244,8 @@ static int
__glXMesaContextForceCurrent(__GLXcontext *baseContext)
{
__GLXMESAcontext *context = (__GLXMESAcontext *) baseContext;
+ __GLXMESAscreen *screen = (__GLXMESAscreen *) context->base.pGlxScreen;
+ const __GLcoreModule *glcore = screen->glcore;
/* GlxSetRenderTables() call for XGL moved in XMesaForceCurrent() */
@@ -219,6 +257,8 @@ __glXMesaScreenCreateContext(__GLXscreen *screen,
__GLXconfig *config,
__GLXcontext *baseShareContext)
{
+ __GLXMESAscreen *mesaScreen = (__GLXMESAscreen *) screen;
+ const __GLcoreModule *glcore = mesaScreen->glcore;
__GLXMESAcontext *context;
__GLXMESAcontext *shareContext = (__GLXMESAcontext *) baseShareContext;
XMesaVisual xm_vis;
@@ -261,6 +301,7 @@ static void
__glXMesaScreenDestroy(__GLXscreen *screen)
{
__GLXMESAscreen *mesaScreen = (__GLXMESAscreen *) screen;
+ const __GLcoreModule *glcore = mesaScreen->glcore;
int i;
if (mesaScreen->xm_vis) {
@@ -272,6 +313,8 @@ __glXMesaScreenDestroy(__GLXscreen *screen)
xfree(mesaScreen->xm_vis);
}
+ dlclose(mesaScreen->driver);
+
__glXScreenDestroy(screen);
xfree(screen);
@@ -317,9 +360,10 @@ createFBConfigsForVisual(__GLXscreen *screen, ScreenPtr pScreen,
for (back = numBack - 1; back >= 0; back--)
for (depth = 0; depth < numDepth; depth++)
for (stencil = 0; stencil < numStencil; stencil++) {
- config->next = xalloc(sizeof *config);
+ config->next = xcalloc(sizeof(*config), 1);
config = config->next;
+ config->visualRating = GLX_NONE;
config->visualType = glx_visual_types[visual->class];
config->xRenderable = GL_TRUE;
config->drawableType = GLX_WINDOW_BIT | GLX_PIXMAP_BIT;
@@ -372,6 +416,7 @@ createFBConfigs(__GLXscreen *pGlxScreen, ScreenPtr pScreen)
static void
createMesaVisuals(__GLXMESAscreen *pMesaScreen)
{
+ const __GLcoreModule *glcore = pMesaScreen->glcore;
__GLXconfig *config;
ScreenPtr pScreen;
VisualPtr visual = NULL;
@@ -408,15 +453,35 @@ createMesaVisuals(__GLXMESAscreen *pMesaScreen)
}
}
+static const char dri_driver_path[] = DRI_DRIVER_PATH;
+
static __GLXscreen *
__glXMesaScreenProbe(ScreenPtr pScreen)
{
__GLXMESAscreen *screen;
+ char filename[128];
screen = xalloc(sizeof *screen);
if (screen == NULL)
return NULL;
+ snprintf(filename, sizeof filename, "%s/%s.so",
+ dri_driver_path, "libGLcore");
+
+ screen->driver = dlopen(filename, RTLD_LAZY | RTLD_LOCAL);
+ if (screen->driver == NULL) {
+ LogMessage(X_ERROR, "GLX error: dlopen of %s failed (%s)\n",
+ filename, dlerror());
+ goto handle_error;
+ }
+
+ screen->glcore = dlsym(screen->driver, __GL_CORE);
+ if (screen->glcore == NULL) {
+ LogMessage(X_ERROR, "GLX error: dlsym for %s failed (%s)\n",
+ __GL_CORE, dlerror());
+ goto handle_error;
+ }
+
/*
* Find the GLX visuals that are supported by this screen and create
* XMesa's visuals.
@@ -431,9 +496,23 @@ __glXMesaScreenProbe(ScreenPtr pScreen)
screen->base.destroy = __glXMesaScreenDestroy;
screen->base.createContext = __glXMesaScreenCreateContext;
screen->base.createDrawable = __glXMesaScreenCreateDrawable;
+ screen->base.swapInterval = NULL;
screen->base.pScreen = pScreen;
+ LogMessage(X_INFO, "GLX: Loaded and initialized %s\n", filename);
+
return &screen->base;
+
+handle_error:
+
+ if (screen->driver)
+ dlclose(screen->driver);
+
+ xfree(screen);
+
+ FatalError("GLX: could not load software renderer\n");
+
+ return NULL;
}
__GLXprovider __glXMesaProvider = {
diff --git a/GL/glx/glxscreens.c b/GL/glx/glxscreens.c
index b49a775b5..5859de0b1 100644
--- a/GL/glx/glxscreens.c
+++ b/GL/glx/glxscreens.c
@@ -437,6 +437,7 @@ initGlxVisual(VisualPtr visual, __GLXconfig *config)
typedef struct {
GLboolean doubleBuffer;
GLboolean depthBuffer;
+ GLboolean stencilBuffer;
} FBConfigTemplateRec, *FBConfigTemplatePtr;
static __GLXconfig *
@@ -453,6 +454,8 @@ pickFBConfig(__GLXscreen *pGlxScreen, FBConfigTemplatePtr template, int class)
continue;
if ((config->depthBits > 0) != template->depthBuffer)
continue;
+ if ((config->stencilBits > 0) != template->stencilBuffer)
+ continue;
return config;
}
@@ -466,8 +469,9 @@ addMinimalSet(__GLXscreen *pGlxScreen)
__GLXconfig *config;
VisualPtr visuals;
int i, j;
- FBConfigTemplateRec best = { GL_TRUE, GL_TRUE };
- FBConfigTemplateRec minimal = { GL_FALSE, GL_FALSE };
+ FBConfigTemplateRec best = { GL_TRUE, GL_TRUE, GL_TRUE };
+ FBConfigTemplateRec good = { GL_TRUE, GL_TRUE, GL_FALSE };
+ FBConfigTemplateRec minimal = { GL_FALSE, GL_FALSE, GL_FALSE };
pGlxScreen->visuals = xcalloc(pGlxScreen->pScreen->numVisuals,
sizeof (__GLXconfig *));
@@ -480,15 +484,18 @@ addMinimalSet(__GLXscreen *pGlxScreen)
for (i = 0, j = 0; i < pGlxScreen->pScreen->numVisuals; i++) {
if (visuals[i].nplanes == 32)
config = pickFBConfig(pGlxScreen, &minimal, visuals[i].class);
- else
+ else {
config = pickFBConfig(pGlxScreen, &best, visuals[i].class);
+ if (config == NULL)
+ config = pickFBConfig(pGlxScreen, &good, visuals[i].class);
+ }
if (config == NULL)
config = pGlxScreen->fbconfigs;
if (config == NULL)
continue;
pGlxScreen->visuals[j] = config;
- config->visualID = visuals[j].vid;
+ config->visualID = visuals[i].vid;
j++;
}
diff --git a/GL/glx/glxutil.c b/GL/glx/glxutil.c
index 11e9f898b..aa23a95fd 100644
--- a/GL/glx/glxutil.c
+++ b/GL/glx/glxutil.c
@@ -81,38 +81,40 @@ __glXDeassociateContext(__GLXcontext *glxc)
__GLXcontext *curr, *prev;
prev = NULL;
- for ( curr = glxc->drawPriv->drawGlxc
- ; curr != NULL
- ; prev = curr, curr = curr->nextDrawPriv ) {
- if (curr == glxc) {
- /* found context. Deassociate. */
- if (prev == NULL) {
- glxc->drawPriv->drawGlxc = curr->nextDrawPriv;
- } else {
- prev->nextDrawPriv = curr->nextDrawPriv;
+ if (glxc->drawPriv) {
+ for ( curr = glxc->drawPriv->drawGlxc; curr != NULL
+ ; prev = curr, curr = curr->nextDrawPriv ) {
+ if (curr == glxc) {
+ /* found context. Deassociate. */
+ if (prev == NULL) {
+ glxc->drawPriv->drawGlxc = curr->nextDrawPriv;
+ } else {
+ prev->nextDrawPriv = curr->nextDrawPriv;
+ }
+ curr->nextDrawPriv = NULL;
+ __glXUnrefDrawable(glxc->drawPriv);
+ break;
}
- curr->nextDrawPriv = NULL;
- __glXUnrefDrawable(glxc->drawPriv);
- break;
- }
+ }
}
-
prev = NULL;
- for ( curr = glxc->readPriv->readGlxc
- ; curr != NULL
- ; prev = curr, curr = curr->nextReadPriv ) {
- if (curr == glxc) {
- /* found context. Deassociate. */
- if (prev == NULL) {
- glxc->readPriv->readGlxc = curr->nextReadPriv;
- } else {
- prev->nextReadPriv = curr->nextReadPriv;
- }
- curr->nextReadPriv = NULL;
- __glXUnrefDrawable(glxc->readPriv);
- break;
- }
+ if (glxc->readPriv) {
+ for ( curr = glxc->readPriv->readGlxc
+ ; curr != NULL
+ ; prev = curr, curr = curr->nextReadPriv ) {
+ if (curr == glxc) {
+ /* found context. Deassociate. */
+ if (prev == NULL) {
+ glxc->readPriv->readGlxc = curr->nextReadPriv;
+ } else {
+ prev->nextReadPriv = curr->nextReadPriv;
+ }
+ curr->nextReadPriv = NULL;
+ __glXUnrefDrawable(glxc->readPriv);
+ break;
+ }
+ }
}
}
diff --git a/GL/mesa/.gitignore b/GL/mesa/.gitignore
deleted file mode 100644
index 6b92b24bd..000000000
--- a/GL/mesa/.gitignore
+++ /dev/null
@@ -1,32 +0,0 @@
-X/drivers
-X/glxheader.h
-X/xm*.h
-X/xm*.c
-mesa/drivers
-mesa/glxheader.h
-mesa/xm*.c
-glapi/*.c
-glapi/*.h
-main/*.c
-main/*.h
-math/*.c
-math/*.h
-ppc
-shader/*.c
-shader/*.h
-shader/slang/*.c
-shader/slang/*.h
-shader/slang/library
-shader/grammar/*.c
-shader/grammar/*.h
-sparc
-swrast/*.c
-swrast/*.h
-swrast_setup/*.c
-swrast_setup/*.h
-tnl/*.c
-tnl/*.h
-x86
-x86-64
-vbo/*.c
-vbo/*.h
diff --git a/GL/mesa/Makefile.am b/GL/mesa/Makefile.am
deleted file mode 100644
index 7f27c58ba..000000000
--- a/GL/mesa/Makefile.am
+++ /dev/null
@@ -1,18 +0,0 @@
-SUBDIRS = X
-SUBDIRS += main math swrast swrast_setup tnl shader glapi vbo
-
-noinst_LTLIBRARIES = libGLcore.la
-
-libGLcore_la_SOURCES = dummy.c
-MESA_LIBS = main/libmain.la \
- math/libmath.la \
- swrast/libswrast.la \
- swrast_setup/libss.la \
- tnl/libtnl.la \
- shader/libshader.la \
- shader/grammar/libgrammar.la \
- shader/slang/libslang.la \
- vbo/libvbo.la
-
-libGLcore_la_LIBADD = $(MESA_LIBS) \
- X/libX.la
diff --git a/GL/mesa/X/Makefile.am b/GL/mesa/X/Makefile.am
deleted file mode 100644
index d8abbc6bd..000000000
--- a/GL/mesa/X/Makefile.am
+++ /dev/null
@@ -1,27 +0,0 @@
-noinst_LTLIBRARIES = libX.la
-
-INCLUDES = -I@MESA_SOURCE@/include \
- -I. \
- -I@MESA_SOURCE@/src/mesa/glapi \
- -I@MESA_SOURCE@/src/mesa/main \
- -I@MESA_SOURCE@/src/mesa
-
-# -DXFree86Server is required because the X11 driver in Mesa thinks that
-# symbol means "being built in the server"
-AM_CFLAGS = \
- $(DIX_CFLAGS) \
- -DXFree86Server \
- @GLX_DEFINES@
-
-XM_SOURCES = \
- xm_api.c \
- xm_buffer.c \
- xm_dd.c \
- xm_image.c \
- xm_line.c \
- xm_span.c \
- xm_tri.c
-
-XM_SOURCES += drivers/common/driverfuncs.c
-
-nodist_libX_la_SOURCES = $(XM_SOURCES)
diff --git a/GL/mesa/dummy.c b/GL/mesa/dummy.c
deleted file mode 100644
index e69de29bb..000000000
--- a/GL/mesa/dummy.c
+++ /dev/null
diff --git a/GL/mesa/glapi/Makefile.am b/GL/mesa/glapi/Makefile.am
deleted file mode 100644
index db791143e..000000000
--- a/GL/mesa/glapi/Makefile.am
+++ /dev/null
@@ -1,20 +0,0 @@
-noinst_LTLIBRARIES = libglapi.la
-
-AM_CFLAGS = \
- $(DIX_CFLAGS) \
- -DXFree86Server \
- @GLX_DEFINES@
-
-INCLUDES = -I@MESA_SOURCE@/include \
- -I../X \
- -I../glapi \
- -I../main \
- -I../math \
- -I../shader \
- -I../swrast \
- -I../swrast_setup \
- -I../tnl \
- -I.. \
- -I$(top_srcdir)/hw/xfree86/os-support
-
-nodist_libglapi_la_SOURCES = glapi.c glthread.c
diff --git a/GL/mesa/main/Makefile.am b/GL/mesa/main/Makefile.am
deleted file mode 100644
index f8ce13775..000000000
--- a/GL/mesa/main/Makefile.am
+++ /dev/null
@@ -1,86 +0,0 @@
-noinst_LTLIBRARIES = libmain.la
-
-AM_CFLAGS = \
- $(DIX_CFLAGS) \
- -DXFree86Server \
- @GLX_DEFINES@
-
-INCLUDES = -I@MESA_SOURCE@/include \
- -I../X \
- -I../glapi \
- -I../main \
- -I../math \
- -I../shader \
- -I../swrast \
- -I../swrast_setup \
- -I../tnl \
- -I.. \
- -I$(top_srcdir)/hw/xfree86/os-support
-
-if NEED_VSNPRINTF
-VSNPRINTF_SOURCES = vsnprintf.c
-endif
-
-nodist_libmain_la_SOURCES = accum.c \
- api_arrayelt.c \
- api_loopback.c \
- api_noop.c \
- api_validate.c \
- arrayobj.c \
- attrib.c \
- blend.c \
- bufferobj.c \
- buffers.c \
- clip.c \
- colortab.c \
- context.c \
- convolve.c \
- debug.c \
- depth.c \
- depthstencil.c \
- dlist.c \
- drawpix.c \
- enable.c \
- enums.c \
- eval.c \
- execmem.c \
- extensions.c \
- fbobject.c \
- feedback.c \
- fog.c \
- framebuffer.c \
- get.c \
- getstring.c \
- hash.c \
- hint.c \
- histogram.c \
- image.c \
- imports.c \
- light.c \
- lines.c \
- matrix.c \
- mipmap.c \
- mm.c \
- pixel.c \
- points.c \
- polygon.c \
- queryobj.c \
- rastpos.c \
- rbadaptors.c \
- renderbuffer.c \
- shaders.c \
- state.c \
- stencil.c \
- texcompress.c \
- texcompress_fxt1.c \
- texcompress_s3tc.c \
- texenvprogram.c \
- texformat.c \
- teximage.c \
- texobj.c \
- texrender.c \
- texstate.c \
- texstore.c \
- varray.c \
- $(VSNPRINTF_SOURCES) \
- vtxfmt.c
diff --git a/GL/mesa/math/Makefile.am b/GL/mesa/math/Makefile.am
deleted file mode 100644
index c7c564272..000000000
--- a/GL/mesa/math/Makefile.am
+++ /dev/null
@@ -1,27 +0,0 @@
-noinst_LTLIBRARIES = libmath.la
-
-AM_CFLAGS = \
- $(DIX_CFLAGS) \
- -DXFree86Server \
- @GLX_DEFINES@
-
-INCLUDES = -I@MESA_SOURCE@/include \
- -I../X \
- -I../glapi \
- -I../main \
- -I../math \
- -I../shader \
- -I../swrast \
- -I../swrast_setup \
- -I../tnl \
- -I.. \
- -I$(top_srcdir)/hw/xfree86/os-support
-
-nodist_libmath_la_SOURCES = m_debug_clip.c \
- m_debug_norm.c \
- m_debug_xform.c \
- m_eval.c \
- m_matrix.c \
- m_translate.c \
- m_vector.c \
- m_xform.c
diff --git a/GL/mesa/shader/Makefile.am b/GL/mesa/shader/Makefile.am
deleted file mode 100644
index abde27513..000000000
--- a/GL/mesa/shader/Makefile.am
+++ /dev/null
@@ -1,39 +0,0 @@
-SUBDIRS = grammar slang
-
-noinst_LTLIBRARIES = libshader.la
-
-AM_CFLAGS = \
- $(DIX_CFLAGS) \
- -DXFree86Server \
- @GLX_DEFINES@
-
-INCLUDES = -I@MESA_SOURCE@/include \
- -I../X \
- -I../glapi \
- -I../main \
- -I../math \
- -I../shader \
- -I../shader/grammar \
- -I../shader/slang \
- -I../swrast \
- -I../swrast_setup \
- -I../tnl \
- -I.. \
- -I$(top_srcdir)/hw/xfree86/os-support
-
-nodist_libshader_la_SOURCES = \
- arbprogparse.c \
- arbprogram.c \
- atifragshader.c \
- nvfragparse.c \
- nvprogram.c \
- nvvertparse.c \
- prog_debug.c \
- prog_execute.c \
- prog_instruction.c \
- prog_parameter.c \
- prog_print.c \
- program.c \
- programopt.c \
- prog_statevars.c \
- shader_api.c
diff --git a/GL/mesa/shader/grammar/Makefile.am b/GL/mesa/shader/grammar/Makefile.am
deleted file mode 100644
index 332c8e952..000000000
--- a/GL/mesa/shader/grammar/Makefile.am
+++ /dev/null
@@ -1,20 +0,0 @@
-noinst_LTLIBRARIES = libgrammar.la
-
-AM_CFLAGS = \
- $(DIX_CFLAGS) \
- -DXFree86Server \
- @GLX_DEFINES@
-
-INCLUDES = -I@MESA_SOURCE@/include \
- -I../../X \
- -I../../glapi \
- -I../../main \
- -I../../math \
- -I../../shader \
- -I../../swrast \
- -I../../swrast_setup \
- -I../../tnl \
- -I../.. \
- -I$(top_srcdir)/hw/xfree86/os-support
-
-nodist_libgrammar_la_SOURCES = grammar_mesa.c
diff --git a/GL/mesa/shader/slang/Makefile.am b/GL/mesa/shader/slang/Makefile.am
deleted file mode 100644
index 71498eeac..000000000
--- a/GL/mesa/shader/slang/Makefile.am
+++ /dev/null
@@ -1,41 +0,0 @@
-noinst_LTLIBRARIES = libslang.la
-
-AM_CFLAGS = \
- $(DIX_CFLAGS) \
- -DXFree86Server \
- @GLX_DEFINES@
-
-INCLUDES = -I@MESA_SOURCE@/include \
- -I../grammar \
- -I../../X \
- -I../../glapi \
- -I../../main \
- -I../../math \
- -I../../shader \
- -I../../swrast \
- -I../../swrast_setup \
- -I../../tnl \
- -I../.. \
- -I$(top_srcdir)/hw/xfree86/os-support
-
-nodist_libslang_la_SOURCES = slang_builtin.c \
- slang_codegen.c \
- slang_compile.c \
- slang_compile_function.c \
- slang_compile_operation.c \
- slang_compile_struct.c \
- slang_compile_variable.c \
- slang_emit.c \
- slang_ir.c \
- slang_label.c \
- slang_library_noise.c \
- slang_link.c \
- slang_log.c \
- slang_mem.c \
- slang_preprocess.c \
- slang_print.c \
- slang_simplify.c \
- slang_storage.c \
- slang_typeinfo.c \
- slang_utility.c \
- slang_vartable.c
diff --git a/GL/mesa/swrast/Makefile.am b/GL/mesa/swrast/Makefile.am
deleted file mode 100644
index bffb1e7c1..000000000
--- a/GL/mesa/swrast/Makefile.am
+++ /dev/null
@@ -1,50 +0,0 @@
-noinst_LTLIBRARIES = libswrast.la
-
-AM_CFLAGS = \
- $(DIX_CFLAGS) \
- -DXFree86Server \
- @GLX_DEFINES@
-
-INCLUDES = -I@MESA_SOURCE@/include \
- -I../X \
- -I../glapi \
- -I../main \
- -I../math \
- -I../shader \
- -I../shader/slang \
- -I../shader/slang \
- -I../swrast \
- -I../swrast_setup \
- -I../tnl \
- -I.. \
- -I$(top_srcdir)/hw/xfree86/os-support
-
-nodist_libswrast_la_SOURCES = s_aaline.c \
- s_aatriangle.c \
- s_accum.c \
- s_alpha.c \
- s_atifragshader.c \
- s_bitmap.c \
- s_blend.c \
- s_blit.c \
- s_buffers.c \
- s_context.c \
- s_copypix.c \
- s_depth.c \
- s_drawpix.c \
- s_feedback.c \
- s_fog.c \
- s_fragprog.c \
- s_imaging.c \
- s_lines.c \
- s_logic.c \
- s_masking.c \
- s_points.c \
- s_readpix.c \
- s_span.c \
- s_stencil.c \
- s_texcombine.c \
- s_texfilter.c \
- s_texstore.c \
- s_triangle.c \
- s_zoom.c
diff --git a/GL/mesa/swrast_setup/Makefile.am b/GL/mesa/swrast_setup/Makefile.am
deleted file mode 100644
index 1f3c031aa..000000000
--- a/GL/mesa/swrast_setup/Makefile.am
+++ /dev/null
@@ -1,20 +0,0 @@
-noinst_LTLIBRARIES = libss.la
-
-AM_CFLAGS = \
- $(DIX_CFLAGS) \
- -DXFree86Server \
- @GLX_DEFINES@
-
-INCLUDES = -I@MESA_SOURCE@/include \
- -I../X \
- -I../glapi \
- -I../main \
- -I../math \
- -I../shader \
- -I../swrast \
- -I../swrast_setup \
- -I../tnl \
- -I.. \
- -I$(top_srcdir)/hw/xfree86/os-support
-
-nodist_libss_la_SOURCES = ss_context.c ss_triangle.c
diff --git a/GL/mesa/tnl/Makefile.am b/GL/mesa/tnl/Makefile.am
deleted file mode 100644
index b3c82066f..000000000
--- a/GL/mesa/tnl/Makefile.am
+++ /dev/null
@@ -1,37 +0,0 @@
-noinst_LTLIBRARIES = libtnl.la
-
-AM_CFLAGS = \
- $(DIX_CFLAGS) \
- -DXFree86Server \
- @GLX_DEFINES@
-
-INCLUDES = -I@MESA_SOURCE@/include \
- -I../X \
- -I../glapi \
- -I../main \
- -I../math \
- -I../shader \
- -I../shader/slang \
- -I../swrast \
- -I../swrast_setup \
- -I../tnl \
- -I.. \
- -I$(top_srcdir)/hw/xfree86/os-support
-
-nodist_libtnl_la_SOURCES = t_context.c \
- t_draw.c \
- t_pipeline.c \
- t_vb_cull.c \
- t_vb_fog.c \
- t_vb_light.c \
- t_vb_normals.c \
- t_vb_points.c \
- t_vb_program.c \
- t_vb_render.c \
- t_vb_texgen.c \
- t_vb_texmat.c \
- t_vb_vertex.c \
- t_vertex.c \
- t_vertex_generic.c \
- t_vertex_sse.c \
- t_vp_build.c
diff --git a/GL/mesa/vbo/Makefile.am b/GL/mesa/vbo/Makefile.am
deleted file mode 100644
index 9943f2a5a..000000000
--- a/GL/mesa/vbo/Makefile.am
+++ /dev/null
@@ -1,35 +0,0 @@
-noinst_LTLIBRARIES = libvbo.la
-
-AM_CFLAGS = \
- $(DIX_CFLAGS) \
- -DXFree86Server \
- @GLX_DEFINES@
-
-INCLUDES = -I@MESA_SOURCE@/include \
- -I../X \
- -I../glapi \
- -I../main \
- -I../math \
- -I../shader \
- -I../shader/slang \
- -I../shader/slang \
- -I../swrast \
- -I../swrast_setup \
- -I../tnl \
- -I.. \
- -I$(top_srcdir)/hw/xfree86/os-support
-
-nodist_libvbo_la_SOURCES = vbo_context.c \
- vbo_exec_api.c \
- vbo_exec_array.c \
- vbo_exec.c \
- vbo_exec_draw.c \
- vbo_exec_eval.c \
- vbo_rebase.c \
- vbo_save_api.c \
- vbo_save.c \
- vbo_save_draw.c \
- vbo_save_loopback.c \
- vbo_split.c \
- vbo_split_copy.c \
- vbo_split_inplace.c
diff --git a/GL/symlink-mesa.sh b/GL/symlink-mesa.sh
index 47afdcd37..def4f63f7 100755
--- a/GL/symlink-mesa.sh
+++ b/GL/symlink-mesa.sh
@@ -58,175 +58,14 @@ main() {
## actual symlinking
-symlink_mesa_glapi() {
- src_dir src/mesa/glapi
- dst_dir mesa/glapi
-
- for src in $REAL_SRC_DIR/*.c $REAL_SRC_DIR/*.h; do
- action `basename $src`
- done
-}
-
-symlink_mesa_main() {
- src_dir src/mesa/main
- dst_dir mesa/main
-
- for src in $REAL_SRC_DIR/*.c $REAL_SRC_DIR/*.h; do
- action `basename $src`
- done
-}
-
-symlink_mesa_math() {
- src_dir src/mesa/math
- dst_dir mesa/math
-
- for src in $REAL_SRC_DIR/*.c $REAL_SRC_DIR/*.h; do
- action `basename $src`
- done
-}
-
-symlink_mesa_swrast() {
- src_dir src/mesa/swrast
- dst_dir mesa/swrast
-
- for src in $REAL_SRC_DIR/*.c $REAL_SRC_DIR/*.h; do
- action `basename $src`
- done
-}
-
-symlink_mesa_ss() {
- src_dir src/mesa/swrast_setup
- dst_dir mesa/swrast_setup
-
- for src in $REAL_SRC_DIR/*.c $REAL_SRC_DIR/*.h; do
- action `basename $src`
- done
-}
-
-symlink_mesa_tnl() {
- src_dir src/mesa/tnl
- dst_dir mesa/tnl
-
- for src in $REAL_SRC_DIR/*.c $REAL_SRC_DIR/*.h; do
- action `basename $src`
- done
-}
-
-symlink_mesa_shader() {
- src_dir src/mesa/shader
- dst_dir mesa/shader
-
- for src in $REAL_SRC_DIR/*.c $REAL_SRC_DIR/*.h; do
- action `basename $src`
- done
-}
-
-symlink_mesa_shader_grammar() {
- src_dir src/mesa/shader/grammar
- dst_dir mesa/shader/grammar
-
- for src in $REAL_SRC_DIR/*.c $REAL_SRC_DIR/*.h; do
- action `basename $src`
- done
-}
-
-symlink_mesa_shader_slang() {
- src_dir src/mesa/shader/slang
- dst_dir mesa/shader/slang
-
- for src in $REAL_SRC_DIR/*.c $REAL_SRC_DIR/*.h; do
- action `basename $src`
- done
-}
-
-symlink_mesa_shader_slang_library() {
- src_dir src/mesa/shader/slang/library
- dst_dir mesa/shader/slang/library
-
- for src in $REAL_SRC_DIR/*.c $REAL_SRC_DIR/*.h; do
- action `basename $src`
- done
-}
-
-symlink_mesa_vbo() {
- src_dir src/mesa/vbo
- dst_dir mesa/vbo
-
- for src in $REAL_SRC_DIR/*.c $REAL_SRC_DIR/*.h; do
- action `basename $src`
- done
-}
-
-symlink_mesa_x() {
- src_dir src/mesa/drivers/x11
- dst_dir mesa/X
-
- # action glxapi.h
- action glxheader.h
- # action realglx.h
- # action xfonts.h
- action xm_api.c
- action xm_buffer.c
- action xm_dd.c
- action xm_image.c
- action xm_image.h
- action xm_line.c
- action xm_span.c
- action xm_tri.c
- action xmesaP.h
-
- # another hack
- src_dir src/mesa/drivers/common
- dst_dir mesa/X/drivers/common
- action driverfuncs.c
- action driverfuncs.h
-}
-
-symlink_mesa_ppc() {
- src_dir src/mesa/ppc
- dst_dir mesa/ppc
-}
-
-symlink_mesa_sparc() {
- src_dir src/mesa/sparc
- dst_dir mesa/sparc
-}
-
-symlink_mesa_x86() {
- src_dir src/mesa/x86
- dst_dir mesa/x86
-}
-
-symlink_mesa_x8664() {
- src_dir src/mesa/x86-64
- dst_dir mesa/x86-64
-}
-
-symlink_mesa() {
- symlink_mesa_main
- symlink_mesa_math
- symlink_mesa_swrast
- symlink_mesa_ss
- symlink_mesa_tnl
- symlink_mesa_shader
- symlink_mesa_shader_grammar
- symlink_mesa_shader_slang
- symlink_mesa_shader_slang_library
- symlink_mesa_x
- symlink_mesa_glapi
- symlink_mesa_ppc
- symlink_mesa_sparc
- symlink_mesa_vbo
- symlink_mesa_x86
- symlink_mesa_x8664
-}
-
symlink_glx() {
# this is... unpleasant
src_dir src/glx/x11
dst_dir glx
action indirect_size.h
+ action glcontextmodes.c
+ action glcontextmodes.h
action indirect_dispatch.c
action indirect_dispatch.h
action indirect_dispatch_swap.c
@@ -267,7 +106,6 @@ run() {
# $1 what to do
# $2 explanation
- ACTION=$1 EXPLANATION=$2 run_module mesa
ACTION=$1 EXPLANATION=$2 run_module glx
}
diff --git a/Xext/EVI.c b/Xext/EVI.c
deleted file mode 100644
index a637bae5d..000000000
--- a/Xext/EVI.c
+++ /dev/null
@@ -1,200 +0,0 @@
-/************************************************************
-Copyright (c) 1997 by Silicon Graphics Computer Systems, Inc.
-Permission to use, copy, modify, and distribute this
-software and its documentation for any purpose and without
-fee is hereby granted, 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 Silicon Graphics not be
-used in advertising or publicity pertaining to distribution
-of the software without specific prior written permission.
-Silicon Graphics makes no representation about the suitability
-of this software for any purpose. It is provided "as is"
-without any express or implied warranty.
-SILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
-SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
-AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON
-GRAPHICS 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_DIX_CONFIG_H
-#include <dix-config.h>
-#endif
-
-#include <X11/X.h>
-#include <X11/Xproto.h>
-#include "dixstruct.h"
-#include "extnsionst.h"
-#include "dix.h"
-#define _XEVI_SERVER_
-#include <X11/extensions/XEVIstr.h>
-#include "EVIstruct.h"
-#include "modinit.h"
-#include "scrnintstr.h"
-
-static EviPrivPtr eviPriv;
-
-static int
-ProcEVIQueryVersion(ClientPtr client)
-{
- /* REQUEST(xEVIQueryVersionReq); */
- xEVIQueryVersionReply rep;
- register int n;
- REQUEST_SIZE_MATCH (xEVIQueryVersionReq);
- rep.type = X_Reply;
- rep.length = 0;
- rep.sequenceNumber = client->sequence;
- rep.majorVersion = XEVI_MAJOR_VERSION;
- rep.minorVersion = XEVI_MAJOR_VERSION;
- if (client->swapped) {
- swaps(&rep.sequenceNumber, n);
- swapl(&rep.length, n);
- swaps(&rep.majorVersion, n);
- swaps(&rep.minorVersion, n);
- }
- WriteToClient(client, sizeof (xEVIQueryVersionReply), (char *)&rep);
- return (client->noClientException);
-}
-#define swapEviInfo(eviInfo, l) \
-{ \
- int l1 = l; \
- xExtendedVisualInfo *eviInfo1 = eviInfo; \
- while (l1-- > 0) { \
- swapl(&eviInfo1->core_visual_id, n); \
- swapl(&eviInfo1->transparency_value, n); \
- swaps(&eviInfo1->num_colormap_conflicts, n); \
- eviInfo1++; \
- } \
-}
-#define swapVisual(visual, l) \
-{ \
- int l1 = l; \
- VisualID32 *visual1 = visual; \
- while (l1-- > 0) { \
- swapl(visual1, n); \
- visual1++; \
- } \
-}
-
-static int
-ProcEVIGetVisualInfo(ClientPtr client)
-{
- REQUEST(xEVIGetVisualInfoReq);
- xEVIGetVisualInfoReply rep;
- int i, n, n_conflict, n_info, sz_info, sz_conflict;
- VisualID32 *conflict;
- unsigned int total_visuals = 0;
- xExtendedVisualInfo *eviInfo;
- int status;
-
- /*
- * do this first, otherwise REQUEST_FIXED_SIZE can overflow. we assume
- * here that you don't have more than 2^32 visuals over all your screens;
- * this seems like a safe assumption.
- */
- for (i = 0; i < screenInfo.numScreens; i++)
- total_visuals += screenInfo.screens[i]->numVisuals;
- if (stuff->n_visual > total_visuals)
- return BadValue;
-
- REQUEST_FIXED_SIZE(xEVIGetVisualInfoReq, stuff->n_visual * sz_VisualID32);
- status = eviPriv->getVisualInfo((VisualID32 *)&stuff[1], (int)stuff->n_visual,
- &eviInfo, &n_info, &conflict, &n_conflict);
- if (status != Success)
- return status;
- sz_info = n_info * sz_xExtendedVisualInfo;
- sz_conflict = n_conflict * sz_VisualID32;
- rep.type = X_Reply;
- rep.n_info = n_info;
- rep.n_conflicts = n_conflict;
- rep.sequenceNumber = client->sequence;
- rep.length = (sz_info + sz_conflict) >> 2;
- if (client->swapped) {
- swaps(&rep.sequenceNumber, n);
- swapl(&rep.length, n);
- swapl(&rep.n_info, n);
- swapl(&rep.n_conflicts, n);
- swapEviInfo(eviInfo, n_info);
- swapVisual(conflict, n_conflict);
- }
- WriteToClient(client, sz_xEVIGetVisualInfoReply, (char *)&rep);
- WriteToClient(client, sz_info, (char *)eviInfo);
- WriteToClient(client, sz_conflict, (char *)conflict);
- eviPriv->freeVisualInfo(eviInfo, conflict);
- return (client->noClientException);
-}
-
-static int
-ProcEVIDispatch(ClientPtr client)
-{
- REQUEST(xReq);
- switch (stuff->data) {
- case X_EVIQueryVersion:
- return ProcEVIQueryVersion (client);
- case X_EVIGetVisualInfo:
- return ProcEVIGetVisualInfo (client);
- default:
- return BadRequest;
- }
-}
-
-static int
-SProcEVIQueryVersion(ClientPtr client)
-{
- REQUEST(xEVIQueryVersionReq);
- int n;
- swaps(&stuff->length, n);
- return ProcEVIQueryVersion(client);
-}
-
-static int
-SProcEVIGetVisualInfo(ClientPtr client)
-{
- register int n;
- REQUEST(xEVIGetVisualInfoReq);
- swaps(&stuff->length, n);
- return ProcEVIGetVisualInfo(client);
-}
-
-static int
-SProcEVIDispatch(ClientPtr client)
-{
- REQUEST(xReq);
- switch (stuff->data)
- {
- case X_EVIQueryVersion:
- return SProcEVIQueryVersion (client);
- case X_EVIGetVisualInfo:
- return SProcEVIGetVisualInfo (client);
- default:
- return BadRequest;
- }
-}
-
-/*ARGSUSED*/
-static void
-EVIResetProc(ExtensionEntry *extEntry)
-{
- eviDDXReset();
-}
-
-/****************
- * XEVIExtensionInit
- *
- * Called from InitExtensions in main() or from QueryExtension() if the
- * extension is dynamically loaded.
- *
- ****************/
-void
-EVIExtensionInit(INITARGS)
-{
- if (AddExtension(EVINAME, 0, 0,
- ProcEVIDispatch, SProcEVIDispatch,
- EVIResetProc, StandardMinorOpcode)) {
- eviPriv = eviDDXInit();
- }
-}
diff --git a/Xext/EVIstruct.h b/Xext/EVIstruct.h
deleted file mode 100644
index e6581909f..000000000
--- a/Xext/EVIstruct.h
+++ /dev/null
@@ -1,58 +0,0 @@
-/************************************************************
-Copyright (c) 1997 by Silicon Graphics Computer Systems, Inc.
-Permission to use, copy, modify, and distribute this
-software and its documentation for any purpose and without
-fee is hereby granted, 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 Silicon Graphics not be
-used in advertising or publicity pertaining to distribution
-of the software without specific prior written permission.
-Silicon Graphics makes no representation about the suitability
-of this software for any purpose. It is provided "as is"
-without any express or implied warranty.
-SILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
-SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
-AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON
-GRAPHICS 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_DIX_CONFIG_H
-#include <dix-config.h>
-#endif
-
-#ifndef EVI_STRUCT_H
-#define EVI_STRUCT_H
-
-/*
- ******************************************************************************
- ** Per-ddx data
- ******************************************************************************
- */
-
-typedef int (*GetVisualInfoProc)(
- VisualID32*,
- int,
- xExtendedVisualInfo**,
- int*,
- VisualID32**,
- int*
-);
-
-typedef void (*FreeVisualInfoProc)(
- xExtendedVisualInfo*,
- VisualID32*
-);
-typedef struct _EviPrivRec {
- GetVisualInfoProc getVisualInfo;
- FreeVisualInfoProc freeVisualInfo;
-} EviPrivRec, *EviPrivPtr;
-
-extern EviPrivPtr eviDDXInit(void);
-extern void eviDDXReset(void);
-
-#endif /* EVI_STRUCT_H */
diff --git a/Xext/Makefile.am b/Xext/Makefile.am
index 648736d95..b03fedaa3 100644
--- a/Xext/Makefile.am
+++ b/Xext/Makefile.am
@@ -28,7 +28,6 @@ BUILTIN_SRCS = \
# Sources always included in libXextmodule.la & libXext.la
MODULE_SRCS = \
bigreq.c \
- mitmisc.c \
shape.c \
sync.c \
xcmisc.c
@@ -105,25 +104,6 @@ if XPRINT
BUILTIN_SRCS += $(XPRINT_SRCS)
endif
-# AppGroup
-APPGROUP_SRCS = appgroup.c appgroup.h
-if APPGROUP
-BUILTIN_SRCS += $(APPGROUP_SRCS)
-endif
-
-# Colormap Utilization Protocol: Less flashing when switching between
-# PsuedoColor apps and better sharing of limited colormap slots
-CUP_SRCS = cup.c
-if CUP
-MODULE_SRCS += $(CUP_SRCS)
-endif
-
-# Extended Visual Information
-EVI_SRCS = EVI.c sampleEVI.c EVIstruct.h
-if EVI
-MODULE_SRCS += $(EVI_SRCS)
-endif
-
# Multi-buffering extension
MULTIBUFFER_SRCS = mbuf.c
EXTRA_MULTIBUFFER_SRCS = mbufbf.c mbufpx.c
@@ -170,9 +150,6 @@ EXTRA_DIST = \
$(XINERAMA_SRCS) \
$(XEVIE_SRCS) \
$(XPRINT_SRCS) \
- $(APPGROUP_SRCS) \
- $(CUP_SRCS) \
- $(EVI_SRCS) \
$(MULTIBUFFER_SRCS) \
$(EXTRA_MULTIBUFFER_SRCS) \
$(FONTCACHE_SRCS) \
diff --git a/Xext/appgroup.c b/Xext/appgroup.c
deleted file mode 100644
index c40782df5..000000000
--- a/Xext/appgroup.c
+++ /dev/null
@@ -1,775 +0,0 @@
-/*
-Copyright 1996, 1998, 2001 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.
-*/
-
-#define NEED_REPLIES
-#define NEED_EVENTS
-#ifdef HAVE_DIX_CONFIG_H
-#include <dix-config.h>
-#endif
-
-#include <X11/X.h>
-#include <X11/Xproto.h>
-#include "misc.h"
-#include "dixstruct.h"
-#include "extnsionst.h"
-#include "scrnintstr.h"
-#include "windowstr.h"
-#include "colormapst.h"
-#include "servermd.h"
-#define _XAG_SERVER_
-#include <X11/extensions/Xagstr.h>
-#include "xacestr.h"
-#include "securitysrv.h"
-#include <X11/Xfuncproto.h>
-
-#define XSERV_t
-#include <X11/Xtrans/Xtrans.h>
-#include "../os/osdep.h"
-
-#include <stdio.h>
-
-#include "modinit.h"
-#include "appgroup.h"
-
-typedef struct _AppGroupRec {
- struct _AppGroupRec* next;
- XID appgroupId;
- ClientPtr* clients;
- int nclients;
- ClientPtr leader;
- Bool single_screen;
- Window default_root;
- VisualID root_visual;
- Colormap default_colormap;
- Pixel black_pixel;
- Pixel white_pixel;
- xConnSetupPrefix connSetupPrefix;
- char* ConnectionInfo;
-} AppGroupRec, *AppGroupPtr;
-
-static int ProcXagDispatch(ClientPtr client);
-static int SProcXagDispatch(ClientPtr client);
-static void XagResetProc(ExtensionEntry* extEntry);
-
-static int XagCallbackRefCount = 0;
-
-static RESTYPE RT_APPGROUP;
-static AppGroupPtr appGrpList = NULL;
-
-extern xConnSetupPrefix connSetupPrefix;
-extern char* ConnectionInfo;
-extern int connBlockScreenStart;
-
-static
-int XagAppGroupFree(
- pointer what,
- XID id) /* unused */
-{
- int i;
- AppGroupPtr pAppGrp = (AppGroupPtr) what;
-
- if (pAppGrp->leader)
- for (i = 0; i < pAppGrp->nclients; i++) {
- if (pAppGrp->clients[i] == NULL) continue;
- CloseDownClient (pAppGrp->clients[i]);
- }
-
- if (pAppGrp == appGrpList)
- appGrpList = appGrpList->next;
- else {
- AppGroupPtr tpAppGrp;
- for (tpAppGrp = appGrpList;
- tpAppGrp->next != NULL;
- tpAppGrp = tpAppGrp->next) {
- if (tpAppGrp->next == pAppGrp) {
- tpAppGrp->next = tpAppGrp->next->next;
- break;
- }
- }
- }
- (void) xfree (pAppGrp->clients);
- (void) xfree (pAppGrp->ConnectionInfo);
- (void) xfree (what);
- return Success;
-}
-
-static void XagClientStateChange(
- CallbackListPtr* pcbl,
- pointer nulldata,
- pointer calldata)
-{
- NewClientInfoRec* pci = (NewClientInfoRec*) calldata;
- ClientPtr pClient = pci->client;
- AppGroupPtr pAppGrp = pClient->appgroup;
- int slot;
-
- if (!pAppGrp)
- return;
-
- switch (pClient->clientState) {
- case ClientStateAuthenticating:
- case ClientStateRunning:
- case ClientStateCheckingSecurity:
- break;
-
- case ClientStateInitial:
- case ClientStateCheckedSecurity:
- slot = -1;
- /* see the comment above about Initial vs. CheckedSecurity */
- if (pAppGrp->nclients != 0) {
- /* if this client already in AppGroup, don't add it again */
- int i;
- for (i = 0; i < pAppGrp->nclients; i++)
- if (pClient == pAppGrp->clients[i]) return;
- if (slot == -1 && pAppGrp->clients[i] == NULL)
- slot = i;
- }
- if (slot == -1) {
- slot = pAppGrp->nclients++;
- pAppGrp->clients = (ClientPtr*) xrealloc (pAppGrp->clients,
- pAppGrp->nclients * sizeof (ClientPtr));
- }
- pAppGrp->clients[slot] = pClient;
- pClient->appgroup = pAppGrp;
- break;
-
- case ClientStateGone:
- case ClientStateRetained: /* client disconnected, dump it */
- {
- int i;
- for (i = 0; i < pAppGrp->nclients; i++)
- if (pAppGrp->clients[i] == pClient) {
- pAppGrp->clients[i] = NULL;
- break;
- }
- }
- pClient->appgroup = NULL; /* redundant, pClient will be freed */
- break;
- }
-}
-
-/*ARGSUSED*/
-static
-void XagResetProc(
- ExtensionEntry* extEntry)
-{
- DeleteCallback (&ClientStateCallback, XagClientStateChange, NULL);
- XagCallbackRefCount = 0;
- while (appGrpList) XagAppGroupFree ((pointer) appGrpList, 0);
-}
-
-static
-int ProcXagQueryVersion(
- register ClientPtr client)
-{
- /* REQUEST (xXagQueryVersionReq); */
- xXagQueryVersionReply rep;
- register int n;
-
- REQUEST_SIZE_MATCH (xXagQueryVersionReq);
- rep.type = X_Reply;
- rep.length = 0;
- rep.sequence_number = client->sequence;
- rep.server_major_version = XAG_MAJOR_VERSION;
- rep.server_minor_version = XAG_MINOR_VERSION;
- if (client->swapped) {
- swaps (&rep.sequence_number, n);
- swapl (&rep.length, n);
- swaps (&rep.server_major_version, n);
- swaps (&rep.server_minor_version, n);
- }
- WriteToClient (client, sizeof (xXagQueryVersionReply), (char *)&rep);
- return client->noClientException;
-}
-
-static
-void ProcessAttr(
- AppGroupPtr pAppGrp,
- ClientPtr client,
- unsigned int attrib_mask,
- CARD32* attribs)
-{
- int i;
-
- for (i = 0; i <= XagNappGroupLeader; i++) {
- switch (attrib_mask & (1 << i)) {
- case XagSingleScreenMask:
- pAppGrp->single_screen = *attribs;
- break;
- case XagDefaultRootMask:
- pAppGrp->default_root = *attribs;
- break;
- case XagRootVisualMask:
- pAppGrp->root_visual = *attribs;
- break;
- case XagDefaultColormapMask:
- pAppGrp->default_colormap = *attribs;
- break;
- case XagBlackPixelMask:
- pAppGrp->black_pixel = *attribs;
- break;
- case XagWhitePixelMask:
- pAppGrp->white_pixel = *attribs;
- break;
- case XagAppGroupLeaderMask:
- pAppGrp->leader = client;
- break;
- default: continue;
- }
- attribs++;
- }
-}
-
-static
-void CreateConnectionInfo(
- AppGroupPtr pAppGrp)
-{
- xWindowRoot* rootp;
- xWindowRoot* roots[MAXSCREENS];
- unsigned int rootlens[MAXSCREENS];
- xDepth* depth;
- int olen;
- int snum, i;
-
- rootp = (xWindowRoot*) (ConnectionInfo + connBlockScreenStart);
- for (snum = 0; snum < screenInfo.numScreens; snum++) {
-
- rootlens[snum] = sizeof (xWindowRoot);
- roots[snum] = rootp;
-
- depth = (xDepth*) (rootp + 1);
- for (i = 0; i < rootp->nDepths; i++) {
- rootlens[snum] += sizeof (xDepth) +
- depth->nVisuals * sizeof (xVisualType);
- depth = (xDepth *)(((char*)(depth + 1)) +
- depth->nVisuals * sizeof (xVisualType));
- }
- rootp = (xWindowRoot*) depth;
- }
- snum = 0;
- if (pAppGrp->default_root) {
- for (; snum < screenInfo.numVideoScreens; snum++) {
- if (roots[snum]->windowId == pAppGrp->default_root)
- break;
- }
- }
- olen = connBlockScreenStart + rootlens[snum];
- for (i = screenInfo.numVideoScreens; i < screenInfo.numScreens; i++)
- olen += rootlens[i];
- pAppGrp->ConnectionInfo = (char*) xalloc (olen);
- if (!pAppGrp->ConnectionInfo)
- return;
- memmove (pAppGrp->ConnectionInfo, ConnectionInfo, connBlockScreenStart);
- ((xConnSetup*) (pAppGrp->ConnectionInfo))->numRoots =
- 1 + screenInfo.numScreens - screenInfo.numVideoScreens;
- memmove (pAppGrp->ConnectionInfo + connBlockScreenStart,
- (void*) roots[snum], rootlens[snum]);
- rootp = (xWindowRoot*) (pAppGrp->ConnectionInfo + connBlockScreenStart);
- if (pAppGrp->default_colormap) {
- rootp->defaultColormap = pAppGrp->default_colormap;
- rootp->whitePixel = pAppGrp->white_pixel;
- rootp->blackPixel = pAppGrp->black_pixel;
- }
- if (pAppGrp->root_visual)
- rootp->rootVisualID = pAppGrp->root_visual;
- rootp = (xWindowRoot*) (((char*)rootp) + rootlens[snum]);
- for (i = screenInfo.numVideoScreens; i < screenInfo.numScreens; i++) {
- memmove ((void*) rootp, (void*) roots[i], rootlens[i]);
- rootp = (xWindowRoot*) (((char*) rootp) + rootlens[i]);
- }
- pAppGrp->connSetupPrefix = connSetupPrefix;
- pAppGrp->connSetupPrefix.length = olen >> 2;
-}
-
-static
-AppGroupPtr CreateAppGroup(
- ClientPtr client,
- XID appgroupId,
- unsigned int attrib_mask,
- CARD32* attribs)
-{
- AppGroupPtr pAppGrp;
-
- pAppGrp = (AppGroupPtr) xalloc (sizeof(AppGroupRec));
- if (pAppGrp) {
- pAppGrp->next = appGrpList;
- appGrpList = pAppGrp;
- pAppGrp->appgroupId = appgroupId;
- pAppGrp->clients = (ClientPtr*) xalloc (0);
- pAppGrp->nclients = 0;
- pAppGrp->leader = NULL;
- pAppGrp->default_root = 0;
- pAppGrp->root_visual = 0;
- pAppGrp->default_colormap = 0;
- pAppGrp->black_pixel = -1;
- pAppGrp->white_pixel = -1;
- pAppGrp->ConnectionInfo = NULL;
- ProcessAttr (pAppGrp, client, attrib_mask, attribs);
- }
- return pAppGrp;
-}
-
-static
-int AttrValidate(
- ClientPtr client,
- int attrib_mask,
- AppGroupPtr pAppGrp)
-{
- WindowPtr pWin;
- int idepth, ivids, found, rc;
- ScreenPtr pScreen;
- DepthPtr pDepth;
- ColormapPtr pColormap;
-
- rc = dixLookupWindow(&pWin, pAppGrp->default_root, client,
- DixGetAttrAccess);
- if (rc != Success)
- return rc;
- pScreen = pWin->drawable.pScreen;
- if (WindowTable[pScreen->myNum]->drawable.id != pAppGrp->default_root)
- return BadWindow;
- pDepth = pScreen->allowedDepths;
- if (pAppGrp->root_visual) {
- found = FALSE;
- for (idepth = 0; idepth < pScreen->numDepths; idepth++, pDepth++) {
- for (ivids = 0; ivids < pDepth->numVids; ivids++) {
- if (pAppGrp->root_visual == pDepth->vids[ivids]) {
- found = TRUE;
- break;
- }
- }
- }
- if (!found)
- return BadMatch;
- }
- if (pAppGrp->default_colormap) {
-
- rc = dixLookupResource((pointer *)&pColormap, pAppGrp->default_colormap,
- RT_COLORMAP, client, DixUseAccess);
- if (rc != Success)
- return rc;
- if (pColormap->pScreen != pScreen)
- return BadColor;
- if (pColormap->pVisual->vid != (pAppGrp->root_visual ? pAppGrp->root_visual : pScreen->rootVisual))
- return BadMatch;
- }
- return client->noClientException;
-}
-
-static int ProcXagCreate (
- register ClientPtr client)
-{
- REQUEST (xXagCreateReq);
- AppGroupPtr pAppGrp;
- int ret;
-
- REQUEST_AT_LEAST_SIZE (xXagCreateReq);
-
- LEGAL_NEW_RESOURCE (stuff->app_group, client);
- pAppGrp = CreateAppGroup (client, stuff->app_group,
- stuff->attrib_mask, (CARD32*) &stuff[1]);
- if (!pAppGrp)
- return BadAlloc;
- ret = AttrValidate (client, stuff->attrib_mask, pAppGrp);
- if (ret != Success) {
- XagAppGroupFree ((pointer)pAppGrp, (XID)0);
- return ret;
- }
- if (pAppGrp->single_screen) {
- CreateConnectionInfo (pAppGrp);
- if (!pAppGrp->ConnectionInfo)
- return BadAlloc;
- }
- if (!AddResource (stuff->app_group, RT_APPGROUP, (pointer)pAppGrp))
- return BadAlloc;
- if (XagCallbackRefCount++ == 0)
- (void) AddCallback (&ClientStateCallback, XagClientStateChange, NULL);
- return client->noClientException;
-}
-
-static int ProcXagDestroy(
- register ClientPtr client)
-{
- AppGroupPtr pAppGrp;
- REQUEST (xXagDestroyReq);
-
- REQUEST_SIZE_MATCH (xXagDestroyReq);
- pAppGrp = (AppGroupPtr)SecurityLookupIDByType (client,
- (XID)stuff->app_group, RT_APPGROUP, DixReadAccess);
- if (!pAppGrp) return XagBadAppGroup;
- FreeResource ((XID)stuff->app_group, RT_NONE);
- if (--XagCallbackRefCount == 0)
- (void) DeleteCallback (&ClientStateCallback, XagClientStateChange, NULL);
- return client->noClientException;
-}
-
-static
-int ProcXagGetAttr(
- register ClientPtr client)
-{
- AppGroupPtr pAppGrp;
- REQUEST (xXagGetAttrReq);
- xXagGetAttrReply rep;
- int n;
-
- REQUEST_SIZE_MATCH (xXagGetAttrReq);
- pAppGrp = (AppGroupPtr)SecurityLookupIDByType (client,
- (XID)stuff->app_group, RT_APPGROUP, DixReadAccess);
- if (!pAppGrp) return XagBadAppGroup;
- rep.type = X_Reply;
- rep.length = 0;
- rep.sequence_number = client->sequence;
- rep.default_root = pAppGrp->default_root;
- rep.root_visual = pAppGrp->root_visual;
- rep.default_colormap = pAppGrp->default_colormap;
- rep.black_pixel = pAppGrp->black_pixel;
- rep.white_pixel = pAppGrp->white_pixel;
- rep.single_screen = pAppGrp->single_screen;
- rep.app_group_leader = (pAppGrp->leader) ? 1 : 0;
- if (client->swapped) {
- swaps (&rep.sequence_number, n);
- swapl (&rep.length, n);
- swapl (&rep.default_root, n);
- swapl (&rep.root_visual, n);
- swapl (&rep.default_colormap, n);
- swapl (&rep.black_pixel, n);
- swapl (&rep.white_pixel, n);
- }
- WriteToClient (client, sizeof (xXagGetAttrReply), (char *)&rep);
- return client->noClientException;
-}
-
-static
-int ProcXagQuery(
- register ClientPtr client)
-{
- ClientPtr pClient;
- AppGroupPtr pAppGrp;
- REQUEST (xXagQueryReq);
- int n, rc;
-
- REQUEST_SIZE_MATCH (xXagQueryReq);
- rc = dixLookupClient(&pClient, stuff->resource, client, DixGetAttrAccess);
- if (rc != Success)
- return rc;
-
- for (pAppGrp = appGrpList; pAppGrp != NULL; pAppGrp = pAppGrp->next)
- for (n = 0; n < pAppGrp->nclients; n++)
- if (pAppGrp->clients[n] == pClient) {
- xXagQueryReply rep;
-
- rep.type = X_Reply;
- rep.length = 0;
- rep.sequence_number = client->sequence;
- rep.app_group = pAppGrp->appgroupId;
- if (client->swapped) {
- swaps (&rep.sequence_number, n);
- swapl (&rep.length, n);
- swapl (&rep.app_group, n);
- }
- WriteToClient (client, sizeof (xXagQueryReply), (char *)&rep);
- return client->noClientException;
- }
-
- return BadMatch;
-}
-
-static
-int ProcXagCreateAssoc(
- register ClientPtr client)
-{
- REQUEST (xXagCreateAssocReq);
-
- REQUEST_SIZE_MATCH (xXagCreateAssocReq);
-#ifdef WIN32
- if (stuff->window_type != XagWindowTypeWin32)
-#else
- if (stuff->window_type != XagWindowTypeX11)
-#endif
- return BadMatch;
-#if defined(WIN32) || defined(__CYGWIN__) /* and Mac, etc */
- if (!LocalClient (client))
- return BadAccess;
-#endif
-
-/* Macintosh, OS/2, and MS-Windows servers have some work to do here */
-
- return client->noClientException;
-}
-
-static
-int ProcXagDestroyAssoc(
- register ClientPtr client)
-{
- /* REQUEST (xXagDestroyAssocReq); */
-
- REQUEST_SIZE_MATCH (xXagDestroyAssocReq);
-/* Macintosh, OS/2, and MS-Windows servers have some work to do here */
- return client->noClientException;
-}
-
-static
-int ProcXagDispatch (
- register ClientPtr client)
-{
- REQUEST (xReq);
- switch (stuff->data)
- {
- case X_XagQueryVersion:
- return ProcXagQueryVersion (client);
- case X_XagCreate:
- return ProcXagCreate (client);
- case X_XagDestroy:
- return ProcXagDestroy (client);
- case X_XagGetAttr:
- return ProcXagGetAttr (client);
- case X_XagQuery:
- return ProcXagQuery (client);
- case X_XagCreateAssoc:
- return ProcXagCreateAssoc (client);
- case X_XagDestroyAssoc:
- return ProcXagDestroyAssoc (client);
- default:
- return BadRequest;
- }
-}
-
-static
-int SProcXagQueryVersion(
- register ClientPtr client)
-{
- register int n;
- REQUEST(xXagQueryVersionReq);
- swaps(&stuff->length, n);
- return ProcXagQueryVersion(client);
-}
-
-static
-int SProcXagCreate(
- ClientPtr client)
-{
- register int n;
- REQUEST (xXagCreateReq);
- swaps (&stuff->length, n);
- REQUEST_AT_LEAST_SIZE (xXagCreateReq);
- swapl (&stuff->app_group, n);
- swapl (&stuff->attrib_mask, n);
- SwapRestL (stuff);
- return ProcXagCreate (client);
-}
-
-static
-int SProcXagDestroy(
- ClientPtr client)
-{
- register int n;
- REQUEST (xXagDestroyReq);
- swaps (&stuff->length, n);
- REQUEST_SIZE_MATCH (xXagDestroyReq);
- swapl (&stuff->app_group, n);
- return ProcXagDestroy (client);
-}
-
-static
-int SProcXagGetAttr(
- ClientPtr client)
-{
- register int n;
- REQUEST (xXagGetAttrReq);
- swaps (&stuff->length, n);
- REQUEST_SIZE_MATCH (xXagGetAttrReq);
- swapl (&stuff->app_group, n);
- return ProcXagGetAttr (client);
-}
-
-static
-int SProcXagQuery(
- ClientPtr client)
-{
- register int n;
- REQUEST (xXagQueryReq);
- swaps (&stuff->length, n);
- REQUEST_SIZE_MATCH (xXagQueryReq);
- swapl (&stuff->resource, n);
- return ProcXagQuery (client);
-}
-
-static
-int SProcXagCreateAssoc(
- ClientPtr client)
-{
- register int n;
- REQUEST (xXagCreateAssocReq);
- swaps (&stuff->length, n);
- REQUEST_SIZE_MATCH (xXagCreateAssocReq);
- swapl (&stuff->window, n);
- swapl (&stuff->window_type, n);
- swaps (&stuff->system_window_len, n);
- return ProcXagCreateAssoc (client);
-}
-
-static
-int SProcXagDestroyAssoc(
- ClientPtr client)
-{
- register int n;
- REQUEST (xXagDestroyAssocReq);
- swaps (&stuff->length, n);
- REQUEST_SIZE_MATCH (xXagDestroyAssocReq);
- swapl (&stuff->window, n);
- return ProcXagDestroyAssoc (client);
-}
-
-static
-int SProcXagDispatch(
- register ClientPtr client)
-{
- REQUEST(xReq);
- switch (stuff->data)
- {
- case X_XagQueryVersion:
- return SProcXagQueryVersion (client);
- case X_XagCreate:
- return SProcXagCreate (client);
- case X_XagDestroy:
- return SProcXagDestroy (client);
- case X_XagGetAttr:
- return SProcXagGetAttr (client);
- case X_XagQuery:
- return SProcXagQuery (client);
- case X_XagCreateAssoc:
- return SProcXagCreateAssoc (client);
- case X_XagDestroyAssoc:
- return SProcXagDestroyAssoc (client);
- default:
- return BadRequest;
- }
-}
-
-Colormap XagDefaultColormap(
- ClientPtr client)
-{
- return (client->appgroup ? client->appgroup->default_colormap : None);
-}
-
-VisualID XagRootVisual(
- ClientPtr client)
-{
- return (client->appgroup ? client->appgroup->root_visual : 0);
-}
-
-ClientPtr XagLeader(
- ClientPtr client)
-{
- return (client->appgroup ? client->appgroup->leader : NULL);
-}
-
-/*
- * Return whether the Map request event should be sent to the appgroup leader.
- * We don't want to send it to the leader when the window is on a different
- * screen, e.g. a print screen.
- */
-Bool XagIsControlledRoot(
- ClientPtr client,
- WindowPtr pParent)
-{
- if (client->appgroup) {
- if (client->appgroup->single_screen &&
- pParent->drawable.id == client->appgroup->default_root)
- return TRUE;
- else if (!pParent->parent)
- return TRUE;
- else
- return FALSE;
- }
- return FALSE;
-}
-
-void XagConnectionInfo(
- ClientPtr client,
- xConnSetupPrefix** conn_prefix,
- char** conn_info,
- int* num_screen)
-{
- if (client->appgroup && client->appgroup->ConnectionInfo) {
- *conn_prefix = &client->appgroup->connSetupPrefix;
- *conn_info = client->appgroup->ConnectionInfo;
- *num_screen = ((xConnSetup*)(client->appgroup->ConnectionInfo))->numRoots;
- }
-}
-
-XID XagId(
- ClientPtr client)
-{
- return (client->appgroup ? client->appgroup->appgroupId : 0);
-}
-
-static void XagCallClientStateChange(
- CallbackListPtr *pcbl,
- pointer nulldata,
- pointer calldata)
-{
- XaceAuthAvailRec* rec = (XaceAuthAvailRec*) calldata;
- ClientPtr pClient = rec->client;
-
- if (!pClient->appgroup) {
- SecurityAuthorizationPtr pAuth;
- XID authId = rec->authId;
-
- /* can't use SecurityLookupIDByType here -- client
- * security state hasn't been setup yet.
- */
- pAuth = (SecurityAuthorizationPtr)LookupIDByType(authId,
- SecurityAuthorizationResType);
- if (!pAuth)
- return;
-
- pClient->appgroup = (AppGroupPtr)LookupIDByType(pAuth->group,
- RT_APPGROUP);
- }
-
- if (pClient->appgroup) {
- NewClientInfoRec clientinfo;
-
- clientinfo.client = pClient;
- XagClientStateChange (NULL, NULL, (pointer)&clientinfo);
- }
-}
-
-void
-XagExtensionInit(INITARGS)
-{
- if (AddExtension (XAGNAME,
- 0,
- XagNumberErrors,
- ProcXagDispatch,
- SProcXagDispatch,
- XagResetProc,
- StandardMinorOpcode)) {
- RT_APPGROUP = CreateNewResourceType (XagAppGroupFree);
- XaceRegisterCallback(XACE_AUTH_AVAIL, XagCallClientStateChange, NULL);
- }
-}
diff --git a/Xext/appgroup.h b/Xext/appgroup.h
deleted file mode 100644
index 778da5de6..000000000
--- a/Xext/appgroup.h
+++ /dev/null
@@ -1,67 +0,0 @@
-/*
-Copyright 1996, 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.
-*/
-
-#ifndef _APPGROUP_SRV_H_
-#define _APPGROUP_SRV_H_
-
-#include <X11/Xfuncproto.h>
-
-_XFUNCPROTOBEGIN
-
-extern void XagConnectionInfo(
- ClientPtr /* client */,
- xConnSetupPrefix** /* conn_prefix */,
- char** /* conn_info */,
- int* /* num_screens */
-);
-
-extern VisualID XagRootVisual(
- ClientPtr /* client */
-);
-
-extern Colormap XagDefaultColormap(
- ClientPtr /* client */
-);
-
-extern ClientPtr XagLeader(
- ClientPtr /* client */
-);
-
-extern Bool XagIsControlledRoot (
- ClientPtr /* client */,
- WindowPtr /* pParent */
-);
-
-extern XID XagId (
- ClientPtr /* client */
-);
-
-_XFUNCPROTOEND
-
-#endif /* _APPGROUP_SRV_H_ */
-
-
-
diff --git a/Xext/cup.c b/Xext/cup.c
deleted file mode 100644
index fd1409e33..000000000
--- a/Xext/cup.c
+++ /dev/null
@@ -1,342 +0,0 @@
-/*
-
-Copyright 1997, 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.
-
-*/
-
-#define NEED_REPLIES
-#define NEED_EVENTS
-#ifdef HAVE_DIX_CONFIG_H
-#include <dix-config.h>
-#endif
-
-#include <X11/X.h>
-#include <X11/Xproto.h>
-#include "misc.h"
-#include "dixstruct.h"
-#include "extnsionst.h"
-#include "colormapst.h"
-#include "scrnintstr.h"
-#include "servermd.h"
-#include "swapreq.h"
-#define _XCUP_SERVER_
-#include <X11/extensions/Xcupstr.h>
-#include <X11/Xfuncproto.h>
-
-#include "../os/osdep.h"
-
-#include "modinit.h"
-
-static int ProcDispatch(ClientPtr client);
-static int SProcDispatch(ClientPtr client);
-static void ResetProc(ExtensionEntry* extEntry);
-
-#if defined(WIN32) || defined(TESTWIN32)
-#define HAVE_SPECIAL_DESKTOP_COLORS
-#endif
-
-static xColorItem citems[] = {
-#ifndef HAVE_SPECIAL_DESKTOP_COLORS
-#define CUP_BLACK_PIXEL 0
-#define CUP_WHITE_PIXEL 1
- /* pix red green blue */
- { 0, 0, 0, 0, 0, 0 },
- { 1, 0xffff, 0xffff, 0xffff, 0, 0 }
-#else
-#ifndef WIN32
- /*
- This approximates the MS-Windows desktop colormap for testing
- purposes but has black and white pixels in the typical Unix
- locations, which should be switched if necessary if your system
- has blackPixel and whitePixel swapped. No entries are provided
- for colormap entries 254 and 255 because AllocColor/FindColor
- will reuse entries zero and one.
- */
- { 0, 0, 0, 0, 0, 0 },
- { 1, 0xffff, 0xffff, 0xffff, 0, 0 },
- { 2, 0x8000, 0, 0, 0, 0 },
- { 3, 0, 0x8000, 0, 0, 0 },
- { 4, 0x8000, 0x8000, 0, 0, 0 },
- { 5, 0, 0, 0x8000, 0, 0 },
- { 6, 0x8000, 0, 0x8000, 0, 0 },
- { 7, 0, 0x8000, 0x8000, 0, 0 },
- { 8, 0xc000, 0xc000, 0xc000, 0, 0 },
- { 9, 0xc000, 0xdc00, 0xc000, 0, 0 },
- { 246, 0xa000, 0xa000, 0xa000, 0, 0 },
- { 247, 0x8000, 0x8000, 0x8000, 0, 0 },
- { 248, 0xffff, 0, 0, 0, 0 },
- { 249, 0, 0xffff, 0, 0, 0 },
- { 250, 0xffff, 0xffff, 0, 0, 0 },
- { 251, 0, 0, 0xffff, 0, 0 },
- { 252, 0xffff, 0, 0xffff, 0, 0 },
- { 253, 0, 0xffff, 0xffff, 0, 0 }
-#else
- /*
- this is the MS-Windows desktop, adjusted for X's 16-bit color
- specifications.
- */
- { 0, 0, 0, 0, 0, 0 },
- { 1, 0x8000, 0, 0, 0, 0 },
- { 2, 0, 0x8000, 0, 0, 0 },
- { 3, 0x8000, 0x8000, 0, 0, 0 },
- { 4, 0, 0, 0x8000, 0, 0 },
- { 5, 0x8000, 0, 0x8000, 0, 0 },
- { 6, 0, 0x8000, 0x8000, 0, 0 },
- { 7, 0xc000, 0xc000, 0xc000, 0, 0 },
- { 8, 0xc000, 0xdc00, 0xc000, 0, 0 },
- { 9, 0xa600, 0xca00, 0xf000, 0, 0 },
- { 246, 0xff00, 0xfb00, 0xf000, 0, 0 },
- { 247, 0xa000, 0xa000, 0xa400, 0, 0 },
- { 248, 0x8000, 0x8000, 0x8000, 0, 0 },
- { 249, 0xff00, 0, 0, 0, 0 },
- { 250, 0, 0xff00, 0, 0, 0 },
- { 251, 0xff00, 0xff00, 0, 0, 0 },
- { 252, 0, 0, 0xff00, 0, 0 },
- { 253, 0xff00, 0, 0xff00, 0, 0 },
- { 254, 0, 0xff00, 0xff00, 0, 0 },
- { 255, 0xff00, 0xff00, 0xff00, 0, 0 }
-#endif
-#endif
-};
-#define NUM_DESKTOP_COLORS (sizeof citems / sizeof citems[0])
-
-void
-XcupExtensionInit (INITARGS)
-{
- (void) AddExtension (XCUPNAME,
- 0,
- XcupNumberErrors,
- ProcDispatch,
- SProcDispatch,
- ResetProc,
- StandardMinorOpcode);
-
- /* PC servers initialize the desktop colors (citems) here! */
-}
-
-/*ARGSUSED*/
-static
-void ResetProc(
- ExtensionEntry* extEntry)
-{
-}
-
-static
-int ProcQueryVersion(
- register ClientPtr client)
-{
- /* REQUEST (xXcupQueryVersionReq); */
- xXcupQueryVersionReply rep;
- register int n;
-
- REQUEST_SIZE_MATCH (xXcupQueryVersionReq);
- rep.type = X_Reply;
- rep.length = 0;
- rep.sequence_number = client->sequence;
- rep.server_major_version = XCUP_MAJOR_VERSION;
- rep.server_minor_version = XCUP_MINOR_VERSION;
- if (client->swapped) {
- swaps (&rep.sequence_number, n);
- swapl (&rep.length, n);
- swaps (&rep.server_major_version, n);
- swaps (&rep.server_minor_version, n);
- }
- WriteToClient (client, sizeof (xXcupQueryVersionReply), (char *)&rep);
- return client->noClientException;
-}
-
-static
-int ProcGetReservedColormapEntries(
- register ClientPtr client)
-{
- REQUEST (xXcupGetReservedColormapEntriesReq);
- xXcupGetReservedColormapEntriesReply rep;
- xColorItem* cptr;
- register int n;
-
- REQUEST_SIZE_MATCH (xXcupGetReservedColormapEntriesReq);
-
- if (stuff->screen >= screenInfo.numScreens)
- return BadValue;
-
-#ifndef HAVE_SPECIAL_DESKTOP_COLORS
- citems[CUP_BLACK_PIXEL].pixel =
- screenInfo.screens[stuff->screen]->blackPixel;
- citems[CUP_WHITE_PIXEL].pixel =
- screenInfo.screens[stuff->screen]->whitePixel;
-#endif
-
- rep.type = X_Reply;
- rep.sequence_number = client->sequence;
- rep.length = NUM_DESKTOP_COLORS * 3;
- if (client->swapped) {
- swaps (&rep.sequence_number, n);
- swapl (&rep.length, n);
- }
- WriteToClient (client, sizeof (xXcupGetReservedColormapEntriesReply), (char *)&rep);
- for (n = 0, cptr = citems; n < NUM_DESKTOP_COLORS; n++, cptr++) {
- if (client->swapped) SwapColorItem (cptr);
- WriteToClient (client, SIZEOF(xColorItem), (char *)cptr);
- }
- return client->noClientException;
-}
-
-static
-int ProcStoreColors(
- register ClientPtr client)
-{
- REQUEST (xXcupStoreColorsReq);
- ColormapPtr pcmp;
- int rc;
-
- REQUEST_AT_LEAST_SIZE (xXcupStoreColorsReq);
- rc = dixLookupResource((pointer *)&pcmp, stuff->cmap, RT_COLORMAP,
- client, DixAddAccess);
-
- if (rc == Success) {
- int ncolors, n;
- xXcupStoreColorsReply rep;
- xColorItem* cptr;
-
- if (!(pcmp->class & DynamicClass))
- return BadMatch;
-
- ncolors = (client->req_len << 2) - SIZEOF (xXcupStoreColorsReq);
- if (ncolors % SIZEOF(xColorItem))
- return BadLength;
-
- ncolors /= SIZEOF (xColorItem);
-
-
- for (n = 0, cptr = (xColorItem*) &stuff[1]; n < ncolors; n++) {
- Pixel pixel = cptr->pixel;
-
- if (AllocColor (pcmp,
- &cptr->red, &cptr->green, &cptr->blue,
- &pixel, client->index) == Success) {
- cptr->pixel = pixel;
- cptr->flags = 0x08;
- } else
- cptr->flags = 0;
- cptr = (xColorItem*) (((char*)cptr) + SIZEOF(xColorItem));
- }
-
- rep.type = X_Reply;
- rep.sequence_number = client->sequence;
- rep.length = ncolors * 3;
- if (client->swapped) {
- swaps (&rep.sequence_number, n);
- swapl (&rep.length, n);
- }
- WriteToClient (client, sizeof (xXcupGetReservedColormapEntriesReply), (char *)&rep);
- for (n = 0, cptr = (xColorItem*) &stuff[1]; n < ncolors; n++) {
- if (client->swapped) SwapColorItem (cptr);
- WriteToClient (client, SIZEOF(xColorItem), (char *)cptr);
- cptr = (xColorItem*) (((char*)cptr) + SIZEOF(xColorItem));
- }
- return client->noClientException;
- } else {
- client->errorValue = stuff->cmap;
- return (rc == BadValue) ? BadColor : rc;
- }
-}
-
-static
-int ProcDispatch(
- register ClientPtr client)
-{
- REQUEST (xReq);
- switch (stuff->data)
- {
- case X_XcupQueryVersion:
- return ProcQueryVersion (client);
- case X_XcupGetReservedColormapEntries:
- return ProcGetReservedColormapEntries (client);
- case X_XcupStoreColors:
- return ProcStoreColors (client);
- default:
- return BadRequest;
- }
-}
-
-static
-int SProcQueryVersion(
- register ClientPtr client)
-{
- register int n;
-
- REQUEST(xXcupQueryVersionReq);
- swaps(&stuff->length, n);
- return ProcQueryVersion(client);
-}
-
-static
-int SProcGetReservedColormapEntries(
- ClientPtr client)
-{
- register int n;
-
- REQUEST (xXcupGetReservedColormapEntriesReq);
- swaps (&stuff->length, n);
- swapl (&stuff->screen, n);
- REQUEST_AT_LEAST_SIZE (xXcupGetReservedColormapEntriesReq);
- return ProcGetReservedColormapEntries (client);
-}
-
-static
-int SProcXcupStoreColors(
- ClientPtr client)
-{
- register int n;
- int count;
- xColorItem* pItem;
-
- REQUEST (xXcupStoreColorsReq);
- swaps (&stuff->length, n);
- REQUEST_AT_LEAST_SIZE (xXcupStoreColorsReq);
- swapl(&stuff->cmap, n);
- pItem = (xColorItem*) &stuff[1];
- for(count = LengthRestB(stuff)/sizeof(xColorItem); --count >= 0; )
- SwapColorItem(pItem++);
- return ProcStoreColors (client);
-}
-
-static
-int SProcDispatch(
- register ClientPtr client)
-{
- REQUEST(xReq);
- switch (stuff->data)
- {
- case X_XcupQueryVersion:
- return SProcQueryVersion (client);
- case X_XcupGetReservedColormapEntries:
- return SProcGetReservedColormapEntries (client);
- case X_XcupStoreColors:
- return SProcXcupStoreColors (client);
- default:
- return BadRequest;
- }
-}
-
-
diff --git a/Xext/mitmisc.c b/Xext/mitmisc.c
deleted file mode 100644
index e793d4dc1..000000000
--- a/Xext/mitmisc.c
+++ /dev/null
@@ -1,155 +0,0 @@
-/************************************************************
-
-Copyright 1989, 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.
-
-********************************************************/
-
-/* RANDOM CRUFT! THIS HAS NO OFFICIAL X CONSORTIUM OR X PROJECT TEAM BLESSING */
-
-
-#define NEED_EVENTS
-#ifdef HAVE_DIX_CONFIG_H
-#include <dix-config.h>
-#endif
-
-#include <X11/X.h>
-#include <X11/Xproto.h>
-#include "misc.h"
-#include "os.h"
-#include "dixstruct.h"
-#include "extnsionst.h"
-#define _MITMISC_SERVER_
-#include <X11/extensions/mitmiscstr.h>
-#include "modinit.h"
-
-static void MITResetProc(
- ExtensionEntry * /* extEntry */
-);
-
-static DISPATCH_PROC(ProcMITDispatch);
-static DISPATCH_PROC(ProcMITGetBugMode);
-static DISPATCH_PROC(ProcMITSetBugMode);
-static DISPATCH_PROC(SProcMITDispatch);
-static DISPATCH_PROC(SProcMITGetBugMode);
-static DISPATCH_PROC(SProcMITSetBugMode);
-
-void
-MITMiscExtensionInit(INITARGS)
-{
- AddExtension(MITMISCNAME, 0, 0,
- ProcMITDispatch, SProcMITDispatch,
- MITResetProc, StandardMinorOpcode);
-}
-
-/*ARGSUSED*/
-static void
-MITResetProc (extEntry)
-ExtensionEntry *extEntry;
-{
-}
-
-static int
-ProcMITSetBugMode(client)
- register ClientPtr client;
-{
- REQUEST(xMITSetBugModeReq);
-
- REQUEST_SIZE_MATCH(xMITSetBugModeReq);
- if (stuff->onOff != xFalse)
- return BadRequest;
- return(client->noClientException);
-}
-
-static int
-ProcMITGetBugMode(client)
- register ClientPtr client;
-{
- xMITGetBugModeReply rep;
- register int n;
-
- REQUEST_SIZE_MATCH(xMITGetBugModeReq);
- rep.type = X_Reply;
- rep.length = 0;
- rep.sequenceNumber = client->sequence;
- rep.onOff = FALSE;
- if (client->swapped) {
- swaps(&rep.sequenceNumber, n);
- swapl(&rep.length, n);
- }
- WriteToClient(client, sizeof(xMITGetBugModeReply), (char *)&rep);
- return(client->noClientException);
-}
-
-static int
-ProcMITDispatch (client)
- register ClientPtr client;
-{
- REQUEST(xReq);
- switch (stuff->data)
- {
- case X_MITSetBugMode:
- return ProcMITSetBugMode(client);
- case X_MITGetBugMode:
- return ProcMITGetBugMode(client);
- default:
- return BadRequest;
- }
-}
-
-static int
-SProcMITSetBugMode(client)
- register ClientPtr client;
-{
- register int n;
- REQUEST(xMITSetBugModeReq);
-
- swaps(&stuff->length, n);
- return ProcMITSetBugMode(client);
-}
-
-static int
-SProcMITGetBugMode(client)
- register ClientPtr client;
-{
- register int n;
- REQUEST(xMITGetBugModeReq);
-
- swaps(&stuff->length, n);
- return ProcMITGetBugMode(client);
-}
-
-static int
-SProcMITDispatch (client)
- register ClientPtr client;
-{
- REQUEST(xReq);
- switch (stuff->data)
- {
- case X_MITSetBugMode:
- return SProcMITSetBugMode(client);
- case X_MITGetBugMode:
- return SProcMITGetBugMode(client);
- default:
- return BadRequest;
- }
-}
diff --git a/Xext/sampleEVI.c b/Xext/sampleEVI.c
deleted file mode 100644
index b871bfd74..000000000
--- a/Xext/sampleEVI.c
+++ /dev/null
@@ -1,123 +0,0 @@
-/************************************************************
-Copyright (c) 1997 by Silicon Graphics Computer Systems, Inc.
-Permission to use, copy, modify, and distribute this
-software and its documentation for any purpose and without
-fee is hereby granted, 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 Silicon Graphics not be
-used in advertising or publicity pertaining to distribution
-of the software without specific prior written permission.
-Silicon Graphics makes no representation about the suitability
-of this software for any purpose. It is provided "as is"
-without any express or implied warranty.
-SILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
-SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
-AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON
-GRAPHICS 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_DIX_CONFIG_H
-#include <dix-config.h>
-#endif
-
-#include <X11/X.h>
-#include <X11/Xproto.h>
-#include "dixstruct.h"
-#include "extnsionst.h"
-#include "dix.h"
-#define _XEVI_SERVER_
-#include <X11/extensions/XEVIstr.h>
-#include "EVIstruct.h"
-#include "scrnintstr.h"
-
-#if HAVE_STDINT_H
-#include <stdint.h>
-#elif !defined(UINT32_MAX)
-#define UINT32_MAX 0xffffffffU
-#endif
-
-static int sampleGetVisualInfo(
- VisualID32 *visual,
- int n_visual,
- xExtendedVisualInfo **evi_rn,
- int *n_info_rn,
- VisualID32 **conflict_rn,
- int *n_conflict_rn)
-{
- unsigned int max_sz_evi;
- VisualID32 *temp_conflict;
- xExtendedVisualInfo *evi;
- unsigned int max_visuals = 0, max_sz_conflict, sz_conflict = 0;
- register int visualI, scrI, sz_evi = 0, conflictI, n_conflict;
-
- if (n_visual > UINT32_MAX/(sz_xExtendedVisualInfo * screenInfo.numScreens))
- return BadAlloc;
- max_sz_evi = n_visual * sz_xExtendedVisualInfo * screenInfo.numScreens;
-
- for (scrI = 0; scrI < screenInfo.numScreens; scrI++) {
- if (screenInfo.screens[scrI]->numVisuals > max_visuals)
- max_visuals = screenInfo.screens[scrI]->numVisuals;
- }
-
- if (n_visual > UINT32_MAX/(sz_VisualID32 * screenInfo.numScreens
- * max_visuals))
- return BadAlloc;
- max_sz_conflict = n_visual * sz_VisualID32 * screenInfo.numScreens * max_visuals;
-
- *evi_rn = evi = (xExtendedVisualInfo *)xalloc(max_sz_evi);
- if (!*evi_rn)
- return BadAlloc;
-
- temp_conflict = (VisualID32 *)xalloc(max_sz_conflict);
- if (!temp_conflict) {
- xfree(*evi_rn);
- return BadAlloc;
- }
-
- for (scrI = 0; scrI < screenInfo.numScreens; scrI++) {
- for (visualI = 0; visualI < n_visual; visualI++) {
- evi[sz_evi].core_visual_id = visual[visualI];
- evi[sz_evi].screen = scrI;
- evi[sz_evi].level = 0;
- evi[sz_evi].transparency_type = XEVI_TRANSPARENCY_NONE;
- evi[sz_evi].transparency_value = 0;
- evi[sz_evi].min_hw_colormaps = 1;
- evi[sz_evi].max_hw_colormaps = 1;
- evi[sz_evi].num_colormap_conflicts = n_conflict = 0;
- for (conflictI = 0; conflictI < n_conflict; conflictI++)
- temp_conflict[sz_conflict++] = visual[visualI];
- sz_evi++;
- }
- }
- *conflict_rn = temp_conflict;
- *n_conflict_rn = sz_conflict;
- *n_info_rn = sz_evi;
- return Success;
-}
-
-static void sampleFreeVisualInfo(
- xExtendedVisualInfo *evi,
- VisualID32 *conflict)
-{
- if (evi)
- xfree(evi);
- if (conflict)
- xfree(conflict);
-}
-
-EviPrivPtr eviDDXInit(void)
-{
- static EviPrivRec eviPriv;
- eviPriv.getVisualInfo = sampleGetVisualInfo;
- eviPriv.freeVisualInfo = sampleFreeVisualInfo;
- return &eviPriv;
-}
-
-void eviDDXReset(void)
-{
-}
diff --git a/Xext/security.c b/Xext/security.c
index e82b97626..b5990309e 100644
--- a/Xext/security.c
+++ b/Xext/security.c
@@ -38,9 +38,6 @@ in this Software without prior written authorization from The Open Group.
#include "xacestr.h"
#include "securitysrv.h"
#include <X11/extensions/securstr.h>
-#ifdef XAPPGROUP
-#include "appgroup.h"
-#endif
#include "modinit.h"
/* Extension stuff */
@@ -833,11 +830,6 @@ SecurityResource(CallbackListPtr *pcbl, pointer unused, pointer calldata)
if (SecurityDoCheck(subj, obj, requested, allowed) == Success)
return;
-#ifdef XAPPGROUP
- if (rec->id == XagDefaultColormap(rec->client))
- return;
-#endif
-
SecurityAudit("Security: denied client %d access %x to resource 0x%x "
"of client %d on request %s\n", rec->client->index,
requested, rec->id, cid,
diff --git a/Xi/exevents.c b/Xi/exevents.c
index fb84bef6f..641bead33 100644
--- a/Xi/exevents.c
+++ b/Xi/exevents.c
@@ -1279,6 +1279,8 @@ SendEventToAllWindows(DeviceIntPtr dev, Mask mask, xEvent * ev, int count)
for (i = 0; i < screenInfo.numScreens; i++) {
pWin = WindowTable[i];
+ if (!pWin)
+ continue;
(void)DeliverEventsToWindow(pWin, ev, count, mask, NullGrab, dev->id);
p1 = pWin->firstChild;
FindInterestedChildren(dev, p1, mask, ev, count);
diff --git a/acinclude.m4 b/acinclude.m4
index cbb68e19e..833b5577e 100644
--- a/acinclude.m4
+++ b/acinclude.m4
@@ -8,8 +8,7 @@ dnl To use dolt, invoke the DOLT macro immediately after the libtool macros.
dnl Optionally, copy this file into acinclude.m4, to avoid the need to have it
dnl installed when running autoconf on your project.
dnl
-dnl git snapshot: 198a3026b347b9220a2f2e2ae23a3049c35af262
-
+dnl git snapshot: d91f2b4e9041538400e2703a2a6fbeecdb8ee27d
AC_DEFUN([DOLT], [
AC_REQUIRE([AC_CANONICAL_HOST])
# dolt, a replacement for libtool
@@ -27,11 +26,13 @@ if test x$GCC != xyes; then
fi
case $host in
i?86-*-linux*|x86_64-*-linux*|powerpc-*-linux*) ;;
-amd64-*-freebsd*|i386-*-freebsd*|ia64-*-freebsd*) ;;
+amd64-*-freebsd*|i?86-*-freebsd*|ia64-*-freebsd*) ;;
*) dolt_supported=no ;;
esac
if test x$dolt_supported = xno ; then
AC_MSG_RESULT([no, falling back to libtool])
+ LTCOMPILE='$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(COMPILE)'
+ LTCXXCOMPILE='$(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXXCOMPILE)'
else
AC_MSG_RESULT([yes, replacing libtool])
@@ -65,9 +66,10 @@ dnl Write out shared compilation code.
cat <<'__DOLTCOMPILE__EOF__' >>doltcompile
libobjdir="${obj%$objbase}.libs"
if test ! -d "$libobjdir" ; then
- mkdir -p "$libobjdir"
+ mkdir_out="$(mkdir "$libobjdir" 2>&1)"
mkdir_ret=$?
if test "$mkdir_ret" -ne 0 && test ! -d "$libobjdir" ; then
+ echo "$mkdir_out" 1>&2
exit $mkdir_ret
fi
fi
@@ -130,17 +132,19 @@ __DOLTCOMPILE__EOF__
dnl Done writing out doltcompile; substitute it for libtool compilation.
chmod +x doltcompile
LTCOMPILE='$(top_builddir)/doltcompile $(COMPILE)'
- AC_SUBST(LTCOMPILE)
LTCXXCOMPILE='$(top_builddir)/doltcompile $(CXXCOMPILE)'
- AC_SUBST(LTCXXCOMPILE)
fi
+AC_SUBST(LTCOMPILE)
+AC_SUBST(LTCXXCOMPILE)
# end dolt
])
-##### http://autoconf-archive.cryp.to/ac_define_dir.html
+# ===========================================================================
+# http://autoconf-archive.cryp.to/ac_define_dir.html
+# ===========================================================================
#
# SYNOPSIS
#
@@ -148,11 +152,11 @@ fi
#
# DESCRIPTION
#
-# This macro sets VARNAME to the expansion of the DIR variable,
-# taking care of fixing up ${prefix} and such.
+# This macro sets VARNAME to the expansion of the DIR variable, taking
+# care of fixing up ${prefix} and such.
#
-# VARNAME is then offered as both an output variable and a C
-# preprocessor symbol.
+# VARNAME is then offered as both an output variable and a C preprocessor
+# symbol.
#
# Example:
#
@@ -160,18 +164,18 @@ fi
#
# LAST MODIFICATION
#
-# 2006-10-13
+# 2008-04-12
#
# COPYLEFT
#
-# Copyright (c) 2006 Stepan Kasal <kasal@ucw.cz>
-# Copyright (c) 2006 Andreas Schwab <schwab@suse.de>
-# Copyright (c) 2006 Guido U. Draheim <guidod@gmx.de>
-# Copyright (c) 2006 Alexandre Oliva
+# Copyright (c) 2008 Stepan Kasal <kasal@ucw.cz>
+# Copyright (c) 2008 Andreas Schwab <schwab@suse.de>
+# Copyright (c) 2008 Guido U. Draheim <guidod@gmx.de>
+# Copyright (c) 2008 Alexandre Oliva
#
-# Copying and distribution of this file, with or without
-# modification, are permitted in any medium without royalty provided
-# the copyright notice and this notice are preserved.
+# Copying and distribution of this file, with or without modification, are
+# permitted in any medium without royalty provided the copyright notice
+# and this notice are preserved.
AC_DEFUN([AC_DEFINE_DIR], [
prefix_NONE=
diff --git a/composite/Makefile.am b/composite/Makefile.am
index 21504e659..d7bead137 100644
--- a/composite/Makefile.am
+++ b/composite/Makefile.am
@@ -7,4 +7,5 @@ libcomposite_la_SOURCES = \
compext.c \
compint.h \
compinit.c \
+ compoverlay.c \
compwindow.c
diff --git a/composite/compext.c b/composite/compext.c
index b3433f72b..e720f6ce7 100644
--- a/composite/compext.c
+++ b/composite/compext.c
@@ -54,10 +54,7 @@ static CARD8 CompositeReqCode;
static DevPrivateKey CompositeClientPrivateKey = &CompositeClientPrivateKey;
RESTYPE CompositeClientWindowType;
RESTYPE CompositeClientSubwindowsType;
-static RESTYPE CompositeClientOverlayType;
-
-static void deleteCompOverlayClient (CompOverlayClientPtr pOcToDel,
- ScreenPtr pScreen);
+RESTYPE CompositeClientOverlayType;
typedef struct _CompositeClient {
int major_version;
@@ -107,19 +104,8 @@ static int
FreeCompositeClientOverlay (pointer value, XID ccwid)
{
CompOverlayClientPtr pOc = (CompOverlayClientPtr) value;
- ScreenPtr pScreen = pOc->pScreen;
- CompScreenPtr cs;
-
- deleteCompOverlayClient(pOc, pScreen);
-
- /* Unmap overlay window when there are no more clients using it */
- cs = GetCompScreen(pScreen);
- if (cs->pOverlayClients == NULL) {
- if (cs->pOverlayWin != NULL) {
- UnmapWindow(cs->pOverlayWin, FALSE);
- }
- }
+ compFreeOverlayClient (pOc);
return Success;
}
@@ -304,137 +290,6 @@ ProcCompositeNameWindowPixmap (ClientPtr client)
}
-/*
- * Routines for manipulating the per-screen overlay clients list.
- * This list indicates which clients have called GetOverlayWindow
- * for this screen.
- */
-
-/* Return the screen's overlay client list element for the given client */
-static CompOverlayClientPtr
-findCompOverlayClient (ClientPtr pClient, ScreenPtr pScreen)
-{
- CompScreenPtr cs = GetCompScreen(pScreen);
- CompOverlayClientPtr pOc;
-
- for (pOc = cs->pOverlayClients; pOc != NULL; pOc = pOc->pNext) {
- if (pOc->pClient == pClient) {
- return pOc;
- }
- }
-
- return NULL;
-}
-
-static int
-createCompOverlayClient (ClientPtr pClient, ScreenPtr pScreen)
-{
- CompScreenPtr cs = GetCompScreen(pScreen);
- CompOverlayClientPtr pOc;
-
- pOc = (CompOverlayClientPtr) xalloc(sizeof(CompOverlayClientRec));
- if (pOc == NULL) {
- return BadAlloc;
- }
- pOc->pClient = pClient;
- pOc->pScreen = pScreen;
- pOc->resource = FakeClientID(pClient->index);
- pOc->pNext = cs->pOverlayClients;
- cs->pOverlayClients = pOc;
-
- /*
- * Create a resource for this element so it can be deleted
- * when the client goes away.
- */
- if (!AddResource (pOc->resource, CompositeClientOverlayType,
- (pointer) pOc)) {
- xfree(pOc);
- return BadAlloc;
- }
-
- return Success;
-}
-
-/*
- * Delete the given overlay client list element from its screen list.
- */
-static void
-deleteCompOverlayClient (CompOverlayClientPtr pOcToDel, ScreenPtr pScreen)
-{
- CompScreenPtr cs = GetCompScreen(pScreen);
- CompOverlayClientPtr pOc, pNext;
- CompOverlayClientPtr pOcLast = NULL;
-
- pOc = cs->pOverlayClients;
- while (pOc != NULL) {
- pNext = pOc->pNext;
- if (pOc == pOcToDel) {
- xfree(pOc);
- if (pOcLast == NULL) {
- cs->pOverlayClients = pNext;
- } else {
- pOcLast->pNext = pNext;
- }
- break;
- }
- pOcLast = pOc;
- pOc = pNext;
- }
-}
-
-/*
- * Delete all the hide-counts list elements for this screen.
- */
-void
-deleteCompOverlayClientsForScreen (ScreenPtr pScreen)
-{
- CompScreenPtr cs = GetCompScreen(pScreen);
- CompOverlayClientPtr pOc, pTmp;
-
- pOc = cs->pOverlayClients;
- while (pOc != NULL) {
- pTmp = pOc->pNext;
- FreeResource(pOc->resource, 0);
- pOc = pTmp;
- }
- cs->pOverlayClients = NULL;
-}
-
-/*
-** If necessary, create the overlay window. And map it
-** Note: I found it excessively difficult to destroy this window
-** during compCloseScreen; DeleteWindow can't be called because
-** the input devices are already shut down. So we are going to
-** just allocate an overlay window once per screen per X server
-** invocation.
-*/
-
-static WindowPtr
-createOverlayWindow (ScreenPtr pScreen)
-{
- int wid = FakeClientID(0);
- WindowPtr pWin;
- XID overrideRedirect = TRUE;
- int result;
-
- pWin = CreateWindow (
- wid, WindowTable[pScreen->myNum],
- 0, 0, pScreen->width, pScreen->height, 0,
- InputOutput, CWOverrideRedirect, &overrideRedirect,
- WindowTable[pScreen->myNum]->drawable.depth,
- serverClient, pScreen->rootVisual, &result);
- if (pWin == NULL) {
- return NULL;
- }
-
- if (!AddResource(wid, RT_WINDOW, (pointer)pWin)) {
- DeleteWindow(pWin, None);
- return NULL;
- }
-
- return pWin;
-}
-
static int
ProcCompositeGetOverlayWindow (ClientPtr client)
{
@@ -456,28 +311,31 @@ ProcCompositeGetOverlayWindow (ClientPtr client)
}
pScreen = pWin->drawable.pScreen;
+ /*
+ * Create an OverlayClient structure to mark this client's
+ * interest in the overlay window
+ */
+ pOc = compCreateOverlayClient(pScreen, client);
+ if (pOc == NULL)
+ return BadAlloc;
+
+ /*
+ * Make sure the overlay window exists
+ */
cs = GetCompScreen(pScreen);
- if (cs->pOverlayWin == NULL) {
- cs->pOverlayWin = createOverlayWindow(pScreen);
- if (cs->pOverlayWin == NULL) {
+ if (cs->pOverlayWin == NULL)
+ if (!compCreateOverlayWindow(pScreen))
+ {
+ FreeResource (pOc->resource, RT_NONE);
return BadAlloc;
}
- }
rc = XaceHook(XACE_RESOURCE_ACCESS, client, cs->pOverlayWin->drawable.id,
RT_WINDOW, cs->pOverlayWin, RT_NONE, NULL, DixGetAttrAccess);
if (rc != Success)
+ {
+ FreeResource (pOc->resource, RT_NONE);
return rc;
-
- MapWindow(cs->pOverlayWin, serverClient);
-
- /* Record that client is using this overlay window */
- pOc = findCompOverlayClient(client, pScreen);
- if (pOc == NULL) {
- int ret = createCompOverlayClient(client, pScreen);
- if (ret != Success) {
- return ret;
- }
}
rep.type = X_Reply;
@@ -504,7 +362,6 @@ ProcCompositeReleaseOverlayWindow (ClientPtr client)
WindowPtr pWin;
ScreenPtr pScreen;
CompOverlayClientPtr pOc;
- CompScreenPtr cs;
REQUEST_SIZE_MATCH(xCompositeReleaseOverlayWindowReq);
pWin = (WindowPtr) LookupIDByType (stuff->window, RT_WINDOW);
@@ -519,18 +376,12 @@ ProcCompositeReleaseOverlayWindow (ClientPtr client)
* Has client queried a reference to the overlay window
* on this screen? If not, generate an error.
*/
- pOc = findCompOverlayClient(client, pWin->drawable.pScreen);
- if (pOc == NULL) {
+ pOc = compFindOverlayClient (pWin->drawable.pScreen, client);
+ if (pOc == NULL)
return BadMatch;
- }
/* The delete function will free the client structure */
- FreeResource (pOc->resource, 0);
-
- cs = GetCompScreen(pScreen);
- if (cs->pOverlayClients == NULL) {
- UnmapWindow(cs->pOverlayWin, FALSE);
- }
+ FreeResource (pOc->resource, RT_NONE);
return client->noClientException;
}
diff --git a/composite/compinit.c b/composite/compinit.c
index 49b2044b0..7914a8d25 100644
--- a/composite/compinit.c
+++ b/composite/compinit.c
@@ -76,14 +76,6 @@ compCloseScreen (int index, ScreenPtr pScreen)
pScreen->CopyWindow = cs->CopyWindow;
pScreen->PositionWindow = cs->PositionWindow;
- deleteCompOverlayClientsForScreen(pScreen);
-
- /*
- ** Note: no need to call DeleteWindow; the server has
- ** already destroyed it.
- */
- cs->pOverlayWin = NULL;
-
xfree (cs);
dixSetPrivate(&pScreen->devPrivates, CompScreenPrivateKey, NULL);
ret = (*pScreen->CloseScreen) (index, pScreen);
@@ -122,11 +114,11 @@ compChangeWindowAttributes(WindowPtr pWin, unsigned long mask)
if (ret && (mask & CWBackingStore)) {
if (pWin->backingStore != NotUseful) {
compRedirectWindow(serverClient, pWin, CompositeRedirectAutomatic);
- pWin->backStorage = TRUE;
+ pWin->backStorage = (pointer) (intptr_t) 1;
} else {
compUnredirectWindow(serverClient, pWin,
CompositeRedirectAutomatic);
- pWin->backStorage = FALSE;
+ pWin->backStorage = NULL;
}
}
@@ -380,6 +372,7 @@ compScreenInit (ScreenPtr pScreen)
return FALSE;
cs->damaged = FALSE;
+ cs->overlayWid = FakeClientID(0);
cs->pOverlayWin = NULL;
cs->pOverlayClients = NULL;
diff --git a/composite/compint.h b/composite/compint.h
index 4b0fe0834..1c19ccd39 100644
--- a/composite/compint.h
+++ b/composite/compint.h
@@ -155,6 +155,7 @@ typedef struct _CompScreen {
VisualID *alternateVisuals;
WindowPtr pOverlayWin;
+ Window overlayWid;
CompOverlayClientPtr pOverlayClients;
} CompScreenRec, *CompScreenPtr;
@@ -172,6 +173,7 @@ extern DevPrivateKey CompSubwindowsPrivateKey;
extern RESTYPE CompositeClientWindowType;
extern RESTYPE CompositeClientSubwindowsType;
+extern RESTYPE CompositeClientOverlayType;
/*
* compalloc.c
@@ -230,6 +232,25 @@ Bool
compScreenInit (ScreenPtr pScreen);
/*
+ * compoverlay.c
+ */
+
+void
+compFreeOverlayClient (CompOverlayClientPtr pOcToDel);
+
+CompOverlayClientPtr
+compFindOverlayClient (ScreenPtr pScreen, ClientPtr pClient);
+
+CompOverlayClientPtr
+compCreateOverlayClient (ScreenPtr pScreen, ClientPtr pClient);
+
+Bool
+compCreateOverlayWindow (ScreenPtr pScreen);
+
+void
+compDestroyOverlayWindow (ScreenPtr pScreen);
+
+/*
* compwindow.c
*/
@@ -292,9 +313,6 @@ compCopyWindow (WindowPtr pWin, DDXPointRec ptOldOrg, RegionPtr prgnSrc);
void
compWindowUpdate (WindowPtr pWin);
-void
-deleteCompOverlayClientsForScreen (ScreenPtr pScreen);
-
WindowPtr
CompositeRealChildHead (WindowPtr pWin);
diff --git a/composite/compoverlay.c b/composite/compoverlay.c
new file mode 100644
index 000000000..94e5b0346
--- /dev/null
+++ b/composite/compoverlay.c
@@ -0,0 +1,159 @@
+/*
+ * Copyright © 2006 Sun Microsystems
+ *
+ * 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 Sun Microsystems not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Sun Microsystems makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * SUN MICROSYSTEMS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL SUN MICROSYSTEMS 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.
+ *
+ * Copyright © 2003 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 Keith Packard not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Keith Packard makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL KEITH PACKARD 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_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include "compint.h"
+#include "xace.h"
+
+/*
+ * Delete the given overlay client list element from its screen list.
+ */
+void
+compFreeOverlayClient (CompOverlayClientPtr pOcToDel)
+{
+ ScreenPtr pScreen = pOcToDel->pScreen;
+ CompScreenPtr cs = GetCompScreen (pScreen);
+ CompOverlayClientPtr *pPrev, pOc;
+
+ for (pPrev = &cs->pOverlayClients; (pOc = *pPrev); pPrev = &pOc->pNext)
+ {
+ if (pOc == pOcToDel) {
+ *pPrev = pOc->pNext;
+ xfree (pOc);
+ break;
+ }
+ }
+
+ /* Destroy overlay window when there are no more clients using it */
+ if (cs->pOverlayClients == NULL)
+ compDestroyOverlayWindow (pScreen);
+}
+
+/*
+ * Return the client's first overlay client rec from the given screen
+ */
+CompOverlayClientPtr
+compFindOverlayClient (ScreenPtr pScreen, ClientPtr pClient)
+{
+ CompScreenPtr cs = GetCompScreen(pScreen);
+ CompOverlayClientPtr pOc;
+
+ for (pOc = cs->pOverlayClients; pOc != NULL; pOc = pOc->pNext)
+ if (pOc->pClient == pClient)
+ return pOc;
+
+ return NULL;
+}
+
+/*
+ * Create an overlay client object for the given client
+ */
+CompOverlayClientPtr
+compCreateOverlayClient (ScreenPtr pScreen, ClientPtr pClient)
+{
+ CompScreenPtr cs = GetCompScreen(pScreen);
+ CompOverlayClientPtr pOc;
+
+ pOc = (CompOverlayClientPtr) xalloc(sizeof(CompOverlayClientRec));
+ if (pOc == NULL)
+ return NULL;
+
+ pOc->pClient = pClient;
+ pOc->pScreen = pScreen;
+ pOc->resource = FakeClientID(pClient->index);
+ pOc->pNext = cs->pOverlayClients;
+ cs->pOverlayClients = pOc;
+
+ /*
+ * Create a resource for this element so it can be deleted
+ * when the client goes away.
+ */
+ if (!AddResource (pOc->resource, CompositeClientOverlayType, (pointer) pOc))
+ return NULL;
+
+ return pOc;
+}
+
+/*
+ * Create the overlay window and map it
+ */
+Bool
+compCreateOverlayWindow (ScreenPtr pScreen)
+{
+ CompScreenPtr cs = GetCompScreen(pScreen);
+ WindowPtr pRoot = WindowTable[pScreen->myNum];
+ WindowPtr pWin;
+ XID overrideRedirect = TRUE;
+ int result;
+
+ pWin = cs->pOverlayWin =
+ CreateWindow (cs->overlayWid, pRoot,
+ 0, 0, pScreen->width, pScreen->height, 0,
+ InputOutput, CWOverrideRedirect, &overrideRedirect,
+ pRoot->drawable.depth,
+ serverClient, pScreen->rootVisual, &result);
+ if (pWin == NULL)
+ return FALSE;
+
+ if (!AddResource(pWin->drawable.id, RT_WINDOW, (pointer)pWin))
+ return FALSE;
+
+ MapWindow(pWin, serverClient);
+
+ return TRUE;
+}
+
+/*
+ * Destroy the overlay window
+ */
+void
+compDestroyOverlayWindow (ScreenPtr pScreen)
+{
+ CompScreenPtr cs = GetCompScreen(pScreen);
+
+ cs->pOverlayWin = NullWindow;
+ FreeResource (cs->overlayWid, RT_NONE);
+}
+
diff --git a/configure.ac b/configure.ac
index 07a334cfc..8abebfe99 100644
--- a/configure.ac
+++ b/configure.ac
@@ -177,7 +177,7 @@ AC_CHECK_FUNC([dlopen], [],
AC_CHECK_LIB([dl], [dlopen], DLOPEN_LIBS="-ldl"))
case $host_os in
- linux*)
+ linux*|darwin*)
AC_DEFINE(HAVE_URANDOM, 1, [Has /dev/urandom]) ;;
solaris*)
# Solaris 8 with patches, or Solaris 9 or later have /dev/urandom
@@ -379,7 +379,7 @@ case $host_os in
AC_DEFINE(PCVT_SUPPORT, 1, [System has PCVT console])
AC_DEFINE(SYSCONS_SUPPORT, 1, [System has syscons console])
DRI=yes
- DRI2=yes
+ PKG_CHECK_EXISTS([dri2proto >= 1.1 libdrm >= 2.3.1], DRI2=yes, DRI2=no)
;;
*netbsd*)
AC_DEFINE(CSRG_BASED, 1, [System is BSD-like])
@@ -387,7 +387,7 @@ case $host_os in
AC_DEFINE(PCVT_SUPPORT, 1, [System has PCVT console])
AC_DEFINE(WSCONS_SUPPORT, 1, [System has wscons console])
DRI=yes
- DRI2=yes
+ PKG_CHECK_EXISTS([dri2proto >= 1.1 libdrm >= 2.3.1], DRI2=yes, DRI2=no)
;;
*openbsd*)
AC_DEFINE(CSRG_BASED, 1, [System is BSD-like])
@@ -396,7 +396,7 @@ case $host_os in
;;
*linux*)
DRI=yes
- DRI2=yes
+ PKG_CHECK_EXISTS([dri2proto >= 1.1 libdrm >= 2.3.1], DRI2=yes, DRI2=no)
KDRIVE_HW=yes
;;
*solaris*)
@@ -528,7 +528,7 @@ AC_ARG_ENABLE(composite, AS_HELP_STRING([--disable-composite], [Build Compo
AC_ARG_ENABLE(mitshm, AS_HELP_STRING([--disable-shm], [Build SHM extension (default: enabled)]), [MITSHM=$enableval], [MITSHM=yes])
AC_ARG_ENABLE(xres, AS_HELP_STRING([--disable-xres], [Build XRes extension (default: enabled)]), [RES=$enableval], [RES=yes])
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: disabled)]), [RECORD=$enableval], [RECORD=no])
+AC_ARG_ENABLE(record, AS_HELP_STRING([--enable-record], [Build Record extension (default: disabled)]), [RECORD=$enableval], [RECORD=no])
AC_ARG_ENABLE(xv, AS_HELP_STRING([--disable-xv], [Build Xv extension (default: enabled)]), [XV=$enableval], [XV=yes])
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])
@@ -544,12 +544,9 @@ AC_ARG_ENABLE(xf86misc, AS_HELP_STRING([--disable-xf86misc], [Build XF86Mi
AC_ARG_ENABLE(xace, AS_HELP_STRING([--disable-xace], [Build X-ACE extension (default: enabled)]), [XACE=$enableval], [XACE=yes])
AC_ARG_ENABLE(xselinux, AS_HELP_STRING([--disable-xselinux], [Build SELinux extension (default: disabled)]), [XSELINUX=$enableval], [XSELINUX=no])
AC_ARG_ENABLE(xcsecurity, AS_HELP_STRING([--disable-xcsecurity], [Build Security extension (default: disabled)]), [XCSECURITY=$enableval], [XCSECURITY=no])
-AC_ARG_ENABLE(appgroup, AS_HELP_STRING([--disable-appgroup], [Build XC-APPGROUP extension (default: disabled)]), [APPGROUP=$enableval], [APPGROUP=$XCSECURITY])
AC_ARG_ENABLE(xcalibrate, AS_HELP_STRING([--enable-xcalibrate], [Build XCalibrate extension (default: disabled)]), [XCALIBRATE=$enableval], [XCALIBRATE=no])
AC_ARG_ENABLE(tslib, AS_HELP_STRING([--enable-tslib], [Build kdrive tslib touchscreen support (default: disabled)]), [TSLIB=$enableval], [TSLIB=no])
AC_ARG_ENABLE(xevie, AS_HELP_STRING([--disable-xevie], [Build XEvIE extension (default: enabled)]), [XEVIE=$enableval], [XEVIE=yes])
-AC_ARG_ENABLE(cup, AS_HELP_STRING([--disable-cup], [Build TOG-CUP extension (default: enabled)]), [CUP=$enableval], [CUP=yes])
-AC_ARG_ENABLE(evi, AS_HELP_STRING([--disable-evi], [Build Extended-Visual-Information extension (default: enabled)]), [EVI=$enableval], [EVI=yes])
AC_ARG_ENABLE(multibuffer, AS_HELP_STRING([--enable-multibuffer], [Build Multibuffer extension (default: disabled)]), [MULTIBUFFER=$enableval], [MULTIBUFFER=no])
AC_ARG_ENABLE(fontcache, AS_HELP_STRING([--enable-fontcache], [Build FontCache extension (default: disabled)]), [FONTCACHE=$enableval], [FONTCACHE=no])
AC_ARG_ENABLE(dbe, AS_HELP_STRING([--disable-dbe], [Build DBE extension (default: enabled)]), [DBE=$enableval], [DBE=yes])
@@ -647,6 +644,40 @@ XORG_CHECK_LINUXDOC
dnl Handle installing libxf86config
AM_CONDITIONAL(INSTALL_LIBXF86CONFIG, [test "x$INSTALL_LIBXF86CONFIG" = xyes])
+dnl XQuartz DDX Detection... Yes, it's ugly to have it here... but we need to handle this early on
+case $host_os in
+ darwin*)
+ if test x$XQUARTZ = xauto; then
+ AC_CACHE_CHECK([whether to build Xquartz],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
+ XQUARTZ=yes
+ else
+ XQUARTZ=no
+ fi
+ fi
+
+ if test "x$XQUARTZ" = xyes ; then
+ XQUARTZ=yes
+ XVFB=no
+ XNEST=no
+
+ COMPOSITE=no
+ DGA=no
+ DPMSExtension=no
+ XF86BIGFONT=no
+ XF86MISC=no
+ XF86VIDMODE=no
+ fi
+ ;;
+esac
+
dnl ---------------------------------------------------------------------------
dnl Extension section
dnl ---------------------------------------------------------------------------
@@ -827,7 +858,7 @@ if test "x$GLX" = xyes && ! test "x$MESA_SOURCE" = x; then
PKG_CHECK_MODULES([GL], [glproto >= 1.4.9])
AC_SUBST(XLIB_CFLAGS)
AC_DEFINE(GLXEXT, 1, [Build GLX extension])
- GLX_LIBS='$(top_builddir)/GL/glx/libglx.la $(top_builddir)/GL/mesa/libGLcore.la'
+ GLX_LIBS='$(top_builddir)/GL/glx/libglx.la'
test -d GL || mkdir GL
case $host_os in
solaris*)
@@ -838,6 +869,7 @@ if test "x$GLX" = xyes && ! test "x$MESA_SOURCE" = x; then
if test $? -ne 0; then
AC_MSG_ERROR([Failed to link Mesa source tree. Please specify a proper path to Mesa sources, or disable GLX.])
fi
+ GLX_SYS_LIBS="$GLX_SYS_LIBS $DLOPEN_LIBS"
else
GLX=no
fi
@@ -919,26 +951,6 @@ if test "x$XEVIE" = xyes; then
REQUIRED_MODULES="$REQUIRED_MODULES evieproto"
fi
-AM_CONDITIONAL(APPGROUP, [test "x$APPGROUP" = xyes])
-if test "x$APPGROUP" = xyes; then
- if test "x$XACE" != xyes || test "x$XCSECURITY" != xyes; then
- AC_MSG_ERROR([cannot build APPGROUP extension without X-ACE and XC-SECURITY])
- fi
- AC_DEFINE(XAPPGROUP, 1, [Build APPGROUP extension])
-fi
-
-AM_CONDITIONAL(CUP, [test "x$CUP" = xyes])
-if test "x$CUP" = xyes; then
- AC_DEFINE(TOGCUP, 1, [Build TOG-CUP extension])
- # Requires xextproto which is always required
-fi
-
-AM_CONDITIONAL(EVI, [test "x$EVI" = xyes])
-if test "x$EVI" = xyes; then
- AC_DEFINE(EVI, 1, [Build Extended-Visual-Information extension])
- # Requires xextproto which is always required
-fi
-
AM_CONDITIONAL(MULTIBUFFER, [test "x$MULTIBUFFER" = xyes])
if test "x$MULTIBUFFER" = xyes; then
AC_DEFINE(MULTIBUFFER, 1, [Build Multibuffer extension])
@@ -1101,7 +1113,6 @@ if test "x$DEBUGGING" = xyes; then
fi
AM_CONDITIONAL(DEBUG, [test "x$DEBUGGING" = xyes])
-AC_DEFINE(MITMISC, 1, [Support MIT Misc extension])
AC_DEFINE(XTEST, 1, [Support XTest extension])
AC_DEFINE(XSYNC, 1, [Support XSync extension])
AC_DEFINE(XCMISC, 1, [Support XCMisc extension])
@@ -1129,7 +1140,9 @@ PKG_CHECK_MODULES([XSERVERLIBS], [$REQUIRED_LIBS])
# OpenSSL used for SHA1 hashing in render/glyph.c, but we don't need all of
# the OpenSSL libraries, just libcrypto
-PKG_CHECK_MODULES([OPENSSL], [openssl], [OPENSSL_LIB_FLAGS=`$PKG_CONFIG --libs-only-L --libs-only-other openssl`])
+PKG_CHECK_EXISTS([openssl],
+ [PKG_CHECK_MODULES([OPENSSL], [openssl],
+ [OPENSSL_LIB_FLAGS=`$PKG_CONFIG --libs-only-L --libs-only-other openssl`])])
LIBCRYPTO="$OPENSSL_LIB_FLAGS -lcrypto"
# Autotools has some unfortunate issues with library handling. In order to
@@ -1596,7 +1609,7 @@ AC_MSG_RESULT([$XPRINT])
if test "x$XPRINT" = xyes; then
PKG_CHECK_MODULES([XPRINTMODULES], [printproto x11 xfont $XDMCP_MODULES xau])
- XPRINT_CFLAGS="$XPRINTMODULES_CFLAGS"
+ XPRINT_CFLAGS="$XPRINTMODULES_CFLAGS -DXPRINT"
XPRINT_LIBS="$XEXT_LIB $CONFIG_LIB $DBE_LIB $XTRAP_LIB $RECORD_LIB $RENDER_LIB $COMPOSITE_LIB $RANDR_LIB $XI_LIB $FIXES_LIB $DAMAGE_LIB $XI_LIB $GLX_LIBS $MIEXT_DAMAGE_LIB $XKB_LIB $XKB_STUB_LIB"
XPRINT_SYS_LIBS="$XPRINTMODULES_LIBS"
@@ -1715,58 +1728,17 @@ 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
-if test "X$XQUARTZ" = Xauto; then
- AC_CACHE_CHECK([whether to build Xquartz],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
- XQUARTZ=yes
- else
- XQUARTZ=no
- fi
-fi
-
if test "x$XQUARTZ" = xyes; then
AC_DEFINE(XQUARTZ,1,[Have Quartz])
AC_DEFINE(ROOTLESS,1,[Build Rootless code])
-#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_GLX_LIBS='$(top_builddir)/GL/apple/indirect.o $(top_builddir)/GL/glx/libglx.la'
- DARWIN_LIBS="$MI_LIB $OS_LIB $DIX_LIB $FB_LIB $FIXES_LIB $XEXT_LIB $CONFIG_LIB $DBE_LIB $XTRAP_LIB $RECORD_LIB $RENDER_LIB $RANDR_LIB $DAMAGE_LIB $MIEXT_DAMAGE_LIB $MIEXT_SHADOW_LIB $XI_LIB $XKB_LIB $XKB_STUB_LIB $COMPOSITE_LIB $XPSTUBS_LIB"
+ DARWIN_GLX_LIBS='$(top_builddir)/hw/xquartz/GL/libCGLCore.la $(top_builddir)/GL/glx/libglx.la'
+ DARWIN_LIBS="$MI_LIB $OS_LIB $DIX_LIB $FB_LIB $FIXES_LIB $XEXT_LIB $CONFIG_LIB $DBE_LIB $XTRAP_LIB $RECORD_LIB $RENDER_LIB $RANDR_LIB $DAMAGE_LIB $MIEXT_DAMAGE_LIB $MIEXT_SHADOW_LIB $XI_LIB $XKB_LIB $XKB_STUB_LIB $XPSTUBS_LIB $DARWIN_GLX_LIBS"
AC_SUBST([DARWIN_LIBS])
+
AC_CHECK_LIB([Xplugin],[xp_init],[:])
+
CFLAGS="${CFLAGS} -DROOTLESS_WORKAROUND -DNO_ALLOCA"
- 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$XF86BIGFONT" = xyes || test "x$XF86BIGFONT" = xauto; then
- AC_MSG_NOTICE([Disabling XF86BigFont extension])
- XF86BIGFONT=no
- fi
- if test "x$DGA" = xyes || test "x$DGA" = xauto; then
- AC_MSG_NOTICE([Disabling DGA extension])
- DGA=no
- fi
fi
# Support for objc in autotools is minimal and not documented.
@@ -1928,26 +1900,21 @@ if test "$KDRIVE" = yes; then
if test "x$XV" = xyes; then
XEPHYR_REQUIRED_LIBS="$XEPHYR_REQUIRED_LIBS xv"
fi
+ if test "x$DRI" = xyes && test "x$GLX" = xyes; then
+ XEPHYR_REQUIRED_LIBS="$XEPHYR_REQUIRED_LIBS gl libdrm"
+ fi
+
PKG_CHECK_MODULES(XEPHYR, $XEPHYR_REQUIRED_LIBS, [xephyr="yes"], [xephyr="no"])
if test "x$XEPHYR" = xauto; then
XEPHYR=$xephyr
fi
- XEPHYR_DRI=no
- if test x$XEPHYR = xyes -a x$DRI = xyes && test "x$GLX" = xyes; then
- XEPHYR_DRI=yes
- XEPHYR_DRI_LIBS=-lGL
- AC_SUBST(XEPHYR_DRI_LIBS)
- fi
- if test x$XEPHYR_DRI = xyes ; then
- AC_DEFINE(XEPHYR_DRI,1,[enable DRI extension in xephyr])
- fi
# Xephyr needs nanosleep() which is in librt on Solaris
AC_CHECK_FUNC([nanosleep], [],
AC_CHECK_LIB([rt], [nanosleep], XEPHYR_LIBS="$XEPHYR_LIBS -lrt"))
if test "x$TSLIB" = xyes; then
- PKG_CHECK_MODULES([TSLIB], [tslib-0.0], [HAVE_TSLIB="yes"], [HAVE_TSLIB="no"])
+ PKG_CHECK_MODULES([TSLIB], [tslib-1.0], [HAVE_TSLIB="yes"], [HAVE_TSLIB="no"])
if test "x$HAVE_TSLIB" = xno; then
AC_MSG_ERROR([tslib must be installed to build the tslib driver. See http://tslib.berlios.de/])
fi
@@ -1971,13 +1938,10 @@ if test "$KDRIVE" = yes; then
;;
esac
KDRIVE_STUB_LIB='$(top_builddir)/hw/kdrive/src/libkdrivestubs.a'
- KDRIVE_LOCAL_LIBS="$TSLIB_LIBS $DIX_LIB $KDRIVE_LIB $KDRIVE_STUB_LIB $CONFIG_LIB"
+ KDRIVE_LOCAL_LIBS="$DIX_LIB $KDRIVE_LIB $KDRIVE_STUB_LIB $CONFIG_LIB"
KDRIVE_LOCAL_LIBS="$KDRIVE_LOCAL_LIBS $FB_LIB $MI_LIB $KDRIVE_PURE_LIBS"
KDRIVE_LOCAL_LIBS="$KDRIVE_LOCAL_LIBS $KDRIVE_OS_LIB $OS_LIB $XEXT_LIB"
- KDRIVE_LIBS="$KDRIVE_LOCAL_LIBS $XSERVER_SYS_LIBS"
-
- # check if we can build Xephyr
- PKG_CHECK_MODULES(XEPHYR, $XEPHYR_REQUIRED_LIBS, [xephyr="yes"], [xephyr="no"])
+ KDRIVE_LIBS="$TSLIB_LIBS $KDRIVE_LOCAL_LIBS $XSERVER_SYS_LIBS $GLX_SYS_LIBS"
AC_SUBST([XEPHYR_LIBS])
AC_SUBST([XEPHYR_INCS])
@@ -1998,7 +1962,6 @@ AM_CONDITIONAL(KDRIVEFBDEV, [test "x$XFBDEV" = xyes])
AM_CONDITIONAL(XSDLSERVER, [test x"$XSDL" = xyes])
AM_CONDITIONAL(XEPHYR, [test "x$KDRIVE" = xyes && test "x$XEPHYR" = xyes])
AM_CONDITIONAL(BUILD_KDRIVEFBDEVLIB, [test "x$KDRIVE" = xyes && test "x$KDRIVEFBDEVLIB" = xyes])
-AM_CONDITIONAL(XEPHYR_HAS_DRI, [test x$XEPHYR_DRI = xyes])
AM_CONDITIONAL(XFAKESERVER, [test "x$KDRIVE" = xyes && test "x$XFAKE" = xyes])
dnl these only go in xkb-config.h (which is shared by the Xorg and Xnest servers)
@@ -2107,20 +2070,7 @@ XORG_MANPAGE_SECTIONS
AC_OUTPUT([
Makefile
GL/Makefile
-GL/apple/Makefile
GL/glx/Makefile
-GL/mesa/Makefile
-GL/mesa/glapi/Makefile
-GL/mesa/main/Makefile
-GL/mesa/math/Makefile
-GL/mesa/shader/Makefile
-GL/mesa/shader/grammar/Makefile
-GL/mesa/shader/slang/Makefile
-GL/mesa/swrast/Makefile
-GL/mesa/swrast_setup/Makefile
-GL/mesa/tnl/Makefile
-GL/mesa/vbo/Makefile
-GL/mesa/X/Makefile
include/Makefile
afb/Makefile
composite/Makefile
@@ -2139,7 +2089,6 @@ miext/damage/Makefile
miext/shadow/Makefile
miext/cw/Makefile
miext/rootless/Makefile
-miext/rootless/accel/Makefile
os/Makefile
randr/Makefile
render/Makefile
@@ -2214,6 +2163,7 @@ hw/xgl/glxext/module/Makefile
hw/xnest/Makefile
hw/xwin/Makefile
hw/xquartz/Makefile
+hw/xquartz/GL/Makefile
hw/xquartz/bundle/Makefile
hw/xquartz/xpr/Makefile
hw/kdrive/Makefile
diff --git a/dix/Makefile.am b/dix/Makefile.am
index b7b1ec071..e44b51081 100644
--- a/dix/Makefile.am
+++ b/dix/Makefile.am
@@ -1,4 +1,10 @@
-noinst_LTLIBRARIES = libdix.la libxpstubs.la
+standard_dix_libs = libdix.la libxpstubs.la
+
+if XPRINT
+noinst_LTLIBRARIES = $(standard_dix_libs) libXpdix.la
+else
+noinst_LTLIBRARIES = $(standard_dix_libs)
+endif
AM_CFLAGS = $(DIX_CFLAGS) \
-DVENDOR_NAME=\""@VENDOR_NAME@"\" \
@@ -39,7 +45,11 @@ libdix_la_SOURCES = \
libxpstubs_la_SOURCES = \
xpstubs.c
-INCLUDES = -I$(top_srcdir)/Xprint
+if XPRINT
+libXpdix_la_SOURCES = $(libdix_la_SOURCES)
+libXpdix_la_CPPFLAGS = -I$(top_srcdir)/hw/xprint
+libXpdix_la_CFLAGS = $(AM_CFLAGS) $(XPRINT_CFLAGS)
+endif
EXTRA_DIST = buildatoms BuiltInAtoms CHANGES Xserver.d Xserver-dtrace.h.in
diff --git a/dix/devices.c b/dix/devices.c
index 5a726afe8..2c9a329be 100644
--- a/dix/devices.c
+++ b/dix/devices.c
@@ -524,8 +524,8 @@ CloseDevice(DeviceIntPtr dev)
#ifdef XKB
if (dev->key->xkbInfo)
XkbFreeInfo(dev->key->xkbInfo);
-#endif
dev->key->xkbInfo = NULL;
+#endif
xfree(dev->key->curKeySyms.map);
xfree(dev->key->modifierKeyMap);
xfree(dev->key);
diff --git a/dix/dispatch.c b/dix/dispatch.c
index bb8b0c416..50259537b 100644
--- a/dix/dispatch.c
+++ b/dix/dispatch.c
@@ -136,9 +136,6 @@ int ProcInitialConnection();
#endif
#include "privates.h"
#include "xace.h"
-#ifdef XAPPGROUP
-#include "appgroup.h"
-#endif
#ifdef XKB
#ifndef XKB_IN_SERVER
#define XKB_IN_SERVER
@@ -3516,9 +3513,6 @@ void InitClient(ClientPtr client, int i, pointer ospriv)
}
#endif
client->replyBytesRemaining = 0;
-#ifdef XAPPGROUP
- client->appgroup = NULL;
-#endif
client->fontResFunc = NULL;
#ifdef SMART_SCHEDULE
client->smart_priority = 0;
@@ -3643,9 +3637,6 @@ SendConnSetup(ClientPtr client, char *reason)
client->requestVector = client->swapped ? SwappedProcVector : ProcVector;
client->sequence = 0;
-#ifdef XAPPGROUP
- XagConnectionInfo (client, &lconnSetupPrefix, &lConnectionInfo, &numScreens);
-#endif
((xConnSetup *)lConnectionInfo)->ridBase = client->clientAsMask;
((xConnSetup *)lConnectionInfo)->ridMask = RESOURCE_ID_MASK;
#ifdef MATCH_CLIENT_ENDIAN
diff --git a/dix/dixutils.c b/dix/dixutils.c
index aaf510623..22935cead 100644
--- a/dix/dixutils.c
+++ b/dix/dixutils.c
@@ -270,7 +270,8 @@ dixLookupClient(ClientPtr *pClient, XID rid, ClientPtr client, Mask access)
*pClient = clients[clientIndex];
return Success;
bad:
- client->errorValue = rid;
+ if(client)
+ client->errorValue = rid;
*pClient = NULL;
return rc;
}
diff --git a/dix/getevents.c b/dix/getevents.c
index bf9331eae..0229c0ac6 100644
--- a/dix/getevents.c
+++ b/dix/getevents.c
@@ -407,8 +407,8 @@ GetKeyboardValuatorEvents(xEvent *events, DeviceIntPtr pDev, int type,
int num_valuators, int *valuators) {
int numEvents = 0;
CARD32 ms = 0;
- KeySym *map = pDev->key->curKeySyms.map;
- KeySym sym = map[key_code * pDev->key->curKeySyms.mapWidth];
+ KeySym *map;
+ KeySym sym;
deviceKeyButtonPointer *kbp = NULL;
if (!events)
@@ -419,11 +419,14 @@ GetKeyboardValuatorEvents(xEvent *events, DeviceIntPtr pDev, int type,
return 0;
if (!pDev->key || !pDev->focus || !pDev->kbdfeed ||
- (pDev->coreEvents && !inputInfo.keyboard->key))
+ (pDev->coreEvents && !(inputInfo.keyboard && inputInfo.keyboard->key)))
return 0;
if (key_code < 8 || key_code > 255)
return 0;
+
+ map = pDev->key->curKeySyms.map;
+ sym = map[key_code * pDev->key->curKeySyms.mapWidth];
if (pDev->coreEvents)
numEvents = 2;
@@ -539,6 +542,9 @@ GetPointerEvents(xEvent *events, DeviceIntPtr pDev, int type, int buttons,
if ((type == ButtonPress || type == ButtonRelease) && !pDev->button)
return 0;
+
+ if(pDev->coreEvents && !cp)
+ return 0;
/* FIXME: I guess it should, in theory, be possible to post button events
* from devices without valuators. */
diff --git a/dix/main.c b/dix/main.c
index 8f6507f5c..fbd64138e 100644
--- a/dix/main.c
+++ b/dix/main.c
@@ -113,9 +113,6 @@ Equipment Corporation.
#include "dispatch.h" /* InitProcVectors() */
#endif
-#include <pthread.h>
-pthread_key_t threadname_key=0;
-
#ifdef DPMSExtension
#define DPMS_SERVER
#include <X11/extensions/dpms.h>
@@ -240,28 +237,16 @@ static int indexForScanlinePad[ 65 ] = {
#define MIN(a,b) (((a) < (b)) ? (a) : (b))
#endif
-#ifdef __APPLE__
-void DarwinHandleGUI(int argc, char **argv, char **envp);
+#ifdef XQUARTZ
+int dix_main(int argc, char *argv[], char *envp[])
+#else
+int main(int argc, char *argv[], char *envp[])
#endif
-
-int
-main(int argc, char *argv[], char *envp[])
{
int i, j, k, error;
char *xauthfile;
HWEventQueueType alwaysCheckForInput[2];
- if(threadname_key == 0) ErrorF("pthread_key_create returned %d\n", pthread_key_create(&threadname_key, NULL));
- ErrorF("threadname_key = %d\n", threadname_key);
- if(pthread_getspecific(threadname_key) == NULL) {
- char *nameptr = malloc(32);
- sprintf(nameptr, "main thread %d", random());
- // strcpy(nameptr, "main thread");
- ErrorF("calling: pthread_setspecific(%d, %s)=%d\n", threadname_key, nameptr, pthread_setspecific(threadname_key, nameptr));
- if (pthread_getspecific(threadname_key) != NULL) ErrorF("current thread: %s\n", (char *)pthread_getspecific(threadname_key));
- } else {
- if (pthread_getspecific(threadname_key) != NULL) ErrorF("thread was already: %s\n", (char *)pthread_getspecific(threadname_key));
- }
display = "0";
InitGlobals();
@@ -270,13 +255,6 @@ main(int argc, char *argv[], char *envp[])
PrinterInitGlobals();
#endif
-#ifdef XQUARTZ
- /* Quartz support on Mac OS X requires that the Cocoa event loop be in
- * the main thread. This allows the X server main to be called again
- * from another thread. */
- DarwinHandleGUI(argc, argv, envp);
-#endif
-
CheckUserParameters(argc, argv, envp);
CheckUserAuthorization();
@@ -472,7 +450,10 @@ main(int argc, char *argv[], char *envp[])
#endif
config_fini();
+
+ memset(WindowTable, 0, MAXSCREENS * sizeof(WindowPtr));
CloseDownDevices();
+
for (i = screenInfo.numScreens - 1; i >= 0; i--)
{
FreeScratchPixmapsForScreen(i);
diff --git a/dix/window.c b/dix/window.c
index 499f58e7a..168e940b0 100644
--- a/dix/window.c
+++ b/dix/window.c
@@ -123,9 +123,6 @@ Equipment Corporation.
#include "dixevents.h"
#include "globals.h"
-#ifdef XAPPGROUP
-#include "appgroup.h"
-#endif
#include "privates.h"
#include "xace.h"
@@ -603,14 +600,6 @@ CreateWindow(Window wid, WindowPtr pParent, int x, int y, unsigned w,
if (!ancwopt)
ancwopt = FindWindowWithOptional(pParent)->optional;
if (visual == CopyFromParent) {
-#ifdef XAPPGROUP
- VisualID ag_visual;
-
- if (client->appgroup && !pParent->parent &&
- (ag_visual = XagRootVisual (client)))
- visual = ag_visual;
- else
-#endif
visual = ancwopt->visual;
}
@@ -1290,22 +1279,6 @@ ChangeWindowAttributes(WindowPtr pWin, Mask vmask, XID *vlist, ClientPtr client)
pVlist++;
if (cmap == CopyFromParent)
{
-#ifdef XAPPGROUP
- Colormap ag_colormap;
- ClientPtr win_owner;
-
- /*
- * win_owner == client for CreateWindow, other clients
- * can ChangeWindowAttributes
- */
- win_owner = clients[CLIENT_ID(pWin->drawable.id)];
-
- if ( win_owner && win_owner->appgroup &&
- !pWin->parent->parent &&
- (ag_colormap = XagDefaultColormap (win_owner)))
- cmap = ag_colormap;
- else
-#endif
if (pWin->parent &&
(!pWin->optional ||
pWin->optional->visual == wVisual (pWin->parent)))
@@ -2234,10 +2207,6 @@ ConfigureWindow(WindowPtr pWin, Mask mask, XID *vlist, ClientPtr client)
h = pWin->drawable.height,
bw = pWin->borderWidth;
int rc, action, smode = Above;
-#ifdef XAPPGROUP
- ClientPtr win_owner;
- ClientPtr ag_leader = NULL;
-#endif
xEvent event;
if ((pWin->drawable.class == InputOnly) && (mask & IllegalInputOnlyConfigureMask))
@@ -2333,17 +2302,9 @@ ConfigureWindow(WindowPtr pWin, Mask mask, XID *vlist, ClientPtr client)
else
pSib = pWin->nextSib;
-#ifdef XAPPGROUP
- win_owner = clients[CLIENT_ID(pWin->drawable.id)];
- ag_leader = XagLeader (win_owner);
-#endif
if ((!pWin->overrideRedirect) &&
(RedirectSend(pParent)
-#ifdef XAPPGROUP
- || (win_owner->appgroup && ag_leader &&
- XagIsControlledRoot (client, pParent))
-#endif
))
{
event.u.u.type = ConfigureRequest;
@@ -2368,16 +2329,6 @@ ConfigureWindow(WindowPtr pWin, Mask mask, XID *vlist, ClientPtr client)
event.u.configureRequest.height = h;
event.u.configureRequest.borderWidth = bw;
event.u.configureRequest.valueMask = mask;
-#ifdef XAPPGROUP
- /* make sure if the ag_leader maps the window it goes to the wm */
- if (ag_leader && ag_leader != client &&
- XagIsControlledRoot (client, pParent)) {
- event.u.configureRequest.parent = XagId (win_owner);
- (void) TryClientEvents (ag_leader, &event, 1,
- NoEventMask, NoEventMask, NullGrab);
- return Success;
- }
-#endif
event.u.configureRequest.parent = pParent->drawable.id;
if (MaybeDeliverEventsToClient(pParent, &event, 1,
SubstructureRedirectMask, client) == 1)
@@ -2754,31 +2705,13 @@ MapWindow(WindowPtr pWin, ClientPtr client)
{
xEvent event;
Bool anyMarked;
-#ifdef XAPPGROUP
- ClientPtr win_owner = clients[CLIENT_ID(pWin->drawable.id)];
- ClientPtr ag_leader = XagLeader (win_owner);
-#endif
if ((!pWin->overrideRedirect) &&
(RedirectSend(pParent)
-#ifdef XAPPGROUP
- || (win_owner->appgroup && ag_leader &&
- XagIsControlledRoot (client, pParent))
-#endif
))
{
event.u.u.type = MapRequest;
event.u.mapRequest.window = pWin->drawable.id;
-#ifdef XAPPGROUP
- /* make sure if the ag_leader maps the window it goes to the wm */
- if (ag_leader && ag_leader != client &&
- XagIsControlledRoot (client, pParent)) {
- event.u.mapRequest.parent = XagId (win_owner);
- (void) TryClientEvents (ag_leader, &event, 1,
- NoEventMask, NoEventMask, NullGrab);
- return Success;
- }
-#endif
event.u.mapRequest.parent = pParent->drawable.id;
if (MaybeDeliverEventsToClient(pParent, &event, 1,
diff --git a/exa/Makefile.am b/exa/Makefile.am
index e2f7ed302..2b3f1e416 100644
--- a/exa/Makefile.am
+++ b/exa/Makefile.am
@@ -18,6 +18,7 @@ libexa_la_SOURCES = \
exa.c \
exa.h \
exa_accel.c \
+ exa_glyphs.c \
exa_migration.c \
exa_offscreen.c \
exa_render.c \
diff --git a/exa/exa.c b/exa/exa.c
index baa9e9470..085233406 100644
--- a/exa/exa.c
+++ b/exa/exa.c
@@ -224,6 +224,43 @@ exaLog2(int val)
return bits - 1;
}
+static void
+exaSetAccelBlock(ExaScreenPrivPtr pExaScr, ExaPixmapPrivPtr pExaPixmap,
+ int w, int h, int bpp)
+{
+ pExaPixmap->accel_blocked = 0;
+
+ if (pExaScr->info->maxPitchPixels) {
+ int max_pitch = pExaScr->info->maxPitchPixels * (bpp + 7) / 8;
+
+ if (pExaPixmap->fb_pitch > max_pitch)
+ pExaPixmap->accel_blocked |= EXA_RANGE_PITCH;
+ }
+
+ if (pExaScr->info->maxPitchBytes &&
+ pExaPixmap->fb_pitch > pExaScr->info->maxPitchBytes)
+ pExaPixmap->accel_blocked |= EXA_RANGE_PITCH;
+
+ if (w > pExaScr->info->maxX)
+ pExaPixmap->accel_blocked |= EXA_RANGE_WIDTH;
+
+ if (h > pExaScr->info->maxY)
+ pExaPixmap->accel_blocked |= EXA_RANGE_HEIGHT;
+}
+
+static void
+exaSetFbPitch(ExaScreenPrivPtr pExaScr, ExaPixmapPrivPtr pExaPixmap,
+ int w, int h, int bpp)
+{
+ if (pExaScr->info->flags & EXA_OFFSCREEN_ALIGN_POT && w != 1)
+ pExaPixmap->fb_pitch = (1 << (exaLog2(w - 1) + 1)) * bpp / 8;
+ else
+ pExaPixmap->fb_pitch = w * bpp / 8;
+
+ pExaPixmap->fb_pitch = EXA_ALIGN(pExaPixmap->fb_pitch,
+ pExaScr->info->pixmapPitchAlign);
+}
+
/**
* exaCreatePixmap() creates a new pixmap.
*
@@ -268,12 +305,8 @@ exaCreatePixmap(ScreenPtr pScreen, int w, int h, int depth,
if (paddedWidth / 4 > 32767 || h > 32767)
return NullPixmap;
- if (pExaScr->info->flags & EXA_OFFSCREEN_ALIGN_POT && w != 1)
- pExaPixmap->fb_pitch = (1 << (exaLog2(w - 1) + 1)) * bpp / 8;
- else
- pExaPixmap->fb_pitch = w * bpp / 8;
- pExaPixmap->fb_pitch = EXA_ALIGN(pExaPixmap->fb_pitch,
- pExaScr->info->pixmapPitchAlign);
+ exaSetFbPitch(pExaScr, pExaPixmap, w, h, bpp);
+
if (paddedWidth < pExaPixmap->fb_pitch)
paddedWidth = pExaPixmap->fb_pitch;
@@ -307,12 +340,7 @@ exaCreatePixmap(ScreenPtr pScreen, int w, int h, int depth,
pExaPixmap->offscreen = FALSE;
pExaPixmap->fb_ptr = NULL;
- if (pExaScr->info->flags & EXA_OFFSCREEN_ALIGN_POT && w != 1)
- pExaPixmap->fb_pitch = (1 << (exaLog2(w - 1) + 1)) * bpp / 8;
- else
- pExaPixmap->fb_pitch = w * bpp / 8;
- pExaPixmap->fb_pitch = EXA_ALIGN(pExaPixmap->fb_pitch,
- pExaScr->info->pixmapPitchAlign);
+ exaSetFbPitch(pExaScr, pExaPixmap, w, h, bpp);
pExaPixmap->fb_size = pExaPixmap->fb_pitch * h;
if (pExaPixmap->fb_pitch > 131071) {
@@ -339,25 +367,8 @@ exaCreatePixmap(ScreenPtr pScreen, int w, int h, int depth,
REGION_NULL(pScreen, &pExaPixmap->validSys);
REGION_NULL(pScreen, &pExaPixmap->validFB);
- /* Check whether this pixmap can be used for acceleration. */
- pExaPixmap->accel_blocked = 0;
-
- if (pExaScr->info->maxPitchPixels) {
- int max_pitch = pExaScr->info->maxPitchPixels * (bpp + 7) / 8;
-
- if (pExaPixmap->fb_pitch > max_pitch)
- pExaPixmap->accel_blocked |= EXA_RANGE_PITCH;
- }
-
- if (pExaScr->info->maxPitchBytes &&
- pExaPixmap->fb_pitch > pExaScr->info->maxPitchBytes)
- pExaPixmap->accel_blocked |= EXA_RANGE_PITCH;
-
- if (w > pExaScr->info->maxX)
- pExaPixmap->accel_blocked |= EXA_RANGE_WIDTH;
-
- if (h > pExaScr->info->maxY)
- pExaPixmap->accel_blocked |= EXA_RANGE_HEIGHT;
+ exaSetAccelBlock(pExaScr, pExaPixmap,
+ w, h, bpp);
return pPixmap;
}
@@ -373,12 +384,25 @@ exaModifyPixmapHeader(PixmapPtr pPixmap, int width, int height, int depth,
if (!pPixmap)
return FALSE;
+ pExaScr = ExaGetScreenPriv(pPixmap->drawable.pScreen);
pExaPixmap = ExaGetPixmapPriv(pPixmap);
- if (pExaPixmap)
- pExaPixmap->sys_ptr = pPixData;
+ if (pExaPixmap) {
+ if (pPixData)
+ pExaPixmap->sys_ptr = pPixData;
+
+ if (devKind > 0)
+ pExaPixmap->sys_pitch = devKind;
+
+ if (width > 0 && height > 0 && bitsPerPixel > 0) {
+ exaSetFbPitch(pExaScr, pExaPixmap,
+ width, height, bitsPerPixel);
+
+ exaSetAccelBlock(pExaScr, pExaPixmap,
+ width, height, bitsPerPixel);
+ }
+ }
- pExaScr = ExaGetScreenPriv(pPixmap->drawable.pScreen);
if (pExaScr->info->ModifyPixmapHeader) {
ret = pExaScr->info->ModifyPixmapHeader(pPixmap, width, height, depth,
@@ -675,6 +699,34 @@ exaBitmapToRegion(PixmapPtr pPix)
return ret;
}
+static Bool
+exaCreateScreenResources(ScreenPtr pScreen)
+{
+ ExaScreenPriv(pScreen);
+ PixmapPtr pScreenPixmap;
+ Bool b;
+
+ pScreen->CreateScreenResources = pExaScr->SavedCreateScreenResources;
+ b = pScreen->CreateScreenResources(pScreen);
+ pScreen->CreateScreenResources = exaCreateScreenResources;
+
+ if (!b)
+ return FALSE;
+
+ pScreenPixmap = pScreen->GetScreenPixmap(pScreen);
+
+ if (pScreenPixmap) {
+ ExaPixmapPriv(pScreenPixmap);
+
+ exaSetAccelBlock(pExaScr, pExaPixmap,
+ pScreenPixmap->drawable.width,
+ pScreenPixmap->drawable.height,
+ pScreenPixmap->drawable.bitsPerPixel);
+ }
+
+ return TRUE;
+}
+
/**
* exaCloseScreen() unwraps its wrapped screen functions and tears down EXA's
* screen private, before calling down to the next CloseSccreen.
@@ -687,6 +739,8 @@ exaCloseScreen(int i, ScreenPtr pScreen)
PictureScreenPtr ps = GetPictureScreenIfSet(pScreen);
#endif
+ exaGlyphsFini(pScreen);
+
pScreen->CreateGC = pExaScr->SavedCreateGC;
pScreen->CloseScreen = pExaScr->SavedCloseScreen;
pScreen->GetImage = pExaScr->SavedGetImage;
@@ -696,11 +750,14 @@ exaCloseScreen(int i, ScreenPtr pScreen)
pScreen->CopyWindow = pExaScr->SavedCopyWindow;
pScreen->ChangeWindowAttributes = pExaScr->SavedChangeWindowAttributes;
pScreen->BitmapToRegion = pExaScr->SavedBitmapToRegion;
+ pScreen->CreateScreenResources = pExaScr->SavedCreateScreenResources;
#ifdef RENDER
if (ps) {
ps->Composite = pExaScr->SavedComposite;
+ ps->Glyphs = pExaScr->SavedGlyphs;
ps->Trapezoids = pExaScr->SavedTrapezoids;
ps->AddTraps = pExaScr->SavedAddTraps;
+ ps->Triangles = pExaScr->SavedTriangles;
}
#endif
@@ -854,11 +911,17 @@ exaDriverInit (ScreenPtr pScreen,
pExaScr->SavedBitmapToRegion = pScreen->BitmapToRegion;
pScreen->BitmapToRegion = exaBitmapToRegion;
+ pExaScr->SavedCreateScreenResources = pScreen->CreateScreenResources;
+ pScreen->CreateScreenResources = exaCreateScreenResources;
+
#ifdef RENDER
if (ps) {
pExaScr->SavedComposite = ps->Composite;
ps->Composite = exaComposite;
+ pExaScr->SavedGlyphs = ps->Glyphs;
+ ps->Glyphs = exaGlyphs;
+
pExaScr->SavedTriangles = ps->Triangles;
ps->Triangles = exaTriangles;
@@ -921,6 +984,8 @@ exaDriverInit (ScreenPtr pScreen,
}
}
+ exaGlyphsInit(pScreen);
+
LogMessage(X_INFO, "EXA(%d): Driver registered support for the following"
" operations:\n", pScreen->myNum);
assert(pScreenInfo->PrepareSolid != NULL);
diff --git a/exa/exa.h b/exa/exa.h
index 97ae6c0a5..256209418 100644
--- a/exa/exa.h
+++ b/exa/exa.h
@@ -64,6 +64,8 @@ struct _ExaOffscreenArea {
ExaOffscreenState state;
ExaOffscreenArea *next;
+
+ unsigned eviction_cost;
};
/**
diff --git a/exa/exa_accel.c b/exa/exa_accel.c
index c2bfdee6b..844683cfc 100644
--- a/exa/exa_accel.c
+++ b/exa/exa_accel.c
@@ -527,16 +527,36 @@ exaCopyNtoN (DrawablePtr pSrcDrawable,
pDstExaPixmap = ExaGetPixmapPriv (pDstPixmap);
/* Check whether the accelerator can use this pixmap.
- * FIXME: If it cannot, use temporary pixmaps so that the drawing
- * happens within limits.
+ * If the pitch of the pixmaps is out of range, there's nothing
+ * we can do but fall back to software rendering.
*/
- if (pSrcExaPixmap->accel_blocked || pDstExaPixmap->accel_blocked)
- {
+ if (pSrcExaPixmap->accel_blocked & EXA_RANGE_PITCH ||
+ pDstExaPixmap->accel_blocked & EXA_RANGE_PITCH)
goto fallback;
- } else {
- exaDoMigration (pixmaps, 2, TRUE);
+
+ /* If the width or the height of either of the pixmaps
+ * is out of range, check whether the boxes are actually out of the
+ * addressable range as well. If they aren't, we can still do
+ * the copying in hardware.
+ */
+ if (pSrcExaPixmap->accel_blocked || pDstExaPixmap->accel_blocked) {
+ int i;
+
+ for (i = 0; i < nbox; i++) {
+ /* src */
+ if ((pbox[i].x2 + dx + src_off_x) >= pExaScr->info->maxX ||
+ (pbox[i].y2 + dy + src_off_y) >= pExaScr->info->maxY)
+ goto fallback;
+
+ /* dst */
+ if ((pbox[i].x2 + dst_off_x) >= pExaScr->info->maxX ||
+ (pbox[i].y2 + dst_off_y) >= pExaScr->info->maxY)
+ goto fallback;
+ }
}
+ exaDoMigration (pixmaps, 2, TRUE);
+
/* Mixed directions must be handled specially if the card is lame */
if ((pExaScr->info->flags & EXA_TWO_BITBLT_DIRECTIONS) &&
reverse != upsidedown) {
diff --git a/exa/exa_glyphs.c b/exa/exa_glyphs.c
new file mode 100644
index 000000000..ff665d555
--- /dev/null
+++ b/exa/exa_glyphs.c
@@ -0,0 +1,897 @@
+/*
+ * Copyright © 2008 Red Hat, Inc.
+ * Partly based on code Copyright © 2000 SuSE, 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 Red Hat not be used in advertising or
+ * publicity pertaining to distribution of the software without specific,
+ * written prior permission. Red Hat makes no representations about the
+ * suitability of this software for any purpose. It is provided "as is"
+ * without express or implied warranty.
+ *
+ * Red Hat DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL Red Hat
+ * 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.
+ *
+ * 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 SuSE not be used in advertising or
+ * publicity pertaining to distribution of the software without specific,
+ * written prior permission. SuSE makes no representations about the
+ * suitability of this software for any purpose. It is provided "as is"
+ * without express or implied warranty.
+ *
+ * SuSE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL SuSE
+ * 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.
+ *
+ * Author: Owen Taylor <otaylor@fishsoup.net>
+ * Based on code by: Keith Packard
+ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <stdlib.h>
+
+#include "exa_priv.h"
+
+#include "mipict.h"
+
+#if DEBUG_GLYPH_CACHE
+#define DBG_GLYPH_CACHE(a) ErrorF a
+#else
+#define DBG_GLYPH_CACHE(a)
+#endif
+
+/* Width of the pixmaps we use for the caches; this should be less than
+ * max texture size of the driver; this may need to actually come from
+ * the driver.
+ */
+#define CACHE_PICTURE_WIDTH 1024
+
+/* Maximum number of glyphs we buffer on the stack before flushing
+ * rendering to the mask or destination surface.
+ */
+#define GLYPH_BUFFER_SIZE 256
+
+typedef struct {
+ PicturePtr source;
+ ExaCompositeRectRec rects[GLYPH_BUFFER_SIZE];
+ int count;
+} ExaGlyphBuffer, *ExaGlyphBufferPtr;
+
+typedef enum {
+ ExaGlyphSuccess, /* Glyph added to render buffer */
+ ExaGlyphFail, /* out of memory, etc */
+ ExaGlyphNeedFlush, /* would evict a glyph already in the buffer */
+} ExaGlyphCacheResult;
+
+void
+exaGlyphsInit(ScreenPtr pScreen)
+{
+ ExaScreenPriv(pScreen);
+ int i = 0;
+
+ memset(pExaScr->glyphCaches, 0, sizeof(pExaScr->glyphCaches));
+
+ pExaScr->glyphCaches[i].format = PICT_a8;
+ pExaScr->glyphCaches[i].glyphWidth = pExaScr->glyphCaches[i].glyphHeight = 16;
+ i++;
+ pExaScr->glyphCaches[i].format = PICT_a8;
+ pExaScr->glyphCaches[i].glyphWidth = pExaScr->glyphCaches[i].glyphHeight = 32;
+ i++;
+ pExaScr->glyphCaches[i].format = PICT_a8r8g8b8;
+ pExaScr->glyphCaches[i].glyphWidth = pExaScr->glyphCaches[i].glyphHeight = 16;
+ i++;
+ pExaScr->glyphCaches[i].format = PICT_a8r8g8b8;
+ pExaScr->glyphCaches[i].glyphWidth = pExaScr->glyphCaches[i].glyphHeight = 32;
+ i++;
+
+ assert(i == EXA_NUM_GLYPH_CACHES);
+
+ for (i = 0; i < EXA_NUM_GLYPH_CACHES; i++) {
+ pExaScr->glyphCaches[i].columns = CACHE_PICTURE_WIDTH / pExaScr->glyphCaches[i].glyphWidth;
+ pExaScr->glyphCaches[i].size = 256;
+ pExaScr->glyphCaches[i].hashSize = 557;
+ }
+}
+
+static void
+exaUnrealizeGlyphCaches(ScreenPtr pScreen,
+ unsigned int format)
+{
+ ExaScreenPriv(pScreen);
+ int i;
+
+ for (i = 0; i < EXA_NUM_GLYPH_CACHES; i++) {
+ ExaGlyphCachePtr cache = &pExaScr->glyphCaches[i];
+
+ if (cache->format != format)
+ continue;
+
+ if (cache->picture) {
+ FreePicture ((pointer) cache->picture, (XID) 0);
+ cache->picture = NULL;
+ }
+
+ if (cache->hashEntries) {
+ xfree(cache->hashEntries);
+ cache->hashEntries = NULL;
+ }
+
+ if (cache->glyphs) {
+ xfree(cache->glyphs);
+ cache->glyphs = NULL;
+ }
+ cache->glyphCount = 0;
+ }
+}
+
+/* All caches for a single format share a single pixmap for glyph storage,
+ * allowing mixing glyphs of different sizes without paying a penalty
+ * for switching between source pixmaps. (Note that for a size of font
+ * right at the border between two sizes, we might be switching for almost
+ * every glyph.)
+ *
+ * This function allocates the storage pixmap, and then fills in the
+ * rest of the allocated structures for all caches with the given format.
+ */
+static Bool
+exaRealizeGlyphCaches(ScreenPtr pScreen,
+ unsigned int format)
+{
+ ExaScreenPriv(pScreen);
+
+ int depth = PIXMAN_FORMAT_DEPTH(format);
+ PictFormatPtr pPictFormat;
+ PixmapPtr pPixmap;
+ PicturePtr pPicture;
+ int height;
+ int i;
+ int error;
+
+ pPictFormat = PictureMatchFormat(pScreen, depth, format);
+ if (!pPictFormat)
+ return FALSE;
+
+ /* Compute the total vertical size needed for the format */
+
+ height = 0;
+ for (i = 0; i < EXA_NUM_GLYPH_CACHES; i++) {
+ ExaGlyphCachePtr cache = &pExaScr->glyphCaches[i];
+ int rows;
+
+ if (cache->format != format)
+ continue;
+
+ cache->yOffset = height;
+
+ rows = (cache->size + cache->columns - 1) / cache->columns;
+ height += rows * cache->glyphHeight;
+ }
+
+ /* Now allocate the pixmap and picture */
+
+ pPixmap = (*pScreen->CreatePixmap) (pScreen,
+ CACHE_PICTURE_WIDTH,
+ height, depth, 0);
+ if (!pPixmap)
+ return FALSE;
+
+ pPicture = CreatePicture(0, &pPixmap->drawable, pPictFormat,
+ 0, 0, serverClient, &error);
+
+ (*pScreen->DestroyPixmap) (pPixmap); /* picture holds a refcount */
+
+ if (!pPicture)
+ return FALSE;
+
+ /* And store the picture in all the caches for the format */
+
+ for (i = 0; i < EXA_NUM_GLYPH_CACHES; i++) {
+ ExaGlyphCachePtr cache = &pExaScr->glyphCaches[i];
+ int j;
+
+ if (cache->format != format)
+ continue;
+
+ cache->picture = pPicture;
+ cache->picture->refcnt++;
+ cache->hashEntries = xalloc(sizeof(int) * cache->hashSize);
+ cache->glyphs = xalloc(sizeof(ExaCachedGlyphRec) * cache->size);
+ cache->glyphCount = 0;
+
+ if (!cache->hashEntries || !cache->glyphs)
+ goto bail;
+
+ for (j = 0; j < cache->hashSize; j++)
+ cache->hashEntries[j] = -1;
+
+ cache->evictionPosition = rand() % cache->size;
+ }
+
+ /* Each cache references the picture individually */
+ FreePicture ((pointer) pPicture, (XID) 0);
+ return TRUE;
+
+bail:
+ exaUnrealizeGlyphCaches(pScreen, format);
+ return FALSE;
+}
+
+void
+exaGlyphsFini (ScreenPtr pScreen)
+{
+ ExaScreenPriv(pScreen);
+ int i;
+
+ for (i = 0; i < EXA_NUM_GLYPH_CACHES; i++) {
+ ExaGlyphCachePtr cache = &pExaScr->glyphCaches[i];
+
+ if (cache->picture)
+ exaUnrealizeGlyphCaches(pScreen, cache->format);
+ }
+}
+
+static int
+exaGlyphCacheHashLookup(ExaGlyphCachePtr cache,
+ GlyphPtr pGlyph)
+{
+ int slot;
+
+ slot = (*(CARD32 *) pGlyph->sha1) % cache->hashSize;
+
+ while (TRUE) { /* hash table can never be full */
+ int entryPos = cache->hashEntries[slot];
+ if (entryPos == -1)
+ return -1;
+
+ if (memcmp(pGlyph->sha1, cache->glyphs[entryPos].sha1, sizeof(pGlyph->sha1)) == 0){
+ return entryPos;
+ }
+
+ slot--;
+ if (slot < 0)
+ slot = cache->hashSize - 1;
+ }
+}
+
+static void
+exaGlyphCacheHashInsert(ExaGlyphCachePtr cache,
+ GlyphPtr pGlyph,
+ int pos)
+{
+ int slot;
+
+ memcpy(cache->glyphs[pos].sha1, pGlyph->sha1, sizeof(pGlyph->sha1));
+
+ slot = (*(CARD32 *) pGlyph->sha1) % cache->hashSize;
+
+ while (TRUE) { /* hash table can never be full */
+ if (cache->hashEntries[slot] == -1) {
+ cache->hashEntries[slot] = pos;
+ return;
+ }
+
+ slot--;
+ if (slot < 0)
+ slot = cache->hashSize - 1;
+ }
+}
+
+static void
+exaGlyphCacheHashRemove(ExaGlyphCachePtr cache,
+ int pos)
+{
+ int slot;
+ int emptiedSlot = -1;
+
+ slot = (*(CARD32 *) cache->glyphs[pos].sha1) % cache->hashSize;
+
+ while (TRUE) { /* hash table can never be full */
+ int entryPos = cache->hashEntries[slot];
+
+ if (entryPos == -1)
+ return;
+
+ if (entryPos == pos) {
+ cache->hashEntries[slot] = -1;
+ emptiedSlot = slot;
+ } else if (emptiedSlot != -1) {
+ /* See if we can move this entry into the emptied slot, we can't
+ * do that if if entry would have hashed between the current position
+ * and the emptied slot. (taking wrapping into account). Bad positions
+ * are:
+ *
+ * | XXXXXXXXXX |
+ * i j
+ *
+ * |XXX XXXX|
+ * j i
+ *
+ * i - slot, j - emptiedSlot
+ *
+ * (Knuth 6.4R)
+ */
+
+ int entrySlot = (*(CARD32 *) cache->glyphs[entryPos].sha1) % cache->hashSize;
+
+ if (!((entrySlot >= slot && entrySlot < emptiedSlot) ||
+ (emptiedSlot < slot && (entrySlot < emptiedSlot || entrySlot >= slot))))
+ {
+ cache->hashEntries[emptiedSlot] = entryPos;
+ cache->hashEntries[slot] = -1;
+ emptiedSlot = slot;
+ }
+ }
+
+ slot--;
+ if (slot < 0)
+ slot = cache->hashSize - 1;
+ }
+}
+
+#define CACHE_X(pos) (((pos) % cache->columns) * cache->glyphWidth)
+#define CACHE_Y(pos) (cache->yOffset + ((pos) / cache->columns) * cache->glyphHeight)
+
+/* The most efficient thing to way to upload the glyph to the screen
+ * is to use the UploadToScreen() driver hook; this allows us to
+ * pipeline glyph uploads and to avoid creating offscreen pixmaps for
+ * glyphs that we'll never use again.
+ */
+static Bool
+exaGlyphCacheUploadGlyph(ScreenPtr pScreen,
+ ExaGlyphCachePtr cache,
+ int pos,
+ GlyphPtr pGlyph)
+{
+ ExaScreenPriv(pScreen);
+ PicturePtr pGlyphPicture = GlyphPicture(pGlyph)[pScreen->myNum];
+ PixmapPtr pGlyphPixmap = (PixmapPtr)pGlyphPicture->pDrawable;
+ ExaPixmapPriv(pGlyphPixmap);
+ PixmapPtr pCachePixmap = (PixmapPtr)cache->picture->pDrawable;
+ ExaMigrationRec pixmaps[1];
+ int cacheXoff, cacheYoff;
+
+ if (!pExaScr->info->UploadToScreen || pExaScr->swappedOut || pExaPixmap->accel_blocked)
+ return FALSE;
+
+ /* If the glyph pixmap is already uploaded, no point in doing
+ * things this way */
+ if (exaPixmapIsOffscreen(pGlyphPixmap))
+ return FALSE;
+
+ /* UploadToScreen only works if bpp match */
+ if (pGlyphPixmap->drawable.bitsPerPixel != pCachePixmap->drawable.bitsPerPixel)
+ return FALSE;
+
+ /* cache pixmap must be offscreen. */
+ pixmaps[0].as_dst = TRUE;
+ pixmaps[0].as_src = FALSE;
+ pixmaps[0].pPix = pCachePixmap;
+ pixmaps[0].pReg = NULL;
+ exaDoMigration (pixmaps, 1, TRUE);
+
+ pCachePixmap = exaGetOffscreenPixmap ((DrawablePtr)pCachePixmap, &cacheXoff, &cacheYoff);
+ if (!pCachePixmap)
+ return FALSE;
+
+ if (!pExaScr->info->UploadToScreen(pCachePixmap,
+ CACHE_X(pos) + cacheXoff,
+ CACHE_Y(pos) + cacheYoff,
+ pGlyph->info.width,
+ pGlyph->info.height,
+ (char *)pExaPixmap->sys_ptr,
+ pExaPixmap->sys_pitch))
+ return FALSE;
+
+ exaPixmapDirty (pCachePixmap,
+ CACHE_X(pos) + cacheXoff,
+ CACHE_Y(pos) + cacheYoff,
+ CACHE_X(pos) + cacheXoff + pGlyph->info.width,
+ CACHE_Y(pos) + cacheYoff + pGlyph->info.height);
+
+ return TRUE;
+}
+
+static ExaGlyphCacheResult
+exaGlyphCacheBufferGlyph(ScreenPtr pScreen,
+ ExaGlyphCachePtr cache,
+ ExaGlyphBufferPtr buffer,
+ GlyphPtr pGlyph,
+ int xGlyph,
+ int yGlyph)
+{
+ ExaCompositeRectPtr rect;
+ int pos;
+
+ if (buffer->source && buffer->source != cache->picture)
+ return ExaGlyphNeedFlush;
+
+ if (!cache->picture) {
+ if (!exaRealizeGlyphCaches(pScreen, cache->format))
+ return ExaGlyphFail;
+ }
+
+ DBG_GLYPH_CACHE(("(%d,%d,%s): buffering glyph %lx\n",
+ cache->glyphWidth, cache->glyphHeight, cache->format == PICT_a8 ? "A" : "ARGB",
+ (long)*(CARD32 *) pGlyph->sha1));
+
+ pos = exaGlyphCacheHashLookup(cache, pGlyph);
+ if (pos != -1) {
+ DBG_GLYPH_CACHE((" found existing glyph at %d\n", pos));
+ } else {
+ if (cache->glyphCount < cache->size) {
+ /* Space remaining; we fill from the start */
+ pos = cache->glyphCount;
+ cache->glyphCount++;
+ DBG_GLYPH_CACHE((" storing glyph in free space at %d\n", pos));
+
+ exaGlyphCacheHashInsert(cache, pGlyph, pos);
+
+ } else {
+ /* Need to evict an entry. We have to see if any glyphs
+ * already in the output buffer were at this position in
+ * the cache
+ */
+
+ pos = cache->evictionPosition;
+ DBG_GLYPH_CACHE((" evicting glyph at %d\n", pos));
+ if (buffer->count) {
+ int x, y;
+ int i;
+
+ x = CACHE_X(pos);
+ y = CACHE_Y(pos);
+
+ for (i = 0; i < buffer->count; i++) {
+ if (buffer->rects[i].xSrc == x && buffer->rects[i].ySrc == y) {
+ DBG_GLYPH_CACHE((" must flush buffer\n"));
+ return ExaGlyphNeedFlush;
+ }
+ }
+ }
+
+ /* OK, we're all set, swap in the new glyph */
+ exaGlyphCacheHashRemove(cache, pos);
+ exaGlyphCacheHashInsert(cache, pGlyph, pos);
+
+ /* And pick a new eviction position */
+ cache->evictionPosition = rand() % cache->size;
+ }
+
+ /* Now actually upload the glyph into the cache picture; if
+ * we can't do it with UploadToScreen (because the glyph is
+ * offscreen, etc), we fall back to CompositePicture.
+ */
+ if (!exaGlyphCacheUploadGlyph(pScreen, cache, pos, pGlyph)) {
+ CompositePicture (PictOpSrc,
+ GlyphPicture(pGlyph)[pScreen->myNum],
+ None,
+ cache->picture,
+ 0, 0,
+ 0, 0,
+ CACHE_X(pos),
+ CACHE_Y(pos),
+ pGlyph->info.width,
+ pGlyph->info.height);
+ }
+
+ }
+
+
+ buffer->source = cache->picture;
+
+ rect = &buffer->rects[buffer->count];
+ rect->xSrc = CACHE_X(pos);
+ rect->ySrc = CACHE_Y(pos);
+ rect->xDst = xGlyph - pGlyph->info.x;
+ rect->yDst = yGlyph - pGlyph->info.y;
+ rect->width = pGlyph->info.width;
+ rect->height = pGlyph->info.height;
+
+ buffer->count++;
+
+ return ExaGlyphSuccess;
+}
+
+#undef CACHE_X
+#undef CACHE_Y
+
+static ExaGlyphCacheResult
+exaBufferGlyph(ScreenPtr pScreen,
+ ExaGlyphBufferPtr buffer,
+ GlyphPtr pGlyph,
+ int xGlyph,
+ int yGlyph)
+{
+ ExaScreenPriv(pScreen);
+ unsigned int format = (GlyphPicture(pGlyph)[pScreen->myNum])->format;
+ int width = pGlyph->info.width;
+ int height = pGlyph->info.height;
+ ExaCompositeRectPtr rect;
+ PicturePtr source;
+ int i;
+
+ if (buffer->count == GLYPH_BUFFER_SIZE)
+ return ExaGlyphNeedFlush;
+
+ if (PICT_FORMAT_BPP(format) == 1)
+ format = PICT_a8;
+
+ for (i = 0; i < EXA_NUM_GLYPH_CACHES; i++) {
+ ExaGlyphCachePtr cache = &pExaScr->glyphCaches[i];
+
+ if (format == cache->format &&
+ width <= cache->glyphWidth &&
+ height <= cache->glyphHeight) {
+ ExaGlyphCacheResult result = exaGlyphCacheBufferGlyph(pScreen, &pExaScr->glyphCaches[i],
+ buffer,
+ pGlyph, xGlyph, yGlyph);
+ switch (result) {
+ case ExaGlyphFail:
+ break;
+ case ExaGlyphSuccess:
+ case ExaGlyphNeedFlush:
+ return result;
+ }
+ }
+ }
+
+ /* Couldn't find the glyph in the cache, use the glyph picture directly */
+
+ source = GlyphPicture(pGlyph)[pScreen->myNum];
+ if (buffer->source && buffer->source != source)
+ return ExaGlyphNeedFlush;
+
+ buffer->source = source;
+
+ rect = &buffer->rects[buffer->count];
+ rect->xSrc = 0;
+ rect->ySrc = 0;
+ rect->xDst = xGlyph - pGlyph->info.x;
+ rect->yDst = yGlyph - pGlyph->info.y;
+ rect->width = pGlyph->info.width;
+ rect->height = pGlyph->info.height;
+
+ buffer->count++;
+
+ return ExaGlyphSuccess;
+}
+
+static void
+exaGlyphsToMask(PicturePtr pMask,
+ ExaGlyphBufferPtr buffer)
+{
+ exaCompositeRects(PictOpAdd, buffer->source, pMask,
+ buffer->count, buffer->rects);
+
+ buffer->count = 0;
+ buffer->source = NULL;
+}
+
+static void
+exaGlyphsToDst(CARD8 op,
+ PicturePtr pSrc,
+ PicturePtr pDst,
+ ExaGlyphBufferPtr buffer,
+ INT16 xSrc,
+ INT16 ySrc,
+ INT16 xDst,
+ INT16 yDst)
+{
+ int i;
+
+ for (i = 0; i < buffer->count; i++) {
+ ExaCompositeRectPtr rect = &buffer->rects[i];
+
+ CompositePicture (op,
+ pSrc,
+ buffer->source,
+ pDst,
+ xSrc + rect->xDst - xDst,
+ ySrc + rect->yDst - yDst,
+ rect->xSrc,
+ rect->ySrc,
+ rect->xDst,
+ rect->yDst,
+ rect->width,
+ rect->height);
+ }
+
+ buffer->count = 0;
+ buffer->source = NULL;
+}
+
+/* Cut and paste from render/glyph.c - probably should export it instead */
+static void
+GlyphExtents (int nlist,
+ GlyphListPtr list,
+ GlyphPtr *glyphs,
+ BoxPtr extents)
+{
+ int x1, x2, y1, y2;
+ int n;
+ GlyphPtr glyph;
+ int x, y;
+
+ x = 0;
+ y = 0;
+ extents->x1 = MAXSHORT;
+ extents->x2 = MINSHORT;
+ extents->y1 = MAXSHORT;
+ extents->y2 = MINSHORT;
+ while (nlist--)
+ {
+ x += list->xOff;
+ y += list->yOff;
+ n = list->len;
+ list++;
+ while (n--)
+ {
+ glyph = *glyphs++;
+ x1 = x - glyph->info.x;
+ if (x1 < MINSHORT)
+ x1 = MINSHORT;
+ y1 = y - glyph->info.y;
+ if (y1 < MINSHORT)
+ y1 = MINSHORT;
+ x2 = x1 + glyph->info.width;
+ if (x2 > MAXSHORT)
+ x2 = MAXSHORT;
+ y2 = y1 + glyph->info.height;
+ if (y2 > MAXSHORT)
+ y2 = MAXSHORT;
+ if (x1 < extents->x1)
+ extents->x1 = x1;
+ if (x2 > extents->x2)
+ extents->x2 = x2;
+ if (y1 < extents->y1)
+ extents->y1 = y1;
+ if (y2 > extents->y2)
+ extents->y2 = y2;
+ x += glyph->info.xOff;
+ y += glyph->info.yOff;
+ }
+ }
+}
+
+/**
+ * Returns TRUE if the glyphs in the lists intersect. Only checks based on
+ * bounding box, which appears to be good enough to catch most cases at least.
+ */
+static Bool
+exaGlyphsIntersect(int nlist, GlyphListPtr list, GlyphPtr *glyphs)
+{
+ int x1, x2, y1, y2;
+ int n;
+ GlyphPtr glyph;
+ int x, y;
+ BoxRec extents;
+ Bool first = TRUE;
+
+ x = 0;
+ y = 0;
+ while (nlist--) {
+ x += list->xOff;
+ y += list->yOff;
+ n = list->len;
+ list++;
+ while (n--) {
+ glyph = *glyphs++;
+
+ if (glyph->info.width == 0 || glyph->info.height == 0) {
+ x += glyph->info.xOff;
+ y += glyph->info.yOff;
+ continue;
+ }
+
+ x1 = x - glyph->info.x;
+ if (x1 < MINSHORT)
+ x1 = MINSHORT;
+ y1 = y - glyph->info.y;
+ if (y1 < MINSHORT)
+ y1 = MINSHORT;
+ x2 = x1 + glyph->info.width;
+ if (x2 > MAXSHORT)
+ x2 = MAXSHORT;
+ y2 = y1 + glyph->info.height;
+ if (y2 > MAXSHORT)
+ y2 = MAXSHORT;
+
+ if (first) {
+ extents.x1 = x1;
+ extents.y1 = y1;
+ extents.x2 = x2;
+ extents.y2 = y2;
+ first = FALSE;
+ } else {
+ if (x1 < extents.x2 && x2 > extents.x1 &&
+ y1 < extents.y2 && y2 > extents.y1)
+ {
+ return TRUE;
+ }
+
+ if (x1 < extents.x1)
+ extents.x1 = x1;
+ if (x2 > extents.x2)
+ extents.x2 = x2;
+ if (y1 < extents.y1)
+ extents.y1 = y1;
+ if (y2 > extents.y2)
+ extents.y2 = y2;
+ }
+ x += glyph->info.xOff;
+ y += glyph->info.yOff;
+ }
+ }
+
+ return FALSE;
+}
+
+#define NeedsComponent(f) (PICT_FORMAT_A(f) != 0 && PICT_FORMAT_RGB(f) != 0)
+
+void
+exaGlyphs (CARD8 op,
+ PicturePtr pSrc,
+ PicturePtr pDst,
+ PictFormatPtr maskFormat,
+ INT16 xSrc,
+ INT16 ySrc,
+ int nlist,
+ GlyphListPtr list,
+ GlyphPtr *glyphs)
+{
+ PicturePtr pPicture;
+ PixmapPtr pMaskPixmap = 0;
+ PicturePtr pMask;
+ ScreenPtr pScreen = pDst->pDrawable->pScreen;
+ int width = 0, height = 0;
+ int x, y;
+ int xDst = list->xOff, yDst = list->yOff;
+ int n;
+ GlyphPtr glyph;
+ int error;
+ BoxRec extents = {0, 0, 0, 0};
+ CARD32 component_alpha;
+ ExaGlyphBuffer buffer;
+
+ /* If we don't have a mask format but all the glyphs have the same format
+ * and don't intersect, use the glyph format as mask format for the full
+ * benefits of the glyph cache.
+ */
+ if (!maskFormat) {
+ Bool sameFormat = TRUE;
+ int i;
+
+ maskFormat = list[0].format;
+
+ for (i = 0; i < nlist; i++) {
+ if (maskFormat->format != list[i].format->format) {
+ sameFormat = FALSE;
+ break;
+ }
+ }
+
+ if (!sameFormat || (maskFormat->depth != 1 &&
+ exaGlyphsIntersect(nlist, list, glyphs))) {
+ maskFormat = NULL;
+ }
+ }
+
+ if (maskFormat)
+ {
+ GCPtr pGC;
+ xRectangle rect;
+
+ GlyphExtents (nlist, list, glyphs, &extents);
+
+ if (extents.x2 <= extents.x1 || extents.y2 <= extents.y1)
+ return;
+ width = extents.x2 - extents.x1;
+ height = extents.y2 - extents.y1;
+
+ if (maskFormat->depth == 1) {
+ PictFormatPtr a8Format = PictureMatchFormat (pScreen, 8, PICT_a8);
+
+ if (a8Format)
+ maskFormat = a8Format;
+ }
+
+ pMaskPixmap = (*pScreen->CreatePixmap) (pScreen, width, height,
+ maskFormat->depth,
+ CREATE_PIXMAP_USAGE_SCRATCH);
+ if (!pMaskPixmap)
+ return;
+ component_alpha = NeedsComponent(maskFormat->format);
+ pMask = CreatePicture (0, &pMaskPixmap->drawable,
+ maskFormat, CPComponentAlpha, &component_alpha,
+ serverClient, &error);
+ if (!pMask)
+ {
+ (*pScreen->DestroyPixmap) (pMaskPixmap);
+ return;
+ }
+ pGC = GetScratchGC (pMaskPixmap->drawable.depth, pScreen);
+ ValidateGC (&pMaskPixmap->drawable, pGC);
+ rect.x = 0;
+ rect.y = 0;
+ rect.width = width;
+ rect.height = height;
+ (*pGC->ops->PolyFillRect) (&pMaskPixmap->drawable, pGC, 1, &rect);
+ FreeScratchGC (pGC);
+ x = -extents.x1;
+ y = -extents.y1;
+ }
+ else
+ {
+ pMask = pDst;
+ x = 0;
+ y = 0;
+ }
+ buffer.count = 0;
+ buffer.source = NULL;
+ while (nlist--)
+ {
+ x += list->xOff;
+ y += list->yOff;
+ n = list->len;
+ while (n--)
+ {
+ glyph = *glyphs++;
+ pPicture = GlyphPicture (glyph)[pScreen->myNum];
+
+ if (glyph->info.width > 0 && glyph->info.height > 0 &&
+ exaBufferGlyph(pScreen, &buffer, glyph, x, y) == ExaGlyphNeedFlush)
+ {
+ if (maskFormat)
+ exaGlyphsToMask(pMask, &buffer);
+ else
+ exaGlyphsToDst(op, pSrc, pDst, &buffer,
+ xSrc, ySrc, xDst, yDst);
+
+ exaBufferGlyph(pScreen, &buffer, glyph, x, y);
+ }
+
+ x += glyph->info.xOff;
+ y += glyph->info.yOff;
+ }
+ list++;
+ }
+
+ if (maskFormat)
+ exaGlyphsToMask(pMask, &buffer);
+ else
+ exaGlyphsToDst(op, pSrc, pDst, &buffer,
+ xSrc, ySrc, xDst, yDst);
+
+ if (maskFormat)
+ {
+ x = extents.x1;
+ y = extents.y1;
+ CompositePicture (op,
+ pSrc,
+ pMask,
+ pDst,
+ xSrc + x - xDst,
+ ySrc + y - yDst,
+ 0, 0,
+ x, y,
+ width, height);
+ FreePicture ((pointer) pMask, (XID) 0);
+ (*pScreen->DestroyPixmap) (pMaskPixmap);
+ }
+}
diff --git a/exa/exa_offscreen.c b/exa/exa_offscreen.c
index 85b538896..4aaa2c132 100644
--- a/exa/exa_offscreen.c
+++ b/exa/exa_offscreen.c
@@ -21,11 +21,9 @@
*/
/** @file
- * This allocator allocates blocks of memory by maintaining a list of areas
- * and a score for each area. As an area is marked used, its score is
- * incremented, and periodically all of the areas have their scores decayed by
- * a fraction. When allocating, the contiguous block of areas with the minimum
- * score is found and evicted in order to make room for the new allocation.
+ * This allocator allocates blocks of memory by maintaining a list of areas.
+ * When allocating, the contiguous block of areas with the minimum eviction
+ * cost is found and evicted in order to make room for the new allocation.
*/
#include "exa_priv.h"
@@ -71,19 +69,36 @@ ExaOffscreenKickOut (ScreenPtr pScreen, ExaOffscreenArea *area)
return exaOffscreenFree (pScreen, area);
}
-#define AREA_SCORE(area) (area->size / (double)(pExaScr->offScreenCounter - area->last_use))
+static void
+exaUpdateEvictionCost(ExaOffscreenArea *area, unsigned offScreenCounter)
+{
+ unsigned age;
+
+ if (area->state == ExaOffscreenAvail)
+ return;
+
+ age = offScreenCounter - area->last_use;
+
+ /* This is unlikely to happen, but could result in a division by zero... */
+ if (age > (UINT_MAX / 2)) {
+ age = UINT_MAX / 2;
+ area->last_use = offScreenCounter - age;
+ }
+
+ area->eviction_cost = area->size / age;
+}
static ExaOffscreenArea *
exaFindAreaToEvict(ExaScreenPrivPtr pExaScr, int size, int align)
{
ExaOffscreenArea *begin, *end, *best;
- double score, best_score;
+ unsigned cost, best_cost;
int avail, real_size, tmp;
- best_score = UINT_MAX;
+ best_cost = UINT_MAX;
begin = end = pExaScr->info->offScreenAreas;
avail = 0;
- score = 0;
+ cost = 0;
best = 0;
while (end != NULL)
@@ -106,23 +121,24 @@ exaFindAreaToEvict(ExaScreenPrivPtr pExaScr, int size, int align)
if (end->state == ExaOffscreenLocked) {
/* Can't more room here, restart after this locked area */
avail = 0;
- score = 0;
+ cost = 0;
begin = end;
goto restart;
}
avail += end->size;
- score += AREA_SCORE(end);
+ exaUpdateEvictionCost(end, pExaScr->offScreenCounter);
+ cost += end->eviction_cost;
end = end->next;
}
- /* Check the score, update best */
- if (avail >= real_size && score < best_score) {
+ /* Check the cost, update best */
+ if (avail >= real_size && cost < best_cost) {
best = begin;
- best_score = score;
+ best_cost = cost;
}
avail -= begin->size;
- score -= AREA_SCORE(begin);
+ cost -= begin->eviction_cost;
begin = begin->next;
}
@@ -244,6 +260,7 @@ exaOffscreenAlloc (ScreenPtr pScreen, int size, int align,
new_area->state = ExaOffscreenAvail;
new_area->save = NULL;
new_area->last_use = 0;
+ new_area->eviction_cost = 0;
new_area->next = area->next;
area->next = new_area;
area->size = real_size;
@@ -409,6 +426,7 @@ exaOffscreenFree (ScreenPtr pScreen, ExaOffscreenArea *area)
area->state = ExaOffscreenAvail;
area->save = NULL;
area->last_use = 0;
+ area->eviction_cost = 0;
/*
* Find previous area
*/
@@ -474,6 +492,7 @@ exaOffscreenInit (ScreenPtr pScreen)
area->save = NULL;
area->next = NULL;
area->last_use = 0;
+ area->eviction_cost = 0;
/* Add it to the free areas */
pExaScr->info->offScreenAreas = area;
diff --git a/exa/exa_priv.h b/exa/exa_priv.h
index 90e13da9f..8c279466b 100644
--- a/exa/exa_priv.h
+++ b/exa/exa_priv.h
@@ -61,6 +61,7 @@
#define DEBUG_MIGRATE 0
#define DEBUG_PIXMAP 0
#define DEBUG_OFFSCREEN 0
+#define DEBUG_GLYPH_CACHE 0
#if DEBUG_TRACE_FALL
#define EXA_FALLBACK(x) \
@@ -95,6 +96,38 @@ enum ExaMigrationHeuristic {
ExaMigrationSmart
};
+typedef struct {
+ unsigned char sha1[20];
+} ExaCachedGlyphRec, *ExaCachedGlyphPtr;
+
+typedef struct {
+ /* The identity of the cache, statically configured at initialization */
+ unsigned int format;
+ int glyphWidth;
+ int glyphHeight;
+
+ int size; /* Size of cache; eventually this should be dynamically determined */
+
+ /* Hash table mapping from glyph sha1 to position in the glyph; we use
+ * open addressing with a hash table size determined based on size and large
+ * enough so that we always have a good amount of free space, so we can
+ * use linear probing. (Linear probing is preferrable to double hashing
+ * here because it allows us to easily remove entries.)
+ */
+ int *hashEntries;
+ int hashSize;
+
+ ExaCachedGlyphPtr glyphs;
+ int glyphCount; /* Current number of glyphs */
+
+ PicturePtr picture; /* Where the glyphs of the cache are stored */
+ int yOffset; /* y location within the picture where the cache starts */
+ int columns; /* Number of columns the glyphs are layed out in */
+ int evictionPosition; /* Next random position to evict a glyph */
+} ExaGlyphCacheRec, *ExaGlyphCachePtr;
+
+#define EXA_NUM_GLYPH_CACHES 4
+
typedef void (*EnableDisableFBAccessProcPtr)(int, Bool);
typedef struct {
ExaDriverPtr info;
@@ -107,6 +140,7 @@ typedef struct {
CopyWindowProcPtr SavedCopyWindow;
ChangeWindowAttributesProcPtr SavedChangeWindowAttributes;
BitmapToRegionProcPtr SavedBitmapToRegion;
+ CreateScreenResourcesProcPtr SavedCreateScreenResources;
ModifyPixmapHeaderProcPtr SavedModifyPixmapHeader;
#ifdef RENDER
CompositeProcPtr SavedComposite;
@@ -122,6 +156,8 @@ typedef struct {
unsigned disableFbCount;
Bool optimize_migration;
unsigned offScreenCounter;
+
+ ExaGlyphCacheRec glyphCaches[EXA_NUM_GLYPH_CACHES];
} ExaScreenPrivRec, *ExaScreenPrivPtr;
/*
@@ -209,6 +245,15 @@ typedef struct _ExaMigrationRec {
RegionPtr pReg;
} ExaMigrationRec, *ExaMigrationPtr;
+typedef struct {
+ INT16 xSrc;
+ INT16 ySrc;
+ INT16 xDst;
+ INT16 yDst;
+ INT16 width;
+ INT16 height;
+} ExaCompositeRectRec, *ExaCompositeRectPtr;
+
/**
* exaDDXDriverInit must be implemented by the DDX using EXA, and is the place
* to set EXA options or hook in screen functions to handle using EXA as the AA.
@@ -430,6 +475,13 @@ exaComposite(CARD8 op,
CARD16 height);
void
+exaCompositeRects(CARD8 op,
+ PicturePtr Src,
+ PicturePtr pDst,
+ int nrect,
+ ExaCompositeRectPtr rects);
+
+void
exaTrapezoids (CARD8 op, PicturePtr pSrc, PicturePtr pDst,
PictFormatPtr maskFormat, INT16 xSrc, INT16 ySrc,
int ntrap, xTrapezoid *traps);
@@ -439,6 +491,13 @@ exaTriangles (CARD8 op, PicturePtr pSrc, PicturePtr pDst,
PictFormatPtr maskFormat, INT16 xSrc, INT16 ySrc,
int ntri, xTriangle *tris);
+/* exa_glyph.c */
+void
+exaGlyphsInit(ScreenPtr pScreen);
+
+void
+exaGlyphsFini (ScreenPtr pScreen);
+
void
exaGlyphs (CARD8 op,
PicturePtr pSrc,
diff --git a/exa/exa_render.c b/exa/exa_render.c
index da8140102..b480c6d05 100644
--- a/exa/exa_render.c
+++ b/exa/exa_render.c
@@ -51,6 +51,9 @@ static void exaCompositeFallbackPictDesc(PicturePtr pict, char *string, int n)
case PICT_a8r8g8b8:
snprintf(format, 20, "ARGB8888");
break;
+ case PICT_x8r8g8b8:
+ snprintf(format, 20, "XRGB8888");
+ break;
case PICT_r5g6b5:
snprintf(format, 20, "RGB565 ");
break;
@@ -329,6 +332,231 @@ exaTryDriverSolidFill(PicturePtr pSrc,
}
static int
+exaTryDriverCompositeRects(CARD8 op,
+ PicturePtr pSrc,
+ PicturePtr pDst,
+ int nrect,
+ ExaCompositeRectPtr rects)
+{
+ ExaScreenPriv (pDst->pDrawable->pScreen);
+ int src_off_x, src_off_y, dst_off_x, dst_off_y;
+ PixmapPtr pSrcPix, pDstPix;
+ ExaPixmapPrivPtr pSrcExaPix, pDstExaPix;
+ struct _Pixmap scratch;
+ ExaMigrationRec pixmaps[2];
+
+ if (!pExaScr->info->PrepareComposite)
+ return -1;
+
+ pSrcPix = exaGetDrawablePixmap(pSrc->pDrawable);
+ pSrcExaPix = ExaGetPixmapPriv(pSrcPix);
+
+ pDstPix = exaGetDrawablePixmap(pDst->pDrawable);
+ pDstExaPix = ExaGetPixmapPriv(pDstPix);
+
+ /* Check whether the accelerator can use these pixmaps.
+ * FIXME: If it cannot, use temporary pixmaps so that the drawing
+ * happens within limits.
+ */
+ if (pSrcExaPix->accel_blocked ||
+ pDstExaPix->accel_blocked)
+ {
+ return -1;
+ }
+
+ if (pExaScr->info->CheckComposite &&
+ !(*pExaScr->info->CheckComposite) (op, pSrc, NULL, pDst))
+ {
+ return -1;
+ }
+
+ exaGetDrawableDeltas (pDst->pDrawable, pDstPix, &dst_off_x, &dst_off_y);
+
+ pixmaps[0].as_dst = TRUE;
+ pixmaps[0].as_src = exaOpReadsDestination(op);
+ pixmaps[0].pPix = pDstPix;
+ pixmaps[0].pReg = NULL;
+ pixmaps[1].as_dst = FALSE;
+ pixmaps[1].as_src = TRUE;
+ pixmaps[1].pPix = pSrcPix;
+ pixmaps[1].pReg = NULL;
+ exaDoMigration(pixmaps, 2, TRUE);
+
+ pSrcPix = exaGetOffscreenPixmap (pSrc->pDrawable, &src_off_x, &src_off_y);
+ if (!exaPixmapIsOffscreen(pDstPix))
+ return 0;
+
+ if (!pSrcPix && pExaScr->info->UploadToScratch)
+ {
+ pSrcPix = exaGetDrawablePixmap (pSrc->pDrawable);
+ if ((*pExaScr->info->UploadToScratch) (pSrcPix, &scratch))
+ pSrcPix = &scratch;
+ }
+
+ if (!pSrcPix)
+ return 0;
+
+ if (!(*pExaScr->info->PrepareComposite) (op, pSrc, NULL, pDst, pSrcPix,
+ NULL, pDstPix))
+ return -1;
+
+ while (nrect--)
+ {
+ INT16 xDst = rects->xDst + pDst->pDrawable->x;
+ INT16 yDst = rects->yDst + pDst->pDrawable->y;
+ INT16 xSrc = rects->xSrc + pSrc->pDrawable->x;
+ INT16 ySrc = rects->ySrc + pSrc->pDrawable->y;
+
+ RegionRec region;
+ BoxPtr pbox;
+ int nbox;
+
+ if (!miComputeCompositeRegion (&region, pSrc, NULL, pDst,
+ xSrc, ySrc, 0, 0, xDst, yDst,
+ rects->width, rects->height))
+ goto next_rect;
+
+ REGION_TRANSLATE(pScreen, &region, dst_off_x, dst_off_y);
+
+ nbox = REGION_NUM_RECTS(&region);
+ pbox = REGION_RECTS(&region);
+
+ xSrc = xSrc + src_off_x - xDst - dst_off_x;
+ ySrc = ySrc + src_off_y - yDst - dst_off_y;
+
+ while (nbox--)
+ {
+ (*pExaScr->info->Composite) (pDstPix,
+ pbox->x1 + xSrc,
+ pbox->y1 + ySrc,
+ 0, 0,
+ pbox->x1,
+ pbox->y1,
+ pbox->x2 - pbox->x1,
+ pbox->y2 - pbox->y1);
+ pbox++;
+ }
+
+ next_rect:
+ REGION_UNINIT(pDst->pDrawable->pScreen, &region);
+
+ rects++;
+ }
+
+ (*pExaScr->info->DoneComposite) (pDstPix);
+ exaMarkSync(pDst->pDrawable->pScreen);
+
+ return 1;
+}
+
+/**
+ * Copy a number of rectangles from source to destination in a single
+ * operation. This is specialized for building a glyph mask: we don'y
+ * have a mask argument because we don't need it for that, and we
+ * don't have he special-case fallbacks found in exaComposite() - if the
+ * driver can support it, we use the driver functionality, otherwise we
+ * fallback straight to software.
+ */
+void
+exaCompositeRects(CARD8 op,
+ PicturePtr pSrc,
+ PicturePtr pDst,
+ int nrect,
+ ExaCompositeRectPtr rects)
+{
+ PixmapPtr pPixmap = exaGetDrawablePixmap(pDst->pDrawable);
+ ExaPixmapPriv(pPixmap);
+
+ int xoff, yoff;
+ int x1 = MAXSHORT;
+ int y1 = MAXSHORT;
+ int x2 = MINSHORT;
+ int y2 = MINSHORT;
+ RegionRec region;
+ RegionPtr pending_damage;
+ BoxRec box;
+ int n;
+ ExaCompositeRectPtr r;
+
+ /* We have to manage the damage ourselves, since CompositeRects isn't
+ * something in the screen that can be managed by the damage extension,
+ * and EXA depends on damage to track what needs to be migrated between
+ * offscreen and onscreen.
+ */
+
+ /* Compute the overall extents of the composited region - we're making
+ * the assumption here that we are compositing a bunch of glyphs that
+ * cluster closely together and damaging each glyph individually would
+ * be a loss compared to damaging the bounding box.
+ */
+ n = nrect;
+ r = rects;
+ while (n--) {
+ int rect_x2 = r->xDst + r->width;
+ int rect_y2 = r->yDst + r->width;
+
+ if (r->xDst < x1) x1 = r->xDst;
+ if (r->xDst < y1) y1 = r->xDst;
+ if (rect_x2 > x2) x2 = rect_x2;
+ if (rect_y2 > y2) y2 = rect_y2;
+
+ r++;
+ }
+
+ if (x2 <= x1 && y2 <= y1)
+ return;
+
+ box.x1 = x1;
+ box.x2 = x2 < MAXSHORT ? x2 : MAXSHORT;
+ box.y1 = y1;
+ box.y2 = y2 < MAXSHORT ? y2 : MAXSHORT;
+
+ /* The pixmap migration code relies on pendingDamage indicating
+ * the bounds of the current rendering, so we need to force
+ * the actual damage into that region before we do anything, and
+ * (see use of DamagePendingRegion in exaCopyDirty)
+ */
+
+ REGION_INIT(pScreen, &region, &box, 1);
+
+ exaGetDrawableDeltas(pDst->pDrawable, pPixmap, &xoff, &yoff);
+
+ REGION_TRANSLATE(pScreen, &region, xoff, yoff);
+ pending_damage = DamagePendingRegion(pExaPixmap->pDamage);
+ REGION_UNION(pScreen, pending_damage, pending_damage, &region);
+ REGION_TRANSLATE(pScreen, &region, -xoff, -yoff);
+
+ /************************************************************/
+
+ ValidatePicture (pSrc);
+ ValidatePicture (pDst);
+
+ if (exaTryDriverCompositeRects(op, pSrc, pDst, nrect, rects) != 1) {
+ n = nrect;
+ r = rects;
+ while (n--) {
+ ExaCheckComposite (op, pSrc, NULL, pDst,
+ r->xSrc, r->ySrc,
+ 0, 0,
+ r->xDst, r->yDst,
+ r->width, r->height);
+ r++;
+ }
+ }
+
+ /************************************************************/
+
+ /* Now we have to flush the damage out from pendingDamage => damage
+ * Calling DamageDamageRegion has that effect. (We could pass
+ * in an empty region here, but we pass in the same region we
+ * use above; the effect is the same.)
+ */
+
+ DamageDamageRegion(pDst->pDrawable, &region);
+ REGION_UNINIT(pScreen, &region);
+}
+
+static int
exaTryDriverComposite(CARD8 op,
PicturePtr pSrc,
PicturePtr pMask,
diff --git a/fb/Makefile.am b/fb/Makefile.am
index e34aaba10..399426933 100644
--- a/fb/Makefile.am
+++ b/fb/Makefile.am
@@ -7,7 +7,7 @@ INCLUDES = \
AM_CFLAGS = $(DIX_CFLAGS)
if XORG
-sdk_HEADERS = fb.h fbrop.h fbpseudocolor.h fboverlay.h wfbrename.h
+sdk_HEADERS = fb.h fbrop.h fboverlay.h wfbrename.h
endif
libfb_la_CFLAGS = $(AM_CFLAGS)
@@ -49,9 +49,7 @@ libfb_la_SOURCES = \
fbtile.c \
fbtrap.c \
fbutil.c \
- fbwindow.c \
- fbpseudocolor.c \
- fbpseudocolor.h
+ fbwindow.c
libwfb_la_SOURCES = $(libfb_la_SOURCES)
diff --git a/fb/fb.h b/fb/fb.h
index 01000d79c..1cd947380 100644
--- a/fb/fb.h
+++ b/fb/fb.h
@@ -141,7 +141,7 @@ typedef unsigned __int64 FbBits;
defined(ia64) || defined(__ia64__) || \
defined(__sparc64__) || defined(_LP64) || \
defined(__s390x__) || \
- defined(amd64) || defined (__amd64__) || \
+ defined(amd64) || defined (__amd64__) || defined(__x86_64__) || \
defined (__powerpc64__) || \
(defined(sgi) && (_MIPS_SZLONG == 64))
typedef unsigned long FbBits;
diff --git a/fb/fbpseudocolor.c b/fb/fbpseudocolor.c
deleted file mode 100644
index 06cf15992..000000000
--- a/fb/fbpseudocolor.c
+++ /dev/null
@@ -1,2248 +0,0 @@
-#ifdef HAVE_DIX_CONFIG_H
-#include <dix-config.h>
-#endif
-
-#include <string.h>
-
-#include <X11/X.h>
-#include <X11/Xproto.h>
-#include "scrnintstr.h"
-#include "colormapst.h"
-#include "glyphstr.h"
-#include "resource.h"
-#include <X11/fonts/font.h>
-#include "dixfontstr.h"
-#include <X11/fonts/fontstruct.h>
-#include "micmap.h"
-#include "fb.h"
-#include "fbpseudocolor.h"
-
-static Bool xxCreateGC(GCPtr pGC);
-static void xxValidateGC(GCPtr pGC, unsigned long changes, DrawablePtr pDraw);
-static void xxDestroyGC(GCPtr pGC);
-static void xxChangeGC (GCPtr pGC, unsigned long mask);
-static void xxCopyGC (GCPtr pGCSrc, unsigned long mask, GCPtr pGCDst);
-static void xxChangeClip (GCPtr pGC, int type, pointer pvalue, int nrects);
-
-static void xxCopyClip(GCPtr pgcDst, GCPtr pgcSrc);
-static void xxDestroyClip(GCPtr pGC);
-static void xxFillSpans(DrawablePtr pDraw, GC *pGC, int nInit,
- DDXPointPtr pptInit, int *pwidthInit, int fSorted);
-static void xxSetSpans(DrawablePtr pDraw, GCPtr pGC, char *pcharsrc,
- DDXPointPtr pptInit, int *pwidthInit, int nspans,
- int fSorted);
-static void xxPutImage(DrawablePtr pDraw, GCPtr pGC, int depth, int x, int y,
- int w, int h,int leftPad, int format, char *pImage);
-static RegionPtr xxCopyPlane(DrawablePtr pSrc,
- DrawablePtr pDst, GCPtr pGC,int srcx, int srcy,
- int width, int height, int dstx, int dsty,
- unsigned long bitPlane);
-static void xxPolyPoint(DrawablePtr pDraw, GCPtr pGC, int mode, int npt,
- xPoint *pptInit);
-static void xxPolylines(DrawablePtr pDraw, GCPtr pGC, int mode,
- int npt, DDXPointPtr pptInit);
-static void xxPolySegment(DrawablePtr pDraw, GCPtr pGC, int nseg,
- xSegment *pSeg);
-static void xxPolyRectangle(DrawablePtr pDraw, GCPtr pGC, int nRects,
- xRectangle *pRects);
-static void xxPolyArc( DrawablePtr pDraw, GCPtr pGC, int narcs, xArc *parcs);
-static void xxFillPolygon(DrawablePtr pDraw, GCPtr pGC, int shape,
- int mode, int count, DDXPointPtr pptInit);
-static void xxPolyFillRect(DrawablePtr pDraw, GCPtr pGC, int nRectsInit,
- xRectangle *pRectsInit);
-static RegionPtr xxCopyArea(DrawablePtr pSrc, DrawablePtr pDst, GC *pGC,
- int srcx, int srcy, int width, int height,
- int dstx, int dsty);
-static void xxPolyFillArc(DrawablePtr pDraw, GCPtr pGC, int narcs,
- xArc *parcs);
-static int xxPolyText8(DrawablePtr pDraw, GCPtr pGC, int x, int y, int count,
- char *chars);
-static int xxPolyText16(DrawablePtr pDraw, GCPtr pGC, int x, int y,
- int count, unsigned short *chars);
-static void xxImageText8(DrawablePtr pDraw, GCPtr pGC, int x,
- int y, int count, char *chars);
-static void xxImageText16(DrawablePtr pDraw, GCPtr pGC, int x, int y,
- int count, unsigned short *chars);
-static void xxImageGlyphBlt(DrawablePtr pDraw, GCPtr pGC, int x, int y,
- unsigned int nglyph, CharInfoPtr *ppci,
- pointer pglyphBase);
-static void xxPolyGlyphBlt(DrawablePtr pDraw, GCPtr pGC, int x, int y,
- unsigned int nglyph, CharInfoPtr *ppci,
- pointer pglyphBase);
-static void xxPushPixels(GCPtr pGC, PixmapPtr pBitMap, DrawablePtr pDraw,
- int dx, int dy, int xOrg, int yOrg);
-static void
-xxComposite (CARD8 op, PicturePtr pSrc, PicturePtr pMask, PicturePtr pDst,
- INT16 xSrc, INT16 ySrc, INT16 xMask, INT16 yMask,
- INT16 xDst, INT16 yDst, CARD16 width, CARD16 height);
-static void
-xxGlyphs (CARD8 op, PicturePtr pSrc, PicturePtr pDst,
- PictFormatPtr maskFormat, INT16 xSrc, INT16 ySrc, int nlist,
- GlyphListPtr list, GlyphPtr *glyphs);
-
-
-typedef struct _xxCmapPrivRec {
- CARD32* cmap;
- ColormapPtr pmap;
- Bool dirty;
- struct _xxCmapPrivRec *next;
-} xxCmapPrivRec, *xxCmapPrivPtr;
-
-
-typedef struct {
- CloseScreenProcPtr CloseScreen;
- CreateScreenResourcesProcPtr CreateScreenResources;
- CreateWindowProcPtr CreateWindow;
- CopyWindowProcPtr CopyWindow;
- WindowExposuresProcPtr WindowExposures;
- CreateGCProcPtr CreateGC;
- CreateColormapProcPtr CreateColormap;
- DestroyColormapProcPtr DestroyColormap;
- InstallColormapProcPtr InstallColormap;
- UninstallColormapProcPtr UninstallColormap;
- ListInstalledColormapsProcPtr ListInstalledColormaps;
- StoreColorsProcPtr StoreColors;
-#ifdef RENDER
- CompositeProcPtr Composite;
- GlyphsProcPtr Glyphs;
-#endif
- PixmapPtr pPixmap;
- char * addr;
- pointer pBits;
- RegionRec region;
- VisualPtr bVisual;
- RegionRec bRegion;
- int myDepth;
- int depth;
- ColormapPtr baseCmap;
- ColormapPtr* InstalledCmaps;
- xxCmapPrivPtr Cmaps;
- int numInstalledColormaps;
- int colormapDirty;
- xxSyncFunc sync;
-} xxScrPrivRec, *xxScrPrivPtr;
-
-#define xxGetScrPriv(s) ((xxScrPrivPtr) \
- dixLookupPrivate(&(s)->devPrivates, xxScrPrivateKey))
-#define xxScrPriv(s) xxScrPrivPtr pScrPriv = xxGetScrPriv(s)
-
-#define xxGetCmapPriv(s) ((xxCmapPrivPtr) \
- dixLookupPrivate(&(s)->devPrivates, xxColormapPrivateKey))
-#define xxCmapPriv(s) xxCmapPrivPtr pCmapPriv = xxGetCmapPriv(s);
-
-typedef struct _xxGCPriv {
- GCOps *ops;
- GCFuncs *funcs;
-} xxGCPrivRec, *xxGCPrivPtr;
-
-#define xxGetGCPriv(pGC) ((xxGCPrivPtr) \
- dixLookupPrivate(&(pGC)->devPrivates, xxGCPrivateKey))
-#define xxGCPriv(pGC) xxGCPrivPtr pGCPriv = xxGetGCPriv(pGC)
-
-static DevPrivateKey xxScrPrivateKey = &xxScrPrivateKey;
-static DevPrivateKey xxGCPrivateKey = &xxGCPrivateKey;
-static DevPrivateKey xxColormapPrivateKey = &xxColormapPrivateKey;
-
-
-#define wrap(priv,real,mem,func) {\
- priv->mem = real->mem; \
- real->mem = func; \
-}
-
-#define unwrap(priv,real,mem) {\
- real->mem = priv->mem; \
-}
-
-#define MARK_DIRTY (1 << 31)
-
-#define MAX_NUM_XX_INSTALLED_CMAPS 255
-/* #define DEBUG */
-#ifdef DEBUG
-# define DBG ErrorF
-# define DBG_ARGS(x) ErrorF x
-# define PRINT_RECTS(rec) {\
- int i;\
- BoxPtr box;\
- ErrorF("RECTS: %i\n",REGION_NUM_RECTS(&rec));\
- if (REGION_NUM_RECTS(&rec) > 1) { \
- for (i = 0; i < REGION_NUM_RECTS(&rec); i++ ) {\
- box = REGION_BOX(&rec,i);\
- ErrorF("x1: %hi x2: %hi y1: %hi y2: %hi\n", \
- box->x1,box->x2,box->y1,box->y2);\
- }\
- } else { \
- box = &(rec.extents); \
- ErrorF("x1: %hi x2: %hi y1: %hi y2: %hi\n", \
- box->x1,box->x2,box->y1,box->y2);\
- } \
-}
-#else
-# define DBG(x)
-# define DBG_ARGS(x)
-# define PRINT_RECTS(rec)
-#endif
-
-#if 0
-static void xxCopyPseudocolorRegion(ScreenPtr pScreen, RegionPtr pReg,
- xxCmapPrivPtr pCmapPriv);
-static void xxUpdateFb(ScreenPtr pScreen);
-
-
-static void
-xxUpdateWindowImmediately(WindowPtr pWin)
-{
- xxScrPriv(pWin->drawable.pScreen);
- xxCmapPrivPtr pCmapPriv;
- ColormapPtr pmap;
-
- pmap = (ColormapPtr)LookupIDByType(wColormap(pWin),RT_COLORMAP);
-
- if (pmap && (pCmapPriv = xxGetCmapPriv(pmap)) != (pointer)-1) {
- xxCopyPseudocolorRegion(pWin->drawable.pScreen,
- &pScrPriv->region, pCmapPriv);
- }
-}
-#else
-# define xxUpdateWindowImmediately(x)
-#endif
-
-static ColormapPtr
-xxGetBaseColormap(ScreenPtr pScreen)
-{
- xxScrPriv(pScreen);
- DepthPtr pDepth = pScreen->allowedDepths;
- int i,j,k;
- ColormapPtr pDefMap
- = (ColormapPtr) LookupIDByType(pScreen->defColormap,RT_COLORMAP);
- ColormapPtr cmap = NULL;
- VisualPtr pVisual = NULL;
-
- for (i = 0; i < pScreen->numDepths; i++, pDepth++)
- if (pDepth->depth == pScrPriv->depth) {
- for (j = 0; j < pDepth->numVids; j++) {
- if (pDefMap->pVisual->vid == pDepth->vids[j]
- && pDefMap->pVisual->class == TrueColor) {
- cmap = pDefMap;
- break;
- }
- if (!pVisual) {
- for (k = 0; k < pScreen->numVisuals; k++) {
- if (pScreen->visuals[k].class == TrueColor
- && pScreen->visuals[k].vid
- == pDepth->vids[j]) {
- pVisual = &pScreen->visuals[k];
- break;
- }
- }
- }
- }
- if (cmap)
- break;
- }
-
- if (!cmap) {
- CreateColormap(FakeClientID(0),pScreen,pVisual,&cmap,AllocNone,0);
- }
-
- return cmap;
-}
-
-static Bool
-xxCreateScreenResources(ScreenPtr pScreen)
-{
- PixmapPtr pPix;
- xxScrPriv(pScreen);
- Bool ret;
- PixmapPtr pPixmap;
- BoxRec box;
- int depth = pScrPriv->myDepth;
- pointer pBits;
-
- unwrap (pScrPriv,pScreen, CreateScreenResources);
- ret = pScreen->CreateScreenResources(pScreen);
- wrap(pScrPriv,pScreen,CreateScreenResources,xxCreateScreenResources);
-
- if (!ret) return FALSE;
-
- pScrPriv->pBits = NULL;
- if (pScrPriv->addr)
- pBits = pScrPriv->addr;
- else
- pBits = xalloc(pScreen->width * pScreen->height
- * (BitsPerPixel(depth) >> 3));
- if (!pBits) return FALSE;
-
- pPixmap = (*pScreen->CreatePixmap)(pScreen, 0, 0, depth, 0);
- if (!pPixmap) {
- xfree(pBits);
- return FALSE;
- }
- if (!(*pScreen->ModifyPixmapHeader)(pPixmap, pScreen->width,
- pScreen->height, depth,
- BitsPerPixel(depth),
- PixmapBytePad(pScreen->width, depth),
- pBits)) {
- xfree(pBits);
- return FALSE;
- }
- if (pScreen->rootDepth == pScrPriv->myDepth) {
- pPix = (PixmapPtr)pScreen->devPrivate;
- if (!(*pScreen->ModifyPixmapHeader)(pPix, 0,0, pScrPriv->depth,
- BitsPerPixel(pScrPriv->depth),
- PixmapBytePad(pScreen->width,
- pScrPriv->depth),
- 0)) {
- xfree(pBits);
- return FALSE;
- }
- }
-
- pScrPriv->baseCmap = xxGetBaseColormap(pScreen);
-
- pScrPriv->pBits = pBits;
- pScrPriv->pPixmap = pPixmap;
- box.x1 = 0;
- box.y1 = 0;
- box.x2 = pScreen->width;
- box.y2 = pScreen->height;
- REGION_NULL(pScreen, &pScrPriv->region);
- REGION_INIT(pScreen, &pScrPriv->bRegion, &box, 0);
-
- return TRUE;
-}
-
-static Bool
-xxCloseScreen (int iScreen, ScreenPtr pScreen)
-{
- xxScrPriv(pScreen);
- Bool ret;
-
- (*pScreen->DestroyPixmap)(pScrPriv->pPixmap);
- /* We don't need to free the baseColormap as FreeClientResourcess
- will have taken care of it. */
- REGION_UNINIT (pScreen, &pScrPriv->region);
-
- unwrap (pScrPriv,pScreen, CloseScreen);
- ret = pScreen->CloseScreen(iScreen,pScreen);
-
- xfree(pScrPriv->pBits);
- xfree(pScrPriv->InstalledCmaps);
- xfree(pScrPriv);
-
- return TRUE;
-}
-
-static Bool
-xxMyVisual(ScreenPtr pScreen, VisualID vid)
-{
- xxScrPriv(pScreen);
- DepthPtr pDepth = pScreen->allowedDepths;
- int i,j;
-
- for (i = 0; i < pScreen->numDepths; i++, pDepth++)
- if (pDepth->depth == pScrPriv->myDepth) {
- for (j = 0; j < pDepth->numVids; j++) {
- if (vid == pDepth->vids[j]) {
- return TRUE;
- }
- }
- }
- return FALSE;
-}
-
-static Bool
-xxInitColormapPrivate(ColormapPtr pmap)
-{
- xxScrPriv(pmap->pScreen);
- xxCmapPrivPtr pCmapPriv;
- pointer cmap;
-
- dixSetPrivate(&pmap->devPrivates, xxColormapPrivateKey, (pointer) -1);
-
- if (xxMyVisual(pmap->pScreen,pmap->pVisual->vid)) {
- DBG("CreateColormap\n");
- pCmapPriv = (xxCmapPrivPtr) xalloc (sizeof (xxCmapPrivRec));
- if (!pCmapPriv)
- return FALSE;
- dixSetPrivate(&pmap->devPrivates, xxColormapPrivateKey, pCmapPriv);
- cmap = xalloc(sizeof (CARD32) * (1 << pScrPriv->myDepth));
- if (!cmap)
- return FALSE;
-
- memset(cmap,0,sizeof (CARD32) * (1 << pScrPriv->myDepth));
-
- pCmapPriv->cmap = cmap;
- pCmapPriv->dirty = FALSE;
- pCmapPriv->pmap = pmap;
- pCmapPriv->next = pScrPriv->Cmaps;
- pScrPriv->Cmaps = pCmapPriv;
- }
- return TRUE;
-}
-
-
-static Bool
-xxCreateColormap(ColormapPtr pmap)
-{
- xxScrPriv(pmap->pScreen);
- Bool ret;
-
- if (!xxInitColormapPrivate(pmap)) return FALSE;
-
- unwrap(pScrPriv,pmap->pScreen, CreateColormap);
- ret = pmap->pScreen->CreateColormap(pmap);
- wrap(pScrPriv,pmap->pScreen,CreateColormap,xxCreateColormap);
-
- return ret;
-}
-
-static int
-xxCmapInstalled(ColormapPtr pmap)
-{
- xxScrPriv(pmap->pScreen);
- int i;
-
- for (i = 0; i < pScrPriv->numInstalledColormaps; i++)
- if (pScrPriv->InstalledCmaps[i] == pmap)
- break;
- if (i == pScrPriv->numInstalledColormaps) /* not installed */
- return -1;
- return i;
-}
-
-static void
-xxInstalledCmapDelete(ScreenPtr pScreen, int num)
-{
- xxScrPriv(pScreen);
- int i;
-
- pScrPriv->numInstalledColormaps--;
-
- for (i = num; i < pScrPriv->numInstalledColormaps; i++)
- pScrPriv->InstalledCmaps[i] = pScrPriv->InstalledCmaps[i+1];
-}
-
-static void
-xxDestroyColormap(ColormapPtr pmap)
-{
- xxScrPriv(pmap->pScreen);
- xxCmapPriv(pmap);
-
- if (pCmapPriv != (pointer) -1) {
- xxCmapPrivPtr tmpCmapPriv = pScrPriv->Cmaps;
- xxCmapPrivPtr *prevCmapPriv = &pScrPriv->Cmaps;
- int n;
-
- DBG("DestroyColormap\n");
-
- if ((n = xxCmapInstalled(pmap)) != -1)
- xxInstalledCmapDelete(pmap->pScreen,n);
-
- while (tmpCmapPriv) {
- if (tmpCmapPriv->pmap == pmap) {
- *prevCmapPriv = tmpCmapPriv->next;
- break;
- }
- prevCmapPriv = &tmpCmapPriv->next;
- tmpCmapPriv = tmpCmapPriv->next;
- }
-
- xfree(pCmapPriv->cmap);
- xfree(pCmapPriv);
- }
-
- unwrap(pScrPriv,pmap->pScreen, DestroyColormap);
- pmap->pScreen->DestroyColormap(pmap);
- wrap(pScrPriv,pmap->pScreen,DestroyColormap,xxDestroyColormap);
-}
-
-#define Shift(v,d) ((d) < 0 ? ((v) >> (-d)) : ((v) << (d)))
-
-static int
-xxComputeCmapShift (unsigned long mask)
-{
- int shift;
- unsigned long bit;
-
- shift = 16;
- bit = 0x80000000;
- while (!(mask & bit))
- {
- shift--;
- bit >>= 1;
- }
- return shift;
-}
-
-static void
-xxStoreColors(ColormapPtr pmap, int nColors, xColorItem *pColors)
-{
- xxScrPriv(pmap->pScreen);
- xxCmapPriv(pmap);
-
- if (pCmapPriv != (pointer) -1) {
-
- xColorItem *expanddefs;
- int i;
- VisualPtr bVisual;
- int rs, gs, bs;
-
- if (nColors == 0) return;
-
- DBG("StoreColors\n");
-
- expanddefs = xalloc(sizeof(xColorItem)
- * (1 << pScrPriv->myDepth));
- if (!expanddefs) return;
-
- bVisual = pScrPriv->bVisual;
-
- DBG("StoreColors\n");
-
- rs = xxComputeCmapShift(bVisual->redMask);
- gs = xxComputeCmapShift(bVisual->greenMask);
- bs = xxComputeCmapShift(bVisual->blueMask);
-
- if ((pmap->pVisual->class | DynamicClass) == DirectColor) {
- nColors = miExpandDirectColors(pmap, nColors, pColors, expanddefs);
- pColors = expanddefs;
- }
-
- for (i = 0; i < nColors; i++) {
- DBG_ARGS(("index: %i r 0x%x g 0x%x b 0x%x\n", pColors->pixel,
- pColors->red, pColors->green, pColors->blue));
- pCmapPriv->cmap[pColors->pixel] = MARK_DIRTY
- | (Shift(pColors->red, rs) & bVisual->redMask)
- | (Shift(pColors->green, gs) & bVisual->greenMask)
- | (Shift(pColors->blue, bs) & bVisual->blueMask);
- pColors++;
- }
-
- xfree(expanddefs);
-
- pCmapPriv->dirty = TRUE;
- pScrPriv->colormapDirty = TRUE;
-
- return;
- }
-
- unwrap(pScrPriv,pmap->pScreen, StoreColors);
- pmap->pScreen->StoreColors(pmap,nColors,pColors);
- wrap(pScrPriv,pmap->pScreen,StoreColors,xxStoreColors);
-}
-
-static void
-xxInstallColormap(ColormapPtr pmap)
-{
- int i;
- xxScrPriv(pmap->pScreen);
- xxCmapPriv(pmap);
-
- if (pCmapPriv != (pointer) -1) {
- Pixel *pixels;
- xrgb *colors;
- int i;
- VisualPtr pVisual;
- xColorItem *defs;
-
- DBG("InstallColormap\n");
-
- if (xxCmapInstalled(pmap) != -1)
- return;
-
- if (!pScrPriv->numInstalledColormaps) {
- unwrap(pScrPriv,pmap->pScreen, InstallColormap);
- pmap->pScreen->InstallColormap(pScrPriv->baseCmap);
- wrap(pScrPriv,pmap->pScreen,InstallColormap,xxInstallColormap);
- }
-
- pixels = xalloc(sizeof(Pixel) * (1 << pScrPriv->myDepth));
- colors = xalloc(sizeof(xrgb) * (1 << pScrPriv->myDepth));
- defs = xalloc(sizeof(xColorItem) * (1 << pScrPriv->myDepth));
-
- if (!pixels || !colors)
- return;
-
- /* if we have more than max installed delete the oldest */
- if (pScrPriv->numInstalledColormaps == MAX_NUM_XX_INSTALLED_CMAPS)
- xxInstalledCmapDelete(pmap->pScreen,0);
-
- pScrPriv->InstalledCmaps[pScrPriv->numInstalledColormaps] = pmap;
- pScrPriv->numInstalledColormaps++;
-
- pVisual = pScrPriv->bVisual;
-
- for (i = 0; i < (1 << pScrPriv->myDepth); i++)
- pixels[i] = i;
-
- QueryColors (pmap, (1 << pScrPriv->myDepth), pixels, colors);
-
- for (i = 0; i < (1 << pScrPriv->myDepth); i++) {
- defs[i].pixel = pixels[i];
- defs[i].red = colors[i].red;
- defs[i].green = colors[i].green;
- defs[i].blue = colors[i].blue;
- defs[i].flags = DoRed|DoGreen|DoBlue;
- }
- xxStoreColors(pmap,(1 << pScrPriv->myDepth),defs);
-
- xfree(pixels);
- xfree(colors);
- xfree(defs);
-
- return;
- }
-
- for (i = pScrPriv->numInstalledColormaps; i ; i--)
- WalkTree(pmap->pScreen, TellLostMap,
- (char *)&pScrPriv->InstalledCmaps[i-1]->mid);
-
- pScrPriv->numInstalledColormaps = 0;
-
- unwrap(pScrPriv,pmap->pScreen, InstallColormap);
- pmap->pScreen->InstallColormap(pmap);
- wrap(pScrPriv,pmap->pScreen,InstallColormap,xxInstallColormap);
-}
-
-static void
-xxUninstallColormap(ColormapPtr pmap)
-{
- xxScrPriv(pmap->pScreen);
- xxCmapPriv(pmap);
-
- if (pCmapPriv != (pointer) -1) {
- int num;
-
- if ((num = xxCmapInstalled(pmap)) == -1)
- return;
-
- DBG("UninstallColormap\n");
- xxInstalledCmapDelete(pmap->pScreen,num);
-
- return;
- }
-
- unwrap(pScrPriv,pmap->pScreen, UninstallColormap);
- pmap->pScreen->UninstallColormap(pmap);
- wrap(pScrPriv,pmap->pScreen,UninstallColormap,xxUninstallColormap);
-
-}
-
-static int
-xxListInstalledColormaps(ScreenPtr pScreen, Colormap *pCmapIds)
-{
- int n,i;
- xxScrPriv(pScreen);
-
- unwrap(pScrPriv,pScreen, ListInstalledColormaps);
- n = pScreen->ListInstalledColormaps(pScreen, pCmapIds);
- wrap (pScrPriv,pScreen,ListInstalledColormaps,xxListInstalledColormaps);
-
- pCmapIds += n;
-
- for (i = 0; i < pScrPriv->numInstalledColormaps; i++) {
- *pCmapIds++ = pScrPriv->InstalledCmaps[i]->mid;
- n++;
- }
-
- return n;
-}
-
-static Bool
-xxCreateWindow(WindowPtr pWin)
-{
- xxScrPriv(pWin->drawable.pScreen);
-
- if (pWin->drawable.class != InputOutput
- || pScrPriv->myDepth != pWin->drawable.depth) {
- Bool ret;
- DBG("CreateWindow NoPseudo\n");
- unwrap (pScrPriv, pWin->drawable.pScreen, CreateWindow);
- ret = pWin->drawable.pScreen->CreateWindow(pWin);
- wrap(pScrPriv, pWin->drawable.pScreen, CreateWindow, xxCreateWindow);
-
- return ret;
- }
-
- DBG("CreateWindow\n");
-
- dixSetPrivate(&pWin->devPrivates, fbGetWinPrivateKey(), pScrPriv->pPixmap);
- PRINT_RECTS(pScrPriv->region);
- if (!pWin->parent) {
- REGION_EMPTY (pWin->drawable.pScreen, &pScrPriv->region);
- }
- PRINT_RECTS(pScrPriv->region);
-
- return TRUE;
-}
-
-static void
-xxWalkChildren(WindowPtr pWin, RegionPtr pReg, PixmapPtr pPixmap)
-{
-
- WindowPtr pCurWin = pWin;
-
- do {
- if (fbGetWindowPixmap(pCurWin) == pPixmap) {
- DBG("WalkWindow Add\n");
- REGION_UNION(pWin->drawable.pScreen,pReg,pReg,
- &pCurWin->borderClip);
- } else {
- DBG("WalkWindow Sub\n");
- REGION_SUBTRACT(pWin->drawable.pScreen,pReg,pReg,
- &pCurWin->borderClip);
- }
- if (pCurWin->lastChild)
- xxWalkChildren(pCurWin->lastChild,pReg, pPixmap);
- } while ((pCurWin = pCurWin->prevSib));
-}
-
-static void
-xxPickMyWindows(WindowPtr pWin, RegionPtr pRgn)
-{
- ScreenPtr pScreen = pWin->drawable.pScreen;
- xxScrPriv(pScreen);
-
- if (fbGetWindowPixmap(pWin) == pScrPriv->pPixmap) {
- REGION_UNION(pWin->drawable.pScreen,pRgn,pRgn,&pWin->borderClip);
- }
- if (pWin->lastChild)
- xxWalkChildren(pWin->lastChild,pRgn,pScrPriv->pPixmap);
-}
-
-static void
-xxCopyWindow(WindowPtr pWin,
- DDXPointRec ptOldOrg,
- RegionPtr prgnSrc)
-{
- ScreenPtr pScreen = pWin->drawable.pScreen;
- xxScrPriv(pScreen);
- RegionRec rgn;
- RegionRec rgn_new;
- int dx, dy;
- PixmapPtr pPixmap = fbGetWindowPixmap(pWin);
-
- DBG("xxCopyWindow\n");
-
- dx = ptOldOrg.x - pWin->drawable.x;
- dy = ptOldOrg.y - pWin->drawable.y;
-
- REGION_NULL(pScreen, &rgn_new);
- REGION_UNION(pScreen, &rgn_new,&rgn_new,prgnSrc);
- REGION_TRANSLATE(pScreen,&rgn_new,-dx,-dy);
-
- REGION_NULL(pScreen, &rgn);
- xxPickMyWindows(pWin,&rgn);
-
- unwrap (pScrPriv, pScreen, CopyWindow);
- dixSetPrivate(&pWin->devPrivates, fbGetWinPrivateKey(),
- fbGetScreenPixmap(pScreen));
- pScreen->CopyWindow(pWin, ptOldOrg, prgnSrc);
- dixSetPrivate(&pWin->devPrivates, fbGetWinPrivateKey(), pPixmap);
- wrap(pScrPriv, pScreen, CopyWindow, xxCopyWindow);
-
- REGION_INTERSECT(pScreen,&rgn,&rgn,&rgn_new);
- if (REGION_NOTEMPTY (pScreen,&rgn)) {
- fbCopyRegion(&pScrPriv->pPixmap->drawable,&pScrPriv->pPixmap->drawable,
- 0,&rgn,dx,dy,fbCopyWindowProc,0,(void*)0);
- REGION_TRANSLATE(pScreen,&rgn,dx,dy);
- REGION_INTERSECT(pScreen,&rgn_new,&pScrPriv->region,&rgn);
- REGION_SUBTRACT(pScreen,&pScrPriv->region,&pScrPriv->region,&rgn);
- REGION_TRANSLATE(pScreen,&rgn_new,-dx,-dy);
- REGION_UNION(pScreen,&pScrPriv->region,&pScrPriv->region,&rgn_new);
- }
-#if 1
- REGION_UNINIT(pScreen,&rgn_new);
- REGION_UNINIT(pScreen,&rgn);
-#endif
-}
-
-static void
-xxWindowExposures (WindowPtr pWin,
- RegionPtr prgn,
- RegionPtr other_exposed)
-{
- xxScrPriv(pWin->drawable.pScreen);
-
- if (fbGetWindowPixmap(pWin) == pScrPriv->pPixmap) {
- DBG("WindowExposures\n");
- PRINT_RECTS(pScrPriv->region);
- REGION_UNION(pWin->drawable.pScreen,&pScrPriv->region,
- &pScrPriv->region,
- prgn);
- PRINT_RECTS(pScrPriv->region);
- } else {
- DBG("WindowExposures NonPseudo\n");
- PRINT_RECTS(pScrPriv->region);
- REGION_SUBTRACT(pWin->drawable.pScreen,&pScrPriv->region,
- &pScrPriv->region,
- prgn);
- PRINT_RECTS(pScrPriv->region);
- }
- unwrap (pScrPriv, pWin->drawable.pScreen, WindowExposures);
- pWin->drawable.pScreen->WindowExposures(pWin, prgn, other_exposed);
- wrap(pScrPriv, pWin->drawable.pScreen, WindowExposures, xxWindowExposures);
-}
-
-static void
-xxCopyPseudocolorRegion(ScreenPtr pScreen, RegionPtr pReg,
- xxCmapPrivPtr pCmapPriv)
-{
- xxScrPriv(pScreen);
- CARD32 mask = (1 << pScrPriv->myDepth) - 1;
- int num = REGION_NUM_RECTS(pReg);
- BoxPtr pbox = REGION_RECTS(pReg);
- int width, height;
- CARD8 *src;
- CARD16 *dst, *dst_base;
- int dst_stride;
- register CARD32 *cmap = pCmapPriv->cmap;
- register CARD8 *s;
- register CARD16 *d;
- int w;
-
- fbPrepareAccess((DrawablePtr)pScreen->devPrivate);
-
- dst_base = (CARD16*) ((PixmapPtr)pScreen->devPrivate)->devPrivate.ptr;
- dst_stride = (int)((PixmapPtr)pScreen->devPrivate)->devKind
- / sizeof (CARD16);
-
- while (num--) {
- height = pbox->y2 - pbox->y1;
- width = pbox->x2 - pbox->x1;
-
- src = (unsigned char *) pScrPriv->pBits
- + (pbox->y1 * pScreen->width) + pbox->x1;
- dst = dst_base + (pbox->y1 * dst_stride) + pbox->x1;
- while (height--) {
- w = width;
- s = src;
- d = dst;
-
- while(w--) {
- *(d++) = (CARD16)*(cmap + ((*(s++)) & mask));
- }
- src += pScreen->width;
- dst += dst_stride;
- }
- pbox++;
- }
-
- fbFinishAccess(&((PixmapPtr)pScreen->devPrivate)->drawable);
-}
-
-static void
-xxUpdateCmapPseudocolorRegion(ScreenPtr pScreen, RegionPtr pReg,
- xxCmapPrivPtr pCmapPriv)
-{
- xxScrPriv(pScreen);
- CARD32 mask = (1 << pScrPriv->myDepth) - 1;
- int num = REGION_NUM_RECTS(pReg);
- BoxPtr pbox = REGION_RECTS(pReg);
- int width, height;
- CARD8 *src;
- CARD16 *dst, *dst_base;
- int dst_stride;
- register CARD32 val;
- register CARD32 *cmap = pCmapPriv->cmap;
- register CARD8 *s;
- register CARD16 *d;
- int w;
-
- dst_base = (CARD16*) ((PixmapPtr)pScreen->devPrivate)->devPrivate.ptr;
- dst_stride = (int)((PixmapPtr)pScreen->devPrivate)->devKind
- / sizeof (CARD16);
-
- while (num--) {
-
- height = pbox->y2 - pbox->y1;
- width = pbox->x2 - pbox->x1;
-
- src = (unsigned char *) pScrPriv->pBits
- + (pbox->y1 * pScreen->width) + pbox->x1;
- dst = dst_base + (pbox->y1 * dst_stride) + pbox->x1;
- while (height--) {
- w = width;
- s = src;
- d = dst;
- while(w--) {
- val = *(cmap + ((*(s++)) & mask));
- if (val & MARK_DIRTY) {
- *d = (CARD16) val;
- }
- d++;
- }
- src += pScreen->width;
- dst += dst_stride;
- }
- pbox++;
- }
-}
-
-static void
-xxGetWindowRegion(WindowPtr pWin,RegionPtr winreg)
-{
- REGION_NULL(pWin->drawable.pScreen,winreg);
- /* get visible part of the border ...Argh */
- REGION_SUBTRACT(pWin->drawable.pScreen,winreg,&pWin->borderSize,
- &pWin->winSize);
- REGION_INTERSECT(pWin->drawable.pScreen,winreg,winreg,
- &pWin->borderClip);
- /* add window interior excluding children */
- REGION_UNION(pWin->drawable.pScreen,winreg,winreg,
- &pWin->clipList);
-}
-
-static int
-xxUpdateRegion(WindowPtr pWin, pointer unused)
-{
- ScreenPtr pScreen = pWin->drawable.pScreen;
- xxScrPriv(pScreen);
- ColormapPtr pmap = (pointer) -1;
- RegionRec winreg, rgni;
-
- if (pScrPriv->myDepth == pWin->drawable.depth) {
- xxCmapPrivPtr pCmapPriv = (pointer)-1;
- xxGetWindowRegion(pWin,&winreg);
-
- if (pScrPriv->colormapDirty) {
-
- pmap = (ColormapPtr)LookupIDByType(wColormap(pWin),RT_COLORMAP);
- if (!pmap)
- goto CONTINUE; /* return ? */
-
- pCmapPriv = xxGetCmapPriv(pmap);
- if (pCmapPriv == (pointer) -1)
- return WT_WALKCHILDREN;
- if (!pCmapPriv->dirty)
- goto CONTINUE;
-
- REGION_NULL (pScreen, &rgni);
- /* This will be taken care of when damaged regions are updated */
- REGION_SUBTRACT(pScreen, &rgni, &winreg, &pScrPriv->region);
- if (REGION_NOTEMPTY (pScreen,&rgni))
- xxUpdateCmapPseudocolorRegion(pScreen,&rgni, pCmapPriv);
- }
- CONTINUE:
-
- REGION_NULL (pScreen, &rgni);
- REGION_INTERSECT (pScreen, &rgni, &winreg, &pScrPriv->region);
-
- if (REGION_NOTEMPTY (pScreen,&rgni)) {
- if (pmap == (pointer) -1) {
- pmap =
- (ColormapPtr)LookupIDByType(wColormap(pWin),RT_COLORMAP);
- if (!pmap) /* return ? */
- pmap = (ColormapPtr)LookupIDByType(pScreen->defColormap,
- RT_COLORMAP);
- pCmapPriv = xxGetCmapPriv(pmap);
- }
-
- if (pCmapPriv != (pointer)-1)
- xxCopyPseudocolorRegion(pScreen,&rgni, pCmapPriv);
- REGION_SUBTRACT(pScreen, &pScrPriv->region, &pScrPriv->region,
- &rgni);
- }
-#if 1
- REGION_UNINIT(pScreen,&rgni);
- REGION_UNINIT(pScreen,&winreg);
-#endif
- }
- return WT_WALKCHILDREN;
-}
-
-
-static void
-xxUpdateFb(ScreenPtr pScreen)
-{
- xxScrPriv(pScreen);
-
- DBG("Update FB\n");
- PRINT_RECTS(pScrPriv->region);
-
- if (pScrPriv->sync)
- pScrPriv->sync(pScreen); /*@!@*/
-
- WalkTree(pScreen,xxUpdateRegion,NULL);
-#if 0
- if (REGION_NOTEMPTY (pScreen,&pScrPriv->region)) {
- ColormapPtr pmap = (pointer) -1;
- xxCmapPrivPtr pCmapPriv;
-
- pmap = (ColormapPtr)LookupIDByType(pScreen->defColormap,
- RT_COLORMAP);
- pCmapPriv = xxGetCmapPriv(pmap);
- if (pCmapPriv != (pointer)-1)
- xxCopyPseudocolorRegion(pScreen,&pScrPriv->region, pCmapPriv);
- REGION_SUBTRACT(pScreen, &pScrPriv->region, &pScrPriv->region,
- &pScrPriv->region);
- }
-#endif
- if (pScrPriv->colormapDirty) {
- xxCmapPrivPtr pCmap = pScrPriv->Cmaps;
-
- while (pCmap) {
- int j;
-
- if (pCmap->dirty) {
- for (j = 0; j < (1 << pScrPriv->myDepth); j++)
- pCmap->cmap[j] &= ~MARK_DIRTY;
- pCmap->dirty = FALSE;
- }
- pCmap = pCmap->next;
- }
- pScrPriv->colormapDirty = FALSE;
- }
-}
-
-static void
-xxBlockHandler (pointer data,
- OSTimePtr pTimeout,
- pointer pRead)
-{
- ScreenPtr pScreen = (ScreenPtr) data;
- xxScrPriv(pScreen);
-
- if (REGION_NOTEMPTY (pScreen,&pScrPriv->region) || pScrPriv->colormapDirty)
- xxUpdateFb (pScreen);
-}
-
-static void
-xxWakeupHandler (pointer data, int i, pointer LastSelectMask)
-{
-}
-
-Bool
-xxSetup(ScreenPtr pScreen, int myDepth, int baseDepth, char* addr, xxSyncFunc sync)
-{
- xxScrPrivPtr pScrPriv;
- DepthPtr pDepths;
- ColormapPtr pDefMap;
- int i,j,k;
-
-#ifdef RENDER
- PictureScreenPtr ps = GetPictureScreenIfSet(pScreen);
-#endif
-
- if (!dixRequestPrivate(xxGCPrivateKey, sizeof (xxGCPrivRec)))
- return FALSE;
-
- pScrPriv = (xxScrPrivPtr) xalloc (sizeof (xxScrPrivRec));
- if (!pScrPriv)
- return FALSE;
-
- if (baseDepth)
- pScrPriv->depth = baseDepth;
- else {
- pDepths = pScreen->allowedDepths;
- for (i = 0; i < pScreen->numDepths; i++, pDepths++)
- if (pDepths->depth != myDepth)
- pScrPriv->depth = pDepths->depth;
- }
- if (!pScrPriv->depth)
- return FALSE;
-
- pDepths = pScreen->allowedDepths;
- for (i = 0; i < pScreen->numDepths; i++, pDepths++)
- if (pDepths->depth == pScrPriv->depth) {
- for (j = 0; i < pDepths->numVids; j++) {
- for (k = 0; k < pScreen->numVisuals; k++) {
- if (pScreen->visuals[k].vid
- == pDepths[i].vids[j]
- && pScreen->visuals[k].class == TrueColor) {
- pScrPriv->bVisual = &pScreen->visuals[k];
- goto DONE;
- }
- }
- }
- }
-
- DONE:
- if (!pScrPriv->bVisual)
- return FALSE;
-
- pScrPriv->myDepth = myDepth;
- pScrPriv->numInstalledColormaps = 0;
- pScrPriv->colormapDirty = FALSE;
- pScrPriv->Cmaps = NULL;
- pScrPriv->sync = sync;
-
- pScreen->maxInstalledCmaps += MAX_NUM_XX_INSTALLED_CMAPS;
- pScrPriv->InstalledCmaps = xcalloc(MAX_NUM_XX_INSTALLED_CMAPS,
- sizeof(ColormapPtr));
- if (!pScrPriv->InstalledCmaps)
- return FALSE;
-
-
- if (!RegisterBlockAndWakeupHandlers (xxBlockHandler,
- xxWakeupHandler,
- (pointer) pScreen))
- return FALSE;
-
- wrap (pScrPriv, pScreen, CloseScreen, xxCloseScreen);
- wrap (pScrPriv, pScreen, CreateScreenResources, xxCreateScreenResources);
- wrap (pScrPriv, pScreen, CreateWindow, xxCreateWindow);
- wrap (pScrPriv, pScreen, CopyWindow, xxCopyWindow);
-#if 0 /* can we leave this out even with backing store enabled ? */
- wrap (pScrPriv, pScreen, WindowExposures, xxWindowExposures);
-#endif
- wrap (pScrPriv, pScreen, CreateGC, xxCreateGC);
- wrap (pScrPriv, pScreen, CreateColormap, xxCreateColormap);
- wrap (pScrPriv, pScreen, DestroyColormap, xxDestroyColormap);
- wrap (pScrPriv, pScreen, InstallColormap, xxInstallColormap);
- wrap (pScrPriv, pScreen, UninstallColormap, xxUninstallColormap);
- wrap (pScrPriv, pScreen, ListInstalledColormaps, xxListInstalledColormaps);
- wrap (pScrPriv, pScreen, StoreColors, xxStoreColors);
-#ifdef RENDER
- if (ps) {
- wrap (pScrPriv, ps, Glyphs, xxGlyphs);
- wrap (pScrPriv, ps, Composite, xxComposite);
- }
-#endif
- pScrPriv->addr = addr;
- dixSetPrivate(&pScreen->devPrivates, xxScrPrivateKey, pScrPriv);
-
- pDefMap = (ColormapPtr) LookupIDByType(pScreen->defColormap, RT_COLORMAP);
- if (!xxInitColormapPrivate(pDefMap))
- return FALSE;
-
- return TRUE;
-}
-
-GCFuncs xxGCFuncs = {
- xxValidateGC, xxChangeGC, xxCopyGC, xxDestroyGC,
- xxChangeClip, xxDestroyClip, xxCopyClip
-};
-
-static GCOps xxGCOps = {
- xxFillSpans, xxSetSpans,
- xxPutImage, xxCopyArea,
- xxCopyPlane, xxPolyPoint,
- xxPolylines, xxPolySegment,
- xxPolyRectangle, xxPolyArc,
- xxFillPolygon, xxPolyFillRect,
- xxPolyFillArc, xxPolyText8,
- xxPolyText16, xxImageText8,
- xxImageText16, xxImageGlyphBlt,
- xxPolyGlyphBlt, xxPushPixels,
- {NULL} /* devPrivate */
-};
-
-#define IS_VISIBLE(pDraw) (pDraw->type == DRAWABLE_WINDOW \
- && (fbGetWindowPixmap((WindowPtr) pDraw) == pScrPriv->pPixmap))
-
-#define TRANSLATE_BOX(box, pDraw) { \
- box.x1 += pDraw->x; \
- box.x2 += pDraw->x; \
- box.y1 += pDraw->y; \
- box.y2 += pDraw->y; \
- }
-
-#define TRIM_BOX(box, pGC) { \
- BoxPtr extents = &pGC->pCompositeClip->extents;\
- if(box.x1 < extents->x1) box.x1 = extents->x1; \
- if(box.x2 > extents->x2) box.x2 = extents->x2; \
- if(box.y1 < extents->y1) box.y1 = extents->y1; \
- if(box.y2 > extents->y2) box.y2 = extents->y2; \
- }
-
-#define BOX_NOT_EMPTY(box) \
- (((box.x2 - box.x1) > 0) && ((box.y2 - box.y1) > 0))
-
-
-#define _ADD_BOX(box,pGC) {\
- if (BOX_NOT_EMPTY(box)) { \
- RegionRec region; \
- ScreenPtr pScreen = pGC->pScreen;\
- REGION_INIT (pScreen, &region, &box, 1); \
- REGION_INTERSECT(pScreen,&region,&region,\
- (pGC)->pCompositeClip);\
- if (REGION_NOTEMPTY(pScreen,&region)) { \
- xxScrPriv(pScreen);\
- PRINT_RECTS(pScrPriv->region);\
- REGION_UNION(pScreen,&pScrPriv->region,&pScrPriv->region,&region);\
- PRINT_RECTS(pScrPriv->region);\
- REGION_UNINIT(pScreen,&region);\
- }\
- }\
-}
-
-#define TRANSLATE_AND_ADD_BOX(box,pGC) {\
- TRANSLATE_BOX(box,pDraw); \
- TRIM_BOX(box,pGC); \
- _ADD_BOX(box,pGC); \
-}
-
-#define ADD_BOX(box,pGC) { \
- TRIM_BOX(box,pGC); \
- _ADD_BOX(box,pGC); \
-}
-
-#define XX_GC_FUNC_PROLOGUE(pGC) \
- xxGCPriv(pGC); \
- unwrap(pGCPriv, pGC, funcs); \
- if (pGCPriv->ops) unwrap(pGCPriv, pGC, ops)
-
-#define XX_GC_FUNC_EPILOGUE(pGC) \
- wrap(pGCPriv, pGC, funcs, &xxGCFuncs); \
- if (pGCPriv->ops) wrap(pGCPriv, pGC, ops, &xxGCOps)
-
-static Bool
-xxCreateGC(GCPtr pGC)
-{
- ScreenPtr pScreen = pGC->pScreen;
- xxScrPriv(pScreen);
- xxGCPriv(pGC);
- Bool ret;
-
- unwrap (pScrPriv, pScreen, CreateGC);
- if((ret = (*pScreen->CreateGC) (pGC))) {
- pGCPriv->ops = NULL;
- pGCPriv->funcs = pGC->funcs;
- pGC->funcs = &xxGCFuncs;
- }
- wrap (pScrPriv, pScreen, CreateGC, xxCreateGC);
-
- return ret;
-}
-
-static void
-xxValidateGC(
- GCPtr pGC,
- unsigned long changes,
- DrawablePtr pDraw
-){
- XX_GC_FUNC_PROLOGUE (pGC);
- (*pGC->funcs->ValidateGC)(pGC, changes, pDraw);
- if(pDraw->type == DRAWABLE_WINDOW)
- pGCPriv->ops = pGC->ops; /* just so it's not NULL */
- else
- pGCPriv->ops = NULL;
- XX_GC_FUNC_EPILOGUE (pGC);
-}
-
-static void
-xxDestroyGC(GCPtr pGC)
-{
- XX_GC_FUNC_PROLOGUE (pGC);
- (*pGC->funcs->DestroyGC)(pGC);
- XX_GC_FUNC_EPILOGUE (pGC);
-}
-
-static void
-xxChangeGC (
- GCPtr pGC,
- unsigned long mask
-){
- XX_GC_FUNC_PROLOGUE (pGC);
- (*pGC->funcs->ChangeGC) (pGC, mask);
- XX_GC_FUNC_EPILOGUE (pGC);
-}
-
-static void
-xxCopyGC (
- GCPtr pGCSrc,
- unsigned long mask,
- GCPtr pGCDst
-){
- XX_GC_FUNC_PROLOGUE (pGCDst);
- (*pGCDst->funcs->CopyGC) (pGCSrc, mask, pGCDst);
- XX_GC_FUNC_EPILOGUE (pGCDst);
-}
-
-static void
-xxChangeClip (
- GCPtr pGC,
- int type,
- pointer pvalue,
- int nrects
-){
- XX_GC_FUNC_PROLOGUE (pGC);
- (*pGC->funcs->ChangeClip) (pGC, type, pvalue, nrects);
- XX_GC_FUNC_EPILOGUE (pGC);
-}
-
-static void
-xxCopyClip(GCPtr pgcDst, GCPtr pgcSrc)
-{
- XX_GC_FUNC_PROLOGUE (pgcDst);
- (* pgcDst->funcs->CopyClip)(pgcDst, pgcSrc);
- XX_GC_FUNC_EPILOGUE (pgcDst);
-}
-
-static void
-xxDestroyClip(GCPtr pGC)
-{
- XX_GC_FUNC_PROLOGUE (pGC);
- (* pGC->funcs->DestroyClip)(pGC);
- XX_GC_FUNC_EPILOGUE (pGC);
-}
-
-#define XX_GC_OP_PROLOGUE(pGC,pDraw) \
- xxScrPriv(pDraw->pScreen); \
- xxGCPriv(pGC); \
- GCFuncs *oldFuncs = pGC->funcs; \
- unwrap(pGCPriv, pGC, funcs); \
- unwrap(pGCPriv, pGC, ops); \
-
-#define XX_GC_OP_EPILOGUE(pGC,pDraw) \
- wrap(pGCPriv, pGC, funcs, oldFuncs); \
- wrap(pGCPriv, pGC, ops, &xxGCOps)
-
-static void
-xxFillSpans(
- DrawablePtr pDraw,
- GC *pGC,
- int nInit,
- DDXPointPtr pptInit,
- int *pwidthInit,
- int fSorted
-){
- XX_GC_OP_PROLOGUE(pGC, pDraw);
-
- if(IS_VISIBLE(pDraw) && nInit) {
- DDXPointPtr ppt = pptInit;
- int *pwidth = pwidthInit;
- int i = nInit;
- BoxRec box;
-
- DBG("FillSpans\n");
- box.x1 = ppt->x;
- box.x2 = box.x1 + *pwidth;
- box.y2 = box.y1 = ppt->y;
-
- while(--i) {
- ppt++;
- pwidthInit++;
- if(box.x1 > ppt->x) box.x1 = ppt->x;
- if(box.x2 < (ppt->x + *pwidth))
- box.x2 = ppt->x + *pwidth;
- if(box.y1 > ppt->y) box.y1 = ppt->y;
- else if(box.y2 < ppt->y) box.y2 = ppt->y;
- }
-
- box.y2++;
-
- (*pGC->ops->FillSpans)(pDraw, pGC, nInit, pptInit, pwidthInit, fSorted);
-
-
- TRANSLATE_AND_ADD_BOX(box, pGC);
- } else
- (*pGC->ops->FillSpans)(pDraw, pGC, nInit, pptInit, pwidthInit, fSorted);
-
- XX_GC_OP_EPILOGUE(pGC, pDraw);
-}
-
-static void
-xxSetSpans(
- DrawablePtr pDraw,
- GCPtr pGC,
- char *pcharsrc,
- DDXPointPtr pptInit,
- int *pwidthInit,
- int nspans,
- int fSorted
-){
- XX_GC_OP_PROLOGUE(pGC, pDraw);
-
- if(IS_VISIBLE(pDraw) && nspans) {
- DDXPointPtr ppt = pptInit;
- int *pwidth = pwidthInit;
- int i = nspans;
- BoxRec box;
-
- DBG("SetSpans\n");
- box.x1 = ppt->x;
- box.x2 = box.x1 + *pwidth;
- box.y2 = box.y1 = ppt->y;
-
- while(--i) {
- ppt++;
- pwidth++;
- if(box.x1 > ppt->x) box.x1 = ppt->x;
- if(box.x2 < (ppt->x + *pwidth))
- box.x2 = ppt->x + *pwidth;
- if(box.y1 > ppt->y) box.y1 = ppt->y;
- else if(box.y2 < ppt->y) box.y2 = ppt->y;
- }
-
- box.y2++;
-
- (*pGC->ops->SetSpans)(pDraw, pGC, pcharsrc, pptInit,
- pwidthInit, nspans, fSorted);
-
- TRANSLATE_AND_ADD_BOX(box, pGC);
- } else
- (*pGC->ops->SetSpans)(pDraw, pGC, pcharsrc, pptInit,
- pwidthInit, nspans, fSorted);
-
- XX_GC_OP_EPILOGUE(pGC, pDraw);
-}
-
-static void
-xxPutImage(
- DrawablePtr pDraw,
- GCPtr pGC,
- int depth,
- int x, int y, int w, int h,
- int leftPad,
- int format,
- char *pImage
-){
- XX_GC_OP_PROLOGUE(pGC, pDraw);
- (*pGC->ops->PutImage)(pDraw, pGC, depth, x, y, w, h,
- leftPad, format, pImage);
- XX_GC_OP_EPILOGUE(pGC, pDraw);
- if(IS_VISIBLE(pDraw)) {
- BoxRec box;
-
- DBG("PutImage\n");
- box.x1 = x + pDraw->x;
- box.x2 = box.x1 + w;
- box.y1 = y + pDraw->y;
- box.y2 = box.y1 + h;
-
- ADD_BOX(box, pGC);
- }
-}
-
-static RegionPtr
-xxCopyArea(
- DrawablePtr pSrc,
- DrawablePtr pDst,
- GC *pGC,
- int srcx, int srcy,
- int width, int height,
- int dstx, int dsty
-){
- RegionPtr ret;
- XX_GC_OP_PROLOGUE(pGC, pDst);
- DBG("xxCopyArea\n");
- ret = (*pGC->ops->CopyArea)(pSrc, pDst,
- pGC, srcx, srcy, width, height, dstx, dsty);
- XX_GC_OP_EPILOGUE(pGC, pDst);
-
- if(IS_VISIBLE(pDst)) {
- BoxRec box;
-
- DBG("CopyArea\n");
- box.x1 = dstx + pDst->x;
- box.x2 = box.x1 + width;
- box.y1 = dsty + pDst->y;
- box.y2 = box.y1 + height;
-
- ADD_BOX(box, pGC);
- }
-
- return ret;
-}
-
-static RegionPtr
-xxCopyPlane(
- DrawablePtr pSrc,
- DrawablePtr pDst,
- GCPtr pGC,
- int srcx, int srcy,
- int width, int height,
- int dstx, int dsty,
- unsigned long bitPlane
-){
- RegionPtr ret;
- XX_GC_OP_PROLOGUE(pGC, pDst);
- ret = (*pGC->ops->CopyPlane)(pSrc, pDst,
- pGC, srcx, srcy, width, height, dstx, dsty, bitPlane);
- XX_GC_OP_EPILOGUE(pGC, pDst);
-
- if(IS_VISIBLE(pDst)) {
- BoxRec box;
-
- DBG("CopyPlane\n");
- box.x1 = dstx + pDst->x;
- box.x2 = box.x1 + width;
- box.y1 = dsty + pDst->y;
- box.y2 = box.y1 + height;
-
- ADD_BOX(box, pGC);
- }
-
- return ret;
-}
-
-static void
-xxPolyPoint(
- DrawablePtr pDraw,
- GCPtr pGC,
- int mode,
- int npt,
- xPoint *pptInit
-){
- XX_GC_OP_PROLOGUE(pGC, pDraw);
- (*pGC->ops->PolyPoint)(pDraw, pGC, mode, npt, pptInit);
- XX_GC_OP_EPILOGUE(pGC, pDraw);
-
- if(IS_VISIBLE(pDraw) && npt) {
- BoxRec box;
-
- DBG("PolyPoint\n");
- box.x2 = box.x1 = pptInit->x;
- box.y2 = box.y1 = pptInit->y;
-
- /* this could be slow if the points were spread out */
-
- while(--npt) {
- pptInit++;
- if(box.x1 > pptInit->x) box.x1 = pptInit->x;
- else if(box.x2 < pptInit->x) box.x2 = pptInit->x;
- if(box.y1 > pptInit->y) box.y1 = pptInit->y;
- else if(box.y2 < pptInit->y) box.y2 = pptInit->y;
- }
-
- box.x2++;
- box.y2++;
-
- TRANSLATE_AND_ADD_BOX(box, pGC);
- }
-}
-
-static void
-xxPolylines(
- DrawablePtr pDraw,
- GCPtr pGC,
- int mode,
- int npt,
- DDXPointPtr pptInit
-){
- XX_GC_OP_PROLOGUE(pGC, pDraw);
- (*pGC->ops->Polylines)(pDraw, pGC, mode, npt, pptInit);
- XX_GC_OP_EPILOGUE(pGC, pDraw);
-
-
- if(IS_VISIBLE(pDraw) && npt) {
- BoxRec box;
- int extra = pGC->lineWidth >> 1;
-
- DBG("PolyLine\n");
- box.x2 = box.x1 = pptInit->x;
- box.y2 = box.y1 = pptInit->y;
-
- if(npt > 1) {
- if(pGC->joinStyle == JoinMiter)
- extra = 6 * pGC->lineWidth;
- else if(pGC->capStyle == CapProjecting)
- extra = pGC->lineWidth;
- }
-
- if(mode == CoordModePrevious) {
- int x = box.x1;
- int y = box.y1;
- while(--npt) {
- pptInit++;
- x += pptInit->x;
- y += pptInit->y;
- if(box.x1 > x) box.x1 = x;
- else if(box.x2 < x) box.x2 = x;
- if(box.y1 > y) box.y1 = y;
- else if(box.y2 < y) box.y2 = y;
- }
- } else {
- while(--npt) {
- pptInit++;
- if(box.x1 > pptInit->x) box.x1 = pptInit->x;
- else if(box.x2 < pptInit->x) box.x2 = pptInit->x;
- if(box.y1 > pptInit->y) box.y1 = pptInit->y;
- else if(box.y2 < pptInit->y) box.y2 = pptInit->y;
- }
- }
-
- box.x2++;
- box.y2++;
-
- if(extra) {
- box.x1 -= extra;
- box.x2 += extra;
- box.y1 -= extra;
- box.y2 += extra;
- }
-
- TRANSLATE_AND_ADD_BOX(box, pGC);
- }
-}
-
-static void
-xxPolySegment(
- DrawablePtr pDraw,
- GCPtr pGC,
- int nseg,
- xSegment *pSeg
- ){
- XX_GC_OP_PROLOGUE(pGC, pDraw);
- (*pGC->ops->PolySegment)(pDraw, pGC, nseg, pSeg);
- XX_GC_OP_EPILOGUE(pGC, pDraw);
-
- if(IS_VISIBLE(pDraw) && nseg) {
- BoxRec box;
- int extra = pGC->lineWidth;
-
- DBG("PolySegment\n");
- if(pGC->capStyle != CapProjecting)
- extra >>= 1;
-
- if(pSeg->x2 > pSeg->x1) {
- box.x1 = pSeg->x1;
- box.x2 = pSeg->x2;
- } else {
- box.x2 = pSeg->x1;
- box.x1 = pSeg->x2;
- }
-
- if(pSeg->y2 > pSeg->y1) {
- box.y1 = pSeg->y1;
- box.y2 = pSeg->y2;
- } else {
- box.y2 = pSeg->y1;
- box.y1 = pSeg->y2;
- }
-
- while(--nseg) {
- pSeg++;
- if(pSeg->x2 > pSeg->x1) {
- if(pSeg->x1 < box.x1) box.x1 = pSeg->x1;
- if(pSeg->x2 > box.x2) box.x2 = pSeg->x2;
- } else {
- if(pSeg->x2 < box.x1) box.x1 = pSeg->x2;
- if(pSeg->x1 > box.x2) box.x2 = pSeg->x1;
- }
- if(pSeg->y2 > pSeg->y1) {
- if(pSeg->y1 < box.y1) box.y1 = pSeg->y1;
- if(pSeg->y2 > box.y2) box.y2 = pSeg->y2;
- } else {
- if(pSeg->y2 < box.y1) box.y1 = pSeg->y2;
- if(pSeg->y1 > box.y2) box.y2 = pSeg->y1;
- }
- }
-
- box.x2++;
- box.y2++;
-
- if(extra) {
- box.x1 -= extra;
- box.x2 += extra;
- box.y1 -= extra;
- box.y2 += extra;
- }
-
- TRANSLATE_AND_ADD_BOX(box, pGC);
- }
-}
-
-static void
-xxPolyRectangle(
- DrawablePtr pDraw,
- GCPtr pGC,
- int nRects,
- xRectangle *pRects
-){
- XX_GC_OP_PROLOGUE(pGC, pDraw);
- (*pGC->ops->PolyRectangle)(pDraw, pGC, nRects, pRects);
- XX_GC_OP_EPILOGUE(pGC, pDraw);
-
- if(IS_VISIBLE(pDraw) && nRects)
- {
- BoxRec box;
- int offset1, offset2, offset3;
-
- DBG("PolyRectangle\n");
- offset2 = pGC->lineWidth;
- if(!offset2) offset2 = 1;
- offset1 = offset2 >> 1;
- offset3 = offset2 - offset1;
-
- while(nRects--)
- {
- box.x1 = pRects->x - offset1;
- box.y1 = pRects->y - offset1;
- box.x2 = box.x1 + pRects->width + offset2;
- box.y2 = box.y1 + offset2;
- TRANSLATE_AND_ADD_BOX(box, pGC);
- box.x1 = pRects->x - offset1;
- box.y1 = pRects->y + offset3;
- box.x2 = box.x1 + offset2;
- box.y2 = box.y1 + pRects->height - offset2;
- TRANSLATE_AND_ADD_BOX(box, pGC);
- box.x1 = pRects->x + pRects->width - offset1;
- box.y1 = pRects->y + offset3;
- box.x2 = box.x1 + offset2;
- box.y2 = box.y1 + pRects->height - offset2;
- TRANSLATE_AND_ADD_BOX(box, pGC);
- box.x1 = pRects->x - offset1;
- box.y1 = pRects->y + pRects->height - offset1;
- box.x2 = box.x1 + pRects->width + offset2;
- box.y2 = box.y1 + offset2;
- TRANSLATE_AND_ADD_BOX(box, pGC);
-
- pRects++;
- }
- }
-}
-
-static void
-xxPolyArc(
- DrawablePtr pDraw,
- GCPtr pGC,
- int narcs,
- xArc *parcs
-){
- XX_GC_OP_PROLOGUE(pGC, pDraw);
- (*pGC->ops->PolyArc)(pDraw, pGC, narcs, parcs);
- XX_GC_OP_EPILOGUE(pGC, pDraw);
-
- if(IS_VISIBLE(pDraw) && narcs) {
- int extra = pGC->lineWidth >> 1;
- BoxRec box;
-
- DBG("PolyArc\n");
- box.x1 = parcs->x;
- box.x2 = box.x1 + parcs->width;
- box.y1 = parcs->y;
- box.y2 = box.y1 + parcs->height;
-
- /* should I break these up instead ? */
-
- while(--narcs) {
- parcs++;
- if(box.x1 > parcs->x) box.x1 = parcs->x;
- if(box.x2 < (parcs->x + parcs->width))
- box.x2 = parcs->x + parcs->width;
- if(box.y1 > parcs->y) box.y1 = parcs->y;
- if(box.y2 < (parcs->y + parcs->height))
- box.y2 = parcs->y + parcs->height;
- }
-
- if(extra) {
- box.x1 -= extra;
- box.x2 += extra;
- box.y1 -= extra;
- box.y2 += extra;
- }
-
- box.x2++;
- box.y2++;
-
- TRANSLATE_AND_ADD_BOX(box, pGC);
- }
-}
-
-static void
-xxFillPolygon(
- DrawablePtr pDraw,
- GCPtr pGC,
- int shape,
- int mode,
- int count,
- DDXPointPtr pptInit
-){
- XX_GC_OP_PROLOGUE(pGC, pDraw);
-
- if(IS_VISIBLE(pDraw) && (count > 2)) {
- DDXPointPtr ppt = pptInit;
- int i = count;
- BoxRec box;
-
- DBG("FillPolygon\n");
- box.x2 = box.x1 = ppt->x;
- box.y2 = box.y1 = ppt->y;
-
- if(mode != CoordModeOrigin) {
- int x = box.x1;
- int y = box.y1;
- while(--i) {
- ppt++;
- x += ppt->x;
- y += ppt->y;
- if(box.x1 > x) box.x1 = x;
- else if(box.x2 < x) box.x2 = x;
- if(box.y1 > y) box.y1 = y;
- else if(box.y2 < y) box.y2 = y;
- }
- } else {
- while(--i) {
- ppt++;
- if(box.x1 > ppt->x) box.x1 = ppt->x;
- else if(box.x2 < ppt->x) box.x2 = ppt->x;
- if(box.y1 > ppt->y) box.y1 = ppt->y;
- else if(box.y2 < ppt->y) box.y2 = ppt->y;
- }
- }
-
- box.x2++;
- box.y2++;
-
- (*pGC->ops->FillPolygon)(pDraw, pGC, shape, mode, count, pptInit);
-
- TRANSLATE_AND_ADD_BOX(box, pGC);
- } else
- (*pGC->ops->FillPolygon)(pDraw, pGC, shape, mode, count, pptInit);
-
- XX_GC_OP_EPILOGUE(pGC, pDraw);
-}
-
-static void
-xxPolyFillRect(
- DrawablePtr pDraw,
- GCPtr pGC,
- int nRectsInit,
- xRectangle *pRectsInit
-){
- XX_GC_OP_PROLOGUE(pGC, pDraw);
-
- if(IS_VISIBLE(pDraw) && nRectsInit) {
- BoxRec box;
- xRectangle *pRects = pRectsInit;
- int nRects = nRectsInit;
-
- DBG("PolyFillRect\n");
- box.x1 = pRects->x;
- box.x2 = box.x1 + pRects->width;
- box.y1 = pRects->y;
- box.y2 = box.y1 + pRects->height;
-
- while(--nRects) {
- pRects++;
- if(box.x1 > pRects->x) box.x1 = pRects->x;
- if(box.x2 < (pRects->x + pRects->width))
- box.x2 = pRects->x + pRects->width;
- if(box.y1 > pRects->y) box.y1 = pRects->y;
- if(box.y2 < (pRects->y + pRects->height))
- box.y2 = pRects->y + pRects->height;
- }
-
- /* cfb messes with the pRectsInit so we have to do our
- calculations first */
-
- (*pGC->ops->PolyFillRect)(pDraw, pGC, nRectsInit, pRectsInit);
-
- TRANSLATE_AND_ADD_BOX(box, pGC);
- } else
- (*pGC->ops->PolyFillRect)(pDraw, pGC, nRectsInit, pRectsInit);
-
- XX_GC_OP_EPILOGUE(pGC, pDraw);
-}
-
-static void
-xxPolyFillArc(
- DrawablePtr pDraw,
- GCPtr pGC,
- int narcs,
- xArc *parcs
-){
- XX_GC_OP_PROLOGUE(pGC, pDraw);
- (*pGC->ops->PolyFillArc)(pDraw, pGC, narcs, parcs);
- XX_GC_OP_EPILOGUE(pGC, pDraw);
-
- if(IS_VISIBLE(pDraw) && narcs) {
- BoxRec box;
-
- DBG("PolyFillArc\n");
- box.x1 = parcs->x;
- box.x2 = box.x1 + parcs->width;
- box.y1 = parcs->y;
- box.y2 = box.y1 + parcs->height;
-
- /* should I break these up instead ? */
-
- while(--narcs) {
- parcs++;
- if(box.x1 > parcs->x) box.x1 = parcs->x;
- if(box.x2 < (parcs->x + parcs->width))
- box.x2 = parcs->x + parcs->width;
- if(box.y1 > parcs->y) box.y1 = parcs->y;
- if(box.y2 < (parcs->y + parcs->height))
- box.y2 = parcs->y + parcs->height;
- }
-
- TRANSLATE_AND_ADD_BOX(box, pGC);
- }
-}
-
-static int
-xxPolyText8(
- DrawablePtr pDraw,
- GCPtr pGC,
- int x,
- int y,
- int count,
- char *chars
-){
- int width;
-
- XX_GC_OP_PROLOGUE(pGC, pDraw);
- width = (*pGC->ops->PolyText8)(pDraw, pGC, x, y, count, chars);
- XX_GC_OP_EPILOGUE(pGC, pDraw);
-
- width -= x;
-
- if(IS_VISIBLE(pDraw) && (width > 0)) {
- BoxRec box;
-
- DBG("PolyText8\n");
- /* ugh */
- box.x1 = pDraw->x + x + FONTMINBOUNDS(pGC->font, leftSideBearing);
- box.x2 = pDraw->x + x + FONTMAXBOUNDS(pGC->font, rightSideBearing);
-
- if(count > 1) {
- if(width > 0) box.x2 += width;
- else box.x1 += width;
- }
-
- box.y1 = pDraw->y + y - FONTMAXBOUNDS(pGC->font, ascent);
- box.y2 = pDraw->y + y + FONTMAXBOUNDS(pGC->font, descent);
-
- ADD_BOX(box, pGC);
- }
-
- return (width + x);
-}
-
-static int
-xxPolyText16(
- DrawablePtr pDraw,
- GCPtr pGC,
- int x,
- int y,
- int count,
- unsigned short *chars
-){
- int width;
-
- XX_GC_OP_PROLOGUE(pGC, pDraw);
- width = (*pGC->ops->PolyText16)(pDraw, pGC, x, y, count, chars);
- XX_GC_OP_EPILOGUE(pGC, pDraw);
-
- width -= x;
-
- if(IS_VISIBLE(pDraw) && (width > 0)) {
- BoxRec box;
-
- DBG("PolyText16\n");
- /* ugh */
- box.x1 = pDraw->x + x + FONTMINBOUNDS(pGC->font, leftSideBearing);
- box.x2 = pDraw->x + x + FONTMAXBOUNDS(pGC->font, rightSideBearing);
-
- if(count > 1) {
- if(width > 0) box.x2 += width;
- else box.x1 += width;
- }
-
- box.y1 = pDraw->y + y - FONTMAXBOUNDS(pGC->font, ascent);
- box.y2 = pDraw->y + y + FONTMAXBOUNDS(pGC->font, descent);
-
- ADD_BOX(box, pGC);
- }
-
- return (width + x);
-}
-
-static void
-xxImageText8(
- DrawablePtr pDraw,
- GCPtr pGC,
- int x,
- int y,
- int count,
- char *chars
-){
- XX_GC_OP_PROLOGUE(pGC, pDraw);
- (*pGC->ops->ImageText8)(pDraw, pGC, x, y, count, chars);
- XX_GC_OP_EPILOGUE(pGC, pDraw);
-
- if(IS_VISIBLE(pDraw) && count) {
- int top, bot, Min, Max;
- BoxRec box;
-
- DBG("ImageText8\n");
- top = max(FONTMAXBOUNDS(pGC->font, ascent), FONTASCENT(pGC->font));
- bot = max(FONTMAXBOUNDS(pGC->font, descent), FONTDESCENT(pGC->font));
-
- Min = count * FONTMINBOUNDS(pGC->font, characterWidth);
- if(Min > 0) Min = 0;
- Max = count * FONTMAXBOUNDS(pGC->font, characterWidth);
- if(Max < 0) Max = 0;
-
- /* ugh */
- box.x1 = pDraw->x + x + Min +
- FONTMINBOUNDS(pGC->font, leftSideBearing);
- box.x2 = pDraw->x + x + Max +
- FONTMAXBOUNDS(pGC->font, rightSideBearing);
-
- box.y1 = pDraw->y + y - top;
- box.y2 = pDraw->y + y + bot;
-
- ADD_BOX(box, pGC);
- }
-}
-
-static void
-xxImageText16(
- DrawablePtr pDraw,
- GCPtr pGC,
- int x,
- int y,
- int count,
- unsigned short *chars
-){
- XX_GC_OP_PROLOGUE(pGC, pDraw);
- (*pGC->ops->ImageText16)(pDraw, pGC, x, y, count, chars);
- XX_GC_OP_EPILOGUE(pGC, pDraw);
-
- if(IS_VISIBLE(pDraw) && count) {
- int top, bot, Min, Max;
- BoxRec box;
-
- DBG("ImageText16\n");
- top = max(FONTMAXBOUNDS(pGC->font, ascent), FONTASCENT(pGC->font));
- bot = max(FONTMAXBOUNDS(pGC->font, descent), FONTDESCENT(pGC->font));
-
- Min = count * FONTMINBOUNDS(pGC->font, characterWidth);
- if(Min > 0) Min = 0;
- Max = count * FONTMAXBOUNDS(pGC->font, characterWidth);
- if(Max < 0) Max = 0;
-
- /* ugh */
- box.x1 = pDraw->x + x + Min +
- FONTMINBOUNDS(pGC->font, leftSideBearing);
- box.x2 = pDraw->x + x + Max +
- FONTMAXBOUNDS(pGC->font, rightSideBearing);
-
- box.y1 = pDraw->y + y - top;
- box.y2 = pDraw->y + y + bot;
-
- ADD_BOX(box, pGC);
- }
-}
-
-static void
-xxImageGlyphBlt(
- DrawablePtr pDraw,
- GCPtr pGC,
- int x, int y,
- unsigned int nglyph,
- CharInfoPtr *ppci,
- pointer pglyphBase
-){
- XX_GC_OP_PROLOGUE(pGC, pDraw);
- (*pGC->ops->ImageGlyphBlt)(pDraw, pGC, x, y, nglyph,
- ppci, pglyphBase);
- XX_GC_OP_EPILOGUE(pGC, pDraw);
-
- if(IS_VISIBLE(pDraw) && nglyph) {
- int top, bot, width = 0;
- BoxRec box;
-
- DBG("ImageGlyphBlt\n");
- top = max(FONTMAXBOUNDS(pGC->font, ascent), FONTASCENT(pGC->font));
- bot = max(FONTMAXBOUNDS(pGC->font, descent), FONTDESCENT(pGC->font));
-
- box.x1 = ppci[0]->metrics.leftSideBearing;
- if(box.x1 > 0) box.x1 = 0;
- box.x2 = ppci[nglyph - 1]->metrics.rightSideBearing -
- ppci[nglyph - 1]->metrics.characterWidth;
- if(box.x2 < 0) box.x2 = 0;
-
- box.x2 += pDraw->x + x;
- box.x1 += pDraw->x + x;
-
- while(nglyph--) {
- width += (*ppci)->metrics.characterWidth;
- ppci++;
- }
-
- if(width > 0)
- box.x2 += width;
- else
- box.x1 += width;
-
- box.y1 = pDraw->y + y - top;
- box.y2 = pDraw->y + y + bot;
-
- ADD_BOX(box, pGC);
- }
-}
-
-static void
-xxPolyGlyphBlt(
- DrawablePtr pDraw,
- GCPtr pGC,
- int x, int y,
- unsigned int nglyph,
- CharInfoPtr *ppci,
- pointer pglyphBase
-){
- XX_GC_OP_PROLOGUE(pGC, pDraw);
- (*pGC->ops->PolyGlyphBlt)(pDraw, pGC, x, y, nglyph,
- ppci, pglyphBase);
- XX_GC_OP_EPILOGUE(pGC, pDraw);
-
- if(IS_VISIBLE(pDraw) && nglyph) {
- BoxRec box;
-
- DBG("PolyGlyphBlt\n");
- /* ugh */
- box.x1 = pDraw->x + x + ppci[0]->metrics.leftSideBearing;
- box.x2 = pDraw->x + x + ppci[nglyph - 1]->metrics.rightSideBearing;
-
- if(nglyph > 1) {
- int width = 0;
-
- while(--nglyph) {
- width += (*ppci)->metrics.characterWidth;
- ppci++;
- }
-
- if(width > 0) box.x2 += width;
- else box.x1 += width;
- }
-
- box.y1 = pDraw->y + y - FONTMAXBOUNDS(pGC->font, ascent);
- box.y2 = pDraw->y + y + FONTMAXBOUNDS(pGC->font, descent);
-
- ADD_BOX(box, pGC);
- }
-}
-
-static void
-xxPushPixels(
- GCPtr pGC,
- PixmapPtr pBitMap,
- DrawablePtr pDraw,
- int dx, int dy, int xOrg, int yOrg
-){
- XX_GC_OP_PROLOGUE(pGC, pDraw);
- (*pGC->ops->PushPixels)(pGC, pBitMap, pDraw, dx, dy, xOrg, yOrg);
- XX_GC_OP_EPILOGUE(pGC, pDraw);
-
- if(IS_VISIBLE(pDraw)) {
- BoxRec box;
-
- DBG("PushPixels\n");
- box.x1 = xOrg + pDraw->x;
- box.x2 = box.x1 + dx;
- box.y1 = yOrg + pDraw->y;
- box.y2 = box.y1 + dy;
-
- ADD_BOX(box, pGC);
- }
-}
-
-
-#ifdef RENDER
-#define RENDER_MAKE_BOX(pDrawable,X,Y,W,H) { \
- box.x1 = X + pDrawable->x; \
- box.x2 = X + pDrawable->x + W; \
- box.y1 = Y + pDrawable->y; \
- box.y2 = Y + pDrawable->y + H; \
-}
-
-#define RENDER_ADD_BOX(pScreen,box) {\
- if (BOX_NOT_EMPTY(box)) { \
- RegionRec region; \
- xxScrPriv(pScreen);\
- ScreenPtr pScreen = pScreen;\
- REGION_INIT (pScreen, &region, &box, 1); \
- PRINT_RECTS(pScrPriv->region);\
- REGION_UNION(pScreen,&pScrPriv->region,&pScrPriv->region,&region);\
- PRINT_RECTS(pScrPriv->region);\
- REGION_UNINIT(pScreen,&region);\
- }\
-}
-
-static void
-xxComposite (CARD8 op, PicturePtr pSrc, PicturePtr pMask, PicturePtr pDst,
- INT16 xSrc, INT16 ySrc, INT16 xMask, INT16 yMask,
- INT16 xDst, INT16 yDst, CARD16 width, CARD16 height)
-{
- ScreenPtr pScreen = pDst->pDrawable->pScreen;
- PictureScreenPtr ps = GetPictureScreen(pScreen);
- xxScrPriv(pScreen);
- BoxRec box;
-
- unwrap (pScrPriv, ps, Composite);
- (*ps->Composite) (op, pSrc, pMask, pDst, xSrc, ySrc, xMask, yMask,
- xDst, yDst, width, height);
- wrap (pScrPriv, ps, Composite, xxComposite);
- if (pDst->pDrawable->type == DRAWABLE_WINDOW) {
- RENDER_MAKE_BOX(pDst->pDrawable, xDst, yDst, width, height);
- RENDER_ADD_BOX(pScreen,box);
- }
-}
-
-
-static void
-xxGlyphs (CARD8 op, PicturePtr pSrc, PicturePtr pDst,
- PictFormatPtr maskFormat, INT16 xSrc, INT16 ySrc, int nlist,
- GlyphListPtr list, GlyphPtr *glyphs)
-{
- ScreenPtr pScreen = pDst->pDrawable->pScreen;
- PictureScreenPtr ps = GetPictureScreen(pScreen);
- xxScrPriv(pScreen);
- int x, y;
- int n;
- GlyphPtr glyph;
- BoxRec box;
-
- unwrap (pScrPriv, ps, Glyphs);
- (*ps->Glyphs) (op, pSrc, pDst, maskFormat, xSrc, ySrc,
- nlist, list, glyphs);
- wrap (pScrPriv, ps, Glyphs, xxGlyphs);
- if (pDst->pDrawable->type == DRAWABLE_WINDOW)
- {
- x = xSrc;
- y = ySrc;
- while (nlist--)
- {
- x += list->xOff;
- y += list->yOff;
- n = list->len;
- while (n--)
- {
- glyph = *glyphs++;
- RENDER_MAKE_BOX(pDst->pDrawable,
- x - glyph->info.x, y - glyph->info.y,
- glyph->info.width, glyph->info.height);
- RENDER_ADD_BOX(pScreen,box);
- x += glyph->info.xOff;
- y += glyph->info.yOff;
- }
- list++;
- }
- }
-}
-#endif
-
-void
-xxPrintVisuals(void)
-{
- int k,i,j;
- DepthPtr pDepth;
- VisualPtr pVisual;
-
- for (k = 0; k < screenInfo.numScreens; k++) {
- ScreenPtr pScreen = screenInfo.screens[k];
-
- pDepth = pScreen->allowedDepths;
- for (i = 0; i < pScreen->numDepths; i++, pDepth++)
- for (j = 0; j < pDepth->numVids; j++) {
- ErrorF("depth: %i vid: 0x%lx\n",
- pDepth->depth, pDepth->vids[j]);
- }
-
- pVisual = pScreen->visuals;
- for (i = 0; i < pScreen->numVisuals; i++, pVisual++)
- ErrorF("vid: 0x%x rm: 0x%lx gm: 0x%lx bm: 0x%lx\n",
- (unsigned int)pVisual->vid,
- pVisual->redMask,
- pVisual->greenMask,
- pVisual->blueMask);
- }
-}
-
-
diff --git a/fb/fbpseudocolor.h b/fb/fbpseudocolor.h
deleted file mode 100644
index 64de71db8..000000000
--- a/fb/fbpseudocolor.h
+++ /dev/null
@@ -1,20 +0,0 @@
-#ifndef _FB_XX_H_
-# define _FB_XX_H_
-
-typedef void (*xxSyncFunc)(ScreenPtr);
-extern Bool xxSetup(ScreenPtr pScreen, int myDepth,
- int baseDepth, char *addr, xxSyncFunc sync);
-extern void xxPrintVisuals(void);
-
-
-#endif /* _FB_XX_H_ */
-
-
-
-
-
-
-
-
-
-
diff --git a/fb/wfbrename.h b/fb/wfbrename.h
index dc0528559..73ee510b9 100644
--- a/fb/wfbrename.h
+++ b/fb/wfbrename.h
@@ -187,12 +187,4 @@
#define fbZeroSegment wfbZeroSegment
#define free_pixman_pict wfb_free_pixman_pict
#define image_from_pict wfb_image_from_pict
-#define xxScrPrivateKey wfbxxScrPrivateKey
-#define xxGCPrivateKey wfbxxGCPrivateKey
-#define xxColormapPrivateKey wfbxxColormapPrivateKey
-#define xxGeneration wfbxxGeneration
-#define xxPrintVisuals wfbxxPrintVisuals
-#define xxGCFuncs wfbxxGCFuncs
-#define xxGCOps wfbxxGCOps
-#define xxSetup wfbxxSetup
#define composeFunctions wfbComposeFunctions
diff --git a/hw/dmx/dmx-config.h b/hw/dmx/dmx-config.h
index 343fdabf5..4a2dfe060 100644
--- a/hw/dmx/dmx-config.h
+++ b/hw/dmx/dmx-config.h
@@ -83,8 +83,6 @@
#undef XF86MISC
#undef XFreeXDGA
#undef XF86DRI
-#undef TOGCUP
-#undef MITMISC
#undef SCREENSAVER
#undef RANDR
#undef XFIXES
diff --git a/hw/dmx/dmxextension.c b/hw/dmx/dmxextension.c
index 560468c4b..aaa50d5c4 100644
--- a/hw/dmx/dmxextension.c
+++ b/hw/dmx/dmxextension.c
@@ -1350,7 +1350,6 @@ int dmxAttachScreen(int idx, DMXScreenAttributesPtr attr)
* RTContext
* TagResType
* StalledResType
- * RT_APPGROUP
* SecurityAuthorizationResType
* RTEventClient
* __glXContextRes
diff --git a/hw/kdrive/Makefile.am b/hw/kdrive/Makefile.am
index 5803644d5..767e1c40d 100644
--- a/hw/kdrive/Makefile.am
+++ b/hw/kdrive/Makefile.am
@@ -1,10 +1,10 @@
if KDRIVEVESA
-VESA_SUBDIRS = vesa ati chips epson i810 mach64 mga nvidia pm2 r128 \
+VESA_SUBDIRS = vesa ati chips i810 mach64 mga nvidia pm2 r128 \
smi via
endif
if BUILD_KDRIVEFBDEVLIB
-FBDEV_SUBDIRS = fbdev
+FBDEV_SUBDIRS = fbdev epson
endif
if XFAKESERVER
diff --git a/hw/kdrive/ati/Makefile.am b/hw/kdrive/ati/Makefile.am
index 8429250f3..31462bb04 100644
--- a/hw/kdrive/ati/Makefile.am
+++ b/hw/kdrive/ati/Makefile.am
@@ -58,6 +58,10 @@ ATI_LIBS = \
$(DRI_LIBS) \
@KDRIVE_LIBS@
+if GLX
+Xati_LDFLAGS = $(LD_EXPORT_SYMBOLS_FLAG)
+endif
+
Xati_LDADD = \
$(ATI_LIBS) \
@KDRIVE_LIBS@
diff --git a/hw/kdrive/chips/Makefile.am b/hw/kdrive/chips/Makefile.am
index 51b0edf31..46e176051 100644
--- a/hw/kdrive/chips/Makefile.am
+++ b/hw/kdrive/chips/Makefile.am
@@ -20,6 +20,10 @@ CHIPS_LIBS = \
$(top_builddir)/hw/kdrive/vesa/libvesa.a \
@KDRIVE_LIBS@
+if GLX
+Xchips_LDFLAGS = $(LD_EXPORT_SYMBOLS_FLAG)
+endif
+
Xchips_LDADD = \
$(CHIPS_LIBS) \
@KDRIVE_LIBS@
diff --git a/hw/kdrive/ephyr/GL/internal/dri_interface.h b/hw/kdrive/ephyr/GL/internal/dri_interface.h
deleted file mode 100644
index 8d24e311f..000000000
--- a/hw/kdrive/ephyr/GL/internal/dri_interface.h
+++ /dev/null
@@ -1,517 +0,0 @@
-/*
- * Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas.
- * (C) Copyright IBM Corporation 2004
- * 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
- * on 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 COPYRIGHT HOLDERS AND/OR THEIR 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.
- */
-
-/**
- * \file dri_interface.h
- *
- * This file contains all the types and functions that define the interface
- * between a DRI driver and driver loader. Currently, the most common driver
- * loader is the XFree86 libGL.so. However, other loaders do exist, and in
- * the future the server-side libglx.a will also be a loader.
- *
- * \author Kevin E. Martin <kevin@precisioninsight.com>
- * \author Ian Romanick <idr@us.ibm.com>
- */
-
-#ifndef DRI_INTERFACE_H
-#define DRI_INTERFACE_H
-
-#include <GL/internal/glcore.h>
-#include <drm.h>
-
-/**
- * \name DRI interface structures
- *
- * The following structures define the interface between the GLX client
- * side library and the DRI (direct rendering infrastructure).
- */
-/*@{*/
-typedef struct __DRIdisplayRec __DRIdisplay;
-typedef struct __DRIscreenRec __DRIscreen;
-typedef struct __DRIcontextRec __DRIcontext;
-typedef struct __DRIdrawableRec __DRIdrawable;
-typedef struct __DRIdriverRec __DRIdriver;
-typedef struct __DRIframebufferRec __DRIframebuffer;
-typedef struct __DRIversionRec __DRIversion;
-typedef struct __DRIinterfaceMethodsRec __DRIinterfaceMethods;
-typedef unsigned long __DRIid;
-typedef void __DRInativeDisplay;
-/*@}*/
-
-
-/**
- * \name Functions provided by the driver loader.
- */
-/*@{*/
-/**
- * Type of a pointer to \c glXGetScreenDriver, as returned by
- * \c glXGetProcAddress. This function is used to get the name of the DRI
- * driver for the specified screen of the specified display. The driver
- * name is typically used with \c glXGetDriverConfig.
- *
- * \sa glXGetScreenDriver, glXGetProcAddress, glXGetDriverConfig
- */
-typedef const char * (* PFNGLXGETSCREENDRIVERPROC) (__DRInativeDisplay *dpy, int scrNum);
-
-/**
- * Type of a pointer to \c glXGetDriverConfig, as returned by
- * \c glXGetProcAddress. This function is used to get the XML document
- * describing the configuration options available for the specified driver.
- *
- * \sa glXGetDriverConfig, glXGetProcAddress, glXGetScreenDriver
- */
-typedef const char * (* PFNGLXGETDRIVERCONFIGPROC) (const char *driverName);
-
-/**
- * Type of a pointer to \c glxEnableExtension, as returned by
- * \c __DRIinterfaceMethods::getProcAddress. This function is used to enable
- * a GLX extension on the specified screen.
- */
-typedef void (* PFNGLXSCRENABLEEXTENSIONPROC) ( void *psc, const char * name );
-/*@}*/
-
-
-/**
- * \name Functions and data provided by the driver.
- */
-/*@{*/
-
-typedef void *(CREATENEWSCREENFUNC)(__DRInativeDisplay *dpy, int scrn,
- __DRIscreen *psc, const __GLcontextModes * modes,
- const __DRIversion * ddx_version, const __DRIversion * dri_version,
- const __DRIversion * drm_version, const __DRIframebuffer * frame_buffer,
- void * pSAREA, int fd, int internal_api_version,
- const __DRIinterfaceMethods * interface,
- __GLcontextModes ** driver_modes);
-typedef CREATENEWSCREENFUNC* PFNCREATENEWSCREENFUNC;
-extern CREATENEWSCREENFUNC __driCreateNewScreen_20050727;
-
-
-/**
- * XML document describing the configuration options supported by the
- * driver.
- */
-extern const char __driConfigOptions[];
-
-/*@}*/
-
-
-/**
- * Stored version of some component (i.e., server-side DRI module, kernel-side
- * DRM, etc.).
- *
- * \todo
- * There are several data structures that explicitly store a major version,
- * minor version, and patch level. These structures should be modified to
- * have a \c __DRIversionRec instead.
- */
-struct __DRIversionRec {
- int major; /**< Major version number. */
- int minor; /**< Minor version number. */
- int patch; /**< Patch-level. */
-};
-
-
-typedef void (*__DRIfuncPtr)(void);
-
-struct __DRIinterfaceMethodsRec {
- /**
- * Get pointer to named function.
- */
- __DRIfuncPtr (*getProcAddress)( const char * proc_name );
-
- /**
- * Create a list of \c __GLcontextModes structures.
- */
- __GLcontextModes * (*createContextModes)(unsigned count,
- size_t minimum_bytes_per_struct);
-
- /**
- * Destroy a list of \c __GLcontextModes structures.
- *
- * \todo
- * Determine if the drivers actually need to call this.
- */
- void (*destroyContextModes)( __GLcontextModes * modes );
-
- /**
- * Get the \c __DRIscreen for a given display and screen number.
- */
- __DRIscreen *(*getScreen)(__DRInativeDisplay *dpy, int screenNum);
-
-
- /**
- * \name Client/server protocol functions.
- *
- * These functions implement the DRI client/server protocol for
- * context and drawable operations. Platforms that do not implement
- * the wire protocol (e.g., EGL) will implement glorified no-op functions.
- */
- /*@{*/
- /**
- * Determine if the specified window ID still exists.
- *
- * \note
- * Implementations may assume that the driver will only pass an ID into
- * this function that actually corresponds to a window. On
- * implementations where windows can only be destroyed by the DRI driver
- * (e.g., EGL), this function is allowed to always return \c GL_TRUE.
- */
- GLboolean (*windowExists)(__DRInativeDisplay *dpy, __DRIid draw);
-
- /**
- * Create the server-side portion of the GL context.
- */
- GLboolean (* createContext)( __DRInativeDisplay *dpy, int screenNum,
- int configID, void * contextID, drm_context_t * hw_context );
-
- /**
- * Destroy the server-side portion of the GL context.
- */
- GLboolean (* destroyContext)( __DRInativeDisplay *dpy, int screenNum,
- __DRIid context );
-
- /**
- * Create the server-side portion of the drawable.
- */
- GLboolean (*createDrawable)( __DRInativeDisplay * ndpy, int screen,
- __DRIid drawable, drm_drawable_t * hHWDrawable );
-
- /**
- * Destroy the server-side portion of the drawable.
- */
- GLboolean (*destroyDrawable)( __DRInativeDisplay * ndpy, int screen,
- __DRIid drawable );
-
- /**
- * This function is used to get information about the position, size, and
- * clip rects of a drawable.
- */
- GLboolean (* getDrawableInfo) ( __DRInativeDisplay *dpy, int scrn,
- __DRIid draw, unsigned int * index, unsigned int * stamp,
- int * x, int * y, int * width, int * height,
- int * numClipRects, drm_clip_rect_t ** pClipRects,
- int * backX, int * backY,
- int * numBackClipRects, drm_clip_rect_t ** pBackClipRects );
- /*@}*/
-
-
- /**
- * \name Timing related functions.
- */
- /*@{*/
- /**
- * Get the 64-bit unadjusted system time (UST).
- */
- int (*getUST)(int64_t * ust);
-
- /**
- * Get the media stream counter (MSC) rate.
- *
- * Matching the definition in GLX_OML_sync_control, this function returns
- * the rate of the "media stream counter". In practical terms, this is
- * the frame refresh rate of the display.
- */
- GLboolean (*getMSCRate)(__DRInativeDisplay * dpy, __DRIid drawable,
- int32_t * numerator, int32_t * denominator);
- /*@}*/
-
- /**
- * Reports areas of the given drawable which have been modified by the
- * driver.
- *
- * \param drawable which the drawing was done to.
- * \param rects rectangles affected, with the drawable origin as the
- * origin.
- * \param x X offset of the drawable within the screen (used in the
- * front_buffer case)
- * \param y Y offset of the drawable within the screen.
- * \param front_buffer boolean flag for whether the drawing to the
- * drawable was actually done directly to the front buffer (instead
- * of backing storage, for example)
- */
- void (*reportDamage)(__DRInativeDisplay * dpy, int screen,
- __DRIid drawable,
- int x, int y,
- drm_clip_rect_t *rects, int num_rects,
- int front_buffer);
-};
-
-
-/**
- * Framebuffer information record. Used by libGL to communicate information
- * about the framebuffer to the driver's \c __driCreateNewScreen function.
- *
- * In XFree86, most of this information is derrived from data returned by
- * calling \c XF86DRIGetDeviceInfo.
- *
- * \sa XF86DRIGetDeviceInfo __DRIdisplayRec::createNewScreen
- * __driUtilCreateNewScreen CallCreateNewScreen
- *
- * \bug This structure could be better named.
- */
-struct __DRIframebufferRec {
- unsigned char *base; /**< Framebuffer base address in the CPU's
- * address space. This value is calculated by
- * calling \c drmMap on the framebuffer handle
- * returned by \c XF86DRIGetDeviceInfo (or a
- * similar function).
- */
- int size; /**< Framebuffer size, in bytes. */
- int stride; /**< Number of bytes from one line to the next. */
- int width; /**< Pixel width of the framebuffer. */
- int height; /**< Pixel height of the framebuffer. */
- int dev_priv_size; /**< Size of the driver's dev-priv structure. */
- void *dev_priv; /**< Pointer to the driver's dev-priv structure. */
-};
-
-
-/**
- * Screen dependent methods. This structure is initialized during the
- * \c __DRIdisplayRec::createScreen call.
- */
-struct __DRIscreenRec {
- /**
- * Method to destroy the private DRI screen data.
- */
- void (*destroyScreen)(__DRInativeDisplay *dpy, int scrn, void *screenPrivate);
-
- /**
- * Method to create the private DRI drawable data and initialize the
- * drawable dependent methods.
- */
- void *(*createNewDrawable)(__DRInativeDisplay *dpy, const __GLcontextModes *modes,
- __DRIid draw, __DRIdrawable *pdraw,
- int renderType, const int *attrs);
-
- /**
- * Method to return a pointer to the DRI drawable data.
- */
- __DRIdrawable *(*getDrawable)(__DRInativeDisplay *dpy, __DRIid draw,
- void *drawablePrivate);
-
- /**
- * Opaque pointer to private per screen direct rendering data. \c NULL
- * if direct rendering is not supported on this screen. Never
- * dereferenced in libGL.
- */
- void *private;
-
- /**
- * Get the number of vertical refreshes since some point in time before
- * this function was first called (i.e., system start up).
- *
- * \since Internal API version 20030317.
- */
- int (*getMSC)( void *screenPrivate, int64_t *msc );
-
- /**
- * Opaque pointer that points back to the containing
- * \c __GLXscreenConfigs. This data structure is shared with DRI drivers
- * but \c __GLXscreenConfigs is not. However, they are needed by some GLX
- * functions called by DRI drivers.
- *
- * \since Internal API version 20030813.
- */
- void *screenConfigs;
-
- /**
- * Functions associated with MESA_allocate_memory.
- *
- * \since Internal API version 20030815.
- */
- /*@{*/
- void *(*allocateMemory)(__DRInativeDisplay *dpy, int scrn, GLsizei size,
- GLfloat readfreq, GLfloat writefreq,
- GLfloat priority);
-
- void (*freeMemory)(__DRInativeDisplay *dpy, int scrn, GLvoid *pointer);
-
- GLuint (*memoryOffset)(__DRInativeDisplay *dpy, int scrn, const GLvoid *pointer);
- /*@}*/
-
- /**
- * Method to create the private DRI context data and initialize the
- * context dependent methods.
- *
- * \since Internal API version 20031201.
- */
- void * (*createNewContext)(__DRInativeDisplay *dpy, const __GLcontextModes *modes,
- int render_type,
- void *sharedPrivate, __DRIcontext *pctx);
-
- /**
- * Method to override base texture image with a driver specific 'offset'.
- * The depth passed in allows e.g. to ignore the alpha channel of texture
- * images where the non-alpha components don't occupy a whole texel.
- *
- * For GLX_EXT_texture_from_pixmap with AIGLX.
- *
- * \since Internal API version 20070121.
- */
- void (*setTexOffset)(__DRIcontext *pDRICtx, GLint texname,
- unsigned long long offset, GLint depth, GLuint pitch);
-};
-
-/**
- * Context dependent methods. This structure is initialized during the
- * \c __DRIscreenRec::createContext call.
- */
-struct __DRIcontextRec {
- /**
- * Method to destroy the private DRI context data.
- */
- void (*destroyContext)(__DRInativeDisplay *dpy, int scrn, void *contextPrivate);
-
- /**
- * Opaque pointer to private per context direct rendering data.
- * \c NULL if direct rendering is not supported on the display or
- * screen used to create this context. Never dereferenced in libGL.
- */
- void *private;
-
- /**
- * Pointer to the mode used to create this context.
- *
- * \since Internal API version 20040317.
- */
- const __GLcontextModes * mode;
-
- /**
- * Method to bind a DRI drawable to a DRI graphics context.
- *
- * \since Internal API version 20050727.
- */
- GLboolean (*bindContext)(__DRInativeDisplay *dpy, int scrn, __DRIid draw,
- __DRIid read, __DRIcontext *ctx);
-
- /**
- * Method to unbind a DRI drawable from a DRI graphics context.
- *
- * \since Internal API version 20050727.
- */
- GLboolean (*unbindContext)(__DRInativeDisplay *dpy, int scrn, __DRIid draw,
- __DRIid read, __DRIcontext *ctx);
-};
-
-/**
- * Drawable dependent methods. This structure is initialized during the
- * \c __DRIscreenRec::createDrawable call. \c createDrawable is not called
- * by libGL at this time. It's currently used via the dri_util.c utility code
- * instead.
- */
-struct __DRIdrawableRec {
- /**
- * Method to destroy the private DRI drawable data.
- */
- void (*destroyDrawable)(__DRInativeDisplay *dpy, void *drawablePrivate);
-
- /**
- * Method to swap the front and back buffers.
- */
- void (*swapBuffers)(__DRInativeDisplay *dpy, void *drawablePrivate);
-
- /**
- * Opaque pointer to private per drawable direct rendering data.
- * \c NULL if direct rendering is not supported on the display or
- * screen used to create this drawable. Never dereferenced in libGL.
- */
- void *private;
-
- /**
- * Get the number of completed swap buffers for this drawable.
- *
- * \since Internal API version 20030317.
- */
- int (*getSBC)(__DRInativeDisplay *dpy, void *drawablePrivate, int64_t *sbc );
-
- /**
- * Wait for the SBC to be greater than or equal target_sbc.
- *
- * \since Internal API version 20030317.
- */
- int (*waitForSBC)( __DRInativeDisplay * dpy, void *drawablePriv,
- int64_t target_sbc,
- int64_t * msc, int64_t * sbc );
-
- /**
- * Wait for the MSC to equal target_msc, or, if that has already passed,
- * the next time (MSC % divisor) is equal to remainder. If divisor is
- * zero, the function will return as soon as MSC is greater than or equal
- * to target_msc.
- *
- * \since Internal API version 20030317.
- */
- int (*waitForMSC)( __DRInativeDisplay * dpy, void *drawablePriv,
- int64_t target_msc, int64_t divisor, int64_t remainder,
- int64_t * msc, int64_t * sbc );
-
- /**
- * Like \c swapBuffers, but does NOT have an implicit \c glFlush. Once
- * rendering is complete, waits until MSC is equal to target_msc, or
- * if that has already passed, waits until (MSC % divisor) is equal
- * to remainder. If divisor is zero, the swap will happen as soon as
- * MSC is greater than or equal to target_msc.
- *
- * \since Internal API version 20030317.
- */
- int64_t (*swapBuffersMSC)(__DRInativeDisplay *dpy, void *drawablePrivate,
- int64_t target_msc,
- int64_t divisor, int64_t remainder);
-
- /**
- * Enable or disable frame usage tracking.
- *
- * \since Internal API version 20030317.
- */
- int (*frameTracking)(__DRInativeDisplay *dpy, void *drawablePrivate, GLboolean enable);
-
- /**
- * Retrieve frame usage information.
- *
- * \since Internal API version 20030317.
- */
- int (*queryFrameTracking)(__DRInativeDisplay *dpy, void *drawablePrivate,
- int64_t * sbc, int64_t * missedFrames,
- float * lastMissedUsage, float * usage );
-
- /**
- * Used by drivers that implement the GLX_SGI_swap_control or
- * GLX_MESA_swap_control extension.
- *
- * \since Internal API version 20030317.
- */
- unsigned swap_interval;
-
- /**
- * Used by drivers that implement the GLX_MESA_copy_sub_buffer extension.
- *
- * \since Internal API version 20060314.
- */
- void (*copySubBuffer)(__DRInativeDisplay *dpy, void *drawablePrivate,
- int x, int y, int w, int h);
-};
-
-#endif
diff --git a/hw/kdrive/ephyr/Makefile.am b/hw/kdrive/ephyr/Makefile.am
index 81d3d69ea..526987672 100644
--- a/hw/kdrive/ephyr/Makefile.am
+++ b/hw/kdrive/ephyr/Makefile.am
@@ -1,89 +1,90 @@
-INCLUDES = \
- @KDRIVE_INCS@ \
- @KDRIVE_CFLAGS@ \
- -I$(srcdir)/../../../exa
+INCLUDES = \
+ @KDRIVE_INCS@ \
+ @KDRIVE_CFLAGS@ \
+ @XEPHYR_INCS@ \
+ @XEPHYR_CFLAGS@ \
+ @DRIPROTO_CFLAGS@ \
+ -I$(top_srcdir) \
+ -I$(top_srcdir)/exa
if XV
- LIBXEPHYR_HOSTXV=libxephyr-hostxv.a
-else
- LIBXEPHYR_HOSTXV=
+LIBXEPHYR_HOSTXV=libxephyr-hostxv.a
endif
-if XEPHYR_HAS_DRI
- LIBXEPHYR_HOSTDRI=libxephyr-hostdri.a
-else
- LIBXEPHYR_HOSTDRI=
+if DRI
+LIBXEPHYR_HOSTDRI=libxephyr-hostdri.a
endif
noinst_LIBRARIES = libxephyr-hostx.a $(LIBXEPHYR_HOSTXV) $(LIBXEPHYR_HOSTDRI) libxephyr.a
bin_PROGRAMS = Xephyr
-libxephyr_hostx_a_SOURCES = \
- hostx.c \
+HOSTX_SRCS = \
+ hostx.c \
hostx.h
-libxephyr_hostxv_a_INCLUDES = @XEPHYR_INCS@
-
-if XV
-libxephyr_hostxv_a_SOURCES= \
- ephyrhostvideo.c \
+HOSTVIDEO_SRCS = \
+ ephyrvideo.c \
+ ephyrhostvideo.c \
ephyrhostvideo.h
-endif
-
-if XEPHYR_HAS_DRI
-
-libxephyr_hostdri_a_SOURCES= \
-ephyrdriext.c \
-ephyrdriext.h \
-ephyrdri.c \
-ephyrdri.h \
-XF86dri.c \
-ephyrglxext.c \
-ephyrglxext.h \
-ephyrhostglx.c \
-ephyrhostglx.h
-libxephyr_hostdri_a_CFLAGS= \
--I$(top_srcdir) \
-@LIBDRM_CFLAGS@ \
-@DRIPROTO_CFLAGS@
+HOSTDRI_SRCS = \
+ ephyrdriext.c \
+ ephyrdriext.h \
+ ephyrdri.c \
+ ephyrdri.h \
+ XF86dri.c \
+ xf86dri.h \
+ ephyrglxext.c \
+ ephyrglxext.h \
+ ephyrhostglx.c \
+ ephyrhostglx.h
+
+XEPHYR_SRCS = \
+ ephyr.c \
+ ephyr.h \
+ ephyrlog.h \
+ ephyr_draw.c \
+ os.c
+
+libxephyr_hostx_a_SOURCES = $(HOSTX_SRCS)
+if XV
+libxephyr_hostxv_a_SOURCES = $(HOSTVIDEO_SRCS)
endif
-libxephyr_a_SOURCES = \
- ephyr.c \
- ephyr_draw.c \
- ephyrvideo.c \
- os.c \
- hostx.h \
- ephyr.h \
- ephyrlog.h
+if DRI
+libxephyr_hostdri_a_SOURCES = $(HOSTDRI_SRCS)
+endif
-libxephyr_a_CFLAGS = \
--I$(top_srcdir) \
-@LIBDRM_CFLAGS@
+libxephyr_a_SOURCES = $(XEPHYR_SRCS)
Xephyr_SOURCES = \
ephyrinit.c
+if GLX
+Xephyr_LDFLAGS = $(LD_EXPORT_SYMBOLS_FLAG)
+endif
+
Xephyr_LDADD = \
libxephyr.a \
- libxephyr-hostx.a \
+ libxephyr-hostx.a \
$(LIBXEPHYR_HOSTXV) \
$(LIBXEPHYR_HOSTDRI) \
- ../../../exa/libexa.la \
+ $(top_builddir)/exa/libexa.la \
@KDRIVE_LIBS@ \
- @XEPHYR_LIBS@ \
- @LIBDRM_LIBS@ \
- @XEPHYR_DRI_LIBS@
+ @XEPHYR_LIBS@
Xephyr_DEPENDENCIES = \
libxephyr.a \
- libxephyr-hostx.a \
+ libxephyr-hostx.a \
$(LIBXEPHYR_HOSTXV) \
$(LIBXEPHYR_HOSTDRI) \
@KDRIVE_LOCAL_LIBS@
relink:
rm -f $(bin_PROGRAMS) && make $(bin_PROGRAMS)
+
+EXTRA_DIST = \
+ $(HOSTVIDEO_SRCS) \
+ $(HOSTDRI_SRCS)
diff --git a/hw/kdrive/ephyr/XF86dri.c b/hw/kdrive/ephyr/XF86dri.c
index e656ff5a0..be65edf5b 100644
--- a/hw/kdrive/ephyr/XF86dri.c
+++ b/hw/kdrive/ephyr/XF86dri.c
@@ -46,8 +46,6 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#include <kdrive-config.h>
#endif
-#ifdef XEPHYR_DRI
-
/* THIS IS NOT AN X CONSORTIUM STANDARD */
#define NEED_REPLIES
@@ -55,9 +53,8 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#include <X11/extensions/Xext.h>
#include <X11/extensions/extutil.h>
#include <GL/glx.h>
-#include <X11/dri/xf86dri.h>
+#include "xf86dri.h"
#include <X11/dri/xf86dristr.h>
-#include "GL/internal/dri_interface.h"
static XExtensionInfo _xf86dri_info_data;
static XExtensionInfo *xf86dri_info = &_xf86dri_info_data;
@@ -640,5 +637,3 @@ XF86DRICloseFullScreen(Display *dpy, int screen, Drawable drawable)
(void) drawable;
return True;
}
-#endif /*EPHYR_DRI*/
-
diff --git a/hw/kdrive/ephyr/ephyr.c b/hw/kdrive/ephyr/ephyr.c
index b02f9903c..3989d0d9f 100644
--- a/hw/kdrive/ephyr/ephyr.c
+++ b/hw/kdrive/ephyr/ephyr.c
@@ -32,11 +32,11 @@
#include "scrnintstr.h"
#include "ephyrlog.h"
-#ifdef XEPHYR_DRI
+#ifdef XF86DRI
#include "ephyrdri.h"
#include "ephyrdriext.h"
#include "ephyrglxext.h"
-#endif /*XEPHYR_DRI*/
+#endif /* XF86DRI */
extern int KdTsPhyScreen;
#ifdef GLXEXT
@@ -150,11 +150,22 @@ ephyrScreenInitialize (KdScreenInfo *screen, EphyrScrPriv *scrpriv)
screen->fb[0].depth = 16;
screen->fb[0].bitsPerPixel = 16;
}
- else
+ else if (screen->fb[0].depth <= 24)
{
screen->fb[0].depth = 24;
screen->fb[0].bitsPerPixel = 32;
}
+ else if (screen->fb[0].depth <= 30)
+ {
+ screen->fb[0].depth = 30;
+ screen->fb[0].bitsPerPixel = 32;
+ }
+ else
+ {
+ ErrorF("\nXephyr: Unsupported screen depth %d\n",
+ screen->fb[0].depth);
+ return FALSE;
+ }
hostx_get_visual_masks (screen, &redMask, &greenMask, &blueMask);
@@ -631,7 +642,7 @@ ephyrInitScreen (ScreenPtr pScreen)
}
#endif /*XV*/
-#ifdef XEPHYR_DRI
+#ifdef XF86DRI
if (!ephyrNoDRI && !hostx_has_dri ()) {
EPHYR_LOG ("host x does not support DRI. Disabling DRI forwarding\n") ;
ephyrNoDRI = TRUE ;
@@ -841,7 +852,7 @@ miPointerScreenFuncRec ephyrPointerScreenFuncs =
ephyrWarpCursor
};
-#ifdef XEPHYR_DRI
+#ifdef XF86DRI
/**
* find if the remote window denoted by a_remote
* is paired with an internal Window within the Xephyr server.
@@ -873,7 +884,7 @@ ephyrExposePairedWindow (int a_remote)
screen->WindowExposures (pair->local, &reg, NullRegion);
REGION_UNINIT (screen, &reg);
}
-#endif /*XEPHYR_DRI*/
+#endif /* XF86DRI */
void
ephyrPoll(void)
@@ -908,14 +919,14 @@ ephyrPoll(void)
else
{
int x=0, y=0;
-#ifdef XEPHYR_DRI
+#ifdef XF86DRI
EphyrWindowPair *pair = NULL;
#endif
EPHYR_LOG ("enqueuing mouse motion:%d\n", ephyrCurScreen) ;
x = ev.data.mouse_motion.x;
y = ev.data.mouse_motion.y;
EPHYR_LOG ("initial (x,y):(%d,%d)\n", x, y) ;
-#ifdef XEPHYR_DRI
+#ifdef XF86DRI
EPHYR_LOG ("is this window peered by a gl drawable ?\n") ;
if (findWindowPairFromRemote (ev.data.mouse_motion.window,
&pair))
@@ -972,7 +983,7 @@ ephyrPoll(void)
KdEnqueueKeyboardEvent (ephyrKbd, ev.data.key_up.scancode, TRUE);
break;
-#ifdef XEPHYR_DRI
+#ifdef XF86DRI
case EPHYR_EV_EXPOSE:
/*
* We only receive expose events when the expose event have
@@ -982,7 +993,7 @@ ephyrPoll(void)
*/
ephyrExposePairedWindow (ev.data.expose.window);
break;
-#endif /*XEPHYR_DRI*/
+#endif /* XF86DRI */
default:
break;
diff --git a/hw/kdrive/ephyr/ephyrdri.c b/hw/kdrive/ephyr/ephyrdri.c
index 53a96ba11..9aa68b126 100644
--- a/hw/kdrive/ephyr/ephyrdri.c
+++ b/hw/kdrive/ephyr/ephyrdri.c
@@ -29,13 +29,10 @@
#include <kdrive-config.h>
#endif
-#ifdef XEPHYR_DRI
-
#include <X11/Xutil.h>
#include <X11/Xlibint.h>
-/*#define _XF86DRI_SERVER_*/
#include <GL/glx.h>
-#include <X11/dri/xf86dri.h>
+#include "xf86dri.h"
#include "hostx.h"
#include "ephyrdri.h"
#define _HAVE_XALLOC_DECLS
@@ -287,5 +284,3 @@ ephyrDRIGetDeviceInfo (int a_screen,
EPHYR_LOG ("leave:%d\n", is_ok) ;
return is_ok ;
}
-#endif /*EPHYR_DRI*/
-
diff --git a/hw/kdrive/ephyr/ephyrdriext.c b/hw/kdrive/ephyr/ephyrdriext.c
index fafe56d1f..883e3309d 100644
--- a/hw/kdrive/ephyr/ephyrdriext.c
+++ b/hw/kdrive/ephyr/ephyrdriext.c
@@ -32,8 +32,6 @@
#include <kdrive-config.h>
#endif
-#ifdef XEPHYR_DRI
-
#include <string.h>
#define NEED_REPLIES
@@ -1439,5 +1437,3 @@ SProcXF86DRIDispatch (register ClientPtr client)
}
}
}
-
-#endif /*XEPHYR_DRI*/
diff --git a/hw/kdrive/ephyr/ephyrglxext.c b/hw/kdrive/ephyr/ephyrglxext.c
index 43a634d24..2e08e392c 100644
--- a/hw/kdrive/ephyr/ephyrglxext.c
+++ b/hw/kdrive/ephyr/ephyrglxext.c
@@ -42,8 +42,6 @@
#include "hostx.h"
-#ifdef XEPHYR_DRI
-
#ifndef TRUE
#define TRUE 1
#endif
@@ -727,6 +725,3 @@ ephyrGLXIsDirectSwap (__GLXclientState *a_cl, GLbyte *a_pc)
{
return ephyrGLXIsDirectReal (a_cl, a_pc, TRUE) ;
}
-
-#endif /*XEPHYR_DRI*/
-
diff --git a/hw/kdrive/ephyr/ephyrhostglx.c b/hw/kdrive/ephyr/ephyrhostglx.c
index f5db5be16..6d783d279 100644
--- a/hw/kdrive/ephyr/ephyrhostglx.c
+++ b/hw/kdrive/ephyr/ephyrhostglx.c
@@ -41,7 +41,6 @@
#include "ephyrlog.h"
#include "hostx.h"
-#ifdef XEPHYR_DRI
enum VisualConfRequestType {
EPHYR_GET_FB_CONFIG,
EPHYR_VENDOR_PRIV_GET_FB_CONFIG_SGIX,
@@ -687,6 +686,3 @@ out:
EPHYR_LOG ("leave\n") ;
return is_ok ;
}
-
-#endif /*XEPHYR_DRI*/
-
diff --git a/hw/kdrive/ephyr/hostx.c b/hw/kdrive/ephyr/hostx.c
index 1a71d0641..74f9f1628 100644
--- a/hw/kdrive/ephyr/hostx.c
+++ b/hw/kdrive/ephyr/hostx.c
@@ -45,12 +45,12 @@
#include <X11/keysym.h>
#include <X11/extensions/XShm.h>
#include <X11/extensions/shape.h>
-#ifdef XEPHYR_DRI
+#ifdef XF86DRI
#include <GL/glx.h>
-#endif /*XEPHYR_DRI*/
+#endif /* XF86DRI */
#include "ephyrlog.h"
-#ifdef XEPHYR_DRI
+#ifdef XF86DRI
extern Bool XF86DRIQueryExtension (Display *dpy,
int *event_basep,
int *error_basep);
@@ -1315,7 +1315,7 @@ hostx_has_xshape (void)
return TRUE;
}
-#ifdef XEPHYR_DRI
+#ifdef XF86DRI
typedef struct {
int is_valid ;
int local_id ;
@@ -1418,5 +1418,4 @@ hostx_has_glx (void)
return TRUE ;
}
-#endif /*XEPHYR_DRI*/
-
+#endif /* XF86DRI */
diff --git a/hw/kdrive/ephyr/hostx.h b/hw/kdrive/ephyr/hostx.h
index 47ba61b5b..c1b1958de 100644
--- a/hw/kdrive/ephyr/hostx.h
+++ b/hw/kdrive/ephyr/hostx.h
@@ -244,7 +244,7 @@ int hostx_set_window_clipping_rectangles (int a_window,
int a_num_rects) ;
int hostx_has_xshape (void) ;
-#ifdef XEPHYR_DRI
+#ifdef XF86DRI
int hostx_lookup_peer_window (void *a_local_window,
int *a_host_peer /*out parameter*/) ;
int
@@ -256,6 +256,6 @@ hostx_get_resource_id_peer (int a_local_resource_id,
int hostx_has_dri (void) ;
int hostx_has_glx (void) ;
-#endif /*XEPHYR_DRI*/
+#endif /* XF86DRI */
#endif /*_XLIBS_STUFF_H_*/
diff --git a/hw/kdrive/ephyr/xf86dri.h b/hw/kdrive/ephyr/xf86dri.h
new file mode 100644
index 000000000..cd650b582
--- /dev/null
+++ b/hw/kdrive/ephyr/xf86dri.h
@@ -0,0 +1,120 @@
+/* $XFree86: xc/lib/GL/dri/xf86dri.h,v 1.8 2002/10/30 12:51:25 alanh Exp $ */
+/**************************************************************************
+
+Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas.
+Copyright 2000 VA Linux Systems, 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.
+
+**************************************************************************/
+
+/**
+ * \file xf86dri.h
+ * Protocol numbers and function prototypes for DRI X protocol.
+ *
+ * \author Kevin E. Martin <martin@valinux.com>
+ * \author Jens Owen <jens@tungstengraphics.com>
+ * \author Rickard E. (Rik) Faith <faith@valinux.com>
+ */
+
+#ifndef _XF86DRI_H_
+#define _XF86DRI_H_
+
+#include <X11/Xfuncproto.h>
+#include <xf86drm.h>
+
+#define X_XF86DRIQueryVersion 0
+#define X_XF86DRIQueryDirectRenderingCapable 1
+#define X_XF86DRIOpenConnection 2
+#define X_XF86DRICloseConnection 3
+#define X_XF86DRIGetClientDriverName 4
+#define X_XF86DRICreateContext 5
+#define X_XF86DRIDestroyContext 6
+#define X_XF86DRICreateDrawable 7
+#define X_XF86DRIDestroyDrawable 8
+#define X_XF86DRIGetDrawableInfo 9
+#define X_XF86DRIGetDeviceInfo 10
+#define X_XF86DRIAuthConnection 11
+#define X_XF86DRIOpenFullScreen 12 /* Deprecated */
+#define X_XF86DRICloseFullScreen 13 /* Deprecated */
+
+#define XF86DRINumberEvents 0
+
+#define XF86DRIClientNotLocal 0
+#define XF86DRIOperationNotSupported 1
+#define XF86DRINumberErrors (XF86DRIOperationNotSupported + 1)
+
+#ifndef _XF86DRI_SERVER_
+
+_XFUNCPROTOBEGIN
+
+Bool XF86DRIQueryExtension( Display *dpy, int *event_base, int *error_base );
+
+Bool XF86DRIQueryVersion( Display *dpy, int *majorVersion, int *minorVersion,
+ int *patchVersion );
+
+Bool XF86DRIQueryDirectRenderingCapable( Display *dpy, int screen,
+ Bool *isCapable );
+
+Bool XF86DRIOpenConnection( Display *dpy, int screen, drm_handle_t *hSAREA,
+ char **busIDString );
+
+Bool XF86DRIAuthConnection( Display *dpy, int screen, drm_magic_t magic );
+
+Bool XF86DRICloseConnection( Display *dpy, int screen );
+
+Bool XF86DRIGetClientDriverName( Display *dpy, int screen,
+ int *ddxDriverMajorVersion, int *ddxDriverMinorVersion,
+ int *ddxDriverPatchVersion, char **clientDriverName );
+
+Bool XF86DRICreateContext( Display *dpy, int screen, Visual *visual,
+ XID *ptr_to_returned_context_id, drm_context_t *hHWContext );
+
+Bool XF86DRICreateContextWithConfig( Display *dpy, int screen, int configID,
+ XID *ptr_to_returned_context_id, drm_context_t *hHWContext );
+
+extern GLboolean XF86DRIDestroyContext( Display *dpy, int screen,
+ XID context_id );
+
+extern GLboolean XF86DRICreateDrawable( Display *dpy, int screen,
+ XID drawable, drm_drawable_t *hHWDrawable );
+
+extern GLboolean XF86DRIDestroyDrawable( Display *dpy, int screen,
+ XID drawable);
+
+Bool XF86DRIGetDrawableInfo( Display *dpy, int screen, Drawable drawable,
+ unsigned int *index, unsigned int *stamp,
+ int *X, int *Y, int *W, int *H,
+ int *numClipRects, drm_clip_rect_t ** pClipRects,
+ int *backX, int *backY,
+ int *numBackClipRects, drm_clip_rect_t **pBackClipRects );
+
+Bool XF86DRIGetDeviceInfo( Display *dpy, int screen,
+ drm_handle_t *hFrameBuffer, int *fbOrigin, int *fbSize,
+ int *fbStride, int *devPrivateSize, void **pDevPrivate );
+
+_XFUNCPROTOEND
+
+#endif /* _XF86DRI_SERVER_ */
+
+#endif /* _XF86DRI_H_ */
+
diff --git a/hw/kdrive/epson/Makefile.am b/hw/kdrive/epson/Makefile.am
index 2a440149d..14bb04996 100644
--- a/hw/kdrive/epson/Makefile.am
+++ b/hw/kdrive/epson/Makefile.am
@@ -20,6 +20,10 @@ EPSON_LIBS = \
libepson.a \
@KDRIVE_LIBS@
+if GLX
+Xepson_LDFLAGS = $(LD_EXPORT_SYMBOLS_FLAG)
+endif
+
Xepson_LDADD = \
$(EPSON_LIBS) \
@KDRIVE_LIBS@
diff --git a/hw/kdrive/fake/Makefile.am b/hw/kdrive/fake/Makefile.am
index 09d179eb0..0f8865699 100644
--- a/hw/kdrive/fake/Makefile.am
+++ b/hw/kdrive/fake/Makefile.am
@@ -16,6 +16,10 @@ libfake_a_SOURCES = \
Xfake_SOURCES = \
fakeinit.c
+if GLX
+Xfake_LDFLAGS = $(LD_EXPORT_SYMBOLS_FLAG)
+endif
+
Xfake_LDADD = \
libfake.a \
@KDRIVE_LIBS@ \
diff --git a/hw/kdrive/fbdev/Makefile.am b/hw/kdrive/fbdev/Makefile.am
index 420855b8d..c77f146ee 100644
--- a/hw/kdrive/fbdev/Makefile.am
+++ b/hw/kdrive/fbdev/Makefile.am
@@ -14,6 +14,10 @@ bin_PROGRAMS = Xfbdev
Xfbdev_SOURCES = \
fbinit.c
+if GLX
+Xfbdev_LDFLAGS = $(LD_EXPORT_SYMBOLS_FLAG)
+endif
+
Xfbdev_LDADD = \
libfbdev.a \
@KDRIVE_LIBS@
diff --git a/hw/kdrive/fbdev/fbdev.c b/hw/kdrive/fbdev/fbdev.c
index 177be0bdc..7721e608a 100644
--- a/hw/kdrive/fbdev/fbdev.c
+++ b/hw/kdrive/fbdev/fbdev.c
@@ -179,16 +179,24 @@ fbdevScreenInitialize (KdScreenInfo *screen, FbdevScrPriv *scrpriv)
screen->rate = 103; /* FIXME: should get proper value from fb driver */
}
if (!screen->fb[0].depth)
- screen->fb[0].depth = 16;
-
- t = KdFindMode (screen, fbdevModeSupported);
- screen->rate = t->rate;
- screen->width = t->horizontal;
- screen->height = t->vertical;
+ {
+ if (k >= 0)
+ screen->fb[0].depth = var.bits_per_pixel;
+ else
+ screen->fb[0].depth = 16;
+ }
- /* Now try setting the mode */
- if (k < 0 || (t->horizontal != var.xres || t->vertical != var.yres))
- fbdevConvertMonitorTiming (t, &var);
+ if ((screen->width != var.xres) || (screen->height != var.yres))
+ {
+ t = KdFindMode (screen, fbdevModeSupported);
+ screen->rate = t->rate;
+ screen->width = t->horizontal;
+ screen->height = t->vertical;
+
+ /* Now try setting the mode */
+ if (k < 0 || (t->horizontal != var.xres || t->vertical != var.yres))
+ fbdevConvertMonitorTiming (t, &var);
+ }
var.activate = FB_ACTIVATE_NOW;
var.bits_per_pixel = screen->fb[0].depth;
diff --git a/hw/kdrive/i810/Makefile.am b/hw/kdrive/i810/Makefile.am
index ea02cb67d..30919fad9 100644
--- a/hw/kdrive/i810/Makefile.am
+++ b/hw/kdrive/i810/Makefile.am
@@ -23,6 +23,10 @@ I810_LIBS = \
libi810.a \
@KDRIVE_LIBS@
+if GLX
+Xi810_LDFLAGS = $(LD_EXPORT_SYMBOLS_FLAG)
+endif
+
Xi810_LDADD = \
$(I810_LIBS) \
@KDRIVE_LIBS@
diff --git a/hw/kdrive/linux/keyboard.c b/hw/kdrive/linux/keyboard.c
index 3193ab761..ae981b776 100644
--- a/hw/kdrive/linux/keyboard.c
+++ b/hw/kdrive/linux/keyboard.c
@@ -42,6 +42,8 @@
#include <sys/ioctl.h>
extern int LinuxConsoleFd;
+static unsigned char mediumraw_data, mediumraw_up;
+static enum { DEFAULT, EXTBYTE1, EXTBYTE2 } mediumraw_state = DEFAULT;
static const KeySym linux_to_x[256] = {
NoSymbol, NoSymbol, NoSymbol, NoSymbol,
@@ -701,7 +703,29 @@ LinuxKeyboardRead (int fd, void *closure)
else
#endif
scancode = b[0] & 0x7f;
- KdEnqueueKeyboardEvent (closure, scancode, b[0] & 0x80);
+ /* This is extended medium raw mode interpreter
+ see linux/drivers/keyboard.c (kbd->kbdmode == VC_MEDIUMRAW) */
+ switch (mediumraw_state)
+ {
+ case DEFAULT:
+ if (scancode == 0)
+ {
+ mediumraw_state = EXTBYTE1;
+ mediumraw_up = b[0] & 0x80;
+ }
+ else
+ KdEnqueueKeyboardEvent (closure, scancode, b[0] & 0x80);
+ break;
+ case EXTBYTE1:
+ mediumraw_data = scancode;
+ mediumraw_state = EXTBYTE2;
+ break;
+ case EXTBYTE2:
+ /* Note: Only codes < 256 will pass correctly through KdEnqueueKeyboardEvent() */
+ KdEnqueueKeyboardEvent (closure, (int)mediumraw_data << 7 | scancode, mediumraw_up);
+ mediumraw_state = DEFAULT;
+ break;
+ }
b++;
}
}
diff --git a/hw/kdrive/linux/tslib.c b/hw/kdrive/linux/tslib.c
index 371aeced9..50cd7cbd2 100644
--- a/hw/kdrive/linux/tslib.c
+++ b/hw/kdrive/linux/tslib.c
@@ -114,6 +114,10 @@ TslibEnable (KdPointerInfo *pi)
private->raw_event_hook = NULL;
private->raw_event_closure = NULL;
+ if (!pi->path) {
+ pi->path = "/dev/input/touchscreen0";
+ ErrorF("[tslib/TslibEnable] no device path given, trying %s\n", pi->path);
+ }
private->tsDev = ts_open(pi->path, 0);
private->fd = ts_fd(private->tsDev);
if (!private->tsDev || ts_config(private->tsDev) || private->fd < 0) {
diff --git a/hw/kdrive/mach64/Makefile.am b/hw/kdrive/mach64/Makefile.am
index 746ffff8f..6ca376ab2 100644
--- a/hw/kdrive/mach64/Makefile.am
+++ b/hw/kdrive/mach64/Makefile.am
@@ -27,6 +27,10 @@ MACH64_LIBS = \
$(top_builddir)/hw/kdrive/vesa/libvesa.a
+if GLX
+Xmach64_LDFLAGS = $(LD_EXPORT_SYMBOLS_FLAG)
+endif
+
Xmach64_LDADD = \
$(MACH64_LIBS) \
@KDRIVE_LIBS@
diff --git a/hw/kdrive/mga/Makefile.am b/hw/kdrive/mga/Makefile.am
index 37bc50cf2..a7dd2cbf6 100644
--- a/hw/kdrive/mga/Makefile.am
+++ b/hw/kdrive/mga/Makefile.am
@@ -22,6 +22,10 @@ MGA_LIBS = \
$(top_builddir)/hw/kdrive/vesa/libvesa.a \
@KDRIVE_LIBS@
+if GLX
+Xmga_LDFLAGS = $(LD_EXPORT_SYMBOLS_FLAG)
+endif
+
Xmga_LDADD = \
$(MGA_LIBS) \
@KDRIVE_LIBS@
diff --git a/hw/kdrive/neomagic/Makefile.am b/hw/kdrive/neomagic/Makefile.am
index 95f0e1eaa..b449c37c5 100644
--- a/hw/kdrive/neomagic/Makefile.am
+++ b/hw/kdrive/neomagic/Makefile.am
@@ -32,6 +32,10 @@ NEOMAGIC_LIBS = \
${VESA_LIBS} \
@KDRIVE_LIBS@
+if GLX
+Xneomagic_LDFLAGS = $(LD_EXPORT_SYMBOLS_FLAG)
+endif
+
Xneomagic_LDADD = \
$(NEOMAGIC_LIBS) \
@KDRIVE_LIBS@ \
diff --git a/hw/kdrive/nvidia/Makefile.am b/hw/kdrive/nvidia/Makefile.am
index b380e44ee..81736c311 100644
--- a/hw/kdrive/nvidia/Makefile.am
+++ b/hw/kdrive/nvidia/Makefile.am
@@ -23,6 +23,10 @@ NVIDIA_LIBS = \
$(top_builddir)/hw/kdrive/vesa/libvesa.a \
@KDRIVE_LIBS@
+if GLX
+Xnvidia_LDFLAGS = $(LD_EXPORT_SYMBOLS_FLAG)
+endif
+
Xnvidia_LDADD = \
$(NVIDIA_LIBS) \
@KDRIVE_LIBS@
diff --git a/hw/kdrive/pm2/Makefile.am b/hw/kdrive/pm2/Makefile.am
index 208d0319e..cb28de6cb 100644
--- a/hw/kdrive/pm2/Makefile.am
+++ b/hw/kdrive/pm2/Makefile.am
@@ -21,6 +21,10 @@ PM2_LIBS = \
$(top_builddir)/hw/kdrive/vesa/libvesa.a \
@KDRIVE_LIBS@
+if GLX
+Xpm2_LDFLAGS = $(LD_EXPORT_SYMBOLS_FLAG)
+endif
+
Xpm2_LDADD = \
$(PM2_LIBS) \
@KDRIVE_LIBS@
diff --git a/hw/kdrive/r128/Makefile.am b/hw/kdrive/r128/Makefile.am
index 62c1fcfa3..344fbebf7 100644
--- a/hw/kdrive/r128/Makefile.am
+++ b/hw/kdrive/r128/Makefile.am
@@ -20,6 +20,10 @@ R128_LIBS = \
$(top_builddir)/hw/kdrive/vesa/libvesa.a \
@KDRIVE_LIBS@
+if GLX
+Xr128_LDFLAGS = $(LD_EXPORT_SYMBOLS_FLAG)
+endif
+
Xr128_LDADD = \
$(R128_LIBS) \
@KDRIVE_LIBS@
diff --git a/hw/kdrive/sdl/Makefile.am b/hw/kdrive/sdl/Makefile.am
index fe9309e46..a70d147de 100644
--- a/hw/kdrive/sdl/Makefile.am
+++ b/hw/kdrive/sdl/Makefile.am
@@ -7,6 +7,10 @@ bin_PROGRAMS = Xsdl
Xsdl_SOURCES = sdl.c
+if GLX
+Xsdl_LDFLAGS = $(LD_EXPORT_SYMBOLS_FLAG)
+endif
+
Xsdl_LDADD = \
@KDRIVE_LIBS@ \
@XSDL_LIBS@
diff --git a/hw/kdrive/sis300/Makefile.am b/hw/kdrive/sis300/Makefile.am
index 3e8ce90b7..af2500aee 100644
--- a/hw/kdrive/sis300/Makefile.am
+++ b/hw/kdrive/sis300/Makefile.am
@@ -34,6 +34,10 @@ SIS_LIBS = \
$(VESA_LIBS) \
@KDRIVE_LIBS@
+if GLX
+Xsis_LDFLAGS = $(LD_EXPORT_SYMBOLS_FLAG)
+endif
+
Xsis_LDADD = \
$(SIS_LIBS) \
@KDRIVE_LIBS@ \
diff --git a/hw/kdrive/smi/Makefile.am b/hw/kdrive/smi/Makefile.am
index a4d6624c5..bd7077c56 100644
--- a/hw/kdrive/smi/Makefile.am
+++ b/hw/kdrive/smi/Makefile.am
@@ -25,6 +25,10 @@ SMI_LIBS = \
$(top_builddir)/hw/kdrive/vesa/libvesa.a \
@KDRIVE_LIBS@
+if GLX
+Xsmi_LDFLAGS = $(LD_EXPORT_SYMBOLS_FLAG)
+endif
+
Xsmi_LDADD = \
$(SMI_LIBS) \
@KDRIVE_LIBS@
diff --git a/hw/kdrive/vesa/Makefile.am b/hw/kdrive/vesa/Makefile.am
index ac50d2bf5..ec35c1e2b 100644
--- a/hw/kdrive/vesa/Makefile.am
+++ b/hw/kdrive/vesa/Makefile.am
@@ -19,6 +19,10 @@ libvesa_a_SOURCES = \
Xvesa_SOURCES = \
vesainit.c
+if GLX
+Xvesa_LDFLAGS = $(LD_EXPORT_SYMBOLS_FLAG)
+endif
+
Xvesa_LDADD = \
libvesa.a \
@KDRIVE_LIBS@
diff --git a/hw/kdrive/via/Makefile.am b/hw/kdrive/via/Makefile.am
index 249b3f31e..c659379f0 100644
--- a/hw/kdrive/via/Makefile.am
+++ b/hw/kdrive/via/Makefile.am
@@ -21,6 +21,10 @@ VIA_LIBS = \
libvia.a \
$(top_builddir)/hw/kdrive/vesa/libvesa.a
+if GLX
+Xvia_LDFLAGS = $(LD_EXPORT_SYMBOLS_FLAG)
+endif
+
Xvia_LDADD = \
$(VIA_LIBS) \
@KDRIVE_LIBS@
diff --git a/hw/xfree86/common/compiler.h b/hw/xfree86/common/compiler.h
index 73ca3d0ac..9e7f8219d 100644
--- a/hw/xfree86/common/compiler.h
+++ b/hw/xfree86/common/compiler.h
@@ -498,7 +498,7 @@ extern unsigned int inb(unsigned long port);
extern unsigned int inw(unsigned long port);
extern unsigned int inl(unsigned long port);
-# elif defined(linux) && defined(__amd64__)
+# elif defined(linux) && (defined(__amd64__) || defined(__x86_64__))
# include <inttypes.h>
@@ -1363,7 +1363,7 @@ do { \
# define write_mem_barrier() /* NOP */
# if !defined(__SUNPRO_C)
-# if !defined(FAKEIT) && !defined(__mc68000__) && !defined(__arm__) && !defined(__sh__) && !defined(__hppa__) && !defined(__s390__)
+# if !defined(FAKEIT) && !defined(__mc68000__) && !defined(__arm__) && !defined(__sh__) && !defined(__hppa__) && !defined(__s390__) && !defined(__m32r__)
# ifdef GCCUSESGAS
/*
@@ -1472,7 +1472,7 @@ inl(unsigned short port)
# endif /* GCCUSESGAS */
-# else /* !defined(FAKEIT) && !defined(__mc68000__) && !defined(__arm__) && !defined(__sh__) && !defined(__hppa__)*/
+# else /* !defined(FAKEIT) && !defined(__mc68000__) && !defined(__arm__) && !defined(__sh__) && !defined(__hppa__) && !defined(__m32r__) */
static __inline__ void
outb(unsigned short port, unsigned char val)
diff --git a/hw/xfree86/common/xf86.h b/hw/xfree86/common/xf86.h
index 4b3e10463..065102fb5 100644
--- a/hw/xfree86/common/xf86.h
+++ b/hw/xfree86/common/xf86.h
@@ -71,6 +71,7 @@ extern Bool sbusSlotClaimed;
#endif
extern confDRIRec xf86ConfigDRI;
extern Bool xf86inSuspend;
+extern Bool xf86DRI2Enabled(void);
#define XF86SCRNINFO(p) ((ScrnInfoPtr)dixLookupPrivate(&(p)->devPrivates, \
xf86ScreenKey))
diff --git a/hw/xfree86/common/xf86AutoConfig.c b/hw/xfree86/common/xf86AutoConfig.c
index 3210e4460..7e5fab412 100644
--- a/hw/xfree86/common/xf86AutoConfig.c
+++ b/hw/xfree86/common/xf86AutoConfig.c
@@ -146,7 +146,11 @@ videoPtrToDriverName(struct pci_device *dev)
switch (dev->vendor_id)
{
- case 0x1022: return "amd";
+ case 0x1022:
+ if (dev->device_id == 0x2081)
+ return "geode";
+ else
+ return NULL;
case 0x1142: return "apm";
case 0xedd8: return "ark";
case 0x1a03: return "ast";
@@ -326,86 +330,87 @@ matchDriverFromFiles (char** matches, uint16_t match_vendor, uint16_t match_chip
int i, j;
idsdir = opendir(PCI_TXT_IDS_PATH);
- if (idsdir) {
- xf86Msg(X_INFO, "Scanning %s directory for additional PCI ID's supported by the drivers\n", PCI_TXT_IDS_PATH);
- direntry = readdir(idsdir);
- /* Read the directory */
- while (direntry) {
- if (direntry->d_name[0] == '.') {
- direntry = readdir(idsdir);
- continue;
+ if (!idsdir)
+ return;
+
+ xf86Msg(X_INFO, "Scanning %s directory for additional PCI ID's supported by the drivers\n", PCI_TXT_IDS_PATH);
+ direntry = readdir(idsdir);
+ /* Read the directory */
+ while (direntry) {
+ if (direntry->d_name[0] == '.') {
+ direntry = readdir(idsdir);
+ continue;
+ }
+ len = strlen(direntry->d_name);
+ /* A tiny bit of sanity checking. We should probably do better */
+ if (strncmp(&(direntry->d_name[len-4]), ".ids", 4) == 0) {
+ /* We need the full path name to open the file */
+ strncpy(path_name, PCI_TXT_IDS_PATH, 256);
+ strncat(path_name, "/", 1);
+ strncat(path_name, direntry->d_name, (256 - strlen(path_name) - 1));
+ fp = fopen(path_name, "r");
+ if (fp == NULL) {
+ xf86Msg(X_ERROR, "Could not open %s for reading. Exiting.\n", path_name);
+ goto end;
}
- len = strlen(direntry->d_name);
- /* A tiny bit of sanity checking. We should probably do better */
- if (strncmp(&(direntry->d_name[len-4]), ".ids", 4) == 0) {
- /* We need the full path name to open the file */
- strncpy(path_name, PCI_TXT_IDS_PATH, 256);
- strncat(path_name, "/", 1);
- strncat(path_name, direntry->d_name, (256 - strlen(path_name) - 1));
- fp = fopen(path_name, "r");
- if (fp == NULL) {
- xf86Msg(X_ERROR, "Could not open %s for reading. Exiting.\n", path_name);
- goto end;
- }
- /* Read the file */
- #ifdef __GLIBC__
- while ((read = getline(&line, &len, fp)) != -1) {
- #else
- while ((line = fgetln(fp, &len)) != (char *)NULL) {
- #endif /* __GLIBC __ */
- xchomp(line);
- if (isdigit(line[0])) {
- strncpy(vendor_str, line, 4);
- vendor_str[4] = '\0';
- vendor = (int)strtol(vendor_str, NULL, 16);
- if ((strlen(&line[4])) == 0) {
- chip_str[0] = '\0';
- chip = -1;
+ /* Read the file */
+#ifdef __GLIBC__
+ while ((read = getline(&line, &len, fp)) != -1) {
+#else
+ while ((line = fgetln(fp, &len)) != (char *)NULL) {
+#endif /* __GLIBC __ */
+ xchomp(line);
+ if (isdigit(line[0])) {
+ strncpy(vendor_str, line, 4);
+ vendor_str[4] = '\0';
+ vendor = (int)strtol(vendor_str, NULL, 16);
+ if ((strlen(&line[4])) == 0) {
+ chip_str[0] = '\0';
+ chip = -1;
+ } else {
+ /* Handle trailing whitespace */
+ if (isspace(line[4])) {
+ chip_str[0] = '\0';
+ chip = -1;
} else {
- /* Handle trailing whitespace */
- if (isspace(line[4])) {
- chip_str[0] = '\0';
- chip = -1;
- } else {
- /* Ok, it's a real ID */
- strncpy(chip_str, &line[4], 4);
- chip_str[4] = '\0';
- chip = (int)strtol(chip_str, NULL, 16);
- }
+ /* Ok, it's a real ID */
+ strncpy(chip_str, &line[4], 4);
+ chip_str[4] = '\0';
+ chip = (int)strtol(chip_str, NULL, 16);
}
- if (vendor == match_vendor && chip == match_chip ) {
- i = 0;
- while (matches[i]) {
- i++;
- }
- matches[i] = (char*)xalloc(sizeof(char) * strlen(direntry->d_name) - 3);
- if (!matches[i]) {
- xf86Msg(X_ERROR, "Could not allocate space for the module name. Exiting.\n");
- goto end;
- }
- /* hack off the .ids suffix. This should guard
- * against other problems, but it will end up
- * taking off anything after the first '.' */
- for (j = 0; j < (strlen(direntry->d_name) - 3) ; j++) {
- if (direntry->d_name[j] == '.') {
- matches[i][j] = '\0';
- break;
- } else {
- matches[i][j] = direntry->d_name[j];
- }
+ }
+ if (vendor == match_vendor && chip == match_chip ) {
+ i = 0;
+ while (matches[i]) {
+ i++;
+ }
+ matches[i] = (char*)xalloc(sizeof(char) * strlen(direntry->d_name) - 3);
+ if (!matches[i]) {
+ xf86Msg(X_ERROR, "Could not allocate space for the module name. Exiting.\n");
+ goto end;
+ }
+ /* hack off the .ids suffix. This should guard
+ * against other problems, but it will end up
+ * taking off anything after the first '.' */
+ for (j = 0; j < (strlen(direntry->d_name) - 3) ; j++) {
+ if (direntry->d_name[j] == '.') {
+ matches[i][j] = '\0';
+ break;
+ } else {
+ matches[i][j] = direntry->d_name[j];
}
- xf86Msg(X_INFO, "Matched %s from file name %s\n", matches[i], direntry->d_name);
}
- } else {
- /* TODO Handle driver overrides here */
+ xf86Msg(X_INFO, "Matched %s from file name %s\n", matches[i], direntry->d_name);
}
+ } else {
+ /* TODO Handle driver overrides here */
}
- fclose(fp);
}
- direntry = readdir(idsdir);
+ fclose(fp);
}
+ direntry = readdir(idsdir);
}
- end:
+ end:
xfree(line);
closedir(idsdir);
}
@@ -449,7 +454,7 @@ chooseVideoDriver(void)
if (info != NULL)
chosen_driver = videoPtrToDriverName(info);
if (chosen_driver == NULL) {
-#if defined __i386__ || defined __amd64__ || defined __hurd__
+#if defined __i386__ || defined __amd64__ || defined __x86_64__ || defined __hurd__
chosen_driver = "vesa";
#elif defined __sparc__
chosen_driver = "sunffb";
diff --git a/hw/xfree86/common/xf86Bus.c b/hw/xfree86/common/xf86Bus.c
index f7ffac85e..7e6b93a10 100644
--- a/hw/xfree86/common/xf86Bus.c
+++ b/hw/xfree86/common/xf86Bus.c
@@ -2773,7 +2773,7 @@ xf86FindPrimaryDevice()
}
}
-#if !defined(__sparc) && !defined(__sparc__) && !defined(__powerpc__) && !defined(__mips__) && !defined(__arm__)
+#if !defined(__sparc) && !defined(__sparc__) && !defined(__powerpc__) && !defined(__mips__) && !defined(__arm__) && !defined(__m32r__)
#include "vgaHW.h"
#include "compiler.h"
#endif
@@ -2785,7 +2785,7 @@ static void
CheckGenericGA()
{
/* This needs to be changed for multiple domains */
-#if !defined(__sparc__) && !defined(__sparc) && !defined(__powerpc__) && !defined(__mips__) && !defined(__ia64__) && !defined(__arm__) && !defined(__s390__)
+#if !defined(__sparc__) && !defined(__sparc) && !defined(__powerpc__) && !defined(__mips__) && !defined(__ia64__) && !defined(__arm__) && !defined(__s390__) && !defined(__m32r__)
IOADDRESS GenericIOBase = VGAHW_GET_IOBASE();
CARD8 CurrentValue, TestValue;
diff --git a/hw/xfree86/common/xf86Config.c b/hw/xfree86/common/xf86Config.c
index 3cc04f0a1..8e412b56d 100644
--- a/hw/xfree86/common/xf86Config.c
+++ b/hw/xfree86/common/xf86Config.c
@@ -766,6 +766,7 @@ typedef enum {
FLAG_AUTO_ADD_DEVICES,
FLAG_AUTO_ENABLE_DEVICES,
FLAG_GLX_VISUALS,
+ FLAG_DRI2,
} FlagValues;
static OptionInfoRec FlagOptions[] = {
@@ -837,16 +838,18 @@ static OptionInfoRec FlagOptions[] = {
{0}, FALSE },
{ FLAG_ALLOW_EMPTY_INPUT, "AllowEmptyInput", OPTV_BOOLEAN,
{0}, FALSE },
- { FLAG_IGNORE_ABI, "IgnoreABI", OPTV_BOOLEAN,
+ { FLAG_IGNORE_ABI, "IgnoreABI", OPTV_BOOLEAN,
{0}, FALSE },
- { FLAG_USE_DEFAULT_FONT_PATH, "UseDefaultFontPath", OPTV_BOOLEAN,
+ { FLAG_USE_DEFAULT_FONT_PATH, "UseDefaultFontPath", OPTV_BOOLEAN,
{0}, FALSE },
- { FLAG_AUTO_ADD_DEVICES, "AutoAddDevices", OPTV_BOOLEAN,
+ { FLAG_AUTO_ADD_DEVICES, "AutoAddDevices", OPTV_BOOLEAN,
{0}, TRUE },
- { FLAG_AUTO_ENABLE_DEVICES, "AutoEnableDevices", OPTV_BOOLEAN,
+ { FLAG_AUTO_ENABLE_DEVICES, "AutoEnableDevices", OPTV_BOOLEAN,
{0}, TRUE },
{ FLAG_GLX_VISUALS, "GlxVisuals", OPTV_STRING,
{0}, FALSE },
+ { FLAG_DRI2, "DRI2", OPTV_BOOLEAN,
+ {0}, FALSE },
{ -1, NULL, OPTV_NONE,
{0}, FALSE },
};
@@ -1179,9 +1182,23 @@ configServerFlags(XF86ConfFlagsPtr flagsconf, XF86OptionPtr layoutopts)
xf86Msg(from, "Xinerama: enabled\n");
#endif
+#ifdef DRI2
+ xf86Info.dri2 = FALSE;
+ xf86Info.dri2From = X_DEFAULT;
+ if (xf86GetOptValBool(FlagOptions, FLAG_DRI2, &value)) {
+ xf86Info.dri2 = value;
+ xf86Info.dri2From = X_CONFIG;
+ }
+#endif
+
return TRUE;
}
+Bool xf86DRI2Enabled(void)
+{
+ return xf86Info.dri2;
+}
+
/*
* Locate the core input devices. These can be specified/located in
* the following ways, in order of priority:
diff --git a/hw/xfree86/common/xf86Init.c b/hw/xfree86/common/xf86Init.c
index 6d5eaadc3..68dc38772 100644
--- a/hw/xfree86/common/xf86Init.c
+++ b/hw/xfree86/common/xf86Init.c
@@ -1123,37 +1123,35 @@ InitInput(argc, argv)
xf86Info.vtRequestsPending = FALSE;
xf86Info.inputPending = FALSE;
- if (serverGeneration == 1) {
- /* Call the PreInit function for each input device instance. */
- for (pDev = xf86ConfigLayout.inputs; pDev && *pDev; pDev++) {
- /* Replace obsolete keyboard driver with kbd */
- if (!xf86NameCmp((*pDev)->driver, "keyboard")) {
- strcpy((*pDev)->driver, "kbd");
- }
-
- if ((pDrv = xf86LookupInputDriver((*pDev)->driver)) == NULL) {
- xf86Msg(X_ERROR, "No Input driver matching `%s'\n", (*pDev)->driver);
- /* XXX For now, just continue. */
- continue;
- }
- if (!pDrv->PreInit) {
- xf86MsgVerb(X_WARNING, 0,
- "Input driver `%s' has no PreInit function (ignoring)\n",
- pDrv->driverName);
- continue;
- }
- pInfo = pDrv->PreInit(pDrv, *pDev, 0);
- if (!pInfo) {
- xf86Msg(X_ERROR, "PreInit returned NULL for \"%s\"\n",
- (*pDev)->identifier);
- continue;
- } else if (!(pInfo->flags & XI86_CONFIGURED)) {
- xf86Msg(X_ERROR, "PreInit failed for input device \"%s\"\n",
- (*pDev)->identifier);
- xf86DeleteInput(pInfo, 0);
- continue;
- }
- }
+ /* Call the PreInit function for each input device instance. */
+ for (pDev = xf86ConfigLayout.inputs; pDev && *pDev; pDev++) {
+ /* Replace obsolete keyboard driver with kbd */
+ if (!xf86NameCmp((*pDev)->driver, "keyboard")) {
+ strcpy((*pDev)->driver, "kbd");
+ }
+
+ if ((pDrv = xf86LookupInputDriver((*pDev)->driver)) == NULL) {
+ xf86Msg(X_ERROR, "No Input driver matching `%s'\n", (*pDev)->driver);
+ /* XXX For now, just continue. */
+ continue;
+ }
+ if (!pDrv->PreInit) {
+ xf86MsgVerb(X_WARNING, 0,
+ "Input driver `%s' has no PreInit function (ignoring)\n",
+ pDrv->driverName);
+ continue;
+ }
+ pInfo = pDrv->PreInit(pDrv, *pDev, 0);
+ if (!pInfo) {
+ xf86Msg(X_ERROR, "PreInit returned NULL for \"%s\"\n",
+ (*pDev)->identifier);
+ continue;
+ } else if (!(pInfo->flags & XI86_CONFIGURED)) {
+ xf86Msg(X_ERROR, "PreInit failed for input device \"%s\"\n",
+ (*pDev)->identifier);
+ xf86DeleteInput(pInfo, 0);
+ continue;
+ }
}
/* Initialise all input devices. */
diff --git a/hw/xfree86/common/xf86Privstr.h b/hw/xfree86/common/xf86Privstr.h
index d97ca440e..8cab56ec8 100644
--- a/hw/xfree86/common/xf86Privstr.h
+++ b/hw/xfree86/common/xf86Privstr.h
@@ -149,6 +149,9 @@ typedef struct {
Bool autoAddDevices; /* Whether to succeed NIDR, or ignore. */
Bool autoEnableDevices; /* Whether to enable, or let the client
* control. */
+
+ Bool dri2;
+ MessageType dri2From;
} xf86InfoRec, *xf86InfoPtr;
#ifdef DPMSExtension
diff --git a/hw/xfree86/common/xf86Xinput.c b/hw/xfree86/common/xf86Xinput.c
index d34238edc..710e787fd 100644
--- a/hw/xfree86/common/xf86Xinput.c
+++ b/hw/xfree86/common/xf86Xinput.c
@@ -448,6 +448,8 @@ DeleteInputDeviceRequest(DeviceIntPtr pDev)
LocalDevicePtr pInfo = (LocalDevicePtr) pDev->public.devicePrivate;
InputDriverPtr drv;
IDevRec *idev;
+ BOOL found;
+ IDevPtr *it;
if (pInfo) /* need to get these before RemoveDevice */
{
@@ -464,10 +466,18 @@ DeleteInputDeviceRequest(DeviceIntPtr pDev)
else
xf86DeleteInput(pInfo, 0);
- xfree(idev->driver);
- xfree(idev->identifier);
- xf86optionListFree(idev->commonOptions);
- xfree(idev);
+ /* devices added through HAL aren't in the config layout */
+ it = xf86ConfigLayout.inputs;
+ while(*it && *it != idev)
+ it++;
+
+ if (!(*it)) /* end of list, not in the layout */
+ {
+ xfree(idev->driver);
+ xfree(idev->identifier);
+ xf86optionListFree(idev->commonOptions);
+ xfree(idev);
+ }
}
/*
diff --git a/hw/xfree86/dixmods/GLcoremodule.c b/hw/xfree86/dixmods/GLcoremodule.c
deleted file mode 100644
index d55cb78a7..000000000
--- a/hw/xfree86/dixmods/GLcoremodule.c
+++ /dev/null
@@ -1,63 +0,0 @@
-/**************************************************************************
-
-Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas.
-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 <kevin@precisioninsight.com>
- *
- */
-
-#ifdef HAVE_XORG_CONFIG_H
-#include <xorg-config.h>
-#endif
-
-#include "xf86Module.h"
-
-static MODULESETUPPROTO(GLcoreSetup);
-
-static XF86ModuleVersionInfo VersRec =
-{
- "GLcore",
- MODULEVENDORSTRING,
- MODINFOSTRING1,
- MODINFOSTRING2,
- XORG_VERSION_CURRENT,
- 1, 0, 0,
- ABI_CLASS_EXTENSION,
- ABI_EXTENSION_VERSION,
- MOD_CLASS_NONE,
- {0,0,0,0}
-};
-
-_X_EXPORT XF86ModuleData GLcoreModuleData = { &VersRec, GLcoreSetup, NULL };
-
-static pointer
-GLcoreSetup(pointer module, pointer opts, int *errmaj, int *errmin)
-{
- /* Need a non-NULL return value to indicate success */
- return (pointer)1;
-}
diff --git a/hw/xfree86/dixmods/Makefile.am b/hw/xfree86/dixmods/Makefile.am
index 67967c52d..beff9b175 100644
--- a/hw/xfree86/dixmods/Makefile.am
+++ b/hw/xfree86/dixmods/Makefile.am
@@ -3,7 +3,7 @@ noinst_LTLIBRARIES = libdixmods.la libxorgxkb.la
SUBDIRS = extmod
if GLX
-GLXMODS = libglx.la libGLcore.la
+GLXMODS = libglx.la
endif
if XTRAP
@@ -48,10 +48,6 @@ INCLUDES = @XORG_INCS@ \
-I$(top_srcdir)/miext/shadow \
-I$(top_srcdir)/GL/glx
-libGLcore_la_LDFLAGS = -avoid-version
-libGLcore_la_LIBADD = $(top_builddir)/GL/mesa/libGLcore.la
-libGLcore_la_SOURCES = GLcoremodule.c
-
libafb_la_LDFLAGS = -avoid-version
libafb_la_LIBADD = $(top_builddir)/afb/libafb.la
libafb_la_SOURCES = afbmodule.c
diff --git a/hw/xfree86/dixmods/extmod/modinit.c b/hw/xfree86/dixmods/extmod/modinit.c
index 8c8a4ceeb..f8440f127 100644
--- a/hw/xfree86/dixmods/extmod/modinit.c
+++ b/hw/xfree86/dixmods/extmod/modinit.c
@@ -65,15 +65,6 @@ static ExtensionModule extensionModules[] = {
NULL
},
#endif
-#ifdef MITMISC
- {
- MITMiscExtensionInit,
- MITMISCNAME,
- &noMITMiscExtension,
- NULL,
- NULL
- },
-#endif
#ifdef notyet
{
XTestExtensionInit,
@@ -164,24 +155,6 @@ static ExtensionModule extensionModules[] = {
NULL
},
#endif
-#ifdef TOGCUP
- {
- XcupExtensionInit,
- XCUPNAME,
- &noXcupExtension,
- NULL,
- NULL
- },
-#endif
-#ifdef EVI
- {
- EVIExtensionInit,
- EVINAME,
- &noEVIExtension,
- NULL,
- NULL
- },
-#endif
#ifdef XV
{
XvExtensionInit,
diff --git a/hw/xfree86/dixmods/extmod/modinit.h b/hw/xfree86/dixmods/extmod/modinit.h
index 3c2e2022a..7282e6e06 100644
--- a/hw/xfree86/dixmods/extmod/modinit.h
+++ b/hw/xfree86/dixmods/extmod/modinit.h
@@ -18,12 +18,6 @@ extern void MultibufferExtensionInit(INITARGS);
#include <X11/extensions/multibufst.h>
#endif
-#ifdef MITMISC
-extern void MITMiscExtensionInit(INITARGS);
-#define _MITMISC_SERVER_
-#include <X11/extensions/mitmiscstr.h>
-#endif
-
#ifdef XTEST
extern void XTestExtensionInit(INITARGS);
#define _XTEST_SERVER_
@@ -89,18 +83,6 @@ extern void FontCacheExtensionInit(INITARGS);
#include "fontcachstr.h"
#endif
-#ifdef TOGCUP
-extern void XcupExtensionInit(INITARGS);
-#define _XCUP_SERVER_
-#include <X11/extensions/Xcupstr.h>
-#endif
-
-#ifdef EVI
-extern void EVIExtensionInit(INITARGS);
-#define _XEVI_SERVER_
-#include <X11/extensions/XEVIstr.h>
-#endif
-
#ifdef XV
extern void XvExtensionInit(INITARGS);
extern void XvMCExtensionInit(INITARGS);
@@ -135,14 +117,6 @@ extern void SecurityExtensionInit(INITARGS);
#endif
#if 1
-extern void XagExtensionInit(INITARGS);
-#endif
-
-#if 1
-extern void XpExtensionInit(INITARGS);
-#endif
-
-#if 1
extern void PanoramiXExtensionInit(int argc, char *argv[]);
#endif
diff --git a/hw/xfree86/dixmods/glxmodule.c b/hw/xfree86/dixmods/glxmodule.c
index a1a088629..88091cd69 100644
--- a/hw/xfree86/dixmods/glxmodule.c
+++ b/hw/xfree86/dixmods/glxmodule.c
@@ -72,37 +72,6 @@ static XF86ModuleVersionInfo VersRec =
_X_EXPORT XF86ModuleData glxModuleData = { &VersRec, glxSetup, NULL };
-/* We do a little proxy dance here, so we can avoid loading GLcore
- * unless we really need to.*/
-
-static pointer glxModule;
-
-static __GLXscreen *
-__glXMesaProxyScreenProbe(ScreenPtr pScreen)
-{
- pointer GLcore;
- static __GLXprovider *provider;
-
- if (provider == NULL) {
- GLcore = LoadSubModule(glxModule, "GLcore", NULL, NULL, NULL, NULL,
- NULL, NULL);
- if (GLcore == NULL)
- return NULL;
-
- provider = LoaderSymbol("__glXMesaProvider");
- if (provider == NULL)
- return NULL;
- }
-
- return provider->screenProbe(pScreen);
-}
-
-static __GLXprovider __glXMesaProxyProvider = {
- __glXMesaProxyScreenProbe,
- "MESA-PROXY",
- NULL
-};
-
static pointer
glxSetup(pointer module, pointer opts, int *errmaj, int *errmin)
{
@@ -116,8 +85,10 @@ glxSetup(pointer module, pointer opts, int *errmaj, int *errmin)
setupDone = TRUE;
- glxModule = module;
- GlxPushProvider(&__glXMesaProxyProvider);
+ provider = LoaderSymbol("__glXMesaProvider");
+ if (provider == NULL)
+ return NULL;
+ GlxPushProvider(provider);
xf86Msg(xf86Info.aiglxFrom, "AIGLX %s\n",
xf86Info.aiglx ? "enabled" : "disabled");
diff --git a/hw/xfree86/doc/man/xorg.conf.man.pre b/hw/xfree86/doc/man/xorg.conf.man.pre
index 9f3980879..8b66f89a6 100644
--- a/hw/xfree86/doc/man/xorg.conf.man.pre
+++ b/hw/xfree86/doc/man/xorg.conf.man.pre
@@ -54,7 +54,7 @@ is the relative path (with no \(lq..\(rq components) specified by that
environment variable, and
.I <hostname>
is the machine's hostname as reported by
-.BR gethostname (__oslibmansuffix__).
+.BR gethostname (__libmansuffix__).
.PP
When the __xservername__ server is started by the \(lqroot\(rq user, the config file
search locations are as follows:
@@ -93,7 +93,7 @@ is the path specified by that environment variable (usually the home
directory), and
.I <hostname>
is the machine's hostname as reported by
-.BR gethostname (__oslibmansuffix__).
+.BR gethostname (__libmansuffix__).
.PP
The
.I __xconfigfile__
@@ -1624,8 +1624,8 @@ Others are driver\-independent, and will eventually be described here.
.\" XXX These should really be in an xaa man page.
.TP 7
.BI "Option \*qAccel\*q"
-Enables XAA (X Acceleration Architecture), a mechanism that makes video
-cards' 2D hardware acceleration available to the __xservername__ server.
+Enables XAA (X Acceleration Architecture), a mechanism that makes video cards'
+2D hardware acceleration available to the __xservername__ server.
This option is on by default, but it may be necessary to turn it off if
there are bugs in the driver.
There are many options to disable specific accelerated operations, listed
diff --git a/hw/xfree86/dri/dri.c b/hw/xfree86/dri/dri.c
index b736c6ae0..ef1a6ea0a 100644
--- a/hw/xfree86/dri/dri.c
+++ b/hw/xfree86/dri/dri.c
@@ -2436,7 +2436,7 @@ static void drmSIGIOHandler(int interrupt, void *closure)
#if 0
fprintf(stderr, "Trying %d\n", entry->fd);
#endif
- if ((count = read(entry->fd, buf, sizeof(buf))) > 0) {
+ if ((count = read(entry->fd, buf, sizeof(buf) - 1)) > 0) {
buf[count] = '\0';
#if 0
fprintf(stderr, "Got %s\n", buf);
diff --git a/hw/xfree86/loader/dixsym.c b/hw/xfree86/loader/dixsym.c
index d6d22c4b9..61dec59c4 100644
--- a/hw/xfree86/loader/dixsym.c
+++ b/hw/xfree86/loader/dixsym.c
@@ -358,9 +358,6 @@ _X_HIDDEN void *dixLookupTab[] = {
#ifdef DPMSExtension
SYMVAR(noDPMSExtension)
#endif
-#ifdef EVI
- SYMVAR(noEVIExtension)
-#endif
#ifdef FONTCACHE
SYMVAR(noFontCacheExtension)
#endif
@@ -373,9 +370,6 @@ _X_HIDDEN void *dixLookupTab[] = {
#ifdef MITSHM
SYMVAR(noMITShmExtension)
#endif
-#ifdef MITMISC
- SYMVAR(noMITMiscExtension)
-#endif
#ifdef MULTIBUFFER
SYMVAR(noMultibufferExtension)
#endif
@@ -394,15 +388,9 @@ _X_HIDDEN void *dixLookupTab[] = {
#ifdef XSYNC
SYMVAR(noSyncExtension)
#endif
-#ifdef TOGCUP
- SYMVAR(noXcupExtension)
-#endif
#ifdef RES
SYMVAR(noResExtension)
#endif
-#ifdef XAPPGROUP
- SYMVAR(noXagExtension)
-#endif
#ifdef XCMISC
SYMVAR(noXCMiscExtension)
#endif
diff --git a/hw/xfree86/loader/loader.c b/hw/xfree86/loader/loader.c
index 774a4c4a0..a00269b70 100644
--- a/hw/xfree86/loader/loader.c
+++ b/hw/xfree86/loader/loader.c
@@ -63,7 +63,7 @@
#include <string.h>
#if defined(linux) && \
(defined(__alpha__) || defined(__powerpc__) || defined(__ia64__) \
- || defined(__amd64__))
+ || defined(__amd64__) || defined(__x86_64__))
#include <malloc.h>
#endif
#include <stdarg.h>
diff --git a/hw/xfree86/loader/xf86sym.c b/hw/xfree86/loader/xf86sym.c
index 24fc44c1b..9833d34a3 100644
--- a/hw/xfree86/loader/xf86sym.c
+++ b/hw/xfree86/loader/xf86sym.c
@@ -942,6 +942,7 @@ _X_HIDDEN void *xfree86LookupTab[] = {
SYMFUNC(xf86CrtcDestroy)
SYMFUNC(xf86CrtcInUse)
SYMFUNC(xf86CrtcSetScreenSubpixelOrder)
+ SYMFUNC(xf86RotateFreeShadow)
SYMFUNC(xf86RotateCloseScreen)
SYMFUNC(xf86CrtcRotate)
SYMFUNC(xf86CrtcSetMode)
diff --git a/hw/xfree86/modes/xf86Crtc.h b/hw/xfree86/modes/xf86Crtc.h
index 6d7a9b1bf..4d4d96786 100644
--- a/hw/xfree86/modes/xf86Crtc.h
+++ b/hw/xfree86/modes/xf86Crtc.h
@@ -680,6 +680,12 @@ Bool
xf86CrtcRotate (xf86CrtcPtr crtc);
/*
+ * free shadow memory allocated for all crtcs
+ */
+void
+xf86RotateFreeShadow(ScrnInfoPtr pScrn);
+
+/*
* Clean up rotation during CloseScreen
*/
void
diff --git a/hw/xfree86/modes/xf86Rotate.c b/hw/xfree86/modes/xf86Rotate.c
index 0090658da..c6cc51e29 100644
--- a/hw/xfree86/modes/xf86Rotate.c
+++ b/hw/xfree86/modes/xf86Rotate.c
@@ -311,8 +311,7 @@ xf86RotateDestroy (xf86CrtcPtr crtc)
}
for (c = 0; c < xf86_config->num_crtc; c++)
- if (xf86_config->crtc[c]->rotatedPixmap ||
- xf86_config->crtc[c]->rotatedData)
+ if (xf86_config->crtc[c]->transform_in_use)
return;
/*
@@ -333,6 +332,24 @@ xf86RotateDestroy (xf86CrtcPtr crtc)
}
_X_EXPORT void
+xf86RotateFreeShadow(ScrnInfoPtr pScrn)
+{
+ xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(pScrn);
+ int c;
+
+ for (c = 0; c < config->num_crtc; c++) {
+ xf86CrtcPtr crtc = config->crtc[c];
+
+ if (crtc->rotatedPixmap || crtc->rotatedData) {
+ crtc->funcs->shadow_destroy(crtc, crtc->rotatedPixmap,
+ crtc->rotatedData);
+ crtc->rotatedPixmap = NULL;
+ crtc->rotatedData = NULL;
+ }
+ }
+}
+
+_X_EXPORT void
xf86RotateCloseScreen (ScreenPtr screen)
{
ScrnInfoPtr scrn = xf86Screens[screen->myNum];
diff --git a/hw/xfree86/os-support/bsd/bsdResource.c b/hw/xfree86/os-support/bsd/bsdResource.c
index fe166c845..d1ee787f1 100644
--- a/hw/xfree86/os-support/bsd/bsdResource.c
+++ b/hw/xfree86/os-support/bsd/bsdResource.c
@@ -19,7 +19,7 @@
#ifdef INCLUDE_XF86_NO_DOMAIN
-#if defined(__alpha__) || defined(__sparc64__) || defined(__amd64__)
+#if defined(__alpha__) || defined(__sparc64__) || defined(__amd64__) || defined(__x86_64__)
resPtr
xf86AccResFromOS(resPtr ret)
diff --git a/hw/xfree86/os-support/bsd/i386_video.c b/hw/xfree86/os-support/bsd/i386_video.c
index 1ebac678d..e2f6420d8 100644
--- a/hw/xfree86/os-support/bsd/i386_video.c
+++ b/hw/xfree86/os-support/bsd/i386_video.c
@@ -55,7 +55,7 @@
#endif
#endif
-#if defined(__OpenBSD__) && defined(__amd64__)
+#if defined(__OpenBSD__) && (defined(__amd64__) || defined(__x86_64__))
#include <machine/mtrr.h>
#include <machine/sysarch.h>
#endif
@@ -108,7 +108,7 @@ static pointer NetBSDsetWC(int, unsigned long, unsigned long, Bool,
MessageType);
static void NetBSDundoWC(int, pointer);
#endif
-#if defined(__amd64__) && defined(__OpenBSD__)
+#if (defined(__amd64__) || defined(__x86_64__)) && defined(__OpenBSD__)
static pointer amd64setWC(int, unsigned long, unsigned long, Bool,
MessageType);
static void amd64undoWC(int, pointer);
@@ -229,7 +229,7 @@ xf86OSInitVidMem(VidMemInfoPtr pVidMem)
pVidMem->setWC = NetBSDsetWC;
pVidMem->undoWC = NetBSDundoWC;
#endif
-#if defined(__amd64__) && defined(__OpenBSD__)
+#if (defined(__amd64__) || defined(__x86_64__)) && defined(__OpenBSD__)
pVidMem->setWC = amd64setWC;
pVidMem->undoWC = amd64undoWC;
#endif
@@ -953,7 +953,7 @@ NetBSDundoWC(int screenNum, pointer list)
}
#endif
-#if defined(__OpenBSD__) && defined(__amd64__)
+#if defined(__OpenBSD__) && (defined(__amd64__) || defined(__x86_64__))
static pointer
amd64setWC(int screenNum, unsigned long base, unsigned long size, Bool enable,
MessageType from)
diff --git a/hw/xfree86/os-support/bus/Pci.h b/hw/xfree86/os-support/bus/Pci.h
index ebac0905b..1385eee85 100644
--- a/hw/xfree86/os-support/bus/Pci.h
+++ b/hw/xfree86/os-support/bus/Pci.h
@@ -237,6 +237,12 @@
# if defined(linux)
# define ARCH_PCI_INIT linuxPciInit
# endif
+#elif defined(__m32r__)
+# if defined(linux)
+# define ARCH_PCI_INIT linuxPciInit
+# define INCLUDE_XF86_MAP_PCI_MEM
+# define INCLUDE_XF86_NO_DOMAIN
+# endif
#elif defined(__sparc__) || defined(sparc)
# if defined(linux)
# define ARCH_PCI_INIT linuxPciInit
@@ -246,7 +252,7 @@
# if !defined(__FreeBSD__) && !defined(linux)
# define ARCH_PCI_PCI_BRIDGE sparcPciPciBridge
# endif
-#elif defined(__amd64__) || defined(__amd64)
+#elif defined(__amd64__) || defined(__amd64) || defined(__x86_64__)
# if defined(linux)
# define ARCH_PCI_INIT linuxPciInit
# else
diff --git a/hw/xfree86/os-support/linux/lnxResource.c b/hw/xfree86/os-support/linux/lnxResource.c
index 67af9db3d..734f4d674 100644
--- a/hw/xfree86/os-support/linux/lnxResource.c
+++ b/hw/xfree86/os-support/linux/lnxResource.c
@@ -65,6 +65,7 @@ xf86AccResFromOS(resPtr ret)
defined(__sparc__) || \
defined(__mips__) || \
defined(__sh__) || \
+ defined(__m32r__) || \
defined(__mc68000__) || \
defined(__arm__) || \
defined(__s390__) || \
diff --git a/hw/xfree86/os-support/linux/lnx_video.c b/hw/xfree86/os-support/linux/lnx_video.c
index 1bd2d575f..429593784 100644
--- a/hw/xfree86/os-support/linux/lnx_video.c
+++ b/hw/xfree86/os-support/linux/lnx_video.c
@@ -558,7 +558,7 @@ xf86EnableIO(void)
#endif
}
close(fd);
-#elif !defined(__mc68000__) && !defined(__sparc__) && !defined(__mips__) && !defined(__sh__) && !defined(__hppa__) && !defined(__s390__) && !defined(__arm__)
+#elif !defined(__mc68000__) && !defined(__sparc__) && !defined(__mips__) && !defined(__sh__) && !defined(__hppa__) && !defined(__s390__) && !defined(__arm__) && !defined(__m32r__)
if (ioperm(0, 1024, 1) || iopl(3)) {
if (errno == ENODEV)
ErrorF("xf86EnableIOPorts: no I/O ports found\n");
@@ -585,7 +585,7 @@ xf86DisableIO(void)
#if defined(__powerpc__)
munmap(ioBase, 0x20000);
ioBase = NULL;
-#elif !defined(__mc68000__) && !defined(__sparc__) && !defined(__mips__) && !defined(__sh__) && !defined(__hppa__) && !defined(__arm__) && !defined(__s390__)
+#elif !defined(__mc68000__) && !defined(__sparc__) && !defined(__mips__) && !defined(__sh__) && !defined(__hppa__) && !defined(__arm__) && !defined(__s390__) && !defined(__m32r__)
iopl(0);
ioperm(0, 1024, 0);
#endif
diff --git a/hw/xfree86/utils/xorgcfg/expert.c b/hw/xfree86/utils/xorgcfg/expert.c
index bb6960ce7..484c2ec4b 100644
--- a/hw/xfree86/utils/xorgcfg/expert.c
+++ b/hw/xfree86/utils/xorgcfg/expert.c
@@ -465,7 +465,7 @@ CreateFiles(TreeNode *files)
Widget w;
char *value;
- value = file->file_logfile ? file->file_logfile : "";
+ value = (file && file->file_logfile) ? file->file_logfile : "";
node = NewNode(files, NULL, NULL, files->node,
(TreeData*)XtCalloc(1, sizeof(TreeData)));
CreateFilesField(node, "LogFile", value);
@@ -509,10 +509,14 @@ UpdateFiles(TreeNode *files)
/* LogFile */
files = files->child;
XtVaGetValues(files->data->files.text, XtNstring, &str, NULL);
- XtFree(XF86Config->conf_files->file_logfile);
- if (*str)
+ if (XF86Config->conf_files && XF86Config->conf_files->file_logfile)
+ XtFree(XF86Config->conf_files->file_logfile);
+ if (*str) {
+ if (XF86Config->conf_files == NULL)
+ XF86Config->conf_files = XtCalloc(1, sizeof(XF86ConfFilesRec));
XF86Config->conf_files->file_logfile = XtNewString(str);
- else
+ }
+ else if (XF86Config->conf_files)
XF86Config->conf_files->file_logfile = NULL;
}
@@ -527,10 +531,11 @@ CreateFontPath(TreeNode *fontpath, char *path)
if (path == NULL) {
if (XF86Font_path) {
path = XtNewString(XF86Font_path);
- if (XF86Config->conf_files && XF86Config->conf_files->file_fontpath) {
+ if (XF86Config->conf_files && XF86Config->conf_files->file_fontpath)
XtFree(XF86Config->conf_files->file_fontpath);
- XF86Config->conf_files->file_fontpath = XtNewString(path);
- }
+ if (XF86Config->conf_files == NULL)
+ XF86Config->conf_files = XtCalloc(1, sizeof(XF86ConfFilesRec));
+ XF86Config->conf_files->file_fontpath = XtNewString(path);
}
else if (XF86Config->conf_files && XF86Config->conf_files->file_fontpath)
path = XtNewString(XF86Config->conf_files->file_fontpath);
@@ -629,9 +634,14 @@ FontPathChanged(TreeNode *node)
pos += len - 2;
}
- if (XF86Config->conf_files->file_fontpath)
- XtFree(XF86Config->conf_files->file_fontpath);
- XF86Config->conf_files->file_fontpath = fontpath;
+ if (XF86Config->conf_files) {
+ if (XF86Config->conf_files->file_fontpath)
+ XtFree(XF86Config->conf_files->file_fontpath);
+ }
+ else if (fontpath)
+ XF86Config->conf_files = XtCalloc(1, sizeof(XF86ConfFilesRec));
+ if (XF86Config->conf_files)
+ XF86Config->conf_files->file_fontpath = fontpath;
}
static void
@@ -703,10 +713,11 @@ CreateModulePath(TreeNode *modulepath, char *path)
if (path == NULL) {
if (XF86Module_path) {
path = XtNewString(XF86Module_path);
- if (XF86Config->conf_files && XF86Config->conf_files->file_modulepath) {
+ if (XF86Config->conf_files == NULL)
+ XF86Config->conf_files = XtCalloc(1, sizeof(XF86ConfFilesRec));
+ else if (XF86Config->conf_files->file_modulepath)
XtFree(XF86Config->conf_files->file_modulepath);
- XF86Config->conf_files->file_modulepath = XtNewString(path);
- }
+ XF86Config->conf_files->file_modulepath = XtNewString(path);
}
else if (XF86Config->conf_files && XF86Config->conf_files->file_modulepath)
path = XtNewString(XF86Config->conf_files->file_modulepath);
@@ -799,9 +810,14 @@ ModulePathChanged(TreeNode *node)
pos += len - 2;
}
- if (XF86Config->conf_files->file_modulepath)
- XtFree(XF86Config->conf_files->file_modulepath);
- XF86Config->conf_files->file_modulepath = modulepath;
+ if (XF86Config->conf_files) {
+ if (XF86Config->conf_files->file_modulepath)
+ XtFree(XF86Config->conf_files->file_modulepath);
+ }
+ else if (modulepath)
+ XF86Config->conf_files = XtCalloc(1, sizeof(XF86ConfFilesRec));
+ if (XF86Config->conf_files)
+ XF86Config->conf_files->file_modulepath = modulepath;
}
static void
@@ -921,6 +937,8 @@ NewModuleCallback(Widget unused, XtPointer user_data, XtPointer call_data)
DeleteNode(node);
load = (XF86LoadPtr)XtCalloc(1, sizeof(XF86LoadRec));
load->load_name = XtNewString(label);
+ if (XF86Config->conf_modules == NULL)
+ XF86Config->conf_modules = XtCalloc(1, sizeof(XF86ConfModuleRec));
XF86Config->conf_modules->mod_load_lst =
xf86addModule(XF86Config->conf_modules->mod_load_lst, load);
diff --git a/hw/xfree86/utils/xorgcfg/loadmod.c b/hw/xfree86/utils/xorgcfg/loadmod.c
index 1207820ce..629dfe118 100644
--- a/hw/xfree86/utils/xorgcfg/loadmod.c
+++ b/hw/xfree86/utils/xorgcfg/loadmod.c
@@ -179,7 +179,9 @@ LOOKUP xfree86LookupTab[] = {
SYMFUNC(xf86memchr)
SYMFUNC(xf86memcmp)
SYMFUNC(xf86memcpy)
-#if (defined(__powerpc__) && (defined(Lynx) || defined(linux))) || defined(__sparc__) || defined(__sparc) || defined(__ia64__) || defined (__amd64__)
+#if (defined(__powerpc__) && (defined(Lynx) || defined(linux))) || \
+ defined(__sparc__) || defined(__sparc) || defined(__ia64__) || \
+ defined (__amd64__) || defined(__x86_64__)
/*
* Some PPC, SPARC, and IA64 compilers generate calls to memcpy to handle
* structure copies. This causes a problem both here and in shared
diff --git a/hw/xfree86/x86emu/prim_ops.c b/hw/xfree86/x86emu/prim_ops.c
index b42cdc0a5..41968e1a7 100644
--- a/hw/xfree86/x86emu/prim_ops.c
+++ b/hw/xfree86/x86emu/prim_ops.c
@@ -103,7 +103,7 @@
#include "x86emu/x86emui.h"
#if defined(__GNUC__)
-# if defined (__i386__) || defined(__i386) || defined(__AMD64__) || defined(__x86_64__) || defined(__amd64__)
+# if defined (__i386__) || defined(__i386) || defined(__AMD64__) || defined(__x86_64__) || defined(__amd64__) || defined(__x86_64__)
# include "x86emu/prim_x86_gcc.h"
# endif
#endif
diff --git a/hw/xfree86/x86emu/x86emu/prim_x86_gcc.h b/hw/xfree86/x86emu/x86emu/prim_x86_gcc.h
index af61e2023..5a443cdbf 100644
--- a/hw/xfree86/x86emu/x86emu/prim_x86_gcc.h
+++ b/hw/xfree86/x86emu/x86emu/prim_x86_gcc.h
@@ -42,7 +42,7 @@
#include "x86emu/types.h"
-#if !defined(__GNUC__) || !(defined (__i386__) || defined(__i386) || defined(__AMD64__) || defined(__x86_64__) || defined(__amd64__))
+#if !defined(__GNUC__) || !(defined (__i386__) || defined(__i386) || defined(__AMD64__) || defined(__x86_64__) || defined(__amd64__) || defined(__x86_64__))
#error This file is intended to be used by gcc on i386 or x86-64 system
#endif
diff --git a/hw/xfree86/x86emu/x86emu/types.h b/hw/xfree86/x86emu/x86emu/types.h
index c0c09c1b0..2d41b0f18 100644
--- a/hw/xfree86/x86emu/x86emu/types.h
+++ b/hw/xfree86/x86emu/x86emu/types.h
@@ -75,7 +75,7 @@
defined(__sparc64__) || \
defined(__s390x__) || \
(defined(__hppa__) && defined(__LP64)) || \
- defined(__amd64__) || defined(amd64) || \
+ defined(__amd64__) || defined(amd64) || defined(__x86_64__) || \
(defined(__sgi) && (_MIPS_SZLONG == 64))
#define NUM32 int
#else
diff --git a/hw/xnest/Args.c b/hw/xnest/Args.c
index f061f9e80..209f175ab 100644
--- a/hw/xnest/Args.c
+++ b/hw/xnest/Args.c
@@ -57,11 +57,6 @@ void ddxInitGlobals(void)
extern Bool noCompositeExtension;
noCompositeExtension = TRUE;
#endif
-
-#ifdef XKB
- extern Bool noXkbExtension;
- noXkbExtension = TRUE;
-#endif
}
int
diff --git a/hw/xprint/Makefile.am b/hw/xprint/Makefile.am
index 1b8004841..2ed7aaf57 100644
--- a/hw/xprint/Makefile.am
+++ b/hw/xprint/Makefile.am
@@ -3,7 +3,7 @@ SUBDIRS = doc pcl pcl-mono raster ps etc config
bin_PROGRAMS = Xprt
Xprt_CFLAGS = @DIX_CFLAGS@ @XPRINT_CFLAGS@ \
- -DXPRINT -DPRINT_ONLY_SERVER -D_XP_PRINT_SERVER_ \
+ -DPRINT_ONLY_SERVER -D_XP_PRINT_SERVER_ \
-DXPRINTDIR=\"$(libdir)/X11/xserver\" \
-DXPRASTERDDX -DXPPCLDDX -DXPMONOPCLDDX -DXPPSDDX \
-DXFree86Server
@@ -17,6 +17,7 @@ XPRINT_LIBS = \
pcl-mono/libpcl.la \
$(top_builddir)/fb/libfb.la \
$(top_builddir)/render/librender.la \
+ $(top_builddir)/dix/libXpdix.la \
$(XSERVER_LIBS) \
$(top_builddir)/Xext/libXext.la \
$(top_builddir)/xkb/libxkb.la \
diff --git a/hw/xprint/ps/psout.h b/hw/xprint/ps/psout.h
index 3e19d5a67..1138e4afe 100644
--- a/hw/xprint/ps/psout.h
+++ b/hw/xprint/ps/psout.h
@@ -169,7 +169,7 @@ typedef signed __int64 PsOutColor;
defined(ia64) || defined(__ia64__) || \
defined(__sparc64__) || defined(_LP64) || \
defined(__s390x__) || \
- defined(amd64) || defined (__amd64__) || \
+ defined(amd64) || defined (__amd64__) || defined(__x86_64__) || \
defined (__powerpc64__) || \
(defined(sgi) && (_MIPS_SZLONG == 64))
typedef signed long PsOutColor;
diff --git a/hw/xquartz/GL/Makefile.am b/hw/xquartz/GL/Makefile.am
new file mode 100644
index 000000000..41d4566dc
--- /dev/null
+++ b/hw/xquartz/GL/Makefile.am
@@ -0,0 +1,13 @@
+noinst_LTLIBRARIES = libCGLCore.la
+AM_CFLAGS = $(XSERVER_CFLAGS) $(DIX_CFLAGS)
+AM_CPPFLAGS = \
+ -I$(top_srcdir) \
+ -I$(top_srcdir)/GL/glx \
+ -I$(top_srcdir)/GL/include \
+ -I$(top_srcdir)/GL/mesa/glapi \
+ -I$(top_srcdir)/hw/xquartz \
+ -I$(top_srcdir)/hw/xquartz/xpr \
+ -I$(top_srcdir)/miext/damage
+
+libCGLCore_la_SOURCES = \
+ indirect.c
diff --git a/GL/apple/indirect.c b/hw/xquartz/GL/indirect.c
index 2729ab0ba..a0884d45c 100644
--- a/GL/apple/indirect.c
+++ b/hw/xquartz/GL/indirect.c
@@ -102,7 +102,7 @@ void warn_func(void * p1, char *format, ...);
// some prototypes
static __GLXscreen * __glXAquaScreenProbe(ScreenPtr pScreen);
-static __GLXdrawable * __glXAquaScreenCreateDrawable(__GLXscreen *screen, DrawablePtr pDraw, XID drawId, __GLcontextModes *modes);
+static __GLXdrawable * __glXAquaScreenCreateDrawable(__GLXscreen *screen, DrawablePtr pDraw, XID drawId, __GLXconfig *modes);
static Bool glAquaInitVisuals(VisualPtr *visualp, DepthPtr *depthp,
int *nvisualp, int *ndepthp,
@@ -118,7 +118,7 @@ static int __glXAquaContextLoseCurrent(__GLXcontext *baseContext);
static int __glXAquaContextForceCurrent(__GLXcontext *baseContext);
static int __glXAquaContextCopy(__GLXcontext *baseDst, __GLXcontext *baseSrc, unsigned long mask);
-static CGLPixelFormatObj makeFormat(__GLcontextModes *mode);
+static CGLPixelFormatObj makeFormat(__GLXconfig *mode);
__GLXprovider __glXMesaProvider = {
__glXAquaScreenProbe,
@@ -141,7 +141,7 @@ struct __GLXAquaScreen {
__GLXscreen base;
int index;
int num_vis;
- __GLcontextModes *modes;
+ __GLXconfig *modes;
};
static __GLXAquaScreen glAquaScreens[MAXSCREENS];
@@ -162,7 +162,7 @@ struct __GLXAquaDrawable {
static __GLXcontext *
__glXAquaScreenCreateContext(__GLXscreen *screen,
- __GLcontextModes *modes,
+ __GLXconfig *config,
__GLXcontext *baseShareContext)
{
__GLXAquaContext *context;
@@ -177,7 +177,7 @@ __glXAquaScreenCreateContext(__GLXscreen *screen,
memset(context, 0, sizeof *context);
context->base.pGlxScreen = screen;
- context->base.modes = modes;
+ context->base.config = config;
context->base.destroy = __glXAquaContextDestroy;
context->base.makeCurrent = __glXAquaContextMakeCurrent;
@@ -186,7 +186,7 @@ __glXAquaScreenCreateContext(__GLXscreen *screen,
context->base.forceCurrent = __glXAquaContextForceCurrent;
// context->base.createDrawable = __glXAquaContextCreateDrawable;
- context->pixelFormat = makeFormat(modes);
+ context->pixelFormat = makeFormat(config);
if (!context->pixelFormat) {
free(context);
return NULL;
@@ -437,7 +437,7 @@ static GLboolean __glXAquaDrawableSwapBuffers(__GLXdrawable *base) {
return GL_TRUE;
}
-static CGLPixelFormatObj makeFormat(__GLcontextModes *mode) {
+static CGLPixelFormatObj makeFormat(__GLXconfig *config) {
int i;
CGLPixelFormatAttribute attr[64]; // currently uses max of 30
CGLPixelFormatObj result;
@@ -446,7 +446,7 @@ static CGLPixelFormatObj makeFormat(__GLcontextModes *mode) {
GLAQUA_DEBUG_MSG("makeFormat\n");
- if (!mode->rgbMode)
+ if (!config->rgbMode)
return NULL;
i = 0;
@@ -454,42 +454,43 @@ static CGLPixelFormatObj makeFormat(__GLcontextModes *mode) {
// attr [i++] = kCGLPFAAcelerated; // require hwaccel - BAD for multiscreen
// attr [i++] = kCGLPFANoRecovery; // disable fallback renderers - BAD
- if (mode->stereoMode) {
+ if (config->stereoMode) {
attr[i++] = kCGLPFAStereo;
}
- if (mode->doubleBufferMode) {
+
+ if (config->doubleBufferMode) {
attr[i++] = kCGLPFADoubleBuffer;
}
- if (mode->colorIndexMode) {
+ if (config->colorIndexMode) {
/* ignored */
}
- if (mode->rgbMode) {
+ if (config->rgbMode) {
attr[i++] = kCGLPFAColorSize;
- attr[i++] = mode->redBits + mode->greenBits + mode->blueBits;
+ attr[i++] = config->redBits + config->greenBits + config->blueBits;
attr[i++] = kCGLPFAAlphaSize;
- attr[i++] = 1; /* FIXME: ignoring mode->alphaBits which is always 0 */
+ attr[i++] = 1; /* FIXME: ignoring config->alphaBits which is always 0 */
}
- if (mode->haveAccumBuffer) {
+ if (config->haveAccumBuffer) {
attr[i++] = kCGLPFAAccumSize;
- attr[i++] = mode->accumRedBits + mode->accumGreenBits
- + mode->accumBlueBits + mode->accumAlphaBits;
+ attr[i++] = config->accumRedBits + config->accumGreenBits
+ + config->accumBlueBits + config->accumAlphaBits;
}
- if (mode->haveDepthBuffer) {
+ if (config->haveDepthBuffer) {
attr[i++] = kCGLPFADepthSize;
- attr[i++] = mode->depthBits;
+ attr[i++] = config->depthBits;
}
- if (mode->haveStencilBuffer) {
+ if (config->haveStencilBuffer) {
attr[i++] = kCGLPFAStencilSize;
- attr[i++] = mode->stencilBits;
+ attr[i++] = config->stencilBits;
}
attr[i++] = kCGLPFAAuxBuffers;
- attr[i++] = mode->numAuxBuffers;
+ attr[i++] = config->numAuxBuffers;
/* mode->level ignored */
@@ -670,7 +671,7 @@ static Bool init_visuals(int *nvisualp, VisualPtr *visualp,
VisualPtr pVisual = *visualp;
VisualPtr pVisualNew = NULL;
VisualID *orig_vid = NULL;
- __GLcontextModes *modes;
+ __GLXconfig *modes;
__GLXvisualConfig *pNewVisualConfigs = NULL;
void **glXVisualPriv;
void **pNewVisualPriv;
@@ -752,7 +753,7 @@ static Bool init_visuals(int *nvisualp, VisualPtr *visualp,
}
/* Alloc space for the list of glXVisuals */
- modes = _gl_context_modes_create(numNewVisuals, sizeof(__GLcontextModes));
+ modes = _gl_context_modes_create(numNewVisuals, sizeof(__GLXconfig));
if (modes == NULL) {
free(orig_vid);
free(pNewVisualPriv);
@@ -925,6 +926,7 @@ Bool enable_stereo = FALSE;
/* based on code in i830_dri.c
This ends calling glAquaSetVisualConfigs to set the static
numconfigs, etc. */
+// see also glxglcore.c -- bhb
static void
glAquaInitVisualConfigs(void)
{
@@ -1085,7 +1087,7 @@ static void __glXAquaScreenDestroy(__GLXscreen *screen) {
static void init_screen_visuals(__GLXAquaScreen *screen) {
ScreenPtr pScreen = screen->base.pScreen;
- __GLcontextModes *modes;
+ __GLXconfig *modes;
int *used;
int i, j;
@@ -1101,7 +1103,7 @@ static void init_screen_visuals(__GLXAquaScreen *screen) {
memset(used, 0, pScreen->numVisuals * sizeof(int));
i = 0;
- for ( modes = screen -> base.modes
+ for ( modes = screen -> base.visuals
; modes != NULL
; modes = modes->next ) {
const int vis_class = _gl_convert_to_x_visual_type( modes->visualType );
@@ -1174,7 +1176,7 @@ static __GLXdrawable *
__glXAquaScreenCreateDrawable(__GLXscreen *screen,
DrawablePtr pDraw,
XID drawId,
- __GLcontextModes *modes) {
+ __GLXconfig *modes) {
__GLXAquaDrawable *glxPriv;
GLAQUA_DEBUG_MSG("glAquaScreenCreateDrawable(%p,%p,%d,%p)\n", context, pDraw, drawId, modes);
@@ -1184,7 +1186,7 @@ __glXAquaScreenCreateDrawable(__GLXscreen *screen,
memset(glxPriv, 0, sizeof *glxPriv);
- if (!__glXDrawableInit(&glxPriv->base, screen, pDraw, drawId, modes)) {
+ if (!__glXDrawableInit(&glxPriv->base, screen, pDraw, GLX_DRAWABLE_PIXMAP /*?*/, drawId, modes)) {
xfree(glxPriv);
return NULL;
}
diff --git a/hw/xquartz/Makefile.am b/hw/xquartz/Makefile.am
index 075382476..b2674be4f 100644
--- a/hw/xquartz/Makefile.am
+++ b/hw/xquartz/Makefile.am
@@ -13,19 +13,17 @@ if X11APP
X11APP_SUBDIRS = bundle
endif
-SUBDIRS = . xpr $(X11APP_SUBDIRS)
-DIST_SUBDIRS = xpr bundle
+SUBDIRS = . GL xpr $(X11APP_SUBDIRS)
+DIST_SUBDIRS = GL xpr bundle
libXquartz_la_SOURCES = \
$(top_srcdir)/fb/fbcmap_mi.c \
$(top_srcdir)/mi/miinitext.c \
- $(top_srcdir)/Xext/dpmsstubs.c \
X11Application.m \
X11Controller.m \
applewm.c \
darwin.c \
darwinEvents.c \
- darwinKeyboard.c \
darwinXinput.c \
keysym2ucs.c \
pseudoramiX.c \
@@ -35,7 +33,8 @@ libXquartz_la_SOURCES = \
quartzForeground.c \
quartzKeyboard.c \
quartzPasteboard.c \
- quartzStartup.c
+ quartzStartup.c \
+ threadSafety.c
EXTRA_DIST = \
X11Application.h \
@@ -44,7 +43,6 @@ EXTRA_DIST = \
darwinClut8.h \
darwin.h \
darwinEvents.h \
- darwinKeyboard.h \
keysym2ucs.h \
pseudoramiX.h \
quartz.h \
@@ -52,4 +50,7 @@ EXTRA_DIST = \
quartzCommon.h \
quartzForeground.h \
quartzKeyboard.h \
- quartzPasteboard.h
+ quartzPasteboard.h \
+ sanitizedCarbon.h \
+ sanitizedCocoa.h \
+ threadSafety.h
diff --git a/hw/xquartz/X11Application.h b/hw/xquartz/X11Application.h
index ea9a6b758..8e7fed23b 100644
--- a/hw/xquartz/X11Application.h
+++ b/hw/xquartz/X11Application.h
@@ -32,7 +32,6 @@
#if __OBJC__
-#import <Cocoa/Cocoa.h>
#import "X11Controller.h"
@interface X11Application : NSApplication {
@@ -56,7 +55,7 @@
- (void) prefs_set_string:(NSString *)key value:(NSString *)value;
- (void) prefs_synchronize;
-- (BOOL) x_active;
+- (OSX_BOOL) x_active;
@end
@@ -72,7 +71,7 @@ void X11ApplicationSetCanQuit (int state);
void X11ApplicationServerReady (void);
void X11ApplicationShowHideMenubar (int state);
-void X11ApplicationMain(int argc, const char **argv, void (*server_thread) (void *), void *server_arg);
+void X11ApplicationMain(int argc, char **argv, char **envp);
extern int X11EnableKeyEquivalents;
extern int quartzHasRoot, quartzEnableRootless;
diff --git a/hw/xquartz/X11Application.m b/hw/xquartz/X11Application.m
index 2844fca10..691725df9 100644
--- a/hw/xquartz/X11Application.m
+++ b/hw/xquartz/X11Application.m
@@ -27,35 +27,34 @@
promote the sale, use or other dealings in this Software without
prior written authorization. */
+#include "sanitizedCarbon.h"
+
#ifdef HAVE_DIX_CONFIG_H
#include <dix-config.h>
#endif
-#include "quartzCommon.h"
#include "quartzForeground.h"
+#include "quartzCommon.h"
#import "X11Application.h"
-#include <Carbon/Carbon.h>
-/* ouch! */
-#define BOOL X_BOOL
# include "darwin.h"
# include "darwinEvents.h"
# include "quartz.h"
# define _APPLEWM_SERVER_
# include "X11/extensions/applewm.h"
# include "micmap.h"
-#undef BOOL
-
#include <mach/mach.h>
#include <unistd.h>
-#include <pthread.h>
-#include "rootlessCommon.h"
+#define DEFAULTS_FILE "/usr/X11/lib/X11/xserver/Xquartz.plist"
-WindowPtr xprGetXWindowFromAppKit(int windowNumber); // xpr/xprFrame.c
+#ifndef XSERVER_VERSION
+#define XSERVER_VERSION "?"
+#endif
-#define DEFAULTS_FILE "/usr/X11/lib/X11/xserver/Xquartz.plist"
+#define ProximityIn 0
+#define ProximityOut 1
int X11EnableKeyEquivalents = TRUE;
int quartzHasRoot = FALSE, quartzEnableRootless = TRUE;
@@ -159,7 +158,7 @@ static void message_kit_thread (SEL selector, NSObject *arg) {
[self orderFrontStandardAboutPanelWithOptions: dict];
}
-- (void) activateX:(BOOL)state {
+- (void) activateX:(OSX_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) */
@@ -193,7 +192,7 @@ static void message_kit_thread (SEL selector, NSObject *arg) {
- (void) sendEvent:(NSEvent *)e {
NSEventType type;
- BOOL for_appkit, for_x;
+ OSX_BOOL for_appkit, for_x;
type = [e type];
@@ -210,8 +209,6 @@ static void message_kit_thread (SEL selector, NSObject *arg) {
if (_x_active) [self activateX:NO];
} else if ([self modalWindow] == nil) {
/* Must be an X window. Tell appkit it doesn't have focus. */
- WindowPtr pWin = xprGetXWindowFromAppKit([e windowNumber]);
- if (pWin) RootlessReorderWindow(pWin);
for_appkit = NO;
if ([self isActive]) {
@@ -244,9 +241,6 @@ static void message_kit_thread (SEL selector, NSObject *arg) {
|| [e keyCode] == 53 /*Esc*/)) {
swallow_up = 0;
for_x = NO;
-#ifdef DARWIN_DDX_MISSING
- DarwinSendDDXEvent(kXquartzToggleFullscreen, 0);
-#endif
}
} else {
/* If we saw a key equivalent on the down, don't pass
@@ -277,7 +271,8 @@ static void message_kit_thread (SEL selector, NSObject *arg) {
_appFlags._active = YES;
[self activateX:YES];
- if ([e data2] & 0x10) X11ApplicationSetFrontProcess();
+ if ([e data2] & 0x10)
+ DarwinSendDDXEvent(kXquartzBringAllToFront, 0);
}
break;
@@ -647,8 +642,8 @@ static NSMutableArray * cfarray_to_nsarray (CFArrayRef in) {
if(darwinDesiredDepth == 8)
darwinDesiredDepth = -1;
- enable_stereo = [self prefs_get_boolean:@PREFS_ENABLE_STEREO
- default:false];
+// enable_stereo = [self prefs_get_boolean:@PREFS_ENABLE_STEREO
+// default:false];
}
/* This will end up at the end of the responder chain. */
@@ -657,7 +652,7 @@ static NSMutableArray * cfarray_to_nsarray (CFArrayRef in) {
AppleWMCopyToPasteboard);
}
-- (BOOL) x_active {
+- (OSX_BOOL) x_active {
return _x_active;
}
@@ -744,19 +739,6 @@ void X11ApplicationShowHideMenubar (int state) {
[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;
@@ -798,7 +780,7 @@ environment?", @"Startup xinitrc dialog");
[X11App prefs_synchronize];
}
-void X11ApplicationMain (int argc, const char **argv, void (*server_thread) (void *), void *server_arg) {
+void X11ApplicationMain (int argc, char **argv, char **envp) {
NSAutoreleasePool *pool;
#ifdef DEBUG
@@ -824,13 +806,9 @@ void X11ApplicationMain (int argc, const char **argv, void (*server_thread) (voi
/* Calculate the height of the menubar so we can avoid it. */
aquaMenuBarHeight = NSHeight([[NSScreen mainScreen] frame]) -
NSMaxY([[NSScreen mainScreen] visibleFrame]);
-
- if (!create_thread (server_thread, server_arg)) {
- ErrorF("can't create secondary thread\n");
- exit (1);
- }
- QuartzMoveToForeground();
+ /* Tell the server thread that it can proceed */
+ QuartzInitServer(argc, argv, envp);
[NSApp run];
/* not reached */
@@ -861,7 +839,7 @@ static void send_nsevent (NSEventType type, NSEvent *e) {
int pointer_x, pointer_y, ev_button, ev_type;
float pressure, tilt_x, tilt_y;
- /* convert location to global top-left coordinates */
+ /* convert location to be relative to top-left of primary display */
location = [e locationInWindow];
window = [e window];
screen = [[[NSScreen screens] objectAtIndex:0] frame];
@@ -876,36 +854,44 @@ static void send_nsevent (NSEventType type, NSEvent *e) {
pointer_y = (screen.origin.y + screen.size.height) - location.y;
}
- pointer_y -= aquaMenuBarHeight;
-
pressure = 0; // for tablets
tilt_x = 0;
tilt_y = 0;
switch (type) {
- case NSLeftMouseDown: ev_button=1; ev_type=ButtonPress; goto handle_mouse;
- case NSOtherMouseDown: ev_button=2; ev_type=ButtonPress; goto handle_mouse;
- case NSRightMouseDown: ev_button=3; ev_type=ButtonPress; goto handle_mouse;
- case NSLeftMouseUp: ev_button=1; ev_type=ButtonRelease; goto handle_mouse;
- case NSOtherMouseUp: ev_button=2; ev_type=ButtonRelease; goto handle_mouse;
- case NSRightMouseUp: ev_button=3; ev_type=ButtonRelease; goto handle_mouse;
- case NSLeftMouseDragged: ev_button=1; ev_type=MotionNotify; goto handle_mouse;
- case NSOtherMouseDragged: ev_button=2; ev_type=MotionNotify; goto handle_mouse;
- case NSRightMouseDragged: ev_button=3; ev_type=MotionNotify; goto handle_mouse;
+ case NSLeftMouseDown: ev_button=1; ev_type=ButtonPress; goto check_subtype;
+ case NSOtherMouseDown: ev_button=2; ev_type=ButtonPress; goto check_subtype;
+ case NSRightMouseDown: ev_button=3; ev_type=ButtonPress; goto check_subtype;
+ case NSLeftMouseUp: ev_button=1; ev_type=ButtonRelease; goto check_subtype;
+ case NSOtherMouseUp: ev_button=2; ev_type=ButtonRelease; goto check_subtype;
+ case NSRightMouseUp: ev_button=3; ev_type=ButtonRelease; goto check_subtype;
+ case NSLeftMouseDragged: ev_button=1; ev_type=MotionNotify; goto check_subtype;
+ case NSOtherMouseDragged: ev_button=2; ev_type=MotionNotify; goto check_subtype;
+ case NSRightMouseDragged: ev_button=3; ev_type=MotionNotify; goto check_subtype;
+
+check_subtype:
+ if ([e subtype] != NSTabletPointEventSubtype) goto handle_mouse;
+ // fall through to get tablet data
case NSTabletPoint:
pressure = [e pressure];
tilt_x = [e tilt].x;
- tilt_y = [e tilt].y; // fall through
+ tilt_y = [e tilt].y;
+ // fall through to normal mouse handling
+
case NSMouseMoved: ev_button=0; ev_type=MotionNotify; goto handle_mouse;
- handle_mouse:
-// if ([e subtype] == NSTabletPointEventSubtype) pressure = [e pressure];
+handle_mouse:
DarwinSendPointerEvents(ev_type, ev_button, pointer_x, pointer_y,
pressure, tilt_x, tilt_y);
break;
+ case NSTabletProximity:
+ DarwinSendProximityEvents([e isEnteringProximity]?ProximityIn:ProximityOut,
+ pointer_x, pointer_y);
+ break;
+
case NSScrollWheel:
- DarwinSendScrollEvents([e deltaY], pointer_x, pointer_y,
+ DarwinSendScrollEvents([e deltaX], [e deltaY], pointer_x, pointer_y,
pressure, tilt_x, tilt_y);
break;
diff --git a/hw/xquartz/X11Controller.h b/hw/xquartz/X11Controller.h
index 8d6a38ff0..7942bc44b 100644
--- a/hw/xquartz/X11Controller.h
+++ b/hw/xquartz/X11Controller.h
@@ -32,7 +32,7 @@
#if __OBJC__
-#import <Cocoa/Cocoa.h>
+#include "sanitizedCocoa.h"
#include "xpr/x-list.h"
@interface X11Controller : NSObject
@@ -67,14 +67,14 @@
int checked_window_item;
x_list *pending_apps;
- BOOL finished_launching;
- BOOL can_quit;
+ OSX_BOOL finished_launching;
+ OSX_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) set_can_quit:(OSX_BOOL)state;
- (void) server_ready;
- (IBAction) apps_table_show:(id)sender;
@@ -100,6 +100,6 @@
#endif /* __OBJC__ */
-void X11ControllerMain(int argc, const char **argv, void (*server_thread) (void *), void *server_arg);
+void X11ControllerMain(int argc, char **argv, char **envp);
#endif /* X11CONTROLLER_H */
diff --git a/hw/xquartz/X11Controller.m b/hw/xquartz/X11Controller.m
index 2fd988661..107d8ee9b 100644
--- a/hw/xquartz/X11Controller.m
+++ b/hw/xquartz/X11Controller.m
@@ -27,6 +27,8 @@
promote the sale, use or other dealings in this Software without
prior written authorization. */
+#include "sanitizedCarbon.h"
+
#ifdef HAVE_DIX_CONFIG_H
#include <dix-config.h>
#endif
@@ -37,17 +39,14 @@
#import "X11Controller.h"
#import "X11Application.h"
-#import <Carbon/Carbon.h>
-/* ouch! */
-#define BOOL X_BOOL
#include "opaque.h"
-# include "darwin.h"
-# include "quartz.h"
-# define _APPLEWM_SERVER_
-# include "X11/extensions/applewm.h"
-# include "applewmExt.h"
-#undef BOOL
+#include "darwin.h"
+#include "darwinEvents.h"
+#include "quartz.h"
+#define _APPLEWM_SERVER_
+#include "X11/extensions/applewm.h"
+#include "applewmExt.h"
#include <stdio.h>
#include <unistd.h>
@@ -602,7 +601,7 @@ objectValueForTableColumn:(NSTableColumn *)tableColumn row:(int)row
#endif
}
-- (void) set_can_quit:(BOOL)state
+- (void) set_can_quit:(OSX_BOOL)state
{
can_quit = state;
}
@@ -669,7 +668,7 @@ objectValueForTableColumn:(NSTableColumn *)tableColumn row:(int)row
AHLookupAnchor ((CFStringRef)NSLocalizedString(@"Mac Help", no comment), CFSTR ("mchlp2276"));
}
-- (BOOL) validateMenuItem:(NSMenuItem *)item
+- (OSX_BOOL) validateMenuItem:(NSMenuItem *)item
{
NSMenu *menu = [item menu];
@@ -692,24 +691,26 @@ objectValueForTableColumn:(NSTableColumn *)tableColumn row:(int)row
DarwinSendDDXEvent(kXquartzControllerNotify, 1, AppleWMShowAll);
}
-- (NSApplicationTerminateReply) applicationShouldTerminate:sender
-{
- NSString *msg;
+- (NSApplicationTerminateReply) applicationShouldTerminate:sender {
+ NSString *msg;
+ NSString *title;
- if (can_quit || [X11App prefs_get_boolean:@PREFS_NO_QUIT_ALERT default:NO])
- return NSTerminateNow;
-
- /* Make sure we're frontmost. */
- [NSApp activateIgnoringOtherApps:YES];
+ if (can_quit || [X11App prefs_get_boolean:@PREFS_NO_QUIT_ALERT default:NO])
+ return NSTerminateNow;
- 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");
+ /* Make sure we're frontmost. */
+ [NSApp activateIgnoringOtherApps:YES];
- /* 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.. */
+ title = NSLocalizedString(@"Do you really want to quit X11?", @"Dialog title when quitting");
+ msg = NSLocalizedString(@"Any open X11 applications will stop immediately, and you will lose any unsaved changes.", @"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;
+ return (NSRunAlertPanel (title, msg, NSLocalizedString (@"Quit", @""),
+ NSLocalizedString (@"Cancel", @""), nil)
+ == NSAlertDefaultReturn) ? NSTerminateNow : NSTerminateCancel;
}
- (void) applicationWillTerminate:(NSNotification *)aNotification
@@ -741,7 +742,7 @@ objectValueForTableColumn:(NSTableColumn *)tableColumn row:(int)row
pending_apps = NULL;
}
-- (BOOL) application:(NSApplication *)app openFile:(NSString *)filename
+- (OSX_BOOL) application:(NSApplication *)app openFile:(NSString *)filename
{
const char *name = [filename UTF8String];
@@ -754,14 +755,8 @@ objectValueForTableColumn:(NSTableColumn *)tableColumn row:(int)row
return YES;
}
-- (BOOL) applicationShouldHandleReopen:(NSApplication *)app
- hasVisibleWindows:(BOOL)hasVis {
- DarwinSendDDXEvent(kXquartzBringAllToFront, 0);
- return YES;
-}
-
@end
-void X11ControllerMain(int argc, const char **argv, void (*server_thread) (void *), void *server_arg) {
- X11ApplicationMain (argc, argv, server_thread, server_arg);
+void X11ControllerMain(int argc, char **argv, char **envp) {
+ X11ApplicationMain (argc, argv, envp);
}
diff --git a/hw/xquartz/applewm.c b/hw/xquartz/applewm.c
index 072e57ff4..ba86f1045 100644
--- a/hw/xquartz/applewm.c
+++ b/hw/xquartz/applewm.c
@@ -25,6 +25,8 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
**************************************************************************/
+#include "sanitizedCarbon.h"
+
#ifdef HAVE_DIX_CONFIG_H
#include <dix-config.h>
#endif
diff --git a/hw/xquartz/bundle/English.lproj/Localizable.strings b/hw/xquartz/bundle/English.lproj/Localizable.strings
index c83b08536..63a135255 100644
--- a/hw/xquartz/bundle/English.lproj/Localizable.strings
+++ b/hw/xquartz/bundle/English.lproj/Localizable.strings
Binary files differ
diff --git a/hw/xquartz/darwin.c b/hw/xquartz/darwin.c
index 002ea413d..f20cce127 100644
--- a/hw/xquartz/darwin.c
+++ b/hw/xquartz/darwin.c
@@ -1,10 +1,9 @@
/**************************************************************
*
- * Shared code for the Darwin X Server
- * running with Quartz or IOKit display mode
+ * Xquartz initialization code
*
+ * Copyright (c) 2007-2008 Apple Inc.
* Copyright (c) 2001-2004 Torrey T. Lyons. All Rights Reserved.
- * Copyright (c) 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"),
@@ -76,7 +75,7 @@
#include "darwin.h"
#include "darwinEvents.h"
-#include "darwinKeyboard.h"
+#include "quartzKeyboard.h"
#include "quartz.h"
//#include "darwinClut8.h"
@@ -112,6 +111,7 @@ int darwinFakeMouse3Mask = NX_COMMANDMASK;
// devices
DeviceIntPtr darwinPointer = NULL;
+DeviceIntPtr darwinTablet = NULL;
DeviceIntPtr darwinKeyboard = NULL;
// Common pixmap formats
@@ -142,6 +142,8 @@ const int NUMFORMATS = sizeof(formats)/sizeof(formats[0]);
#define XORG_RELEASE "?"
#endif
+const char *__crashreporter_info__ = "X.Org X Server " XSERVER_VERSION "Build Date: " BUILD_DATE;
+
void DDXRingBell(int volume, int pitch, int duration) {
// FIXME -- make some noise, yo
}
@@ -330,48 +332,65 @@ static void DarwinChangePointerControl(
#endif
/*
- * DarwinMouseProc
- * Handle the initialization, etc. of a mouse
+ * DarwinMouseProc: Handle the initialization, etc. of a mouse
*/
-static int DarwinMouseProc(
- DeviceIntPtr pPointer,
- int what )
-{
- CARD8 map[6];
-
+static int DarwinMouseProc(DeviceIntPtr pPointer, int what) {
+ // 7 buttons: left, right, middle, then four scroll wheel "buttons"
+ CARD8 map[8] = {0, 1, 2, 3, 4, 5, 6, 7};
+
switch (what) {
-
case DEVICE_INIT:
pPointer->public.on = FALSE;
-
+
// Set button map.
- map[1] = 1;
- map[2] = 2;
- map[3] = 3;
- map[4] = 4;
- map[5] = 5;
- InitPointerDeviceStruct( (DevicePtr)pPointer, map, 5,
- GetMotionHistory,
- (PtrCtrlProcPtr)NoopDDA,
- GetMotionHistorySize(), 5);
- InitProximityClassDeviceStruct( (DevicePtr)pPointer);
+ InitPointerDeviceStruct((DevicePtr)pPointer, map, 7,
+ GetMotionHistory,
+ (PtrCtrlProcPtr)NoopDDA,
+ GetMotionHistorySize(), 2);
+ pPointer->name = strdup("Quartz Pointing Device");
break;
-
case DEVICE_ON:
pPointer->public.on = TRUE;
AddEnabledDevice( darwinEventReadFD );
return Success;
-
case DEVICE_CLOSE:
case DEVICE_OFF:
pPointer->public.on = FALSE;
- RemoveEnabledDevice( darwinEventReadFD );
+ RemoveEnabledDevice(darwinEventReadFD);
return Success;
}
-
+
return Success;
}
+static int DarwinTabletProc(DeviceIntPtr pPointer, int what) {
+ CARD8 map[4] = {0, 1, 2, 3};
+
+ switch (what) {
+ case DEVICE_INIT:
+ pPointer->public.on = FALSE;
+
+ // Set button map.
+ InitPointerDeviceStruct((DevicePtr)pPointer, map, 3,
+ GetMotionHistory,
+ (PtrCtrlProcPtr)NoopDDA,
+ GetMotionHistorySize(), 7);
+ InitProximityClassDeviceStruct(pPointer);
+// InitAbsoluteClassDeviceStruct(pPointer);
+ pPointer->name = strdup("pen");
+ break;
+ case DEVICE_ON:
+ pPointer->public.on = TRUE;
+ AddEnabledDevice( darwinEventReadFD );
+ return Success;
+ case DEVICE_CLOSE:
+ case DEVICE_OFF:
+ pPointer->public.on = FALSE;
+ RemoveEnabledDevice(darwinEventReadFD);
+ return Success;
+ }
+ return Success;
+}
/*
* DarwinKeybdProc
@@ -382,6 +401,7 @@ static int DarwinKeybdProc( DeviceIntPtr pDev, int onoff )
switch ( onoff ) {
case DEVICE_INIT:
DarwinKeyboardInit( pDev );
+ pDev->name = strdup("Quartz Keyboard");
break;
case DEVICE_ON:
pDev->public.on = TRUE;
@@ -507,10 +527,13 @@ void InitInput( int argc, char **argv )
darwinPointer = AddInputDevice(DarwinMouseProc, TRUE);
RegisterPointerDevice( darwinPointer );
+ darwinTablet = AddInputDevice(DarwinTabletProc, TRUE);
+ RegisterPointerDevice( darwinTablet );
+
darwinKeyboard = AddInputDevice(DarwinKeybdProc, TRUE);
RegisterKeyboardDevice( darwinKeyboard );
- DarwinEQInit( (DevicePtr)darwinKeyboard, (DevicePtr)darwinPointer );
+ DarwinEQInit();
QuartzInitInput(argc, argv);
}
@@ -541,8 +564,7 @@ DarwinAdjustScreenOrigins(ScreenInfo *pScreenInfo)
/* Find leftmost screen. If there's a tie, take the topmost of the two. */
for (i = 1; i < pScreenInfo->numScreens; i++) {
if (dixScreenOrigins[i].x < left ||
- (dixScreenOrigins[i].x == left &&
- dixScreenOrigins[i].y < top))
+ (dixScreenOrigins[i].x == left && dixScreenOrigins[i].y < top))
{
left = dixScreenOrigins[i].x;
top = dixScreenOrigins[i].y;
@@ -551,17 +573,20 @@ DarwinAdjustScreenOrigins(ScreenInfo *pScreenInfo)
darwinMainScreenX = left;
darwinMainScreenY = top;
+
+ DEBUG_LOG("top = %d, left=%d\n", top, left);
/* Shift all screens so that there is a screen whose top left
- is at X11 (0,0) and at global screen coordinate
- (darwinMainScreenX, darwinMainScreenY). */
+ * is at X11 (0,0) and at global screen coordinate
+ * (darwinMainScreenX, darwinMainScreenY).
+ */
if (darwinMainScreenX != 0 || darwinMainScreenY != 0) {
for (i = 0; i < pScreenInfo->numScreens; i++) {
dixScreenOrigins[i].x -= darwinMainScreenX;
dixScreenOrigins[i].y -= darwinMainScreenY;
- /* ErrorF("Screen %d placed at X11 coordinate (%d,%d).\n",
- i, dixScreenOrigins[i].x, dixScreenOrigins[i].y); */
+ DEBUG_LOG("Screen %d placed at X11 coordinate (%d,%d).\n",
+ i, dixScreenOrigins[i].x, dixScreenOrigins[i].y);
}
}
}
diff --git a/hw/xquartz/darwin.h b/hw/xquartz/darwin.h
index df92d8b49..bdf00468e 100644
--- a/hw/xquartz/darwin.h
+++ b/hw/xquartz/darwin.h
@@ -34,6 +34,8 @@
#include <X11/extensions/XKB.h>
#include <assert.h>
+#include "threadSafety.h"
+
typedef struct {
void *framebuffer;
int x;
@@ -69,6 +71,7 @@ extern io_connect_t darwinParamConnect;
extern int darwinEventReadFD;
extern int darwinEventWriteFD;
extern DeviceIntPtr darwinPointer;
+extern DeviceIntPtr darwinTablet;
extern DeviceIntPtr darwinKeyboard;
// User preferences
@@ -86,46 +89,16 @@ extern int darwinDesiredRefresh;
extern int darwinMainScreenX;
extern int darwinMainScreenY;
-
-/*
- * Special ddx events understood by the X server
- */
-enum {
- kXquartzReloadKeymap // Reload system keymap
- = LASTEvent+1, // (from X.h list of event names)
- kXquartzActivate, // restore X drawing and cursor
- kXquartzDeactivate, // clip X drawing and switch to Aqua cursor
- kXquartzSetRootClip, // enable or disable drawing to the X screen
- kXquartzQuit, // kill the X server and release the display
- kXquartzReadPasteboard, // copy Mac OS X pasteboard into X cut buffer
- kXquartzWritePasteboard, // copy X cut buffer onto Mac OS X pasteboard
- kXquartzBringAllToFront, // bring all X windows to front
- kXquartzToggleFullscreen, // Enable/Disable fullscreen mode
- kXquartzSetRootless, // Set rootless mode
- kXquartzSpaceChanged, // Spaces changed
- /*
- * AppleWM events
- */
- kXquartzControllerNotify, // send an AppleWMControllerNotify event
- kXquartzPasteboardNotify, // notify the WM to copy or paste
- /*
- * Xplugin notification events
- */
- kXquartzDisplayChanged, // display configuration has changed
- kXquartzWindowState, // window visibility state has changed
- kXquartzWindowMoved, // window has moved on screen
-};
-
-void DarwinSendDDXEvent(int type, int argc, ...);
-
#define ENABLE_DEBUG_LOG 1
#ifdef ENABLE_DEBUG_LOG
extern FILE *debug_log_fp;
#define DEBUG_LOG_NAME "x11-debug.txt"
-#define DEBUG_LOG(msg, args...) if (debug_log_fp) fprintf(debug_log_fp, "%x:%s:%s:%d " msg, pthread_self(), __FILE__, __FUNCTION__, __LINE__, ##args ); fflush(debug_log_fp);
+#define DEBUG_LOG(msg, args...) if (debug_log_fp) fprintf(debug_log_fp, "%s:%s:%s:%d " msg, threadSafetyID(pthread_self()), __FILE__, __FUNCTION__, __LINE__, ##args ); fflush(debug_log_fp);
#else
#define DEBUG_LOG(msg, args...)
#endif
+#define TRACE() DEBUG_LOG("\n")
+
#endif /* _DARWIN_H */
diff --git a/hw/xquartz/darwinEvents.c b/hw/xquartz/darwinEvents.c
index 78708d2b2..154709448 100644
--- a/hw/xquartz/darwinEvents.c
+++ b/hw/xquartz/darwinEvents.c
@@ -1,7 +1,7 @@
/*
Darwin event queue and event handling
-Copyright 2007 Apple Inc.
+Copyright 2007-2008 Apple Inc.
Copyright 2004 Kaleb S. KEITHLEY. All Rights Reserved.
Copyright (c) 2002-2004 Torrey T. Lyons. All Rights Reserved.
@@ -48,32 +48,58 @@ in this Software without prior written authorization from The Open Group.
#include "darwin.h"
#include "quartz.h"
-#include "darwinKeyboard.h"
+#include "quartzKeyboard.h"
#include "darwinEvents.h"
#include <sys/types.h>
#include <sys/uio.h>
#include <unistd.h>
+#include <pthread.h>
+#include <errno.h>
+
#include <IOKit/hidsystem/IOLLEvent.h>
+/* Fake button press/release for scroll wheel move. */
+#define SCROLLWHEELUPFAKE 4
+#define SCROLLWHEELDOWNFAKE 5
+#define SCROLLWHEELLEFTFAKE 6
+#define SCROLLWHEELRIGHTFAKE 7
+
+/* These values were chosen to match the output of xinput under Linux */
+#define SCALEFACTOR_TILT 64.0
+#define SCALEFACTOR_PRESSURE 1000.0
+
#define _APPLEWM_SERVER_
#include "applewmExt.h"
#include <X11/extensions/applewm.h>
-/* FIXME: Abstract this away into xpr */
-#include <Xplugin.h>
-#include "rootlessWindow.h"
-WindowPtr xprGetXWindow(xp_window_id wid);
-
-/* Fake button press/release for scroll wheel move. */
-#define SCROLLWHEELUPFAKE 4
-#define SCROLLWHEELDOWNFAKE 5
+/* FIXME: Abstract this better */
+void QuartzModeEQInit(void);
int input_check_zero, input_check_flag;
static int old_flags = 0; // last known modifier state
xEvent *darwinEvents = NULL;
+pthread_mutex_t darwinEvents_mutex = PTHREAD_MUTEX_INITIALIZER;
+
+static inline void darwinEvents_lock(void) {
+ int err;
+ if((err = pthread_mutex_lock(&darwinEvents_mutex))) {
+ ErrorF("%s:%s:%d: Failed to lock darwinEvents_mutex: %d\n",
+ __FILE__, __FUNCTION__, __LINE__, err);
+ spewCallStack();
+ }
+}
+
+static inline void darwinEvents_unlock(void) {
+ int err;
+ if((err = pthread_mutex_unlock(&darwinEvents_mutex))) {
+ ErrorF("%s:%s:%d: Failed to unlock darwinEvents_mutex: %d\n",
+ __FILE__, __FUNCTION__, __LINE__, err);
+ spewCallStack();
+ }
+}
/*
* DarwinPressModifierMask
@@ -194,103 +220,93 @@ static void DarwinSimulateMouseClick(
be moved into their own individual functions and set as handlers using
mieqSetHandler. */
-void DarwinEventHandler(int screenNum, xEventPtr xe, DeviceIntPtr dev, int nevents) {
- int i;
-
- DEBUG_LOG("DarwinEventHandler(%d, %p, %p, %d)\n", screenNum, xe, dev, nevents);
- for (i=0; i<nevents; i++) {
- switch(xe[i].u.u.type) {
- case kXquartzControllerNotify:
- DEBUG_LOG("kXquartzControllerNotify\n");
- AppleWMSendEvent(AppleWMControllerNotify,
- AppleWMControllerNotifyMask,
- xe[i].u.clientMessage.u.l.longs0,
- xe[i].u.clientMessage.u.l.longs1);
- break;
-
- case kXquartzPasteboardNotify:
- DEBUG_LOG("kXquartzPasteboardNotify\n");
- AppleWMSendEvent(AppleWMPasteboardNotify,
- AppleWMPasteboardNotifyMask,
- xe[i].u.clientMessage.u.l.longs0,
- xe[i].u.clientMessage.u.l.longs1);
- break;
-
- case kXquartzActivate:
- DEBUG_LOG("kXquartzActivate\n");
- QuartzShow(xe[i].u.keyButtonPointer.rootX,
- xe[i].u.keyButtonPointer.rootY);
- AppleWMSendEvent(AppleWMActivationNotify,
- AppleWMActivationNotifyMask,
- AppleWMIsActive, 0);
- break;
-
- case kXquartzDeactivate:
- DEBUG_LOG("kXquartzDeactivate\n");
- DarwinReleaseModifiers();
- AppleWMSendEvent(AppleWMActivationNotify,
- AppleWMActivationNotifyMask,
- AppleWMIsInactive, 0);
- QuartzHide();
- break;
-
- case kXquartzWindowState:
- DEBUG_LOG("kXquartzWindowState\n");
- RootlessNativeWindowStateChanged(xprGetXWindow(xe[i].u.clientMessage.u.l.longs0),
- xe[i].u.clientMessage.u.l.longs1);
- break;
-
- case kXquartzWindowMoved:
- DEBUG_LOG("kXquartzWindowMoved\n");
- RootlessNativeWindowMoved ((WindowPtr)xe[i].u.clientMessage.u.l.longs0);
- break;
-
- case kXquartzToggleFullscreen:
- DEBUG_LOG("kXquartzToggleFullscreen\n");
+static void DarwinEventHandler(int screenNum, xEventPtr xe, DeviceIntPtr dev, int nevents) {
+ int i;
+
+ TA_SERVER();
+
+ DEBUG_LOG("DarwinEventHandler(%d, %p, %p, %d)\n", screenNum, xe, dev, nevents);
+ for (i=0; i<nevents; i++) {
+ switch(xe[i].u.u.type) {
+ case kXquartzControllerNotify:
+ DEBUG_LOG("kXquartzControllerNotify\n");
+ AppleWMSendEvent(AppleWMControllerNotify,
+ AppleWMControllerNotifyMask,
+ xe[i].u.clientMessage.u.l.longs0,
+ xe[i].u.clientMessage.u.l.longs1);
+ break;
+
+ case kXquartzPasteboardNotify:
+ DEBUG_LOG("kXquartzPasteboardNotify\n");
+ AppleWMSendEvent(AppleWMPasteboardNotify,
+ AppleWMPasteboardNotifyMask,
+ xe[i].u.clientMessage.u.l.longs0,
+ xe[i].u.clientMessage.u.l.longs1);
+ break;
+
+ case kXquartzActivate:
+ DEBUG_LOG("kXquartzActivate\n");
+ QuartzShow(xe[i].u.keyButtonPointer.rootX,
+ xe[i].u.keyButtonPointer.rootY);
+ AppleWMSendEvent(AppleWMActivationNotify,
+ AppleWMActivationNotifyMask,
+ AppleWMIsActive, 0);
+ break;
+
+ case kXquartzDeactivate:
+ DEBUG_LOG("kXquartzDeactivate\n");
+ DarwinReleaseModifiers();
+ AppleWMSendEvent(AppleWMActivationNotify,
+ AppleWMActivationNotifyMask,
+ AppleWMIsInactive, 0);
+ QuartzHide();
+ break;
+
+ case kXquartzToggleFullscreen:
+ DEBUG_LOG("kXquartzToggleFullscreen\n");
#ifdef DARWIN_DDX_MISSING
- if (quartzEnableRootless) QuartzSetFullscreen(!quartzHasRoot);
- else if (quartzHasRoot) QuartzHide();
- else QuartzShow();
+ if (quartzEnableRootless)
+ QuartzSetFullscreen(!quartzHasRoot);
+ else if (quartzHasRoot)
+ QuartzHide();
+ else
+ QuartzShow();
#else
- // ErrorF("kXquartzToggleFullscreen not implemented\n");
+ // ErrorF("kXquartzToggleFullscreen not implemented\n");
#endif
- break;
-
- case kXquartzSetRootless:
- DEBUG_LOG("kXquartzSetRootless\n");
+ break;
+
+ case kXquartzSetRootless:
+ DEBUG_LOG("kXquartzSetRootless\n");
#ifdef DARWIN_DDX_MISSING
- QuartzSetRootless(xe[i].u.clientMessage.u.l.longs0);
- if (!quartzEnableRootless && !quartzHasRoot) QuartzHide();
+ QuartzSetRootless(xe[i].u.clientMessage.u.l.longs0);
+ if (!quartzEnableRootless && !quartzHasRoot)
+ QuartzHide();
#else
- // ErrorF("kXquartzSetRootless not implemented\n");
+ // ErrorF("kXquartzSetRootless not implemented\n");
#endif
- break;
-
- case kXquartzSetRootClip:
- QuartzSetRootClip((BOOL)xe[i].u.clientMessage.u.l.longs0);
- break;
-
- case kXquartzQuit:
- GiveUp(0);
- break;
-
- case kXquartzBringAllToFront:
- DEBUG_LOG("kXquartzBringAllToFront\n");
- RootlessOrderAllWindows();
- break;
-
- case kXquartzSpaceChanged:
- DEBUG_LOG("kXquartzSpaceChanged\n");
- QuartzSpaceChanged(xe[i].u.clientMessage.u.l.longs0);
-
- break;
- default:
- ErrorF("Unknown application defined event type %d.\n", xe[i].u.u.type);
+ break;
+
+ case kXquartzSetRootClip:
+ QuartzSetRootClip((Bool)xe[i].u.clientMessage.u.l.longs0);
+ break;
+
+ case kXquartzQuit:
+ GiveUp(0);
+ break;
+
+ case kXquartzSpaceChanged:
+ DEBUG_LOG("kXquartzSpaceChanged\n");
+ QuartzSpaceChanged(xe[i].u.clientMessage.u.l.longs0);
+ break;
+
+ default:
+ ErrorF("Unknown application defined event type %d.\n", xe[i].u.u.type);
}
- }
+ }
}
-Bool DarwinEQInit(DevicePtr pKbd, DevicePtr pPtr) {
+Bool DarwinEQInit(void) {
if (!darwinEvents)
darwinEvents = (xEvent *)xcalloc(sizeof(xEvent), GetMaximumEventsNum());
if (!darwinEvents)
@@ -303,16 +319,16 @@ Bool DarwinEQInit(DevicePtr pKbd, DevicePtr pPtr) {
mieqSetHandler(kXquartzSetRootClip, DarwinEventHandler);
mieqSetHandler(kXquartzQuit, DarwinEventHandler);
mieqSetHandler(kXquartzReadPasteboard, QuartzReadPasteboard);
- mieqSetHandler(kXquartzWritePasteboard, QuartzWritePasteboard);
+ mieqSetHandler(kXquartzWritePasteboard, QuartzWritePasteboard);
mieqSetHandler(kXquartzToggleFullscreen, DarwinEventHandler);
mieqSetHandler(kXquartzSetRootless, DarwinEventHandler);
mieqSetHandler(kXquartzSpaceChanged, DarwinEventHandler);
mieqSetHandler(kXquartzControllerNotify, DarwinEventHandler);
mieqSetHandler(kXquartzPasteboardNotify, DarwinEventHandler);
mieqSetHandler(kXquartzDisplayChanged, QuartzDisplayChangedHandler);
- mieqSetHandler(kXquartzWindowState, DarwinEventHandler);
- mieqSetHandler(kXquartzWindowMoved, DarwinEventHandler);
+ QuartzModeEQInit();
+
return TRUE;
}
@@ -322,168 +338,208 @@ Bool DarwinEQInit(DevicePtr pKbd, DevicePtr pPtr) {
*/
void ProcessInputEvents(void) {
xEvent xe;
- // button number and modifier mask of currently pressed fake button
- input_check_flag=0;
+ int x = sizeof(xe);
+
+ TA_SERVER();
- // ErrorF("calling mieqProcessInputEvents\n");
mieqProcessInputEvents();
// Empty the signaling pipe
- int x = sizeof(xe);
while (x == sizeof(xe)) {
-// DEBUG_LOG("draining pipe\n");
x = read(darwinEventReadFD, &xe, sizeof(xe));
}
}
/* 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++;
- // <daniels> bushing: oh, i ... er ... christ.
- write(darwinEventWriteFD, &nullbyte, 1);
+static void DarwinPokeEQ(void) {
+ char nullbyte=0;
+ input_check_flag++;
+ // <daniels> oh, i ... er ... christ.
+ write(darwinEventWriteFD, &nullbyte, 1);
+}
+
+/* Convert from Appkit pointer input values to X input values:
+ * Note: pointer_x and pointer_y are relative to the upper-left of primary
+ * display.
+ */
+static void DarwinPrepareValuators(int *valuators, ScreenPtr screen,
+ int pointer_x, int pointer_y,
+ float pressure, float tilt_x, float tilt_y) {
+ /* Fix offset between darwin and X screens */
+ pointer_x -= darwinMainScreenX + dixScreenOrigins[screen->myNum].x;
+ pointer_y -= darwinMainScreenY + dixScreenOrigins[screen->myNum].y;
+
+ /* Setup our array of values */
+ valuators[0] = pointer_x;
+ valuators[1] = pointer_y;
+ valuators[2] = pressure * SCALEFACTOR_PRESSURE;
+ valuators[3] = tilt_x * SCALEFACTOR_TILT;
+ valuators[4] = tilt_y * SCALEFACTOR_TILT;
+
+ DEBUG_LOG("Valuators: {%d,%d,%d,%d,%d}\n",
+ valuators[0], valuators[1], valuators[2], valuators[3], valuators[4]);
}
void DarwinSendPointerEvents(int ev_type, int ev_button, int pointer_x, int pointer_y,
float pressure, float tilt_x, float tilt_y) {
- static int darwinFakeMouseButtonDown = 0;
- static int darwinFakeMouseButtonMask = 0;
- int i, num_events;
-
+ static int darwinFakeMouseButtonDown = 0;
+ static int darwinFakeMouseButtonMask = 0;
+ int i, num_events;
+ DeviceIntPtr dev;
+ ScreenPtr screen;
+ int valuators[5];
+
+ DEBUG_LOG("x=%d, y=%d, p=%f, tx=%f, ty=%f\n", pointer_x, pointer_y, pressure, tilt_x, tilt_y);
+
if(!darwinEvents) {
- ErrorF("DarwinSendPointerEvents called before darwinEvents was initialized\n");
+ DEBUG_LOG("DarwinSendPointerEvents called before darwinEvents was initialized\n");
return;
}
- /* I can't find a spec for this, but at least GTK expects that tablets are
- just like mice, except they have either one or three extra valuators, in this
- order:
-
- X coord, Y coord, pressure, X tilt, Y tilt
- Pressure and tilt should be represented natively as floats; unfortunately,
- we can't do that. Again, GTK seems to record the min/max of each valuator,
- and then perform scaling back to float itself using that info. Soo.... */
-
- int valuators[5] = {pointer_x, pointer_y,
- pressure * INT32_MAX * 1.0f,
- tilt_x * INT32_MAX * 1.0f,
- tilt_y * INT32_MAX * 1.0f};
-
- if (ev_type == ButtonPress && darwinFakeButtons && ev_button == 1) {
- // Mimic multi-button mouse with modifier-clicks
- // If both sets of modifiers are pressed,
- // button 2 is clicked.
- if ((old_flags & darwinFakeMouse2Mask) == darwinFakeMouse2Mask) {
- DarwinSimulateMouseClick(pointer_x, pointer_y, pressure,
+
+ if (pressure == 0 && tilt_x == 0 && tilt_y == 0)
+ dev = darwinPointer;
+ else
+ dev = darwinTablet;
+
+ screen = miPointerGetScreen(dev);
+ if(!screen) {
+ DEBUG_LOG("DarwinSendPointerEvents called before screen was initialized\n");
+ return;
+ }
+
+ if (ev_type == ButtonPress && darwinFakeButtons && ev_button == 1) {
+ // Mimic multi-button mouse with modifier-clicks
+ // If both sets of modifiers are pressed,
+ // button 2 is clicked.
+ if ((old_flags & darwinFakeMouse2Mask) == darwinFakeMouse2Mask) {
+ DarwinSimulateMouseClick(pointer_x, pointer_y, pressure,
tilt_x, tilt_y, 2, darwinFakeMouse2Mask);
- darwinFakeMouseButtonDown = 2;
- darwinFakeMouseButtonMask = darwinFakeMouse2Mask;
- return;
- } else if ((old_flags & darwinFakeMouse3Mask) == darwinFakeMouse3Mask) {
- DarwinSimulateMouseClick(pointer_x, pointer_y, pressure,
+ darwinFakeMouseButtonDown = 2;
+ darwinFakeMouseButtonMask = darwinFakeMouse2Mask;
+ return;
+ } else if ((old_flags & darwinFakeMouse3Mask) == darwinFakeMouse3Mask) {
+ DarwinSimulateMouseClick(pointer_x, pointer_y, pressure,
tilt_x, tilt_y, 3, darwinFakeMouse3Mask);
- darwinFakeMouseButtonDown = 3;
- darwinFakeMouseButtonMask = darwinFakeMouse3Mask;
- return;
- }
- }
- if (ev_type == ButtonRelease && darwinFakeButtons && darwinFakeMouseButtonDown) {
- // If last mousedown was a fake click, don't check for
- // mouse modifiers here. The user may have released the
- // modifiers before the mouse button.
- ev_button = darwinFakeMouseButtonDown;
- darwinFakeMouseButtonDown = 0;
- // Bring modifiers back up to date
- DarwinUpdateModifiers(KeyPress, darwinFakeMouseButtonMask & old_flags);
- darwinFakeMouseButtonMask = 0;
- return;
- }
-
- num_events = GetPointerEvents(darwinEvents, darwinPointer, ev_type, ev_button,
- POINTER_ABSOLUTE, 0, 5, valuators);
-
- for(i=0; i<num_events; i++) mieqEnqueue (darwinPointer,&darwinEvents[i]);
- DarwinPokeEQ();
+ darwinFakeMouseButtonDown = 3;
+ darwinFakeMouseButtonMask = darwinFakeMouse3Mask;
+ return;
+ }
+ }
+
+ if (ev_type == ButtonRelease && darwinFakeButtons && darwinFakeMouseButtonDown) {
+ // If last mousedown was a fake click, don't check for
+ // mouse modifiers here. The user may have released the
+ // modifiers before the mouse button.
+ ev_button = darwinFakeMouseButtonDown;
+ darwinFakeMouseButtonDown = 0;
+ // Bring modifiers back up to date
+ DarwinUpdateModifiers(KeyPress, darwinFakeMouseButtonMask & old_flags);
+ darwinFakeMouseButtonMask = 0;
+ return;
+ }
+
+ DarwinPrepareValuators(valuators, screen, pointer_x, pointer_y, pressure, tilt_x, tilt_y);
+ darwinEvents_lock(); {
+ num_events = GetPointerEvents(darwinEvents, dev, ev_type, ev_button,
+ POINTER_ABSOLUTE, 0, dev==darwinTablet?5:2, valuators);
+ for(i=0; i<num_events; i++) mieqEnqueue (dev, &darwinEvents[i]);
+ DarwinPokeEQ();
+
+ } darwinEvents_unlock();
}
void DarwinSendKeyboardEvents(int ev_type, int keycode) {
- int i, num_events;
+ int i, num_events;
+
if(!darwinEvents) {
- ErrorF("DarwinSendKeyboardEvents called before darwinEvents was initialized\n");
+ DEBUG_LOG("DarwinSendKeyboardEvents called before darwinEvents was initialized\n");
return;
}
- if (old_flags == 0 && darwinSyncKeymap && darwinKeymapFile == NULL) {
- /* See if keymap has changed. */
+ if (old_flags == 0 && darwinSyncKeymap && darwinKeymapFile == NULL) {
+ /* See if keymap has changed. */
- static unsigned int last_seed;
- unsigned int this_seed;
+ static unsigned int last_seed;
+ unsigned int this_seed;
- this_seed = QuartzSystemKeymapSeed();
- if (this_seed != last_seed) {
- last_seed = this_seed;
- DarwinSendDDXEvent(kXquartzReloadKeymap, 0);
- }
- }
+ this_seed = QuartzSystemKeymapSeed();
+ if (this_seed != last_seed) {
+ last_seed = this_seed;
+ DarwinSendDDXEvent(kXquartzReloadKeymap, 0);
+ }
+ }
- num_events = GetKeyboardEvents(darwinEvents, darwinKeyboard, ev_type, keycode + MIN_KEYCODE);
- for(i=0; i<num_events; i++) mieqEnqueue(darwinKeyboard,&darwinEvents[i]);
- DarwinPokeEQ();
+ darwinEvents_lock(); {
+ num_events = GetKeyboardEvents(darwinEvents, darwinKeyboard, ev_type, keycode + MIN_KEYCODE);
+ for(i=0; i<num_events; i++) mieqEnqueue(darwinKeyboard,&darwinEvents[i]);
+ DarwinPokeEQ();
+ } darwinEvents_unlock();
}
-void DarwinSendProximityEvents(int ev_type, int pointer_x, int pointer_y,
- float pressure, float tilt_x, float tilt_y) {
- int i, num_events;
- int valuators[5] = {pointer_x, pointer_y,
- pressure * INT32_MAX * 1.0f,
- tilt_x * INT32_MAX * 1.0f,
- tilt_y * INT32_MAX * 1.0f};
+void DarwinSendProximityEvents(int ev_type, int pointer_x, int pointer_y) {
+ int i, num_events;
+ ScreenPtr screen;
+ DeviceIntPtr dev = darwinTablet;
+ int valuators[5];
- if(!darwinEvents) {
- ErrorF("DarwinSendProximityvents called before darwinEvents was initialized\n");
- return;
-}
+ DEBUG_LOG("DarwinSendProximityEvents(%d, %d, %d)\n", ev_type, pointer_x, pointer_y);
- num_events = GetProximityEvents(darwinEvents, darwinPointer, ev_type,
- 0, 5, valuators);
-
- for(i=0; i<num_events; i++) mieqEnqueue (darwinPointer,&darwinEvents[i]);
- DarwinPokeEQ();
+ if(!darwinEvents) {
+ DEBUG_LOG("DarwinSendProximityEvents called before darwinEvents was initialized\n");
+ return;
+ }
+
+ screen = miPointerGetScreen(dev);
+ if(!screen) {
+ DEBUG_LOG("DarwinSendPointerEvents called before screen was initialized\n");
+ return;
+ }
+
+ DarwinPrepareValuators(valuators, screen, pointer_x, pointer_y, 0.0f, 0.0f, 0.0f);
+ darwinEvents_lock(); {
+ num_events = GetProximityEvents(darwinEvents, dev, ev_type,
+ 0, 5, valuators);
+ for(i=0; i<num_events; i++) mieqEnqueue (dev,&darwinEvents[i]);
+ DarwinPokeEQ();
+ } darwinEvents_unlock();
}
-/* Send the appropriate number of button 4 / 5 clicks to emulate scroll wheel */
-void DarwinSendScrollEvents(float count, int pointer_x, int pointer_y,
- float pressure, float tilt_x, float tilt_y) {
- int i;
- int ev_button = count > 0.0f ? 4 : 5;
- int valuators[5] = {pointer_x, pointer_y,
- pressure * INT32_MAX * 1.0f,
- tilt_x * INT32_MAX * 1.0f,
- tilt_y * INT32_MAX * 1.0f};
-
+/* Send the appropriate number of button clicks to emulate scroll wheel */
+void DarwinSendScrollEvents(float count_x, float count_y,
+ int pointer_x, int pointer_y,
+ float pressure, float tilt_x, float tilt_y) {
if(!darwinEvents) {
- ErrorF("DarwinSendScrollEvents called before darwinEvents was initialized\n");
+ DEBUG_LOG("DarwinSendScrollEvents called before darwinEvents was initialized\n");
return;
}
- for (count = fabs(count); count > 0.0; count = count - 1.0f) {
- int num_events = GetPointerEvents(darwinEvents, darwinPointer, ButtonPress, ev_button,
- POINTER_ABSOLUTE, 0, 5, valuators);
- for(i=0; i<num_events; i++) mieqEnqueue(darwinPointer,&darwinEvents[i]);
- num_events = GetPointerEvents(darwinEvents, darwinPointer, ButtonRelease, ev_button,
- POINTER_ABSOLUTE, 0, 5, valuators);
- for(i=0; i<num_events; i++) mieqEnqueue(darwinPointer,&darwinEvents[i]);
- }
- DarwinPokeEQ();
+ int sign_x = count_x > 0.0f ? SCROLLWHEELLEFTFAKE : SCROLLWHEELRIGHTFAKE;
+ int sign_y = count_y > 0.0f ? SCROLLWHEELUPFAKE : SCROLLWHEELDOWNFAKE;
+ count_x = fabs(count_x);
+ count_y = fabs(count_y);
+
+ while ((count_x > 0.0f) || (count_y > 0.0f)) {
+ if (count_x > 0.0f) {
+ DarwinSendPointerEvents(ButtonPress, sign_x, pointer_x, pointer_y, pressure, tilt_x, tilt_y);
+ DarwinSendPointerEvents(ButtonRelease, sign_x, pointer_x, pointer_y, pressure, tilt_x, tilt_y);
+ count_x = count_x - 1.0f;
+ }
+ if (count_y > 0.0f) {
+ DarwinSendPointerEvents(ButtonPress, sign_y, pointer_x, pointer_y, pressure, tilt_x, tilt_y);
+ DarwinSendPointerEvents(ButtonRelease, sign_y, pointer_x, pointer_y, pressure, tilt_x, tilt_y);
+ count_y = count_y - 1.0f;
+ }
+ }
}
/* Send the appropriate KeyPress/KeyRelease events to GetKeyboardEvents to
reflect changing modifier flags (alt, control, meta, etc) */
void DarwinUpdateModKeys(int flags) {
- DarwinUpdateModifiers(KeyRelease, old_flags & ~flags);
- DarwinUpdateModifiers(KeyPress, ~old_flags & flags);
- old_flags = flags;
+ DarwinUpdateModifiers(KeyRelease, old_flags & ~flags);
+ DarwinUpdateModifiers(KeyPress, ~old_flags & flags);
+ old_flags = flags;
}
@@ -511,5 +567,8 @@ void DarwinSendDDXEvent(int type, int argc, ...) {
va_end (args);
}
- mieqEnqueue(NULL, &xe);
+ darwinEvents_lock();
+ mieqEnqueue(darwinPointer, &xe);
+ DarwinPokeEQ();
+ darwinEvents_unlock();
}
diff --git a/hw/xquartz/darwinEvents.h b/hw/xquartz/darwinEvents.h
index 7c56be9c8..a676aeb53 100644
--- a/hw/xquartz/darwinEvents.h
+++ b/hw/xquartz/darwinEvents.h
@@ -28,21 +28,48 @@
#ifndef _DARWIN_EVENTS_H
#define _DARWIN_EVENTS_H
-Bool DarwinEQInit(DevicePtr pKbd, DevicePtr pPtr);
+Bool DarwinEQInit(void);
void DarwinEQEnqueue(const xEventPtr e);
void DarwinEQPointerPost(DeviceIntPtr pDev, xEventPtr e);
void DarwinEQSwitchScreen(ScreenPtr pScreen, Bool fromDIX);
-void DarwinPokeEQ(void);
void DarwinSendPointerEvents(int ev_type, int ev_button, int pointer_x, int pointer_y,
float pressure, float tilt_x, float tilt_y);
-void DarwinSendProximityEvents(int ev_type, int pointer_x, int pointer_y,
- float pressure, float tilt_x, float tilt_y);
+void DarwinSendProximityEvents(int ev_type, int pointer_x, int pointer_y);
void DarwinSendKeyboardEvents(int ev_type, int keycode);
-void DarwinSendScrollEvents(float count, int pointer_x, int pointer_y,
+void DarwinSendScrollEvents(float count_x, float count_y, int pointer_x, int pointer_y,
float pressure, float tilt_x, float tilt_y);
void DarwinUpdateModKeys(int flags);
-void DarwinEventHandler(int screenNum, xEventPtr xe, DeviceIntPtr dev,
- int nevents);
+/*
+ * Special ddx events understood by the X server
+ */
+enum {
+ kXquartzReloadKeymap // Reload system keymap
+ = LASTEvent+1, // (from X.h list of event names)
+ kXquartzActivate, // restore X drawing and cursor
+ kXquartzDeactivate, // clip X drawing and switch to Aqua cursor
+ kXquartzSetRootClip, // enable or disable drawing to the X screen
+ kXquartzQuit, // kill the X server and release the display
+ kXquartzReadPasteboard, // copy Mac OS X pasteboard into X cut buffer
+ kXquartzWritePasteboard, // copy X cut buffer onto Mac OS X pasteboard
+ kXquartzBringAllToFront, // bring all X windows to front
+ kXquartzToggleFullscreen, // Enable/Disable fullscreen mode
+ kXquartzSetRootless, // Set rootless mode
+ kXquartzSpaceChanged, // Spaces changed
+ /*
+ * AppleWM events
+ */
+ kXquartzControllerNotify, // send an AppleWMControllerNotify event
+ kXquartzPasteboardNotify, // notify the WM to copy or paste
+ /*
+ * Xplugin notification events
+ */
+ kXquartzDisplayChanged, // display configuration has changed
+ kXquartzWindowState, // window visibility state has changed
+ kXquartzWindowMoved, // window has moved on screen
+};
+
+/* Send one of the above events to the server thread. */
+void DarwinSendDDXEvent(int type, int argc, ...);
#endif /* _DARWIN_EVENTS_H */
diff --git a/hw/xquartz/darwinKeyboard.c b/hw/xquartz/darwinKeyboard.c
deleted file mode 100644
index 0a8c5c010..000000000
--- a/hw/xquartz/darwinKeyboard.c
+++ /dev/null
@@ -1,1013 +0,0 @@
-//=============================================================================
-//
-// Keyboard support for the Darwin X Server
-//
-// Copyright (c) 2001-2004 Torrey T. Lyons. All Rights Reserved.
-// Copyright (c) 2003 Apple Computer, Inc. All Rights Reserved.
-// Copyright 2004 Kaleb S. KEITHLEY. All Rights Reserved.
-//
-// The code to parse the Darwin keymap is derived from dumpkeymap.c
-// by Eric Sunshine, which includes the following copyright:
-//
-// Copyright (C) 1999,2000 by Eric Sunshine <sunshine@sunshineco.com>
-// All rights reserved.
-//
-//-----------------------------------------------------------------------------
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are met:
-//
-// 1. Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-// 2. Redistributions in binary form must reproduce the above copyright
-// notice, this list of conditions and the following disclaimer in the
-// documentation and/or other materials provided with the distribution.
-// 3. The name of the author may not be used to endorse or promote products
-// derived from this software without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
-// IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
-// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
-// NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
-// TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
-// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
-// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
-// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
-// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-//
-//=============================================================================
-
-
-/*
-===========================================================================
-
- An X keyCode must be in the range XkbMinLegalKeyCode (8) to
- XkbMaxLegalKeyCode(255).
-
- The keyCodes we get from the kernel range from 0 to 127, so we need to
- offset the range before passing the keyCode to X.
-
- An X KeySym is an extended ascii code that is device independent.
-
- The modifier map is accessed by the keyCode, but the normal map is
- accessed by keyCode - MIN_KEYCODE. Sigh.
-
-===========================================================================
-*/
-
-#ifdef HAVE_DIX_CONFIG_H
-#include <dix-config.h>
-#endif
-
-// Define this to get a diagnostic output to stderr which is helpful
-// in determining how the X server is interpreting the Darwin keymap.
-// #define DUMP_DARWIN_KEYMAP
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <errno.h>
-#include <sys/stat.h>
-#include <IOKit/hidsystem/event_status_driver.h>
-#include <IOKit/hidsystem/ev_keymap.h>
-#include <architecture/byte_order.h> // For the NXSwap*
-#include "darwin.h"
-#include "darwinKeyboard.h"
-#include "quartzKeyboard.h"
-#include "quartzAudio.h"
-
-#include <assert.h>
-
-#define AltMask Mod1Mask
-#define MetaMask Mod2Mask
-#define FunctionMask Mod3Mask
-
-#define UK(a) NoSymbol // unknown symbol
-
-static KeySym const next_to_x[256] = {
- NoSymbol, NoSymbol, NoSymbol, XK_KP_Enter,
- NoSymbol, NoSymbol, NoSymbol, NoSymbol,
- XK_BackSpace, XK_Tab, XK_Linefeed, NoSymbol,
- NoSymbol, XK_Return, NoSymbol, NoSymbol,
- NoSymbol, NoSymbol, NoSymbol, NoSymbol,
- NoSymbol, NoSymbol, NoSymbol, NoSymbol,
- NoSymbol, NoSymbol, NoSymbol, XK_Escape,
- NoSymbol, NoSymbol, NoSymbol, NoSymbol,
- XK_space, XK_exclam, XK_quotedbl, XK_numbersign,
- XK_dollar, XK_percent, XK_ampersand, XK_apostrophe,
- XK_parenleft, XK_parenright, XK_asterisk, XK_plus,
- XK_comma, XK_minus, XK_period, XK_slash,
- XK_0, XK_1, XK_2, XK_3,
- XK_4, XK_5, XK_6, XK_7,
- XK_8, XK_9, XK_colon, XK_semicolon,
- XK_less, XK_equal, XK_greater, XK_question,
- XK_at, XK_A, XK_B, XK_C,
- XK_D, XK_E, XK_F, XK_G,
- XK_H, XK_I, XK_J, XK_K,
- XK_L, XK_M, XK_N, XK_O,
- XK_P, XK_Q, XK_R, XK_S,
- XK_T, XK_U, XK_V, XK_W,
- XK_X, XK_Y, XK_Z, XK_bracketleft,
- XK_backslash, XK_bracketright,XK_asciicircum, XK_underscore,
- XK_grave, XK_a, XK_b, XK_c,
- XK_d, XK_e, XK_f, XK_g,
- XK_h, XK_i, XK_j, XK_k,
- XK_l, XK_m, XK_n, XK_o,
- XK_p, XK_q, XK_r, XK_s,
- XK_t, XK_u, XK_v, XK_w,
- XK_x, XK_y, XK_z, XK_braceleft,
- XK_bar, XK_braceright, XK_asciitilde, XK_BackSpace,
-// 128
- NoSymbol, XK_Agrave, XK_Aacute, XK_Acircumflex,
- XK_Atilde, XK_Adiaeresis, XK_Aring, XK_Ccedilla,
- XK_Egrave, XK_Eacute, XK_Ecircumflex, XK_Ediaeresis,
- XK_Igrave, XK_Iacute, XK_Icircumflex, XK_Idiaeresis,
-// 144
- XK_ETH, XK_Ntilde, XK_Ograve, XK_Oacute,
- XK_Ocircumflex, XK_Otilde, XK_Odiaeresis, XK_Ugrave,
- XK_Uacute, XK_Ucircumflex, XK_Udiaeresis, XK_Yacute,
- XK_THORN, XK_mu, XK_multiply, XK_division,
-// 160
- XK_copyright, XK_exclamdown, XK_cent, XK_sterling,
- UK(fraction), XK_yen, UK(fhook), XK_section,
- XK_currency, XK_rightsinglequotemark,
- XK_leftdoublequotemark,
- XK_guillemotleft,
- XK_leftanglebracket,
- XK_rightanglebracket,
- UK(filigature), UK(flligature),
-// 176
- XK_registered, XK_endash, XK_dagger, XK_doubledagger,
- XK_periodcentered,XK_brokenbar, XK_paragraph, UK(bullet),
- XK_singlelowquotemark,
- XK_doublelowquotemark,
- XK_rightdoublequotemark,
- XK_guillemotright,
- XK_ellipsis, UK(permille), XK_notsign, XK_questiondown,
-// 192
- XK_onesuperior, XK_dead_grave, XK_dead_acute, XK_dead_circumflex,
- XK_dead_tilde, XK_dead_macron, XK_dead_breve, XK_dead_abovedot,
- XK_dead_diaeresis,
- XK_twosuperior, XK_dead_abovering,
- XK_dead_cedilla,
- XK_threesuperior,
- XK_dead_doubleacute,
- XK_dead_ogonek, XK_dead_caron,
-// 208
- XK_emdash, XK_plusminus, XK_onequarter, XK_onehalf,
- XK_threequarters,
- XK_agrave, XK_aacute, XK_acircumflex,
- XK_atilde, XK_adiaeresis, XK_aring, XK_ccedilla,
- XK_egrave, XK_eacute, XK_ecircumflex, XK_ediaeresis,
-// 224
- XK_igrave, XK_AE, XK_iacute, XK_ordfeminine,
- XK_icircumflex, XK_idiaeresis, XK_eth, XK_ntilde,
- XK_Lstroke, XK_Ooblique, XK_OE, XK_masculine,
- XK_ograve, XK_oacute, XK_ocircumflex, XK_otilde,
-// 240
- XK_odiaeresis, XK_ae, XK_ugrave, XK_uacute,
- XK_ucircumflex, XK_idotless, XK_udiaeresis, XK_ygrave,
- XK_lstroke, XK_ooblique, XK_oe, XK_ssharp,
- XK_thorn, XK_ydiaeresis, NoSymbol, NoSymbol,
- };
-
-#define MIN_SYMBOL 0xAC
-static KeySym const symbol_to_x[] = {
- XK_Left, XK_Up, XK_Right, XK_Down
- };
-static int const NUM_SYMBOL = sizeof(symbol_to_x) / sizeof(symbol_to_x[0]);
-
-#define MIN_FUNCKEY 0x20
-static KeySym const funckey_to_x[] = {
- XK_F1, XK_F2, XK_F3, XK_F4,
- XK_F5, XK_F6, XK_F7, XK_F8,
- XK_F9, XK_F10, XK_F11, XK_F12,
- XK_Insert, XK_Delete, XK_Home, XK_End,
- XK_Page_Up, XK_Page_Down, XK_F13, XK_F14,
- XK_F15
- };
-static int const NUM_FUNCKEY = sizeof(funckey_to_x) / sizeof(funckey_to_x[0]);
-
-typedef struct {
- KeySym normalSym;
- KeySym keypadSym;
-} darwinKeyPad_t;
-
-static darwinKeyPad_t const normal_to_keypad[] = {
- { XK_0, XK_KP_0 },
- { XK_1, XK_KP_1 },
- { XK_2, XK_KP_2 },
- { XK_3, XK_KP_3 },
- { XK_4, XK_KP_4 },
- { XK_5, XK_KP_5 },
- { XK_6, XK_KP_6 },
- { XK_7, XK_KP_7 },
- { XK_8, XK_KP_8 },
- { XK_9, XK_KP_9 },
- { XK_equal, XK_KP_Equal },
- { XK_asterisk, XK_KP_Multiply },
- { XK_plus, XK_KP_Add },
- { XK_comma, XK_KP_Separator },
- { XK_minus, XK_KP_Subtract },
- { XK_period, XK_KP_Decimal },
- { XK_slash, XK_KP_Divide }
-};
-static int const NUM_KEYPAD = sizeof(normal_to_keypad) / sizeof(normal_to_keypad[0]);
-
-static void DarwinChangeKeyboardControl( DeviceIntPtr device, KeybdCtrl *ctrl )
-{
- // keyclick, bell volume / pitch, autorepead, LED's
-}
-
-darwinKeyboardInfo keyInfo;
-static FILE *fref = NULL;
-static char *inBuffer = NULL;
-
-//-----------------------------------------------------------------------------
-// Data Stream Object
-// Can be configured to treat embedded "numbers" as being composed of
-// either 1, 2, or 4 bytes, apiece.
-//-----------------------------------------------------------------------------
-typedef struct _DataStream {
- unsigned char const *data;
- unsigned char const *data_end;
- short number_size; // Size in bytes of a "number" in the stream.
-} DataStream;
-
-static DataStream* new_data_stream(unsigned char const* data, int size) {
- DataStream* s = (DataStream*)xalloc( sizeof(DataStream) );
- if(s) {
- s->data = data;
- s->data_end = data + size;
- s->number_size = 1; // Default to byte-sized numbers.
- }
- return s;
-}
-
-static void destroy_data_stream(DataStream* s) {
- xfree(s);
-}
-
-static unsigned char get_byte(DataStream* s) {
- assert(s->data + 1 <= s->data_end);
- return *s->data++;
-}
-
-static short get_word(DataStream* s) {
- short hi, lo;
- assert(s->data + 2 <= s->data_end);
- hi = *s->data++;
- lo = *s->data++;
- return ((hi << 8) | lo);
-}
-
-static int get_dword(DataStream* s) {
- int b1, b2, b3, b4;
- assert(s->data + 4 <= s->data_end);
- b4 = *s->data++;
- b3 = *s->data++;
- b2 = *s->data++;
- b1 = *s->data++;
- return ((b4 << 24) | (b3 << 16) | (b2 << 8) | b1);
-}
-
-static int get_number(DataStream* s) {
- switch (s->number_size) {
- case 4: return get_dword(s);
- case 2: return get_word(s);
- default: return get_byte(s);
- }
-}
-
-//-----------------------------------------------------------------------------
-// Utility functions to help parse Darwin keymap
-//-----------------------------------------------------------------------------
-
-/*
- * bits_set
- * Calculate number of bits set in the modifier mask.
- */
-static short bits_set(short mask) {
- short n = 0;
-
- for ( ; mask != 0; mask >>= 1)
- if ((mask & 0x01) != 0)
- n++;
- return n;
-}
-
-/*
- * parse_next_char_code
- * Read the next character code from the Darwin keymapping
- * and write it to the X keymap.
- */
-static void parse_next_char_code(DataStream *s, KeySym *k) {
- const short charSet = get_number(s);
- const short charCode = get_number(s);
-
- if (charSet == 0) { // ascii character
- if (charCode >= 0 && charCode < 256)
- *k = next_to_x[charCode];
- } else if (charSet == 0x01) { // symbol character
- if (charCode >= MIN_SYMBOL &&
- charCode <= MIN_SYMBOL + NUM_SYMBOL)
- *k = symbol_to_x[charCode - MIN_SYMBOL];
- } else if (charSet == 0xFE) { // function key
- if (charCode >= MIN_FUNCKEY &&
- charCode <= MIN_FUNCKEY + NUM_FUNCKEY)
- *k = funckey_to_x[charCode - MIN_FUNCKEY];
- }
-}
-
-
-/*
- * DarwinReadKeymapFile
- * Read the appropriate keymapping from a keymapping file.
- */
-static Bool DarwinReadKeymapFile(NXKeyMapping *keyMap) {
- struct stat st;
- NXEventSystemDevice info[20];
- int interface = 0, handler_id = 0;
- int map_interface, map_handler_id, map_size = 0;
- unsigned int i, size;
- int *bufferEnd;
- union km_tag {
- int *intP;
- char *charP;
- } km;
-
- fref = fopen( darwinKeymapFile, "rb" );
- if (fref == NULL) {
- ErrorF("Unable to open keymapping file '%s' (%s).\n",
- darwinKeymapFile, strerror(errno));
- return FALSE;
- }
- if (fstat(fileno(fref), &st) == -1) {
- ErrorF("Could not stat keymapping file '%s' (%s).\n",
- darwinKeymapFile, strerror(errno));
- return FALSE;
- }
-
- // check to make sure we don't crash later
- if (st.st_size <= 16*sizeof(int)) {
- ErrorF("Keymapping file '%s' is invalid (too small).\n",
- darwinKeymapFile);
- return FALSE;
- }
-
- inBuffer = (char*) xalloc( st.st_size );
- bufferEnd = (int *) (inBuffer + st.st_size);
- if (fread(inBuffer, st.st_size, 1, fref) != 1) {
- ErrorF("Could not read %qd bytes from keymapping file '%s' (%s).\n",
- st.st_size, darwinKeymapFile, strerror(errno));
- return FALSE;
- }
-
- if (strncmp( inBuffer, "KYM1", 4 ) == 0) {
- // Magic number OK.
- } else if (strncmp( inBuffer, "KYMP", 4 ) == 0) {
- ErrorF("Keymapping file '%s' is intended for use with the original NeXT keyboards and cannot be used by XDarwin.\n", darwinKeymapFile);
- return FALSE;
- } else {
- ErrorF("Keymapping file '%s' has a bad magic number and cannot be used by XDarwin.\n", darwinKeymapFile);
- return FALSE;
- }
-
- // find the keyboard interface and handler id
- size = sizeof( info ) / sizeof( int );
- if (!NXEventSystemInfo( darwinParamConnect, NX_EVS_DEVICE_INFO,
- (NXEventSystemInfoType) info, &size )) {
- ErrorF("Error reading event status driver info.\n");
- return FALSE;
- }
-
- size = size * sizeof( int ) / sizeof( info[0] );
- for( i = 0; i < size; i++) {
- if (info[i].dev_type == NX_EVS_DEVICE_TYPE_KEYBOARD) {
- Bool hasInterface = FALSE;
- Bool hasMatch = FALSE;
-
- interface = info[i].interface;
- handler_id = info[i].id;
-
- // Find an appropriate keymapping:
- // The first time we try to match both interface and handler_id.
- // If we can't match both, we take the first match for interface.
-
- do {
- km.charP = inBuffer;
- km.intP++;
- while (km.intP+3 < bufferEnd) {
- map_interface = NXSwapBigIntToHost(*(km.intP++));
- map_handler_id = NXSwapBigIntToHost(*(km.intP++));
- map_size = NXSwapBigIntToHost(*(km.intP++));
- if (map_interface == interface) {
- if (map_handler_id == handler_id || hasInterface) {
- hasMatch = TRUE;
- break;
- } else {
- hasInterface = TRUE;
- }
- }
- km.charP += map_size;
- }
- } while (hasInterface && !hasMatch);
-
- if (hasMatch) {
- // fill in NXKeyMapping structure
- keyMap->size = map_size;
- keyMap->mapping = (char*) xalloc(map_size);
- memcpy(keyMap->mapping, km.charP, map_size);
- return TRUE;
- }
- } // if dev_id == keyboard device
- } // foreach info struct
-
- // The keymapping file didn't match any of the info structs
- // returned by NXEventSystemInfo.
- ErrorF("Keymapping file '%s' did not contain appropriate keyboard interface.\n", darwinKeymapFile);
- return FALSE;
-}
-
-
-/*
- * DarwinParseNXKeyMapping
- */
-static Bool DarwinParseNXKeyMapping(darwinKeyboardInfo *info) {
- KeySym *k;
- int i;
- short numMods, numKeys, numPadKeys = 0;
- Bool haveKeymap = FALSE;
- NXKeyMapping keyMap;
- DataStream *keyMapStream;
- unsigned char const *numPadStart = 0;
-
- if (darwinKeymapFile) {
- haveKeymap = DarwinReadKeymapFile(&keyMap);
- if (fref)
- fclose(fref);
- if (inBuffer)
- xfree(inBuffer);
- if (!haveKeymap) {
- ErrorF("Reverting to kernel keymapping.\n");
- }
- }
-
- if (!haveKeymap) {
- // get the Darwin keyboard map
- keyMap.size = NXKeyMappingLength( darwinParamConnect );
- keyMap.mapping = (char*) xalloc( keyMap.size );
- if (!NXGetKeyMapping( darwinParamConnect, &keyMap )) {
- return FALSE;
- }
- }
-
- keyMapStream = new_data_stream( (unsigned char const*)keyMap.mapping,
- keyMap.size );
-
- // check the type of map
- if (get_word(keyMapStream)) {
- keyMapStream->number_size = 2;
- ErrorF("Current 16-bit keymapping may not be interpreted correctly.\n");
- }
-
- // Insert X modifier KeySyms into the keyboard map.
- numMods = get_number(keyMapStream);
- while (numMods-- > 0) {
- int left = 1; // first keycode is left
- short const charCode = get_number(keyMapStream);
- short numKeyCodes = get_number(keyMapStream);
-
- // This is just a marker, not a real modifier.
- // Store numeric keypad keys for later.
- if (charCode == NX_MODIFIERKEY_NUMERICPAD) {
- numPadStart = keyMapStream->data;
- numPadKeys = numKeyCodes;
- }
-
- while (numKeyCodes-- > 0) {
- const short keyCode = get_number(keyMapStream);
- if (charCode != NX_MODIFIERKEY_NUMERICPAD) {
- switch (charCode) {
- case NX_MODIFIERKEY_ALPHALOCK:
- info->keyMap[keyCode * GLYPHS_PER_KEY] = XK_Caps_Lock;
- break;
- case NX_MODIFIERKEY_SHIFT:
- info->keyMap[keyCode * GLYPHS_PER_KEY] =
- (left ? XK_Shift_L : XK_Shift_R);
- break;
- case NX_MODIFIERKEY_CONTROL:
- info->keyMap[keyCode * GLYPHS_PER_KEY] =
- (left ? XK_Control_L : XK_Control_R);
- break;
- case NX_MODIFIERKEY_ALTERNATE:
- // info->keyMap[keyCode * GLYPHS_PER_KEY] = XK_Mode_switch;
- info->keyMap[keyCode * GLYPHS_PER_KEY] =
- (left ? XK_Alt_L : XK_Alt_R);
- break;
- case NX_MODIFIERKEY_COMMAND:
- info->keyMap[keyCode * GLYPHS_PER_KEY] =
- (left ? XK_Meta_L : XK_Meta_R);
- break;
- case NX_MODIFIERKEY_SECONDARYFN:
- info->keyMap[keyCode * GLYPHS_PER_KEY] =
- (left ? XK_Control_L : XK_Control_R);
- break;
- case NX_MODIFIERKEY_HELP:
- // Help is not an X11 modifier; treat as normal key
- info->keyMap[keyCode * GLYPHS_PER_KEY] = XK_Help;
- break;
- }
- }
- left = 0;
- }
- }
-
- // Convert the Darwin keyboard mapping to an X keyboard map.
- // A key can have a different character code for each combination of
- // modifiers. We currently ignore all modifier combinations except
- // those with Shift, AlphaLock, and Alt.
- numKeys = get_number(keyMapStream);
- for (i = 0, k = info->keyMap; i < numKeys; i++, k += GLYPHS_PER_KEY) {
- short const charGenMask = get_number(keyMapStream);
- if (charGenMask != 0xFF) { // is key bound?
- short numKeyCodes = 1 << bits_set(charGenMask);
-
- // Record unmodified case
- parse_next_char_code( keyMapStream, k );
- numKeyCodes--;
-
- // If AlphaLock and Shift modifiers produce different codes,
- // we record the Shift case since X handles AlphaLock.
- if (charGenMask & 0x01) { // AlphaLock
- parse_next_char_code( keyMapStream, k+1 );
- numKeyCodes--;
- }
-
- if (charGenMask & 0x02) { // Shift
- parse_next_char_code( keyMapStream, k+1 );
- numKeyCodes--;
-
- if (charGenMask & 0x01) { // Shift-AlphaLock
- get_number(keyMapStream); get_number(keyMapStream);
- numKeyCodes--;
- }
- }
-
- // Skip the Control cases
- if (charGenMask & 0x04) { // Control
- get_number(keyMapStream); get_number(keyMapStream);
- numKeyCodes--;
-
- if (charGenMask & 0x01) { // Control-AlphaLock
- get_number(keyMapStream); get_number(keyMapStream);
- numKeyCodes--;
- }
-
- if (charGenMask & 0x02) { // Control-Shift
- get_number(keyMapStream); get_number(keyMapStream);
- numKeyCodes--;
-
- if (charGenMask & 0x01) { // Shift-Control-AlphaLock
- get_number(keyMapStream); get_number(keyMapStream);
- numKeyCodes--;
- }
- }
- }
-
- // Process Alt cases
- if (charGenMask & 0x08) { // Alt
- parse_next_char_code( keyMapStream, k+2 );
- numKeyCodes--;
-
- if (charGenMask & 0x01) { // Alt-AlphaLock
- parse_next_char_code( keyMapStream, k+3 );
- numKeyCodes--;
- }
-
- if (charGenMask & 0x02) { // Alt-Shift
- parse_next_char_code( keyMapStream, k+3 );
- numKeyCodes--;
-
- if (charGenMask & 0x01) { // Alt-Shift-AlphaLock
- get_number(keyMapStream); get_number(keyMapStream);
- numKeyCodes--;
- }
- }
- }
-
- while (numKeyCodes-- > 0) {
- get_number(keyMapStream); get_number(keyMapStream);
- }
-
- if (k[3] == k[2]) k[3] = NoSymbol;
- if (k[2] == k[1]) k[2] = NoSymbol;
- if (k[1] == k[0]) k[1] = NoSymbol;
- if (k[0] == k[2] && k[1] == k[3]) k[2] = k[3] = NoSymbol;
- }
- }
-
- // Now we have to go back through the list of keycodes that are on the
- // numeric keypad and update the X keymap.
- keyMapStream->data = numPadStart;
- while(numPadKeys-- > 0) {
- const short keyCode = get_number(keyMapStream);
- k = &info->keyMap[keyCode * GLYPHS_PER_KEY];
- for (i = 0; i < NUM_KEYPAD; i++) {
- if (*k == normal_to_keypad[i].normalSym) {
- k[0] = normal_to_keypad[i].keypadSym;
- break;
- }
- }
- }
-
- // free Darwin keyboard map
- destroy_data_stream( keyMapStream );
- xfree( keyMap.mapping );
-
- return TRUE;
-}
-
-/*
- * DarwinBuildModifierMaps
- * Use the keyMap field of keyboard info structure to populate
- * the modMap and modifierKeycodes fields.
- */
-static void DarwinBuildModifierMaps(darwinKeyboardInfo *info) {
- int i;
- KeySym *k;
-
- memset(info->modMap, NoSymbol, sizeof(info->modMap));
- memset(info->modifierKeycodes, 0, sizeof(info->modifierKeycodes));
-
- for (i = 0; i < NUM_KEYCODES; i++) {
- k = info->keyMap + i * GLYPHS_PER_KEY;
-
- switch (*k) {
- case XK_Shift_L:
- info->modifierKeycodes[NX_MODIFIERKEY_SHIFT][0] = i;
- info->modMap[MIN_KEYCODE + i] = ShiftMask;
- break;
-
- case XK_Shift_R:
-#ifdef NX_MODIFIERKEY_RSHIFT
- info->modifierKeycodes[NX_MODIFIERKEY_RSHIFT][0] = i;
-#else
- info->modifierKeycodes[NX_MODIFIERKEY_SHIFT][0] = i;
-#endif
- info->modMap[MIN_KEYCODE + i] = ShiftMask;
- break;
-
- case XK_Control_L:
- info->modifierKeycodes[NX_MODIFIERKEY_CONTROL][0] = i;
- info->modMap[MIN_KEYCODE + i] = ControlMask;
- break;
-
- case XK_Control_R:
-#ifdef NX_MODIFIERKEY_RCONTROL
- info->modifierKeycodes[NX_MODIFIERKEY_RCONTROL][0] = i;
-#else
- info->modifierKeycodes[NX_MODIFIERKEY_CONTROL][0] = i;
-#endif
- info->modMap[MIN_KEYCODE + i] = ControlMask;
- break;
-
- case XK_Caps_Lock:
- info->modifierKeycodes[NX_MODIFIERKEY_ALPHALOCK][0] = i;
- info->modMap[MIN_KEYCODE + i] = LockMask;
- break;
-
- case XK_Alt_L:
- info->modifierKeycodes[NX_MODIFIERKEY_ALTERNATE][0] = i;
- info->modMap[MIN_KEYCODE + i] = Mod1Mask;
- *k = XK_Mode_switch; // Yes, this is ugly. This needs to be cleaned up when we integrate quartzKeyboard with this code and refactor.
- break;
-
- case XK_Alt_R:
-#ifdef NX_MODIFIERKEY_RALTERNATE
- info->modifierKeycodes[NX_MODIFIERKEY_RALTERNATE][0] = i;
-#else
- info->modifierKeycodes[NX_MODIFIERKEY_ALTERNATE][0] = i;
-#endif
- *k = XK_Mode_switch; // Yes, this is ugly. This needs to be cleaned up when we integrate quartzKeyboard with this code and refactor.
- info->modMap[MIN_KEYCODE + i] = Mod1Mask;
- break;
-
- case XK_Mode_switch:
- info->modMap[MIN_KEYCODE + i] = Mod1Mask;
- break;
-
- case XK_Meta_L:
- info->modifierKeycodes[NX_MODIFIERKEY_COMMAND][0] = i;
- info->modMap[MIN_KEYCODE + i] = Mod2Mask;
- break;
-
- case XK_Meta_R:
-#ifdef NX_MODIFIERKEY_RCOMMAND
- info->modifierKeycodes[NX_MODIFIERKEY_RCOMMAND][0] = i;
-#else
- info->modifierKeycodes[NX_MODIFIERKEY_COMMAND][0] = i;
-#endif
- info->modMap[MIN_KEYCODE + i] = Mod2Mask;
- break;
-
- case XK_Num_Lock:
- info->modMap[MIN_KEYCODE + i] = Mod3Mask;
- break;
- }
- }
-}
-
-/*
- * DarwinLoadKeyboardMapping
- * Load the keyboard map from a file or system and convert
- * it to an equivalent X keyboard map and modifier map.
- */
-static void DarwinLoadKeyboardMapping(KeySymsRec *keySyms) {
- void* callstack[128];
- int i, frames = backtrace(callstack, 128);
- char** strs = backtrace_symbols(callstack, frames);
- for (i = 0; i < frames; ++i) {
- ErrorF("%s\n", strs[i]);
- }
- free(strs);
-
- memset(keyInfo.keyMap, 0, sizeof(keyInfo.keyMap));
-
- /* TODO: Clean this up
- * QuartzReadSystemKeymap is in quartz/quartzKeyboard.c
- * DarwinParseNXKeyMapping is here
- */
- if (!DarwinParseNXKeyMapping(&keyInfo)) {
- DEBUG_LOG("DarwinParseNXKeyMapping returned 0... running QuartzReadSystemKeymap().\n");
- if (!QuartzReadSystemKeymap(&keyInfo)) {
- FatalError("Could not build a valid keymap.");
- }
- }
-
- DarwinBuildModifierMaps(&keyInfo);
-
-#ifdef DUMP_DARWIN_KEYMAP
- int i;
- KeySym *k;
- DEBUG_LOG("Darwin -> X converted keyboard map\n");
- for (i = 0, k = keyInfo.keyMap; i < NX_NUMKEYCODES;
- i++, k += GLYPHS_PER_KEY)
- {
- int j;
- for (j = 0; j < GLYPHS_PER_KEY; j++) {
- if (k[j] == NoSymbol) {
- DEBUG_LOG("0x%02x:\tNoSym\n", i);
- } else {
- DEBUG_LOG("0x%02x:\t0x%lx\n", i, k[j]);
- }
- }
- }
-#endif
-
- keySyms->map = keyInfo.keyMap;
- keySyms->mapWidth = GLYPHS_PER_KEY;
- keySyms->minKeyCode = MIN_KEYCODE;
- keySyms->maxKeyCode = MAX_KEYCODE;
-}
-
-
-/*
- * DarwinKeyboardInit
- * Get the Darwin keyboard map and compute an equivalent
- * X keyboard map and modifier map. Set the new keyboard
- * device structure.
- */
-void DarwinKeyboardInit(DeviceIntPtr pDev) {
- KeySymsRec keySyms;
-
- // Open a shared connection to the HID System.
- // Note that the Event Status Driver is really just a wrapper
- // for a kIOHIDParamConnectType connection.
- assert( darwinParamConnect = NXOpenEventStatus() );
-
- DarwinLoadKeyboardMapping(&keySyms);
- // DarwinKeyboardReload(pDev);
- /* Initialize the seed, so we don't reload the keymap unnecessarily
- (and possibly overwrite xinitrc changes) */
- QuartzSystemKeymapSeed();
-
- assert( InitKeyboardDeviceStruct( (DevicePtr)pDev, &keySyms,
- keyInfo.modMap, QuartzBell,
- DarwinChangeKeyboardControl ));
-}
-
-
-/* Borrowed from dix/devices.c */
-static Bool InitModMap(register KeyClassPtr keyc) {
- int i, j;
- CARD8 keysPerModifier[8];
- CARD8 mask;
-
- // darwinKeyc = keyc;
- if (keyc->modifierKeyMap != NULL)
- xfree (keyc->modifierKeyMap);
-
- keyc->maxKeysPerModifier = 0;
- for (i = 0; i < 8; i++)
- keysPerModifier[i] = 0;
- for (i = 8; i < MAP_LENGTH; i++)
- {
- for (j = 0, mask = 1; j < 8; j++, mask <<= 1)
- {
- if (mask & keyc->modifierMap[i])
- {
- if (++keysPerModifier[j] > keyc->maxKeysPerModifier)
- keyc->maxKeysPerModifier = keysPerModifier[j];
- }
- }
- }
- keyc->modifierKeyMap = (KeyCode *)xalloc(8*keyc->maxKeysPerModifier);
- if (!keyc->modifierKeyMap && keyc->maxKeysPerModifier)
- return (FALSE);
- bzero((char *)keyc->modifierKeyMap, 8*(int)keyc->maxKeysPerModifier);
- for (i = 0; i < 8; i++)
- keysPerModifier[i] = 0;
- for (i = 8; i < MAP_LENGTH; i++)
- {
- for (j = 0, mask = 1; j < 8; j++, mask <<= 1)
- {
- if (mask & keyc->modifierMap[i])
- {
- keyc->modifierKeyMap[(j*keyc->maxKeysPerModifier) +
- keysPerModifier[j]] = i;
- keysPerModifier[j]++;
- }
- }
- }
- return TRUE;
-}
-
-
-void DarwinKeyboardReloadHandler(int screenNum, xEventPtr xe, DeviceIntPtr dev, int nevents) {
- KeySymsRec keySyms;
- if (dev == NULL) dev = darwinKeyboard;
-
- DEBUG_LOG("DarwinKeyboardReloadHandler(%p)\n", dev);
- DarwinLoadKeyboardMapping(&keySyms);
-
- if (SetKeySymsMap(&dev->key->curKeySyms, &keySyms)) {
- /* now try to update modifiers. */
-
- memmove(dev->key->modifierMap, keyInfo.modMap, MAP_LENGTH);
- InitModMap(dev->key);
- } else DEBUG_LOG("SetKeySymsMap=0\n");
-
- SendMappingNotify(MappingKeyboard, MIN_KEYCODE, NUM_KEYCODES, 0);
- SendMappingNotify(MappingModifier, 0, 0, 0);
-}
-
-
-//-----------------------------------------------------------------------------
-// Modifier translation functions
-//
-// There are three different ways to specify a Mac modifier key:
-// keycode - specifies hardware key, read from keymapping
-// key - NX_MODIFIERKEY_*, really an index
-// mask - NX_*MASK, mask for modifier flags in event record
-// Left and right side have different keycodes but the same key and mask.
-//-----------------------------------------------------------------------------
-
-/*
- * DarwinModifierNXKeyToNXKeycode
- * Return the keycode for an NX_MODIFIERKEY_* modifier.
- * side = 0 for left or 1 for right.
- * Returns 0 if key+side is not a known modifier.
- */
-int DarwinModifierNXKeyToNXKeycode(int key, int side) {
- return keyInfo.modifierKeycodes[key][side];
-}
-
-/*
- * DarwinModifierNXKeycodeToNXKey
- * Returns -1 if keycode+side is not a modifier key
- * outSide may be NULL, else it gets 0 for left and 1 for right.
- */
-int DarwinModifierNXKeycodeToNXKey(unsigned char keycode, int *outSide) {
- int key, side;
-
- keycode += MIN_KEYCODE;
- // search modifierKeycodes for this keycode+side
- for (key = 0; key < NX_NUMMODIFIERS; key++) {
- for (side = 0; side <= 1; side++) {
- if (keyInfo.modifierKeycodes[key][side] == keycode) break;
- }
- }
- if (key == NX_NUMMODIFIERS) return -1;
- if (outSide) *outSide = side;
- return key;
-}
-
-/*
- * DarwinModifierNXMaskToNXKey
- * Returns -1 if mask is not a known modifier mask.
- */
-int DarwinModifierNXMaskToNXKey(int mask) {
- switch (mask) {
- case NX_ALPHASHIFTMASK: return NX_MODIFIERKEY_ALPHALOCK;
- case NX_SHIFTMASK: return NX_MODIFIERKEY_SHIFT;
-#ifdef NX_DEVICELSHIFTKEYMASK
- case NX_DEVICELSHIFTKEYMASK: return NX_MODIFIERKEY_SHIFT;
- case NX_DEVICERSHIFTKEYMASK: return NX_MODIFIERKEY_RSHIFT;
-#endif
- case NX_CONTROLMASK: return NX_MODIFIERKEY_CONTROL;
-#ifdef NX_DEVICELCTLKEYMASK
- case NX_DEVICELCTLKEYMASK: return NX_MODIFIERKEY_CONTROL;
- case NX_DEVICERCTLKEYMASK: return NX_MODIFIERKEY_RCONTROL;
-#endif
- case NX_ALTERNATEMASK: return NX_MODIFIERKEY_ALTERNATE;
-#ifdef NX_DEVICELALTKEYMASK
- case NX_DEVICELALTKEYMASK: return NX_MODIFIERKEY_ALTERNATE;
- case NX_DEVICERALTKEYMASK: return NX_MODIFIERKEY_RALTERNATE;
-#endif
- case NX_COMMANDMASK: return NX_MODIFIERKEY_COMMAND;
-#ifdef NX_DEVICELCMDKEYMASK
- case NX_DEVICELCMDKEYMASK: return NX_MODIFIERKEY_COMMAND;
- case NX_DEVICERCMDKEYMASK: return NX_MODIFIERKEY_RCOMMAND;
-#endif
- case NX_NUMERICPADMASK: return NX_MODIFIERKEY_NUMERICPAD;
- case NX_HELPMASK: return NX_MODIFIERKEY_HELP;
- case NX_SECONDARYFNMASK: return NX_MODIFIERKEY_SECONDARYFN;
- }
- return -1;
-}
-
-static const char *DarwinModifierNXMaskTostring(int mask) {
- switch (mask) {
- case NX_ALPHASHIFTMASK: return "NX_ALPHASHIFTMASK";
- case NX_SHIFTMASK: return "NX_SHIFTMASK";
- case NX_DEVICELSHIFTKEYMASK: return "NX_DEVICELSHIFTKEYMASK";
- case NX_DEVICERSHIFTKEYMASK: return "NX_DEVICERSHIFTKEYMASK";
- case NX_CONTROLMASK: return "NX_CONTROLMASK";
- case NX_DEVICELCTLKEYMASK: return "NX_DEVICELCTLKEYMASK";
- case NX_DEVICERCTLKEYMASK: return "NX_DEVICERCTLKEYMASK";
- case NX_ALTERNATEMASK: return "NX_ALTERNATEMASK";
- case NX_DEVICELALTKEYMASK: return "NX_DEVICELALTKEYMASK";
- case NX_DEVICERALTKEYMASK: return "NX_DEVICERALTKEYMASK";
- case NX_COMMANDMASK: return "NX_COMMANDMASK";
- case NX_DEVICELCMDKEYMASK: return "NX_DEVICELCMDKEYMASK";
- case NX_DEVICERCMDKEYMASK: return "NX_DEVICERCMDKEYMASK";
- case NX_NUMERICPADMASK: return "NX_NUMERICPADMASK";
- case NX_HELPMASK: return "NX_HELPMASK";
- case NX_SECONDARYFNMASK: return "NX_SECONDARYFNMASK";
- }
- return "unknown mask";
-}
-
-/*
- * DarwinModifierNXKeyToNXMask
- * Returns 0 if key is not a known modifier key.
- */
-int DarwinModifierNXKeyToNXMask(int key) {
- switch (key) {
- case NX_MODIFIERKEY_ALPHALOCK: return NX_ALPHASHIFTMASK;
- case NX_MODIFIERKEY_SHIFT: return NX_SHIFTMASK;
-#ifdef NX_MODIFIERKEY_RSHIFT
- case NX_MODIFIERKEY_RSHIFT: return NX_SHIFTMASK;
-#endif
- case NX_MODIFIERKEY_CONTROL: return NX_CONTROLMASK;
-#ifdef NX_MODIFIERKEY_RCONTROL
- case NX_MODIFIERKEY_RCONTROL: return NX_CONTROLMASK;
-#endif
- case NX_MODIFIERKEY_ALTERNATE: return NX_ALTERNATEMASK;
-#ifdef NX_MODIFIERKEY_RALTERNATE
- case NX_MODIFIERKEY_RALTERNATE: return NX_ALTERNATEMASK;
-#endif
- case NX_MODIFIERKEY_COMMAND: return NX_COMMANDMASK;
-#ifdef NX_MODIFIERKEY_RCOMMAND
- case NX_MODIFIERKEY_RCOMMAND: return NX_COMMANDMASK;
-#endif
- case NX_MODIFIERKEY_NUMERICPAD: return NX_NUMERICPADMASK;
- case NX_MODIFIERKEY_HELP: return NX_HELPMASK;
- case NX_MODIFIERKEY_SECONDARYFN: return NX_SECONDARYFNMASK;
- }
- return 0;
-}
-
-/*
- * DarwinModifierStringToNXKey
- * Returns -1 if string is not a known modifier.
- */
-int DarwinModifierStringToNXKey(const char *str) {
- if (!strcasecmp(str, "shift")) return NX_MODIFIERKEY_SHIFT;
- else if (!strcasecmp(str, "control")) return NX_MODIFIERKEY_CONTROL;
- else if (!strcasecmp(str, "option")) return NX_MODIFIERKEY_ALTERNATE;
- else if (!strcasecmp(str, "command")) return NX_MODIFIERKEY_COMMAND;
- else if (!strcasecmp(str, "fn")) return NX_MODIFIERKEY_SECONDARYFN;
- else return -1;
-}
-
-/*
- * LegalModifier
- * This allows the ddx layer to prevent some keys from being remapped
- * as modifier keys.
- */
-Bool LegalModifier(unsigned int key, DeviceIntPtr pDev)
-{
- return 1;
-}
diff --git a/hw/xquartz/pseudoramiX.c b/hw/xquartz/pseudoramiX.c
index 49d5eb6d4..aafaa26ef 100644
--- a/hw/xquartz/pseudoramiX.c
+++ b/hw/xquartz/pseudoramiX.c
@@ -37,6 +37,7 @@ Equipment Corporation.
#include <dix-config.h>
#endif
+#include "darwin.h"
#include "pseudoramiX.h"
#include "extnsionst.h"
#include "dixstruct.h"
@@ -99,6 +100,8 @@ PseudoramiXAddScreen(int x, int y, int w, int h)
sizeof(PseudoramiXScreenRec));
}
+ DEBUG_LOG("x: %d, y: %d, w: %d, h: %d\n", x, y, w, h);
+
s = &pseudoramiXScreens[pseudoramiXNumScreens++];
s->x = x;
s->y = y;
@@ -116,6 +119,8 @@ void PseudoramiXExtensionInit(int argc, char *argv[])
if (noPseudoramiXExtension) return;
+ TRACE();
+
/* Even with only one screen we need to enable PseudoramiX to allow
dynamic screen configuration changes. */
#if 0
@@ -153,12 +158,16 @@ void PseudoramiXExtensionInit(int argc, char *argv[])
void PseudoramiXResetScreens(void)
{
+ TRACE();
+
pseudoramiXNumScreens = 0;
}
static void PseudoramiXResetProc(ExtensionEntry *extEntry)
{
+ TRACE();
+
PseudoramiXResetScreens();
}
@@ -166,6 +175,8 @@ static void PseudoramiXResetProc(ExtensionEntry *extEntry)
// was PanoramiX
static int ProcPseudoramiXQueryVersion(ClientPtr client)
{
+ TRACE();
+
return ProcPanoramiXQueryVersion(client);
}
@@ -178,6 +189,8 @@ static int ProcPseudoramiXGetState(ClientPtr client)
xPanoramiXGetStateReply rep;
register int n, rc;
+ TRACE();
+
REQUEST_SIZE_MATCH(xPanoramiXGetStateReq);
rc = dixLookupWindow(&pWin, stuff->window, client, DixGetAttrAccess);
if (rc != Success)
@@ -205,6 +218,8 @@ static int ProcPseudoramiXGetScreenCount(ClientPtr client)
xPanoramiXGetScreenCountReply rep;
register int n, rc;
+ TRACE();
+
REQUEST_SIZE_MATCH(xPanoramiXGetScreenCountReq);
rc = dixLookupWindow(&pWin, stuff->window, client, DixGetAttrAccess);
if (rc != Success)
@@ -232,6 +247,8 @@ static int ProcPseudoramiXGetScreenSize(ClientPtr client)
xPanoramiXGetScreenSizeReply rep;
register int n, rc;
+ TRACE();
+
REQUEST_SIZE_MATCH(xPanoramiXGetScreenSizeReq);
rc = dixLookupWindow(&pWin, stuff->window, client, DixGetAttrAccess);
if (rc != Success)
@@ -262,6 +279,8 @@ static int ProcPseudoramiXIsActive(ClientPtr client)
/* REQUEST(xXineramaIsActiveReq); */
xXineramaIsActiveReply rep;
+ TRACE();
+
REQUEST_SIZE_MATCH(xXineramaIsActiveReq);
rep.type = X_Reply;
@@ -285,6 +304,8 @@ static int ProcPseudoramiXQueryScreens(ClientPtr client)
/* REQUEST(xXineramaQueryScreensReq); */
xXineramaQueryScreensReply rep;
+ DEBUG_LOG("noPseudoramiXExtension=%d, pseudoramiXNumScreens=%d\n", noPseudoramiXExtension, pseudoramiXNumScreens);
+
REQUEST_SIZE_MATCH(xXineramaQueryScreensReq);
rep.type = X_Reply;
@@ -327,6 +348,7 @@ static int ProcPseudoramiXQueryScreens(ClientPtr client)
// was PanoramiX
static int ProcPseudoramiXDispatch (ClientPtr client)
{ REQUEST(xReq);
+ TRACE();
switch (stuff->data)
{
case X_PanoramiXQueryVersion:
@@ -353,6 +375,8 @@ SProcPseudoramiXQueryVersion (ClientPtr client)
REQUEST(xPanoramiXQueryVersionReq);
register int n;
+ TRACE();
+
swaps(&stuff->length,n);
REQUEST_SIZE_MATCH (xPanoramiXQueryVersionReq);
return ProcPseudoramiXQueryVersion(client);
@@ -364,6 +388,8 @@ SProcPseudoramiXGetState(ClientPtr client)
REQUEST(xPanoramiXGetStateReq);
register int n;
+ TRACE();
+
swaps (&stuff->length, n);
REQUEST_SIZE_MATCH(xPanoramiXGetStateReq);
return ProcPseudoramiXGetState(client);
@@ -375,6 +401,8 @@ SProcPseudoramiXGetScreenCount(ClientPtr client)
REQUEST(xPanoramiXGetScreenCountReq);
register int n;
+ TRACE();
+
swaps (&stuff->length, n);
REQUEST_SIZE_MATCH(xPanoramiXGetScreenCountReq);
return ProcPseudoramiXGetScreenCount(client);
@@ -386,6 +414,8 @@ SProcPseudoramiXGetScreenSize(ClientPtr client)
REQUEST(xPanoramiXGetScreenSizeReq);
register int n;
+ TRACE();
+
swaps (&stuff->length, n);
REQUEST_SIZE_MATCH(xPanoramiXGetScreenSizeReq);
return ProcPseudoramiXGetScreenSize(client);
@@ -398,6 +428,8 @@ SProcPseudoramiXIsActive(ClientPtr client)
REQUEST(xXineramaIsActiveReq);
register int n;
+ TRACE();
+
swaps (&stuff->length, n);
REQUEST_SIZE_MATCH(xXineramaIsActiveReq);
return ProcPseudoramiXIsActive(client);
@@ -410,6 +442,8 @@ SProcPseudoramiXQueryScreens(ClientPtr client)
REQUEST(xXineramaQueryScreensReq);
register int n;
+ TRACE();
+
swaps (&stuff->length, n);
REQUEST_SIZE_MATCH(xXineramaQueryScreensReq);
return ProcPseudoramiXQueryScreens(client);
@@ -419,6 +453,9 @@ SProcPseudoramiXQueryScreens(ClientPtr client)
static int
SProcPseudoramiXDispatch (ClientPtr client)
{ REQUEST(xReq);
+
+ TRACE();
+
switch (stuff->data)
{
case X_PanoramiXQueryVersion:
diff --git a/hw/xquartz/quartz.c b/hw/xquartz/quartz.c
index 6a8cf7c12..0635b48b5 100644
--- a/hw/xquartz/quartz.c
+++ b/hw/xquartz/quartz.c
@@ -28,6 +28,8 @@
* use or other dealings in this Software without prior written authorization.
*/
+#include "sanitizedCarbon.h"
+
#ifdef HAVE_DIX_CONFIG_H
#include <dix-config.h>
#endif
@@ -37,7 +39,6 @@
#include "quartz.h"
#include "darwin.h"
#include "darwinEvents.h"
-#include "quartzAudio.h"
#include "pseudoramiX.h"
#define _APPLEWM_SERVER_
#include "applewmExt.h"
@@ -52,6 +53,7 @@
#include "windowstr.h"
#include "colormapst.h"
#include "globals.h"
+#include "mi.h"
// System headers
#include <sys/types.h>
@@ -153,10 +155,6 @@ void QuartzInitOutput(
int argc,
char **argv )
{
- if (serverGeneration == 0) {
- QuartzAudioInit();
- }
-
if (!RegisterBlockAndWakeupHandlers(QuartzBlockHandler,
QuartzWakeupHandler,
NULL))
@@ -241,7 +239,7 @@ void QuartzDisplayChangedHandler(int screenNum, xEventPtr xe, DeviceIntPtr dev,
int x, y, width, height, sx, sy;
xEvent e;
- DEBUG_LOG("QuartzDisplayChangedHandler()\n");
+ DEBUG_LOG("QuartzDisplayChangedHandler(): noPseudoramiXExtension=%d, screenInfo.numScreens=%d\n", noPseudoramiXExtension, screenInfo.numScreens);
if (noPseudoramiXExtension || screenInfo.numScreens != 1)
{
/* FIXME: if not using Xinerama, we have multiple screens, and
diff --git a/hw/xquartz/quartz.h b/hw/xquartz/quartz.h
index ffe06f9c6..1b6d71f20 100644
--- a/hw/xquartz/quartz.h
+++ b/hw/xquartz/quartz.h
@@ -128,7 +128,13 @@ Bool QuartzAddScreen(int index, ScreenPtr pScreen);
Bool QuartzSetupScreen(int index, ScreenPtr pScreen);
void QuartzInitOutput(int argc,char **argv);
void QuartzInitInput(int argc, char **argv);
+void QuartzInitServer(int argc, char **argv, char **envp);
void QuartzGiveUp(void);
void QuartzProcessEvent(xEvent *xe);
void QuartzDisplayChangedHandler(int screenNum, xEventPtr xe, DeviceIntPtr dev, int nevents);
+
+void QuartzShow(int x, int y); // (x, y) = cursor loc
+void QuartzHide(void);
+void QuartzSetRootClip(BOOL enable);
+void QuartzSpaceChanged(uint32_t space_id);
#endif
diff --git a/hw/xquartz/quartzAudio.c b/hw/xquartz/quartzAudio.c
index 5dee32f54..d3698d7c9 100644
--- a/hw/xquartz/quartzAudio.c
+++ b/hw/xquartz/quartzAudio.c
@@ -36,6 +36,8 @@
* use or other dealings in this Software without prior written authorization.
*/
+#include "sanitizedCarbon.h"
+
#ifdef HAVE_DIX_CONFIG_H
#include <dix-config.h>
#endif
diff --git a/hw/xquartz/quartzCocoa.m b/hw/xquartz/quartzCocoa.m
index d8f9c69e4..2890d34f1 100644
--- a/hw/xquartz/quartzCocoa.m
+++ b/hw/xquartz/quartzCocoa.m
@@ -32,6 +32,8 @@
* use or other dealings in this Software without prior written authorization.
*/
+#include "sanitizedCocoa.h"
+
#ifdef HAVE_DIX_CONFIG_H
#include <dix-config.h>
#endif
@@ -40,14 +42,8 @@
#include "inputstr.h"
#include "quartzPasteboard.h"
-#define BOOL xBOOL
#include "darwin.h"
-#include <Cocoa/Cocoa.h>
-#undef BOOL
-
-#include "pseudoramiX.h"
-
extern void FatalError(const char *, ...);
extern char *display;
extern int noPanoramiXExtension;
diff --git a/hw/xquartz/quartzCommon.h b/hw/xquartz/quartzCommon.h
index c4bd2d803..e63c2b760 100644
--- a/hw/xquartz/quartzCommon.h
+++ b/hw/xquartz/quartzCommon.h
@@ -35,17 +35,6 @@
#ifndef _QUARTZCOMMON_H
#define _QUARTZCOMMON_H
-// QuickDraw in ApplicationServices has the following conflicts with
-// the basic X server headers. Use QD_<name> to use the QuickDraw
-// definition of any of these symbols, or the normal name for the
-// X11 definition.
-#define Cursor QD_Cursor
-#define WindowPtr QD_WindowPtr
-#define Picture QD_Picture
-#include <ApplicationServices/ApplicationServices.h>
-#undef Cursor
-#undef WindowPtr
-#undef Picture
#include <X11/Xdefs.h>
#include "privates.h"
diff --git a/hw/xquartz/quartzKeyboard.c b/hw/xquartz/quartzKeyboard.c
index 9b899ca67..698f39a22 100644
--- a/hw/xquartz/quartzKeyboard.c
+++ b/hw/xquartz/quartzKeyboard.c
@@ -1,51 +1,77 @@
/*
- quartzKeyboard.c
-
- Code to build a keymap using the Carbon Keyboard Layout API.
-
- Copyright (c) 2003-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.
+ quartzKeyboard.c: Keyboard support for Xquartz
+
+ Copyright (c) 2003-2008 Apple Inc.
+ Copyright (c) 2001-2004 Torrey T. Lyons. All Rights Reserved.
+ Copyright 2004 Kaleb S. KEITHLEY. All Rights Reserved.
+
+ The code to parse the Darwin keymap is derived from dumpkeymap.c
+ by Eric Sunshine, which includes the following copyright:
+
+ Copyright (C) 1999,2000 by Eric Sunshine <sunshine@sunshineco.com>
+ All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+ 2. Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+ 3. The name of the author may not be used to endorse or promote products
+ derived from this software without specific prior written permission.
+
+ THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
+ NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+ TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+#include "sanitizedCarbon.h"
+
#ifdef HAVE_DIX_CONFIG_H
#include <dix-config.h>
#endif
-#include "quartzCommon.h"
+// Define this to get a diagnostic output to stderr which is helpful
+// in determining how the X server is interpreting the Darwin keymap.
+#define DUMP_DARWIN_KEYMAP
+#define XQUARTZ_USE_XKB
+#define HACK_MISSING 1
+#define HACK_KEYPAD 1
-#include <CoreServices/CoreServices.h>
-#include <Carbon/Carbon.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <errno.h>
+#include <sys/stat.h>
+
+#include "quartzCommon.h"
+#include "darwin.h"
#include "quartzKeyboard.h"
+#include "quartzAudio.h"
+
+#ifdef NDEBUG
+#undef NDEBUG
+#include <assert.h>
+#define NDEBUG 1
+#else
+#include <assert.h>
+#endif
+
+#include "xkbsrv.h"
+#include "exevents.h"
#include "X11/keysym.h"
#include "keysym2ucs.h"
-#define HACK_MISSING 1
-#define HACK_KEYPAD 1
+void QuartzXkbUpdate(DeviceIntPtr pDev);
enum {
MOD_COMMAND = 256,
@@ -56,6 +82,143 @@ enum {
#define UKEYSYM(u) ((u) | 0x01000000)
+#define AltMask Mod1Mask
+#define MetaMask Mod2Mask
+#define FunctionMask Mod3Mask
+
+#define UK(a) NoSymbol // unknown symbol
+
+static KeySym const next_to_x[256] = {
+ NoSymbol, NoSymbol, NoSymbol, XK_KP_Enter,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ XK_BackSpace, XK_Tab, XK_Linefeed, NoSymbol,
+ NoSymbol, XK_Return, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, XK_Escape,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ XK_space, XK_exclam, XK_quotedbl, XK_numbersign,
+ XK_dollar, XK_percent, XK_ampersand, XK_apostrophe,
+ XK_parenleft, XK_parenright, XK_asterisk, XK_plus,
+ XK_comma, XK_minus, XK_period, XK_slash,
+ XK_0, XK_1, XK_2, XK_3,
+ XK_4, XK_5, XK_6, XK_7,
+ XK_8, XK_9, XK_colon, XK_semicolon,
+ XK_less, XK_equal, XK_greater, XK_question,
+ XK_at, XK_A, XK_B, XK_C,
+ XK_D, XK_E, XK_F, XK_G,
+ XK_H, XK_I, XK_J, XK_K,
+ XK_L, XK_M, XK_N, XK_O,
+ XK_P, XK_Q, XK_R, XK_S,
+ XK_T, XK_U, XK_V, XK_W,
+ XK_X, XK_Y, XK_Z, XK_bracketleft,
+ XK_backslash, XK_bracketright,XK_asciicircum, XK_underscore,
+ XK_grave, XK_a, XK_b, XK_c,
+ XK_d, XK_e, XK_f, XK_g,
+ XK_h, XK_i, XK_j, XK_k,
+ XK_l, XK_m, XK_n, XK_o,
+ XK_p, XK_q, XK_r, XK_s,
+ XK_t, XK_u, XK_v, XK_w,
+ XK_x, XK_y, XK_z, XK_braceleft,
+ XK_bar, XK_braceright, XK_asciitilde, XK_BackSpace,
+// 128
+ NoSymbol, XK_Agrave, XK_Aacute, XK_Acircumflex,
+ XK_Atilde, XK_Adiaeresis, XK_Aring, XK_Ccedilla,
+ XK_Egrave, XK_Eacute, XK_Ecircumflex, XK_Ediaeresis,
+ XK_Igrave, XK_Iacute, XK_Icircumflex, XK_Idiaeresis,
+// 144
+ XK_ETH, XK_Ntilde, XK_Ograve, XK_Oacute,
+ XK_Ocircumflex, XK_Otilde, XK_Odiaeresis, XK_Ugrave,
+ XK_Uacute, XK_Ucircumflex, XK_Udiaeresis, XK_Yacute,
+ XK_THORN, XK_mu, XK_multiply, XK_division,
+// 160
+ XK_copyright, XK_exclamdown, XK_cent, XK_sterling,
+ UK(fraction), XK_yen, UK(fhook), XK_section,
+ XK_currency, XK_rightsinglequotemark,
+ XK_leftdoublequotemark,
+ XK_guillemotleft,
+ XK_leftanglebracket,
+ XK_rightanglebracket,
+ UK(filigature), UK(flligature),
+// 176
+ XK_registered, XK_endash, XK_dagger, XK_doubledagger,
+ XK_periodcentered,XK_brokenbar, XK_paragraph, UK(bullet),
+ XK_singlelowquotemark,
+ XK_doublelowquotemark,
+ XK_rightdoublequotemark,
+ XK_guillemotright,
+ XK_ellipsis, UK(permille), XK_notsign, XK_questiondown,
+// 192
+ XK_onesuperior, XK_dead_grave, XK_dead_acute, XK_dead_circumflex,
+ XK_dead_tilde, XK_dead_macron, XK_dead_breve, XK_dead_abovedot,
+ XK_dead_diaeresis,
+ XK_twosuperior, XK_dead_abovering,
+ XK_dead_cedilla,
+ XK_threesuperior,
+ XK_dead_doubleacute,
+ XK_dead_ogonek, XK_dead_caron,
+// 208
+ XK_emdash, XK_plusminus, XK_onequarter, XK_onehalf,
+ XK_threequarters,
+ XK_agrave, XK_aacute, XK_acircumflex,
+ XK_atilde, XK_adiaeresis, XK_aring, XK_ccedilla,
+ XK_egrave, XK_eacute, XK_ecircumflex, XK_ediaeresis,
+// 224
+ XK_igrave, XK_AE, XK_iacute, XK_ordfeminine,
+ XK_icircumflex, XK_idiaeresis, XK_eth, XK_ntilde,
+ XK_Lstroke, XK_Ooblique, XK_OE, XK_masculine,
+ XK_ograve, XK_oacute, XK_ocircumflex, XK_otilde,
+// 240
+ XK_odiaeresis, XK_ae, XK_ugrave, XK_uacute,
+ XK_ucircumflex, XK_idotless, XK_udiaeresis, XK_ygrave,
+ XK_lstroke, XK_ooblique, XK_oe, XK_ssharp,
+ XK_thorn, XK_ydiaeresis, NoSymbol, NoSymbol,
+ };
+
+#define MIN_SYMBOL 0xAC
+static KeySym const symbol_to_x[] = {
+ XK_Left, XK_Up, XK_Right, XK_Down
+ };
+static int const NUM_SYMBOL = sizeof(symbol_to_x) / sizeof(symbol_to_x[0]);
+
+#define MIN_FUNCKEY 0x20
+static KeySym const funckey_to_x[] = {
+ XK_F1, XK_F2, XK_F3, XK_F4,
+ XK_F5, XK_F6, XK_F7, XK_F8,
+ XK_F9, XK_F10, XK_F11, XK_F12,
+ XK_Insert, XK_Delete, XK_Home, XK_End,
+ XK_Page_Up, XK_Page_Down, XK_F13, XK_F14,
+ XK_F15
+ };
+static int const NUM_FUNCKEY = sizeof(funckey_to_x) / sizeof(funckey_to_x[0]);
+
+typedef struct {
+ KeySym normalSym;
+ KeySym keypadSym;
+} darwinKeyPad_t;
+
+static darwinKeyPad_t const normal_to_keypad[] = {
+ { XK_0, XK_KP_0 },
+ { XK_1, XK_KP_1 },
+ { XK_2, XK_KP_2 },
+ { XK_3, XK_KP_3 },
+ { XK_4, XK_KP_4 },
+ { XK_5, XK_KP_5 },
+ { XK_6, XK_KP_6 },
+ { XK_7, XK_KP_7 },
+ { XK_8, XK_KP_8 },
+ { XK_9, XK_KP_9 },
+ { XK_equal, XK_KP_Equal },
+ { XK_asterisk, XK_KP_Multiply },
+ { XK_plus, XK_KP_Add },
+ { XK_comma, XK_KP_Separator },
+ { XK_minus, XK_KP_Subtract },
+ { XK_period, XK_KP_Decimal },
+ { XK_slash, XK_KP_Divide }
+};
+
+static int const NUM_KEYPAD = sizeof(normal_to_keypad) / sizeof(normal_to_keypad[0]);
+
/* Table of keycode->keysym mappings we use to fallback on for important
keys that are often not in the Unicode mapping. */
@@ -146,6 +309,783 @@ const static struct {
{UKEYSYM (0x31b), XK_dead_horn}, /* COMBINING HORN */
};
+darwinKeyboardInfo keyInfo;
+static FILE *fref = NULL;
+static char *inBuffer = NULL;
+
+static void DarwinChangeKeyboardControl( DeviceIntPtr device, KeybdCtrl *ctrl )
+{
+ // FIXME: to be implemented
+ // keyclick, bell volume / pitch, autorepead, LED's
+}
+
+//-----------------------------------------------------------------------------
+// Data Stream Object
+// Can be configured to treat embedded "numbers" as being composed of
+// either 1, 2, or 4 bytes, apiece.
+//-----------------------------------------------------------------------------
+typedef struct _DataStream {
+ unsigned char const *data;
+ unsigned char const *data_end;
+ short number_size; // Size in bytes of a "number" in the stream.
+} DataStream;
+
+static DataStream* new_data_stream(unsigned char const* data, int size) {
+ DataStream* s = (DataStream*)xalloc( sizeof(DataStream) );
+ if(s) {
+ s->data = data;
+ s->data_end = data + size;
+ s->number_size = 1; // Default to byte-sized numbers.
+ }
+ return s;
+}
+
+static void destroy_data_stream(DataStream* s) {
+ xfree(s);
+}
+
+static unsigned char get_byte(DataStream* s) {
+ assert(s->data + 1 <= s->data_end);
+ return *s->data++;
+}
+
+static short get_word(DataStream* s) {
+ short hi, lo;
+ assert(s->data + 2 <= s->data_end);
+ hi = *s->data++;
+ lo = *s->data++;
+ return ((hi << 8) | lo);
+}
+
+static int get_dword(DataStream* s) {
+ int b1, b2, b3, b4;
+ assert(s->data + 4 <= s->data_end);
+ b4 = *s->data++;
+ b3 = *s->data++;
+ b2 = *s->data++;
+ b1 = *s->data++;
+ return ((b4 << 24) | (b3 << 16) | (b2 << 8) | b1);
+}
+
+static int get_number(DataStream* s) {
+ switch (s->number_size) {
+ case 4: return get_dword(s);
+ case 2: return get_word(s);
+ default: return get_byte(s);
+ }
+}
+
+//-----------------------------------------------------------------------------
+// Utility functions to help parse Darwin keymap
+//-----------------------------------------------------------------------------
+
+/*
+ * bits_set
+ * Calculate number of bits set in the modifier mask.
+ */
+static short bits_set(short mask) {
+ short n = 0;
+
+ for ( ; mask != 0; mask >>= 1)
+ if ((mask & 0x01) != 0)
+ n++;
+ return n;
+}
+
+/*
+ * parse_next_char_code
+ * Read the next character code from the Darwin keymapping
+ * and write it to the X keymap.
+ */
+static void parse_next_char_code(DataStream *s, KeySym *k) {
+ const short charSet = get_number(s);
+ const short charCode = get_number(s);
+
+ if (charSet == 0) { // ascii character
+ if (charCode >= 0 && charCode < 256)
+ *k = next_to_x[charCode];
+ } else if (charSet == 0x01) { // symbol character
+ if (charCode >= MIN_SYMBOL &&
+ charCode <= MIN_SYMBOL + NUM_SYMBOL)
+ *k = symbol_to_x[charCode - MIN_SYMBOL];
+ } else if (charSet == 0xFE) { // function key
+ if (charCode >= MIN_FUNCKEY &&
+ charCode <= MIN_FUNCKEY + NUM_FUNCKEY)
+ *k = funckey_to_x[charCode - MIN_FUNCKEY];
+ }
+}
+
+
+/*
+ * DarwinReadKeymapFile
+ * Read the appropriate keymapping from a keymapping file.
+ */
+static Bool DarwinReadKeymapFile(NXKeyMapping *keyMap) {
+ struct stat st;
+ NXEventSystemDevice info[20];
+ int interface = 0, handler_id = 0;
+ int map_interface, map_handler_id, map_size = 0;
+ unsigned int i, size;
+ int *bufferEnd;
+ union km_tag {
+ int *intP;
+ char *charP;
+ } km;
+
+ fref = fopen( darwinKeymapFile, "rb" );
+ if (fref == NULL) {
+ ErrorF("Unable to open keymapping file '%s': %s.\n",
+ darwinKeymapFile, strerror(errno));
+ return FALSE;
+ }
+ if (fstat(fileno(fref), &st) == -1) {
+ ErrorF("Could not stat keymapping file '%s': %s.\n",
+ darwinKeymapFile, strerror(errno));
+ return FALSE;
+ }
+
+ // check to make sure we don't crash later
+ if (st.st_size <= 16*sizeof(int)) {
+ ErrorF("Keymapping file '%s' is invalid (too small).\n",
+ darwinKeymapFile);
+ return FALSE;
+ }
+
+ inBuffer = (char*) xalloc( st.st_size );
+ bufferEnd = (int *) (inBuffer + st.st_size);
+ if (fread(inBuffer, st.st_size, 1, fref) != 1) {
+ ErrorF("Could not read %qd bytes from keymapping file '%s': %s.\n",
+ st.st_size, darwinKeymapFile, strerror(errno));
+ return FALSE;
+ }
+
+ if (strncmp( inBuffer, "KYM1", 4 ) == 0) {
+ // Magic number OK.
+ } else if (strncmp( inBuffer, "KYMP", 4 ) == 0) {
+ ErrorF("Keymapping file '%s' is intended for use with the original NeXT keyboards and cannot be used by XDarwin.\n", darwinKeymapFile);
+ return FALSE;
+ } else {
+ ErrorF("Keymapping file '%s' has a bad magic number and cannot be used by XDarwin.\n", darwinKeymapFile);
+ return FALSE;
+ }
+
+ // find the keyboard interface and handler id
+ size = sizeof( info ) / sizeof( int );
+ if (!NXEventSystemInfo( darwinParamConnect, NX_EVS_DEVICE_INFO,
+ (NXEventSystemInfoType) info, &size )) {
+ ErrorF("Error reading event status driver info.\n");
+ return FALSE;
+ }
+
+ size = size * sizeof( int ) / sizeof( info[0] );
+ for( i = 0; i < size; i++) {
+ if (info[i].dev_type == NX_EVS_DEVICE_TYPE_KEYBOARD) {
+ Bool hasInterface = FALSE;
+ Bool hasMatch = FALSE;
+
+ interface = info[i].interface;
+ handler_id = info[i].id;
+
+ // Find an appropriate keymapping:
+ // The first time we try to match both interface and handler_id.
+ // If we can't match both, we take the first match for interface.
+
+ do {
+ km.charP = inBuffer;
+ km.intP++;
+ while (km.intP+3 < bufferEnd) {
+ map_interface = NXSwapBigIntToHost(*(km.intP++));
+ map_handler_id = NXSwapBigIntToHost(*(km.intP++));
+ map_size = NXSwapBigIntToHost(*(km.intP++));
+ if (map_interface == interface) {
+ if (map_handler_id == handler_id || hasInterface) {
+ hasMatch = TRUE;
+ break;
+ } else {
+ hasInterface = TRUE;
+ }
+ }
+ km.charP += map_size;
+ }
+ } while (hasInterface && !hasMatch);
+
+ if (hasMatch) {
+ // fill in NXKeyMapping structure
+ keyMap->size = map_size;
+ keyMap->mapping = (char*) xalloc(map_size);
+ memcpy(keyMap->mapping, km.charP, map_size);
+ return TRUE;
+ }
+ } // if dev_id == keyboard device
+ } // foreach info struct
+
+ // The keymapping file didn't match any of the info structs
+ // returned by NXEventSystemInfo.
+ ErrorF("Keymapping file '%s' did not contain appropriate keyboard interface.\n", darwinKeymapFile);
+ return FALSE;
+}
+
+
+/*
+ * DarwinParseNXKeyMapping
+ */
+static Bool DarwinParseNXKeyMapping(darwinKeyboardInfo *info) {
+ KeySym *k;
+ int i;
+ short numMods, numKeys, numPadKeys = 0;
+ Bool haveKeymap = FALSE;
+ NXKeyMapping keyMap;
+ DataStream *keyMapStream;
+ unsigned char const *numPadStart = 0;
+
+ if (darwinKeymapFile) {
+ haveKeymap = DarwinReadKeymapFile(&keyMap);
+ if (fref)
+ fclose(fref);
+ if (inBuffer)
+ xfree(inBuffer);
+ if (!haveKeymap) {
+ ErrorF("Reverting to kernel keymapping.\n");
+ }
+ }
+
+ if (!haveKeymap) {
+ // get the Darwin keyboard map
+ keyMap.size = NXKeyMappingLength( darwinParamConnect );
+ keyMap.mapping = (char*) xalloc( keyMap.size );
+ if (!NXGetKeyMapping( darwinParamConnect, &keyMap )) {
+ return FALSE;
+ }
+ }
+
+ keyMapStream = new_data_stream( (unsigned char const*)keyMap.mapping,
+ keyMap.size );
+
+ // check the type of map
+ if (get_word(keyMapStream)) {
+ keyMapStream->number_size = 2;
+ ErrorF("Current 16-bit keymapping may not be interpreted correctly.\n");
+ }
+
+ // Insert X modifier KeySyms into the keyboard map.
+ numMods = get_number(keyMapStream);
+ while (numMods-- > 0) {
+ int left = 1; // first keycode is left
+ short const charCode = get_number(keyMapStream);
+ short numKeyCodes = get_number(keyMapStream);
+
+ // This is just a marker, not a real modifier.
+ // Store numeric keypad keys for later.
+ if (charCode == NX_MODIFIERKEY_NUMERICPAD) {
+ numPadStart = keyMapStream->data;
+ numPadKeys = numKeyCodes;
+ }
+
+ while (numKeyCodes-- > 0) {
+ const short keyCode = get_number(keyMapStream);
+ if (charCode != NX_MODIFIERKEY_NUMERICPAD) {
+ switch (charCode) {
+ case NX_MODIFIERKEY_ALPHALOCK:
+ info->keyMap[keyCode * GLYPHS_PER_KEY] = XK_Caps_Lock;
+ break;
+ case NX_MODIFIERKEY_SHIFT:
+ info->keyMap[keyCode * GLYPHS_PER_KEY] =
+ (left ? XK_Shift_L : XK_Shift_R);
+ break;
+ case NX_MODIFIERKEY_CONTROL:
+ info->keyMap[keyCode * GLYPHS_PER_KEY] =
+ (left ? XK_Control_L : XK_Control_R);
+ break;
+ case NX_MODIFIERKEY_ALTERNATE:
+ // info->keyMap[keyCode * GLYPHS_PER_KEY] = XK_Mode_switch;
+ info->keyMap[keyCode * GLYPHS_PER_KEY] =
+ (left ? XK_Alt_L : XK_Alt_R);
+ break;
+ case NX_MODIFIERKEY_COMMAND:
+ info->keyMap[keyCode * GLYPHS_PER_KEY] =
+ (left ? XK_Meta_L : XK_Meta_R);
+ break;
+ case NX_MODIFIERKEY_SECONDARYFN:
+ info->keyMap[keyCode * GLYPHS_PER_KEY] =
+ (left ? XK_Control_L : XK_Control_R);
+ break;
+ case NX_MODIFIERKEY_HELP:
+ // Help is not an X11 modifier; treat as normal key
+ info->keyMap[keyCode * GLYPHS_PER_KEY] = XK_Help;
+ break;
+ }
+ }
+ left = 0;
+ }
+ }
+
+ // Convert the Darwin keyboard mapping to an X keyboard map.
+ // A key can have a different character code for each combination of
+ // modifiers. We currently ignore all modifier combinations except
+ // those with Shift, AlphaLock, and Alt.
+ numKeys = get_number(keyMapStream);
+ for (i = 0, k = info->keyMap; i < numKeys; i++, k += GLYPHS_PER_KEY) {
+ short const charGenMask = get_number(keyMapStream);
+ if (charGenMask != 0xFF) { // is key bound?
+ short numKeyCodes = 1 << bits_set(charGenMask);
+
+ // Record unmodified case
+ parse_next_char_code( keyMapStream, k );
+ numKeyCodes--;
+
+ // If AlphaLock and Shift modifiers produce different codes,
+ // we record the Shift case since X handles AlphaLock.
+ if (charGenMask & 0x01) { // AlphaLock
+ parse_next_char_code( keyMapStream, k+1 );
+ numKeyCodes--;
+ }
+
+ if (charGenMask & 0x02) { // Shift
+ parse_next_char_code( keyMapStream, k+1 );
+ numKeyCodes--;
+
+ if (charGenMask & 0x01) { // Shift-AlphaLock
+ get_number(keyMapStream); get_number(keyMapStream);
+ numKeyCodes--;
+ }
+ }
+
+ // Skip the Control cases
+ if (charGenMask & 0x04) { // Control
+ get_number(keyMapStream); get_number(keyMapStream);
+ numKeyCodes--;
+
+ if (charGenMask & 0x01) { // Control-AlphaLock
+ get_number(keyMapStream); get_number(keyMapStream);
+ numKeyCodes--;
+ }
+
+ if (charGenMask & 0x02) { // Control-Shift
+ get_number(keyMapStream); get_number(keyMapStream);
+ numKeyCodes--;
+
+ if (charGenMask & 0x01) { // Shift-Control-AlphaLock
+ get_number(keyMapStream); get_number(keyMapStream);
+ numKeyCodes--;
+ }
+ }
+ }
+
+ // Process Alt cases
+ if (charGenMask & 0x08) { // Alt
+ parse_next_char_code( keyMapStream, k+2 );
+ numKeyCodes--;
+
+ if (charGenMask & 0x01) { // Alt-AlphaLock
+ parse_next_char_code( keyMapStream, k+3 );
+ numKeyCodes--;
+ }
+
+ if (charGenMask & 0x02) { // Alt-Shift
+ parse_next_char_code( keyMapStream, k+3 );
+ numKeyCodes--;
+
+ if (charGenMask & 0x01) { // Alt-Shift-AlphaLock
+ get_number(keyMapStream); get_number(keyMapStream);
+ numKeyCodes--;
+ }
+ }
+ }
+
+ while (numKeyCodes-- > 0) {
+ get_number(keyMapStream); get_number(keyMapStream);
+ }
+
+ if (k[3] == k[2]) k[3] = NoSymbol;
+ if (k[2] == k[1]) k[2] = NoSymbol;
+ if (k[1] == k[0]) k[1] = NoSymbol;
+ if (k[0] == k[2] && k[1] == k[3]) k[2] = k[3] = NoSymbol;
+ }
+ }
+
+ // Now we have to go back through the list of keycodes that are on the
+ // numeric keypad and update the X keymap.
+ keyMapStream->data = numPadStart;
+ while(numPadKeys-- > 0) {
+ const short keyCode = get_number(keyMapStream);
+ k = &info->keyMap[keyCode * GLYPHS_PER_KEY];
+ for (i = 0; i < NUM_KEYPAD; i++) {
+ if (*k == normal_to_keypad[i].normalSym) {
+ k[0] = normal_to_keypad[i].keypadSym;
+ break;
+ }
+ }
+ }
+
+ // free Darwin keyboard map
+ destroy_data_stream( keyMapStream );
+ xfree( keyMap.mapping );
+
+ return TRUE;
+}
+
+/*
+ * DarwinBuildModifierMaps
+ * Use the keyMap field of keyboard info structure to populate
+ * the modMap and modifierKeycodes fields.
+ */
+static void DarwinBuildModifierMaps(darwinKeyboardInfo *info) {
+ int i;
+ KeySym *k;
+
+ memset(info->modMap, NoSymbol, sizeof(info->modMap));
+ memset(info->modifierKeycodes, 0, sizeof(info->modifierKeycodes));
+
+ for (i = 0; i < NUM_KEYCODES; i++) {
+ k = info->keyMap + i * GLYPHS_PER_KEY;
+
+ switch (*k) {
+ case XK_Shift_L:
+ info->modifierKeycodes[NX_MODIFIERKEY_SHIFT][0] = i;
+ info->modMap[MIN_KEYCODE + i] = ShiftMask;
+ break;
+
+ case XK_Shift_R:
+#ifdef NX_MODIFIERKEY_RSHIFT
+ info->modifierKeycodes[NX_MODIFIERKEY_RSHIFT][0] = i;
+#else
+ info->modifierKeycodes[NX_MODIFIERKEY_SHIFT][0] = i;
+#endif
+ info->modMap[MIN_KEYCODE + i] = ShiftMask;
+ break;
+
+ case XK_Control_L:
+ info->modifierKeycodes[NX_MODIFIERKEY_CONTROL][0] = i;
+ info->modMap[MIN_KEYCODE + i] = ControlMask;
+ break;
+
+ case XK_Control_R:
+#ifdef NX_MODIFIERKEY_RCONTROL
+ info->modifierKeycodes[NX_MODIFIERKEY_RCONTROL][0] = i;
+#else
+ info->modifierKeycodes[NX_MODIFIERKEY_CONTROL][0] = i;
+#endif
+ info->modMap[MIN_KEYCODE + i] = ControlMask;
+ break;
+
+ case XK_Caps_Lock:
+ info->modifierKeycodes[NX_MODIFIERKEY_ALPHALOCK][0] = i;
+ info->modMap[MIN_KEYCODE + i] = LockMask;
+ break;
+
+ case XK_Alt_L:
+ info->modifierKeycodes[NX_MODIFIERKEY_ALTERNATE][0] = i;
+ info->modMap[MIN_KEYCODE + i] = Mod1Mask;
+ *k = XK_Mode_switch; // Yes, this is ugly. This needs to be cleaned up when we integrate quartzKeyboard with this code and refactor.
+ break;
+
+ case XK_Alt_R:
+#ifdef NX_MODIFIERKEY_RALTERNATE
+ info->modifierKeycodes[NX_MODIFIERKEY_RALTERNATE][0] = i;
+#else
+ info->modifierKeycodes[NX_MODIFIERKEY_ALTERNATE][0] = i;
+#endif
+ *k = XK_Mode_switch; // Yes, this is ugly. This needs to be cleaned up when we integrate quartzKeyboard with this code and refactor.
+ info->modMap[MIN_KEYCODE + i] = Mod1Mask;
+ break;
+
+ case XK_Mode_switch:
+ info->modMap[MIN_KEYCODE + i] = Mod1Mask;
+ break;
+
+ case XK_Meta_L:
+ info->modifierKeycodes[NX_MODIFIERKEY_COMMAND][0] = i;
+ info->modMap[MIN_KEYCODE + i] = Mod2Mask;
+ break;
+
+ case XK_Meta_R:
+#ifdef NX_MODIFIERKEY_RCOMMAND
+ info->modifierKeycodes[NX_MODIFIERKEY_RCOMMAND][0] = i;
+#else
+ info->modifierKeycodes[NX_MODIFIERKEY_COMMAND][0] = i;
+#endif
+ info->modMap[MIN_KEYCODE + i] = Mod2Mask;
+ break;
+
+ case XK_Num_Lock:
+ info->modMap[MIN_KEYCODE + i] = Mod3Mask;
+ break;
+ }
+ }
+}
+
+/*
+ * DarwinLoadKeyboardMapping
+ * Load the keyboard map from a file or system and convert
+ * it to an equivalent X keyboard map and modifier map.
+ */
+static void DarwinLoadKeyboardMapping(KeySymsRec *keySyms) {
+ memset(keyInfo.keyMap, 0, sizeof(keyInfo.keyMap));
+
+ /* TODO: Clean this up
+ * QuartzReadSystemKeymap is in quartz/quartzKeyboard.c
+ * DarwinParseNXKeyMapping is here
+ */
+ if (!DarwinParseNXKeyMapping(&keyInfo)) {
+ DEBUG_LOG("DarwinParseNXKeyMapping returned 0... running QuartzReadSystemKeymap().\n");
+ if (!QuartzReadSystemKeymap(&keyInfo)) {
+ FatalError("Could not build a valid keymap.");
+ }
+ }
+
+ DarwinBuildModifierMaps(&keyInfo);
+
+#ifdef DUMP_DARWIN_KEYMAP
+ int i;
+ KeySym *k;
+ DEBUG_LOG("Darwin -> X converted keyboard map\n");
+ for (i = 0, k = keyInfo.keyMap; i < NX_NUMKEYCODES;
+ i++, k += GLYPHS_PER_KEY)
+ {
+ int j;
+ for (j = 0; j < GLYPHS_PER_KEY; j++) {
+ if (k[j] == NoSymbol) {
+ DEBUG_LOG("0x%02x:\tNoSym\n", i);
+ } else {
+ DEBUG_LOG("0x%02x:\t0x%lx\n", i, k[j]);
+ }
+ }
+ }
+#endif
+
+ keySyms->map = keyInfo.keyMap;
+ keySyms->mapWidth = GLYPHS_PER_KEY;
+ keySyms->minKeyCode = MIN_KEYCODE;
+ keySyms->maxKeyCode = MAX_KEYCODE;
+}
+
+void QuartzXkbUpdate(DeviceIntPtr pDev) {
+#ifdef XQUARTZ_USE_XKB
+ SendDeviceMappingNotify(serverClient, MappingKeyboard,
+ pDev->key->curKeySyms.minKeyCode,
+ pDev->key->curKeySyms.maxKeyCode - pDev->key->curKeySyms.minKeyCode, pDev);
+ SendDeviceMappingNotify(serverClient, MappingModifier, 0, 0, pDev);
+ SwitchCoreKeyboard(pDev);
+#endif
+}
+
+/*
+ * DarwinKeyboardInit
+ * Get the Darwin keyboard map and compute an equivalent
+ * X keyboard map and modifier map. Set the new keyboard
+ * device structure.
+ */
+void DarwinKeyboardInit(DeviceIntPtr pDev) {
+ KeySymsRec keySyms;
+
+ // Open a shared connection to the HID System.
+ // Note that the Event Status Driver is really just a wrapper
+ // for a kIOHIDParamConnectType connection.
+ assert( darwinParamConnect = NXOpenEventStatus() );
+
+ DarwinLoadKeyboardMapping(&keySyms);
+ /* Initialize the seed, so we don't reload the keymap unnecessarily
+ (and possibly overwrite xinitrc changes) */
+ QuartzSystemKeymapSeed();
+
+#ifdef XQUARTZ_USE_XKB
+ XkbComponentNamesRec names;
+ bzero(&names, sizeof(names));
+ XkbSetRulesDflts("base", "pc105", "us", NULL, NULL);
+ assert(XkbInitKeyboardDeviceStruct(pDev, &names, &keySyms, keyInfo.modMap,
+ QuartzBell, DarwinChangeKeyboardControl));
+ assert(SetKeySymsMap(&pDev->key->curKeySyms, &keySyms));
+ assert(keyInfo.modMap!=NULL);
+ assert(pDev->key->modifierMap!=NULL);
+ memcpy(pDev->key->modifierMap, keyInfo.modMap, sizeof(keyInfo.modMap));
+
+ QuartzXkbUpdate(pDev);
+#else
+#error FAIL
+ assert( InitKeyboardDeviceStruct( (DevicePtr)pDev, &keySyms,
+ keyInfo.modMap, QuartzBell,
+ DarwinChangeKeyboardControl ));
+ SwitchCoreKeyboard(pDev);
+#endif
+}
+
+
+void DarwinKeyboardReloadHandler(int screenNum, xEventPtr xe, DeviceIntPtr pDev, int nevents) {
+ if (pDev == NULL) pDev = darwinKeyboard;
+
+ DEBUG_LOG("DarwinKeyboardReloadHandler(%p)\n", pDev);
+
+#ifdef XQUARTZ_USE_XKB
+ QuartzXkbUpdate(pDev);
+#else
+#error FAIL
+ if (pDev->key) {
+ if (pDev->key->curKeySyms.map) xfree(pDev->key->curKeySyms.map);
+ if (pDev->key->modifierKeyMap) xfree(pDev->key->modifierKeyMap);
+ xfree(pDev->key);
+ }
+
+ KeySymsRec keySyms;
+ if (!InitKeyClassDeviceStruct(pDev, &keySyms, keyInfo.modMap)) {
+ DEBUG_LOG("InitKeyClassDeviceStruct failed\n");
+ return;
+ }
+
+ SendMappingNotify(MappingKeyboard, MIN_KEYCODE, NUM_KEYCODES, 0);
+ SendMappingNotify(MappingModifier, 0, 0, 0);
+#endif
+}
+
+
+//-----------------------------------------------------------------------------
+// Modifier translation functions
+//
+// There are three different ways to specify a Mac modifier key:
+// keycode - specifies hardware key, read from keymapping
+// key - NX_MODIFIERKEY_*, really an index
+// mask - NX_*MASK, mask for modifier flags in event record
+// Left and right side have different keycodes but the same key and mask.
+//-----------------------------------------------------------------------------
+
+/*
+ * DarwinModifierNXKeyToNXKeycode
+ * Return the keycode for an NX_MODIFIERKEY_* modifier.
+ * side = 0 for left or 1 for right.
+ * Returns 0 if key+side is not a known modifier.
+ */
+int DarwinModifierNXKeyToNXKeycode(int key, int side) {
+ return keyInfo.modifierKeycodes[key][side];
+}
+
+/*
+ * DarwinModifierNXKeycodeToNXKey
+ * Returns -1 if keycode+side is not a modifier key
+ * outSide may be NULL, else it gets 0 for left and 1 for right.
+ */
+int DarwinModifierNXKeycodeToNXKey(unsigned char keycode, int *outSide) {
+ int key, side;
+
+ keycode += MIN_KEYCODE;
+ // search modifierKeycodes for this keycode+side
+ for (key = 0; key < NX_NUMMODIFIERS; key++) {
+ for (side = 0; side <= 1; side++) {
+ if (keyInfo.modifierKeycodes[key][side] == keycode) break;
+ }
+ }
+ if (key == NX_NUMMODIFIERS) return -1;
+ if (outSide) *outSide = side;
+ return key;
+}
+
+/*
+ * DarwinModifierNXMaskToNXKey
+ * Returns -1 if mask is not a known modifier mask.
+ */
+int DarwinModifierNXMaskToNXKey(int mask) {
+ switch (mask) {
+ case NX_ALPHASHIFTMASK: return NX_MODIFIERKEY_ALPHALOCK;
+ case NX_SHIFTMASK: return NX_MODIFIERKEY_SHIFT;
+#ifdef NX_DEVICELSHIFTKEYMASK
+ case NX_DEVICELSHIFTKEYMASK: return NX_MODIFIERKEY_SHIFT;
+ case NX_DEVICERSHIFTKEYMASK: return NX_MODIFIERKEY_RSHIFT;
+#endif
+ case NX_CONTROLMASK: return NX_MODIFIERKEY_CONTROL;
+#ifdef NX_DEVICELCTLKEYMASK
+ case NX_DEVICELCTLKEYMASK: return NX_MODIFIERKEY_CONTROL;
+ case NX_DEVICERCTLKEYMASK: return NX_MODIFIERKEY_RCONTROL;
+#endif
+ case NX_ALTERNATEMASK: return NX_MODIFIERKEY_ALTERNATE;
+#ifdef NX_DEVICELALTKEYMASK
+ case NX_DEVICELALTKEYMASK: return NX_MODIFIERKEY_ALTERNATE;
+ case NX_DEVICERALTKEYMASK: return NX_MODIFIERKEY_RALTERNATE;
+#endif
+ case NX_COMMANDMASK: return NX_MODIFIERKEY_COMMAND;
+#ifdef NX_DEVICELCMDKEYMASK
+ case NX_DEVICELCMDKEYMASK: return NX_MODIFIERKEY_COMMAND;
+ case NX_DEVICERCMDKEYMASK: return NX_MODIFIERKEY_RCOMMAND;
+#endif
+ case NX_NUMERICPADMASK: return NX_MODIFIERKEY_NUMERICPAD;
+ case NX_HELPMASK: return NX_MODIFIERKEY_HELP;
+ case NX_SECONDARYFNMASK: return NX_MODIFIERKEY_SECONDARYFN;
+ }
+ return -1;
+}
+
+static const char *DarwinModifierNXMaskTostring(int mask) {
+ switch (mask) {
+ case NX_ALPHASHIFTMASK: return "NX_ALPHASHIFTMASK";
+ case NX_SHIFTMASK: return "NX_SHIFTMASK";
+ case NX_DEVICELSHIFTKEYMASK: return "NX_DEVICELSHIFTKEYMASK";
+ case NX_DEVICERSHIFTKEYMASK: return "NX_DEVICERSHIFTKEYMASK";
+ case NX_CONTROLMASK: return "NX_CONTROLMASK";
+ case NX_DEVICELCTLKEYMASK: return "NX_DEVICELCTLKEYMASK";
+ case NX_DEVICERCTLKEYMASK: return "NX_DEVICERCTLKEYMASK";
+ case NX_ALTERNATEMASK: return "NX_ALTERNATEMASK";
+ case NX_DEVICELALTKEYMASK: return "NX_DEVICELALTKEYMASK";
+ case NX_DEVICERALTKEYMASK: return "NX_DEVICERALTKEYMASK";
+ case NX_COMMANDMASK: return "NX_COMMANDMASK";
+ case NX_DEVICELCMDKEYMASK: return "NX_DEVICELCMDKEYMASK";
+ case NX_DEVICERCMDKEYMASK: return "NX_DEVICERCMDKEYMASK";
+ case NX_NUMERICPADMASK: return "NX_NUMERICPADMASK";
+ case NX_HELPMASK: return "NX_HELPMASK";
+ case NX_SECONDARYFNMASK: return "NX_SECONDARYFNMASK";
+ }
+ return "unknown mask";
+}
+
+/*
+ * DarwinModifierNXKeyToNXMask
+ * Returns 0 if key is not a known modifier key.
+ */
+int DarwinModifierNXKeyToNXMask(int key) {
+ switch (key) {
+ case NX_MODIFIERKEY_ALPHALOCK: return NX_ALPHASHIFTMASK;
+ case NX_MODIFIERKEY_SHIFT: return NX_SHIFTMASK;
+#ifdef NX_MODIFIERKEY_RSHIFT
+ case NX_MODIFIERKEY_RSHIFT: return NX_SHIFTMASK;
+#endif
+ case NX_MODIFIERKEY_CONTROL: return NX_CONTROLMASK;
+#ifdef NX_MODIFIERKEY_RCONTROL
+ case NX_MODIFIERKEY_RCONTROL: return NX_CONTROLMASK;
+#endif
+ case NX_MODIFIERKEY_ALTERNATE: return NX_ALTERNATEMASK;
+#ifdef NX_MODIFIERKEY_RALTERNATE
+ case NX_MODIFIERKEY_RALTERNATE: return NX_ALTERNATEMASK;
+#endif
+ case NX_MODIFIERKEY_COMMAND: return NX_COMMANDMASK;
+#ifdef NX_MODIFIERKEY_RCOMMAND
+ case NX_MODIFIERKEY_RCOMMAND: return NX_COMMANDMASK;
+#endif
+ case NX_MODIFIERKEY_NUMERICPAD: return NX_NUMERICPADMASK;
+ case NX_MODIFIERKEY_HELP: return NX_HELPMASK;
+ case NX_MODIFIERKEY_SECONDARYFN: return NX_SECONDARYFNMASK;
+ }
+ return 0;
+}
+
+/*
+ * DarwinModifierStringToNXKey
+ * Returns -1 if string is not a known modifier.
+ */
+int DarwinModifierStringToNXKey(const char *str) {
+ if (!strcasecmp(str, "shift")) return NX_MODIFIERKEY_SHIFT;
+ else if (!strcasecmp(str, "control")) return NX_MODIFIERKEY_CONTROL;
+ else if (!strcasecmp(str, "option")) return NX_MODIFIERKEY_ALTERNATE;
+ else if (!strcasecmp(str, "command")) return NX_MODIFIERKEY_COMMAND;
+ else if (!strcasecmp(str, "fn")) return NX_MODIFIERKEY_SECONDARYFN;
+ else return -1;
+}
+
+/*
+ * LegalModifier
+ * This allows the ddx layer to prevent some keys from being remapped
+ * as modifier keys.
+ */
+Bool LegalModifier(unsigned int key, DeviceIntPtr pDev)
+{
+ return 1;
+}
+
unsigned int QuartzSystemKeymapSeed(void) {
static unsigned int seed;
static KeyboardLayoutRef last_key_layout;
diff --git a/hw/xquartz/quartzKeyboard.h b/hw/xquartz/quartzKeyboard.h
index 4f495bb46..964ea012e 100644
--- a/hw/xquartz/quartzKeyboard.h
+++ b/hw/xquartz/quartzKeyboard.h
@@ -49,4 +49,17 @@ typedef struct darwinKeyboardInfo_struct {
Bool QuartzReadSystemKeymap(darwinKeyboardInfo *info);
unsigned int QuartzSystemKeymapSeed(void);
+/* Provided for darwinEvents.c */
+extern darwinKeyboardInfo keyInfo;
+void DarwinKeyboardReloadHandler(int screenNum, xEventPtr xe, DeviceIntPtr dev, int nevents);
+void DarwinKeyboardInit(DeviceIntPtr pDev);
+int DarwinModifierNXKeycodeToNXKey(unsigned char keycode, int *outSide);
+int DarwinModifierNXKeyToNXKeycode(int key, int side);
+int DarwinModifierNXKeyToNXMask(int key);
+int DarwinModifierNXMaskToNXKey(int mask);
+int DarwinModifierStringToNXKey(const char *string);
+
+/* Provided for darwin.c */
+void DarwinKeyboardInit(DeviceIntPtr pDev);
+
#endif /* QUARTZ_KEYBOARD_H */
diff --git a/hw/xquartz/quartzStartup.c b/hw/xquartz/quartzStartup.c
index 5ac3017e1..a4472e659 100644
--- a/hw/xquartz/quartzStartup.c
+++ b/hw/xquartz/quartzStartup.c
@@ -27,6 +27,8 @@
* use or other dealings in this Software without prior written authorization.
*/
+#include "sanitizedCarbon.h"
+
#ifdef HAVE_DIX_CONFIG_H
#include <dix-config.h>
#endif
@@ -35,42 +37,72 @@
#include <unistd.h>
#include <CoreFoundation/CoreFoundation.h>
#include "quartzCommon.h"
+#include "quartzForeground.h"
#include "X11Controller.h"
#include "darwin.h"
+#include "darwinEvents.h"
+#include "quartzAudio.h"
#include "quartz.h"
#include "opaque.h"
#include "micmap.h"
#include <assert.h>
-char **envpGlobal; // argcGlobal and argvGlobal
- // are from dix/globals.c
+#include <pthread.h>
+
+int dix_main(int argc, char **argv, char **envp);
-int main(int argc, char **argv, char **envp);
-void _InitHLTB(void);
-void DarwinHandleGUI(int argc, char **argv, char **envp);
+struct arg {
+ int argc;
+ char **argv;
+ char **envp;
+};
static void server_thread (void *arg) {
- exit (main (argcGlobal, argvGlobal, envpGlobal));
+ struct arg args = *((struct arg *)arg);
+ free(arg);
+ exit (dix_main(args.argc, args.argv, args.envp));
}
-/*
- * DarwinHandleGUI
- * This function is called first from main(). The first time
- * it is called we start the Mac OS X front end. The front end
- * will call main() again from another thread to run the X
- * server. On the second call this function loads the user
- * preferences set by the Mac OS X front end.
- */
-void DarwinHandleGUI(int argc, char **argv, char **envp) {
- static Bool been_here = FALSE;
+static pthread_t 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 tid;
+}
+
+void QuartzInitServer(int argc, char **argv, char **envp) {
+ struct arg *args = (struct arg*)malloc(sizeof(struct arg));
+ if(!args)
+ FatalError("Could not allocate memory.\n");
+
+ args->argc = argc;
+ args->argv = argv;
+ args->envp = envp;
+
+ APPKIT_THREAD_ID = pthread_self();
+ SERVER_THREAD_ID = create_thread(server_thread, args);
+
+ if (!SERVER_THREAD_ID) {
+ FatalError("can't create secondary thread\n");
+ }
+}
+
+int main(int argc, char **argv, char **envp) {
int i;
int fd[2];
- if (been_here) {
- return;
- }
- been_here = TRUE;
+ /* Unset CFProcessPath, so our children don't inherit this kludge we need
+ * to load our nib. If an xterm gets this set, then it fails to
+ * 'open hi.txt' properly.
+ */
+ unsetenv("CFProcessPath");
// Make a pipe to pass events
assert( pipe(fd) == 0 );
@@ -78,11 +110,6 @@ void DarwinHandleGUI(int argc, char **argv, char **envp) {
darwinEventWriteFD = fd[1];
fcntl(darwinEventReadFD, F_SETFL, O_NONBLOCK);
- // Store command line arguments to pass back to main()
- argcGlobal = argc;
- argvGlobal = argv;
- envpGlobal = envp;
-
for (i = 1; i < argc; i++) {
// Display version info without starting Mac OS X UI if requested
if (!strcmp( argv[i], "-showconfig" ) || !strcmp( argv[i], "-version" )) {
@@ -91,16 +118,10 @@ void DarwinHandleGUI(int argc, char **argv, char **envp) {
}
}
- /* 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. */
-
- _InitHLTB();
- X11ControllerMain(argc, (const char **)argv, server_thread, NULL);
+ /* Create the audio mutex */
+ QuartzAudioInit();
+
+ QuartzMoveToForeground();
+ X11ControllerMain(argc, argv, envp);
exit(0);
}
diff --git a/hw/xquartz/sanitizedCarbon.h b/hw/xquartz/sanitizedCarbon.h
new file mode 100644
index 000000000..cc6ef198d
--- /dev/null
+++ b/hw/xquartz/sanitizedCarbon.h
@@ -0,0 +1,32 @@
+/*
+ * Don't #include any of the AppKit, etc stuff directly since it will
+ * pollute the X11 namespace.
+ */
+
+#ifndef _XQ_SANITIZED_CARBON_H_
+#define _XQ_SANITIZED_CARBON_H_
+
+// QuickDraw in ApplicationServices has the following conflicts with
+// the basic X server headers. Use QD_<name> to use the QuickDraw
+// definition of any of these symbols, or the normal name for the
+// X11 definition.
+#define Cursor QD_Cursor
+#define WindowPtr QD_WindowPtr
+#define Picture QD_Picture
+#define BOOL OSX_BOOL
+#define EventType HIT_EventType
+
+#include <ApplicationServices/ApplicationServices.h>
+#include <CoreServices/CoreServices.h>
+#include <Carbon/Carbon.h>
+#include <IOKit/hidsystem/event_status_driver.h>
+#include <IOKit/hidsystem/ev_keymap.h>
+#include <architecture/byte_order.h> // For the NXSwap*
+
+#undef Cursor
+#undef WindowPtr
+#undef Picture
+#undef BOOL
+#undef EventType
+
+#endif /* _XQ_SANITIZED_CARBON_H_ */
diff --git a/hw/xquartz/sanitizedCocoa.h b/hw/xquartz/sanitizedCocoa.h
new file mode 100644
index 000000000..58de64c1c
--- /dev/null
+++ b/hw/xquartz/sanitizedCocoa.h
@@ -0,0 +1,27 @@
+/*
+ * Don't #include any of the AppKit, etc stuff directly since it will
+ * pollute the X11 namespace.
+ */
+
+#ifndef _XQ_SANITIZED_COCOA_H_
+#define _XQ_SANITIZED_COCOA_H_
+
+// QuickDraw in ApplicationServices has the following conflicts with
+// the basic X server headers. Use QD_<name> to use the QuickDraw
+// definition of any of these symbols, or the normal name for the
+// X11 definition.
+#define Cursor QD_Cursor
+#define WindowPtr QD_WindowPtr
+#define Picture QD_Picture
+#define BOOL OSX_BOOL
+#define EventType HIT_EventType
+
+#include <Cocoa/Cocoa.h>
+
+#undef Cursor
+#undef WindowPtr
+#undef Picture
+#undef BOOL
+#undef EventType
+
+#endif /* _XQ_SANITIZED_COCOA_H_ */
diff --git a/hw/xquartz/threadSafety.c b/hw/xquartz/threadSafety.c
new file mode 100644
index 000000000..b5a4ecf95
--- /dev/null
+++ b/hw/xquartz/threadSafety.c
@@ -0,0 +1,70 @@
+/*
+ * Copyright (C) 2008 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.
+ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include "threadSafety.h"
+#include "os.h"
+
+#include <execinfo.h>
+
+pthread_t APPKIT_THREAD_ID;
+pthread_t SERVER_THREAD_ID;
+
+void spewCallStack(void) {
+ void* callstack[128];
+ int i, frames = backtrace(callstack, 128);
+ char** strs = backtrace_symbols(callstack, frames);
+
+ for (i = 0; i < frames; ++i) {
+ ErrorF("%s\n", strs[i]);
+ }
+
+ free(strs);
+}
+
+void _threadSafetyAssert(pthread_t tid, const char *file, const char *fun, int line) {
+ if(pthread_equal(pthread_self(), tid))
+ return;
+
+ /* NOOOO! */
+ ErrorF("Thread Assertion Failed: self=%s, expected=%s\n%s:%s:%d\n",
+ threadSafetyID(pthread_self()), threadSafetyID(tid),
+ file, fun, line);
+ spewCallStack();
+}
+
+const char *threadSafetyID(pthread_t tid) {
+ if(pthread_equal(tid, APPKIT_THREAD_ID)) {
+ return "Appkit Thread";
+ } else if(pthread_equal(tid, SERVER_THREAD_ID)) {
+ return "Xserver Thread";
+ } else {
+ return "Unknown Thread";
+ }
+}
diff --git a/hw/xquartz/darwinKeyboard.h b/hw/xquartz/threadSafety.h
index 762f65919..7b009103a 100644
--- a/hw/xquartz/darwinKeyboard.h
+++ b/hw/xquartz/threadSafety.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003-2004 Torrey T. Lyons. All Rights Reserved.
+ * Copyright (C) 2008 Apple, Inc.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
@@ -24,22 +24,33 @@
* use or other dealings in this Software without prior written authorization.
*/
-#ifndef DARWIN_KEYBOARD_H
-#define DARWIN_KEYBOARD_H 1
+#ifndef _XQ_THREAD_SAFETY_H_
+#define _XQ_THREAD_SAFETY_H_
-#include "quartzKeyboard.h"
+#define DEBUG_THREADS 1
-/* Provided for darwinEvents.c */
-extern darwinKeyboardInfo keyInfo;
-void DarwinKeyboardReloadHandler(int screenNum, xEventPtr xe, DeviceIntPtr dev, int nevents);
-void DarwinKeyboardInit(DeviceIntPtr pDev);
-int DarwinModifierNXKeycodeToNXKey(unsigned char keycode, int *outSide);
-int DarwinModifierNXKeyToNXKeycode(int key, int side);
-int DarwinModifierNXKeyToNXMask(int key);
-int DarwinModifierNXMaskToNXKey(int mask);
-int DarwinModifierStringToNXKey(const char *string);
+#include <pthread.h>
-/* Provided for darwin.c */
-void DarwinKeyboardInit(DeviceIntPtr pDev);
+extern pthread_t APPKIT_THREAD_ID;
+extern pthread_t SERVER_THREAD_ID;
-#endif /* DARWIN_KEYBOARD_H */
+/* Dump the call stack */
+void spewCallStack(void);
+
+/* Print message to ErrorF if we're in the wrong thread */
+void _threadSafetyAssert(pthread_t tid, const char *file, const char *fun, int line);
+
+/* Get a string that identifies our thread nicely */
+const char *threadSafetyID(pthread_t tid);
+
+#define threadSafetyAssert(tid) _threadSafetyAssert(tid, __FILE__, __FUNCTION__, __LINE__)
+
+#ifdef DEBUG_THREADS
+#define TA_APPKIT() threadSafetyAssert(APPKIT_THREAD_ID)
+#define TA_SERVER() threadSafetyAssert(SERVER_THREAD_ID)
+#else
+#define TA_SERVER()
+#define TA_APPKIT()
+#endif
+
+#endif _XQ_THREAD_SAFETY_H_
diff --git a/hw/xquartz/xpr/Makefile.am b/hw/xquartz/xpr/Makefile.am
index b4d67c7b7..41f2b8655 100644
--- a/hw/xquartz/xpr/Makefile.am
+++ b/hw/xquartz/xpr/Makefile.am
@@ -11,6 +11,7 @@ Xquartz_SOURCES = \
dri.c \
xprAppleWM.c \
xprCursor.c \
+ xprEvent.c \
xprFrame.c \
xprScreen.c \
x-hash.c \
@@ -20,27 +21,7 @@ Xquartz_SOURCES = \
Xquartz_LDADD = \
$(top_builddir)/hw/xquartz/libXquartz.la \
$(top_builddir)/dix/dixfonts.lo \
- $(top_builddir)/config/libconfig.a \
- $(top_builddir)/dix/libdix.la \
- $(top_builddir)/os/libos.la \
- $(top_builddir)/dix/libxpstubs.la \
- $(top_builddir)/miext/shadow/libshadow.la \
- $(top_builddir)/fb/libfb.la \
- $(top_builddir)/mi/libmi.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 \
$(top_builddir)/miext/rootless/librootless.la \
- $(top_builddir)/miext/rootless/accel/librlAccel.la \
$(DARWIN_LIBS) $(XSERVER_LIBS) $(XSERVER_SYS_LIBS) -lXplugin
Xquartz_LDFLAGS = \
@@ -66,6 +47,7 @@ include $(top_srcdir)/cpprules.in
cp $< $@
EXTRA_DIST = \
+ Xquartz.man.pre \
dri.h \
dristruct.h \
appledri.h \
@@ -73,4 +55,5 @@ EXTRA_DIST = \
x-hash.h \
x-hook.h \
x-list.h \
- xpr.h
+ xpr.h \
+ xprEvent.h
diff --git a/hw/xquartz/xpr/dri.h b/hw/xquartz/xpr/dri.h
index cf2638a9f..8bb2e9e80 100644
--- a/hw/xquartz/xpr/dri.h
+++ b/hw/xquartz/xpr/dri.h
@@ -41,7 +41,7 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#include "scrnintstr.h"
#define _APPLEDRI_SERVER_
#include "appledri.h"
-#include "Xplugin.h"
+#include <Xplugin.h>
typedef void (*ClipNotifyPtr)( WindowPtr, int, int );
diff --git a/hw/xquartz/xpr/xpr.h b/hw/xquartz/xpr/xpr.h
index b8c69df0d..ab79a42cd 100644
--- a/hw/xquartz/xpr/xpr.h
+++ b/hw/xquartz/xpr/xpr.h
@@ -29,7 +29,9 @@
#ifndef XPR_H
#define XPR_H
+#include "windowstr.h"
#include "screenint.h"
+#include <Xplugin.h>
Bool QuartzModeBundleInit(void);
@@ -37,6 +39,7 @@ void AppleDRIExtensionInit(void);
void xprAppleWMInit(void);
Bool xprInit(ScreenPtr pScreen);
Bool xprIsX11Window(void *nsWindow, int windowNumber);
+WindowPtr xprGetXWindow(xp_window_id wid);
void xprHideWindows(Bool hide);
diff --git a/hw/xquartz/xpr/xprAppleWM.c b/hw/xquartz/xpr/xprAppleWM.c
index bd82df03c..aa5f29159 100644
--- a/hw/xquartz/xpr/xprAppleWM.c
+++ b/hw/xquartz/xpr/xprAppleWM.c
@@ -34,7 +34,7 @@
#include "xpr.h"
#include "applewmExt.h"
#include "rootless.h"
-#include "Xplugin.h"
+#include <Xplugin.h>
#include <X11/X.h>
static int xprSetWindowLevel(
diff --git a/hw/xquartz/xpr/xprCursor.c b/hw/xquartz/xpr/xprCursor.c
index 2ad8d6f56..76ab75c02 100644
--- a/hw/xquartz/xpr/xprCursor.c
+++ b/hw/xquartz/xpr/xprCursor.c
@@ -29,6 +29,8 @@
* use or other dealings in this Software without prior written authorization.
*/
+#include "sanitizedCarbon.h"
+
#ifdef HAVE_DIX_CONFIG_H
#include <dix-config.h>
#endif
@@ -37,7 +39,7 @@
#include "xpr.h"
#include "darwin.h"
#include "darwinEvents.h"
-#include "Xplugin.h"
+#include <Xplugin.h>
#include "mi.h"
#include "scrnintstr.h"
diff --git a/hw/xquartz/xpr/xprEvent.c b/hw/xquartz/xpr/xprEvent.c
new file mode 100644
index 000000000..617d6e146
--- /dev/null
+++ b/hw/xquartz/xpr/xprEvent.c
@@ -0,0 +1,91 @@
+/* Copyright (c) 2008 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.
+ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include "xpr.h"
+
+#define NEED_EVENTS
+#include <X11/X.h>
+#include <X11/Xmd.h>
+#include <X11/Xproto.h>
+#include "misc.h"
+#include "windowstr.h"
+#include "pixmapstr.h"
+#include "inputstr.h"
+#include "mi.h"
+#include "scrnintstr.h"
+#include "mipointer.h"
+
+#include "darwin.h"
+#include "quartz.h"
+#include "quartzKeyboard.h"
+#include "darwinEvents.h"
+
+#include <sys/types.h>
+#include <sys/uio.h>
+#include <unistd.h>
+
+#include "rootlessWindow.h"
+#include "xprEvent.h"
+
+static void xprEventHandler(int screenNum, xEventPtr xe, DeviceIntPtr dev, int nevents) {
+ int i;
+
+ TA_SERVER();
+
+ DEBUG_LOG("DarwinEventHandler(%d, %p, %p, %d)\n", screenNum, xe, dev, nevents);
+ for (i=0; i<nevents; i++) {
+ switch(xe[i].u.u.type) {
+
+ case kXquartzWindowState:
+ DEBUG_LOG("kXquartzWindowState\n");
+ RootlessNativeWindowStateChanged(xprGetXWindow(xe[i].u.clientMessage.u.l.longs0),
+ xe[i].u.clientMessage.u.l.longs1);
+ break;
+
+ case kXquartzWindowMoved:
+ DEBUG_LOG("kXquartzWindowMoved\n");
+ RootlessNativeWindowMoved ((WindowPtr)xe[i].u.clientMessage.u.l.longs0);
+ break;
+
+ case kXquartzBringAllToFront:
+ DEBUG_LOG("kXquartzBringAllToFront\n");
+ RootlessOrderAllWindows();
+ break;
+ }
+ }
+}
+
+void QuartzModeEQInit(void) {
+ mieqSetHandler(kXquartzWindowState, xprEventHandler);
+ mieqSetHandler(kXquartzWindowMoved, xprEventHandler);
+ mieqSetHandler(kXquartzBringAllToFront, xprEventHandler);
+}
diff --git a/hw/xquartz/xpr/xprEvent.h b/hw/xquartz/xpr/xprEvent.h
new file mode 100644
index 000000000..5af9dfd77
--- /dev/null
+++ b/hw/xquartz/xpr/xprEvent.h
@@ -0,0 +1,34 @@
+/* Copyright (c) 2008 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.
+ */
+
+#ifndef __XPR_EVENT_H__
+#define __XPR_EVENT_H__
+
+void QuartzModeEQInit(void);
+
+#endif
diff --git a/hw/xquartz/xpr/xprFrame.c b/hw/xquartz/xpr/xprFrame.c
index 864ef0d40..9fa94243e 100644
--- a/hw/xquartz/xpr/xprFrame.c
+++ b/hw/xquartz/xpr/xprFrame.c
@@ -33,7 +33,7 @@
#include "xpr.h"
#include "rootlessCommon.h"
-#include "Xplugin.h"
+#include <Xplugin.h>
#include "x-hash.h"
#include "x-list.h"
#include "applewmExt.h"
@@ -43,6 +43,8 @@
#include <X11/Xatom.h>
#include "windowstr.h"
+#include "threadSafety.h"
+
#include <pthread.h>
#define DEFINE_ATOM_HELPER(func,atom_name) \
@@ -69,7 +71,8 @@ static inline xp_error
xprConfigureWindow(xp_window_id id, unsigned int mask,
const xp_window_changes *values)
{
- // ErrorF("xprConfigureWindow()\n");
+ TA_SERVER();
+
if (!no_configure_window)
return xp_configure_window(id, mask, values);
else
@@ -84,6 +87,8 @@ xprSetNativeProperty(RootlessWindowPtr pFrame)
unsigned int native_id;
long data;
+ TA_SERVER();
+
err = xp_get_native_window((xp_window_id) pFrame->wid, &native_id);
if (err == Success)
{
@@ -108,6 +113,8 @@ xprCreateFrame(RootlessWindowPtr pFrame, ScreenPtr pScreen,
unsigned int mask = 0;
xp_error err;
+ TA_SERVER();
+
wc.x = newX;
wc.y = newY;
wc.width = pFrame->width;
@@ -169,6 +176,8 @@ xprCreateFrame(RootlessWindowPtr pFrame, ScreenPtr pScreen,
void
xprDestroyFrame(RootlessFrameID wid)
{
+ TA_SERVER();
+
pthread_mutex_lock(&window_hash_mutex);
x_hash_table_remove(window_hash, wid);
pthread_mutex_unlock(&window_hash_mutex);
@@ -183,6 +192,8 @@ xprDestroyFrame(RootlessFrameID wid)
void
xprMoveFrame(RootlessFrameID wid, ScreenPtr pScreen, int newX, int newY)
{
+ TA_SERVER();
+
xp_window_changes wc;
wc.x = newX;
@@ -202,6 +213,8 @@ xprResizeFrame(RootlessFrameID wid, ScreenPtr pScreen,
{
xp_window_changes wc;
+ TA_SERVER();
+
wc.x = newX;
wc.y = newY;
wc.width = newW;
@@ -223,7 +236,9 @@ xprRestackFrame(RootlessFrameID wid, RootlessFrameID nextWid)
{
xp_window_changes wc;
- /* Stack frame below nextWid it if it exists, or raise
+ TA_SERVER();
+
+ /* Stack frame below nextWid it if it exists, or raise
frame above everything otherwise. */
if (nextWid == NULL)
@@ -249,6 +264,8 @@ xprReshapeFrame(RootlessFrameID wid, RegionPtr pShape)
{
xp_window_changes wc;
+ TA_SERVER();
+
if (pShape != NULL)
{
wc.shape_nrects = REGION_NUM_RECTS(pShape);
@@ -274,6 +291,8 @@ xprUnmapFrame(RootlessFrameID wid)
{
xp_window_changes wc;
+ TA_SERVER();
+
wc.stack_mode = XP_UNMAPPED;
wc.sibling = 0;
@@ -292,6 +311,8 @@ xprStartDrawing(RootlessFrameID wid, char **pixelData, int *bytesPerRow)
unsigned int rowbytes[2];
xp_error err;
+ TA_SERVER();
+
err = xp_lock_window((xp_window_id) wid, NULL, NULL, data, rowbytes, NULL);
if (err != Success)
FatalError("Could not lock window %i for drawing.", (int) wid);
@@ -307,6 +328,8 @@ xprStartDrawing(RootlessFrameID wid, char **pixelData, int *bytesPerRow)
void
xprStopDrawing(RootlessFrameID wid, Bool flush)
{
+ TA_SERVER();
+
xp_unlock_window((xp_window_id) wid, flush);
}
@@ -317,6 +340,8 @@ xprStopDrawing(RootlessFrameID wid, Bool flush)
void
xprUpdateRegion(RootlessFrameID wid, RegionPtr pDamage)
{
+ TA_SERVER();
+
xp_flush_window((xp_window_id) wid);
}
@@ -328,6 +353,8 @@ void
xprDamageRects(RootlessFrameID wid, int nrects, const BoxRec *rects,
int shift_x, int shift_y)
{
+ TA_SERVER();
+
xp_mark_window((xp_window_id) wid, nrects, rects, shift_x, shift_y);
}
@@ -341,6 +368,8 @@ xprSwitchWindow(RootlessWindowPtr pFrame, WindowPtr oldWin)
{
DeleteProperty(serverClient, oldWin, xa_native_window_id());
+ TA_SERVER();
+
xprSetNativeProperty(pFrame);
}
@@ -352,6 +381,8 @@ Bool xprDoReorderWindow(RootlessWindowPtr pFrame)
{
WindowPtr pWin = pFrame->win;
+ TA_SERVER();
+
return AppleWMDoReorderWindow(pWin);
}
@@ -364,6 +395,8 @@ void
xprCopyWindow(RootlessFrameID wid, int dstNrects, const BoxRec *dstRects,
int dx, int dy)
{
+ TA_SERVER();
+
xp_copy_window((xp_window_id) wid, (xp_window_id) wid,
dstNrects, dstRects, dx, dy);
}
@@ -398,6 +431,8 @@ xprInit(ScreenPtr pScreen)
{
RootlessInit(pScreen, &xprRootlessProcs);
+ TA_SERVER();
+
rootless_CopyBytes_threshold = xp_copy_bytes_threshold;
rootless_FillBytes_threshold = xp_fill_bytes_threshold;
rootless_CompositePixels_threshold = xp_composite_area_threshold;
@@ -498,6 +533,8 @@ xprHideWindows(Bool hide)
int screen;
WindowPtr pRoot, pWin;
+ TA_SERVER();
+
for (screen = 0; screen < screenInfo.numScreens; screen++) {
pRoot = WindowTable[screenInfo.screens[screen]->myNum];
RootlessFrameID prevWid = NULL;
diff --git a/hw/xquartz/xpr/xprScreen.c b/hw/xquartz/xpr/xprScreen.c
index d685fca33..d8eb72a48 100644
--- a/hw/xquartz/xpr/xprScreen.c
+++ b/hw/xquartz/xpr/xprScreen.c
@@ -27,6 +27,8 @@
* use or other dealings in this Software without prior written authorization.
*/
+#include "sanitizedCarbon.h"
+
#ifdef HAVE_DIX_CONFIG_H
#include <dix-config.h>
#endif
@@ -35,18 +37,17 @@
#include "inputstr.h"
#include "quartz.h"
#include "xpr.h"
+#include "xprEvent.h"
#include "pseudoramiX.h"
#include "darwin.h"
+#include "darwinEvents.h"
#include "rootless.h"
#include "dri.h"
#include "globals.h"
-#include "Xplugin.h"
+#include <Xplugin.h>
#include "applewmExt.h"
#include "micmap.h"
-// From xprFrame.c
-WindowPtr xprGetXWindow(xp_window_id wid);
-
#ifdef DAMAGE
# include "damage.h"
#endif
@@ -142,20 +143,27 @@ displayAtIndex(int index)
* Return the bounds of a particular display.
*/
static CGRect
-displayScreenBounds(CGDirectDisplayID id)
+displayScreenBounds(CGDirectDisplayID id, Bool remove_menubar)
{
CGRect frame;
frame = CGDisplayBounds(id);
+ DEBUG_LOG(" %dx%d @ (%d,%d).\n",
+ (int)frame.size.width, (int)frame.size.height,
+ (int)frame.origin.x, (int)frame.origin.y);
+
/* Remove menubar to help standard X11 window managers. */
-
- if (frame.origin.x == 0 && frame.origin.y == 0)
- {
+ if (remove_menubar && !quartzHasRoot &&
+ frame.origin.x == 0 && frame.origin.y == 0) {
frame.origin.y += aquaMenuBarHeight;
frame.size.height -= aquaMenuBarHeight;
}
+ DEBUG_LOG(" %dx%d @ (%d,%d).\n",
+ (int)frame.size.width, (int)frame.size.height,
+ (int)frame.origin.x, (int)frame.origin.y);
+
return frame;
}
@@ -179,8 +187,13 @@ xprAddPseudoramiXScreens(int *x, int *y, int *width, int *height)
/* Get the union of all screens */
for (i = 0; i < displayCount; i++)
{
+
+ /* we can't remove the menubar from the screen - doing so
+ * would constrain the pointer to the screen, not allowing it
+ * to reach the menubar..
+ */
CGDirectDisplayID dpy = displayList[i];
- frame = displayScreenBounds(dpy);
+ frame = displayScreenBounds(dpy, FALSE);
unionRect = CGRectUnion(unionRect, frame);
}
@@ -190,22 +203,20 @@ xprAddPseudoramiXScreens(int *x, int *y, int *width, int *height)
*width = unionRect.size.width;
*height = unionRect.size.height;
+ DEBUG_LOG(" screen union origin: (%d,%d) size: (%d,%d).\n",
+ *x, *y, *width, *height);
+
/* Tell PseudoramiX about the real screens. */
for (i = 0; i < displayCount; i++)
{
CGDirectDisplayID dpy = displayList[i];
- frame = displayScreenBounds(dpy);
-
- /* ErrorF("PseudoramiX screen %d added: %dx%d @ (%d,%d).\n", i,
- (int)frame.size.width, (int)frame.size.height,
- (int)frame.origin.x, (int)frame.origin.y); */
-
+ frame = displayScreenBounds(dpy, TRUE);
frame.origin.x -= unionRect.origin.x;
frame.origin.y -= unionRect.origin.y;
- /* ErrorF("PseudoramiX screen %d placed at X11 coordinate (%d,%d).\n",
- i, (int)frame.origin.x, (int)frame.origin.y); */
+ DEBUG_LOG(" placed at X11 coordinate (%d,%d).\n",
+ (int)frame.origin.x, (int)frame.origin.y);
PseudoramiXAddScreen(frame.origin.x, frame.origin.y,
frame.size.width, frame.size.height);
@@ -223,7 +234,7 @@ xprDisplayInit(void)
{
CGDisplayCount displayCount;
- // ErrorF("Display mode: Rootless Quartz -- Xplugin implementation\n");
+ DEBUG_LOG("");
CGGetActiveDisplayList(0, NULL, &displayCount);
@@ -259,6 +270,8 @@ xprAddScreen(int index, ScreenPtr pScreen)
{
DarwinFramebufferPtr dfb = SCREEN_PRIV(pScreen);
int depth = darwinDesiredDepth;
+
+ DEBUG_LOG("index=%d depth=%d\n", index, depth);
if(depth == -1) {
depth = CGDisplaySamplesPerPixel(kCGDirectMainDisplay) * CGDisplayBitsPerSample(kCGDirectMainDisplay);
@@ -315,12 +328,14 @@ xprAddScreen(int index, ScreenPtr pScreen)
if (noPseudoramiXExtension)
{
+ ErrorF("Warning: noPseudoramiXExtension!\n");
+
CGDirectDisplayID dpy;
CGRect frame;
dpy = displayAtIndex(index);
- frame = displayScreenBounds(dpy);
+ frame = displayScreenBounds(dpy, TRUE);
dfb->x = frame.origin.x;
dfb->y = frame.origin.y;
@@ -352,7 +367,9 @@ xprSetupScreen(int index, ScreenPtr pScreen)
{
// Initialize accelerated rootless drawing
// Note that this must be done before DamageSetup().
- RootlessAccelInit(pScreen);
+
+ // These are crashing ugly... better to be stable and not crash for now.
+ //RootlessAccelInit(pScreen);
#ifdef DAMAGE
// The Damage extension needs to wrap underneath the
diff --git a/include/dix-config.h.in b/include/dix-config.h.in
index a7c0c6a60..fc1caa31a 100644
--- a/include/dix-config.h.in
+++ b/include/dix-config.h.in
@@ -148,6 +148,9 @@
/* Define to 1 if you have version 2.2 (or newer) of the drm library */
#undef HAVE_LIBDRM_2_2
+/* Define to 1 if launchd is available. */
+#undef HAVE_LAUNCHD
+
/* Have Quartz */
#undef XQUARTZ
@@ -258,9 +261,6 @@
/* Support os-specific local connections */
#undef LOCALCONN
-/* Support MIT Misc extension */
-#undef MITMISC
-
/* Support MIT-SHM Extension */
#undef MITSHM
@@ -416,23 +416,12 @@
/* Support Xv extension */
#undef XV
-/* Build APPGROUP extension */
-#undef XAPPGROUP
-
-/* Build TOG-CUP extension */
-#undef TOGCUP
-
-/* Build Extended-Visual-Information extension */
-#undef EVI
-
/* Build Multibuffer extension */
#undef MULTIBUFFER
/* Support DRI extension */
#undef XF86DRI
-#undef XEPHYR_DRI
-
/* Build DRI2 extension */
#undef DRI2
diff --git a/include/dixstruct.h b/include/dixstruct.h
index d44b9cfa7..18d161ae3 100644
--- a/include/dixstruct.h
+++ b/include/dixstruct.h
@@ -125,9 +125,7 @@ typedef struct _Client {
int requestLogIndex;
#endif
unsigned long replyBytesRemaining;
-#ifdef XAPPGROUP
- struct _AppGroupRec* appgroup;
-#endif
+ void *appgroup; /* Can't remove, ABI */
struct _FontResolution * (*fontResFunc) ( /* no need for font.h */
ClientPtr /* pClient */,
int * /* num */);
diff --git a/include/globals.h b/include/globals.h
index 2ca9531d9..9e5060d5f 100644
--- a/include/globals.h
+++ b/include/globals.h
@@ -66,10 +66,6 @@ extern Bool noDbeExtension;
extern Bool noDPMSExtension;
#endif
-#ifdef EVI
-extern Bool noEVIExtension;
-#endif
-
#ifdef FONTCACHE
extern Bool noFontCacheExtension;
#endif
@@ -86,10 +82,6 @@ extern Bool noScreenSaverExtension;
extern Bool noMITShmExtension;
#endif
-#ifdef MITMISC
-extern Bool noMITMiscExtension;
-#endif
-
#ifdef MULTIBUFFER
extern Bool noMultibufferExtension;
#endif
@@ -114,18 +106,10 @@ extern Bool noSecurityExtension;
extern Bool noSyncExtension;
#endif
-#ifdef TOGCUP
-extern Bool noXcupExtension;
-#endif
-
#ifdef RES
extern Bool noResExtension;
#endif
-#ifdef XAPPGROUP
-extern Bool noXagExtension;
-#endif
-
#ifdef XCMISC
extern Bool noXCMiscExtension;
#endif
diff --git a/include/servermd.h b/include/servermd.h
index 2f511dabe..8e6de0959 100644
--- a/include/servermd.h
+++ b/include/servermd.h
@@ -130,6 +130,16 @@ SOFTWARE.
#endif /* vax */
+#ifdef __avr32__
+
+#define IMAGE_BYTE_ORDER MSBFirst
+#define BITMAP_BIT_ORDER MSBFirst
+#define GLYPHPADBYTES 4
+#define GETLEFTBITS_ALIGNMENT 1
+#define AVOID_MEMORY_READ
+
+#endif /* __avr32__ */
+
#ifdef __arm32__
#define IMAGE_BYTE_ORDER LSBFirst
@@ -207,6 +217,26 @@ SOFTWARE.
#endif /* SuperH */
+#if defined(__m32r__)
+
+#if defined(__BIG_ENDIAN__)
+# define IMAGE_BYTE_ORDER MSBFirst
+# define BITMAP_BIT_ORDER MSBFirst
+# define GLYPHPADBYTES 4
+# define GETLEFTBITS_ALIGNMENT 1
+#else
+# define IMAGE_BYTE_ORDER LSBFirst
+# define BITMAP_BIT_ORDER LSBFirst
+# define GLYPHPADBYTES 4
+# define GETLEFTBITS_ALIGNMENT 1
+#endif
+
+#define AVOID_MEMORY_READ
+#define FAST_CONSTANT_OFFSET_MODE
+#define LARGE_INSTRUCTION_CACHE
+#define PLENTIFUL_REGISTERS
+
+#endif /* __m32r__ */
#if (defined(sun) && (defined(__sparc) || defined(sparc))) || \
(defined(__uxp__) && (defined(sparc) || defined(mc68000))) || \
@@ -393,7 +423,7 @@ SOFTWARE.
#endif /* ia64 */
-#if defined(__amd64__) || defined(amd64) || defined(__amd64)
+#if defined(__amd64__) || defined(amd64) || defined(__amd64) || defined(__x86_64__)
# define IMAGE_BYTE_ORDER LSBFirst
# if defined(XF86MONOVGA) || defined(XF86VGA16) || defined(XF86MONO)
diff --git a/include/xorg-server.h.in b/include/xorg-server.h.in
index 72b45514c..5a253c7c6 100644
--- a/include/xorg-server.h.in
+++ b/include/xorg-server.h.in
@@ -46,9 +46,6 @@
/* Support IPv6 for TCP connections */
#undef IPv6
-/* Support MIT Misc extension */
-#undef MITMISC
-
/* Support MIT-SHM Extension */
#undef MITSHM
diff --git a/mi/micoord.h b/mi/micoord.h
index 16d086117..876e88c95 100644
--- a/mi/micoord.h
+++ b/mi/micoord.h
@@ -48,7 +48,7 @@
defined(__alpha) || defined(__alpha__) || \
defined(__i386__) || defined(__i386) || defined(__ia64__) || \
defined(__s390x__) || defined(__s390__) || \
- defined(__amd64__) || defined(amd64) || defined(__amd64)
+ defined(__amd64__) || defined(amd64) || defined(__amd64) || defined(__x86_64__)
#define GetHighWord(x) (((int) (x)) >> 16)
#else
#define GetHighWord(x) (((int) (x)) / 65536)
diff --git a/mi/miinitext.c b/mi/miinitext.c
index cc4c15c9d..8689ee49b 100644
--- a/mi/miinitext.c
+++ b/mi/miinitext.c
@@ -130,9 +130,6 @@ extern Bool noDbeExtension;
#ifdef DPMSExtension
extern Bool noDPMSExtension;
#endif
-#ifdef EVI
-extern Bool noEVIExtension;
-#endif
#ifdef FONTCACHE
extern Bool noFontCacheExtension;
#endif
@@ -145,9 +142,6 @@ extern Bool noScreenSaverExtension;
#ifdef MITSHM
extern Bool noMITShmExtension;
#endif
-#ifdef MITMISC
-extern Bool noMITMiscExtension;
-#endif
#ifdef MULTIBUFFER
extern Bool noMultibufferExtension;
#endif
@@ -166,15 +160,9 @@ extern Bool noSecurityExtension;
#ifdef XSYNC
extern Bool noSyncExtension;
#endif
-#ifdef TOGCUP
-extern Bool noXcupExtension;
-#endif
#ifdef RES
extern Bool noResExtension;
#endif
-#ifdef XAPPGROUP
-extern Bool noXagExtension;
-#endif
#ifdef XCMISC
extern Bool noXCMiscExtension;
#endif
@@ -243,10 +231,6 @@ typedef void (*InitExtension)(INITARGS);
#ifdef XPRINT
#include <X11/extensions/Print.h>
#endif
-#ifdef XAPPGROUP
-#define _XAG_SERVER_
-#include <X11/extensions/Xagstr.h>
-#endif
#ifdef XCSECURITY
#include "securitysrv.h"
#include <X11/extensions/securstr.h>
@@ -265,9 +249,6 @@ typedef void (*InitExtension)(INITARGS);
#endif
/* FIXME: this whole block of externs should be from the appropriate headers */
-#ifdef EVI
-extern void EVIExtensionInit(INITARGS);
-#endif
#ifdef MITSHM
extern void ShmExtensionInit(INITARGS);
#endif
@@ -289,9 +270,6 @@ extern void XTestExtensionInit(INITARGS);
#ifdef BIGREQS
extern void BigReqExtensionInit(INITARGS);
#endif
-#ifdef MITMISC
-extern void MITMiscExtensionInit(INITARGS);
-#endif
#ifdef XIDLE
extern void XIdleExtensionInit(INITARGS);
#endif
@@ -320,9 +298,6 @@ extern void RecordExtensionInit(INITARGS);
#ifdef DBE
extern void DbeExtensionInit(INITARGS);
#endif
-#ifdef XAPPGROUP
-extern void XagExtensionInit(INITARGS);
-#endif
#ifdef XCSECURITY
extern void SecurityExtensionInit(INITARGS);
#endif
@@ -353,9 +328,6 @@ extern void GlxExtensionInit(INITARGS);
#ifdef XF86DRI
extern void XFree86DRIExtensionInit(INITARGS);
#endif
-#ifdef TOGCUP
-extern void XcupExtensionInit(INITARGS);
-#endif
#ifdef DPMSExtension
extern void DPMSExtensionInit(INITARGS);
#endif
@@ -413,9 +385,6 @@ static ExtensionToggle ExtensionToggleList[] =
#ifdef DPMSExtension
{ "DPMS", &noDPMSExtension },
#endif
-#ifdef EVI
- { "Extended-Visual-Information", &noEVIExtension },
-#endif
#ifdef FONTCACHE
{ "FontCache", &noFontCacheExtension },
#endif
@@ -428,9 +397,6 @@ static ExtensionToggle ExtensionToggleList[] =
#ifdef MITSHM
{ SHMNAME, &noMITShmExtension },
#endif
-#ifdef MITMISC
- { "MIT-SUNDRY-NONSTANDARD", &noMITMiscExtension },
-#endif
#ifdef MULTIBUFFER
{ "Multi-Buffering", &noMultibufferExtension },
#endif
@@ -449,15 +415,9 @@ static ExtensionToggle ExtensionToggleList[] =
#ifdef XSYNC
{ "SYNC", &noSyncExtension },
#endif
-#ifdef TOGCUP
- { "TOG-CUP", &noXcupExtension },
-#endif
#ifdef RES
{ "X-Resource", &noResExtension },
#endif
-#ifdef XAPPGROUP
- { "XC-APPGROUP", &noXagExtension },
-#endif
#ifdef XCMISC
{ "XC-MISC", &noXCMiscExtension },
#endif
@@ -548,9 +508,6 @@ InitExtensions(argc, argv)
#ifdef MITSHM
if (!noMITShmExtension) ShmExtensionInit();
#endif
-#ifdef EVI
- if (!noEVIExtension) EVIExtensionInit();
-#endif
#ifdef MULTIBUFFER
if (!noMultibufferExtension) MultibufferExtensionInit();
#endif
@@ -563,9 +520,6 @@ InitExtensions(argc, argv)
#ifdef BIGREQS
if (!noBigReqExtension) BigReqExtensionInit();
#endif
-#ifdef MITMISC
- if (!noMITMiscExtension) MITMiscExtensionInit();
-#endif
#ifdef XIDLE
if (!noXIdleExtension) XIdleExtensionInit();
#endif
@@ -596,9 +550,6 @@ InitExtensions(argc, argv)
#ifdef DBE
if (!noDbeExtension) DbeExtensionInit();
#endif
-#ifdef XAPPGROUP
- if (!noXagExtension) XagExtensionInit();
-#endif
#ifdef XCSECURITY
if (!noSecurityExtension) SecurityExtensionInit();
#endif
@@ -608,9 +559,6 @@ InitExtensions(argc, argv)
#ifdef XPRINT
XpExtensionInit(); /* server-specific extension, cannot be disabled */
#endif
-#ifdef TOGCUP
- if (!noXcupExtension) XcupExtensionInit();
-#endif
#if defined(DPMSExtension) && !defined(NO_HW_ONLY_EXTS)
if (!noDPMSExtension) DPMSExtensionInit();
#endif
@@ -690,9 +638,6 @@ static ExtensionModule staticExtensions[] = {
#ifdef XKB
{ XkbExtensionInit, XkbName, &noXkbExtension, NULL, NULL },
#endif
-#ifdef XAPPGROUP
- { XagExtensionInit, XAGNAME, &noXagExtension, NULL, NULL },
-#endif
#ifdef XCSECURITY
{ SecurityExtensionInit, SECURITY_EXTENSION_NAME, &noSecurityExtension, NULL, NULL },
#endif
diff --git a/mi/mivaltree.c b/mi/mivaltree.c
index 74483e354..d9d07caad 100644
--- a/mi/mivaltree.c
+++ b/mi/mivaltree.c
@@ -255,7 +255,11 @@ miComputeClips (
if (pParent->redirectDraw != RedirectDrawNone)
{
if (miSetRedirectBorderClipProc)
+ {
+ if (TreatAsTransparent (pParent))
+ REGION_EMPTY (pScreen, universe);
(*miSetRedirectBorderClipProc) (pParent, universe);
+ }
REGION_COPY(pScreen, universe, &pParent->borderSize);
}
#endif
diff --git a/miext/rootless/Makefile.am b/miext/rootless/Makefile.am
index dc851702f..f09300d5c 100644
--- a/miext/rootless/Makefile.am
+++ b/miext/rootless/Makefile.am
@@ -1,8 +1,6 @@
AM_CFLAGS = $(DIX_CFLAGS) $(XSERVER_CFLAGS)
AM_CPPFLAGS = -I$(top_srcdir)/hw/xfree86/os-support
-SUBDIRS = accel
-
noinst_LTLIBRARIES = librootless.la
librootless_la_SOURCES = \
rootlessCommon.c \
diff --git a/miext/rootless/README.txt b/miext/rootless/README.txt
index ffd17902f..2c3fbb05a 100644
--- a/miext/rootless/README.txt
+++ b/miext/rootless/README.txt
@@ -76,10 +76,6 @@ rootlessConfig.h to specify compile time options for its platform.
The following compile-time options are defined in
rootlessConfig.h:
- o ROOTLESS_ACCEL: If true, use the optional rootless acceleration
- functions where possible to a accelerate X11 drawing primitives.
- If false, all drawing will be done with fb.
-
o ROOTLESS_GLOBAL_COORDS: This option controls the way that frame
coordinates are passed to the rootless implementation. If false,
the coordinates are passed per screen relative to the origin of
diff --git a/miext/rootless/accel/Makefile.am b/miext/rootless/accel/Makefile.am
deleted file mode 100644
index ca41653b7..000000000
--- a/miext/rootless/accel/Makefile.am
+++ /dev/null
@@ -1,15 +0,0 @@
-AM_CFLAGS = $(DIX_CFLAGS) $(XSERVER_CFLAGS)
-AM_CPPFLAGS = -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/rlAccel.c b/miext/rootless/accel/rlAccel.c
deleted file mode 100644
index f3cb21569..000000000
--- a/miext/rootless/accel/rlAccel.c
+++ /dev/null
@@ -1,147 +0,0 @@
-/*
- * Support for accelerated rootless code
- */
-/*
- * Copyright (c) 2004 Torrey T. Lyons. 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.
- */
-
-/*
- * The accelerated rootless code replaces some GC operations from fb with
- * versions that call the rootless acceleration functions where appropriate.
- * To work properly, this must be wrapped directly on top of fb. Nothing
- * underneath this layer besides fb will get called.
- */
-
-#ifdef HAVE_DIX_CONFIG_H
-#include <dix-config.h>
-#endif
-
-#include "rootless.h"
-#include "rlAccel.h"
-
-typedef struct _rlAccelScreenRec {
- CreateGCProcPtr CreateGC;
- CloseScreenProcPtr CloseScreen;
-} rlAccelScreenRec, *rlAccelScreenPtr;
-
-static DevPrivateKey rlAccelScreenPrivateKey = &rlAccelScreenPrivateKey;
-
-#define RLACCELREC(pScreen) ((rlAccelScreenRec *) \
- dixLookupPrivate(&(pScreen)->devPrivates, rlAccelScreenPrivateKey))
-
-#define SETRLACCELREC(pScreen, v) \
- dixSetPrivate(&(pScreen)->devPrivates, rlAccelScreenPrivateKey, v)
-
-/* This is mostly identical to fbGCOps. */
-static GCOps rlAccelOps = {
- rlFillSpans,
- fbSetSpans,
- fbPutImage,
- rlCopyArea,
- fbCopyPlane,
- fbPolyPoint,
- fbPolyLine,
- fbPolySegment,
- fbPolyRectangle,
- fbPolyArc,
- miFillPolygon,
- rlPolyFillRect,
- fbPolyFillArc,
- miPolyText8,
- miPolyText16,
- miImageText8,
- miImageText16,
- rlImageGlyphBlt,
- fbPolyGlyphBlt,
- fbPushPixels
-};
-
-
-/*
- * Screen function to create a graphics context
- */
-static Bool
-rlCreateGC(GCPtr pGC)
-{
- ScreenPtr pScreen = pGC->pScreen;
- rlAccelScreenRec *s = RLACCELREC(pScreen);
- Bool result;
-
- // Unwrap and call
- pScreen->CreateGC = s->CreateGC;
- result = s->CreateGC(pGC);
-
- // Accelerated GC ops replace some fb GC ops
- pGC->ops = &rlAccelOps;
-
- // Rewrap
- s->CreateGC = pScreen->CreateGC;
- pScreen->CreateGC = rlCreateGC;
-
- return result;
-}
-
-
-/*
- * Clean up when closing a screen on server reset
- */
-static Bool
-rlCloseScreen (int iScreen, ScreenPtr pScreen)
-{
- rlAccelScreenRec *s = RLACCELREC(pScreen);
- Bool result;
-
- // Unwrap
- pScreen->CloseScreen = s->CloseScreen;
- result = pScreen->CloseScreen(iScreen, pScreen);
-
- xfree(s);
-
- return result;
-}
-
-
-/*
- * RootlessAccelInit
- * Called by the rootless implementation to initialize accelerated
- * rootless drawing.
- */
-Bool
-RootlessAccelInit(ScreenPtr pScreen)
-{
- rlAccelScreenRec *s;
-
- s = xalloc(sizeof(rlAccelScreenRec));
- if (!s) return FALSE;
- SETRLACCELREC(pScreen, s);
-
- // Wrap the screen functions we need
- s->CreateGC = pScreen->CreateGC;
- pScreen->CreateGC = rlCreateGC;
- s->CloseScreen = pScreen->CloseScreen;
- pScreen->CloseScreen = rlCloseScreen;
-
- return TRUE;
-}
diff --git a/miext/rootless/accel/rlAccel.h b/miext/rootless/accel/rlAccel.h
deleted file mode 100644
index a3fc6321e..000000000
--- a/miext/rootless/accel/rlAccel.h
+++ /dev/null
@@ -1,140 +0,0 @@
-/*
- * Rootless Acceleration Code
- */
-/*
- * Copyright (c) 2003 Torrey T. Lyons. All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- * THE ABOVE LISTED COPYRIGHT HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
- * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
- * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
- * DEALINGS IN THE SOFTWARE.
- *
- * Except as contained in this notice, the name(s) of the above copyright
- * holders shall not be used in advertising or otherwise to promote the sale,
- * use or other dealings in this Software without prior written authorization.
- */
-
-#ifdef HAVE_DIX_CONFIG_H
-#include <dix-config.h>
-#endif
-
-#include "fb.h"
-
-/*
- * rlBlt.c
- */
-void
-rlBlt (FbBits *srcLine,
- FbStride srcStride,
- int srcX,
-
- ScreenPtr pDstScreen,
- FbBits *dstLine,
- FbStride dstStride,
- int dstX,
-
- int width,
- int height,
-
- int alu,
- FbBits pm,
- int bpp,
-
- Bool reverse,
- Bool upsidedown);
-
-/*
- * rlCopy.c
- */
-RegionPtr
-rlCopyArea (DrawablePtr pSrcDrawable,
- DrawablePtr pDstDrawable,
- GCPtr pGC,
- int xIn,
- int yIn,
- int widthSrc,
- int heightSrc,
- int xOut,
- int yOut);
-
-/*
- * rlFill.c
- */
-void
-rlFill (DrawablePtr pDrawable,
- GCPtr pGC,
- int x,
- int y,
- int width,
- int height);
-
-void
-rlSolidBoxClipped (DrawablePtr pDrawable,
- RegionPtr pClip,
- int x1,
- int y1,
- int x2,
- int y2,
- FbBits and,
- FbBits xor);
-
-/*
- * rlFillRect.c
- */
-void
-rlPolyFillRect(DrawablePtr pDrawable,
- GCPtr pGC,
- int nrect,
- xRectangle *prect);
-
-/*
- * rlFillSpans.c
- */
-void
-rlFillSpans (DrawablePtr pDrawable,
- GCPtr pGC,
- int n,
- DDXPointPtr ppt,
- int *pwidth,
- int fSorted);
-
-/*
- * rlGlyph.c
- */
-void
-rlImageGlyphBlt (DrawablePtr pDrawable,
- GCPtr pGC,
- int x,
- int y,
- unsigned int nglyph,
- CharInfoPtr *ppciInit,
- pointer pglyphBase);
-
-/*
- * rlSolid.c
- */
-void
-rlSolid (ScreenPtr pScreen,
- FbBits *dst,
- FbStride dstStride,
- int dstX,
- int bpp,
-
- int width,
- int height,
-
- FbBits and,
- FbBits xor);
diff --git a/miext/rootless/accel/rlBlt.c b/miext/rootless/accel/rlBlt.c
deleted file mode 100644
index b5fe74085..000000000
--- a/miext/rootless/accel/rlBlt.c
+++ /dev/null
@@ -1,408 +0,0 @@
-/*
- * Accelerated rootless blit
- */
-/*
- * This code is largely copied from fbBlt.c.
- *
- * Copyright © 1998 Keith Packard
- * Copyright (c) 2002 Apple Computer, Inc. All Rights Reserved.
- * Copyright (c) 2003 Torrey T. Lyons. All Rights Reserved.
- *
- * 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 Keith Packard not be used in
- * advertising or publicity pertaining to distribution of the software without
- * specific, written prior permission. Keith Packard makes no
- * representations about the suitability of this software for any purpose. It
- * is provided "as is" without express or implied warranty.
- *
- * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
- * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
- * EVENT SHALL KEITH PACKARD 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_DIX_CONFIG_H
-#include <dix-config.h>
-#endif
-
-#include <stddef.h> /* For NULL */
-#include <string.h>
-#include "fb.h"
-#include "rootlessCommon.h"
-#include "rlAccel.h"
-
-#define InitializeShifts(sx,dx,ls,rs) { \
- if (sx != dx) { \
- if (sx > dx) { \
- ls = sx - dx; \
- rs = FB_UNIT - ls; \
- } else { \
- rs = dx - sx; \
- ls = FB_UNIT - rs; \
- } \
- } \
-}
-
-void
-rlBlt (FbBits *srcLine,
- FbStride srcStride,
- int srcX,
-
- ScreenPtr pDstScreen,
- FbBits *dstLine,
- FbStride dstStride,
- int dstX,
-
- int width,
- int height,
-
- int alu,
- FbBits pm,
- int bpp,
-
- Bool reverse,
- Bool upsidedown)
-{
- FbBits *src, *dst;
- int leftShift, rightShift;
- FbBits startmask, endmask;
- FbBits bits, bits1;
- int n, nmiddle;
- Bool destInvarient;
- int startbyte, endbyte;
- FbDeclareMergeRop ();
-
-#ifdef FB_24BIT
- if (bpp == 24 && !FbCheck24Pix (pm))
- {
- fbBlt24 (srcLine, srcStride, srcX, dstLine, dstStride, dstX,
- width, height, alu, pm, reverse, upsidedown);
- return;
- }
-#endif
-
- if (alu == GXcopy && pm == FB_ALLONES && !reverse &&
- !(srcX & 7) && !(dstX & 7) && !(width & 7)) {
- int i;
- CARD8 *src = (CARD8 *) srcLine;
- CARD8 *dst = (CARD8 *) dstLine;
-
- srcStride *= sizeof(FbBits);
- dstStride *= sizeof(FbBits);
- width >>= 3;
- src += (srcX >> 3);
- dst += (dstX >> 3);
-
- if (!upsidedown)
- for (i = 0; i < height; i++)
- memcpy(dst + i * dstStride, src + i * srcStride, width);
- else
- for (i = height - 1; i >= 0; i--)
- memcpy(dst + i * dstStride, src + i * srcStride, width);
-
- return;
- }
-
- FbInitializeMergeRop(alu, pm);
- destInvarient = FbDestInvarientMergeRop();
- if (upsidedown)
- {
- srcLine += (height - 1) * (srcStride);
- dstLine += (height - 1) * (dstStride);
- srcStride = -srcStride;
- dstStride = -dstStride;
- }
- FbMaskBitsBytes (dstX, width, destInvarient, startmask, startbyte,
- nmiddle, endmask, endbyte);
-
- /*
- * Beginning of the rootless acceleration code
- */
- if (!startmask && !endmask && alu == GXcopy &&
- height * nmiddle * sizeof(*dst) > rootless_CopyBytes_threshold)
- {
- if (pm == FB_ALLONES && SCREENREC(pDstScreen)->imp->CopyBytes)
- {
- SCREENREC(pDstScreen)->imp->CopyBytes(
- nmiddle * sizeof(*dst), height,
- (char *) srcLine + (srcX >> 3),
- srcStride * sizeof (*src),
- (char *) dstLine + (dstX >> 3),
- dstStride * sizeof (*dst));
- return;
- }
-
- /* FIXME: the pm test here isn't super-wonderful - just because
- we don't care about the top eight bits doesn't necessarily
- mean we want them set to 255. But doing this does give a
- factor of two performance improvement when copying from a
- pixmap to a window, which is pretty common.. */
-
- else if (bpp == 32 && sizeof(FbBits) == 4 &&
- pm == 0x00FFFFFFUL && !reverse &&
- SCREENREC(pDstScreen)->imp->CompositePixels)
- {
- /* need to copy XRGB to ARGB. */
-
- void *src[2], *dest[2];
- unsigned int src_rowbytes[2], dest_rowbytes[2];
- unsigned int fn;
-
- src[0] = (char *) srcLine + (srcX >> 3);
- src[1] = NULL;
- src_rowbytes[0] = srcStride * sizeof(*src);
- src_rowbytes[1] = 0;
-
- dest[0] = (char *) dstLine + (dstX >> 3);
- dest[1] = dest[0];
- dest_rowbytes[0] = dstStride * sizeof(*dst);
- dest_rowbytes[1] = dest_rowbytes[0];
-
- fn = RL_COMPOSITE_FUNCTION(RL_COMPOSITE_SRC, RL_DEPTH_ARGB8888,
- RL_DEPTH_NIL, RL_DEPTH_ARGB8888);
-
- if (SCREENREC(pDstScreen)->imp->CompositePixels(
- nmiddle, height,
- fn, src, src_rowbytes,
- NULL, 0, dest, dest_rowbytes) == Success)
- {
- return;
- }
- }
- }
- /* End of the rootless acceleration code */
-
- if (reverse)
- {
- srcLine += ((srcX + width - 1) >> FB_SHIFT) + 1;
- dstLine += ((dstX + width - 1) >> FB_SHIFT) + 1;
- srcX = (srcX + width - 1) & FB_MASK;
- dstX = (dstX + width - 1) & FB_MASK;
- }
- else
- {
- srcLine += srcX >> FB_SHIFT;
- dstLine += dstX >> FB_SHIFT;
- srcX &= FB_MASK;
- dstX &= FB_MASK;
- }
- if (srcX == dstX)
- {
- while (height--)
- {
- src = srcLine;
- srcLine += srcStride;
- dst = dstLine;
- dstLine += dstStride;
- if (reverse)
- {
- if (endmask)
- {
- bits = *--src;
- --dst;
- FbDoRightMaskByteMergeRop(dst, bits, endbyte, endmask);
- }
- n = nmiddle;
- if (destInvarient)
- {
- while (n--)
- *--dst = FbDoDestInvarientMergeRop(*--src);
- }
- else
- {
- while (n--)
- {
- bits = *--src;
- --dst;
- *dst = FbDoMergeRop (bits, *dst);
- }
- }
- if (startmask)
- {
- bits = *--src;
- --dst;
- FbDoLeftMaskByteMergeRop(dst, bits, startbyte, startmask);
- }
- }
- else
- {
- if (startmask)
- {
- bits = *src++;
- FbDoLeftMaskByteMergeRop(dst, bits, startbyte, startmask);
- dst++;
- }
- n = nmiddle;
- if (destInvarient)
- {
-#if 0
- /*
- * This provides some speedup on screen->screen blts
- * over the PCI bus, usually about 10%. But fb
- * isn't usually used for this operation...
- */
- if (_ca2 + 1 == 0 && _cx2 == 0)
- {
- FbBits t1, t2, t3, t4;
- while (n >= 4)
- {
- t1 = *src++;
- t2 = *src++;
- t3 = *src++;
- t4 = *src++;
- *dst++ = t1;
- *dst++ = t2;
- *dst++ = t3;
- *dst++ = t4;
- n -= 4;
- }
- }
-#endif
- while (n--)
- *dst++ = FbDoDestInvarientMergeRop(*src++);
- }
- else
- {
- while (n--)
- {
- bits = *src++;
- *dst = FbDoMergeRop (bits, *dst);
- dst++;
- }
- }
- if (endmask)
- {
- bits = *src;
- FbDoRightMaskByteMergeRop(dst, bits, endbyte, endmask);
- }
- }
- }
- }
- else
- {
- if (srcX > dstX)
- {
- leftShift = srcX - dstX;
- rightShift = FB_UNIT - leftShift;
- }
- else
- {
- rightShift = dstX - srcX;
- leftShift = FB_UNIT - rightShift;
- }
- while (height--)
- {
- src = srcLine;
- srcLine += srcStride;
- dst = dstLine;
- dstLine += dstStride;
-
- bits1 = 0;
- if (reverse)
- {
- if (srcX < dstX)
- bits1 = *--src;
- if (endmask)
- {
- bits = FbScrRight(bits1, rightShift);
- if (FbScrRight(endmask, leftShift))
- {
- bits1 = *--src;
- bits |= FbScrLeft(bits1, leftShift);
- }
- --dst;
- FbDoRightMaskByteMergeRop(dst, bits, endbyte, endmask);
- }
- n = nmiddle;
- if (destInvarient)
- {
- while (n--)
- {
- bits = FbScrRight(bits1, rightShift);
- bits1 = *--src;
- bits |= FbScrLeft(bits1, leftShift);
- --dst;
- *dst = FbDoDestInvarientMergeRop(bits);
- }
- }
- else
- {
- while (n--)
- {
- bits = FbScrRight(bits1, rightShift);
- bits1 = *--src;
- bits |= FbScrLeft(bits1, leftShift);
- --dst;
- *dst = FbDoMergeRop(bits, *dst);
- }
- }
- if (startmask)
- {
- bits = FbScrRight(bits1, rightShift);
- if (FbScrRight(startmask, leftShift))
- {
- bits1 = *--src;
- bits |= FbScrLeft(bits1, leftShift);
- }
- --dst;
- FbDoLeftMaskByteMergeRop (dst, bits, startbyte, startmask);
- }
- }
- else
- {
- if (srcX > dstX)
- bits1 = *src++;
- if (startmask)
- {
- bits = FbScrLeft(bits1, leftShift);
- if (FbScrLeft(startmask, rightShift))
- {
- bits1 = *src++;
- bits |= FbScrRight(bits1, rightShift);
- }
- FbDoLeftMaskByteMergeRop (dst, bits, startbyte, startmask);
- dst++;
- }
- n = nmiddle;
- if (destInvarient)
- {
- while (n--)
- {
- bits = FbScrLeft(bits1, leftShift);
- bits1 = *src++;
- bits |= FbScrRight(bits1, rightShift);
- *dst = FbDoDestInvarientMergeRop(bits);
- dst++;
- }
- }
- else
- {
- while (n--)
- {
- bits = FbScrLeft(bits1, leftShift);
- bits1 = *src++;
- bits |= FbScrRight(bits1, rightShift);
- *dst = FbDoMergeRop(bits, *dst);
- dst++;
- }
- }
- if (endmask)
- {
- bits = FbScrLeft(bits1, leftShift);
- if (FbScrLeft(endmask, rightShift))
- {
- bits1 = *src;
- bits |= FbScrRight(bits1, rightShift);
- }
- FbDoRightMaskByteMergeRop (dst, bits, endbyte, endmask);
- }
- }
- }
- }
-}
diff --git a/miext/rootless/accel/rlCopy.c b/miext/rootless/accel/rlCopy.c
deleted file mode 100644
index df6fc11a7..000000000
--- a/miext/rootless/accel/rlCopy.c
+++ /dev/null
@@ -1,106 +0,0 @@
-/*
- * This code is largely copied from fbcopy.c.
- *
- * Copyright © 1998 Keith Packard
- * Copyright (c) 2003 Torrey T. Lyons. All Rights Reserved.
- *
- * 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 Keith Packard not be used in
- * advertising or publicity pertaining to distribution of the software without
- * specific, written prior permission. Keith Packard makes no
- * representations about the suitability of this software for any purpose. It
- * is provided "as is" without express or implied warranty.
- *
- * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
- * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
- * EVENT SHALL KEITH PACKARD 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_DIX_CONFIG_H
-#include <dix-config.h>
-#endif
-
-#include "fb.h"
-#include "rlAccel.h"
-
-
-void
-rlCopyNtoN (DrawablePtr pSrcDrawable,
- DrawablePtr pDstDrawable,
- GCPtr pGC,
- BoxPtr pbox,
- int nbox,
- int dx,
- int dy,
- Bool reverse,
- Bool upsidedown,
- Pixel bitplane,
- void *closure)
-{
- CARD8 alu = pGC ? pGC->alu : GXcopy;
- FbBits pm = pGC ? fbGetGCPrivate(pGC)->pm : FB_ALLONES;
- FbBits *src;
- FbStride srcStride;
- int srcBpp;
- int srcXoff, srcYoff;
- FbBits *dst;
- FbStride dstStride;
- int dstBpp;
- int dstXoff, dstYoff;
-
- fbGetDrawable (pSrcDrawable, src, srcStride, srcBpp, srcXoff, srcYoff);
- fbGetDrawable (pDstDrawable, dst, dstStride, dstBpp, dstXoff, dstYoff);
-
- while (nbox--)
- {
- rlBlt (src + (pbox->y1 + dy + srcYoff) * srcStride,
- srcStride,
- (pbox->x1 + dx + srcXoff) * srcBpp,
-
- pDstDrawable->pScreen,
- dst + (pbox->y1 + dstYoff) * dstStride,
- dstStride,
- (pbox->x1 + dstXoff) * dstBpp,
-
- (pbox->x2 - pbox->x1) * dstBpp,
- (pbox->y2 - pbox->y1),
-
- alu,
- pm,
- dstBpp,
-
- reverse,
- upsidedown);
- pbox++;
- }
-}
-
-RegionPtr
-rlCopyArea (DrawablePtr pSrcDrawable,
- DrawablePtr pDstDrawable,
- GCPtr pGC,
- int xIn,
- int yIn,
- int widthSrc,
- int heightSrc,
- int xOut,
- int yOut)
-{
- fbCopyProc copy;
-
-#ifdef FB_24_32BIT
- if (pSrcDrawable->bitsPerPixel != pDstDrawable->bitsPerPixel)
- copy = fb24_32CopyMtoN;
- else
-#endif
- copy = rlCopyNtoN;
- return fbDoCopy (pSrcDrawable, pDstDrawable, pGC, xIn, yIn,
- widthSrc, heightSrc, xOut, yOut, copy, 0, 0);
-}
diff --git a/miext/rootless/accel/rlFill.c b/miext/rootless/accel/rlFill.c
deleted file mode 100644
index a80c7769f..000000000
--- a/miext/rootless/accel/rlFill.c
+++ /dev/null
@@ -1,220 +0,0 @@
-/*
- * This code is largely copied from fbfill.c.
- *
- * Copyright © 1998 Keith Packard
- * Copyright (c) 2003 Torrey T. Lyons. All Rights Reserved.
- *
- * 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 Keith Packard not be used in
- * advertising or publicity pertaining to distribution of the software without
- * specific, written prior permission. Keith Packard makes no
- * representations about the suitability of this software for any purpose. It
- * is provided "as is" without express or implied warranty.
- *
- * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
- * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
- * EVENT SHALL KEITH PACKARD 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_DIX_CONFIG_H
-#include <dix-config.h>
-#endif
-
-#include "fb.h"
-#include "rlAccel.h"
-
-
-void
-rlFill (DrawablePtr pDrawable,
- GCPtr pGC,
- int x,
- int y,
- int width,
- int height)
-{
- FbBits *dst;
- FbStride dstStride;
- int dstBpp;
- int dstXoff, dstYoff;
- FbGCPrivPtr pPriv = fbGetGCPrivate(pGC);
-
- fbGetDrawable (pDrawable, dst, dstStride, dstBpp, dstXoff, dstYoff);
-
- switch (pGC->fillStyle) {
- case FillSolid:
- rlSolid (pDrawable->pScreen,
- dst + (y + dstYoff) * dstStride,
- dstStride,
- (x + dstXoff) * dstBpp,
- dstBpp,
- width * dstBpp, height,
- pPriv->and, pPriv->xor);
- break;
- case FillStippled:
- case FillOpaqueStippled: {
- PixmapPtr pStip = pGC->stipple;
- int stipWidth = pStip->drawable.width;
- int stipHeight = pStip->drawable.height;
-
- if (dstBpp == 1)
- {
- int alu;
- FbBits *stip;
- FbStride stipStride;
- int stipBpp;
- int stipXoff, stipYoff; /* XXX assumed to be zero */
-
- if (pGC->fillStyle == FillStippled)
- alu = FbStipple1Rop(pGC->alu,pGC->fgPixel);
- else
- alu = FbOpaqueStipple1Rop(pGC->alu,pGC->fgPixel,pGC->bgPixel);
- fbGetDrawable (&pStip->drawable, stip, stipStride, stipBpp, stipXoff, stipYoff);
- fbTile (dst + (y + dstYoff) * dstStride,
- dstStride,
- x + dstXoff,
- width, height,
- stip,
- stipStride,
- stipWidth,
- stipHeight,
- alu,
- pPriv->pm,
- dstBpp,
-
- (pGC->patOrg.x + pDrawable->x + dstXoff),
- pGC->patOrg.y + pDrawable->y - y);
- }
- else
- {
- FbStip *stip;
- FbStride stipStride;
- int stipBpp;
- int stipXoff, stipYoff; /* XXX assumed to be zero */
- FbBits fgand, fgxor, bgand, bgxor;
-
- fgand = pPriv->and;
- fgxor = pPriv->xor;
- if (pGC->fillStyle == FillStippled)
- {
- bgand = fbAnd(GXnoop,(FbBits) 0,FB_ALLONES);
- bgxor = fbXor(GXnoop,(FbBits) 0,FB_ALLONES);
- }
- else
- {
- bgand = pPriv->bgand;
- bgxor = pPriv->bgxor;
- }
-
- fbGetStipDrawable (&pStip->drawable, stip, stipStride, stipBpp, stipXoff, stipYoff);
- fbStipple (dst + (y + dstYoff) * dstStride,
- dstStride,
- (x + dstXoff) * dstBpp,
- dstBpp,
- width * dstBpp, height,
- stip,
- stipStride,
- stipWidth,
- stipHeight,
- pPriv->evenStipple,
- fgand, fgxor,
- bgand, bgxor,
- pGC->patOrg.x + pDrawable->x + dstXoff,
- pGC->patOrg.y + pDrawable->y - y);
- }
- break;
- }
- case FillTiled: {
- PixmapPtr pTile = pGC->tile.pixmap;
- FbBits *tile;
- FbStride tileStride;
- int tileBpp;
- int tileWidth;
- int tileHeight;
- int tileXoff, tileYoff; /* XXX assumed to be zero */
-
- fbGetDrawable (&pTile->drawable, tile, tileStride, tileBpp, tileXoff, tileYoff);
- tileWidth = pTile->drawable.width;
- tileHeight = pTile->drawable.height;
- fbTile (dst + (y + dstYoff) * dstStride,
- dstStride,
- (x + dstXoff) * dstBpp,
- width * dstBpp, height,
- tile,
- tileStride,
- tileWidth * tileBpp,
- tileHeight,
- pGC->alu,
- pPriv->pm,
- dstBpp,
- (pGC->patOrg.x + pDrawable->x + dstXoff) * dstBpp,
- pGC->patOrg.y + pDrawable->y - y);
- break;
- }
- }
- fbValidateDrawable (pDrawable);
-}
-
-void
-rlSolidBoxClipped (DrawablePtr pDrawable,
- RegionPtr pClip,
- int x1,
- int y1,
- int x2,
- int y2,
- FbBits and,
- FbBits xor)
-{
- FbBits *dst;
- FbStride dstStride;
- int dstBpp;
- int dstXoff, dstYoff;
- BoxPtr pbox;
- int nbox;
- int partX1, partX2, partY1, partY2;
-
- fbGetDrawable (pDrawable, dst, dstStride, dstBpp, dstXoff, dstYoff);
-
- for (nbox = REGION_NUM_RECTS(pClip), pbox = REGION_RECTS(pClip);
- nbox--;
- pbox++)
- {
- partX1 = pbox->x1;
- if (partX1 < x1)
- partX1 = x1;
-
- partX2 = pbox->x2;
- if (partX2 > x2)
- partX2 = x2;
-
- if (partX2 <= partX1)
- continue;
-
- partY1 = pbox->y1;
- if (partY1 < y1)
- partY1 = y1;
-
- partY2 = pbox->y2;
- if (partY2 > y2)
- partY2 = y2;
-
- if (partY2 <= partY1)
- continue;
-
- rlSolid (pDrawable->pScreen,
- dst + (partY1 + dstYoff) * dstStride,
- dstStride,
- (partX1 + dstXoff) * dstBpp,
- dstBpp,
-
- (partX2 - partX1) * dstBpp,
- (partY2 - partY1),
- and, xor);
- }
-}
diff --git a/miext/rootless/accel/rlFillRect.c b/miext/rootless/accel/rlFillRect.c
deleted file mode 100644
index 6efed3bd9..000000000
--- a/miext/rootless/accel/rlFillRect.c
+++ /dev/null
@@ -1,117 +0,0 @@
-/*
- * This code is largely copied from fbfillrect.c.
- *
- * Copyright © 1998 Keith Packard
- * Copyright (c) 2003 Torrey T. Lyons. All Rights Reserved.
- *
- * 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 Keith Packard not be used in
- * advertising or publicity pertaining to distribution of the software without
- * specific, written prior permission. Keith Packard makes no
- * representations about the suitability of this software for any purpose. It
- * is provided "as is" without express or implied warranty.
- *
- * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
- * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
- * EVENT SHALL KEITH PACKARD 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_DIX_CONFIG_H
-#include <dix-config.h>
-#endif
-
-#include "fb.h"
-#include "rlAccel.h"
-
-
-void
-rlPolyFillRect(DrawablePtr pDrawable,
- GCPtr pGC,
- int nrect,
- xRectangle *prect)
-{
- RegionPtr pClip = fbGetCompositeClip(pGC);
- register BoxPtr pbox;
- BoxPtr pextent;
- int extentX1, extentX2, extentY1, extentY2;
- int fullX1, fullX2, fullY1, fullY2;
- int partX1, partX2, partY1, partY2;
- int xorg, yorg;
- int n;
-
- xorg = pDrawable->x;
- yorg = pDrawable->y;
-
- pextent = REGION_EXTENTS(pGC->pScreen, pClip);
- extentX1 = pextent->x1;
- extentY1 = pextent->y1;
- extentX2 = pextent->x2;
- extentY2 = pextent->y2;
- while (nrect--)
- {
- fullX1 = prect->x + xorg;
- fullY1 = prect->y + yorg;
- fullX2 = fullX1 + (int) prect->width;
- fullY2 = fullY1 + (int) prect->height;
- prect++;
-
- if (fullX1 < extentX1)
- fullX1 = extentX1;
-
- if (fullY1 < extentY1)
- fullY1 = extentY1;
-
- if (fullX2 > extentX2)
- fullX2 = extentX2;
-
- if (fullY2 > extentY2)
- fullY2 = extentY2;
-
- if ((fullX1 >= fullX2) || (fullY1 >= fullY2))
- continue;
- n = REGION_NUM_RECTS (pClip);
- if (n == 1)
- {
- rlFill (pDrawable,
- pGC,
- fullX1, fullY1, fullX2-fullX1, fullY2-fullY1);
- }
- else
- {
- pbox = REGION_RECTS(pClip);
- /*
- * clip the rectangle to each box in the clip region
- * this is logically equivalent to calling Intersect()
- */
- while(n--)
- {
- partX1 = pbox->x1;
- if (partX1 < fullX1)
- partX1 = fullX1;
- partY1 = pbox->y1;
- if (partY1 < fullY1)
- partY1 = fullY1;
- partX2 = pbox->x2;
- if (partX2 > fullX2)
- partX2 = fullX2;
- partY2 = pbox->y2;
- if (partY2 > fullY2)
- partY2 = fullY2;
-
- pbox++;
-
- if (partX1 < partX2 && partY1 < partY2)
- rlFill (pDrawable, pGC,
- partX1, partY1,
- partX2 - partX1, partY2 - partY1);
- }
- }
- }
-}
diff --git a/miext/rootless/accel/rlFillSpans.c b/miext/rootless/accel/rlFillSpans.c
deleted file mode 100644
index ab8bff065..000000000
--- a/miext/rootless/accel/rlFillSpans.c
+++ /dev/null
@@ -1,105 +0,0 @@
-/*
- * This code is largely copied from fbfillsp.c.
- *
- * Copyright © 1998 Keith Packard
- * Copyright (c) 2003 Torrey T. Lyons. All Rights Reserved.
- *
- * 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 Keith Packard not be used in
- * advertising or publicity pertaining to distribution of the software without
- * specific, written prior permission. Keith Packard makes no
- * representations about the suitability of this software for any purpose. It
- * is provided "as is" without express or implied warranty.
- *
- * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
- * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
- * EVENT SHALL KEITH PACKARD 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_DIX_CONFIG_H
-#include <dix-config.h>
-#endif
-
-#include "fb.h"
-#include "rlAccel.h"
-
-
-void
-rlFillSpans (DrawablePtr pDrawable,
- GCPtr pGC,
- int n,
- DDXPointPtr ppt,
- int *pwidth,
- int fSorted)
-{
- RegionPtr pClip = fbGetCompositeClip(pGC);
- BoxPtr pextent, pbox;
- int nbox;
- int extentX1, extentX2, extentY1, extentY2;
- int fullX1, fullX2, fullY1;
- int partX1, partX2;
-
- pextent = REGION_EXTENTS(pGC->pScreen, pClip);
- extentX1 = pextent->x1;
- extentY1 = pextent->y1;
- extentX2 = pextent->x2;
- extentY2 = pextent->y2;
- while (n--)
- {
- fullX1 = ppt->x;
- fullY1 = ppt->y;
- fullX2 = fullX1 + (int) *pwidth;
- ppt++;
- pwidth++;
-
- if (fullY1 < extentY1 || extentY2 <= fullY1)
- continue;
-
- if (fullX1 < extentX1)
- fullX1 = extentX1;
-
- if (fullX2 > extentX2)
- fullX2 = extentX2;
-
- if (fullX1 >= fullX2)
- continue;
-
- nbox = REGION_NUM_RECTS (pClip);
- if (nbox == 1)
- {
- rlFill (pDrawable,
- pGC,
- fullX1, fullY1, fullX2-fullX1, 1);
- }
- else
- {
- pbox = REGION_RECTS(pClip);
- while(nbox--)
- {
- if (pbox->y1 <= fullY1 && fullY1 < pbox->y2)
- {
- partX1 = pbox->x1;
- if (partX1 < fullX1)
- partX1 = fullX1;
- partX2 = pbox->x2;
- if (partX2 > fullX2)
- partX2 = fullX2;
- if (partX2 > partX1)
- {
- rlFill (pDrawable, pGC,
- partX1, fullY1,
- partX2 - partX1, 1);
- }
- }
- pbox++;
- }
- }
- }
-}
diff --git a/miext/rootless/accel/rlGlyph.c b/miext/rootless/accel/rlGlyph.c
deleted file mode 100644
index 82cd06c7f..000000000
--- a/miext/rootless/accel/rlGlyph.c
+++ /dev/null
@@ -1,169 +0,0 @@
-/*
- * This code is largely copied from fbglyph.c.
- *
- * Copyright © 1998 Keith Packard
- * Copyright (c) 2003 Torrey T. Lyons. All Rights Reserved.
- *
- * 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 Keith Packard not be used in
- * advertising or publicity pertaining to distribution of the software without
- * specific, written prior permission. Keith Packard makes no
- * representations about the suitability of this software for any purpose. It
- * is provided "as is" without express or implied warranty.
- *
- * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
- * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
- * EVENT SHALL KEITH PACKARD 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_DIX_CONFIG_H
-#include <dix-config.h>
-#endif
-
-#include "fb.h"
-#include <X11/fonts/fontstruct.h>
-#include "dixfontstr.h"
-#include "rlAccel.h"
-
-
-void
-rlImageGlyphBlt (DrawablePtr pDrawable,
- GCPtr pGC,
- int x,
- int y,
- unsigned int nglyph,
- CharInfoPtr *ppciInit,
- pointer pglyphBase)
-{
- FbGCPrivPtr pPriv = fbGetGCPrivate(pGC);
- CharInfoPtr *ppci;
- CharInfoPtr pci;
- unsigned char *pglyph; /* pointer bits in glyph */
- int gWidth, gHeight; /* width and height of glyph */
- FbStride gStride; /* stride of glyph */
- Bool opaque;
- int n;
- int gx, gy;
-#ifndef FBNOPIXADDR
- void (*glyph) (FbBits *,
- FbStride,
- int,
- FbStip *,
- FbBits,
- int,
- int);
- FbBits *dst = 0;
- FbStride dstStride = 0;
- int dstBpp = 0;
- int dstXoff = 0, dstYoff = 0;
-
- glyph = 0;
- if (pPriv->and == 0)
- {
- fbGetDrawable (pDrawable, dst, dstStride, dstBpp, dstXoff, dstYoff);
- switch (dstBpp) {
- case 8: glyph = fbGlyph8; break;
- case 16: glyph = fbGlyph16; break;
-#ifdef FB_24BIT
- case 24: glyph = fbGlyph24; break;
-#endif
- case 32: glyph = fbGlyph32; break;
- }
- }
-#endif
-
- x += pDrawable->x;
- y += pDrawable->y;
-
- if (TERMINALFONT (pGC->font)
-#ifndef FBNOPIXADDR
- && !glyph
-#endif
- )
- {
- opaque = TRUE;
- }
- else
- {
- int xBack, widthBack;
- int yBack, heightBack;
-
- ppci = ppciInit;
- n = nglyph;
- widthBack = 0;
- while (n--)
- widthBack += (*ppci++)->metrics.characterWidth;
-
- xBack = x;
- if (widthBack < 0)
- {
- xBack += widthBack;
- widthBack = -widthBack;
- }
- yBack = y - FONTASCENT(pGC->font);
- heightBack = FONTASCENT(pGC->font) + FONTDESCENT(pGC->font);
- rlSolidBoxClipped (pDrawable,
- fbGetCompositeClip(pGC),
- xBack,
- yBack,
- xBack + widthBack,
- yBack + heightBack,
- fbAnd(GXcopy,pPriv->bg,pPriv->pm),
- fbXor(GXcopy,pPriv->bg,pPriv->pm));
- opaque = FALSE;
- }
-
- ppci = ppciInit;
- while (nglyph--)
- {
- pci = *ppci++;
- pglyph = FONTGLYPHBITS(pglyphBase, pci);
- gWidth = GLYPHWIDTHPIXELS(pci);
- gHeight = GLYPHHEIGHTPIXELS(pci);
- if (gWidth && gHeight)
- {
- gx = x + pci->metrics.leftSideBearing;
- gy = y - pci->metrics.ascent;
-#ifndef FBNOPIXADDR
- if (glyph && gWidth <= sizeof (FbStip) * 8 &&
- fbGlyphIn (fbGetCompositeClip(pGC), gx, gy, gWidth, gHeight))
- {
- (*glyph) (dst + (gy + dstYoff) * dstStride,
- dstStride,
- dstBpp,
- (FbStip *) pglyph,
- pPriv->fg,
- gx + dstXoff,
- gHeight);
- }
- else
-#endif
- {
- gStride = GLYPHWIDTHBYTESPADDED(pci) / sizeof (FbStip);
- fbPutXYImage (pDrawable,
- fbGetCompositeClip(pGC),
- pPriv->fg,
- pPriv->bg,
- pPriv->pm,
- GXcopy,
- opaque,
-
- gx,
- gy,
- gWidth, gHeight,
-
- (FbStip *) pglyph,
- gStride,
- 0);
- }
- }
- x += pci->metrics.characterWidth;
- }
-}
diff --git a/miext/rootless/accel/rlSolid.c b/miext/rootless/accel/rlSolid.c
deleted file mode 100644
index fa4160f38..000000000
--- a/miext/rootless/accel/rlSolid.c
+++ /dev/null
@@ -1,111 +0,0 @@
-/*
- * Accelerated rootless fill
- */
-/*
- * This code is largely copied from fbsolid.c.
- *
- * Copyright © 1998 Keith Packard
- * Copyright (c) 2002 Apple Computer, Inc. All Rights Reserved.
- * Copyright (c) 2003 Torrey T. Lyons. All Rights Reserved.
- *
- * 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 Keith Packard not be used in
- * advertising or publicity pertaining to distribution of the software without
- * specific, written prior permission. Keith Packard makes no
- * representations about the suitability of this software for any purpose. It
- * is provided "as is" without express or implied warranty.
- *
- * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
- * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
- * EVENT SHALL KEITH PACKARD 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_DIX_CONFIG_H
-#include <dix-config.h>
-#endif
-
-#include "fb.h"
-#include "rootlessCommon.h"
-
-
-void
-rlSolid (ScreenPtr pScreen,
- FbBits *dst,
- FbStride dstStride,
- int dstX,
- int bpp,
-
- int width,
- int height,
-
- FbBits and,
- FbBits xor)
-{
- FbBits startmask, endmask;
- int n, nmiddle;
- int startbyte, endbyte;
-
-#ifdef FB_24BIT
- if (bpp == 24 && (!FbCheck24Pix(and) || !FbCheck24Pix(xor)))
- {
- fbSolid24 (dst, dstStride, dstX, width, height, and, xor);
- return;
- }
-#endif
-
- dst += dstX >> FB_SHIFT;
- dstX &= FB_MASK;
- FbMaskBitsBytes(dstX, width, and == 0, startmask, startbyte,
- nmiddle, endmask, endbyte);
-
- /*
- * Beginning of the rootless acceleration code
- */
- if (!startmask && !endmask && !and &&
- height * nmiddle * sizeof (*dst) > rootless_FillBytes_threshold &&
- SCREENREC(pScreen)->imp->FillBytes)
- {
- if (bpp <= 8)
- xor |= xor << 8;
- if (bpp <= 16)
- xor |= xor << 16;
-
- SCREENREC(pScreen)->imp->FillBytes(nmiddle * sizeof (*dst), height,
- xor, (char *) dst + (dstX >> 3),
- dstStride * sizeof (*dst));
- return;
- }
- /* End of the rootless acceleration code */
-
- if (startmask)
- dstStride--;
- dstStride -= nmiddle;
- while (height--)
- {
- if (startmask)
- {
- FbDoLeftMaskByteRRop(dst,startbyte,startmask,and,xor);
- dst++;
- }
- n = nmiddle;
- if (!and)
- while (n--)
- *dst++ = xor;
- else
- while (n--)
- {
- *dst = FbDoRRop (*dst, and, xor);
- dst++;
- }
- if (endmask)
- FbDoRightMaskByteRRop(dst,endbyte,endmask,and,xor);
- dst += dstStride;
- }
-}
diff --git a/miext/rootless/rootlessConfig.h b/miext/rootless/rootlessConfig.h
index ab0187e83..50bac3f51 100644
--- a/miext/rootless/rootlessConfig.h
+++ b/miext/rootless/rootlessConfig.h
@@ -36,12 +36,12 @@
#ifdef __APPLE__
-# define ROOTLESS_ACCEL TRUE
# define ROOTLESS_GLOBAL_COORDS TRUE
# define ROOTLESS_PROTECT_ALPHA TRUE
# define ROOTLESS_REDISPLAY_DELAY 10
# define ROOTLESS_RESIZE_GRAVITY TRUE
# undef ROOTLESS_TRACK_DAMAGE
+/*# define ROOTLESSDEBUG*/
/* Bit mask for alpha channel with a particular number of bits per
pixel. Note that we only care for 32bpp data. Mac OS X uses planar
@@ -52,7 +52,6 @@
#if defined(__CYGWIN__) || defined(WIN32)
-# define ROOTLESS_ACCEL YES
# define ROOTLESS_GLOBAL_COORDS TRUE
# define ROOTLESS_PROTECT_ALPHA NO
# define ROOTLESS_REDISPLAY_DELAY 10
diff --git a/miext/rootless/rootlessGC.c b/miext/rootless/rootlessGC.c
index c80b11f1d..1c787b6ad 100644
--- a/miext/rootless/rootlessGC.c
+++ b/miext/rootless/rootlessGC.c
@@ -118,7 +118,7 @@ static GCOps rootlessGCOps = {
/*
There are two issues we must contend with when drawing. These are
- controlled with ROOTLESS_PROTECT_ALPHA and ROOTLESS_ACCEL.
+ controlled with ROOTLESS_PROTECT_ALPHA and RootlessAccelInit().
If ROOTLESS_PROTECT_ALPHA is set, we have to make sure that the alpha
channel of the on screen windows is always opaque. fb makes this harder
@@ -141,9 +141,9 @@ static GCOps rootlessGCOps = {
from another window since its alpha channel must also be opaque.
The other issue to consider is that the rootless implementation may
- provide accelerated drawing functions if ROOTLESS_ACCEL is set. For some
- drawing primitives we swap in rootless acceleration functions, which use
- the accelerated drawing functions where possible.
+ provide accelerated drawing functions if RootlessAccelInit() is called.For
+ some drawing primitives we swap in rootless acceleration functions, which
+ use the accelerated drawing functions where possible.
Where both alpha protection and acceleration is used, it is even a bigger
win to relax the planemask to all ones because most accelerated drawing
diff --git a/miext/rootless/rootlessWindow.c b/miext/rootless/rootlessWindow.c
index 17fe69085..df1d3a879 100644
--- a/miext/rootless/rootlessWindow.c
+++ b/miext/rootless/rootlessWindow.c
@@ -131,36 +131,38 @@ RootlessNativeWindowStateChanged (WindowPtr pWin, unsigned int state)
pWin->rootlessUnhittable = winRec->is_offscreen;
}
-void
-RootlessNativeWindowMoved (WindowPtr pWin)
-{
- xp_box bounds;
- int sx, sy;
- XID vlist[2];
- Mask mask;
- ClientPtr client;
- RootlessWindowRec *winRec = WINREC(pWin);
-
- if (xp_get_window_bounds ((xp_window_id)winRec->wid, &bounds) != Success) return;
-
- sx = dixScreenOrigins[pWin->drawable.pScreen->myNum].x + darwinMainScreenX;
- sy = dixScreenOrigins[pWin->drawable.pScreen->myNum].y + darwinMainScreenY;
-
- /* Fake up a ConfigureWindow packet to resize the window to the current bounds. */
-
- vlist[0] = (INT16) bounds.x1 - sx;
- vlist[1] = (INT16) bounds.y1 - sy;
- mask = CWX | CWY;
-
- /* pretend we're the owner of the window! */
- client = LookupClient (pWin->drawable.id, NullClient);
-
- /* Don't want to do anything to the physical window (avoids
+void RootlessNativeWindowMoved (WindowPtr pWin) {
+ xp_box bounds;
+ int sx, sy, err;
+ XID vlist[2];
+ Mask mask;
+ ClientPtr client, pClient;
+ RootlessWindowRec *winRec = WINREC(pWin);
+
+ if (xp_get_window_bounds ((xp_window_id)winRec->wid, &bounds) != Success) return;
+
+ sx = dixScreenOrigins[pWin->drawable.pScreen->myNum].x + darwinMainScreenX;
+ sy = dixScreenOrigins[pWin->drawable.pScreen->myNum].y + darwinMainScreenY;
+
+ /* Fake up a ConfigureWindow packet to resize the window to the current bounds. */
+
+ vlist[0] = (INT16) bounds.x1 - sx;
+ vlist[1] = (INT16) bounds.y1 - sy;
+ mask = CWX | CWY;
+
+ /* pretend we're the owner of the window! */
+ err = dixLookupClient(&pClient, pWin->drawable.id, NullClient, DixUnknownAccess);
+ if(err != Success) {
+ ErrorF("RootlessNativeWindowMoved(): Failed to lookup window: 0x%x\n", pWin->drawable.id);
+ return;
+ }
+
+ /* Don't want to do anything to the physical window (avoids
notification-response feedback loops) */
-
- no_configure_window = TRUE;
- ConfigureWindow (pWin, mask, vlist, client);
- no_configure_window = FALSE;
+
+ no_configure_window = TRUE;
+ ConfigureWindow (pWin, mask, vlist, client);
+ no_configure_window = FALSE;
}
/* Updates the _NATIVE_SCREEN_ORIGIN property on the given root window. */
@@ -1427,7 +1429,7 @@ RootlessReparentWindow(WindowPtr pWin, WindowPtr pPriorParent)
pWin->rootlessUnhittable = FALSE;
- DeleteProperty (pWin, xa_native_window_id ());
+ DeleteProperty (serverClient, pWin, xa_native_window_id ());
if (WINREC(pTopWin) != NULL) {
/* We're screwed. */
diff --git a/os/connection.c b/os/connection.c
index 1ae50fef0..396593698 100644
--- a/os/connection.c
+++ b/os/connection.c
@@ -139,9 +139,6 @@ SOFTWARE.
#include <X11/Xpoll.h>
#include "opaque.h"
#include "dixstruct.h"
-#ifdef XAPPGROUP
-#include "appgroup.h"
-#endif
#include "xace.h"
#ifdef X_NOT_POSIX
diff --git a/os/utils.c b/os/utils.c
index d785d46d2..07296dfc5 100644
--- a/os/utils.c
+++ b/os/utils.c
@@ -149,9 +149,6 @@ _X_EXPORT Bool noDbeExtension = FALSE;
#ifdef DPMSExtension
_X_EXPORT Bool noDPMSExtension = FALSE;
#endif
-#ifdef EVI
-_X_EXPORT Bool noEVIExtension = FALSE;
-#endif
#ifdef FONTCACHE
_X_EXPORT Bool noFontCacheExtension = FALSE;
#endif
@@ -165,9 +162,6 @@ _X_EXPORT Bool noScreenSaverExtension = FALSE;
#ifdef MITSHM
_X_EXPORT Bool noMITShmExtension = FALSE;
#endif
-#ifdef MITMISC
-_X_EXPORT Bool noMITMiscExtension = FALSE;
-#endif
#ifdef MULTIBUFFER
_X_EXPORT Bool noMultibufferExtension = FALSE;
#endif
@@ -186,15 +180,9 @@ _X_EXPORT Bool noSecurityExtension = FALSE;
#ifdef XSYNC
_X_EXPORT Bool noSyncExtension = FALSE;
#endif
-#ifdef TOGCUP
-_X_EXPORT Bool noXcupExtension = FALSE;
-#endif
#ifdef RES
_X_EXPORT Bool noResExtension = FALSE;
#endif
-#ifdef XAPPGROUP
-_X_EXPORT Bool noXagExtension = FALSE;
-#endif
#ifdef XCMISC
_X_EXPORT Bool noXCMiscExtension = FALSE;
#endif
diff --git a/xkb/xkbActions.c b/xkb/xkbActions.c
index 8c72874df..f226b6bda 100644
--- a/xkb/xkbActions.c
+++ b/xkb/xkbActions.c
@@ -1031,7 +1031,7 @@ _XkbFilterDeviceBtn( XkbSrvInfoPtr xkbi,
DeviceIntPtr dev;
int button;
- if (dev == inputInfo.keyboard)
+ if (xkbi->device == inputInfo.keyboard)
return 0;
if (filter->keycode==0) { /* initial press */
diff --git a/xorg-server.pc.in b/xorg-server.pc.in
index 53b4ed28c..139adf487 100644
--- a/xorg-server.pc.in
+++ b/xorg-server.pc.in
@@ -14,6 +14,6 @@ abi_font=@abi_font@
Name: xorg-server
Description: Modular X.Org X Server
Version: @PACKAGE_VERSION@
-Requires: pixman-1
+Requires: pixman-1 pciaccess
Cflags: -I${sdkdir}
Libs: -L${libdir}