aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormarha <marha@users.sourceforge.net>2011-05-16 08:06:12 +0000
committermarha <marha@users.sourceforge.net>2011-05-16 08:06:12 +0000
commit08cbf3b50bfe713044f36b363c73768cd042f13c (patch)
tree6be4c5dd7f5bc2f058228b2a2fa747a4d7666dc5
parentd8c3e3d2ba88d6b87a718aef7f4fb4627113eb52 (diff)
downloadvcxsrv-08cbf3b50bfe713044f36b363c73768cd042f13c.tar.gz
vcxsrv-08cbf3b50bfe713044f36b363c73768cd042f13c.tar.bz2
vcxsrv-08cbf3b50bfe713044f36b363c73768cd042f13c.zip
xserver xkeyboar-config mesa git update 16 May 2011
-rw-r--r--mesalib/configure.ac4
-rw-r--r--mesalib/docs/relnotes-7.11.html1
-rw-r--r--mesalib/src/gallium/auxiliary/util/u_math.h1304
-rw-r--r--mesalib/src/gallium/auxiliary/util/u_vbuf_mgr.c1258
-rw-r--r--mesalib/src/mesa/state_tracker/st_atom_sampler.c186
-rw-r--r--mesalib/src/mesa/state_tracker/st_atom_texture.c185
-rw-r--r--mesalib/src/mesa/state_tracker/st_cb_drawpixels.c7
-rw-r--r--mesalib/src/mesa/state_tracker/st_context.c3
-rw-r--r--mesalib/src/mesa/state_tracker/st_context.h557
-rw-r--r--mesalib/src/mesa/state_tracker/st_extensions.c4
-rw-r--r--xorg-server/Makefile.am192
-rw-r--r--xorg-server/Xext/xtest.c5
-rw-r--r--xorg-server/Xi/exevents.c205
-rw-r--r--xorg-server/Xi/xichangehierarchy.c2
-rw-r--r--xorg-server/Xi/xiqueryversion.c7
-rw-r--r--xorg-server/composite/compalloc.c147
-rw-r--r--xorg-server/composite/compint.h669
-rw-r--r--xorg-server/composite/compwindow.c1651
-rw-r--r--xorg-server/configure.ac4496
-rw-r--r--xorg-server/dbe/dbe.c3319
-rw-r--r--xorg-server/devbook.am62
-rw-r--r--xorg-server/dix/devices.c10
-rw-r--r--xorg-server/dix/eventconvert.c2
-rw-r--r--xorg-server/dix/events.c664
-rw-r--r--xorg-server/dix/getevents.c204
-rw-r--r--xorg-server/dix/inpututils.c28
-rw-r--r--xorg-server/doc/Makefile.am18
-rw-r--r--xorg-server/doc/Xinput.xml1209
-rw-r--r--xorg-server/doc/Xserver-spec.xml (renamed from xorg-server/doc/xml/Xserver-spec.xml)0
-rw-r--r--xorg-server/doc/dtrace/Makefile.am17
-rw-r--r--xorg-server/doc/dtrace/Xserver-DTrace.xml (renamed from xorg-server/doc/xml/dtrace/Xserver-DTrace.xml)0
-rw-r--r--xorg-server/doc/xml/Makefile.am30
-rw-r--r--xorg-server/doc/xml/dtrace/Makefile.am36
-rw-r--r--xorg-server/doc/xml/xmlrules-inst.in23
-rw-r--r--xorg-server/doc/xml/xmlrules-noinst.in22
-rw-r--r--xorg-server/doc/xml/xmlrules.in47
-rw-r--r--xorg-server/docbook.am96
-rw-r--r--xorg-server/hw/dmx/Makefile.am2
-rw-r--r--xorg-server/hw/dmx/dmxwindow.c2034
-rw-r--r--xorg-server/hw/dmx/doc/Makefile.am311
-rw-r--r--xorg-server/hw/dmx/doc/doxygen.conf.in1053
-rw-r--r--xorg-server/hw/dmx/doc/doxygen.css49
-rw-r--r--xorg-server/hw/dmx/doc/doxygen.foot12
-rw-r--r--xorg-server/hw/dmx/doc/doxygen.head8
-rw-r--r--xorg-server/hw/dmx/doxygen/Makefile.am (renamed from xorg-server/hw/xfree86/doc/sgml/Makefile.am)63
-rw-r--r--xorg-server/hw/dmx/doxygen/doxygen.conf.in1559
-rw-r--r--xorg-server/hw/dmx/doxygen/footer.html4
-rw-r--r--xorg-server/hw/dmx/input/dmxevents.c66
-rw-r--r--xorg-server/hw/kdrive/src/kinput.c23
-rw-r--r--xorg-server/hw/xfree86/Makefile.am236
-rw-r--r--xorg-server/hw/xfree86/common/xf86Events.c6
-rw-r--r--xorg-server/hw/xfree86/common/xf86Init.c2
-rw-r--r--xorg-server/hw/xfree86/common/xf86Priv.h3
-rw-r--r--xorg-server/hw/xfree86/common/xf86Xinput.c43
-rw-r--r--xorg-server/hw/xfree86/doc/Makefile.am22
-rw-r--r--xorg-server/hw/xfree86/doc/README.DRIcomp (renamed from xorg-server/hw/xfree86/doc/devel/README.DRIcomp)0
-rw-r--r--xorg-server/hw/xfree86/doc/Registry (renamed from xorg-server/hw/xfree86/doc/devel/Registry)0
-rw-r--r--xorg-server/hw/xfree86/doc/ddxDesign.xml (renamed from xorg-server/hw/xfree86/doc/sgml/DESIGN.xml)18788
-rw-r--r--xorg-server/hw/xfree86/doc/devel/Makefile.am7
-rw-r--r--xorg-server/hw/xfree86/doc/exa-driver.txt (renamed from xorg-server/hw/xfree86/doc/devel/exa-driver.txt)0
-rw-r--r--xorg-server/hw/xfree86/dri2/dri2.c7
-rw-r--r--xorg-server/hw/xnest/Events.c36
-rw-r--r--xorg-server/hw/xnest/Init.c4
-rw-r--r--xorg-server/hw/xquartz/Makefile.am6
-rw-r--r--xorg-server/hw/xquartz/X11Application.h3
-rw-r--r--xorg-server/hw/xquartz/applewmExt.h6
-rw-r--r--xorg-server/hw/xquartz/console_redirect.c418
-rw-r--r--xorg-server/hw/xquartz/console_redirect.h44
-rw-r--r--xorg-server/hw/xquartz/darwinEvents.c21
-rw-r--r--xorg-server/hw/xquartz/mach-startup/Makefile.am1
-rw-r--r--xorg-server/hw/xquartz/mach-startup/bundle-main.c56
-rw-r--r--xorg-server/hw/xquartz/mach-startup/launchd_fd.c18
-rw-r--r--xorg-server/hw/xquartz/mach-startup/stub.c69
-rw-r--r--xorg-server/hw/xquartz/man/Xquartz.man63
-rw-r--r--xorg-server/hw/xquartz/quartzKeyboard.c6
-rw-r--r--xorg-server/hw/xquartz/sanitizedCocoa.h39
-rw-r--r--xorg-server/hw/xquartz/xpr/xprFrame.c20
-rw-r--r--xorg-server/hw/xwin/winkeybd.c9
-rw-r--r--xorg-server/hw/xwin/winmouse.c761
-rw-r--r--xorg-server/include/dix.h4
-rw-r--r--xorg-server/include/eventstr.h4
-rw-r--r--xorg-server/include/input.h50
-rw-r--r--xorg-server/include/inputstr.h10
-rw-r--r--xorg-server/include/inpututils.h82
-rw-r--r--xorg-server/include/misc.h622
-rw-r--r--xorg-server/man/Makefile.am (renamed from xorg-server/doc/man/Makefile.am)0
-rw-r--r--xorg-server/man/Xserver.man (renamed from xorg-server/doc/man/Xserver.man)0
-rw-r--r--xorg-server/manpages.am2
-rw-r--r--xorg-server/mi/mieq.c57
-rw-r--r--xorg-server/mi/mipointer.c5
-rw-r--r--xorg-server/os/log.c7
-rw-r--r--xorg-server/randr/rrdispatch.c8
-rw-r--r--xorg-server/record/record.c5872
-rw-r--r--xorg-server/test/Makefile.am3
-rw-r--r--xorg-server/test/misc.c62
-rw-r--r--xorg-server/xfixes/xfixes.c588
-rw-r--r--xorg-server/xkb/xkb.c51
-rw-r--r--xorg-server/xkb/xkbActions.c2868
-rw-r--r--xorg-server/xkb/xkbEvents.c43
-rw-r--r--xorg-server/xkeyboard-config/rules/base.extras.xml.in16
-rw-r--r--xorg-server/xkeyboard-config/rules/base.xml.in97
-rw-r--r--xorg-server/xkeyboard-config/symbols/Makefile.am82
-rw-r--r--xorg-server/xkeyboard-config/symbols/cm331
-rw-r--r--xorg-server/xkeyboard-config/symbols/latin431
-rw-r--r--xorg-server/xkeyboard-config/symbols/pl50
-rw-r--r--xorg-server/xserver.ent.in (renamed from xorg-server/doc/xml/xserver.ent.in)0
106 files changed, 28404 insertions, 25489 deletions
diff --git a/mesalib/configure.ac b/mesalib/configure.ac
index 54d9c2968..c705d4505 100644
--- a/mesalib/configure.ac
+++ b/mesalib/configure.ac
@@ -1194,12 +1194,12 @@ if test "x$enable_egl" = xyes; then
EGL_DRIVERS_DIRS="glx"
fi
+ PKG_CHECK_MODULES([LIBUDEV], [libudev > 150],
+ [have_libudev=yes],[have_libudev=no])
if test "$mesa_driver" = dri; then
# build egl_dri2 when xcb-dri2 is available
PKG_CHECK_MODULES([XCB_DRI2], [x11-xcb xcb-dri2 xcb-xfixes],
[have_xcb_dri2=yes],[have_xcb_dri2=no])
- PKG_CHECK_MODULES([LIBUDEV], [libudev > 150],
- [have_libudev=yes],[have_libudev=no])
if test "$have_xcb_dri2" = yes; then
EGL_DRIVER_DRI2=dri2
diff --git a/mesalib/docs/relnotes-7.11.html b/mesalib/docs/relnotes-7.11.html
index 1c22b082e..f2ff9c7c5 100644
--- a/mesalib/docs/relnotes-7.11.html
+++ b/mesalib/docs/relnotes-7.11.html
@@ -45,6 +45,7 @@ tbd
<li>GL_ARB_robustness (all drivers)
<li>GL_ARB_sampler_objects (gallium drivers)
<li>GL_ARB_seamless_cube_map (gallium r600)
+<li>GL_ARB_shader_texture_lod (gallium drivers)
<li>GL_ARB_sync (gallium drivers only, intel support was in 7.6)
<li>GL_ARB_texture_compression_rgtc (gallium drivers, swrast, i965)
<li>GL_ARB_texture_float (gallium, i965)
diff --git a/mesalib/src/gallium/auxiliary/util/u_math.h b/mesalib/src/gallium/auxiliary/util/u_math.h
index 16a9eab6d..2ecade5f7 100644
--- a/mesalib/src/gallium/auxiliary/util/u_math.h
+++ b/mesalib/src/gallium/auxiliary/util/u_math.h
@@ -1,660 +1,644 @@
-/**************************************************************************
- *
- * Copyright 2008 Tungsten Graphics, 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 TUNGSTEN GRAPHICS 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.
- *
- **************************************************************************/
-
-
-/**
- * Math utilities and approximations for common math functions.
- * Reduced precision is usually acceptable in shaders...
- *
- * "fast" is used in the names of functions which are low-precision,
- * or at least lower-precision than the normal C lib functions.
- */
-
-
-#ifndef U_MATH_H
-#define U_MATH_H
-
-
-#include "pipe/p_compiler.h"
-#include "util/u_debug.h"
-
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-
-#if defined(PIPE_SUBSYSTEM_WINDOWS_MINIPORT)
-__inline double ceil(double val)
-{
- double ceil_val;
-
- if ((val - (long) val) == 0) {
- ceil_val = val;
- }
- else {
- if (val > 0) {
- ceil_val = (long) val + 1;
- }
- else {
- ceil_val = (long) val;
- }
- }
-
- return ceil_val;
-}
-
-#ifndef PIPE_SUBSYSTEM_WINDOWS_CE_OGL
-__inline double floor(double val)
-{
- double floor_val;
-
- if ((val - (long) val) == 0) {
- floor_val = val;
- }
- else {
- if (val > 0) {
- floor_val = (long) val;
- }
- else {
- floor_val = (long) val - 1;
- }
- }
-
- return floor_val;
-}
-#endif
-
-#pragma function(pow)
-__inline double __cdecl pow(double val, double exponent)
-{
- /* XXX */
- assert(0);
- return 0;
-}
-
-#pragma function(log)
-__inline double __cdecl log(double val)
-{
- /* XXX */
- assert(0);
- return 0;
-}
-
-#pragma function(atan2)
-__inline double __cdecl atan2(double val)
-{
- /* XXX */
- assert(0);
- return 0;
-}
-#else
-#include <math.h>
-#include <stdarg.h>
-#endif
-
-
-#ifndef M_SQRT2
-#define M_SQRT2 1.41421356237309504880
-#endif
-
-
-#if defined(_MSC_VER)
-
-#if _MSC_VER < 1400 && !defined(__cplusplus) || defined(PIPE_SUBSYSTEM_WINDOWS_CE)
-
-static INLINE float cosf( float f )
-{
- return (float) cos( (double) f );
-}
-
-static INLINE float sinf( float f )
-{
- return (float) sin( (double) f );
-}
-
-static INLINE float ceilf( float f )
-{
- return (float) ceil( (double) f );
-}
-
-static INLINE float floorf( float f )
-{
- return (float) floor( (double) f );
-}
-
-static INLINE float powf( float f, float g )
-{
- return (float) pow( (double) f, (double) g );
-}
-
-static INLINE float sqrtf( float f )
-{
- return (float) sqrt( (double) f );
-}
-
-static INLINE float fabsf( float f )
-{
- return (float) fabs( (double) f );
-}
-
-static INLINE float logf( float f )
-{
- return (float) log( (double) f );
-}
-
-#else
-/* Work-around an extra semi-colon in VS 2005 logf definition */
-#ifdef logf
-#undef logf
-#define logf(x) ((float)log((double)(x)))
-#endif /* logf */
-
-#define isfinite(x) _finite((double)(x))
-#define isnan(x) _isnan((double)(x))
-#endif /* _MSC_VER < 1400 && !defined(__cplusplus) */
-
-static INLINE double log2( double x )
-{
- const double invln2 = 1.442695041;
- return log( x ) * invln2;
-}
-
-static INLINE double
-round(double x)
-{
- return x >= 0.0 ? floor(x + 0.5) : ceil(x - 0.5);
-}
-
-static INLINE float
-roundf(float x)
-{
- return x >= 0.0f ? floorf(x + 0.5f) : ceilf(x - 0.5f);
-}
-
-#endif /* _MSC_VER */
-
-
-
-
-
-#define POW2_TABLE_SIZE_LOG2 9
-#define POW2_TABLE_SIZE (1 << POW2_TABLE_SIZE_LOG2)
-#define POW2_TABLE_OFFSET (POW2_TABLE_SIZE/2)
-#define POW2_TABLE_SCALE ((float)(POW2_TABLE_SIZE/2))
-extern float pow2_table[POW2_TABLE_SIZE];
-
-
-/**
- * Initialize math module. This should be called before using any
- * other functions in this module.
- */
-extern void
-util_init_math(void);
-
-
-union fi {
- float f;
- int32_t i;
- uint32_t ui;
-};
-
-
-/**
- * Fast version of 2^x
- * Identity: exp2(a + b) = exp2(a) * exp2(b)
- * Let ipart = int(x)
- * Let fpart = x - ipart;
- * So, exp2(x) = exp2(ipart) * exp2(fpart)
- * Compute exp2(ipart) with i << ipart
- * Compute exp2(fpart) with lookup table.
- */
-static INLINE float
-util_fast_exp2(float x)
-{
- int32_t ipart;
- float fpart, mpart;
- union fi epart;
-
- if(x > 129.00000f)
- return 3.402823466e+38f;
-
- if (x < -126.99999f)
- return 0.0f;
-
- ipart = (int32_t) x;
- fpart = x - (float) ipart;
-
- /* same as
- * epart.f = (float) (1 << ipart)
- * but faster and without integer overflow for ipart > 31
- */
- epart.i = (ipart + 127 ) << 23;
-
- mpart = pow2_table[POW2_TABLE_OFFSET + (int)(fpart * POW2_TABLE_SCALE)];
-
- return epart.f * mpart;
-}
-
-
-/**
- * Fast approximation to exp(x).
- */
-static INLINE float
-util_fast_exp(float x)
-{
- const float k = 1.44269f; /* = log2(e) */
- return util_fast_exp2(k * x);
-}
-
-
-#define LOG2_TABLE_SIZE_LOG2 16
-#define LOG2_TABLE_SCALE (1 << LOG2_TABLE_SIZE_LOG2)
-#define LOG2_TABLE_SIZE (LOG2_TABLE_SCALE + 1)
-extern float log2_table[LOG2_TABLE_SIZE];
-
-
-/**
- * Fast approximation to log2(x).
- */
-static INLINE float
-util_fast_log2(float x)
-{
- union fi num;
- float epart, mpart;
- num.f = x;
- epart = (float)(((num.i & 0x7f800000) >> 23) - 127);
- /* mpart = log2_table[mantissa*LOG2_TABLE_SCALE + 0.5] */
- mpart = log2_table[((num.i & 0x007fffff) + (1 << (22 - LOG2_TABLE_SIZE_LOG2))) >> (23 - LOG2_TABLE_SIZE_LOG2)];
- return epart + mpart;
-}
-
-
-/**
- * Fast approximation to x^y.
- */
-static INLINE float
-util_fast_pow(float x, float y)
-{
- return util_fast_exp2(util_fast_log2(x) * y);
-}
-
-/* Note that this counts zero as a power of two.
- */
-static INLINE boolean
-util_is_power_of_two( unsigned v )
-{
- return (v & (v-1)) == 0;
-}
-
-
-/**
- * Floor(x), returned as int.
- */
-static INLINE int
-util_ifloor(float f)
-{
- int ai, bi;
- double af, bf;
- union fi u;
- af = (3 << 22) + 0.5 + (double) f;
- bf = (3 << 22) + 0.5 - (double) f;
- u.f = (float) af; ai = u.i;
- u.f = (float) bf; bi = u.i;
- return (ai - bi) >> 1;
-}
-
-
-/**
- * Round float to nearest int.
- */
-static INLINE int
-util_iround(float f)
-{
-#if defined(PIPE_CC_GCC) && defined(PIPE_ARCH_X86)
- int r;
- __asm__ ("fistpl %0" : "=m" (r) : "t" (f) : "st");
- return r;
-#elif defined(PIPE_CC_MSVC) && defined(PIPE_ARCH_X86)
- int r;
- _asm {
- fld f
- fistp r
- }
- return r;
-#else
- if (f >= 0.0f)
- return (int) (f + 0.5f);
- else
- return (int) (f - 0.5f);
-#endif
-}
-
-
-/**
- * Approximate floating point comparison
- */
-static INLINE boolean
-util_is_approx(float a, float b, float tol)
-{
- return fabs(b - a) <= tol;
-}
-
-
-/**
- * Test if x is NaN or +/- infinity.
- */
-static INLINE boolean
-util_is_inf_or_nan(float x)
-{
- union fi tmp;
- tmp.f = x;
- return !(int)((unsigned int)((tmp.i & 0x7fffffff)-0x7f800000) >> 31);
-}
-
-
-/**
- * Find first bit set in word. Least significant bit is 1.
- * Return 0 if no bits set.
- */
-#if defined(_MSC_VER) && _MSC_VER >= 1300 && (_M_IX86 || _M_AMD64 || _M_IA64)
-unsigned char _BitScanForward(unsigned long* Index, unsigned long Mask);
-#pragma intrinsic(_BitScanForward)
-static INLINE
-unsigned long ffs( unsigned long u )
-{
- unsigned long i;
- if (_BitScanForward(&i, u))
- return i + 1;
- else
- return 0;
-}
-#elif defined(PIPE_CC_MSVC) && defined(PIPE_ARCH_X86)
-static INLINE
-unsigned ffs( unsigned u )
-{
- unsigned i;
-
- if (u == 0) {
- return 0;
- }
-
- __asm bsf eax, [u]
- __asm inc eax
- __asm mov [i], eax
-
- return i;
-}
-#elif defined(__MINGW32__)
-#define ffs __builtin_ffs
-#endif
-
-#ifdef __MINGW32__
-#define ffs __builtin_ffs
-#endif
-
-
-/* Could also binary search for the highest bit.
- */
-static INLINE unsigned
-util_unsigned_logbase2(unsigned n)
-{
- unsigned log2 = 0;
- while (n >>= 1)
- ++log2;
- return log2;
-}
-
-
-/**
- * Return float bits.
- */
-static INLINE unsigned
-fui( float f )
-{
- union fi fi;
- fi.f = f;
- return fi.ui;
-}
-
-
-/**
- * Convert ubyte to float in [0, 1].
- * XXX a 256-entry lookup table would be slightly faster.
- */
-static INLINE float
-ubyte_to_float(ubyte ub)
-{
- return (float) ub * (1.0f / 255.0f);
-}
-
-
-/**
- * Convert float in [0,1] to ubyte in [0,255] with clamping.
- */
-static INLINE ubyte
-float_to_ubyte(float f)
-{
- const int ieee_0996 = 0x3f7f0000; /* 0.996 or so */
- union fi tmp;
-
- tmp.f = f;
- if (tmp.i < 0) {
- return (ubyte) 0;
- }
- else if (tmp.i >= ieee_0996) {
- return (ubyte) 255;
- }
- else {
- tmp.f = tmp.f * (255.0f/256.0f) + 32768.0f;
- return (ubyte) tmp.i;
- }
-}
-
-static INLINE float
-byte_to_float_tex(int8_t b)
-{
- return (b == -128) ? -1.0F : b * 1.0F / 127.0F;
-}
-
-static INLINE int8_t
-float_to_byte_tex(float f)
-{
- return (int8_t) (127.0F * f);
-}
-
-/**
- * Calc log base 2
- */
-static INLINE unsigned
-util_logbase2(unsigned n)
-{
- unsigned log2 = 0;
- while (n >>= 1)
- ++log2;
- return log2;
-}
-
-
-/**
- * Returns the smallest power of two >= x
- */
-static INLINE unsigned
-util_next_power_of_two(unsigned x)
-{
- unsigned i;
-
- if (x == 0)
- return 1;
-
- --x;
-
- for (i = 1; i < sizeof(unsigned) * 8; i <<= 1)
- x |= x >> i;
-
- return x + 1;
-}
-
-
-/**
- * Return number of bits set in n.
- */
-static INLINE unsigned
-util_bitcount(unsigned n)
-{
-#if defined(PIPE_CC_GCC)
- return __builtin_popcount(n);
-#else
- /* K&R classic bitcount.
- *
- * For each iteration, clear the LSB from the bitfield.
- * Requires only one iteration per set bit, instead of
- * one iteration per bit less than highest set bit.
- */
- unsigned bits = 0;
- for (bits; n; bits++) {
- n &= n - 1;
- }
- return bits;
-#endif
-}
-
-
-/**
- * Reverse byte order of a 32 bit word.
- */
-static INLINE uint32_t
-util_bswap32(uint32_t n)
-{
-#if defined(PIPE_CC_GCC) && (PIPE_CC_GCC_VERSION >= 403)
- return __builtin_bswap32(n);
-#else
- return (n >> 24) |
- ((n >> 8) & 0x0000ff00) |
- ((n << 8) & 0x00ff0000) |
- (n << 24);
-#endif
-}
-
-
-/**
- * Reverse byte order of a 16 bit word.
- */
-static INLINE uint16_t
-util_bswap16(uint16_t n)
-{
- return (n >> 8) |
- (n << 8);
-}
-
-
-/**
- * Clamp X to [MIN, MAX].
- * This is a macro to allow float, int, uint, etc. types.
- */
-#define CLAMP( X, MIN, MAX ) ( (X)<(MIN) ? (MIN) : ((X)>(MAX) ? (MAX) : (X)) )
-
-#define MIN2( A, B ) ( (A)<(B) ? (A) : (B) )
-#define MAX2( A, B ) ( (A)>(B) ? (A) : (B) )
-
-#define MIN3( A, B, C ) ((A) < (B) ? MIN2(A, C) : MIN2(B, C))
-#define MAX3( A, B, C ) ((A) > (B) ? MAX2(A, C) : MAX2(B, C))
-
-#define MIN4( A, B, C, D ) ((A) < (B) ? MIN3(A, C, D) : MIN3(B, C, D))
-#define MAX4( A, B, C, D ) ((A) > (B) ? MAX3(A, C, D) : MAX3(B, C, D))
-
-
-/**
- * Align a value, only works pot alignemnts.
- */
-static INLINE int
-align(int value, int alignment)
-{
- return (value + alignment - 1) & ~(alignment - 1);
-}
-
-/**
- * Works like align but on npot alignments.
- */
-static INLINE size_t
-util_align_npot(size_t value, size_t alignment)
-{
- if (value % alignment)
- return value + (alignment - (value % alignment));
- return value;
-}
-
-static INLINE unsigned
-u_minify(unsigned value, unsigned levels)
-{
- return MAX2(1, value >> levels);
-}
-
-#ifndef COPY_4V
-#define COPY_4V( DST, SRC ) \
-do { \
- (DST)[0] = (SRC)[0]; \
- (DST)[1] = (SRC)[1]; \
- (DST)[2] = (SRC)[2]; \
- (DST)[3] = (SRC)[3]; \
-} while (0)
-#endif
-
-
-#ifndef COPY_4FV
-#define COPY_4FV( DST, SRC ) COPY_4V(DST, SRC)
-#endif
-
-
-#ifndef ASSIGN_4V
-#define ASSIGN_4V( DST, V0, V1, V2, V3 ) \
-do { \
- (DST)[0] = (V0); \
- (DST)[1] = (V1); \
- (DST)[2] = (V2); \
- (DST)[3] = (V3); \
-} while (0)
-#endif
-
-
-static INLINE uint32_t util_unsigned_fixed(float value, unsigned frac_bits)
-{
- return value < 0 ? 0 : (uint32_t)(value * (1<<frac_bits));
-}
-
-static INLINE int32_t util_signed_fixed(float value, unsigned frac_bits)
-{
- return (int32_t)(value * (1<<frac_bits));
-}
-
-
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* U_MATH_H */
+/**************************************************************************
+ *
+ * Copyright 2008 Tungsten Graphics, 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 TUNGSTEN GRAPHICS 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.
+ *
+ **************************************************************************/
+
+
+/**
+ * Math utilities and approximations for common math functions.
+ * Reduced precision is usually acceptable in shaders...
+ *
+ * "fast" is used in the names of functions which are low-precision,
+ * or at least lower-precision than the normal C lib functions.
+ */
+
+
+#ifndef U_MATH_H
+#define U_MATH_H
+
+
+#include "pipe/p_compiler.h"
+#include "util/u_debug.h"
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+#if defined(PIPE_SUBSYSTEM_WINDOWS_MINIPORT)
+__inline double ceil(double val)
+{
+ double ceil_val;
+
+ if ((val - (long) val) == 0) {
+ ceil_val = val;
+ }
+ else {
+ if (val > 0) {
+ ceil_val = (long) val + 1;
+ }
+ else {
+ ceil_val = (long) val;
+ }
+ }
+
+ return ceil_val;
+}
+
+#ifndef PIPE_SUBSYSTEM_WINDOWS_CE_OGL
+__inline double floor(double val)
+{
+ double floor_val;
+
+ if ((val - (long) val) == 0) {
+ floor_val = val;
+ }
+ else {
+ if (val > 0) {
+ floor_val = (long) val;
+ }
+ else {
+ floor_val = (long) val - 1;
+ }
+ }
+
+ return floor_val;
+}
+#endif
+
+#pragma function(pow)
+__inline double __cdecl pow(double val, double exponent)
+{
+ /* XXX */
+ assert(0);
+ return 0;
+}
+
+#pragma function(log)
+__inline double __cdecl log(double val)
+{
+ /* XXX */
+ assert(0);
+ return 0;
+}
+
+#pragma function(atan2)
+__inline double __cdecl atan2(double val)
+{
+ /* XXX */
+ assert(0);
+ return 0;
+}
+#else
+#include <math.h>
+#include <stdarg.h>
+#endif
+
+
+#ifndef M_SQRT2
+#define M_SQRT2 1.41421356237309504880
+#endif
+
+
+#if defined(_MSC_VER)
+
+#if _MSC_VER < 1400 && !defined(__cplusplus) || defined(PIPE_SUBSYSTEM_WINDOWS_CE)
+
+static INLINE float cosf( float f )
+{
+ return (float) cos( (double) f );
+}
+
+static INLINE float sinf( float f )
+{
+ return (float) sin( (double) f );
+}
+
+static INLINE float ceilf( float f )
+{
+ return (float) ceil( (double) f );
+}
+
+static INLINE float floorf( float f )
+{
+ return (float) floor( (double) f );
+}
+
+static INLINE float powf( float f, float g )
+{
+ return (float) pow( (double) f, (double) g );
+}
+
+static INLINE float sqrtf( float f )
+{
+ return (float) sqrt( (double) f );
+}
+
+static INLINE float fabsf( float f )
+{
+ return (float) fabs( (double) f );
+}
+
+static INLINE float logf( float f )
+{
+ return (float) log( (double) f );
+}
+
+#else
+/* Work-around an extra semi-colon in VS 2005 logf definition */
+#ifdef logf
+#undef logf
+#define logf(x) ((float)log((double)(x)))
+#endif /* logf */
+
+#define isfinite(x) _finite((double)(x))
+#define isnan(x) _isnan((double)(x))
+#endif /* _MSC_VER < 1400 && !defined(__cplusplus) */
+
+static INLINE double log2( double x )
+{
+ const double invln2 = 1.442695041;
+ return log( x ) * invln2;
+}
+
+static INLINE double
+round(double x)
+{
+ return x >= 0.0 ? floor(x + 0.5) : ceil(x - 0.5);
+}
+
+static INLINE float
+roundf(float x)
+{
+ return x >= 0.0f ? floorf(x + 0.5f) : ceilf(x - 0.5f);
+}
+
+#endif /* _MSC_VER */
+
+
+
+
+
+#define POW2_TABLE_SIZE_LOG2 9
+#define POW2_TABLE_SIZE (1 << POW2_TABLE_SIZE_LOG2)
+#define POW2_TABLE_OFFSET (POW2_TABLE_SIZE/2)
+#define POW2_TABLE_SCALE ((float)(POW2_TABLE_SIZE/2))
+extern float pow2_table[POW2_TABLE_SIZE];
+
+
+/**
+ * Initialize math module. This should be called before using any
+ * other functions in this module.
+ */
+extern void
+util_init_math(void);
+
+
+union fi {
+ float f;
+ int32_t i;
+ uint32_t ui;
+};
+
+
+/**
+ * Fast version of 2^x
+ * Identity: exp2(a + b) = exp2(a) * exp2(b)
+ * Let ipart = int(x)
+ * Let fpart = x - ipart;
+ * So, exp2(x) = exp2(ipart) * exp2(fpart)
+ * Compute exp2(ipart) with i << ipart
+ * Compute exp2(fpart) with lookup table.
+ */
+static INLINE float
+util_fast_exp2(float x)
+{
+ int32_t ipart;
+ float fpart, mpart;
+ union fi epart;
+
+ if(x > 129.00000f)
+ return 3.402823466e+38f;
+
+ if (x < -126.99999f)
+ return 0.0f;
+
+ ipart = (int32_t) x;
+ fpart = x - (float) ipart;
+
+ /* same as
+ * epart.f = (float) (1 << ipart)
+ * but faster and without integer overflow for ipart > 31
+ */
+ epart.i = (ipart + 127 ) << 23;
+
+ mpart = pow2_table[POW2_TABLE_OFFSET + (int)(fpart * POW2_TABLE_SCALE)];
+
+ return epart.f * mpart;
+}
+
+
+/**
+ * Fast approximation to exp(x).
+ */
+static INLINE float
+util_fast_exp(float x)
+{
+ const float k = 1.44269f; /* = log2(e) */
+ return util_fast_exp2(k * x);
+}
+
+
+#define LOG2_TABLE_SIZE_LOG2 16
+#define LOG2_TABLE_SCALE (1 << LOG2_TABLE_SIZE_LOG2)
+#define LOG2_TABLE_SIZE (LOG2_TABLE_SCALE + 1)
+extern float log2_table[LOG2_TABLE_SIZE];
+
+
+/**
+ * Fast approximation to log2(x).
+ */
+static INLINE float
+util_fast_log2(float x)
+{
+ union fi num;
+ float epart, mpart;
+ num.f = x;
+ epart = (float)(((num.i & 0x7f800000) >> 23) - 127);
+ /* mpart = log2_table[mantissa*LOG2_TABLE_SCALE + 0.5] */
+ mpart = log2_table[((num.i & 0x007fffff) + (1 << (22 - LOG2_TABLE_SIZE_LOG2))) >> (23 - LOG2_TABLE_SIZE_LOG2)];
+ return epart + mpart;
+}
+
+
+/**
+ * Fast approximation to x^y.
+ */
+static INLINE float
+util_fast_pow(float x, float y)
+{
+ return util_fast_exp2(util_fast_log2(x) * y);
+}
+
+/* Note that this counts zero as a power of two.
+ */
+static INLINE boolean
+util_is_power_of_two( unsigned v )
+{
+ return (v & (v-1)) == 0;
+}
+
+
+/**
+ * Floor(x), returned as int.
+ */
+static INLINE int
+util_ifloor(float f)
+{
+ int ai, bi;
+ double af, bf;
+ union fi u;
+ af = (3 << 22) + 0.5 + (double) f;
+ bf = (3 << 22) + 0.5 - (double) f;
+ u.f = (float) af; ai = u.i;
+ u.f = (float) bf; bi = u.i;
+ return (ai - bi) >> 1;
+}
+
+
+/**
+ * Round float to nearest int.
+ */
+static INLINE int
+util_iround(float f)
+{
+#if defined(PIPE_CC_GCC) && defined(PIPE_ARCH_X86)
+ int r;
+ __asm__ ("fistpl %0" : "=m" (r) : "t" (f) : "st");
+ return r;
+#elif defined(PIPE_CC_MSVC) && defined(PIPE_ARCH_X86)
+ int r;
+ _asm {
+ fld f
+ fistp r
+ }
+ return r;
+#else
+ if (f >= 0.0f)
+ return (int) (f + 0.5f);
+ else
+ return (int) (f - 0.5f);
+#endif
+}
+
+
+/**
+ * Approximate floating point comparison
+ */
+static INLINE boolean
+util_is_approx(float a, float b, float tol)
+{
+ return fabs(b - a) <= tol;
+}
+
+
+/**
+ * Test if x is NaN or +/- infinity.
+ */
+static INLINE boolean
+util_is_inf_or_nan(float x)
+{
+ union fi tmp;
+ tmp.f = x;
+ return !(int)((unsigned int)((tmp.i & 0x7fffffff)-0x7f800000) >> 31);
+}
+
+
+/**
+ * Find first bit set in word. Least significant bit is 1.
+ * Return 0 if no bits set.
+ */
+#if defined(_MSC_VER) && _MSC_VER >= 1300 && (_M_IX86 || _M_AMD64 || _M_IA64)
+unsigned char _BitScanForward(unsigned long* Index, unsigned long Mask);
+#pragma intrinsic(_BitScanForward)
+static INLINE
+unsigned long ffs( unsigned long u )
+{
+ unsigned long i;
+ if (_BitScanForward(&i, u))
+ return i + 1;
+ else
+ return 0;
+}
+#elif defined(PIPE_CC_MSVC) && defined(PIPE_ARCH_X86)
+static INLINE
+unsigned ffs( unsigned u )
+{
+ unsigned i;
+
+ if (u == 0) {
+ return 0;
+ }
+
+ __asm bsf eax, [u]
+ __asm inc eax
+ __asm mov [i], eax
+
+ return i;
+}
+#elif defined(__MINGW32__)
+#define ffs __builtin_ffs
+#endif
+
+
+/**
+ * Return float bits.
+ */
+static INLINE unsigned
+fui( float f )
+{
+ union fi fi;
+ fi.f = f;
+ return fi.ui;
+}
+
+
+/**
+ * Convert ubyte to float in [0, 1].
+ * XXX a 256-entry lookup table would be slightly faster.
+ */
+static INLINE float
+ubyte_to_float(ubyte ub)
+{
+ return (float) ub * (1.0f / 255.0f);
+}
+
+
+/**
+ * Convert float in [0,1] to ubyte in [0,255] with clamping.
+ */
+static INLINE ubyte
+float_to_ubyte(float f)
+{
+ const int ieee_0996 = 0x3f7f0000; /* 0.996 or so */
+ union fi tmp;
+
+ tmp.f = f;
+ if (tmp.i < 0) {
+ return (ubyte) 0;
+ }
+ else if (tmp.i >= ieee_0996) {
+ return (ubyte) 255;
+ }
+ else {
+ tmp.f = tmp.f * (255.0f/256.0f) + 32768.0f;
+ return (ubyte) tmp.i;
+ }
+}
+
+static INLINE float
+byte_to_float_tex(int8_t b)
+{
+ return (b == -128) ? -1.0F : b * 1.0F / 127.0F;
+}
+
+static INLINE int8_t
+float_to_byte_tex(float f)
+{
+ return (int8_t) (127.0F * f);
+}
+
+/**
+ * Calc log base 2
+ */
+static INLINE unsigned
+util_logbase2(unsigned n)
+{
+ unsigned log2 = 0;
+ while (n >>= 1)
+ ++log2;
+ return log2;
+}
+
+
+/**
+ * Returns the smallest power of two >= x
+ */
+static INLINE unsigned
+util_next_power_of_two(unsigned x)
+{
+ unsigned i;
+
+ if (x == 0)
+ return 1;
+
+ --x;
+
+ for (i = 1; i < sizeof(unsigned) * 8; i <<= 1)
+ x |= x >> i;
+
+ return x + 1;
+}
+
+
+/**
+ * Return number of bits set in n.
+ */
+static INLINE unsigned
+util_bitcount(unsigned n)
+{
+#if defined(PIPE_CC_GCC)
+ return __builtin_popcount(n);
+#else
+ /* K&R classic bitcount.
+ *
+ * For each iteration, clear the LSB from the bitfield.
+ * Requires only one iteration per set bit, instead of
+ * one iteration per bit less than highest set bit.
+ */
+ unsigned bits = 0;
+ for (bits; n; bits++) {
+ n &= n - 1;
+ }
+ return bits;
+#endif
+}
+
+
+/**
+ * Reverse byte order of a 32 bit word.
+ */
+static INLINE uint32_t
+util_bswap32(uint32_t n)
+{
+#if defined(PIPE_CC_GCC) && (PIPE_CC_GCC_VERSION >= 403)
+ return __builtin_bswap32(n);
+#else
+ return (n >> 24) |
+ ((n >> 8) & 0x0000ff00) |
+ ((n << 8) & 0x00ff0000) |
+ (n << 24);
+#endif
+}
+
+
+/**
+ * Reverse byte order of a 16 bit word.
+ */
+static INLINE uint16_t
+util_bswap16(uint16_t n)
+{
+ return (n >> 8) |
+ (n << 8);
+}
+
+
+/**
+ * Clamp X to [MIN, MAX].
+ * This is a macro to allow float, int, uint, etc. types.
+ */
+#define CLAMP( X, MIN, MAX ) ( (X)<(MIN) ? (MIN) : ((X)>(MAX) ? (MAX) : (X)) )
+
+#define MIN2( A, B ) ( (A)<(B) ? (A) : (B) )
+#define MAX2( A, B ) ( (A)>(B) ? (A) : (B) )
+
+#define MIN3( A, B, C ) ((A) < (B) ? MIN2(A, C) : MIN2(B, C))
+#define MAX3( A, B, C ) ((A) > (B) ? MAX2(A, C) : MAX2(B, C))
+
+#define MIN4( A, B, C, D ) ((A) < (B) ? MIN3(A, C, D) : MIN3(B, C, D))
+#define MAX4( A, B, C, D ) ((A) > (B) ? MAX3(A, C, D) : MAX3(B, C, D))
+
+
+/**
+ * Align a value, only works pot alignemnts.
+ */
+static INLINE int
+align(int value, int alignment)
+{
+ return (value + alignment - 1) & ~(alignment - 1);
+}
+
+/**
+ * Works like align but on npot alignments.
+ */
+static INLINE size_t
+util_align_npot(size_t value, size_t alignment)
+{
+ if (value % alignment)
+ return value + (alignment - (value % alignment));
+ return value;
+}
+
+static INLINE unsigned
+u_minify(unsigned value, unsigned levels)
+{
+ return MAX2(1, value >> levels);
+}
+
+#ifndef COPY_4V
+#define COPY_4V( DST, SRC ) \
+do { \
+ (DST)[0] = (SRC)[0]; \
+ (DST)[1] = (SRC)[1]; \
+ (DST)[2] = (SRC)[2]; \
+ (DST)[3] = (SRC)[3]; \
+} while (0)
+#endif
+
+
+#ifndef COPY_4FV
+#define COPY_4FV( DST, SRC ) COPY_4V(DST, SRC)
+#endif
+
+
+#ifndef ASSIGN_4V
+#define ASSIGN_4V( DST, V0, V1, V2, V3 ) \
+do { \
+ (DST)[0] = (V0); \
+ (DST)[1] = (V1); \
+ (DST)[2] = (V2); \
+ (DST)[3] = (V3); \
+} while (0)
+#endif
+
+
+static INLINE uint32_t util_unsigned_fixed(float value, unsigned frac_bits)
+{
+ return value < 0 ? 0 : (uint32_t)(value * (1<<frac_bits));
+}
+
+static INLINE int32_t util_signed_fixed(float value, unsigned frac_bits)
+{
+ return (int32_t)(value * (1<<frac_bits));
+}
+
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* U_MATH_H */
diff --git a/mesalib/src/gallium/auxiliary/util/u_vbuf_mgr.c b/mesalib/src/gallium/auxiliary/util/u_vbuf_mgr.c
index 9306fcd5c..a034483ee 100644
--- a/mesalib/src/gallium/auxiliary/util/u_vbuf_mgr.c
+++ b/mesalib/src/gallium/auxiliary/util/u_vbuf_mgr.c
@@ -1,613 +1,645 @@
-/**************************************************************************
- *
- * Copyright 2011 Marek Olšák <maraeo@gmail.com>
- * 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 AUTHORS 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.
- *
- **************************************************************************/
-
-#include "util/u_vbuf_mgr.h"
-
-#include "util/u_format.h"
-#include "util/u_inlines.h"
-#include "util/u_memory.h"
-#include "util/u_upload_mgr.h"
-#include "translate/translate.h"
-#include "translate/translate_cache.h"
-
-/* Hardware vertex fetcher limitations can be described by this structure. */
-struct u_vbuf_caps {
- /* Vertex format CAPs. */
- /* TRUE if hardware supports it. */
- unsigned format_fixed32:1; /* PIPE_FORMAT_*32*_FIXED */
- unsigned format_float16:1; /* PIPE_FORMAT_*16*_FLOAT */
- unsigned format_float64:1; /* PIPE_FORMAT_*64*_FLOAT */
- unsigned format_norm32:1; /* PIPE_FORMAT_*32*NORM */
- unsigned format_scaled32:1; /* PIPE_FORMAT_*32*SCALED */
-
- /* Whether vertex fetches don't have to be dword-aligned. */
- /* TRUE if hardware supports it. */
- unsigned fetch_dword_unaligned:1;
-};
-
-struct u_vbuf_mgr_elements {
- unsigned count;
- struct pipe_vertex_element ve[PIPE_MAX_ATTRIBS];
-
- /* If (velem[i].src_format != real_format[i]), the vertex buffer
- * referenced by the vertex element cannot be used for rendering and
- * its vertex data must be translated to real_format[i]. */
- enum pipe_format native_format[PIPE_MAX_ATTRIBS];
- unsigned native_format_size[PIPE_MAX_ATTRIBS];
-
- /* This might mean two things:
- * - src_format != native_format, as discussed above.
- * - src_offset % 4 != 0 (if the caps don't allow such an offset). */
- boolean incompatible_layout;
-};
-
-struct u_vbuf_mgr_priv {
- struct u_vbuf_mgr b;
- struct u_vbuf_caps caps;
- struct pipe_context *pipe;
-
- struct translate_cache *translate_cache;
- unsigned translate_vb_slot;
-
- struct u_vbuf_mgr_elements *ve;
- void *saved_ve, *fallback_ve;
- boolean ve_binding_lock;
-
- boolean any_user_vbs;
- boolean incompatible_vb_layout;
-};
-
-static void u_vbuf_mgr_init_format_caps(struct u_vbuf_mgr_priv *mgr)
-{
- struct pipe_screen *screen = mgr->pipe->screen;
-
- mgr->caps.format_fixed32 =
- screen->is_format_supported(screen, PIPE_FORMAT_R32_FIXED, PIPE_BUFFER,
- 0, PIPE_BIND_VERTEX_BUFFER);
-
- mgr->caps.format_float16 =
- screen->is_format_supported(screen, PIPE_FORMAT_R16_FLOAT, PIPE_BUFFER,
- 0, PIPE_BIND_VERTEX_BUFFER);
-
- mgr->caps.format_float64 =
- screen->is_format_supported(screen, PIPE_FORMAT_R64_FLOAT, PIPE_BUFFER,
- 0, PIPE_BIND_VERTEX_BUFFER);
-
- mgr->caps.format_norm32 =
- screen->is_format_supported(screen, PIPE_FORMAT_R32_UNORM, PIPE_BUFFER,
- 0, PIPE_BIND_VERTEX_BUFFER) &&
- screen->is_format_supported(screen, PIPE_FORMAT_R32_SNORM, PIPE_BUFFER,
- 0, PIPE_BIND_VERTEX_BUFFER);
-
- mgr->caps.format_scaled32 =
- screen->is_format_supported(screen, PIPE_FORMAT_R32_USCALED, PIPE_BUFFER,
- 0, PIPE_BIND_VERTEX_BUFFER) &&
- screen->is_format_supported(screen, PIPE_FORMAT_R32_SSCALED, PIPE_BUFFER,
- 0, PIPE_BIND_VERTEX_BUFFER);
-}
-
-struct u_vbuf_mgr *
-u_vbuf_mgr_create(struct pipe_context *pipe,
- unsigned upload_buffer_size,
- unsigned upload_buffer_alignment,
- unsigned upload_buffer_bind,
- enum u_fetch_alignment fetch_alignment)
-{
- struct u_vbuf_mgr_priv *mgr = CALLOC_STRUCT(u_vbuf_mgr_priv);
-
- mgr->pipe = pipe;
- mgr->translate_cache = translate_cache_create();
-
- mgr->b.uploader = u_upload_create(pipe, upload_buffer_size,
- upload_buffer_alignment,
- upload_buffer_bind);
-
- mgr->caps.fetch_dword_unaligned =
- fetch_alignment == U_VERTEX_FETCH_BYTE_ALIGNED;
-
- u_vbuf_mgr_init_format_caps(mgr);
-
- return &mgr->b;
-}
-
-void u_vbuf_mgr_destroy(struct u_vbuf_mgr *mgrb)
-{
- struct u_vbuf_mgr_priv *mgr = (struct u_vbuf_mgr_priv*)mgrb;
- unsigned i;
-
- for (i = 0; i < mgr->b.nr_real_vertex_buffers; i++) {
- pipe_resource_reference(&mgr->b.vertex_buffer[i].buffer, NULL);
- pipe_resource_reference(&mgr->b.real_vertex_buffer[i], NULL);
- }
-
- translate_cache_destroy(mgr->translate_cache);
- u_upload_destroy(mgr->b.uploader);
- FREE(mgr);
-}
-
-
-static void u_vbuf_translate_begin(struct u_vbuf_mgr_priv *mgr,
- int min_index, int max_index,
- boolean *upload_flushed)
-{
- struct translate_key key;
- struct translate_element *te;
- unsigned tr_elem_index[PIPE_MAX_ATTRIBS];
- struct translate *tr;
- boolean vb_translated[PIPE_MAX_ATTRIBS] = {0};
- uint8_t *vb_map[PIPE_MAX_ATTRIBS] = {0}, *out_map;
- struct pipe_transfer *vb_transfer[PIPE_MAX_ATTRIBS] = {0};
- struct pipe_resource *out_buffer = NULL;
- unsigned i, num_verts, out_offset;
- struct pipe_vertex_element new_velems[PIPE_MAX_ATTRIBS];
-
- memset(&key, 0, sizeof(key));
- memset(tr_elem_index, 0xff, sizeof(tr_elem_index));
-
- /* Initialize the translate key, i.e. the recipe how vertices should be
- * translated. */
- memset(&key, 0, sizeof key);
- for (i = 0; i < mgr->ve->count; i++) {
- struct pipe_vertex_buffer *vb =
- &mgr->b.vertex_buffer[mgr->ve->ve[i].vertex_buffer_index];
- enum pipe_format output_format = mgr->ve->native_format[i];
- unsigned output_format_size = mgr->ve->native_format_size[i];
-
- /* Check for support. */
- if (mgr->ve->ve[i].src_format == mgr->ve->native_format[i] &&
- (mgr->caps.fetch_dword_unaligned ||
- (vb->buffer_offset % 4 == 0 &&
- vb->stride % 4 == 0 &&
- mgr->ve->ve[i].src_offset % 4 == 0))) {
- continue;
- }
-
- /* Workaround for translate: output floats instead of halfs. */
- switch (output_format) {
- case PIPE_FORMAT_R16_FLOAT:
- output_format = PIPE_FORMAT_R32_FLOAT;
- output_format_size = 4;
- break;
- case PIPE_FORMAT_R16G16_FLOAT:
- output_format = PIPE_FORMAT_R32G32_FLOAT;
- output_format_size = 8;
- break;
- case PIPE_FORMAT_R16G16B16_FLOAT:
- output_format = PIPE_FORMAT_R32G32B32_FLOAT;
- output_format_size = 12;
- break;
- case PIPE_FORMAT_R16G16B16A16_FLOAT:
- output_format = PIPE_FORMAT_R32G32B32A32_FLOAT;
- output_format_size = 16;
- break;
- default:;
- }
-
- /* Add this vertex element. */
- te = &key.element[key.nr_elements];
- /*te->type;
- te->instance_divisor;*/
- te->input_buffer = mgr->ve->ve[i].vertex_buffer_index;
- te->input_format = mgr->ve->ve[i].src_format;
- te->input_offset = mgr->ve->ve[i].src_offset;
- te->output_format = output_format;
- te->output_offset = key.output_stride;
-
- key.output_stride += output_format_size;
- vb_translated[mgr->ve->ve[i].vertex_buffer_index] = TRUE;
- tr_elem_index[i] = key.nr_elements;
- key.nr_elements++;
- }
-
- /* Get a translate object. */
- tr = translate_cache_find(mgr->translate_cache, &key);
-
- /* Map buffers we want to translate. */
- for (i = 0; i < mgr->b.nr_vertex_buffers; i++) {
- if (vb_translated[i]) {
- struct pipe_vertex_buffer *vb = &mgr->b.vertex_buffer[i];
-
- vb_map[i] = pipe_buffer_map(mgr->pipe, vb->buffer,
- PIPE_TRANSFER_READ, &vb_transfer[i]);
-
- tr->set_buffer(tr, i,
- vb_map[i] + vb->buffer_offset + vb->stride * min_index,
- vb->stride, ~0);
- }
- }
-
- /* Create and map the output buffer. */
- num_verts = max_index + 1 - min_index;
-
- u_upload_alloc(mgr->b.uploader,
- key.output_stride * min_index,
- key.output_stride * num_verts,
- &out_offset, &out_buffer, upload_flushed,
- (void**)&out_map);
-
- out_offset -= key.output_stride * min_index;
-
- /* Translate. */
- tr->run(tr, 0, num_verts, 0, out_map);
-
- /* Unmap all buffers. */
- for (i = 0; i < mgr->b.nr_vertex_buffers; i++) {
- if (vb_translated[i]) {
- pipe_buffer_unmap(mgr->pipe, vb_transfer[i]);
- }
- }
-
- /* Setup the new vertex buffer in the first free slot. */
- mgr->translate_vb_slot = ~0;
- for (i = 0; i < PIPE_MAX_ATTRIBS; i++) {
- if (!mgr->b.vertex_buffer[i].buffer) {
- mgr->translate_vb_slot = i;
-
- if (i >= mgr->b.nr_vertex_buffers) {
- mgr->b.nr_real_vertex_buffers = i+1;
- }
- break;
- }
- }
-
- if (mgr->translate_vb_slot != ~0) {
- /* Setup the new vertex buffer. */
- pipe_resource_reference(
- &mgr->b.real_vertex_buffer[mgr->translate_vb_slot], out_buffer);
- mgr->b.vertex_buffer[mgr->translate_vb_slot].buffer_offset = out_offset;
- mgr->b.vertex_buffer[mgr->translate_vb_slot].stride = key.output_stride;
-
- /* Setup new vertex elements. */
- for (i = 0; i < mgr->ve->count; i++) {
- if (tr_elem_index[i] < key.nr_elements) {
- te = &key.element[tr_elem_index[i]];
- new_velems[i].instance_divisor = mgr->ve->ve[i].instance_divisor;
- new_velems[i].src_format = te->output_format;
- new_velems[i].src_offset = te->output_offset;
- new_velems[i].vertex_buffer_index = mgr->translate_vb_slot;
- } else {
- memcpy(&new_velems[i], &mgr->ve->ve[i],
- sizeof(struct pipe_vertex_element));
- }
- }
-
- mgr->fallback_ve =
- mgr->pipe->create_vertex_elements_state(mgr->pipe, mgr->ve->count,
- new_velems);
-
- /* Preserve saved_ve. */
- mgr->ve_binding_lock = TRUE;
- mgr->pipe->bind_vertex_elements_state(mgr->pipe, mgr->fallback_ve);
- mgr->ve_binding_lock = FALSE;
- }
-
- pipe_resource_reference(&out_buffer, NULL);
-}
-
-static void u_vbuf_translate_end(struct u_vbuf_mgr_priv *mgr)
-{
- if (mgr->fallback_ve == NULL) {
- return;
- }
-
- /* Restore vertex elements. */
- /* Note that saved_ve will be overwritten in bind_vertex_elements_state. */
- mgr->pipe->bind_vertex_elements_state(mgr->pipe, mgr->saved_ve);
- mgr->pipe->delete_vertex_elements_state(mgr->pipe, mgr->fallback_ve);
- mgr->fallback_ve = NULL;
-
- /* Delete the now-unused VBO. */
- pipe_resource_reference(&mgr->b.real_vertex_buffer[mgr->translate_vb_slot],
- NULL);
- mgr->b.nr_real_vertex_buffers = mgr->b.nr_vertex_buffers;
-}
-
-#define FORMAT_REPLACE(what, withwhat) \
- case PIPE_FORMAT_##what: format = PIPE_FORMAT_##withwhat; break
-
-struct u_vbuf_mgr_elements *
-u_vbuf_mgr_create_vertex_elements(struct u_vbuf_mgr *mgrb,
- unsigned count,
- const struct pipe_vertex_element *attribs,
- struct pipe_vertex_element *native_attribs)
-{
- struct u_vbuf_mgr_priv *mgr = (struct u_vbuf_mgr_priv*)mgrb;
- unsigned i;
- struct u_vbuf_mgr_elements *ve = CALLOC_STRUCT(u_vbuf_mgr_elements);
-
- ve->count = count;
-
- if (!count) {
- return ve;
- }
-
- memcpy(ve->ve, attribs, sizeof(struct pipe_vertex_element) * count);
- memcpy(native_attribs, attribs, sizeof(struct pipe_vertex_element) * count);
-
- /* Set the best native format in case the original format is not
- * supported. */
- for (i = 0; i < count; i++) {
- enum pipe_format format = ve->ve[i].src_format;
-
- /* Choose a native format.
- * For now we don't care about the alignment, that's going to
- * be sorted out later. */
- if (!mgr->caps.format_fixed32) {
- switch (format) {
- FORMAT_REPLACE(R32_FIXED, R32_FLOAT);
- FORMAT_REPLACE(R32G32_FIXED, R32G32_FLOAT);
- FORMAT_REPLACE(R32G32B32_FIXED, R32G32B32_FLOAT);
- FORMAT_REPLACE(R32G32B32A32_FIXED, R32G32B32A32_FLOAT);
- default:;
- }
- }
- if (!mgr->caps.format_float16) {
- switch (format) {
- FORMAT_REPLACE(R16_FLOAT, R32_FLOAT);
- FORMAT_REPLACE(R16G16_FLOAT, R32G32_FLOAT);
- FORMAT_REPLACE(R16G16B16_FLOAT, R32G32B32_FLOAT);
- FORMAT_REPLACE(R16G16B16A16_FLOAT, R32G32B32A32_FLOAT);
- default:;
- }
- }
- if (!mgr->caps.format_float64) {
- switch (format) {
- FORMAT_REPLACE(R64_FLOAT, R32_FLOAT);
- FORMAT_REPLACE(R64G64_FLOAT, R32G32_FLOAT);
- FORMAT_REPLACE(R64G64B64_FLOAT, R32G32B32_FLOAT);
- FORMAT_REPLACE(R64G64B64A64_FLOAT, R32G32B32A32_FLOAT);
- default:;
- }
- }
- if (!mgr->caps.format_norm32) {
- switch (format) {
- FORMAT_REPLACE(R32_UNORM, R32_FLOAT);
- FORMAT_REPLACE(R32G32_UNORM, R32G32_FLOAT);
- FORMAT_REPLACE(R32G32B32_UNORM, R32G32B32_FLOAT);
- FORMAT_REPLACE(R32G32B32A32_UNORM, R32G32B32A32_FLOAT);
- FORMAT_REPLACE(R32_SNORM, R32_FLOAT);
- FORMAT_REPLACE(R32G32_SNORM, R32G32_FLOAT);
- FORMAT_REPLACE(R32G32B32_SNORM, R32G32B32_FLOAT);
- FORMAT_REPLACE(R32G32B32A32_SNORM, R32G32B32A32_FLOAT);
- default:;
- }
- }
- if (!mgr->caps.format_scaled32) {
- switch (format) {
- FORMAT_REPLACE(R32_USCALED, R32_FLOAT);
- FORMAT_REPLACE(R32G32_USCALED, R32G32_FLOAT);
- FORMAT_REPLACE(R32G32B32_USCALED, R32G32B32_FLOAT);
- FORMAT_REPLACE(R32G32B32A32_USCALED,R32G32B32A32_FLOAT);
- FORMAT_REPLACE(R32_SSCALED, R32_FLOAT);
- FORMAT_REPLACE(R32G32_SSCALED, R32G32_FLOAT);
- FORMAT_REPLACE(R32G32B32_SSCALED, R32G32B32_FLOAT);
- FORMAT_REPLACE(R32G32B32A32_SSCALED,R32G32B32A32_FLOAT);
- default:;
- }
- }
-
- native_attribs[i].src_format = format;
- ve->native_format[i] = format;
- ve->native_format_size[i] =
- util_format_get_blocksize(ve->native_format[i]);
-
- ve->incompatible_layout =
- ve->incompatible_layout ||
- ve->ve[i].src_format != ve->native_format[i] ||
- (!mgr->caps.fetch_dword_unaligned && ve->ve[i].src_offset % 4 != 0);
- }
-
- /* Align the formats to the size of DWORD if needed. */
- if (!mgr->caps.fetch_dword_unaligned) {
- for (i = 0; i < count; i++) {
- ve->native_format_size[i] = align(ve->native_format_size[i], 4);
- }
- }
-
- return ve;
-}
-
-void u_vbuf_mgr_bind_vertex_elements(struct u_vbuf_mgr *mgrb,
- void *cso,
- struct u_vbuf_mgr_elements *ve)
-{
- struct u_vbuf_mgr_priv *mgr = (struct u_vbuf_mgr_priv*)mgrb;
-
- if (!cso) {
- return;
- }
-
- if (!mgr->ve_binding_lock) {
- mgr->saved_ve = cso;
- mgr->ve = ve;
- }
-}
-
-void u_vbuf_mgr_destroy_vertex_elements(struct u_vbuf_mgr *mgr,
- struct u_vbuf_mgr_elements *ve)
-{
- FREE(ve);
-}
-
-void u_vbuf_mgr_set_vertex_buffers(struct u_vbuf_mgr *mgrb,
- unsigned count,
- const struct pipe_vertex_buffer *bufs)
-{
- struct u_vbuf_mgr_priv *mgr = (struct u_vbuf_mgr_priv*)mgrb;
- unsigned i;
-
- mgr->b.max_index = ~0;
- mgr->any_user_vbs = FALSE;
- mgr->incompatible_vb_layout = FALSE;
-
- if (!mgr->caps.fetch_dword_unaligned) {
- /* Check if the strides and offsets are aligned to the size of DWORD. */
- for (i = 0; i < count; i++) {
- if (bufs[i].buffer) {
- if (bufs[i].stride % 4 != 0 ||
- bufs[i].buffer_offset % 4 != 0) {
- mgr->incompatible_vb_layout = TRUE;
- break;
- }
- }
- }
- }
-
- for (i = 0; i < count; i++) {
- const struct pipe_vertex_buffer *vb = &bufs[i];
-
- pipe_resource_reference(&mgr->b.vertex_buffer[i].buffer, vb->buffer);
- pipe_resource_reference(&mgr->b.real_vertex_buffer[i], NULL);
-
- if (u_vbuf_resource(vb->buffer)->user_ptr) {
- mgr->any_user_vbs = TRUE;
- continue;
- }
-
- pipe_resource_reference(&mgr->b.real_vertex_buffer[i], vb->buffer);
-
- /* The stride of zero means we will be fetching only the first
- * vertex, so don't care about max_index. */
- if (!vb->stride) {
- continue;
- }
-
- /* Update the maximum index. */
- mgr->b.max_index =
- MIN2(mgr->b.max_index,
- (vb->buffer->width0 - vb->buffer_offset) / vb->stride - 1);
- }
-
- for (; i < mgr->b.nr_real_vertex_buffers; i++) {
- pipe_resource_reference(&mgr->b.vertex_buffer[i].buffer, NULL);
- pipe_resource_reference(&mgr->b.real_vertex_buffer[i], NULL);
- }
-
- memcpy(mgr->b.vertex_buffer, bufs,
- sizeof(struct pipe_vertex_buffer) * count);
-
- mgr->b.nr_vertex_buffers = count;
- mgr->b.nr_real_vertex_buffers = count;
-}
-
-static void u_vbuf_upload_buffers(struct u_vbuf_mgr_priv *mgr,
- int min_index, int max_index,
- unsigned instance_count,
- boolean *upload_flushed)
-{
- int i, nr = mgr->ve->count;
- unsigned count = max_index + 1 - min_index;
- boolean uploaded[PIPE_MAX_ATTRIBS] = {0};
-
- for (i = 0; i < nr; i++) {
- unsigned index = mgr->ve->ve[i].vertex_buffer_index;
- struct pipe_vertex_buffer *vb = &mgr->b.vertex_buffer[index];
-
- if (vb->buffer &&
- u_vbuf_resource(vb->buffer)->user_ptr &&
- !uploaded[index]) {
- unsigned first, size;
- boolean flushed;
- unsigned instance_div = mgr->ve->ve[i].instance_divisor;
-
- if (instance_div) {
- first = 0;
- size = vb->stride *
- ((instance_count + instance_div - 1) / instance_div);
- } else if (vb->stride) {
- first = vb->stride * min_index;
- size = vb->stride * count;
- } else {
- first = 0;
- size = mgr->ve->native_format_size[i];
- }
-
- u_upload_data(mgr->b.uploader, first, size,
- u_vbuf_resource(vb->buffer)->user_ptr + first,
- &vb->buffer_offset,
- &mgr->b.real_vertex_buffer[index],
- &flushed);
-
- vb->buffer_offset -= first;
-
- uploaded[index] = TRUE;
- *upload_flushed = *upload_flushed || flushed;
- } else {
- assert(mgr->b.real_vertex_buffer[index]);
- }
- }
-}
-
-void u_vbuf_mgr_draw_begin(struct u_vbuf_mgr *mgrb,
- const struct pipe_draw_info *info,
- boolean *buffers_updated,
- boolean *uploader_flushed)
-{
- struct u_vbuf_mgr_priv *mgr = (struct u_vbuf_mgr_priv*)mgrb;
- boolean bufs_updated = FALSE, upload_flushed = FALSE;
- int min_index, max_index;
-
- min_index = info->min_index - info->index_bias;
- if (info->max_index == ~0) {
- max_index = mgr->b.max_index;
- } else {
- max_index = MIN2(info->max_index - info->index_bias, mgr->b.max_index);
- }
-
- /* Translate vertices with non-native layouts or formats. */
- if (mgr->incompatible_vb_layout || mgr->ve->incompatible_layout) {
- u_vbuf_translate_begin(mgr, min_index, max_index, &upload_flushed);
-
- if (mgr->fallback_ve) {
- bufs_updated = TRUE;
- }
- }
-
- /* Upload user buffers. */
- if (mgr->any_user_vbs) {
- u_vbuf_upload_buffers(mgr, min_index, max_index, info->instance_count,
- &upload_flushed);
- bufs_updated = TRUE;
- }
-
- /* Set the return values. */
- if (buffers_updated) {
- *buffers_updated = bufs_updated;
- }
- if (uploader_flushed) {
- *uploader_flushed = upload_flushed;
- }
-}
-
-void u_vbuf_mgr_draw_end(struct u_vbuf_mgr *mgrb)
-{
- struct u_vbuf_mgr_priv *mgr = (struct u_vbuf_mgr_priv*)mgrb;
-
- if (mgr->fallback_ve) {
- u_vbuf_translate_end(mgr);
- }
-}
+/**************************************************************************
+ *
+ * Copyright 2011 Marek Olšák <maraeo@gmail.com>
+ * 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 AUTHORS 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.
+ *
+ **************************************************************************/
+
+#include "util/u_vbuf_mgr.h"
+
+#include "util/u_format.h"
+#include "util/u_inlines.h"
+#include "util/u_memory.h"
+#include "util/u_upload_mgr.h"
+#include "translate/translate.h"
+#include "translate/translate_cache.h"
+
+/* Hardware vertex fetcher limitations can be described by this structure. */
+struct u_vbuf_caps {
+ /* Vertex format CAPs. */
+ /* TRUE if hardware supports it. */
+ unsigned format_fixed32:1; /* PIPE_FORMAT_*32*_FIXED */
+ unsigned format_float16:1; /* PIPE_FORMAT_*16*_FLOAT */
+ unsigned format_float64:1; /* PIPE_FORMAT_*64*_FLOAT */
+ unsigned format_norm32:1; /* PIPE_FORMAT_*32*NORM */
+ unsigned format_scaled32:1; /* PIPE_FORMAT_*32*SCALED */
+
+ /* Whether vertex fetches don't have to be dword-aligned. */
+ /* TRUE if hardware supports it. */
+ unsigned fetch_dword_unaligned:1;
+};
+
+struct u_vbuf_mgr_elements {
+ unsigned count;
+ struct pipe_vertex_element ve[PIPE_MAX_ATTRIBS];
+
+ unsigned src_format_size[PIPE_MAX_ATTRIBS];
+
+ /* If (velem[i].src_format != native_format[i]), the vertex buffer
+ * referenced by the vertex element cannot be used for rendering and
+ * its vertex data must be translated to native_format[i]. */
+ enum pipe_format native_format[PIPE_MAX_ATTRIBS];
+ unsigned native_format_size[PIPE_MAX_ATTRIBS];
+
+ /* This might mean two things:
+ * - src_format != native_format, as discussed above.
+ * - src_offset % 4 != 0 (if the caps don't allow such an offset). */
+ boolean incompatible_layout;
+};
+
+struct u_vbuf_mgr_priv {
+ struct u_vbuf_mgr b;
+ struct u_vbuf_caps caps;
+ struct pipe_context *pipe;
+
+ struct translate_cache *translate_cache;
+ unsigned translate_vb_slot;
+
+ struct u_vbuf_mgr_elements *ve;
+ void *saved_ve, *fallback_ve;
+ boolean ve_binding_lock;
+
+ boolean any_user_vbs;
+ boolean incompatible_vb_layout;
+};
+
+static void u_vbuf_mgr_init_format_caps(struct u_vbuf_mgr_priv *mgr)
+{
+ struct pipe_screen *screen = mgr->pipe->screen;
+
+ mgr->caps.format_fixed32 =
+ screen->is_format_supported(screen, PIPE_FORMAT_R32_FIXED, PIPE_BUFFER,
+ 0, PIPE_BIND_VERTEX_BUFFER);
+
+ mgr->caps.format_float16 =
+ screen->is_format_supported(screen, PIPE_FORMAT_R16_FLOAT, PIPE_BUFFER,
+ 0, PIPE_BIND_VERTEX_BUFFER);
+
+ mgr->caps.format_float64 =
+ screen->is_format_supported(screen, PIPE_FORMAT_R64_FLOAT, PIPE_BUFFER,
+ 0, PIPE_BIND_VERTEX_BUFFER);
+
+ mgr->caps.format_norm32 =
+ screen->is_format_supported(screen, PIPE_FORMAT_R32_UNORM, PIPE_BUFFER,
+ 0, PIPE_BIND_VERTEX_BUFFER) &&
+ screen->is_format_supported(screen, PIPE_FORMAT_R32_SNORM, PIPE_BUFFER,
+ 0, PIPE_BIND_VERTEX_BUFFER);
+
+ mgr->caps.format_scaled32 =
+ screen->is_format_supported(screen, PIPE_FORMAT_R32_USCALED, PIPE_BUFFER,
+ 0, PIPE_BIND_VERTEX_BUFFER) &&
+ screen->is_format_supported(screen, PIPE_FORMAT_R32_SSCALED, PIPE_BUFFER,
+ 0, PIPE_BIND_VERTEX_BUFFER);
+}
+
+struct u_vbuf_mgr *
+u_vbuf_mgr_create(struct pipe_context *pipe,
+ unsigned upload_buffer_size,
+ unsigned upload_buffer_alignment,
+ unsigned upload_buffer_bind,
+ enum u_fetch_alignment fetch_alignment)
+{
+ struct u_vbuf_mgr_priv *mgr = CALLOC_STRUCT(u_vbuf_mgr_priv);
+
+ mgr->pipe = pipe;
+ mgr->translate_cache = translate_cache_create();
+
+ mgr->b.uploader = u_upload_create(pipe, upload_buffer_size,
+ upload_buffer_alignment,
+ upload_buffer_bind);
+
+ mgr->caps.fetch_dword_unaligned =
+ fetch_alignment == U_VERTEX_FETCH_BYTE_ALIGNED;
+
+ u_vbuf_mgr_init_format_caps(mgr);
+
+ return &mgr->b;
+}
+
+void u_vbuf_mgr_destroy(struct u_vbuf_mgr *mgrb)
+{
+ struct u_vbuf_mgr_priv *mgr = (struct u_vbuf_mgr_priv*)mgrb;
+ unsigned i;
+
+ for (i = 0; i < mgr->b.nr_real_vertex_buffers; i++) {
+ pipe_resource_reference(&mgr->b.vertex_buffer[i].buffer, NULL);
+ pipe_resource_reference(&mgr->b.real_vertex_buffer[i], NULL);
+ }
+
+ translate_cache_destroy(mgr->translate_cache);
+ u_upload_destroy(mgr->b.uploader);
+ FREE(mgr);
+}
+
+
+static void u_vbuf_translate_begin(struct u_vbuf_mgr_priv *mgr,
+ int min_index, int max_index,
+ boolean *upload_flushed)
+{
+ struct translate_key key;
+ struct translate_element *te;
+ unsigned tr_elem_index[PIPE_MAX_ATTRIBS];
+ struct translate *tr;
+ boolean vb_translated[PIPE_MAX_ATTRIBS] = {0};
+ uint8_t *vb_map[PIPE_MAX_ATTRIBS] = {0}, *out_map;
+ struct pipe_transfer *vb_transfer[PIPE_MAX_ATTRIBS] = {0};
+ struct pipe_resource *out_buffer = NULL;
+ unsigned i, num_verts, out_offset;
+ struct pipe_vertex_element new_velems[PIPE_MAX_ATTRIBS];
+
+ memset(&key, 0, sizeof(key));
+ memset(tr_elem_index, 0xff, sizeof(tr_elem_index));
+
+ /* Initialize the translate key, i.e. the recipe how vertices should be
+ * translated. */
+ memset(&key, 0, sizeof key);
+ for (i = 0; i < mgr->ve->count; i++) {
+ struct pipe_vertex_buffer *vb =
+ &mgr->b.vertex_buffer[mgr->ve->ve[i].vertex_buffer_index];
+ enum pipe_format output_format = mgr->ve->native_format[i];
+ unsigned output_format_size = mgr->ve->native_format_size[i];
+
+ /* Check for support. */
+ if (mgr->ve->ve[i].src_format == mgr->ve->native_format[i] &&
+ (mgr->caps.fetch_dword_unaligned ||
+ (vb->buffer_offset % 4 == 0 &&
+ vb->stride % 4 == 0 &&
+ mgr->ve->ve[i].src_offset % 4 == 0))) {
+ continue;
+ }
+
+ /* Workaround for translate: output floats instead of halfs. */
+ switch (output_format) {
+ case PIPE_FORMAT_R16_FLOAT:
+ output_format = PIPE_FORMAT_R32_FLOAT;
+ output_format_size = 4;
+ break;
+ case PIPE_FORMAT_R16G16_FLOAT:
+ output_format = PIPE_FORMAT_R32G32_FLOAT;
+ output_format_size = 8;
+ break;
+ case PIPE_FORMAT_R16G16B16_FLOAT:
+ output_format = PIPE_FORMAT_R32G32B32_FLOAT;
+ output_format_size = 12;
+ break;
+ case PIPE_FORMAT_R16G16B16A16_FLOAT:
+ output_format = PIPE_FORMAT_R32G32B32A32_FLOAT;
+ output_format_size = 16;
+ break;
+ default:;
+ }
+
+ /* Add this vertex element. */
+ te = &key.element[key.nr_elements];
+ /*te->type;
+ te->instance_divisor;*/
+ te->input_buffer = mgr->ve->ve[i].vertex_buffer_index;
+ te->input_format = mgr->ve->ve[i].src_format;
+ te->input_offset = mgr->ve->ve[i].src_offset;
+ te->output_format = output_format;
+ te->output_offset = key.output_stride;
+
+ key.output_stride += output_format_size;
+ vb_translated[mgr->ve->ve[i].vertex_buffer_index] = TRUE;
+ tr_elem_index[i] = key.nr_elements;
+ key.nr_elements++;
+ }
+
+ /* Get a translate object. */
+ tr = translate_cache_find(mgr->translate_cache, &key);
+
+ /* Map buffers we want to translate. */
+ for (i = 0; i < mgr->b.nr_vertex_buffers; i++) {
+ if (vb_translated[i]) {
+ struct pipe_vertex_buffer *vb = &mgr->b.vertex_buffer[i];
+
+ vb_map[i] = pipe_buffer_map(mgr->pipe, vb->buffer,
+ PIPE_TRANSFER_READ, &vb_transfer[i]);
+
+ tr->set_buffer(tr, i,
+ vb_map[i] + vb->buffer_offset + vb->stride * min_index,
+ vb->stride, ~0);
+ }
+ }
+
+ /* Create and map the output buffer. */
+ num_verts = max_index + 1 - min_index;
+
+ u_upload_alloc(mgr->b.uploader,
+ key.output_stride * min_index,
+ key.output_stride * num_verts,
+ &out_offset, &out_buffer, upload_flushed,
+ (void**)&out_map);
+
+ out_offset -= key.output_stride * min_index;
+
+ /* Translate. */
+ tr->run(tr, 0, num_verts, 0, out_map);
+
+ /* Unmap all buffers. */
+ for (i = 0; i < mgr->b.nr_vertex_buffers; i++) {
+ if (vb_translated[i]) {
+ pipe_buffer_unmap(mgr->pipe, vb_transfer[i]);
+ }
+ }
+
+ /* Setup the new vertex buffer in the first free slot. */
+ mgr->translate_vb_slot = ~0;
+ for (i = 0; i < PIPE_MAX_ATTRIBS; i++) {
+ if (!mgr->b.vertex_buffer[i].buffer) {
+ mgr->translate_vb_slot = i;
+
+ if (i >= mgr->b.nr_vertex_buffers) {
+ mgr->b.nr_real_vertex_buffers = i+1;
+ }
+ break;
+ }
+ }
+
+ if (mgr->translate_vb_slot != ~0) {
+ /* Setup the new vertex buffer. */
+ pipe_resource_reference(
+ &mgr->b.real_vertex_buffer[mgr->translate_vb_slot], out_buffer);
+ mgr->b.vertex_buffer[mgr->translate_vb_slot].buffer_offset = out_offset;
+ mgr->b.vertex_buffer[mgr->translate_vb_slot].stride = key.output_stride;
+
+ /* Setup new vertex elements. */
+ for (i = 0; i < mgr->ve->count; i++) {
+ if (tr_elem_index[i] < key.nr_elements) {
+ te = &key.element[tr_elem_index[i]];
+ new_velems[i].instance_divisor = mgr->ve->ve[i].instance_divisor;
+ new_velems[i].src_format = te->output_format;
+ new_velems[i].src_offset = te->output_offset;
+ new_velems[i].vertex_buffer_index = mgr->translate_vb_slot;
+ } else {
+ memcpy(&new_velems[i], &mgr->ve->ve[i],
+ sizeof(struct pipe_vertex_element));
+ }
+ }
+
+ mgr->fallback_ve =
+ mgr->pipe->create_vertex_elements_state(mgr->pipe, mgr->ve->count,
+ new_velems);
+
+ /* Preserve saved_ve. */
+ mgr->ve_binding_lock = TRUE;
+ mgr->pipe->bind_vertex_elements_state(mgr->pipe, mgr->fallback_ve);
+ mgr->ve_binding_lock = FALSE;
+ }
+
+ pipe_resource_reference(&out_buffer, NULL);
+}
+
+static void u_vbuf_translate_end(struct u_vbuf_mgr_priv *mgr)
+{
+ if (mgr->fallback_ve == NULL) {
+ return;
+ }
+
+ /* Restore vertex elements. */
+ /* Note that saved_ve will be overwritten in bind_vertex_elements_state. */
+ mgr->pipe->bind_vertex_elements_state(mgr->pipe, mgr->saved_ve);
+ mgr->pipe->delete_vertex_elements_state(mgr->pipe, mgr->fallback_ve);
+ mgr->fallback_ve = NULL;
+
+ /* Delete the now-unused VBO. */
+ pipe_resource_reference(&mgr->b.real_vertex_buffer[mgr->translate_vb_slot],
+ NULL);
+ mgr->b.nr_real_vertex_buffers = mgr->b.nr_vertex_buffers;
+}
+
+#define FORMAT_REPLACE(what, withwhat) \
+ case PIPE_FORMAT_##what: format = PIPE_FORMAT_##withwhat; break
+
+struct u_vbuf_mgr_elements *
+u_vbuf_mgr_create_vertex_elements(struct u_vbuf_mgr *mgrb,
+ unsigned count,
+ const struct pipe_vertex_element *attribs,
+ struct pipe_vertex_element *native_attribs)
+{
+ struct u_vbuf_mgr_priv *mgr = (struct u_vbuf_mgr_priv*)mgrb;
+ unsigned i;
+ struct u_vbuf_mgr_elements *ve = CALLOC_STRUCT(u_vbuf_mgr_elements);
+
+ ve->count = count;
+
+ if (!count) {
+ return ve;
+ }
+
+ memcpy(ve->ve, attribs, sizeof(struct pipe_vertex_element) * count);
+ memcpy(native_attribs, attribs, sizeof(struct pipe_vertex_element) * count);
+
+ /* Set the best native format in case the original format is not
+ * supported. */
+ for (i = 0; i < count; i++) {
+ enum pipe_format format = ve->ve[i].src_format;
+
+ ve->src_format_size[i] = util_format_get_blocksize(format);
+
+ /* Choose a native format.
+ * For now we don't care about the alignment, that's going to
+ * be sorted out later. */
+ if (!mgr->caps.format_fixed32) {
+ switch (format) {
+ FORMAT_REPLACE(R32_FIXED, R32_FLOAT);
+ FORMAT_REPLACE(R32G32_FIXED, R32G32_FLOAT);
+ FORMAT_REPLACE(R32G32B32_FIXED, R32G32B32_FLOAT);
+ FORMAT_REPLACE(R32G32B32A32_FIXED, R32G32B32A32_FLOAT);
+ default:;
+ }
+ }
+ if (!mgr->caps.format_float16) {
+ switch (format) {
+ FORMAT_REPLACE(R16_FLOAT, R32_FLOAT);
+ FORMAT_REPLACE(R16G16_FLOAT, R32G32_FLOAT);
+ FORMAT_REPLACE(R16G16B16_FLOAT, R32G32B32_FLOAT);
+ FORMAT_REPLACE(R16G16B16A16_FLOAT, R32G32B32A32_FLOAT);
+ default:;
+ }
+ }
+ if (!mgr->caps.format_float64) {
+ switch (format) {
+ FORMAT_REPLACE(R64_FLOAT, R32_FLOAT);
+ FORMAT_REPLACE(R64G64_FLOAT, R32G32_FLOAT);
+ FORMAT_REPLACE(R64G64B64_FLOAT, R32G32B32_FLOAT);
+ FORMAT_REPLACE(R64G64B64A64_FLOAT, R32G32B32A32_FLOAT);
+ default:;
+ }
+ }
+ if (!mgr->caps.format_norm32) {
+ switch (format) {
+ FORMAT_REPLACE(R32_UNORM, R32_FLOAT);
+ FORMAT_REPLACE(R32G32_UNORM, R32G32_FLOAT);
+ FORMAT_REPLACE(R32G32B32_UNORM, R32G32B32_FLOAT);
+ FORMAT_REPLACE(R32G32B32A32_UNORM, R32G32B32A32_FLOAT);
+ FORMAT_REPLACE(R32_SNORM, R32_FLOAT);
+ FORMAT_REPLACE(R32G32_SNORM, R32G32_FLOAT);
+ FORMAT_REPLACE(R32G32B32_SNORM, R32G32B32_FLOAT);
+ FORMAT_REPLACE(R32G32B32A32_SNORM, R32G32B32A32_FLOAT);
+ default:;
+ }
+ }
+ if (!mgr->caps.format_scaled32) {
+ switch (format) {
+ FORMAT_REPLACE(R32_USCALED, R32_FLOAT);
+ FORMAT_REPLACE(R32G32_USCALED, R32G32_FLOAT);
+ FORMAT_REPLACE(R32G32B32_USCALED, R32G32B32_FLOAT);
+ FORMAT_REPLACE(R32G32B32A32_USCALED,R32G32B32A32_FLOAT);
+ FORMAT_REPLACE(R32_SSCALED, R32_FLOAT);
+ FORMAT_REPLACE(R32G32_SSCALED, R32G32_FLOAT);
+ FORMAT_REPLACE(R32G32B32_SSCALED, R32G32B32_FLOAT);
+ FORMAT_REPLACE(R32G32B32A32_SSCALED,R32G32B32A32_FLOAT);
+ default:;
+ }
+ }
+
+ native_attribs[i].src_format = format;
+ ve->native_format[i] = format;
+ ve->native_format_size[i] =
+ util_format_get_blocksize(ve->native_format[i]);
+
+ ve->incompatible_layout =
+ ve->incompatible_layout ||
+ ve->ve[i].src_format != ve->native_format[i] ||
+ (!mgr->caps.fetch_dword_unaligned && ve->ve[i].src_offset % 4 != 0);
+ }
+
+ /* Align the formats to the size of DWORD if needed. */
+ if (!mgr->caps.fetch_dword_unaligned) {
+ for (i = 0; i < count; i++) {
+ ve->native_format_size[i] = align(ve->native_format_size[i], 4);
+ }
+ }
+
+ return ve;
+}
+
+void u_vbuf_mgr_bind_vertex_elements(struct u_vbuf_mgr *mgrb,
+ void *cso,
+ struct u_vbuf_mgr_elements *ve)
+{
+ struct u_vbuf_mgr_priv *mgr = (struct u_vbuf_mgr_priv*)mgrb;
+
+ if (!cso) {
+ return;
+ }
+
+ if (!mgr->ve_binding_lock) {
+ mgr->saved_ve = cso;
+ mgr->ve = ve;
+ }
+}
+
+void u_vbuf_mgr_destroy_vertex_elements(struct u_vbuf_mgr *mgr,
+ struct u_vbuf_mgr_elements *ve)
+{
+ FREE(ve);
+}
+
+void u_vbuf_mgr_set_vertex_buffers(struct u_vbuf_mgr *mgrb,
+ unsigned count,
+ const struct pipe_vertex_buffer *bufs)
+{
+ struct u_vbuf_mgr_priv *mgr = (struct u_vbuf_mgr_priv*)mgrb;
+ unsigned i;
+
+ mgr->any_user_vbs = FALSE;
+ mgr->incompatible_vb_layout = FALSE;
+
+ if (!mgr->caps.fetch_dword_unaligned) {
+ /* Check if the strides and offsets are aligned to the size of DWORD. */
+ for (i = 0; i < count; i++) {
+ if (bufs[i].buffer) {
+ if (bufs[i].stride % 4 != 0 ||
+ bufs[i].buffer_offset % 4 != 0) {
+ mgr->incompatible_vb_layout = TRUE;
+ break;
+ }
+ }
+ }
+ }
+
+ for (i = 0; i < count; i++) {
+ const struct pipe_vertex_buffer *vb = &bufs[i];
+
+ pipe_resource_reference(&mgr->b.vertex_buffer[i].buffer, vb->buffer);
+ pipe_resource_reference(&mgr->b.real_vertex_buffer[i], NULL);
+
+ if (!vb->buffer) {
+ continue;
+ }
+
+ if (u_vbuf_resource(vb->buffer)->user_ptr) {
+ mgr->any_user_vbs = TRUE;
+ continue;
+ }
+
+ pipe_resource_reference(&mgr->b.real_vertex_buffer[i], vb->buffer);
+ }
+
+ for (; i < mgr->b.nr_real_vertex_buffers; i++) {
+ pipe_resource_reference(&mgr->b.vertex_buffer[i].buffer, NULL);
+ pipe_resource_reference(&mgr->b.real_vertex_buffer[i], NULL);
+ }
+
+ memcpy(mgr->b.vertex_buffer, bufs,
+ sizeof(struct pipe_vertex_buffer) * count);
+
+ mgr->b.nr_vertex_buffers = count;
+ mgr->b.nr_real_vertex_buffers = count;
+}
+
+static void u_vbuf_upload_buffers(struct u_vbuf_mgr_priv *mgr,
+ int min_index, int max_index,
+ unsigned instance_count,
+ boolean *upload_flushed)
+{
+ unsigned i, nr = mgr->ve->count;
+ unsigned count = max_index + 1 - min_index;
+ boolean uploaded[PIPE_MAX_ATTRIBS] = {0};
+
+ for (i = 0; i < nr; i++) {
+ unsigned index = mgr->ve->ve[i].vertex_buffer_index;
+ struct pipe_vertex_buffer *vb = &mgr->b.vertex_buffer[index];
+
+ if (vb->buffer &&
+ u_vbuf_resource(vb->buffer)->user_ptr &&
+ !uploaded[index]) {
+ unsigned first, size;
+ boolean flushed;
+ unsigned instance_div = mgr->ve->ve[i].instance_divisor;
+
+ if (instance_div) {
+ first = 0;
+ size = vb->stride *
+ ((instance_count + instance_div - 1) / instance_div);
+ } else if (vb->stride) {
+ first = vb->stride * min_index;
+ size = vb->stride * count;
+ } else {
+ first = 0;
+ size = mgr->ve->native_format_size[i];
+ }
+
+ u_upload_data(mgr->b.uploader, first, size,
+ u_vbuf_resource(vb->buffer)->user_ptr + first,
+ &vb->buffer_offset,
+ &mgr->b.real_vertex_buffer[index],
+ &flushed);
+
+ vb->buffer_offset -= first;
+
+ uploaded[index] = TRUE;
+ *upload_flushed = *upload_flushed || flushed;
+ } else {
+ assert(mgr->b.real_vertex_buffer[index]);
+ }
+ }
+}
+
+static void u_vbuf_mgr_compute_max_index(struct u_vbuf_mgr_priv *mgr)
+{
+ unsigned i, nr = mgr->ve->count;
+
+ mgr->b.max_index = ~0;
+
+ for (i = 0; i < nr; i++) {
+ struct pipe_vertex_buffer *vb =
+ &mgr->b.vertex_buffer[mgr->ve->ve[i].vertex_buffer_index];
+ int unused;
+ unsigned max_index;
+
+ if (!vb->buffer ||
+ !vb->stride ||
+ u_vbuf_resource(vb->buffer)->user_ptr) {
+ continue;
+ }
+
+ /* How many bytes is unused after the last vertex.
+ * width0 may be "count*stride - unused" and we have to compensate
+ * for that when dividing by stride. */
+ unused = vb->stride -
+ (mgr->ve->ve[i].src_offset + mgr->ve->src_format_size[i]);
+ assert(unused >= 0);
+
+ /* Compute the maximum index for this vertex element. */
+ max_index =
+ (vb->buffer->width0 - vb->buffer_offset + (unsigned)unused) /
+ vb->stride - 1;
+
+ mgr->b.max_index = MIN2(mgr->b.max_index, max_index);
+ }
+}
+
+void u_vbuf_mgr_draw_begin(struct u_vbuf_mgr *mgrb,
+ const struct pipe_draw_info *info,
+ boolean *buffers_updated,
+ boolean *uploader_flushed)
+{
+ struct u_vbuf_mgr_priv *mgr = (struct u_vbuf_mgr_priv*)mgrb;
+ boolean bufs_updated = FALSE, upload_flushed = FALSE;
+ int min_index, max_index;
+
+ u_vbuf_mgr_compute_max_index(mgr);
+
+ min_index = info->min_index - info->index_bias;
+ if (info->max_index == ~0) {
+ max_index = mgr->b.max_index;
+ } else {
+ max_index = MIN2(info->max_index - info->index_bias, mgr->b.max_index);
+ }
+
+ /* Translate vertices with non-native layouts or formats. */
+ if (mgr->incompatible_vb_layout || mgr->ve->incompatible_layout) {
+ u_vbuf_translate_begin(mgr, min_index, max_index, &upload_flushed);
+
+ if (mgr->fallback_ve) {
+ bufs_updated = TRUE;
+ }
+ }
+
+ /* Upload user buffers. */
+ if (mgr->any_user_vbs) {
+ u_vbuf_upload_buffers(mgr, min_index, max_index, info->instance_count,
+ &upload_flushed);
+ bufs_updated = TRUE;
+ }
+
+ /* Set the return values. */
+ if (buffers_updated) {
+ *buffers_updated = bufs_updated;
+ }
+ if (uploader_flushed) {
+ *uploader_flushed = upload_flushed;
+ }
+}
+
+void u_vbuf_mgr_draw_end(struct u_vbuf_mgr *mgrb)
+{
+ struct u_vbuf_mgr_priv *mgr = (struct u_vbuf_mgr_priv*)mgrb;
+
+ if (mgr->fallback_ve) {
+ u_vbuf_translate_end(mgr);
+ }
+}
diff --git a/mesalib/src/mesa/state_tracker/st_atom_sampler.c b/mesalib/src/mesa/state_tracker/st_atom_sampler.c
index e3d6cbb8e..ccbd54892 100644
--- a/mesalib/src/mesa/state_tracker/st_atom_sampler.c
+++ b/mesalib/src/mesa/state_tracker/st_atom_sampler.c
@@ -120,14 +120,110 @@ gl_filter_to_img_filter(GLenum filter)
}
}
+static void convert_sampler(struct st_context *st,
+ struct pipe_sampler_state *sampler,
+ GLuint texUnit)
+{
+ struct gl_texture_object *texobj;
+ struct gl_sampler_object *msamp;
+
+ texobj = st->ctx->Texture.Unit[texUnit]._Current;
+ if (!texobj) {
+ texobj = st_get_default_texture(st);
+ }
+
+ msamp = _mesa_get_samplerobj(st->ctx, texUnit);
+ sampler->wrap_s = gl_wrap_xlate(msamp->WrapS);
+ sampler->wrap_t = gl_wrap_xlate(msamp->WrapT);
+ sampler->wrap_r = gl_wrap_xlate(msamp->WrapR);
+
+ sampler->min_img_filter = gl_filter_to_img_filter(msamp->MinFilter);
+ sampler->min_mip_filter = gl_filter_to_mip_filter(msamp->MinFilter);
+ sampler->mag_img_filter = gl_filter_to_img_filter(msamp->MagFilter);
+
+ if (texobj->Target != GL_TEXTURE_RECTANGLE_ARB)
+ sampler->normalized_coords = 1;
+
+ sampler->lod_bias = st->ctx->Texture.Unit[texUnit].LodBias +
+ msamp->LodBias;
+
+ sampler->min_lod = CLAMP(msamp->MinLod,
+ 0.0f,
+ (GLfloat) texobj->MaxLevel - texobj->BaseLevel);
+ sampler->max_lod = MIN2((GLfloat) texobj->MaxLevel - texobj->BaseLevel,
+ msamp->MaxLod);
+ if (sampler->max_lod < sampler->min_lod) {
+ /* The GL spec doesn't seem to specify what to do in this case.
+ * Swap the values.
+ */
+ float tmp = sampler->max_lod;
+ sampler->max_lod = sampler->min_lod;
+ sampler->min_lod = tmp;
+ assert(sampler->min_lod <= sampler->max_lod);
+ }
+
+ if (msamp->BorderColor.ui[0] ||
+ msamp->BorderColor.ui[1] ||
+ msamp->BorderColor.ui[2] ||
+ msamp->BorderColor.ui[3]) {
+ struct gl_texture_image *teximg;
+
+ teximg = texobj->Image[0][texobj->BaseLevel];
+
+ st_translate_color(msamp->BorderColor.f,
+ teximg ? teximg->_BaseFormat : GL_RGBA,
+ sampler->border_color);
+ }
+
+ sampler->max_anisotropy = (msamp->MaxAnisotropy == 1.0 ?
+ 0 : (GLuint) msamp->MaxAnisotropy);
+
+ /* only care about ARB_shadow, not SGI shadow */
+ if (msamp->CompareMode == GL_COMPARE_R_TO_TEXTURE) {
+ sampler->compare_mode = PIPE_TEX_COMPARE_R_TO_TEXTURE;
+ sampler->compare_func
+ = st_compare_func_to_pipe(msamp->CompareFunc);
+ }
+
+ sampler->seamless_cube_map =
+ st->ctx->Texture.CubeMapSeamless || msamp->CubeMapSeamless;
+}
-static void
-update_samplers(struct st_context *st)
+static void
+update_vertex_samplers(struct st_context *st)
{
struct gl_vertex_program *vprog = st->ctx->VertexProgram._Current;
+ GLuint su;
+
+ st->state.num_vertex_samplers = 0;
+
+ /* loop over sampler units (aka tex image units) */
+ for (su = 0; su < st->ctx->Const.MaxVertexTextureImageUnits; su++) {
+ struct pipe_sampler_state *sampler = st->state.vertex_samplers + su;
+
+ memset(sampler, 0, sizeof(*sampler));
+
+ if (vprog->Base.SamplersUsed & (1 << su)) {
+ GLuint texUnit;
+
+ texUnit = vprog->Base.SamplerUnits[su];
+
+ convert_sampler(st, sampler, texUnit);
+
+ st->state.num_vertex_samplers = su + 1;
+
+ cso_single_vertex_sampler(st->cso_context, su, sampler);
+ } else {
+ cso_single_vertex_sampler(st->cso_context, su, NULL);
+ }
+ }
+ cso_single_vertex_sampler_done(st->cso_context);
+}
+
+static void
+update_fragment_samplers(struct st_context *st)
+{
struct gl_fragment_program *fprog = st->ctx->FragmentProgram._Current;
- const GLbitfield samplersUsed = (vprog->Base.SamplersUsed |
- fprog->Base.SamplersUsed);
GLuint su;
st->state.num_samplers = 0;
@@ -138,95 +234,33 @@ update_samplers(struct st_context *st)
memset(sampler, 0, sizeof(*sampler));
- if (samplersUsed & (1 << su)) {
- struct gl_texture_object *texobj;
- struct gl_texture_image *teximg;
- struct gl_sampler_object *msamp;
+ if (fprog->Base.SamplersUsed & (1 << su)) {
GLuint texUnit;
- if (fprog->Base.SamplersUsed & (1 << su))
- texUnit = fprog->Base.SamplerUnits[su];
- else
- texUnit = vprog->Base.SamplerUnits[su];
-
- texobj = st->ctx->Texture.Unit[texUnit]._Current;
- if (!texobj) {
- texobj = st_get_default_texture(st);
- }
-
- teximg = texobj->Image[0][texobj->BaseLevel];
-
- msamp = _mesa_get_samplerobj(st->ctx, texUnit);
-
- sampler->wrap_s = gl_wrap_xlate(msamp->WrapS);
- sampler->wrap_t = gl_wrap_xlate(msamp->WrapT);
- sampler->wrap_r = gl_wrap_xlate(msamp->WrapR);
-
- sampler->min_img_filter = gl_filter_to_img_filter(msamp->MinFilter);
- sampler->min_mip_filter = gl_filter_to_mip_filter(msamp->MinFilter);
- sampler->mag_img_filter = gl_filter_to_img_filter(msamp->MagFilter);
-
- if (texobj->Target != GL_TEXTURE_RECTANGLE_ARB)
- sampler->normalized_coords = 1;
-
- sampler->lod_bias = st->ctx->Texture.Unit[texUnit].LodBias +
- msamp->LodBias;
-
- sampler->min_lod = CLAMP(msamp->MinLod,
- 0.0f,
- (GLfloat) texobj->MaxLevel - texobj->BaseLevel);
- sampler->max_lod = MIN2((GLfloat) texobj->MaxLevel - texobj->BaseLevel,
- msamp->MaxLod);
- if (sampler->max_lod < sampler->min_lod) {
- /* The GL spec doesn't seem to specify what to do in this case.
- * Swap the values.
- */
- float tmp = sampler->max_lod;
- sampler->max_lod = sampler->min_lod;
- sampler->min_lod = tmp;
- assert(sampler->min_lod <= sampler->max_lod);
- }
-
- st_translate_color(msamp->BorderColor.f,
- teximg ? teximg->_BaseFormat : GL_RGBA,
- sampler->border_color);
-
- sampler->max_anisotropy = (msamp->MaxAnisotropy == 1.0 ?
- 0 : (GLuint) msamp->MaxAnisotropy);
-
- /* only care about ARB_shadow, not SGI shadow */
- if (msamp->CompareMode == GL_COMPARE_R_TO_TEXTURE) {
- sampler->compare_mode = PIPE_TEX_COMPARE_R_TO_TEXTURE;
- sampler->compare_func
- = st_compare_func_to_pipe(msamp->CompareFunc);
- }
-
- sampler->seamless_cube_map =
- st->ctx->Texture.CubeMapSeamless || msamp->CubeMapSeamless;
+ texUnit = fprog->Base.SamplerUnits[su];
+
+ convert_sampler(st, sampler, texUnit);
st->state.num_samplers = su + 1;
/*printf("%s su=%u non-null\n", __FUNCTION__, su);*/
cso_single_sampler(st->cso_context, su, sampler);
- if (su < st->ctx->Const.MaxVertexTextureImageUnits) {
- cso_single_vertex_sampler(st->cso_context, su, sampler);
- }
}
else {
/*printf("%s su=%u null\n", __FUNCTION__, su);*/
cso_single_sampler(st->cso_context, su, NULL);
- if (su < st->ctx->Const.MaxVertexTextureImageUnits) {
- cso_single_vertex_sampler(st->cso_context, su, NULL);
- }
}
}
cso_single_sampler_done(st->cso_context);
- if (st->ctx->Const.MaxVertexTextureImageUnits > 0) {
- cso_single_vertex_sampler_done(st->cso_context);
- }
}
+static void
+update_samplers(struct st_context *st)
+{
+ update_fragment_samplers(st);
+ update_vertex_samplers(st);
+}
const struct st_tracked_state st_update_sampler = {
"st_update_sampler", /* name */
diff --git a/mesalib/src/mesa/state_tracker/st_atom_texture.c b/mesalib/src/mesa/state_tracker/st_atom_texture.c
index 9d437ad08..990b50438 100644
--- a/mesalib/src/mesa/state_tracker/st_atom_texture.c
+++ b/mesalib/src/mesa/state_tracker/st_atom_texture.c
@@ -182,90 +182,132 @@ st_get_texture_sampler_view_from_stobj(struct st_texture_object *stObj,
return stObj->sampler_view;
}
+static GLboolean
+update_single_texture(struct st_context *st, struct pipe_sampler_view **sampler_view,
+ GLuint texUnit)
+{
+ struct pipe_context *pipe = st->pipe;
+ const struct gl_sampler_object *samp;
+ struct gl_texture_object *texObj;
+ struct st_texture_object *stObj;
+ enum pipe_format st_view_format;
+ GLboolean retval;
+
+ samp = _mesa_get_samplerobj(st->ctx, texUnit);
+
+ texObj = st->ctx->Texture.Unit[texUnit]._Current;
+
+ if (!texObj) {
+ texObj = st_get_default_texture(st);
+ samp = &texObj->Sampler;
+ }
+ stObj = st_texture_object(texObj);
+
+ retval = st_finalize_texture(st->ctx, st->pipe, texObj);
+ if (!retval) {
+ /* out of mem */
+ return GL_FALSE;
+ }
+
+ /* Determine the format of the texture sampler view */
+ st_view_format = stObj->pt->format;
+ {
+ const struct st_texture_image *firstImage =
+ st_texture_image(stObj->base.Image[0][stObj->base.BaseLevel]);
+ const gl_format texFormat = firstImage->base.TexFormat;
+ enum pipe_format firstImageFormat =
+ st_mesa_format_to_pipe_format(texFormat);
+
+ if ((samp->sRGBDecode == GL_SKIP_DECODE_EXT) &&
+ (_mesa_get_format_color_encoding(texFormat) == GL_SRGB)) {
+ /* don't do sRGB->RGB conversion. Interpret the texture
+ * texture data as linear values.
+ */
+ const gl_format linearFormat =
+ _mesa_get_srgb_format_linear(texFormat);
+ firstImageFormat = st_mesa_format_to_pipe_format(linearFormat);
+ }
+
+ if (firstImageFormat != stObj->pt->format)
+ st_view_format = firstImageFormat;
+ }
+
+
+ /* if sampler view has changed dereference it */
+ if (stObj->sampler_view) {
+ if (check_sampler_swizzle(stObj->sampler_view,
+ stObj->base._Swizzle,
+ samp->DepthMode) ||
+ (st_view_format != stObj->sampler_view->format) ||
+ stObj->base.BaseLevel != stObj->sampler_view->u.tex.first_level) {
+ pipe_sampler_view_reference(&stObj->sampler_view, NULL);
+ }
+ }
+
+ *sampler_view = st_get_texture_sampler_view_from_stobj(stObj, pipe,
+ samp,
+ st_view_format);
+ return GL_TRUE;
+}
static void
-update_textures(struct st_context *st)
+update_vertex_textures(struct st_context *st)
{
- struct pipe_context *pipe = st->pipe;
struct gl_vertex_program *vprog = st->ctx->VertexProgram._Current;
- struct gl_fragment_program *fprog = st->ctx->FragmentProgram._Current;
- const GLbitfield samplersUsed = (vprog->Base.SamplersUsed |
- fprog->Base.SamplersUsed);
GLuint su;
- st->state.num_textures = 0;
+ st->state.num_vertex_textures = 0;
/* loop over sampler units (aka tex image units) */
for (su = 0; su < st->ctx->Const.MaxTextureImageUnits; su++) {
struct pipe_sampler_view *sampler_view = NULL;
- enum pipe_format st_view_format;
- if (samplersUsed & (1 << su)) {
- struct gl_texture_object *texObj;
- struct st_texture_object *stObj;
+ if (vprog->Base.SamplersUsed & (1 << su)) {
GLboolean retval;
GLuint texUnit;
- const struct gl_sampler_object *samp;
- if (fprog->Base.SamplersUsed & (1 << su))
- texUnit = fprog->Base.SamplerUnits[su];
- else
- texUnit = vprog->Base.SamplerUnits[su];
+ texUnit = vprog->Base.SamplerUnits[su];
- samp = _mesa_get_samplerobj(st->ctx, texUnit);
+ retval = update_single_texture(st, &sampler_view, texUnit);
+ if (retval == GL_FALSE)
+ continue;
- texObj = st->ctx->Texture.Unit[texUnit]._Current;
+ st->state.num_vertex_textures = su + 1;
- if (!texObj) {
- texObj = st_get_default_texture(st);
- samp = &texObj->Sampler;
- }
- stObj = st_texture_object(texObj);
+ }
+ pipe_sampler_view_reference(&st->state.sampler_vertex_views[su], sampler_view);
+ }
- retval = st_finalize_texture(st->ctx, st->pipe, texObj);
- if (!retval) {
- /* out of mem */
- continue;
- }
+ if (st->ctx->Const.MaxVertexTextureImageUnits > 0) {
+ GLuint numUnits = MIN2(st->state.num_vertex_textures,
+ st->ctx->Const.MaxVertexTextureImageUnits);
+ cso_set_vertex_sampler_views(st->cso_context,
+ numUnits,
+ st->state.sampler_vertex_views);
+ }
+}
- /* Determine the format of the texture sampler view */
- st_view_format = stObj->pt->format;
- {
- const struct st_texture_image *firstImage =
- st_texture_image(stObj->base.Image[0][stObj->base.BaseLevel]);
- const gl_format texFormat = firstImage->base.TexFormat;
- enum pipe_format firstImageFormat =
- st_mesa_format_to_pipe_format(texFormat);
-
- if ((samp->sRGBDecode == GL_SKIP_DECODE_EXT) &&
- (_mesa_get_format_color_encoding(texFormat) == GL_SRGB)) {
- /* don't do sRGB->RGB conversion. Interpret the texture
- * texture data as linear values.
- */
- const gl_format linearFormat =
- _mesa_get_srgb_format_linear(texFormat);
- firstImageFormat = st_mesa_format_to_pipe_format(linearFormat);
- }
-
- if (firstImageFormat != stObj->pt->format)
- st_view_format = firstImageFormat;
- }
+static void
+update_fragment_textures(struct st_context *st)
+{
+ struct gl_fragment_program *fprog = st->ctx->FragmentProgram._Current;
+ GLuint su;
- st->state.num_textures = su + 1;
+ st->state.num_textures = 0;
- /* if sampler view has changed dereference it */
- if (stObj->sampler_view) {
- if (check_sampler_swizzle(stObj->sampler_view,
- stObj->base._Swizzle,
- samp->DepthMode) ||
- (st_view_format != stObj->sampler_view->format) ||
- stObj->base.BaseLevel != stObj->sampler_view->u.tex.first_level) {
- pipe_sampler_view_reference(&stObj->sampler_view, NULL);
- }
- }
+ /* loop over sampler units (aka tex image units) */
+ for (su = 0; su < st->ctx->Const.MaxTextureImageUnits; su++) {
+ struct pipe_sampler_view *sampler_view = NULL;
+ if (fprog->Base.SamplersUsed & (1 << su)) {
+ GLboolean retval;
+ GLuint texUnit;
+
+ texUnit = fprog->Base.SamplerUnits[su];
- sampler_view = st_get_texture_sampler_view_from_stobj(stObj, pipe,
- samp,
- st_view_format);
+ retval = update_single_texture(st, &sampler_view, texUnit);
+ if (retval == GL_FALSE)
+ continue;
+
+ st->state.num_textures = su + 1;
}
pipe_sampler_view_reference(&st->state.sampler_views[su], sampler_view);
}
@@ -273,16 +315,14 @@ update_textures(struct st_context *st)
cso_set_fragment_sampler_views(st->cso_context,
st->state.num_textures,
st->state.sampler_views);
-
- if (st->ctx->Const.MaxVertexTextureImageUnits > 0) {
- GLuint numUnits = MIN2(st->state.num_textures,
- st->ctx->Const.MaxVertexTextureImageUnits);
- cso_set_vertex_sampler_views(st->cso_context,
- numUnits,
- st->state.sampler_views);
- }
}
+static void
+update_textures(struct st_context *st)
+{
+ update_fragment_textures(st);
+ update_vertex_textures(st);
+}
const struct st_tracked_state st_update_texture = {
"st_update_texture", /* name */
@@ -293,9 +333,6 @@ const struct st_tracked_state st_update_texture = {
update_textures /* update */
};
-
-
-
static void
finalize_textures(struct st_context *st)
{
diff --git a/mesalib/src/mesa/state_tracker/st_cb_drawpixels.c b/mesalib/src/mesa/state_tracker/st_cb_drawpixels.c
index e377861b8..9948f8d2b 100644
--- a/mesalib/src/mesa/state_tracker/st_cb_drawpixels.c
+++ b/mesalib/src/mesa/state_tracker/st_cb_drawpixels.c
@@ -39,6 +39,7 @@
#include "main/pack.h"
#include "main/pbo.h"
#include "main/texformat.h"
+#include "main/teximage.h"
#include "main/texstore.h"
#include "program/program.h"
#include "program/prog_print.h"
@@ -419,10 +420,10 @@ make_texture(struct st_context *st,
gl_format mformat;
struct pipe_resource *pt;
enum pipe_format pipeFormat;
- GLenum baseFormat, intFormat;
+ GLenum baseInternalFormat, intFormat;
- baseFormat = base_format(format);
intFormat = internal_format(ctx, format, type);
+ baseInternalFormat = _mesa_base_tex_format(ctx, intFormat);
mformat = st_ChooseTextureFormat_renderable(ctx, intFormat,
format, type, GL_FALSE);
@@ -465,7 +466,7 @@ make_texture(struct st_context *st,
* the texture. We deal with that with texcoords.
*/
success = _mesa_texstore(ctx, 2, /* dims */
- baseFormat, /* baseInternalFormat */
+ baseInternalFormat, /* baseInternalFormat */
mformat, /* gl_format */
dest, /* dest */
0, 0, 0, /* dstX/Y/Zoffset */
diff --git a/mesalib/src/mesa/state_tracker/st_context.c b/mesalib/src/mesa/state_tracker/st_context.c
index ce78956e3..6eddbfc88 100644
--- a/mesalib/src/mesa/state_tracker/st_context.c
+++ b/mesalib/src/mesa/state_tracker/st_context.c
@@ -133,9 +133,6 @@ st_create_context_priv( struct gl_context *ctx, struct pipe_context *pipe )
else
st->internal_target = PIPE_TEXTURE_RECT;
- for (i = 0; i < PIPE_MAX_SAMPLERS; i++)
- st->state.sampler_list[i] = &st->state.samplers[i];
-
for (i = 0; i < 3; i++) {
memset(&st->velems_util_draw[i], 0, sizeof(struct pipe_vertex_element));
st->velems_util_draw[i].src_offset = i * 4 * sizeof(float);
diff --git a/mesalib/src/mesa/state_tracker/st_context.h b/mesalib/src/mesa/state_tracker/st_context.h
index a35439741..c6fc31801 100644
--- a/mesalib/src/mesa/state_tracker/st_context.h
+++ b/mesalib/src/mesa/state_tracker/st_context.h
@@ -1,277 +1,280 @@
-/**************************************************************************
- *
- * Copyright 2003 Tungsten Graphics, 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 TUNGSTEN GRAPHICS 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.
- *
- **************************************************************************/
-
-#ifndef ST_CONTEXT_H
-#define ST_CONTEXT_H
-
-#include "main/mtypes.h"
-#include "pipe/p_state.h"
-#include "state_tracker/st_api.h"
-
-struct bitmap_cache;
-struct blit_state;
-struct dd_function_table;
-struct draw_context;
-struct draw_stage;
-struct gen_mipmap_state;
-struct st_context;
-struct st_fragment_program;
-
-
-#define ST_NEW_MESA 0x1 /* Mesa state has changed */
-#define ST_NEW_FRAGMENT_PROGRAM 0x2
-#define ST_NEW_VERTEX_PROGRAM 0x4
-#define ST_NEW_FRAMEBUFFER 0x8
-#define ST_NEW_EDGEFLAGS_DATA 0x10
-#define ST_NEW_GEOMETRY_PROGRAM 0x20
-
-
-struct st_state_flags {
- GLuint mesa;
- GLuint st;
-};
-
-struct st_tracked_state {
- const char *name;
- struct st_state_flags dirty;
- void (*update)( struct st_context *st );
-};
-
-
-
-struct st_context
-{
- struct st_context_iface iface;
-
- struct gl_context *ctx;
-
- struct pipe_context *pipe;
-
- struct draw_context *draw; /**< For selection/feedback/rastpos only */
- struct draw_stage *feedback_stage; /**< For GL_FEEDBACK rendermode */
- struct draw_stage *selection_stage; /**< For GL_SELECT rendermode */
- struct draw_stage *rastpos_stage; /**< For glRasterPos */
-
-
- /* On old libGL's for linux we need to invalidate the drawables
- * on glViewpport calls, this is set via a option.
- */
- boolean invalidate_on_gl_viewport;
-
- /* Some state is contained in constant objects.
- * Other state is just parameter values.
- */
- struct {
- struct pipe_blend_state blend;
- struct pipe_depth_stencil_alpha_state depth_stencil;
- struct pipe_rasterizer_state rasterizer;
- struct pipe_sampler_state samplers[PIPE_MAX_SAMPLERS];
- struct pipe_sampler_state *sampler_list[PIPE_MAX_SAMPLERS];
- struct pipe_clip_state clip;
- struct {
- void *ptr;
- unsigned size;
- } constants[PIPE_SHADER_TYPES];
- struct pipe_framebuffer_state framebuffer;
- struct pipe_sampler_view *sampler_views[PIPE_MAX_SAMPLERS];
- struct pipe_scissor_state scissor;
- struct pipe_viewport_state viewport;
- unsigned sample_mask;
-
- GLuint num_samplers;
- GLuint num_textures;
-
- GLuint poly_stipple[32]; /**< In OpenGL's bottom-to-top order */
- } state;
-
- char vendor[100];
- char renderer[100];
-
- struct st_state_flags dirty;
-
- GLboolean missing_textures;
- GLboolean vertdata_edgeflags;
-
- /** Mapping from VERT_RESULT_x to post-transformed vertex slot */
- const GLuint *vertex_result_to_slot;
-
- struct st_vertex_program *vp; /**< Currently bound vertex program */
- struct st_fragment_program *fp; /**< Currently bound fragment program */
- struct st_geometry_program *gp; /**< Currently bound geometry program */
-
- struct st_vp_variant *vp_variant;
- struct st_fp_variant *fp_variant;
- struct st_gp_variant *gp_variant;
-
- struct gl_texture_object *default_texture;
-
- struct {
- struct gl_program_cache *cache;
- struct st_fragment_program *program; /**< cur pixel transfer prog */
- GLuint xfer_prog_sn; /**< pixel xfer program serial no. */
- GLuint user_prog_sn; /**< user fragment program serial no. */
- struct st_fragment_program *combined_prog;
- GLuint combined_prog_sn;
- struct pipe_resource *pixelmap_texture;
- struct pipe_sampler_view *pixelmap_sampler_view;
- boolean pixelmap_enabled; /**< use the pixelmap texture? */
- } pixel_xfer;
-
- /** for glBitmap */
- struct {
- struct pipe_rasterizer_state rasterizer;
- struct pipe_sampler_state samplers[2];
- enum pipe_format tex_format;
- void *vs;
- float vertices[4][3][4]; /**< vertex pos + color + texcoord */
- struct pipe_resource *vbuf;
- unsigned vbuf_slot; /* next free slot in vbuf */
- struct bitmap_cache *cache;
- } bitmap;
-
- /** for glDraw/CopyPixels */
- struct {
- struct gl_fragment_program *shaders[4];
- void *vert_shaders[2]; /**< ureg shaders */
- } drawpix;
-
- /** for glClear */
- struct {
- struct pipe_rasterizer_state raster;
- struct pipe_viewport_state viewport;
- struct pipe_clip_state clip;
- void *vs;
- void *fs;
- float vertices[4][2][4]; /**< vertex pos + color */
- struct pipe_resource *vbuf;
- unsigned vbuf_slot;
- boolean enable_ds_separate;
- } clear;
-
- /** used for anything using util_draw_vertex_buffer */
- struct pipe_vertex_element velems_util_draw[3];
-
- void *passthrough_fs; /**< simple pass-through frag shader */
-
- enum pipe_texture_target internal_target;
- struct gen_mipmap_state *gen_mipmap;
- struct blit_state *blit;
-
- struct cso_context *cso_context;
-
- int force_msaa;
- void *winsys_drawable_handle;
-
- /* User vertex buffers. */
- struct {
- struct pipe_resource *buffer;
-
- /** Element size */
- GLuint element_size;
-
- /** Attribute stride */
- GLsizei stride;
- } user_attrib[PIPE_MAX_ATTRIBS];
- unsigned num_user_attribs;
-};
-
-
-/* Need this so that we can implement Mesa callbacks in this module.
- */
-static INLINE struct st_context *st_context(struct gl_context *ctx)
-{
- return ctx->st;
-}
-
-
-/**
- * Wrapper for struct gl_framebuffer.
- * This is an opaque type to the outside world.
- */
-struct st_framebuffer
-{
- struct gl_framebuffer Base;
- void *Private;
-
- struct st_framebuffer_iface *iface;
- enum st_attachment_type statts[ST_ATTACHMENT_COUNT];
- unsigned num_statts;
- int32_t revalidate;
-};
-
-
-extern void st_init_driver_functions(struct dd_function_table *functions);
-
-void st_invalidate_state(struct gl_context * ctx, GLuint new_state);
-
-
-
-#define Y_0_TOP 1
-#define Y_0_BOTTOM 2
-
-static INLINE GLuint
-st_fb_orientation(const struct gl_framebuffer *fb)
-{
- if (fb && fb->Name == 0) {
- /* Drawing into a window (on-screen buffer).
- *
- * Negate Y scale to flip image vertically.
- * The NDC Y coords prior to viewport transformation are in the range
- * [y=-1=bottom, y=1=top]
- * Hardware window coords are in the range [y=0=top, y=H-1=bottom] where
- * H is the window height.
- * Use the viewport transformation to invert Y.
- */
- return Y_0_TOP;
- }
- else {
- /* Drawing into user-created FBO (very likely a texture).
- *
- * For textures, T=0=Bottom, so by extension Y=0=Bottom for rendering.
- */
- return Y_0_BOTTOM;
- }
-}
-
-
-/** clear-alloc a struct-sized object, with casting */
-#define ST_CALLOC_STRUCT(T) (struct T *) calloc(1, sizeof(struct T))
-
-
-extern int
-st_get_msaa(void);
-
-extern struct st_context *
-st_create_context(gl_api api, struct pipe_context *pipe,
- const struct gl_config *visual,
- struct st_context *share);
-
-extern void
-st_destroy_context(struct st_context *st);
-
-
-#endif
+/**************************************************************************
+ *
+ * Copyright 2003 Tungsten Graphics, 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 TUNGSTEN GRAPHICS 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.
+ *
+ **************************************************************************/
+
+#ifndef ST_CONTEXT_H
+#define ST_CONTEXT_H
+
+#include "main/mtypes.h"
+#include "pipe/p_state.h"
+#include "state_tracker/st_api.h"
+
+struct bitmap_cache;
+struct blit_state;
+struct dd_function_table;
+struct draw_context;
+struct draw_stage;
+struct gen_mipmap_state;
+struct st_context;
+struct st_fragment_program;
+
+
+#define ST_NEW_MESA 0x1 /* Mesa state has changed */
+#define ST_NEW_FRAGMENT_PROGRAM 0x2
+#define ST_NEW_VERTEX_PROGRAM 0x4
+#define ST_NEW_FRAMEBUFFER 0x8
+#define ST_NEW_EDGEFLAGS_DATA 0x10
+#define ST_NEW_GEOMETRY_PROGRAM 0x20
+
+
+struct st_state_flags {
+ GLuint mesa;
+ GLuint st;
+};
+
+struct st_tracked_state {
+ const char *name;
+ struct st_state_flags dirty;
+ void (*update)( struct st_context *st );
+};
+
+
+
+struct st_context
+{
+ struct st_context_iface iface;
+
+ struct gl_context *ctx;
+
+ struct pipe_context *pipe;
+
+ struct draw_context *draw; /**< For selection/feedback/rastpos only */
+ struct draw_stage *feedback_stage; /**< For GL_FEEDBACK rendermode */
+ struct draw_stage *selection_stage; /**< For GL_SELECT rendermode */
+ struct draw_stage *rastpos_stage; /**< For glRasterPos */
+
+
+ /* On old libGL's for linux we need to invalidate the drawables
+ * on glViewpport calls, this is set via a option.
+ */
+ boolean invalidate_on_gl_viewport;
+
+ /* Some state is contained in constant objects.
+ * Other state is just parameter values.
+ */
+ struct {
+ struct pipe_blend_state blend;
+ struct pipe_depth_stencil_alpha_state depth_stencil;
+ struct pipe_rasterizer_state rasterizer;
+ struct pipe_sampler_state samplers[PIPE_MAX_SAMPLERS];
+ struct pipe_sampler_state vertex_samplers[PIPE_MAX_VERTEX_SAMPLERS];
+ struct pipe_clip_state clip;
+ struct {
+ void *ptr;
+ unsigned size;
+ } constants[PIPE_SHADER_TYPES];
+ struct pipe_framebuffer_state framebuffer;
+ struct pipe_sampler_view *sampler_views[PIPE_MAX_SAMPLERS];
+ struct pipe_sampler_view *sampler_vertex_views[PIPE_MAX_VERTEX_SAMPLERS];
+ struct pipe_scissor_state scissor;
+ struct pipe_viewport_state viewport;
+ unsigned sample_mask;
+
+ GLuint num_samplers;
+ GLuint num_vertex_samplers;
+ GLuint num_textures;
+ GLuint num_vertex_textures;
+
+ GLuint poly_stipple[32]; /**< In OpenGL's bottom-to-top order */
+ } state;
+
+ char vendor[100];
+ char renderer[100];
+
+ struct st_state_flags dirty;
+
+ GLboolean missing_textures;
+ GLboolean vertdata_edgeflags;
+
+ /** Mapping from VERT_RESULT_x to post-transformed vertex slot */
+ const GLuint *vertex_result_to_slot;
+
+ struct st_vertex_program *vp; /**< Currently bound vertex program */
+ struct st_fragment_program *fp; /**< Currently bound fragment program */
+ struct st_geometry_program *gp; /**< Currently bound geometry program */
+
+ struct st_vp_variant *vp_variant;
+ struct st_fp_variant *fp_variant;
+ struct st_gp_variant *gp_variant;
+
+ struct gl_texture_object *default_texture;
+
+ struct {
+ struct gl_program_cache *cache;
+ struct st_fragment_program *program; /**< cur pixel transfer prog */
+ GLuint xfer_prog_sn; /**< pixel xfer program serial no. */
+ GLuint user_prog_sn; /**< user fragment program serial no. */
+ struct st_fragment_program *combined_prog;
+ GLuint combined_prog_sn;
+ struct pipe_resource *pixelmap_texture;
+ struct pipe_sampler_view *pixelmap_sampler_view;
+ boolean pixelmap_enabled; /**< use the pixelmap texture? */
+ } pixel_xfer;
+
+ /** for glBitmap */
+ struct {
+ struct pipe_rasterizer_state rasterizer;
+ struct pipe_sampler_state samplers[2];
+ enum pipe_format tex_format;
+ void *vs;
+ float vertices[4][3][4]; /**< vertex pos + color + texcoord */
+ struct pipe_resource *vbuf;
+ unsigned vbuf_slot; /* next free slot in vbuf */
+ struct bitmap_cache *cache;
+ } bitmap;
+
+ /** for glDraw/CopyPixels */
+ struct {
+ struct gl_fragment_program *shaders[4];
+ void *vert_shaders[2]; /**< ureg shaders */
+ } drawpix;
+
+ /** for glClear */
+ struct {
+ struct pipe_rasterizer_state raster;
+ struct pipe_viewport_state viewport;
+ struct pipe_clip_state clip;
+ void *vs;
+ void *fs;
+ float vertices[4][2][4]; /**< vertex pos + color */
+ struct pipe_resource *vbuf;
+ unsigned vbuf_slot;
+ boolean enable_ds_separate;
+ } clear;
+
+ /** used for anything using util_draw_vertex_buffer */
+ struct pipe_vertex_element velems_util_draw[3];
+
+ void *passthrough_fs; /**< simple pass-through frag shader */
+
+ enum pipe_texture_target internal_target;
+ struct gen_mipmap_state *gen_mipmap;
+ struct blit_state *blit;
+
+ struct cso_context *cso_context;
+
+ int force_msaa;
+ void *winsys_drawable_handle;
+
+ /* User vertex buffers. */
+ struct {
+ struct pipe_resource *buffer;
+
+ /** Element size */
+ GLuint element_size;
+
+ /** Attribute stride */
+ GLsizei stride;
+ } user_attrib[PIPE_MAX_ATTRIBS];
+ unsigned num_user_attribs;
+};
+
+
+/* Need this so that we can implement Mesa callbacks in this module.
+ */
+static INLINE struct st_context *st_context(struct gl_context *ctx)
+{
+ return ctx->st;
+}
+
+
+/**
+ * Wrapper for struct gl_framebuffer.
+ * This is an opaque type to the outside world.
+ */
+struct st_framebuffer
+{
+ struct gl_framebuffer Base;
+ void *Private;
+
+ struct st_framebuffer_iface *iface;
+ enum st_attachment_type statts[ST_ATTACHMENT_COUNT];
+ unsigned num_statts;
+ int32_t revalidate;
+};
+
+
+extern void st_init_driver_functions(struct dd_function_table *functions);
+
+void st_invalidate_state(struct gl_context * ctx, GLuint new_state);
+
+
+
+#define Y_0_TOP 1
+#define Y_0_BOTTOM 2
+
+static INLINE GLuint
+st_fb_orientation(const struct gl_framebuffer *fb)
+{
+ if (fb && fb->Name == 0) {
+ /* Drawing into a window (on-screen buffer).
+ *
+ * Negate Y scale to flip image vertically.
+ * The NDC Y coords prior to viewport transformation are in the range
+ * [y=-1=bottom, y=1=top]
+ * Hardware window coords are in the range [y=0=top, y=H-1=bottom] where
+ * H is the window height.
+ * Use the viewport transformation to invert Y.
+ */
+ return Y_0_TOP;
+ }
+ else {
+ /* Drawing into user-created FBO (very likely a texture).
+ *
+ * For textures, T=0=Bottom, so by extension Y=0=Bottom for rendering.
+ */
+ return Y_0_BOTTOM;
+ }
+}
+
+
+/** clear-alloc a struct-sized object, with casting */
+#define ST_CALLOC_STRUCT(T) (struct T *) calloc(1, sizeof(struct T))
+
+
+extern int
+st_get_msaa(void);
+
+extern struct st_context *
+st_create_context(gl_api api, struct pipe_context *pipe,
+ const struct gl_config *visual,
+ struct st_context *share);
+
+extern void
+st_destroy_context(struct st_context *st);
+
+
+#endif
diff --git a/mesalib/src/mesa/state_tracker/st_extensions.c b/mesalib/src/mesa/state_tracker/st_extensions.c
index ad8e6bb9e..d3aebe526 100644
--- a/mesalib/src/mesa/state_tracker/st_extensions.c
+++ b/mesalib/src/mesa/state_tracker/st_extensions.c
@@ -603,4 +603,8 @@ void st_init_extensions(struct st_context *st)
else if (screen->get_param(screen, PIPE_CAP_SEAMLESS_CUBE_MAP)) {
ctx->Extensions.ARB_seamless_cube_map = GL_TRUE;
}
+
+ if (screen->get_param(screen, PIPE_CAP_SM3)) {
+ ctx->Extensions.ARB_shader_texture_lod = GL_TRUE;
+ }
}
diff --git a/xorg-server/Makefile.am b/xorg-server/Makefile.am
index 1c522137d..cea140bea 100644
--- a/xorg-server/Makefile.am
+++ b/xorg-server/Makefile.am
@@ -1,95 +1,97 @@
-AUTOMAKE_OPTIONS=nostdinc
-ACLOCAL_AMFLAGS = -I m4
-
-if COMPOSITE
-COMPOSITE_DIR=composite
-endif
-
-if GLX
-GLX_DIR=glx
-endif
-
-if DBE
-DBE_DIR=dbe
-endif
-
-if RECORD
-RECORD_DIR=record
-endif
-
-SUBDIRS = \
- doc \
- include \
- dix \
- fb \
- mi \
- Xext \
- miext \
- os \
- randr \
- render \
- Xi \
- xkb \
- $(DBE_DIR) \
- $(RECORD_DIR) \
- xfixes \
- damageext \
- $(COMPOSITE_DIR) \
- $(GLX_DIR) \
- exa \
- config \
- hw \
- test
-
-if XORG
-aclocaldir = $(datadir)/aclocal
-aclocal_DATA = xorg-server.m4
-
-pkgconfigdir = $(libdir)/pkgconfig
-pkgconfig_DATA = xorg-server.pc
-endif
-
-EXTRA_DIST = xorg-server.pc.in xorg-server.m4 autogen.sh
-
-DISTCHECK_CONFIGURE_FLAGS=\
- --with-xkb-path=$(XKB_BASE_DIRECTORY) \
- --with-xkb-bin-directory=$(XKB_BIN_DIRECTORY) \
- --with-xkb-output='$${datadir}/X11/xkb/compiled'
-
-.PHONY: ChangeLog INSTALL
-
-INSTALL:
- $(INSTALL_CMD)
-
-ChangeLog:
- $(CHANGELOG_CMD)
-
-dist-hook: ChangeLog INSTALL
-
-DIST_SUBDIRS = \
- doc \
- include \
- dix \
- fb \
- mi \
- Xext \
- miext \
- os \
- randr \
- render \
- Xi \
- xkb \
- dbe \
- record \
- xfixes \
- damageext \
- composite \
- glx \
- exa \
- config \
- hw \
- test
-
-# gross hack
-relink: all
- $(AM_V_at)$(MAKE) -C hw relink
+AUTOMAKE_OPTIONS=nostdinc
+ACLOCAL_AMFLAGS = -I m4
+
+if COMPOSITE
+COMPOSITE_DIR=composite
+endif
+
+if GLX
+GLX_DIR=glx
+endif
+
+if DBE
+DBE_DIR=dbe
+endif
+
+if RECORD
+RECORD_DIR=record
+endif
+
+SUBDIRS = \
+ doc \
+ man \
+ include \
+ dix \
+ fb \
+ mi \
+ Xext \
+ miext \
+ os \
+ randr \
+ render \
+ Xi \
+ xkb \
+ $(DBE_DIR) \
+ $(RECORD_DIR) \
+ xfixes \
+ damageext \
+ $(COMPOSITE_DIR) \
+ $(GLX_DIR) \
+ exa \
+ config \
+ hw \
+ test
+
+if XORG
+aclocaldir = $(datadir)/aclocal
+aclocal_DATA = xorg-server.m4
+
+pkgconfigdir = $(libdir)/pkgconfig
+pkgconfig_DATA = xorg-server.pc
+endif
+
+EXTRA_DIST = xorg-server.pc.in xorg-server.m4 autogen.sh
+
+DISTCHECK_CONFIGURE_FLAGS=\
+ --with-xkb-path=$(XKB_BASE_DIRECTORY) \
+ --with-xkb-bin-directory=$(XKB_BIN_DIRECTORY) \
+ --with-xkb-output='$${datadir}/X11/xkb/compiled'
+
+.PHONY: ChangeLog INSTALL
+
+INSTALL:
+ $(INSTALL_CMD)
+
+ChangeLog:
+ $(CHANGELOG_CMD)
+
+dist-hook: ChangeLog INSTALL
+
+DIST_SUBDIRS = \
+ doc \
+ man \
+ include \
+ dix \
+ fb \
+ mi \
+ Xext \
+ miext \
+ os \
+ randr \
+ render \
+ Xi \
+ xkb \
+ dbe \
+ record \
+ xfixes \
+ damageext \
+ composite \
+ glx \
+ exa \
+ config \
+ hw \
+ test
+
+# gross hack
+relink: all
+ $(AM_V_at)$(MAKE) -C hw relink
diff --git a/xorg-server/Xext/xtest.c b/xorg-server/Xext/xtest.c
index 18e1ef7ae..daa6430f1 100644
--- a/xorg-server/Xext/xtest.c
+++ b/xorg-server/Xext/xtest.c
@@ -52,6 +52,7 @@
#include "mipointer.h"
#include "xserver-properties.h"
#include "exevents.h"
+#include "eventstr.h"
#include "inpututils.h"
#include "modinit.h"
@@ -61,7 +62,7 @@ extern int DeviceValuator;
/* XTest events are sent during request processing and may be interruped by
* a SIGIO. We need a separate event list to avoid events overwriting each
* other's memory */
-static EventListPtr xtest_evlist;
+static InternalEvent* xtest_evlist;
/**
* xtestpointer
@@ -428,7 +429,7 @@ ProcXTestFakeInput(ClientPtr client)
}
for (i = 0; i < nevents; i++)
- mieqProcessDeviceEvent(dev, (InternalEvent*)(xtest_evlist+i)->event, NULL);
+ mieqProcessDeviceEvent(dev, &xtest_evlist[i], NULL);
if (need_ptr_update)
miPointerUpdateSprite(dev);
diff --git a/xorg-server/Xi/exevents.c b/xorg-server/Xi/exevents.c
index 76d5c3759..c6f9d467f 100644
--- a/xorg-server/Xi/exevents.c
+++ b/xorg-server/Xi/exevents.c
@@ -77,6 +77,7 @@ SOFTWARE.
#include "xiquerydevice.h" /* For List*Info */
#include "eventconvert.h"
#include "eventstr.h"
+#include "inpututils.h"
#include <X11/extensions/XKBproto.h>
#include "xkbsrv.h"
@@ -920,7 +921,7 @@ ProcessOtherEvent(InternalEvent *ev, DeviceIntPtr device)
DeviceIntPtr mouse = NULL, kbd = NULL;
DeviceEvent *event = &ev->device_event;
- CHECKEVENT(ev);
+ verify_internal_event(ev);
if (ev->any.type == ET_RawKeyPress ||
ev->any.type == ET_RawKeyRelease ||
@@ -1188,6 +1189,108 @@ FixDeviceValuator(DeviceIntPtr dev, deviceValuator * ev, ValuatorClassPtr v,
first += ev->num_valuators;
}
+static void
+DeliverStateNotifyEvent(DeviceIntPtr dev, WindowPtr win)
+{
+ int evcount = 1;
+ deviceStateNotify *ev, *sev;
+ deviceKeyStateNotify *kev;
+ deviceButtonStateNotify *bev;
+
+ KeyClassPtr k;
+ ButtonClassPtr b;
+ ValuatorClassPtr v;
+ int nval = 0, nkeys = 0, nbuttons = 0, first = 0;
+
+ if (!(wOtherInputMasks(win)) ||
+ !(wOtherInputMasks(win)->inputEvents[dev->id] & DeviceStateNotifyMask))
+ return;
+
+ if ((b = dev->button) != NULL) {
+ nbuttons = b->numButtons;
+ if (nbuttons > 32)
+ evcount++;
+ }
+ if ((k = dev->key) != NULL) {
+ nkeys = k->xkbInfo->desc->max_key_code -
+ k->xkbInfo->desc->min_key_code;
+ if (nkeys > 32)
+ evcount++;
+ if (nbuttons > 0) {
+ evcount++;
+ }
+ }
+ if ((v = dev->valuator) != NULL) {
+ nval = v->numAxes;
+
+ if (nval > 3)
+ evcount++;
+ if (nval > 6) {
+ if (!(k && b))
+ evcount++;
+ if (nval > 9)
+ evcount += ((nval - 7) / 3);
+ }
+ }
+
+ sev = ev = (deviceStateNotify *) malloc(evcount * sizeof(xEvent));
+ FixDeviceStateNotify(dev, ev, NULL, NULL, NULL, first);
+
+ if (b != NULL) {
+ FixDeviceStateNotify(dev, ev++, NULL, b, v, first);
+ first += 3;
+ nval -= 3;
+ if (nbuttons > 32) {
+ (ev - 1)->deviceid |= MORE_EVENTS;
+ bev = (deviceButtonStateNotify *) ev++;
+ bev->type = DeviceButtonStateNotify;
+ bev->deviceid = dev->id;
+ memcpy((char*)&bev->buttons[4], (char*)&b->down[4], DOWN_LENGTH - 4);
+ }
+ if (nval > 0) {
+ (ev - 1)->deviceid |= MORE_EVENTS;
+ FixDeviceValuator(dev, (deviceValuator *) ev++, v, first);
+ first += 3;
+ nval -= 3;
+ }
+ }
+
+ if (k != NULL) {
+ FixDeviceStateNotify(dev, ev++, k, NULL, v, first);
+ first += 3;
+ nval -= 3;
+ if (nkeys > 32) {
+ (ev - 1)->deviceid |= MORE_EVENTS;
+ kev = (deviceKeyStateNotify *) ev++;
+ kev->type = DeviceKeyStateNotify;
+ kev->deviceid = dev->id;
+ memmove((char *)&kev->keys[0], (char *)&k->down[4], 28);
+ }
+ if (nval > 0) {
+ (ev - 1)->deviceid |= MORE_EVENTS;
+ FixDeviceValuator(dev, (deviceValuator *) ev++, v, first);
+ first += 3;
+ nval -= 3;
+ }
+ }
+
+ while (nval > 0) {
+ FixDeviceStateNotify(dev, ev++, NULL, NULL, v, first);
+ first += 3;
+ nval -= 3;
+ if (nval > 0) {
+ (ev - 1)->deviceid |= MORE_EVENTS;
+ FixDeviceValuator(dev, (deviceValuator *) ev++, v, first);
+ first += 3;
+ nval -= 3;
+ }
+ }
+
+ DeliverEventsToWindow(dev, win, (xEvent *) sev, evcount,
+ DeviceStateNotifyMask, NullGrab);
+ free(sev);
+}
+
void
DeviceFocusEvent(DeviceIntPtr dev, int type, int mode, int detail,
WindowPtr pWin)
@@ -1254,104 +1357,8 @@ DeviceFocusEvent(DeviceIntPtr dev, int type, int mode, int detail,
DeliverEventsToWindow(dev, pWin, (xEvent *) & event, 1,
DeviceFocusChangeMask, NullGrab);
- if ((event.type == DeviceFocusIn) &&
- (wOtherInputMasks(pWin)) &&
- (wOtherInputMasks(pWin)->inputEvents[dev->id] & DeviceStateNotifyMask))
- {
- int evcount = 1;
- deviceStateNotify *ev, *sev;
- deviceKeyStateNotify *kev;
- deviceButtonStateNotify *bev;
-
- KeyClassPtr k;
- ButtonClassPtr b;
- ValuatorClassPtr v;
- int nval = 0, nkeys = 0, nbuttons = 0, first = 0;
-
- if ((b = dev->button) != NULL) {
- nbuttons = b->numButtons;
- if (nbuttons > 32)
- evcount++;
- }
- if ((k = dev->key) != NULL) {
- nkeys = k->xkbInfo->desc->max_key_code -
- k->xkbInfo->desc->min_key_code;
- if (nkeys > 32)
- evcount++;
- if (nbuttons > 0) {
- evcount++;
- }
- }
- if ((v = dev->valuator) != NULL) {
- nval = v->numAxes;
-
- if (nval > 3)
- evcount++;
- if (nval > 6) {
- if (!(k && b))
- evcount++;
- if (nval > 9)
- evcount += ((nval - 7) / 3);
- }
- }
-
- sev = ev = (deviceStateNotify *) malloc(evcount * sizeof(xEvent));
- FixDeviceStateNotify(dev, ev, NULL, NULL, NULL, first);
-
- if (b != NULL) {
- FixDeviceStateNotify(dev, ev++, NULL, b, v, first);
- first += 3;
- nval -= 3;
- if (nbuttons > 32) {
- (ev - 1)->deviceid |= MORE_EVENTS;
- bev = (deviceButtonStateNotify *) ev++;
- bev->type = DeviceButtonStateNotify;
- bev->deviceid = dev->id;
- memcpy((char*)&bev->buttons[4], (char*)&b->down[4], DOWN_LENGTH - 4);
- }
- if (nval > 0) {
- (ev - 1)->deviceid |= MORE_EVENTS;
- FixDeviceValuator(dev, (deviceValuator *) ev++, v, first);
- first += 3;
- nval -= 3;
- }
- }
-
- if (k != NULL) {
- FixDeviceStateNotify(dev, ev++, k, NULL, v, first);
- first += 3;
- nval -= 3;
- if (nkeys > 32) {
- (ev - 1)->deviceid |= MORE_EVENTS;
- kev = (deviceKeyStateNotify *) ev++;
- kev->type = DeviceKeyStateNotify;
- kev->deviceid = dev->id;
- memmove((char *)&kev->keys[0], (char *)&k->down[4], 28);
- }
- if (nval > 0) {
- (ev - 1)->deviceid |= MORE_EVENTS;
- FixDeviceValuator(dev, (deviceValuator *) ev++, v, first);
- first += 3;
- nval -= 3;
- }
- }
-
- while (nval > 0) {
- FixDeviceStateNotify(dev, ev++, NULL, NULL, v, first);
- first += 3;
- nval -= 3;
- if (nval > 0) {
- (ev - 1)->deviceid |= MORE_EVENTS;
- FixDeviceValuator(dev, (deviceValuator *) ev++, v, first);
- first += 3;
- nval -= 3;
- }
- }
-
- DeliverEventsToWindow(dev, pWin, (xEvent *) sev, evcount,
- DeviceStateNotifyMask, NullGrab);
- free(sev);
- }
+ if (event.type == DeviceFocusIn)
+ DeliverStateNotifyEvent(dev, pWin);
}
int
diff --git a/xorg-server/Xi/xichangehierarchy.c b/xorg-server/Xi/xichangehierarchy.c
index 0736a5a36..96ead6fcd 100644
--- a/xorg-server/Xi/xichangehierarchy.c
+++ b/xorg-server/Xi/xichangehierarchy.c
@@ -355,6 +355,7 @@ detach_slave(ClientPtr client, xXIDetachSlaveInfo *c, int flags[MAXDEVICES])
goto unwind;
}
+ ReleaseButtonsAndKeys(dev);
AttachDevice(client, dev, NULL);
flags[dev->id] |= XISlaveDetached;
@@ -406,6 +407,7 @@ attach_slave(ClientPtr client, xXIAttachSlaveInfo *c,
goto unwind;
}
+ ReleaseButtonsAndKeys(dev);
AttachDevice(client, dev, newmaster);
flags[dev->id] |= XISlaveAttached;
diff --git a/xorg-server/Xi/xiqueryversion.c b/xorg-server/Xi/xiqueryversion.c
index ae63297da..f647f9872 100644
--- a/xorg-server/Xi/xiqueryversion.c
+++ b/xorg-server/Xi/xiqueryversion.c
@@ -58,7 +58,6 @@ ProcXIQueryVersion(ClientPtr client)
xXIQueryVersionReply rep;
XIClientPtr pXIClient;
int major, minor;
- unsigned int sversion, cversion;
REQUEST(xXIQueryVersionReq);
REQUEST_SIZE_MATCH(xXIQueryVersionReq);
@@ -72,10 +71,8 @@ ProcXIQueryVersion(ClientPtr client)
pXIClient = dixLookupPrivate(&client->devPrivates, XIClientPrivateKey);
- sversion = XIVersion.major_version * 1000 + XIVersion.minor_version;
- cversion = stuff->major_version * 1000 + stuff->minor_version;
-
- if (sversion > cversion)
+ if (version_compare(XIVersion.major_version, XIVersion.minor_version,
+ stuff->major_version, stuff->minor_version) > 0)
{
major = stuff->major_version;
minor = stuff->minor_version;
diff --git a/xorg-server/composite/compalloc.c b/xorg-server/composite/compalloc.c
index 7164c0d3c..5c27631e1 100644
--- a/xorg-server/composite/compalloc.c
+++ b/xorg-server/composite/compalloc.c
@@ -104,6 +104,35 @@ compDestroyDamage (DamagePtr pDamage, void *closure)
cw->damage = 0;
}
+static Bool
+compMarkWindows(WindowPtr pWin,
+ WindowPtr *ppLayerWin)
+{
+ ScreenPtr pScreen = pWin->drawable.pScreen;
+ WindowPtr pLayerWin = pWin;
+
+ if (!pWin->viewable)
+ return FALSE;
+
+ (*pScreen->MarkOverlappedWindows)(pWin, pWin, &pLayerWin);
+ (*pScreen->MarkWindow)(pLayerWin->parent);
+
+ *ppLayerWin = pLayerWin;
+
+ return TRUE;
+}
+
+static void
+compHandleMarkedWindows(WindowPtr pWin, WindowPtr pLayerWin)
+{
+ ScreenPtr pScreen = pWin->drawable.pScreen;
+
+ (*pScreen->ValidateTree)(pLayerWin->parent, pLayerWin, VTOther);
+ (*pScreen->HandleExposures)(pLayerWin->parent);
+ if (pScreen->PostValidateTree)
+ (*pScreen->PostValidateTree)(pLayerWin->parent, pLayerWin, VTOther);
+}
+
/*
* Redirect one window for one client
*/
@@ -112,8 +141,9 @@ compRedirectWindow (ClientPtr pClient, WindowPtr pWin, int update)
{
CompWindowPtr cw = GetCompWindow (pWin);
CompClientWindowPtr ccw;
- Bool wasMapped = pWin->mapped;
CompScreenPtr cs = GetCompScreen(pWin->drawable.pScreen);
+ WindowPtr pLayerWin;
+ Bool anyMarked = FALSE;
if (pWin == cs->pOverlayWin) {
return Success;
@@ -163,16 +193,14 @@ compRedirectWindow (ClientPtr pClient, WindowPtr pWin, int update)
free(cw);
return BadAlloc;
}
- if (wasMapped)
- {
- DisableMapUnmapEvents (pWin);
- UnmapWindow (pWin, FALSE);
- EnableMapUnmapEvents (pWin);
- }
+ anyMarked = compMarkWindows (pWin, &pLayerWin);
+
+ /* Make sure our borderClip is correct for ValidateTree */
RegionNull(&cw->borderClip);
- cw->borderClipX = 0;
- cw->borderClipY = 0;
+ RegionCopy(&cw->borderClip, &pWin->borderClip);
+ cw->borderClipX = pWin->drawable.x;
+ cw->borderClipY = pWin->drawable.y;
cw->update = CompositeRedirectAutomatic;
cw->clients = 0;
cw->oldx = COMP_ORIGIN_INVALID;
@@ -188,16 +216,9 @@ compRedirectWindow (ClientPtr pClient, WindowPtr pWin, int update)
return BadAlloc;
if (ccw->update == CompositeRedirectManual)
{
- /* If the window was CompositeRedirectAutomatic, then
- * unmap the window so that the parent clip list will
- * be correctly recomputed.
- */
- if (pWin->mapped)
- {
- DisableMapUnmapEvents (pWin);
- UnmapWindow (pWin, FALSE);
- EnableMapUnmapEvents (pWin);
- }
+ if (!anyMarked)
+ anyMarked = compMarkWindows (pWin, &pLayerWin);
+
if (cw->damageRegistered)
{
DamageUnregister (&pWin->drawable, cw->damage);
@@ -205,25 +226,51 @@ compRedirectWindow (ClientPtr pClient, WindowPtr pWin, int update)
}
cw->update = CompositeRedirectManual;
}
+ else if (cw->update == CompositeRedirectAutomatic && !cw->damageRegistered) {
+ if (!anyMarked)
+ anyMarked = compMarkWindows (pWin, &pLayerWin);
+ }
if (!compCheckRedirect (pWin))
{
FreeResource (ccw->id, RT_NONE);
return BadAlloc;
}
- if (wasMapped && !pWin->mapped)
- {
- Bool overrideRedirect = pWin->overrideRedirect;
- pWin->overrideRedirect = TRUE;
- DisableMapUnmapEvents (pWin);
- MapWindow (pWin, pClient);
- EnableMapUnmapEvents (pWin);
- pWin->overrideRedirect = overrideRedirect;
- }
+
+ if (anyMarked)
+ compHandleMarkedWindows (pWin, pLayerWin);
return Success;
}
+void
+compRestoreWindow (WindowPtr pWin, PixmapPtr pPixmap)
+{
+ ScreenPtr pScreen = pWin->drawable.pScreen;
+ WindowPtr pParent = pWin->parent;
+
+ if (pParent->drawable.depth == pWin->drawable.depth) {
+ GCPtr pGC = GetScratchGC (pWin->drawable.depth, pScreen);
+ int bw = (int) pWin->borderWidth;
+ int x = bw;
+ int y = bw;
+ int w = pWin->drawable.width;
+ int h = pWin->drawable.height;
+
+ if (pGC) {
+ ChangeGCVal val;
+ val.val = IncludeInferiors;
+ ChangeGC (NullClient, pGC, GCSubwindowMode, &val);
+ ValidateGC(&pWin->drawable, pGC);
+ (*pGC->ops->CopyArea) (&pPixmap->drawable,
+ &pWin->drawable,
+ pGC,
+ x, y, w, h, 0, 0);
+ FreeScratchGC (pGC);
+ }
+ }
+}
+
/*
* Free one of the per-client per-window resources, clearing
* redirect and the per-window pointer as appropriate
@@ -231,9 +278,12 @@ compRedirectWindow (ClientPtr pClient, WindowPtr pWin, int update)
void
compFreeClientWindow (WindowPtr pWin, XID id)
{
+ ScreenPtr pScreen = pWin->drawable.pScreen;
CompWindowPtr cw = GetCompWindow (pWin);
CompClientWindowPtr ccw, *prev;
- Bool wasMapped = pWin->mapped;
+ Bool anyMarked = FALSE;
+ WindowPtr pLayerWin;
+ PixmapPtr pPixmap = NULL;
if (!cw)
return;
@@ -250,15 +300,12 @@ compFreeClientWindow (WindowPtr pWin, XID id)
}
if (!cw->clients)
{
- if (wasMapped)
- {
- DisableMapUnmapEvents (pWin);
- UnmapWindow (pWin, FALSE);
- EnableMapUnmapEvents (pWin);
- }
+ anyMarked = compMarkWindows (pWin, &pLayerWin);
- if (pWin->redirectDraw != RedirectDrawNone)
- compFreePixmap (pWin);
+ if (pWin->redirectDraw != RedirectDrawNone) {
+ pPixmap = (*pScreen->GetWindowPixmap) (pWin);
+ compSetParentPixmap (pWin);
+ }
if (cw->damage)
DamageDestroy (cw->damage);
@@ -271,19 +318,20 @@ compFreeClientWindow (WindowPtr pWin, XID id)
else if (cw->update == CompositeRedirectAutomatic &&
!cw->damageRegistered && pWin->redirectDraw != RedirectDrawNone)
{
+ anyMarked = compMarkWindows (pWin, &pLayerWin);
+
DamageRegister (&pWin->drawable, cw->damage);
cw->damageRegistered = TRUE;
pWin->redirectDraw = RedirectDrawAutomatic;
DamageDamageRegion(&pWin->drawable, &pWin->borderSize);
}
- if (wasMapped && !pWin->mapped)
- {
- Bool overrideRedirect = pWin->overrideRedirect;
- pWin->overrideRedirect = TRUE;
- DisableMapUnmapEvents (pWin);
- MapWindow (pWin, clients[CLIENT_ID(id)]);
- EnableMapUnmapEvents (pWin);
- pWin->overrideRedirect = overrideRedirect;
+
+ if (anyMarked)
+ compHandleMarkedWindows (pWin, pLayerWin);
+
+ if (pPixmap) {
+ compRestoreWindow (pWin, pPixmap);
+ (*pScreen->DestroyPixmap) (pPixmap);
}
}
@@ -536,9 +584,8 @@ compNewPixmap (WindowPtr pWin, int x, int y, int w, int h, Bool map)
{
ChangeGCVal val;
val.val = IncludeInferiors;
-
+ ChangeGC (NullClient, pGC, GCSubwindowMode, &val);
ValidateGC(&pPixmap->drawable, pGC);
- ChangeGC (serverClient, pGC, GCSubwindowMode, &val);
(*pGC->ops->CopyArea) (&pParent->drawable,
&pPixmap->drawable,
pGC,
@@ -617,10 +664,10 @@ compAllocPixmap (WindowPtr pWin)
}
void
-compFreePixmap (WindowPtr pWin)
+compSetParentPixmap (WindowPtr pWin)
{
ScreenPtr pScreen = pWin->drawable.pScreen;
- PixmapPtr pRedirectPixmap, pParentPixmap;
+ PixmapPtr pParentPixmap;
CompWindowPtr cw = GetCompWindow (pWin);
if (cw->damageRegistered)
@@ -636,11 +683,9 @@ compFreePixmap (WindowPtr pWin)
* parent exposed area; regions beyond the parent cause crashes
*/
RegionCopy(&pWin->borderClip, &cw->borderClip);
- pRedirectPixmap = (*pScreen->GetWindowPixmap) (pWin);
pParentPixmap = (*pScreen->GetWindowPixmap) (pWin->parent);
pWin->redirectDraw = RedirectDrawNone;
compSetPixmap (pWin, pParentPixmap);
- (*pScreen->DestroyPixmap) (pRedirectPixmap);
}
/*
diff --git a/xorg-server/composite/compint.h b/xorg-server/composite/compint.h
index 55cd6459e..bb5335d70 100644
--- a/xorg-server/composite/compint.h
+++ b/xorg-server/composite/compint.h
@@ -1,333 +1,336 @@
-/*
- * Copyright (c) 2006, Oracle and/or its affiliates. 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 (including the next
- * paragraph) shall be included in all copies or substantial portions of the
- * Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
- * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
- * DEALINGS IN THE SOFTWARE.
- *
- * 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
-
-#ifndef _COMPINT_H_
-#define _COMPINT_H_
-
-#include "misc.h"
-#include "scrnintstr.h"
-#include "os.h"
-#include "regionstr.h"
-#include "validate.h"
-#include "windowstr.h"
-#include "input.h"
-#include "resource.h"
-#include "colormapst.h"
-#include "cursorstr.h"
-#include "dixstruct.h"
-#include "gcstruct.h"
-#include "servermd.h"
-#include "dixevents.h"
-#include "globals.h"
-#include "picturestr.h"
-#include "extnsionst.h"
-#include "privates.h"
-#include "mi.h"
-#include "damage.h"
-#include "damageextint.h"
-#include "xfixes.h"
-#include <X11/extensions/compositeproto.h>
-#include <assert.h>
-
-/*
- * enable this for debugging
-
- #define COMPOSITE_DEBUG
- */
-
-typedef struct _CompClientWindow {
- struct _CompClientWindow *next;
- XID id;
- int update;
-} CompClientWindowRec, *CompClientWindowPtr;
-
-typedef struct _CompWindow {
- RegionRec borderClip;
- DamagePtr damage; /* for automatic update mode */
- Bool damageRegistered;
- Bool damaged;
- int update;
- CompClientWindowPtr clients;
- int oldx;
- int oldy;
- PixmapPtr pOldPixmap;
- int borderClipX, borderClipY;
-} CompWindowRec, *CompWindowPtr;
-
-#define COMP_ORIGIN_INVALID 0x80000000
-
-typedef struct _CompSubwindows {
- int update;
- CompClientWindowPtr clients;
-} CompSubwindowsRec, *CompSubwindowsPtr;
-
-#ifndef COMP_INCLUDE_RGB24_VISUAL
-#define COMP_INCLUDE_RGB24_VISUAL 0
-#endif
-
-typedef struct _CompOverlayClientRec *CompOverlayClientPtr;
-
-typedef struct _CompOverlayClientRec {
- CompOverlayClientPtr pNext;
- ClientPtr pClient;
- ScreenPtr pScreen;
- XID resource;
-} CompOverlayClientRec;
-
-typedef struct _CompScreen {
- PositionWindowProcPtr PositionWindow;
- CopyWindowProcPtr CopyWindow;
- CreateWindowProcPtr CreateWindow;
- DestroyWindowProcPtr DestroyWindow;
- RealizeWindowProcPtr RealizeWindow;
- UnrealizeWindowProcPtr UnrealizeWindow;
- ClipNotifyProcPtr ClipNotify;
- /*
- * Called from ConfigureWindow, these
- * three track changes to the offscreen storage
- * geometry
- */
- ConfigNotifyProcPtr ConfigNotify;
- MoveWindowProcPtr MoveWindow;
- ResizeWindowProcPtr ResizeWindow;
- ChangeBorderWidthProcPtr ChangeBorderWidth;
- /*
- * Reparenting has an effect on Subwindows redirect
- */
- ReparentWindowProcPtr ReparentWindow;
-
- /*
- * Colormaps for new visuals better not get installed
- */
- InstallColormapProcPtr InstallColormap;
-
- /*
- * Fake backing store via automatic redirection
- */
- ChangeWindowAttributesProcPtr ChangeWindowAttributes;
-
- ScreenBlockHandlerProcPtr BlockHandler;
- CloseScreenProcPtr CloseScreen;
- int numAlternateVisuals;
- VisualID *alternateVisuals;
-
- WindowPtr pOverlayWin;
- Window overlayWid;
- CompOverlayClientPtr pOverlayClients;
-
- GetImageProcPtr GetImage;
- SourceValidateProcPtr SourceValidate;
-} CompScreenRec, *CompScreenPtr;
-
-extern DevPrivateKeyRec CompScreenPrivateKeyRec;
-#define CompScreenPrivateKey (&CompScreenPrivateKeyRec)
-
-extern DevPrivateKeyRec CompWindowPrivateKeyRec;
-#define CompWindowPrivateKey (&CompWindowPrivateKeyRec)
-
-extern DevPrivateKeyRec CompSubwindowsPrivateKeyRec;
-#define CompSubwindowsPrivateKey (&CompSubwindowsPrivateKeyRec)
-
-#define GetCompScreen(s) ((CompScreenPtr) \
- dixLookupPrivate(&(s)->devPrivates, CompScreenPrivateKey))
-#define GetCompWindow(w) ((CompWindowPtr) \
- dixLookupPrivate(&(w)->devPrivates, CompWindowPrivateKey))
-#define GetCompSubwindows(w) ((CompSubwindowsPtr) \
- dixLookupPrivate(&(w)->devPrivates, CompSubwindowsPrivateKey))
-
-extern RESTYPE CompositeClientWindowType;
-extern RESTYPE CompositeClientSubwindowsType;
-extern RESTYPE CompositeClientOverlayType;
-
-/*
- * compalloc.c
- */
-
-Bool
-compRedirectWindow (ClientPtr pClient, WindowPtr pWin, int update);
-
-void
-compFreeClientWindow (WindowPtr pWin, XID id);
-
-int
-compUnredirectWindow (ClientPtr pClient, WindowPtr pWin, int update);
-
-int
-compRedirectSubwindows (ClientPtr pClient, WindowPtr pWin, int update);
-
-void
-compFreeClientSubwindows (WindowPtr pWin, XID id);
-
-int
-compUnredirectSubwindows (ClientPtr pClient, WindowPtr pWin, int update);
-
-int
-compRedirectOneSubwindow (WindowPtr pParent, WindowPtr pWin);
-
-int
-compUnredirectOneSubwindow (WindowPtr pParent, WindowPtr pWin);
-
-Bool
-compAllocPixmap (WindowPtr pWin);
-
-void
-compFreePixmap (WindowPtr pWin);
-
-Bool
-compReallocPixmap (WindowPtr pWin, int x, int y,
- unsigned int w, unsigned int h, int bw);
-
-/*
- * compext.c
- */
-
-void
-CompositeExtensionInit (void);
-
-/*
- * compinit.c
- */
-
-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
- */
-
-#ifdef COMPOSITE_DEBUG
-void
-compCheckTree (ScreenPtr pScreen);
-#else
-#define compCheckTree(s)
-#endif
-
-PictFormatPtr
-compWindowFormat (WindowPtr pWin);
-
-void
-compSetPixmap (WindowPtr pWin, PixmapPtr pPixmap);
-
-Bool
-compCheckRedirect (WindowPtr pWin);
-
-Bool
-compPositionWindow (WindowPtr pWin, int x, int y);
-
-Bool
-compRealizeWindow (WindowPtr pWin);
-
-Bool
-compUnrealizeWindow (WindowPtr pWin);
-
-void
-compClipNotify (WindowPtr pWin, int dx, int dy);
-
-void
-compMoveWindow (WindowPtr pWin, int x, int y, WindowPtr pSib, VTKind kind);
-
-void
-compResizeWindow (WindowPtr pWin, int x, int y,
- unsigned int w, unsigned int h, WindowPtr pSib);
-
-void
-compChangeBorderWidth (WindowPtr pWin, unsigned int border_width);
-
-void
-compReparentWindow (WindowPtr pWin, WindowPtr pPriorParent);
-
-Bool
-compCreateWindow (WindowPtr pWin);
-
-Bool
-compDestroyWindow (WindowPtr pWin);
-
-void
-compSetRedirectBorderClip (WindowPtr pWin, RegionPtr pRegion);
-
-RegionPtr
-compGetRedirectBorderClip (WindowPtr pWin);
-
-void
-compCopyWindow (WindowPtr pWin, DDXPointRec ptOldOrg, RegionPtr prgnSrc);
-
-void
-compPaintChildrenToWindow (WindowPtr pWin);
-
-WindowPtr
-CompositeRealChildHead (WindowPtr pWin);
-
-int
-DeleteWindowNoInputDevices(pointer value, XID wid);
-
-int
-compConfigNotify(WindowPtr pWin, int x, int y, int w, int h,
- int bw, WindowPtr pSib);
-
-void PanoramiXCompositeInit (void);
-void PanoramiXCompositeReset (void);
-
-#endif /* _COMPINT_H_ */
+/*
+ * Copyright (c) 2006, Oracle and/or its affiliates. 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 (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ *
+ * 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
+
+#ifndef _COMPINT_H_
+#define _COMPINT_H_
+
+#include "misc.h"
+#include "scrnintstr.h"
+#include "os.h"
+#include "regionstr.h"
+#include "validate.h"
+#include "windowstr.h"
+#include "input.h"
+#include "resource.h"
+#include "colormapst.h"
+#include "cursorstr.h"
+#include "dixstruct.h"
+#include "gcstruct.h"
+#include "servermd.h"
+#include "dixevents.h"
+#include "globals.h"
+#include "picturestr.h"
+#include "extnsionst.h"
+#include "privates.h"
+#include "mi.h"
+#include "damage.h"
+#include "damageextint.h"
+#include "xfixes.h"
+#include <X11/extensions/compositeproto.h>
+#include <assert.h>
+
+/*
+ * enable this for debugging
+
+ #define COMPOSITE_DEBUG
+ */
+
+typedef struct _CompClientWindow {
+ struct _CompClientWindow *next;
+ XID id;
+ int update;
+} CompClientWindowRec, *CompClientWindowPtr;
+
+typedef struct _CompWindow {
+ RegionRec borderClip;
+ DamagePtr damage; /* for automatic update mode */
+ Bool damageRegistered;
+ Bool damaged;
+ int update;
+ CompClientWindowPtr clients;
+ int oldx;
+ int oldy;
+ PixmapPtr pOldPixmap;
+ int borderClipX, borderClipY;
+} CompWindowRec, *CompWindowPtr;
+
+#define COMP_ORIGIN_INVALID 0x80000000
+
+typedef struct _CompSubwindows {
+ int update;
+ CompClientWindowPtr clients;
+} CompSubwindowsRec, *CompSubwindowsPtr;
+
+#ifndef COMP_INCLUDE_RGB24_VISUAL
+#define COMP_INCLUDE_RGB24_VISUAL 0
+#endif
+
+typedef struct _CompOverlayClientRec *CompOverlayClientPtr;
+
+typedef struct _CompOverlayClientRec {
+ CompOverlayClientPtr pNext;
+ ClientPtr pClient;
+ ScreenPtr pScreen;
+ XID resource;
+} CompOverlayClientRec;
+
+typedef struct _CompScreen {
+ PositionWindowProcPtr PositionWindow;
+ CopyWindowProcPtr CopyWindow;
+ CreateWindowProcPtr CreateWindow;
+ DestroyWindowProcPtr DestroyWindow;
+ RealizeWindowProcPtr RealizeWindow;
+ UnrealizeWindowProcPtr UnrealizeWindow;
+ ClipNotifyProcPtr ClipNotify;
+ /*
+ * Called from ConfigureWindow, these
+ * three track changes to the offscreen storage
+ * geometry
+ */
+ ConfigNotifyProcPtr ConfigNotify;
+ MoveWindowProcPtr MoveWindow;
+ ResizeWindowProcPtr ResizeWindow;
+ ChangeBorderWidthProcPtr ChangeBorderWidth;
+ /*
+ * Reparenting has an effect on Subwindows redirect
+ */
+ ReparentWindowProcPtr ReparentWindow;
+
+ /*
+ * Colormaps for new visuals better not get installed
+ */
+ InstallColormapProcPtr InstallColormap;
+
+ /*
+ * Fake backing store via automatic redirection
+ */
+ ChangeWindowAttributesProcPtr ChangeWindowAttributes;
+
+ ScreenBlockHandlerProcPtr BlockHandler;
+ CloseScreenProcPtr CloseScreen;
+ int numAlternateVisuals;
+ VisualID *alternateVisuals;
+
+ WindowPtr pOverlayWin;
+ Window overlayWid;
+ CompOverlayClientPtr pOverlayClients;
+
+ GetImageProcPtr GetImage;
+ SourceValidateProcPtr SourceValidate;
+} CompScreenRec, *CompScreenPtr;
+
+extern DevPrivateKeyRec CompScreenPrivateKeyRec;
+#define CompScreenPrivateKey (&CompScreenPrivateKeyRec)
+
+extern DevPrivateKeyRec CompWindowPrivateKeyRec;
+#define CompWindowPrivateKey (&CompWindowPrivateKeyRec)
+
+extern DevPrivateKeyRec CompSubwindowsPrivateKeyRec;
+#define CompSubwindowsPrivateKey (&CompSubwindowsPrivateKeyRec)
+
+#define GetCompScreen(s) ((CompScreenPtr) \
+ dixLookupPrivate(&(s)->devPrivates, CompScreenPrivateKey))
+#define GetCompWindow(w) ((CompWindowPtr) \
+ dixLookupPrivate(&(w)->devPrivates, CompWindowPrivateKey))
+#define GetCompSubwindows(w) ((CompSubwindowsPtr) \
+ dixLookupPrivate(&(w)->devPrivates, CompSubwindowsPrivateKey))
+
+extern RESTYPE CompositeClientWindowType;
+extern RESTYPE CompositeClientSubwindowsType;
+extern RESTYPE CompositeClientOverlayType;
+
+/*
+ * compalloc.c
+ */
+
+Bool
+compRedirectWindow (ClientPtr pClient, WindowPtr pWin, int update);
+
+void
+compFreeClientWindow (WindowPtr pWin, XID id);
+
+int
+compUnredirectWindow (ClientPtr pClient, WindowPtr pWin, int update);
+
+int
+compRedirectSubwindows (ClientPtr pClient, WindowPtr pWin, int update);
+
+void
+compFreeClientSubwindows (WindowPtr pWin, XID id);
+
+int
+compUnredirectSubwindows (ClientPtr pClient, WindowPtr pWin, int update);
+
+int
+compRedirectOneSubwindow (WindowPtr pParent, WindowPtr pWin);
+
+int
+compUnredirectOneSubwindow (WindowPtr pParent, WindowPtr pWin);
+
+Bool
+compAllocPixmap (WindowPtr pWin);
+
+void
+compSetParentPixmap (WindowPtr pWin);
+
+void
+compRestoreWindow (WindowPtr pWin, PixmapPtr pPixmap);
+
+Bool
+compReallocPixmap (WindowPtr pWin, int x, int y,
+ unsigned int w, unsigned int h, int bw);
+
+/*
+ * compext.c
+ */
+
+void
+CompositeExtensionInit (void);
+
+/*
+ * compinit.c
+ */
+
+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
+ */
+
+#ifdef COMPOSITE_DEBUG
+void
+compCheckTree (ScreenPtr pScreen);
+#else
+#define compCheckTree(s)
+#endif
+
+PictFormatPtr
+compWindowFormat (WindowPtr pWin);
+
+void
+compSetPixmap (WindowPtr pWin, PixmapPtr pPixmap);
+
+Bool
+compCheckRedirect (WindowPtr pWin);
+
+Bool
+compPositionWindow (WindowPtr pWin, int x, int y);
+
+Bool
+compRealizeWindow (WindowPtr pWin);
+
+Bool
+compUnrealizeWindow (WindowPtr pWin);
+
+void
+compClipNotify (WindowPtr pWin, int dx, int dy);
+
+void
+compMoveWindow (WindowPtr pWin, int x, int y, WindowPtr pSib, VTKind kind);
+
+void
+compResizeWindow (WindowPtr pWin, int x, int y,
+ unsigned int w, unsigned int h, WindowPtr pSib);
+
+void
+compChangeBorderWidth (WindowPtr pWin, unsigned int border_width);
+
+void
+compReparentWindow (WindowPtr pWin, WindowPtr pPriorParent);
+
+Bool
+compCreateWindow (WindowPtr pWin);
+
+Bool
+compDestroyWindow (WindowPtr pWin);
+
+void
+compSetRedirectBorderClip (WindowPtr pWin, RegionPtr pRegion);
+
+RegionPtr
+compGetRedirectBorderClip (WindowPtr pWin);
+
+void
+compCopyWindow (WindowPtr pWin, DDXPointRec ptOldOrg, RegionPtr prgnSrc);
+
+void
+compPaintChildrenToWindow (WindowPtr pWin);
+
+WindowPtr
+CompositeRealChildHead (WindowPtr pWin);
+
+int
+DeleteWindowNoInputDevices(pointer value, XID wid);
+
+int
+compConfigNotify(WindowPtr pWin, int x, int y, int w, int h,
+ int bw, WindowPtr pSib);
+
+void PanoramiXCompositeInit (void);
+void PanoramiXCompositeReset (void);
+
+#endif /* _COMPINT_H_ */
diff --git a/xorg-server/composite/compwindow.c b/xorg-server/composite/compwindow.c
index ef1f7f154..d2a866d6f 100644
--- a/xorg-server/composite/compwindow.c
+++ b/xorg-server/composite/compwindow.c
@@ -1,819 +1,832 @@
-/*
- * Copyright (c) 2006, Oracle and/or its affiliates. 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 (including the next
- * paragraph) shall be included in all copies or substantial portions of the
- * Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
- * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
- * DEALINGS IN THE SOFTWARE.
- *
- * 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"
-
-#ifdef PANORAMIX
-#include "panoramiXsrv.h"
-#endif
-
-#ifdef COMPOSITE_DEBUG
-static int
-compCheckWindow (WindowPtr pWin, pointer data)
-{
- ScreenPtr pScreen = pWin->drawable.pScreen;
- PixmapPtr pWinPixmap = (*pScreen->GetWindowPixmap) (pWin);
- PixmapPtr pParentPixmap = pWin->parent ? (*pScreen->GetWindowPixmap) (pWin->parent) : 0;
- PixmapPtr pScreenPixmap = (*pScreen->GetScreenPixmap) (pScreen);
-
- if (!pWin->parent)
- {
- assert (pWin->redirectDraw == RedirectDrawNone);
- assert (pWinPixmap == pScreenPixmap);
- }
- else if (pWin->redirectDraw != RedirectDrawNone)
- {
- assert (pWinPixmap != pParentPixmap);
- assert (pWinPixmap != pScreenPixmap);
- }
- else
- {
- assert (pWinPixmap == pParentPixmap);
- }
- assert (0 < pWinPixmap->refcnt && pWinPixmap->refcnt < 3);
- assert (0 < pScreenPixmap->refcnt && pScreenPixmap->refcnt < 3);
- if (pParentPixmap)
- assert (0 <= pParentPixmap->refcnt && pParentPixmap->refcnt < 3);
- return WT_WALKCHILDREN;
-}
-
-void
-compCheckTree (ScreenPtr pScreen)
-{
- WalkTree (pScreen, compCheckWindow, 0);
-}
-#endif
-
-typedef struct _compPixmapVisit {
- WindowPtr pWindow;
- PixmapPtr pPixmap;
-} CompPixmapVisitRec, *CompPixmapVisitPtr;
-
-static Bool
-compRepaintBorder (ClientPtr pClient, pointer closure)
-{
- WindowPtr pWindow;
- int rc = dixLookupWindow(&pWindow, (XID)(intptr_t)closure, pClient, DixWriteAccess);
-
- if (rc == Success) {
- RegionRec exposed;
-
- RegionNull(&exposed);
- RegionSubtract(&exposed, &pWindow->borderClip, &pWindow->winSize);
- miPaintWindow(pWindow, &exposed, PW_BORDER);
- RegionUninit(&exposed);
- }
- return TRUE;
-}
-
-static int
-compSetPixmapVisitWindow (WindowPtr pWindow, pointer data)
-{
- CompPixmapVisitPtr pVisit = (CompPixmapVisitPtr) data;
- ScreenPtr pScreen = pWindow->drawable.pScreen;
-
- if (pWindow != pVisit->pWindow && pWindow->redirectDraw != RedirectDrawNone)
- return WT_DONTWALKCHILDREN;
- (*pScreen->SetWindowPixmap) (pWindow, pVisit->pPixmap);
- /*
- * Recompute winSize and borderSize. This is duplicate effort
- * when resizing pixmaps, but necessary when changing redirection.
- * Might be nice to fix this.
- */
- SetWinSize (pWindow);
- SetBorderSize (pWindow);
- if (HasBorder (pWindow))
- QueueWorkProc (compRepaintBorder, serverClient,
- (pointer)(intptr_t) pWindow->drawable.id);
- return WT_WALKCHILDREN;
-}
-
-void
-compSetPixmap (WindowPtr pWindow, PixmapPtr pPixmap)
-{
- CompPixmapVisitRec visitRec;
-
- visitRec.pWindow = pWindow;
- visitRec.pPixmap = pPixmap;
- TraverseTree (pWindow, compSetPixmapVisitWindow, (pointer) &visitRec);
- compCheckTree (pWindow->drawable.pScreen);
-}
-
-Bool
-compCheckRedirect (WindowPtr pWin)
-{
- CompWindowPtr cw = GetCompWindow (pWin);
- CompScreenPtr cs = GetCompScreen(pWin->drawable.pScreen);
- Bool should;
-
- should = pWin->realized && (pWin->drawable.class != InputOnly) &&
- (cw != NULL) && (pWin->parent != NULL);
-
- /* Never redirect the overlay window */
- if (cs->pOverlayWin != NULL) {
- if (pWin == cs->pOverlayWin) {
- should = FALSE;
- }
- }
-
- if (should != (pWin->redirectDraw != RedirectDrawNone))
- {
- if (should)
- return compAllocPixmap (pWin);
- else
- compFreePixmap (pWin);
- }
- return TRUE;
-}
-
-static int
-updateOverlayWindow(ScreenPtr pScreen)
-{
- CompScreenPtr cs;
- WindowPtr pWin; /* overlay window */
- XID vlist[2];
- int w = pScreen->width;
- int h = pScreen->height;
-
-#ifdef PANORAMIX
- if (!noPanoramiXExtension)
- {
- w = PanoramiXPixWidth;
- h = PanoramiXPixHeight;
- }
-#endif
-
- cs = GetCompScreen(pScreen);
- if ((pWin = cs->pOverlayWin) != NULL) {
- if ((pWin->drawable.width == w) &&
- (pWin->drawable.height == h))
- return Success;
-
- /* Let's resize the overlay window. */
- vlist[0] = w;
- vlist[1] = h;
- return ConfigureWindow(pWin, CWWidth | CWHeight, vlist, wClient(pWin));
- }
-
- /* Let's be on the safe side and not assume an overlay window is always allocated. */
- return Success;
-}
-
-Bool
-compPositionWindow (WindowPtr pWin, int x, int y)
-{
- ScreenPtr pScreen = pWin->drawable.pScreen;
- CompScreenPtr cs = GetCompScreen (pScreen);
- Bool ret = TRUE;
-
- pScreen->PositionWindow = cs->PositionWindow;
- /*
- * "Shouldn't need this as all possible places should be wrapped
- *
- compCheckRedirect (pWin);
- */
-#ifdef COMPOSITE_DEBUG
- if ((pWin->redirectDraw != RedirectDrawNone) !=
- (pWin->viewable && (GetCompWindow(pWin) != NULL)))
- OsAbort ();
-#endif
- if (pWin->redirectDraw != RedirectDrawNone)
- {
- PixmapPtr pPixmap = (*pScreen->GetWindowPixmap) (pWin);
- int bw = wBorderWidth (pWin);
- int nx = pWin->drawable.x - bw;
- int ny = pWin->drawable.y - bw;
-
- if (pPixmap->screen_x != nx || pPixmap->screen_y != ny)
- {
- pPixmap->screen_x = nx;
- pPixmap->screen_y = ny;
- pPixmap->drawable.serialNumber = NEXT_SERIAL_NUMBER;
- }
- }
-
- if (!(*pScreen->PositionWindow) (pWin, x, y))
- ret = FALSE;
- cs->PositionWindow = pScreen->PositionWindow;
- pScreen->PositionWindow = compPositionWindow;
- compCheckTree (pWin->drawable.pScreen);
- if (updateOverlayWindow(pScreen) != Success)
- ret = FALSE;
- return ret;
-}
-
-Bool
-compRealizeWindow (WindowPtr pWin)
-{
- ScreenPtr pScreen = pWin->drawable.pScreen;
- CompScreenPtr cs = GetCompScreen (pScreen);
- Bool ret = TRUE;
-
- pScreen->RealizeWindow = cs->RealizeWindow;
- compCheckRedirect (pWin);
- if (!(*pScreen->RealizeWindow) (pWin))
- ret = FALSE;
- cs->RealizeWindow = pScreen->RealizeWindow;
- pScreen->RealizeWindow = compRealizeWindow;
- compCheckTree (pWin->drawable.pScreen);
- return ret;
-}
-
-Bool
-compUnrealizeWindow (WindowPtr pWin)
-{
- ScreenPtr pScreen = pWin->drawable.pScreen;
- CompScreenPtr cs = GetCompScreen (pScreen);
- Bool ret = TRUE;
-
- pScreen->UnrealizeWindow = cs->UnrealizeWindow;
- compCheckRedirect (pWin);
- if (!(*pScreen->UnrealizeWindow) (pWin))
- ret = FALSE;
- cs->UnrealizeWindow = pScreen->UnrealizeWindow;
- pScreen->UnrealizeWindow = compUnrealizeWindow;
- compCheckTree (pWin->drawable.pScreen);
- return ret;
-}
-
-/*
- * Called after the borderClip for the window has settled down
- * We use this to make sure our extra borderClip has the right origin
- */
-
-void
-compClipNotify (WindowPtr pWin, int dx, int dy)
-{
- ScreenPtr pScreen = pWin->drawable.pScreen;
- CompScreenPtr cs = GetCompScreen (pScreen);
- CompWindowPtr cw = GetCompWindow (pWin);
-
- if (cw)
- {
- if (cw->borderClipX != pWin->drawable.x ||
- cw->borderClipY != pWin->drawable.y)
- {
- RegionTranslate(&cw->borderClip,
- pWin->drawable.x - cw->borderClipX,
- pWin->drawable.y - cw->borderClipY);
- cw->borderClipX = pWin->drawable.x;
- cw->borderClipY = pWin->drawable.y;
- }
- }
- if (cs->ClipNotify)
- {
- pScreen->ClipNotify = cs->ClipNotify;
- (*pScreen->ClipNotify) (pWin, dx, dy);
- cs->ClipNotify = pScreen->ClipNotify;
- pScreen->ClipNotify = compClipNotify;
- }
-}
-
-/*
- * Returns TRUE if the window needs server-provided automatic redirect,
- * which is true if the child and parent aren't both regular or ARGB visuals
- */
-
-static Bool
-compIsAlternateVisual (ScreenPtr pScreen,
- XID visual)
-{
- CompScreenPtr cs = GetCompScreen (pScreen);
- int i;
-
- for (i = 0; i < cs->numAlternateVisuals; i++)
- if (cs->alternateVisuals[i] == visual)
- return TRUE;
- return FALSE;
-}
-
-static Bool
-compImplicitRedirect (WindowPtr pWin, WindowPtr pParent)
-{
- if (pParent)
- {
- ScreenPtr pScreen = pWin->drawable.pScreen;
- XID winVisual = wVisual (pWin);
- XID parentVisual = wVisual (pParent);
-
- if (winVisual != parentVisual &&
- (compIsAlternateVisual (pScreen, winVisual) ||
- compIsAlternateVisual (pScreen, parentVisual)))
- return TRUE;
- }
- return FALSE;
-}
-
-static void compFreeOldPixmap(WindowPtr pWin)
-{
- ScreenPtr pScreen = pWin->drawable.pScreen;
- if (pWin->redirectDraw != RedirectDrawNone)
- {
- CompWindowPtr cw = GetCompWindow (pWin);
- if (cw->pOldPixmap)
- {
- (*pScreen->DestroyPixmap) (cw->pOldPixmap);
- cw->pOldPixmap = NullPixmap;
- }
- }
-}
-void
-compMoveWindow (WindowPtr pWin, int x, int y, WindowPtr pSib, VTKind kind)
-{
- ScreenPtr pScreen = pWin->drawable.pScreen;
- CompScreenPtr cs = GetCompScreen (pScreen);
-
- pScreen->MoveWindow = cs->MoveWindow;
- (*pScreen->MoveWindow) (pWin, x, y, pSib, kind);
- cs->MoveWindow = pScreen->MoveWindow;
- pScreen->MoveWindow = compMoveWindow;
-
- compFreeOldPixmap(pWin);
- compCheckTree (pScreen);
-}
-
-void
-compResizeWindow (WindowPtr pWin, int x, int y,
- unsigned int w, unsigned int h, WindowPtr pSib)
-{
- ScreenPtr pScreen = pWin->drawable.pScreen;
- CompScreenPtr cs = GetCompScreen (pScreen);
-
- pScreen->ResizeWindow = cs->ResizeWindow;
- (*pScreen->ResizeWindow) (pWin, x, y, w, h, pSib);
- cs->ResizeWindow = pScreen->ResizeWindow;
- pScreen->ResizeWindow = compResizeWindow;
-
- compFreeOldPixmap(pWin);
- compCheckTree (pWin->drawable.pScreen);
-}
-
-void
-compChangeBorderWidth (WindowPtr pWin, unsigned int bw)
-{
- ScreenPtr pScreen = pWin->drawable.pScreen;
- CompScreenPtr cs = GetCompScreen (pScreen);
-
- pScreen->ChangeBorderWidth = cs->ChangeBorderWidth;
- (*pScreen->ChangeBorderWidth) (pWin, bw);
- cs->ChangeBorderWidth = pScreen->ChangeBorderWidth;
- pScreen->ChangeBorderWidth = compChangeBorderWidth;
-
- compFreeOldPixmap(pWin);
- compCheckTree (pWin->drawable.pScreen);
-}
-
-void
-compReparentWindow (WindowPtr pWin, WindowPtr pPriorParent)
-{
- ScreenPtr pScreen = pWin->drawable.pScreen;
- CompScreenPtr cs = GetCompScreen (pScreen);
-
- pScreen->ReparentWindow = cs->ReparentWindow;
- /*
- * Remove any implicit redirect due to synthesized visual
- */
- if (compImplicitRedirect (pWin, pPriorParent))
- compUnredirectWindow (serverClient, pWin, CompositeRedirectAutomatic);
- /*
- * Handle subwindows redirection
- */
- compUnredirectOneSubwindow (pPriorParent, pWin);
- compRedirectOneSubwindow (pWin->parent, pWin);
- /*
- * Add any implict redirect due to synthesized visual
- */
- if (compImplicitRedirect (pWin, pWin->parent))
- compRedirectWindow (serverClient, pWin, CompositeRedirectAutomatic);
-
- /*
- * Allocate any necessary redirect pixmap
- * (this actually should never be true; pWin is always unmapped)
- */
- compCheckRedirect (pWin);
-
- /*
- * Reset pixmap pointers as appropriate
- */
- if (pWin->parent && pWin->redirectDraw == RedirectDrawNone)
- compSetPixmap (pWin, (*pScreen->GetWindowPixmap) (pWin->parent));
- /*
- * Call down to next function
- */
- if (pScreen->ReparentWindow)
- (*pScreen->ReparentWindow) (pWin, pPriorParent);
- cs->ReparentWindow = pScreen->ReparentWindow;
- pScreen->ReparentWindow = compReparentWindow;
- compCheckTree (pWin->drawable.pScreen);
-}
-
-void
-compCopyWindow (WindowPtr pWin, DDXPointRec ptOldOrg, RegionPtr prgnSrc)
-{
- ScreenPtr pScreen = pWin->drawable.pScreen;
- CompScreenPtr cs = GetCompScreen (pScreen);
- int dx = 0, dy = 0;
-
- if (pWin->redirectDraw != RedirectDrawNone)
- {
- PixmapPtr pPixmap = (*pScreen->GetWindowPixmap) (pWin);
- CompWindowPtr cw = GetCompWindow (pWin);
-
- assert (cw->oldx != COMP_ORIGIN_INVALID);
- assert (cw->oldy != COMP_ORIGIN_INVALID);
- if (cw->pOldPixmap)
- {
- /*
- * Ok, the old bits are available in pOldPixmap and
- * need to be copied to pNewPixmap.
- */
- RegionRec rgnDst;
- PixmapPtr pPixmap = (*pScreen->GetWindowPixmap) (pWin);
- GCPtr pGC;
-
- dx = ptOldOrg.x - pWin->drawable.x;
- dy = ptOldOrg.y - pWin->drawable.y;
- RegionTranslate(prgnSrc, -dx, -dy);
-
- RegionNull(&rgnDst);
-
- RegionIntersect(&rgnDst,
- &pWin->borderClip, prgnSrc);
-
- RegionTranslate(&rgnDst,
- -pPixmap->screen_x, -pPixmap->screen_y);
-
- dx = dx + pPixmap->screen_x - cw->oldx;
- dy = dy + pPixmap->screen_y - cw->oldy;
- pGC = GetScratchGC (pPixmap->drawable.depth, pScreen);
- if (pGC)
- {
- BoxPtr pBox = RegionRects (&rgnDst);
- int nBox = RegionNumRects (&rgnDst);
-
- ValidateGC(&pPixmap->drawable, pGC);
- while (nBox--)
- {
- (void) (*pGC->ops->CopyArea) (&cw->pOldPixmap->drawable,
- &pPixmap->drawable,
- pGC,
- pBox->x1 + dx, pBox->y1 + dy,
- pBox->x2 - pBox->x1,
- pBox->y2 - pBox->y1,
- pBox->x1, pBox->y1);
- pBox++;
- }
- FreeScratchGC (pGC);
- }
- return;
- }
- dx = pPixmap->screen_x - cw->oldx;
- dy = pPixmap->screen_y - cw->oldy;
- ptOldOrg.x += dx;
- ptOldOrg.y += dy;
- }
-
- pScreen->CopyWindow = cs->CopyWindow;
- if (ptOldOrg.x != pWin->drawable.x || ptOldOrg.y != pWin->drawable.y)
- {
- if (dx || dy)
- RegionTranslate(prgnSrc, dx, dy);
- (*pScreen->CopyWindow) (pWin, ptOldOrg, prgnSrc);
- if (dx || dy)
- RegionTranslate(prgnSrc, -dx, -dy);
- }
- else
- {
- ptOldOrg.x -= dx;
- ptOldOrg.y -= dy;
- RegionTranslate(prgnSrc,
- pWin->drawable.x - ptOldOrg.x,
- pWin->drawable.y - ptOldOrg.y);
- DamageDamageRegion(&pWin->drawable, prgnSrc);
- }
- cs->CopyWindow = pScreen->CopyWindow;
- pScreen->CopyWindow = compCopyWindow;
- compCheckTree (pWin->drawable.pScreen);
-}
-
-Bool
-compCreateWindow (WindowPtr pWin)
-{
- ScreenPtr pScreen = pWin->drawable.pScreen;
- CompScreenPtr cs = GetCompScreen (pScreen);
- Bool ret;
-
- pScreen->CreateWindow = cs->CreateWindow;
- ret = (*pScreen->CreateWindow) (pWin);
- if (pWin->parent && ret)
- {
- CompSubwindowsPtr csw = GetCompSubwindows (pWin->parent);
- CompClientWindowPtr ccw;
-
- (*pScreen->SetWindowPixmap) (pWin, (*pScreen->GetWindowPixmap) (pWin->parent));
- if (csw)
- for (ccw = csw->clients; ccw; ccw = ccw->next)
- compRedirectWindow (clients[CLIENT_ID(ccw->id)],
- pWin, ccw->update);
- if (compImplicitRedirect (pWin, pWin->parent))
- compRedirectWindow (serverClient, pWin, CompositeRedirectAutomatic);
- }
- cs->CreateWindow = pScreen->CreateWindow;
- pScreen->CreateWindow = compCreateWindow;
- compCheckTree (pWin->drawable.pScreen);
- return ret;
-}
-
-Bool
-compDestroyWindow (WindowPtr pWin)
-{
- ScreenPtr pScreen = pWin->drawable.pScreen;
- CompScreenPtr cs = GetCompScreen (pScreen);
- CompWindowPtr cw;
- CompSubwindowsPtr csw;
- Bool ret;
-
- pScreen->DestroyWindow = cs->DestroyWindow;
- while ((cw = GetCompWindow (pWin)))
- FreeResource (cw->clients->id, RT_NONE);
- while ((csw = GetCompSubwindows (pWin)))
- FreeResource (csw->clients->id, RT_NONE);
-
- if (pWin->redirectDraw != RedirectDrawNone)
- compFreePixmap (pWin);
- ret = (*pScreen->DestroyWindow) (pWin);
- cs->DestroyWindow = pScreen->DestroyWindow;
- pScreen->DestroyWindow = compDestroyWindow;
-/* compCheckTree (pWin->drawable.pScreen); can't check -- tree isn't good*/
- return ret;
-}
-
-void
-compSetRedirectBorderClip (WindowPtr pWin, RegionPtr pRegion)
-{
- CompWindowPtr cw = GetCompWindow (pWin);
- RegionRec damage;
-
- RegionNull(&damage);
- /*
- * Align old border clip with new border clip
- */
- RegionTranslate(&cw->borderClip,
- pWin->drawable.x - cw->borderClipX,
- pWin->drawable.y - cw->borderClipY);
- /*
- * Compute newly visible portion of window for repaint
- */
- RegionSubtract(&damage, pRegion, &cw->borderClip);
- /*
- * Report that as damaged so it will be redrawn
- */
- DamageDamageRegion(&pWin->drawable, &damage);
- RegionUninit(&damage);
- /*
- * Save the new border clip region
- */
- RegionCopy(&cw->borderClip, pRegion);
- cw->borderClipX = pWin->drawable.x;
- cw->borderClipY = pWin->drawable.y;
-}
-
-RegionPtr
-compGetRedirectBorderClip (WindowPtr pWin)
-{
- CompWindowPtr cw = GetCompWindow (pWin);
-
- return &cw->borderClip;
-}
-
-static VisualPtr
-compGetWindowVisual (WindowPtr pWin)
-{
- ScreenPtr pScreen = pWin->drawable.pScreen;
- VisualID vid = wVisual (pWin);
- int i;
-
- for (i = 0; i < pScreen->numVisuals; i++)
- if (pScreen->visuals[i].vid == vid)
- return &pScreen->visuals[i];
- return 0;
-}
-
-PictFormatPtr
-compWindowFormat (WindowPtr pWin)
-{
- ScreenPtr pScreen = pWin->drawable.pScreen;
-
- return PictureMatchVisual (pScreen, pWin->drawable.depth,
- compGetWindowVisual (pWin));
-}
-
-static void
-compWindowUpdateAutomatic (WindowPtr pWin)
-{
- CompWindowPtr cw = GetCompWindow (pWin);
- ScreenPtr pScreen = pWin->drawable.pScreen;
- WindowPtr pParent = pWin->parent;
- PixmapPtr pSrcPixmap = (*pScreen->GetWindowPixmap) (pWin);
- PictFormatPtr pSrcFormat = compWindowFormat (pWin);
- PictFormatPtr pDstFormat = compWindowFormat (pWin->parent);
- int error;
- RegionPtr pRegion = DamageRegion (cw->damage);
- PicturePtr pSrcPicture = CreatePicture (0, &pSrcPixmap->drawable,
- pSrcFormat,
- 0, 0,
- serverClient,
- &error);
- XID subwindowMode = IncludeInferiors;
- PicturePtr pDstPicture = CreatePicture (0, &pParent->drawable,
- pDstFormat,
- CPSubwindowMode,
- &subwindowMode,
- serverClient,
- &error);
-
- /*
- * First move the region from window to screen coordinates
- */
- RegionTranslate(pRegion,
- pWin->drawable.x, pWin->drawable.y);
-
- /*
- * Clip against the "real" border clip
- */
- RegionIntersect(pRegion, pRegion, &cw->borderClip);
-
- /*
- * Now translate from screen to dest coordinates
- */
- RegionTranslate(pRegion,
- -pParent->drawable.x, -pParent->drawable.y);
-
- /*
- * Clip the picture
- */
- SetPictureClipRegion (pDstPicture, 0, 0, pRegion);
-
- /*
- * And paint
- */
- CompositePicture (PictOpSrc,
- pSrcPicture,
- 0,
- pDstPicture,
- 0, 0, /* src_x, src_y */
- 0, 0, /* msk_x, msk_y */
- pSrcPixmap->screen_x - pParent->drawable.x,
- pSrcPixmap->screen_y - pParent->drawable.y,
- pSrcPixmap->drawable.width,
- pSrcPixmap->drawable.height);
- FreePicture (pSrcPicture, 0);
- FreePicture (pDstPicture, 0);
- /*
- * Empty the damage region. This has the nice effect of
- * rendering the translations above harmless
- */
- DamageEmpty (cw->damage);
-}
-
-static void
-compPaintWindowToParent (WindowPtr pWin)
-{
- compPaintChildrenToWindow (pWin);
-
- if (pWin->redirectDraw != RedirectDrawNone)
- {
- CompWindowPtr cw = GetCompWindow(pWin);
-
- if (cw->damaged)
- {
- compWindowUpdateAutomatic (pWin);
- cw->damaged = FALSE;
- }
- }
-}
-
-void
-compPaintChildrenToWindow (WindowPtr pWin)
-{
- WindowPtr pChild;
-
- if (!pWin->damagedDescendants)
- return;
-
- for (pChild = pWin->lastChild; pChild; pChild = pChild->prevSib)
- compPaintWindowToParent (pChild);
-
- pWin->damagedDescendants = FALSE;
-}
-
-WindowPtr
-CompositeRealChildHead (WindowPtr pWin)
-{
- WindowPtr pChild, pChildBefore;
- CompScreenPtr cs;
-
- if (!pWin->parent &&
- (screenIsSaved == SCREEN_SAVER_ON) &&
- (HasSaverWindow (pWin->drawable.pScreen))) {
-
- /* First child is the screen saver; see if next child is the overlay */
- pChildBefore = pWin->firstChild;
- pChild = pChildBefore->nextSib;
-
- } else {
- pChildBefore = NullWindow;
- pChild = pWin->firstChild;
- }
-
- if (!pChild) {
- return NullWindow;
- }
-
- cs = GetCompScreen(pWin->drawable.pScreen);
- if (pChild == cs->pOverlayWin) {
- return pChild;
- } else {
- return pChildBefore;
- }
-}
-
-int
-compConfigNotify(WindowPtr pWin, int x, int y, int w, int h,
- int bw, WindowPtr pSib)
-{
- ScreenPtr pScreen = pWin->drawable.pScreen;
- CompScreenPtr cs = GetCompScreen (pScreen);
- Bool ret = 0;
- WindowPtr pParent = pWin->parent;
- int draw_x, draw_y;
- Bool alloc_ret;
-
- if (cs->ConfigNotify)
- {
- pScreen->ConfigNotify = cs->ConfigNotify;
- ret = (*pScreen->ConfigNotify)(pWin, x, y, w, h, bw, pSib);
- cs->ConfigNotify = pScreen->ConfigNotify;
- pScreen->ConfigNotify = compConfigNotify;
-
- if (ret)
- return ret;
- }
-
- if (pWin->redirectDraw == RedirectDrawNone)
- return Success;
-
- compCheckTree (pScreen);
-
- draw_x = pParent->drawable.x + x + bw;
- draw_y = pParent->drawable.y + y + bw;
- alloc_ret = compReallocPixmap (pWin, draw_x, draw_y, w, h, bw);
-
- if (alloc_ret == FALSE)
- return BadAlloc;
- return Success;
-}
+/*
+ * Copyright (c) 2006, Oracle and/or its affiliates. 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 (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ *
+ * 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"
+
+#ifdef PANORAMIX
+#include "panoramiXsrv.h"
+#endif
+
+#ifdef COMPOSITE_DEBUG
+static int
+compCheckWindow (WindowPtr pWin, pointer data)
+{
+ ScreenPtr pScreen = pWin->drawable.pScreen;
+ PixmapPtr pWinPixmap = (*pScreen->GetWindowPixmap) (pWin);
+ PixmapPtr pParentPixmap = pWin->parent ? (*pScreen->GetWindowPixmap) (pWin->parent) : 0;
+ PixmapPtr pScreenPixmap = (*pScreen->GetScreenPixmap) (pScreen);
+
+ if (!pWin->parent)
+ {
+ assert (pWin->redirectDraw == RedirectDrawNone);
+ assert (pWinPixmap == pScreenPixmap);
+ }
+ else if (pWin->redirectDraw != RedirectDrawNone)
+ {
+ assert (pWinPixmap != pParentPixmap);
+ assert (pWinPixmap != pScreenPixmap);
+ }
+ else
+ {
+ assert (pWinPixmap == pParentPixmap);
+ }
+ assert (0 < pWinPixmap->refcnt && pWinPixmap->refcnt < 3);
+ assert (0 < pScreenPixmap->refcnt && pScreenPixmap->refcnt < 3);
+ if (pParentPixmap)
+ assert (0 <= pParentPixmap->refcnt && pParentPixmap->refcnt < 3);
+ return WT_WALKCHILDREN;
+}
+
+void
+compCheckTree (ScreenPtr pScreen)
+{
+ WalkTree (pScreen, compCheckWindow, 0);
+}
+#endif
+
+typedef struct _compPixmapVisit {
+ WindowPtr pWindow;
+ PixmapPtr pPixmap;
+} CompPixmapVisitRec, *CompPixmapVisitPtr;
+
+static Bool
+compRepaintBorder (ClientPtr pClient, pointer closure)
+{
+ WindowPtr pWindow;
+ int rc = dixLookupWindow(&pWindow, (XID)(intptr_t)closure, pClient, DixWriteAccess);
+
+ if (rc == Success) {
+ RegionRec exposed;
+
+ RegionNull(&exposed);
+ RegionSubtract(&exposed, &pWindow->borderClip, &pWindow->winSize);
+ miPaintWindow(pWindow, &exposed, PW_BORDER);
+ RegionUninit(&exposed);
+ }
+ return TRUE;
+}
+
+static int
+compSetPixmapVisitWindow (WindowPtr pWindow, pointer data)
+{
+ CompPixmapVisitPtr pVisit = (CompPixmapVisitPtr) data;
+ ScreenPtr pScreen = pWindow->drawable.pScreen;
+
+ if (pWindow != pVisit->pWindow && pWindow->redirectDraw != RedirectDrawNone)
+ return WT_DONTWALKCHILDREN;
+ (*pScreen->SetWindowPixmap) (pWindow, pVisit->pPixmap);
+ /*
+ * Recompute winSize and borderSize. This is duplicate effort
+ * when resizing pixmaps, but necessary when changing redirection.
+ * Might be nice to fix this.
+ */
+ SetWinSize (pWindow);
+ SetBorderSize (pWindow);
+ if (HasBorder (pWindow))
+ QueueWorkProc (compRepaintBorder, serverClient,
+ (pointer)(intptr_t) pWindow->drawable.id);
+ return WT_WALKCHILDREN;
+}
+
+void
+compSetPixmap (WindowPtr pWindow, PixmapPtr pPixmap)
+{
+ CompPixmapVisitRec visitRec;
+
+ visitRec.pWindow = pWindow;
+ visitRec.pPixmap = pPixmap;
+ TraverseTree (pWindow, compSetPixmapVisitWindow, (pointer) &visitRec);
+ compCheckTree (pWindow->drawable.pScreen);
+}
+
+Bool
+compCheckRedirect (WindowPtr pWin)
+{
+ CompWindowPtr cw = GetCompWindow (pWin);
+ CompScreenPtr cs = GetCompScreen(pWin->drawable.pScreen);
+ Bool should;
+
+ should = pWin->realized && (pWin->drawable.class != InputOnly) &&
+ (cw != NULL) && (pWin->parent != NULL);
+
+ /* Never redirect the overlay window */
+ if (cs->pOverlayWin != NULL) {
+ if (pWin == cs->pOverlayWin) {
+ should = FALSE;
+ }
+ }
+
+ if (should != (pWin->redirectDraw != RedirectDrawNone))
+ {
+ if (should)
+ return compAllocPixmap (pWin);
+ else {
+ ScreenPtr pScreen = pWin->drawable.pScreen;
+ PixmapPtr pPixmap = (*pScreen->GetWindowPixmap) (pWin);
+ compSetParentPixmap (pWin);
+ compRestoreWindow (pWin, pPixmap);
+ (*pScreen->DestroyPixmap) (pPixmap);
+ }
+ } else if (should) {
+ if (cw->update == CompositeRedirectAutomatic)
+ pWin->redirectDraw = RedirectDrawAutomatic;
+ else
+ pWin->redirectDraw = RedirectDrawManual;
+ }
+ return TRUE;
+}
+
+static int
+updateOverlayWindow(ScreenPtr pScreen)
+{
+ CompScreenPtr cs;
+ WindowPtr pWin; /* overlay window */
+ XID vlist[2];
+ int w = pScreen->width;
+ int h = pScreen->height;
+
+#ifdef PANORAMIX
+ if (!noPanoramiXExtension)
+ {
+ w = PanoramiXPixWidth;
+ h = PanoramiXPixHeight;
+ }
+#endif
+
+ cs = GetCompScreen(pScreen);
+ if ((pWin = cs->pOverlayWin) != NULL) {
+ if ((pWin->drawable.width == w) &&
+ (pWin->drawable.height == h))
+ return Success;
+
+ /* Let's resize the overlay window. */
+ vlist[0] = w;
+ vlist[1] = h;
+ return ConfigureWindow(pWin, CWWidth | CWHeight, vlist, wClient(pWin));
+ }
+
+ /* Let's be on the safe side and not assume an overlay window is always allocated. */
+ return Success;
+}
+
+Bool
+compPositionWindow (WindowPtr pWin, int x, int y)
+{
+ ScreenPtr pScreen = pWin->drawable.pScreen;
+ CompScreenPtr cs = GetCompScreen (pScreen);
+ Bool ret = TRUE;
+
+ pScreen->PositionWindow = cs->PositionWindow;
+ /*
+ * "Shouldn't need this as all possible places should be wrapped
+ *
+ compCheckRedirect (pWin);
+ */
+#ifdef COMPOSITE_DEBUG
+ if ((pWin->redirectDraw != RedirectDrawNone) !=
+ (pWin->viewable && (GetCompWindow(pWin) != NULL)))
+ OsAbort ();
+#endif
+ if (pWin->redirectDraw != RedirectDrawNone)
+ {
+ PixmapPtr pPixmap = (*pScreen->GetWindowPixmap) (pWin);
+ int bw = wBorderWidth (pWin);
+ int nx = pWin->drawable.x - bw;
+ int ny = pWin->drawable.y - bw;
+
+ if (pPixmap->screen_x != nx || pPixmap->screen_y != ny)
+ {
+ pPixmap->screen_x = nx;
+ pPixmap->screen_y = ny;
+ pPixmap->drawable.serialNumber = NEXT_SERIAL_NUMBER;
+ }
+ }
+
+ if (!(*pScreen->PositionWindow) (pWin, x, y))
+ ret = FALSE;
+ cs->PositionWindow = pScreen->PositionWindow;
+ pScreen->PositionWindow = compPositionWindow;
+ compCheckTree (pWin->drawable.pScreen);
+ if (updateOverlayWindow(pScreen) != Success)
+ ret = FALSE;
+ return ret;
+}
+
+Bool
+compRealizeWindow (WindowPtr pWin)
+{
+ ScreenPtr pScreen = pWin->drawable.pScreen;
+ CompScreenPtr cs = GetCompScreen (pScreen);
+ Bool ret = TRUE;
+
+ pScreen->RealizeWindow = cs->RealizeWindow;
+ compCheckRedirect (pWin);
+ if (!(*pScreen->RealizeWindow) (pWin))
+ ret = FALSE;
+ cs->RealizeWindow = pScreen->RealizeWindow;
+ pScreen->RealizeWindow = compRealizeWindow;
+ compCheckTree (pWin->drawable.pScreen);
+ return ret;
+}
+
+Bool
+compUnrealizeWindow (WindowPtr pWin)
+{
+ ScreenPtr pScreen = pWin->drawable.pScreen;
+ CompScreenPtr cs = GetCompScreen (pScreen);
+ Bool ret = TRUE;
+
+ pScreen->UnrealizeWindow = cs->UnrealizeWindow;
+ compCheckRedirect (pWin);
+ if (!(*pScreen->UnrealizeWindow) (pWin))
+ ret = FALSE;
+ cs->UnrealizeWindow = pScreen->UnrealizeWindow;
+ pScreen->UnrealizeWindow = compUnrealizeWindow;
+ compCheckTree (pWin->drawable.pScreen);
+ return ret;
+}
+
+/*
+ * Called after the borderClip for the window has settled down
+ * We use this to make sure our extra borderClip has the right origin
+ */
+
+void
+compClipNotify (WindowPtr pWin, int dx, int dy)
+{
+ ScreenPtr pScreen = pWin->drawable.pScreen;
+ CompScreenPtr cs = GetCompScreen (pScreen);
+ CompWindowPtr cw = GetCompWindow (pWin);
+
+ if (cw)
+ {
+ if (cw->borderClipX != pWin->drawable.x ||
+ cw->borderClipY != pWin->drawable.y)
+ {
+ RegionTranslate(&cw->borderClip,
+ pWin->drawable.x - cw->borderClipX,
+ pWin->drawable.y - cw->borderClipY);
+ cw->borderClipX = pWin->drawable.x;
+ cw->borderClipY = pWin->drawable.y;
+ }
+ }
+ if (cs->ClipNotify)
+ {
+ pScreen->ClipNotify = cs->ClipNotify;
+ (*pScreen->ClipNotify) (pWin, dx, dy);
+ cs->ClipNotify = pScreen->ClipNotify;
+ pScreen->ClipNotify = compClipNotify;
+ }
+}
+
+/*
+ * Returns TRUE if the window needs server-provided automatic redirect,
+ * which is true if the child and parent aren't both regular or ARGB visuals
+ */
+
+static Bool
+compIsAlternateVisual (ScreenPtr pScreen,
+ XID visual)
+{
+ CompScreenPtr cs = GetCompScreen (pScreen);
+ int i;
+
+ for (i = 0; i < cs->numAlternateVisuals; i++)
+ if (cs->alternateVisuals[i] == visual)
+ return TRUE;
+ return FALSE;
+}
+
+static Bool
+compImplicitRedirect (WindowPtr pWin, WindowPtr pParent)
+{
+ if (pParent)
+ {
+ ScreenPtr pScreen = pWin->drawable.pScreen;
+ XID winVisual = wVisual (pWin);
+ XID parentVisual = wVisual (pParent);
+
+ if (winVisual != parentVisual &&
+ (compIsAlternateVisual (pScreen, winVisual) ||
+ compIsAlternateVisual (pScreen, parentVisual)))
+ return TRUE;
+ }
+ return FALSE;
+}
+
+static void compFreeOldPixmap(WindowPtr pWin)
+{
+ ScreenPtr pScreen = pWin->drawable.pScreen;
+ if (pWin->redirectDraw != RedirectDrawNone)
+ {
+ CompWindowPtr cw = GetCompWindow (pWin);
+ if (cw->pOldPixmap)
+ {
+ (*pScreen->DestroyPixmap) (cw->pOldPixmap);
+ cw->pOldPixmap = NullPixmap;
+ }
+ }
+}
+void
+compMoveWindow (WindowPtr pWin, int x, int y, WindowPtr pSib, VTKind kind)
+{
+ ScreenPtr pScreen = pWin->drawable.pScreen;
+ CompScreenPtr cs = GetCompScreen (pScreen);
+
+ pScreen->MoveWindow = cs->MoveWindow;
+ (*pScreen->MoveWindow) (pWin, x, y, pSib, kind);
+ cs->MoveWindow = pScreen->MoveWindow;
+ pScreen->MoveWindow = compMoveWindow;
+
+ compFreeOldPixmap(pWin);
+ compCheckTree (pScreen);
+}
+
+void
+compResizeWindow (WindowPtr pWin, int x, int y,
+ unsigned int w, unsigned int h, WindowPtr pSib)
+{
+ ScreenPtr pScreen = pWin->drawable.pScreen;
+ CompScreenPtr cs = GetCompScreen (pScreen);
+
+ pScreen->ResizeWindow = cs->ResizeWindow;
+ (*pScreen->ResizeWindow) (pWin, x, y, w, h, pSib);
+ cs->ResizeWindow = pScreen->ResizeWindow;
+ pScreen->ResizeWindow = compResizeWindow;
+
+ compFreeOldPixmap(pWin);
+ compCheckTree (pWin->drawable.pScreen);
+}
+
+void
+compChangeBorderWidth (WindowPtr pWin, unsigned int bw)
+{
+ ScreenPtr pScreen = pWin->drawable.pScreen;
+ CompScreenPtr cs = GetCompScreen (pScreen);
+
+ pScreen->ChangeBorderWidth = cs->ChangeBorderWidth;
+ (*pScreen->ChangeBorderWidth) (pWin, bw);
+ cs->ChangeBorderWidth = pScreen->ChangeBorderWidth;
+ pScreen->ChangeBorderWidth = compChangeBorderWidth;
+
+ compFreeOldPixmap(pWin);
+ compCheckTree (pWin->drawable.pScreen);
+}
+
+void
+compReparentWindow (WindowPtr pWin, WindowPtr pPriorParent)
+{
+ ScreenPtr pScreen = pWin->drawable.pScreen;
+ CompScreenPtr cs = GetCompScreen (pScreen);
+
+ pScreen->ReparentWindow = cs->ReparentWindow;
+ /*
+ * Remove any implicit redirect due to synthesized visual
+ */
+ if (compImplicitRedirect (pWin, pPriorParent))
+ compUnredirectWindow (serverClient, pWin, CompositeRedirectAutomatic);
+ /*
+ * Handle subwindows redirection
+ */
+ compUnredirectOneSubwindow (pPriorParent, pWin);
+ compRedirectOneSubwindow (pWin->parent, pWin);
+ /*
+ * Add any implict redirect due to synthesized visual
+ */
+ if (compImplicitRedirect (pWin, pWin->parent))
+ compRedirectWindow (serverClient, pWin, CompositeRedirectAutomatic);
+
+ /*
+ * Allocate any necessary redirect pixmap
+ * (this actually should never be true; pWin is always unmapped)
+ */
+ compCheckRedirect (pWin);
+
+ /*
+ * Reset pixmap pointers as appropriate
+ */
+ if (pWin->parent && pWin->redirectDraw == RedirectDrawNone)
+ compSetPixmap (pWin, (*pScreen->GetWindowPixmap) (pWin->parent));
+ /*
+ * Call down to next function
+ */
+ if (pScreen->ReparentWindow)
+ (*pScreen->ReparentWindow) (pWin, pPriorParent);
+ cs->ReparentWindow = pScreen->ReparentWindow;
+ pScreen->ReparentWindow = compReparentWindow;
+ compCheckTree (pWin->drawable.pScreen);
+}
+
+void
+compCopyWindow (WindowPtr pWin, DDXPointRec ptOldOrg, RegionPtr prgnSrc)
+{
+ ScreenPtr pScreen = pWin->drawable.pScreen;
+ CompScreenPtr cs = GetCompScreen (pScreen);
+ int dx = 0, dy = 0;
+
+ if (pWin->redirectDraw != RedirectDrawNone)
+ {
+ PixmapPtr pPixmap = (*pScreen->GetWindowPixmap) (pWin);
+ CompWindowPtr cw = GetCompWindow (pWin);
+
+ assert (cw->oldx != COMP_ORIGIN_INVALID);
+ assert (cw->oldy != COMP_ORIGIN_INVALID);
+ if (cw->pOldPixmap)
+ {
+ /*
+ * Ok, the old bits are available in pOldPixmap and
+ * need to be copied to pNewPixmap.
+ */
+ RegionRec rgnDst;
+ PixmapPtr pPixmap = (*pScreen->GetWindowPixmap) (pWin);
+ GCPtr pGC;
+
+ dx = ptOldOrg.x - pWin->drawable.x;
+ dy = ptOldOrg.y - pWin->drawable.y;
+ RegionTranslate(prgnSrc, -dx, -dy);
+
+ RegionNull(&rgnDst);
+
+ RegionIntersect(&rgnDst,
+ &pWin->borderClip, prgnSrc);
+
+ RegionTranslate(&rgnDst,
+ -pPixmap->screen_x, -pPixmap->screen_y);
+
+ dx = dx + pPixmap->screen_x - cw->oldx;
+ dy = dy + pPixmap->screen_y - cw->oldy;
+ pGC = GetScratchGC (pPixmap->drawable.depth, pScreen);
+ if (pGC)
+ {
+ BoxPtr pBox = RegionRects (&rgnDst);
+ int nBox = RegionNumRects (&rgnDst);
+
+ ValidateGC(&pPixmap->drawable, pGC);
+ while (nBox--)
+ {
+ (void) (*pGC->ops->CopyArea) (&cw->pOldPixmap->drawable,
+ &pPixmap->drawable,
+ pGC,
+ pBox->x1 + dx, pBox->y1 + dy,
+ pBox->x2 - pBox->x1,
+ pBox->y2 - pBox->y1,
+ pBox->x1, pBox->y1);
+ pBox++;
+ }
+ FreeScratchGC (pGC);
+ }
+ return;
+ }
+ dx = pPixmap->screen_x - cw->oldx;
+ dy = pPixmap->screen_y - cw->oldy;
+ ptOldOrg.x += dx;
+ ptOldOrg.y += dy;
+ }
+
+ pScreen->CopyWindow = cs->CopyWindow;
+ if (ptOldOrg.x != pWin->drawable.x || ptOldOrg.y != pWin->drawable.y)
+ {
+ if (dx || dy)
+ RegionTranslate(prgnSrc, dx, dy);
+ (*pScreen->CopyWindow) (pWin, ptOldOrg, prgnSrc);
+ if (dx || dy)
+ RegionTranslate(prgnSrc, -dx, -dy);
+ }
+ else
+ {
+ ptOldOrg.x -= dx;
+ ptOldOrg.y -= dy;
+ RegionTranslate(prgnSrc,
+ pWin->drawable.x - ptOldOrg.x,
+ pWin->drawable.y - ptOldOrg.y);
+ DamageDamageRegion(&pWin->drawable, prgnSrc);
+ }
+ cs->CopyWindow = pScreen->CopyWindow;
+ pScreen->CopyWindow = compCopyWindow;
+ compCheckTree (pWin->drawable.pScreen);
+}
+
+Bool
+compCreateWindow (WindowPtr pWin)
+{
+ ScreenPtr pScreen = pWin->drawable.pScreen;
+ CompScreenPtr cs = GetCompScreen (pScreen);
+ Bool ret;
+
+ pScreen->CreateWindow = cs->CreateWindow;
+ ret = (*pScreen->CreateWindow) (pWin);
+ if (pWin->parent && ret)
+ {
+ CompSubwindowsPtr csw = GetCompSubwindows (pWin->parent);
+ CompClientWindowPtr ccw;
+
+ (*pScreen->SetWindowPixmap) (pWin, (*pScreen->GetWindowPixmap) (pWin->parent));
+ if (csw)
+ for (ccw = csw->clients; ccw; ccw = ccw->next)
+ compRedirectWindow (clients[CLIENT_ID(ccw->id)],
+ pWin, ccw->update);
+ if (compImplicitRedirect (pWin, pWin->parent))
+ compRedirectWindow (serverClient, pWin, CompositeRedirectAutomatic);
+ }
+ cs->CreateWindow = pScreen->CreateWindow;
+ pScreen->CreateWindow = compCreateWindow;
+ compCheckTree (pWin->drawable.pScreen);
+ return ret;
+}
+
+Bool
+compDestroyWindow (WindowPtr pWin)
+{
+ ScreenPtr pScreen = pWin->drawable.pScreen;
+ CompScreenPtr cs = GetCompScreen (pScreen);
+ CompWindowPtr cw;
+ CompSubwindowsPtr csw;
+ Bool ret;
+
+ pScreen->DestroyWindow = cs->DestroyWindow;
+ while ((cw = GetCompWindow (pWin)))
+ FreeResource (cw->clients->id, RT_NONE);
+ while ((csw = GetCompSubwindows (pWin)))
+ FreeResource (csw->clients->id, RT_NONE);
+
+ if (pWin->redirectDraw != RedirectDrawNone) {
+ PixmapPtr pPixmap = (*pScreen->GetWindowPixmap) (pWin);
+ compSetParentPixmap (pWin);
+ (*pScreen->DestroyPixmap) (pPixmap);
+ }
+ ret = (*pScreen->DestroyWindow) (pWin);
+ cs->DestroyWindow = pScreen->DestroyWindow;
+ pScreen->DestroyWindow = compDestroyWindow;
+/* compCheckTree (pWin->drawable.pScreen); can't check -- tree isn't good*/
+ return ret;
+}
+
+void
+compSetRedirectBorderClip (WindowPtr pWin, RegionPtr pRegion)
+{
+ CompWindowPtr cw = GetCompWindow (pWin);
+ RegionRec damage;
+
+ RegionNull(&damage);
+ /*
+ * Align old border clip with new border clip
+ */
+ RegionTranslate(&cw->borderClip,
+ pWin->drawable.x - cw->borderClipX,
+ pWin->drawable.y - cw->borderClipY);
+ /*
+ * Compute newly visible portion of window for repaint
+ */
+ RegionSubtract(&damage, pRegion, &cw->borderClip);
+ /*
+ * Report that as damaged so it will be redrawn
+ */
+ DamageDamageRegion(&pWin->drawable, &damage);
+ RegionUninit(&damage);
+ /*
+ * Save the new border clip region
+ */
+ RegionCopy(&cw->borderClip, pRegion);
+ cw->borderClipX = pWin->drawable.x;
+ cw->borderClipY = pWin->drawable.y;
+}
+
+RegionPtr
+compGetRedirectBorderClip (WindowPtr pWin)
+{
+ CompWindowPtr cw = GetCompWindow (pWin);
+
+ return &cw->borderClip;
+}
+
+static VisualPtr
+compGetWindowVisual (WindowPtr pWin)
+{
+ ScreenPtr pScreen = pWin->drawable.pScreen;
+ VisualID vid = wVisual (pWin);
+ int i;
+
+ for (i = 0; i < pScreen->numVisuals; i++)
+ if (pScreen->visuals[i].vid == vid)
+ return &pScreen->visuals[i];
+ return 0;
+}
+
+PictFormatPtr
+compWindowFormat (WindowPtr pWin)
+{
+ ScreenPtr pScreen = pWin->drawable.pScreen;
+
+ return PictureMatchVisual (pScreen, pWin->drawable.depth,
+ compGetWindowVisual (pWin));
+}
+
+static void
+compWindowUpdateAutomatic (WindowPtr pWin)
+{
+ CompWindowPtr cw = GetCompWindow (pWin);
+ ScreenPtr pScreen = pWin->drawable.pScreen;
+ WindowPtr pParent = pWin->parent;
+ PixmapPtr pSrcPixmap = (*pScreen->GetWindowPixmap) (pWin);
+ PictFormatPtr pSrcFormat = compWindowFormat (pWin);
+ PictFormatPtr pDstFormat = compWindowFormat (pWin->parent);
+ int error;
+ RegionPtr pRegion = DamageRegion (cw->damage);
+ PicturePtr pSrcPicture = CreatePicture (0, &pSrcPixmap->drawable,
+ pSrcFormat,
+ 0, 0,
+ serverClient,
+ &error);
+ XID subwindowMode = IncludeInferiors;
+ PicturePtr pDstPicture = CreatePicture (0, &pParent->drawable,
+ pDstFormat,
+ CPSubwindowMode,
+ &subwindowMode,
+ serverClient,
+ &error);
+
+ /*
+ * First move the region from window to screen coordinates
+ */
+ RegionTranslate(pRegion,
+ pWin->drawable.x, pWin->drawable.y);
+
+ /*
+ * Clip against the "real" border clip
+ */
+ RegionIntersect(pRegion, pRegion, &cw->borderClip);
+
+ /*
+ * Now translate from screen to dest coordinates
+ */
+ RegionTranslate(pRegion,
+ -pParent->drawable.x, -pParent->drawable.y);
+
+ /*
+ * Clip the picture
+ */
+ SetPictureClipRegion (pDstPicture, 0, 0, pRegion);
+
+ /*
+ * And paint
+ */
+ CompositePicture (PictOpSrc,
+ pSrcPicture,
+ 0,
+ pDstPicture,
+ 0, 0, /* src_x, src_y */
+ 0, 0, /* msk_x, msk_y */
+ pSrcPixmap->screen_x - pParent->drawable.x,
+ pSrcPixmap->screen_y - pParent->drawable.y,
+ pSrcPixmap->drawable.width,
+ pSrcPixmap->drawable.height);
+ FreePicture (pSrcPicture, 0);
+ FreePicture (pDstPicture, 0);
+ /*
+ * Empty the damage region. This has the nice effect of
+ * rendering the translations above harmless
+ */
+ DamageEmpty (cw->damage);
+}
+
+static void
+compPaintWindowToParent (WindowPtr pWin)
+{
+ compPaintChildrenToWindow (pWin);
+
+ if (pWin->redirectDraw != RedirectDrawNone)
+ {
+ CompWindowPtr cw = GetCompWindow(pWin);
+
+ if (cw->damaged)
+ {
+ compWindowUpdateAutomatic (pWin);
+ cw->damaged = FALSE;
+ }
+ }
+}
+
+void
+compPaintChildrenToWindow (WindowPtr pWin)
+{
+ WindowPtr pChild;
+
+ if (!pWin->damagedDescendants)
+ return;
+
+ for (pChild = pWin->lastChild; pChild; pChild = pChild->prevSib)
+ compPaintWindowToParent (pChild);
+
+ pWin->damagedDescendants = FALSE;
+}
+
+WindowPtr
+CompositeRealChildHead (WindowPtr pWin)
+{
+ WindowPtr pChild, pChildBefore;
+ CompScreenPtr cs;
+
+ if (!pWin->parent &&
+ (screenIsSaved == SCREEN_SAVER_ON) &&
+ (HasSaverWindow (pWin->drawable.pScreen))) {
+
+ /* First child is the screen saver; see if next child is the overlay */
+ pChildBefore = pWin->firstChild;
+ pChild = pChildBefore->nextSib;
+
+ } else {
+ pChildBefore = NullWindow;
+ pChild = pWin->firstChild;
+ }
+
+ if (!pChild) {
+ return NullWindow;
+ }
+
+ cs = GetCompScreen(pWin->drawable.pScreen);
+ if (pChild == cs->pOverlayWin) {
+ return pChild;
+ } else {
+ return pChildBefore;
+ }
+}
+
+int
+compConfigNotify(WindowPtr pWin, int x, int y, int w, int h,
+ int bw, WindowPtr pSib)
+{
+ ScreenPtr pScreen = pWin->drawable.pScreen;
+ CompScreenPtr cs = GetCompScreen (pScreen);
+ Bool ret = 0;
+ WindowPtr pParent = pWin->parent;
+ int draw_x, draw_y;
+ Bool alloc_ret;
+
+ if (cs->ConfigNotify)
+ {
+ pScreen->ConfigNotify = cs->ConfigNotify;
+ ret = (*pScreen->ConfigNotify)(pWin, x, y, w, h, bw, pSib);
+ cs->ConfigNotify = pScreen->ConfigNotify;
+ pScreen->ConfigNotify = compConfigNotify;
+
+ if (ret)
+ return ret;
+ }
+
+ if (pWin->redirectDraw == RedirectDrawNone)
+ return Success;
+
+ compCheckTree (pScreen);
+
+ draw_x = pParent->drawable.x + x + bw;
+ draw_y = pParent->drawable.y + y + bw;
+ alloc_ret = compReallocPixmap (pWin, draw_x, draw_y, w, h, bw);
+
+ if (alloc_ret == FALSE)
+ return BadAlloc;
+ return Success;
+}
diff --git a/xorg-server/configure.ac b/xorg-server/configure.ac
index 588ee62a8..655c0e4ba 100644
--- a/xorg-server/configure.ac
+++ b/xorg-server/configure.ac
@@ -1,2249 +1,2247 @@
-dnl Copyright © 2003-2007 Keith Packard, Daniel Stone
-dnl
-dnl Permission is hereby granted, free of charge, to any person obtaining a
-dnl copy of this software and associated documentation files (the "Software"),
-dnl to deal in the Software without restriction, including without limitation
-dnl the rights to use, copy, modify, merge, publish, distribute, sublicense,
-dnl and/or sell copies of the Software, and to permit persons to whom the
-dnl Software is furnished to do so, subject to the following conditions:
-dnl
-dnl The above copyright notice and this permission notice (including the next
-dnl paragraph) shall be included in all copies or substantial portions of the
-dnl Software.
-dnl
-dnl THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-dnl IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-dnl FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
-dnl THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-dnl LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-dnl FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
-dnl DEALINGS IN THE SOFTWARE.
-dnl
-dnl Authors: Keith Packard <keithp@keithp.com>
-dnl Daniel Stone <daniel@fooishbar.org>
-dnl an unwitting cast of miscellaneous others
-dnl
-dnl Process this file with autoconf to create configure.
-
-AC_PREREQ(2.57)
-AC_INIT([xorg-server], 1.10.99.1, [https://bugs.freedesktop.org/enter_bug.cgi?product=xorg], xorg-server)
-RELEASE_DATE="unreleased"
-AC_CONFIG_SRCDIR([Makefile.am])
-AM_INIT_AUTOMAKE([foreign dist-bzip2])
-AM_MAINTAINER_MODE
-
-# Require xorg-macros minimum of 1.13 for XORG_ENABLE_UNIT_TESTS
-m4_ifndef([XORG_MACROS_VERSION],
- [m4_fatal([must install xorg-macros 1.13 or later before running autoconf/autogen])])
-XORG_MACROS_VERSION(1.13)
-XORG_DEFAULT_OPTIONS
-XORG_WITH_DOXYGEN(1.6.1)
-XORG_CHECK_SGML_DOCTOOLS(1.5)
-XORG_ENABLE_DOCS
-XORG_ENABLE_DEVEL_DOCS
-XORG_WITH_XMLTO(0.0.20)
-XORG_WITH_FOP
-XORG_ENABLE_UNIT_TESTS
-XORG_LD_WRAP
-
-m4_ifndef([XORG_FONT_MACROS_VERSION], [m4_fatal([must install fontutil 1.1 or later before running autoconf/autogen])])
-XORG_FONT_MACROS_VERSION(1.1)
-
-dnl this gets generated by autoheader, and thus contains all the defines. we
-dnl don't ever actually use it, internally.
-AC_CONFIG_HEADERS(include/do-not-use-config.h)
-dnl xorg-server.h is an external header, designed to be included by loadable
-dnl drivers.
-AC_CONFIG_HEADERS(include/xorg-server.h)
-dnl dix-config.h covers most of the DIX (i.e. everything but the DDX, not just
-dnl dix/).
-AC_CONFIG_HEADERS(include/dix-config.h)
-dnl xorg-config.h covers the Xorg DDX.
-AC_CONFIG_HEADERS(include/xorg-config.h)
-dnl xkb-config.h covers XKB for the Xorg and Xnest DDXs.
-AC_CONFIG_HEADERS(include/xkb-config.h)
-dnl xwin-config.h covers the XWin DDX.
-AC_CONFIG_HEADERS(include/xwin-config.h)
-dnl kdrive-config.h covers the kdrive DDX
-AC_CONFIG_HEADERS(include/kdrive-config.h)
-dnl version-config.h covers the version numbers so they can be bumped without
-dnl forcing an entire recompile.x
-AC_CONFIG_HEADERS(include/version-config.h)
-
-AM_PROG_AS
-AC_PROG_LN_S
-AC_LIBTOOL_WIN32_DLL
-AC_DISABLE_STATIC
-AC_PROG_LIBTOOL
-AC_PROG_MAKE_SET
-PKG_PROG_PKG_CONFIG
-AC_PROG_LEX
-AC_PROG_YACC
-AC_SYS_LARGEFILE
-XORG_PROG_RAWCPP
-
-# Quoted so that make will expand $(CWARNFLAGS) in makefiles to allow
-# easier overrides at build time.
-XSERVER_CFLAGS='$(CWARNFLAGS)'
-
-dnl Check for dtrace program (needed to build Xserver dtrace probes)
-dnl Also checks for <sys/sdt.h>, since some Linux distros have an
-dnl ISDN trace program named dtrace
-AC_ARG_WITH(dtrace, AS_HELP_STRING([--with-dtrace=PATH],
- [Enable dtrace probes (default: enabled if dtrace found)]),
- [WDTRACE=$withval], [WDTRACE=auto])
-if test "x$WDTRACE" = "xyes" -o "x$WDTRACE" = "xauto" ; then
- AC_PATH_PROG(DTRACE, [dtrace], [not_found], [$PATH:/usr/sbin])
- if test "x$DTRACE" = "xnot_found" ; then
- if test "x$WDTRACE" = "xyes" ; then
- AC_MSG_FAILURE([dtrace requested but not found])
- fi
- WDTRACE="no"
- else
- AC_CHECK_HEADER(sys/sdt.h, [HAS_SDT_H="yes"], [HAS_SDT_H="no"])
- if test "x$WDTRACE" = "xauto" -a "x$HAS_SDT_H" = "xno" ; then
- WDTRACE="no"
- fi
- fi
-fi
-if test "x$WDTRACE" != "xno" ; then
- AC_DEFINE(XSERVER_DTRACE, 1,
- [Define to 1 if the DTrace Xserver provider probes should be built in.])
-
-# Solaris/OpenSolaris require dtrace -G to build dtrace probe information into
-# object files, and require linking with those as relocatable objects, not .a
-# archives. MacOS X handles all this in the normal compiler toolchain, and on
-# some releases (like Tiger), will error out on dtrace -G. For now, other
-# platforms with Dtrace ports are assumed to support -G (the FreeBSD and Linux
-# ports appear to, based on my web searches, but have not yet been tested).
- case $host_os in
- darwin*) SPECIAL_DTRACE_OBJECTS=no ;;
- *) SPECIAL_DTRACE_OBJECTS=yes ;;
- esac
-fi
-AM_CONDITIONAL(XSERVER_DTRACE, [test "x$WDTRACE" != "xno"])
-AM_CONDITIONAL(SPECIAL_DTRACE_OBJECTS, [test "x$SPECIAL_DTRACE_OBJECTS" = "xyes"])
-
-AC_HEADER_DIRENT
-AC_HEADER_STDC
-AC_CHECK_HEADERS([fcntl.h stdlib.h string.h unistd.h dlfcn.h stropts.h fnmatch.h sys/utsname.h])
-
-dnl Checks for typedefs, structures, and compiler characteristics.
-AC_C_CONST
-AC_C_BIGENDIAN([ENDIAN="X_BIG_ENDIAN"], [ENDIAN="X_LITTLE_ENDIAN"])
-
-AC_CHECK_SIZEOF([unsigned long])
-if test "$ac_cv_sizeof_unsigned_long" = 8; then
- AC_DEFINE(_XSERVER64, 1, [Define to 1 if unsigned long is 64 bits.])
-fi
-
-AC_TYPE_PID_T
-
-# Checks for headers/macros for byte swapping
-# Known variants:
-# <byteswap.h> bswap_16, bswap_32, bswap_64 (glibc)
-# <sys/endian.h> __swap16, __swap32, __swap64 (OpenBSD)
-# <sys/endian.h> bswap16, bswap32, bswap64 (other BSD's)
-# and a fallback to local macros if none of the above are found
-
-# if <byteswap.h> is found, assume it's the correct version
-AC_CHECK_HEADERS([byteswap.h])
-
-# if <sys/endian.h> is found, have to check which version
-AC_CHECK_HEADER([sys/endian.h], [HAVE_SYS_ENDIAN_H="yes"], [HAVE_SYS_ENDIAN_H="no"])
-
-if test "x$HAVE_SYS_ENDIAN_H" = "xyes" ; then
- AC_MSG_CHECKING([for __swap16 variant of <sys/endian.h> byteswapping macros])
- AC_LINK_IFELSE([AC_LANG_PROGRAM([
-#include <sys/types.h>
-#include <sys/endian.h>
- ], [
-int a = 1, b;
-b = __swap16(a);
- ])
-], [SYS_ENDIAN__SWAP='yes'], [SYS_ENDIAN__SWAP='no'])
- AC_MSG_RESULT([$SYS_ENDIAN__SWAP])
-
- AC_MSG_CHECKING([for bswap16 variant of <sys/endian.h> byteswapping macros])
- AC_LINK_IFELSE([AC_LANG_PROGRAM([
-#include <sys/types.h>
-#include <sys/endian.h>
- ], [
-int a = 1, b;
-b = bswap16(a);
- ])
-], [SYS_ENDIAN_BSWAP='yes'], [SYS_ENDIAN_BSWAP='no'])
- AC_MSG_RESULT([$SYS_ENDIAN_BSWAP])
-
- if test "$SYS_ENDIAN_BSWAP" = "yes" ; then
- USE_SYS_ENDIAN_H=yes
- BSWAP=bswap
- else
- if test "$SYS_ENDIAN__SWAP" = "yes" ; then
- USE_SYS_ENDIAN_H=yes
- BSWAP=__swap
- else
- USE_SYS_ENDIAN_H=no
- fi
- fi
-
- if test "$USE_SYS_ENDIAN_H" = "yes" ; then
- AC_DEFINE([USE_SYS_ENDIAN_H], 1,
- [Define to use byteswap macros from <sys/endian.h>])
- AC_DEFINE_UNQUOTED([bswap_16], ${BSWAP}16,
- [Define to 16-bit byteswap macro])
- AC_DEFINE_UNQUOTED([bswap_32], ${BSWAP}32,
- [Define to 32-bit byteswap macro])
- AC_DEFINE_UNQUOTED([bswap_64], ${BSWAP}64,
- [Define to 64-bit byteswap macro])
- fi
-fi
-
-dnl Check to see if dlopen is in default libraries (like Solaris, which
-dnl has it in libc), or if libdl is needed to get it.
-AC_CHECK_FUNC([dlopen], [],
- AC_CHECK_LIB([dl], [dlopen], DLOPEN_LIBS="-ldl"))
-AC_SUBST(DLOPEN_LIBS)
-
-dnl Checks for library functions.
-AC_FUNC_VPRINTF
-AC_CHECK_FUNCS([geteuid getuid link memmove memset mkstemp strchr strrchr \
- strtol getopt getopt_long vsnprintf walkcontext backtrace \
- getisax getzoneid shmctl64 strcasestr ffs vasprintf])
-AC_FUNC_ALLOCA
-dnl Old HAS_* names used in os/*.c.
-AC_CHECK_FUNC([getdtablesize],
- AC_DEFINE(HAS_GETDTABLESIZE, 1, [Have the 'getdtablesize' function.]))
-AC_CHECK_FUNC([getifaddrs],
- AC_DEFINE(HAS_GETIFADDRS, 1, [Have the 'getifaddrs' function.]))
-AC_CHECK_FUNC([getpeereid],
- AC_DEFINE(HAS_GETPEEREID, 1, [Have the 'getpeereid' function.]))
-AC_CHECK_FUNC([getpeerucred],
- AC_DEFINE(HAS_GETPEERUCRED, 1, [Have the 'getpeerucred' function.]))
-AC_CHECK_FUNC([strlcat], HAVE_STRLCAT=yes, HAVE_STRLCAT=no)
-AM_CONDITIONAL(NEED_STRLCAT, [test x$HAVE_STRLCAT = xno])
-AC_CHECK_FUNC([strlcpy], AC_DEFINE(HAS_STRLCPY, 1, [Have the 'strlcpy' function]))
-
-AM_CONDITIONAL(NEED_VSNPRINTF, [test x$HAVE_VSNPRINTF = xno])
-
-dnl Check for mmap support for Xvfb
-AC_CHECK_FUNC([mmap], AC_DEFINE(HAS_MMAP, 1, [Have the 'mmap' function.]))
-
-dnl Find the math libary
-AC_CHECK_LIB(m, sqrt)
-AC_CHECK_LIB(m, cbrt, AC_DEFINE(HAVE_CBRT, 1, [Have the 'cbrt' function]))
-
-AC_CHECK_HEADERS([ndbm.h dbm.h rpcsvc/dbm.h])
-
-dnl AGPGART headers
-AC_CHECK_HEADERS([linux/agpgart.h sys/agpio.h sys/agpgart.h], AGP=yes)
-AM_CONDITIONAL(AGP, [test "x$AGP" = xyes])
-
-dnl APM header
-AC_CHECK_HEADERS([linux/apm_bios.h], LNXAPM=yes)
-AM_CONDITIONAL(LNXAPM, [test "x$LNXAPM" = xyes])
-
-dnl fbdev header
-AC_CHECK_HEADERS([linux/fb.h], FBDEV=yes)
-AM_CONDITIONAL(FBDEVHW, [test "x$FBDEV" = xyes])
-
-dnl MTRR header
-AC_CHECK_HEADERS([asm/mtrr.h], ac_cv_asm_mtrr_h=yes)
-if test "x$ac_cv_asm_mtrr_h" = xyes; then
- HAVE_MTRR=yes
-fi
-
-dnl BSD MTRR header
-AC_CHECK_HEADERS([sys/memrange.h], ac_cv_memrange_h=yes)
-if test "x$ac_cv_memrange_h" = xyes; then
- HAVE_MTRR=yes
-fi
-
-if test "x$HAVE_MTRR" = xyes; then
- AC_DEFINE(HAS_MTRR_SUPPORT, 1, [MTRR support available])
-fi
-
-dnl A NetBSD MTRR header
-AC_CHECK_HEADERS([machine/mtrr.h], ac_cv_machine_mtrr_h=yes)
-if test "x$ac_cv_machine_mtrr_h" = xyes; then
- AC_DEFINE(HAS_MTRR_BUILTIN, 1, [Define to 1 if NetBSD built-in MTRR
- support is available])
-fi
-
-dnl FreeBSD kldload support (sys/linker.h)
-AC_CHECK_HEADERS([sys/linker.h],
- [ac_cv_sys_linker_h=yes],
- [ac_cv_sys_linker_h=no],
- [#include <sys/param.h>])
-AM_CONDITIONAL(FREEBSD_KLDLOAD, [test "x$ac_cv_sys_linker_h" = xyes])
-
-AC_CACHE_CHECK([for SYSV IPC],
- ac_cv_sysv_ipc,
- [AC_TRY_LINK([
-#include <sys/types.h>
-#include <sys/ipc.h>
-#include <sys/shm.h>
-],[
-{
- int id;
- id = shmget(IPC_PRIVATE, 512, SHM_W | SHM_R);
- if (id < 0) return -1;
- return shmctl(id, IPC_RMID, 0);
-}],
- [ac_cv_sysv_ipc=yes],
- [ac_cv_sysv_ipc=no])])
-if test "x$ac_cv_sysv_ipc" = xyes; then
- AC_DEFINE(HAVE_SYSV_IPC, 1, [Define to 1 if SYSV IPC is available])
-fi
-
-dnl OpenBSD /dev/xf86 aperture driver
-if test -c /dev/xf86 ; then
- AC_DEFINE(HAS_APERTURE_DRV, 1, [System has /dev/xf86 aperture driver])
-fi
-
-dnl BSD APM support
-AC_CHECK_HEADER([machine/apmvar.h],[
- AC_CHECK_HEADER([sys/event.h],
- ac_cv_BSD_KQUEUE_APM=yes,
- ac_cv_BSD_APM=yes)])
-
-AM_CONDITIONAL(BSD_APM, [test "x$ac_cv_BSD_APM" = xyes])
-AM_CONDITIONAL(BSD_KQUEUE_APM, [test "x$ac_cv_BSD_KQUEUE_APM" = xyes])
-
-dnl glibc backtrace support check (hw/xfree86/common/xf86Events.c)
-AC_CHECK_HEADER([execinfo.h],[
- AC_CHECK_LIB(c, backtrace, [
- AC_DEFINE(HAVE_BACKTRACE, 1, [Has backtrace support])
- AC_DEFINE(HAVE_EXECINFO_H, 1, [Have execinfo.h])
- ])]
-)
-
-dnl ---------------------------------------------------------------------------
-dnl Bus options and CPU capabilities. Replaces logic in
-dnl hw/xfree86/os-support/bus/Makefile.am, among others.
-dnl ---------------------------------------------------------------------------
-DEFAULT_INT10="x86emu"
-
-dnl Override defaults as needed for specific platforms:
-
-case $host_cpu in
- alpha*)
- ALPHA_VIDEO=yes
- case $host_os in
- *freebsd*) SYS_LIBS=-lio ;;
- *netbsd*) AC_DEFINE(USE_ALPHA_PIO, 1, [NetBSD PIO alpha IO]) ;;
- esac
- GLX_ARCH_DEFINES="-D__GLX_ALIGN64 -mieee"
- ;;
- arm*)
- ARM_VIDEO=yes
- ;;
- i*86)
- I386_VIDEO=yes
- case $host_os in
- *freebsd*) AC_DEFINE(USE_DEV_IO) ;;
- *dragonfly*) AC_DEFINE(USE_DEV_IO) ;;
- *netbsd*) AC_DEFINE(USE_I386_IOPL)
- SYS_LIBS=-li386
- ;;
- *openbsd*) AC_DEFINE(USE_I386_IOPL)
- SYS_LIBS=-li386
- ;;
- esac
- ;;
- powerpc*)
- PPC_VIDEO=yes
- case $host_os in
- *freebsd*) DEFAULT_INT10=stub ;;
- esac
- ;;
- sparc*)
- SPARC64_VIDEO=yes
- BSD_ARCH_SOURCES="sparc64_video.c ioperm_noop.c"
- GLX_ARCH_DEFINES="-D__GLX_ALIGN64"
- ;;
- x86_64*|amd64*)
- I386_VIDEO=yes
- case $host_os in
- *freebsd*) AC_DEFINE(USE_DEV_IO, 1, [BSD /dev/io]) ;;
- *dragonfly*) AC_DEFINE(USE_DEV_IO, 1, [BSD /dev/io]) ;;
- *netbsd*) AC_DEFINE(USE_I386_IOPL, 1, [BSD i386 iopl])
- SYS_LIBS=-lx86_64
- ;;
- *openbsd*) AC_DEFINE(USE_AMD64_IOPL, 1, [BSD AMD64 iopl])
- SYS_LIBS=-lamd64
- ;;
- esac
- GLX_ARCH_DEFINES="-D__GLX_ALIGN64"
- ;;
- ia64*)
- GLX_ARCH_DEFINES="-D__GLX_ALIGN64"
- ;;
- s390*)
- GLX_ARCH_DEFINES="-D__GLX_ALIGN64"
- ;;
-esac
-AC_SUBST(GLX_ARCH_DEFINES)
-
-dnl BSD *_video.c selection
-AM_CONDITIONAL(ALPHA_VIDEO, [test "x$ALPHA_VIDEO" = xyes])
-AM_CONDITIONAL(ARM_VIDEO, [test "x$ARM_VIDEO" = xyes])
-AM_CONDITIONAL(I386_VIDEO, [test "x$I386_VIDEO" = xyes])
-AM_CONDITIONAL(PPC_VIDEO, [test "x$PPC_VIDEO" = xyes])
-AM_CONDITIONAL(SPARC64_VIDEO, [test "x$SPARC64_VIDEO" = xyes])
-
-DRI=no
-USE_SIGIO_BY_DEFAULT="yes"
-dnl it would be nice to autodetect these *CONS_SUPPORTs
-case $host_os in
- *freebsd* | *dragonfly*)
- case $host_os in
- kfreebsd*-gnu) ;;
- *) AC_DEFINE(CSRG_BASED, 1, [System is BSD-like]) ;;
- esac
- AC_DEFINE(PCCONS_SUPPORT, 1, [System has PC console])
- AC_DEFINE(PCVT_SUPPORT, 1, [System has PCVT console])
- AC_DEFINE(SYSCONS_SUPPORT, 1, [System has syscons console])
- DRI=yes
- ;;
- *netbsd*)
- AC_DEFINE(CSRG_BASED, 1, [System is BSD-like])
- AC_DEFINE(PCCONS_SUPPORT, 1, [System has PC console])
- AC_DEFINE(PCVT_SUPPORT, 1, [System has PCVT console])
- AC_DEFINE(WSCONS_SUPPORT, 1, [System has wscons console])
- DRI=yes
- ;;
- *openbsd*)
- AC_DEFINE(CSRG_BASED, 1, [System is BSD-like])
- AC_DEFINE(PCVT_SUPPORT, 1, [System has PC console])
- AC_DEFINE(WSCONS_SUPPORT, 1, [System has wscons console])
- ;;
- *linux*)
- DRI=yes
- ;;
- *solaris*)
- PKG_CHECK_EXISTS(libdrm, DRI=yes, DRI=no)
- # Disable use of SIGIO by default until some system bugs are
- # fixed - see Sun/OpenSolaris bug id 6879897
- USE_SIGIO_BY_DEFAULT="no"
- ;;
- darwin*)
- AC_DEFINE(CSRG_BASED, 1, [System is BSD-like])
- ;;
- cygwin*)
- CFLAGS="$CFLAGS -DFD_SETSIZE=256"
- ;;
-esac
-
-dnl augment XORG_RELEASE_VERSION for our snapshot number and to expose the
-dnl major number
-PVMAJOR=`echo $PACKAGE_VERSION | cut -d . -f 1`
-PVS=`echo $PACKAGE_VERSION | cut -d . -f 4 | cut -d - -f 1`
-if test "x$PVS" = "x"; then
- PVS="0"
-fi
-
-VENDOR_RELEASE="((($PVMAJOR) * 10000000) + (($PVM) * 100000) + (($PVP) * 1000) + $PVS)"
-VENDOR_MAN_VERSION="Version ${PACKAGE_VERSION}"
-
-VENDOR_NAME="The X.Org Foundation"
-VENDOR_NAME_SHORT="X.Org"
-VENDOR_WEB="http://wiki.x.org"
-
-m4_ifdef([AS_HELP_STRING], , [m4_define([AS_HELP_STRING], m4_defn([AC_HELP_STRING]))])
-
-dnl Build options.
-AC_ARG_ENABLE(werror, AS_HELP_STRING([--enable-werror],
- [Obsolete - use --enable-strict-compilation instead]),
- AC_MSG_ERROR([--enable-werror has been replaced by --enable-strict-compilation]))
-
-AC_ARG_ENABLE(debug, AS_HELP_STRING([--enable-debug],
- [Enable debugging (default: disabled)]),
- [DEBUGGING=$enableval], [DEBUGGING=no])
-AC_ARG_ENABLE(use-sigio-by-default, AS_HELP_STRING([--enable-use-sigio-by-default]
- [Enable SIGIO input handlers by default (default: $USE_SIGIO_BY_DEFAULT)]),
- [USE_SIGIO_BY_DEFAULT=$enableval], [])
-AC_ARG_WITH(int10, AS_HELP_STRING([--with-int10=BACKEND], [int10 backend: vm86, x86emu or stub]),
- [INT10="$withval"],
- [INT10="$DEFAULT_INT10"])
-AC_ARG_WITH(vendor-name, AS_HELP_STRING([--with-vendor-name=VENDOR],
- [Vendor string reported by the server]),
- [ VENDOR_NAME="$withval" ], [])
-AC_ARG_WITH(vendor-name-short, AS_HELP_STRING([--with-vendor-name-short=VENDOR],
- [Short version of vendor string reported by the server]),
- [ VENDOR_NAME_SHORT="$withval" ], [])
-AC_ARG_WITH(vendor-web, AS_HELP_STRING([--with-vendor-web=URL],
- [Vendor web address reported by the server]),
- [ VENDOR_WEB="$withval" ], [])
-AC_ARG_WITH(module-dir, AS_HELP_STRING([--with-module-dir=DIR],
- [Directory where modules are installed (default: $libdir/xorg/modules)]),
- [ moduledir="$withval" ],
- [ moduledir="${libdir}/xorg/modules" ])
-AC_ARG_WITH(log-dir, AS_HELP_STRING([--with-log-dir=DIR],
- [Directory where log files are kept (default: $localstatedir/log)]),
- [ logdir="$withval" ],
- [ logdir="$localstatedir/log" ])
-AC_ARG_WITH(builder-addr, AS_HELP_STRING([--with-builder-addr=ADDRESS],
- [Builder address (default: xorg@lists.freedesktop.org)]),
- [ BUILDERADDR="$withval" ],
- [ BUILDERADDR="xorg@lists.freedesktop.org" ])
-AC_ARG_WITH(os-name, AS_HELP_STRING([--with-os-name=OSNAME], [Name of OS (default: output of "uname -srm")]),
- [ OSNAME="$withval" ],
- [ OSNAME=`uname -srm` ])
-AC_ARG_WITH(os-vendor, AS_HELP_STRING([--with-os-vendor=OSVENDOR], [Name of OS vendor]),
- [ OSVENDOR="$withval" ],
- [ OSVENDOR="" ])
-AC_ARG_WITH(builderstring, AS_HELP_STRING([--with-builderstring=BUILDERSTRING], [Additional builder string]),
- [ BUILDERSTRING="$withval" ]
- [ ])
-
-dnl Determine font path
-XORG_FONTROOTDIR
-XORG_FONTSUBDIR(FONTMISCDIR, fontmiscdir, misc)
-XORG_FONTSUBDIR(FONTOTFDIR, fontotfdir, OTF)
-XORG_FONTSUBDIR(FONTTTFDIR, fontttfdir, TTF)
-XORG_FONTSUBDIR(FONTTYPE1DIR, fonttype1dir, Type1)
-XORG_FONTSUBDIR(FONT75DPIDIR, font75dpidir, 75dpi)
-XORG_FONTSUBDIR(FONT100DPIDIR, font100dpidir, 100dpi)
-
-dnl Uses --default-font-path if set, otherwise checks for /etc/X11/fontpath.d,
-dnl otherwise uses standard subdirectories of FONTROOTDIR. When cross
-dnl compiling, assume default font path uses standard FONTROOTDIR directories.
-DEFAULT_FONT_PATH="${FONTMISCDIR}/,${FONTTTFDIR}/,${FONTOTFDIR}/,${FONTTYPE1DIR}/,${FONT100DPIDIR}/,${FONT75DPIDIR}/"
-if test "$cross_compiling" != yes; then
- AC_CHECK_FILE([${sysconfdir}/X11/fontpath.d],
- [DEFAULT_FONT_PATH='catalogue:${sysconfdir}/X11/fontpath.d'],
- [case $host_os in
- darwin*) DEFAULT_FONT_PATH="${DEFAULT_FONT_PATH},/Library/Fonts,/System/Library/Fonts" ;;
- esac])
-fi
-AC_ARG_WITH(default-font-path, AS_HELP_STRING([--with-default-font-path=PATH], [Comma separated list of font dirs]),
- [ FONTPATH="$withval" ],
- [ FONTPATH="${DEFAULT_FONT_PATH}" ])
-
-AC_MSG_CHECKING([for default font path])
-AC_MSG_RESULT([$FONTPATH])
-
-AC_ARG_WITH(xkb-path, AS_HELP_STRING([--with-xkb-path=PATH], [Path to XKB base dir (default: ${datadir}/X11/xkb)]),
- [ XKBPATH="$withval" ],
- [ XKBPATH="${datadir}/X11/xkb" ])
-AC_ARG_WITH(xkb-output, AS_HELP_STRING([--with-xkb-output=PATH], [Path to XKB output dir (default: ${datadir}/X11/xkb/compiled)]),
- [ XKBOUTPUT="$withval" ],
- [ XKBOUTPUT="compiled" ])
-AC_ARG_WITH(default-xkb-rules, AS_HELP_STRING([--with-default-xkb-rules=RULES],
- [Keyboard ruleset (default: base/evdev)]),
- [ XKB_DFLT_RULES="$withval" ],
- [ XKB_DFLT_RULES="" ])
-AC_ARG_WITH(default-xkb-model, AS_HELP_STRING([--with-default-xkb-model=MODEL],
- [Keyboard model (default: pc105)]),
- [ XKB_DFLT_MODEL="$withval" ],
- [ XKB_DFLT_MODEL="pc105" ])
-AC_ARG_WITH(default-xkb-layout, AS_HELP_STRING([--with-default-xkb-layout=LAYOUT],
- [Keyboard layout (default: us)]),
- [ XKB_DFLT_LAYOUT="$withval" ],
- [ XKB_DFLT_LAYOUT="us" ])
-AC_ARG_WITH(default-xkb-variant, AS_HELP_STRING([--with-default-xkb-variant=VARIANT],
- [Keyboard variant (default: (none))]),
- [ XKB_DFLT_VARIANT="$withval" ],
- [ XKB_DFLT_VARIANT="" ])
-AC_ARG_WITH(default-xkb-options, AS_HELP_STRING([--with-default-xkb-options=OPTIONS],
- [Keyboard layout options (default: (none))]),
- [ XKB_DFLT_OPTIONS="$withval" ],
- [ XKB_DFLT_OPTIONS="" ])
-AC_ARG_WITH(serverconfig-path, AS_HELP_STRING([--with-serverconfig-path=PATH],
- [Directory where ancillary server config files are installed (default: ${libdir}/xorg)]),
- [ SERVERCONFIG="$withval" ],
- [ SERVERCONFIG="${libdir}/xorg" ])
-AC_ARG_WITH(apple-applications-dir,AS_HELP_STRING([--with-apple-applications-dir=PATH], [Path to the Applications directory (default: /Applications/Utilities)]),
- [ APPLE_APPLICATIONS_DIR="${withval}" ],
- [ APPLE_APPLICATIONS_DIR="/Applications/Utilities" ])
-AC_SUBST([APPLE_APPLICATIONS_DIR])
-AC_ARG_WITH(apple-application-name,AS_HELP_STRING([--with-apple-application-name=NAME], [Name for the .app (default: X11)]),
- [ APPLE_APPLICATION_NAME="${withval}" ],
- [ APPLE_APPLICATION_NAME="X11" ])
-AC_SUBST([APPLE_APPLICATION_NAME])
-AC_ARG_WITH(launchd-id-prefix, AS_HELP_STRING([--with-launchd-id-prefix=PATH], [Deprecated: Use --with-bundle-id-prefix.]),
- [ BUNDLE_ID_PREFIX="${withval}" ],
- [ BUNDLE_ID_PREFIX="org.x" ])
-AC_ARG_WITH(bundle-id-prefix, AS_HELP_STRING([--with-bundle-id-prefix=PATH], [Prefix to use for bundle identifiers (default: org.x)]),
- [ BUNDLE_ID_PREFIX="${withval}" ],
- [ BUNDLE_ID_PREFIX="org.x" ])
-AC_SUBST([BUNDLE_ID_PREFIX])
-AC_DEFINE_UNQUOTED(BUNDLE_ID_PREFIX, "$BUNDLE_ID_PREFIX", [Prefix to use for bundle identifiers])
-AC_ARG_ENABLE(sparkle,AS_HELP_STRING([--enable-sparkle], [Enable updating of X11.app using the Sparkle Framework (default: disabled)]),
- [ XQUARTZ_SPARKLE="${enableval}" ],
- [ XQUARTZ_SPARKLE="no" ])
-AC_SUBST([XQUARTZ_SPARKLE])
-AC_ARG_ENABLE(install-libxf86config,
- AS_HELP_STRING([--enable-install-libxf86config],
- [Install libxf86config (default: disabled)]),
- [INSTALL_LIBXF86CONFIG=$enableval],
- [INSTALL_LIBXF86CONFIG=no])
-AC_ARG_ENABLE(visibility, AC_HELP_STRING([--enable-visibility], [Enable symbol visibility (default: auto)]),
- [SYMBOL_VISIBILITY=$enableval],
- [SYMBOL_VISIBILITY=auto])
-AC_ARG_ENABLE(pc98, AC_HELP_STRING([--enable-pc98], [Enable PC98 support in Xorg (default: auto)]),
- [SUPPORT_PC98=$enableval],
- [SUPPORT_PC98=auto])
-
-dnl GLX build options
-AC_ARG_ENABLE(aiglx, AS_HELP_STRING([--enable-aiglx], [Build accelerated indirect GLX (default: enabled)]),
- [AIGLX=$enableval],
- [AIGLX=yes])
-XORG_TLS
-AC_ARG_ENABLE(glx-tls, AS_HELP_STRING([--enable-glx-tls], [Build GLX with TLS support (default: auto)]),
- [GLX_USE_TLS=$enableval
- if test "x$GLX_USE_TLS" = "xyes" && test "${ac_cv_tls}" = "none" ; then
- AC_MSG_ERROR([GLX with TLS support requested, but the compiler does not support it.])
- fi],
- [GLX_USE_TLS=no
- if test "${ac_cv_tls}" != "none" ; then
- GLX_USE_TLS=yes
- fi])
-AC_SUBST(GLX_TLS, ${GLX_USE_TLS})
-AC_ARG_WITH(khronos-spec-dir, AS_HELP_STRING([--with-khronos-spec-dir=PATH], [Path to Khronos OpenGL registry database files (default: auto)]),
- [KHRONOS_SPEC_DIR="${withval}"],
- [KHRONOS_SPEC_DIR=auto])
-
-dnl Extensions.
-AC_ARG_ENABLE(registry, AS_HELP_STRING([--disable-registry], [Build string registry module (default: enabled)]), [XREGISTRY=$enableval], [XREGISTRY=yes])
-AC_ARG_ENABLE(composite, AS_HELP_STRING([--disable-composite], [Build Composite extension (default: enabled)]), [COMPOSITE=$enableval], [COMPOSITE=yes])
-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(record, AS_HELP_STRING([--disable-record], [Build Record extension (default: enabled)]), [RECORD=$enableval], [RECORD=yes])
-AC_ARG_ENABLE(xv, AS_HELP_STRING([--disable-xv], [Build Xv extension (default: enabled)]), [XV=$enableval], [XV=yes])
-AC_ARG_ENABLE(xvmc, AS_HELP_STRING([--disable-xvmc], [Build XvMC extension (default: enabled)]), [XVMC=$enableval], [XVMC=yes])
-AC_ARG_ENABLE(dga, AS_HELP_STRING([--disable-dga], [Build DGA extension (default: auto)]), [DGA=$enableval], [DGA=auto])
-AC_ARG_ENABLE(screensaver, AS_HELP_STRING([--disable-screensaver], [Build ScreenSaver extension (default: enabled)]), [SCREENSAVER=$enableval], [SCREENSAVER=yes])
-AC_ARG_ENABLE(xdmcp, AS_HELP_STRING([--disable-xdmcp], [Build XDMCP extension (default: auto)]), [XDMCP=$enableval], [XDMCP=auto])
-AC_ARG_ENABLE(xdm-auth-1, AS_HELP_STRING([--disable-xdm-auth-1], [Build XDM-Auth-1 extension (default: auto)]), [XDMAUTH=$enableval], [XDMAUTH=auto])
-AC_ARG_ENABLE(glx, AS_HELP_STRING([--disable-glx], [Build GLX extension (default: enabled)]), [GLX=$enableval], [GLX=yes])
-AC_ARG_ENABLE(dri, AS_HELP_STRING([--enable-dri], [Build DRI extension (default: auto)]), [DRI=$enableval])
-AC_ARG_ENABLE(dri2, AS_HELP_STRING([--enable-dri2], [Build DRI2 extension (default: auto)]), [DRI2=$enableval], [DRI2=auto])
-AC_ARG_ENABLE(xinerama, AS_HELP_STRING([--disable-xinerama], [Build Xinerama extension (default: enabled)]), [XINERAMA=$enableval], [XINERAMA=yes])
-AC_ARG_ENABLE(xf86vidmode, AS_HELP_STRING([--disable-xf86vidmode], [Build XF86VidMode extension (default: auto)]), [XF86VIDMODE=$enableval], [XF86VIDMODE=auto])
-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([--enable-xselinux], [Build SELinux extension (default: disabled)]), [XSELINUX=$enableval], [XSELINUX=no])
-AC_ARG_ENABLE(xcsecurity, AS_HELP_STRING([--enable-xcsecurity], [Build Security extension (default: disabled)]), [XCSECURITY=$enableval], [XCSECURITY=no])
-AC_ARG_ENABLE(tslib, AS_HELP_STRING([--enable-tslib], [Build kdrive tslib touchscreen support (default: disabled)]), [TSLIB=$enableval], [TSLIB=no])
-AC_ARG_ENABLE(dbe, AS_HELP_STRING([--disable-dbe], [Build DBE extension (default: enabled)]), [DBE=$enableval], [DBE=yes])
-AC_ARG_ENABLE(xf86bigfont, AS_HELP_STRING([--enable-xf86bigfont], [Build XF86 Big Font extension (default: disabled)]), [XF86BIGFONT=$enableval], [XF86BIGFONT=no])
-AC_ARG_ENABLE(dpms, AS_HELP_STRING([--disable-dpms], [Build DPMS extension (default: enabled)]), [DPMSExtension=$enableval], [DPMSExtension=yes])
-AC_ARG_ENABLE(config-udev, AS_HELP_STRING([--enable-config-udev], [Build udev support (default: auto)]), [CONFIG_UDEV=$enableval], [CONFIG_UDEV=auto])
-AC_ARG_ENABLE(config-dbus, AS_HELP_STRING([--enable-config-dbus], [Build D-BUS API support (default: no)]), [CONFIG_DBUS_API=$enableval], [CONFIG_DBUS_API=no])
-AC_ARG_ENABLE(config-hal, AS_HELP_STRING([--disable-config-hal], [Build HAL support (default: auto)]), [CONFIG_HAL=$enableval], [CONFIG_HAL=auto])
-AC_ARG_ENABLE(xfree86-utils, AS_HELP_STRING([--enable-xfree86-utils], [Build xfree86 DDX utilities (default: enabled)]), [XF86UTILS=$enableval], [XF86UTILS=yes])
-AC_ARG_ENABLE(xaa, AS_HELP_STRING([--enable-xaa], [Build XAA (default: enabled)]), [XAA=$enableval], [XAA=yes])
-AC_ARG_ENABLE(vgahw, AS_HELP_STRING([--enable-vgahw], [Build Xorg with vga access (default: enabled)]), [VGAHW=$enableval], [VGAHW=yes])
-AC_ARG_ENABLE(vbe, AS_HELP_STRING([--enable-vbe], [Build Xorg with VBE module (default: enabled)]), [VBE=$enableval], [VBE=yes])
-AC_ARG_ENABLE(int10-module, AS_HELP_STRING([--enable-int10-module], [Build Xorg with int10 module (default: enabled)]), [INT10MODULE=$enableval], [INT10MODULE=yes])
-AC_ARG_ENABLE(windowswm, AS_HELP_STRING([--enable-windowswm], [Build XWin with WindowsWM extension (default: no)]), [WINDOWSWM=$enableval], [WINDOWSWM=no])
-AC_ARG_ENABLE(libdrm, AS_HELP_STRING([--enable-libdrm], [Build Xorg with libdrm support (default: enabled)]), [DRM=$enableval],[DRM=yes])
-AC_ARG_ENABLE(clientids, AS_HELP_STRING([--disable-clientids], [Build Xorg with client ID tracking (default: enabled)]), [CLIENTIDS=$enableval], [CLIENTIDS=yes])
-
-dnl DDXes.
-AC_ARG_ENABLE(xorg, AS_HELP_STRING([--enable-xorg], [Build Xorg server (default: auto)]), [XORG=$enableval], [XORG=auto])
-AC_ARG_ENABLE(dmx, AS_HELP_STRING([--enable-dmx], [Build DMX server (default: auto)]), [DMX=$enableval], [DMX=auto])
-AC_ARG_ENABLE(xvfb, AS_HELP_STRING([--enable-xvfb], [Build Xvfb server (default: yes)]), [XVFB=$enableval], [XVFB=yes])
-AC_ARG_ENABLE(xnest, AS_HELP_STRING([--enable-xnest], [Build Xnest server (default: auto)]), [XNEST=$enableval], [XNEST=auto])
-AC_ARG_ENABLE(xquartz, AS_HELP_STRING([--enable-xquartz], [Build Xquartz server for OS-X (default: auto)]), [XQUARTZ=$enableval], [XQUARTZ=auto])
-AC_ARG_ENABLE(standalone-xpbproxy, AS_HELP_STRING([--enable-standalone-xpbproxy], [Build a standalone xpbproxy (in addition to the one integrated into Xquartz as a separate thread) (default: no)]), [STANDALONE_XPBPROXY=$enableval], [STANDALONE_XPBPROXY=no])
-AC_ARG_ENABLE(xwin, AS_HELP_STRING([--enable-xwin], [Build XWin server (default: auto)]), [XWIN=$enableval], [XWIN=auto])
-dnl kdrive and its subsystems
-AC_ARG_ENABLE(kdrive, AS_HELP_STRING([--enable-kdrive], [Build kdrive servers (default: no)]), [KDRIVE=$enableval], [KDRIVE=no])
-AC_ARG_ENABLE(xephyr, AS_HELP_STRING([--enable-xephyr], [Build the kdrive Xephyr server (default: auto)]), [XEPHYR=$enableval], [XEPHYR=auto])
-AC_ARG_ENABLE(xfake, AS_HELP_STRING([--enable-xfake], [Build the kdrive 'fake' server (default: auto)]), [XFAKE=$enableval], [XFAKE=auto])
-AC_ARG_ENABLE(xfbdev, AS_HELP_STRING([--enable-xfbdev], [Build the kdrive framebuffer device server (default: auto)]), [XFBDEV=$enableval], [XFBDEV=auto])
-dnl kdrive options
-AC_ARG_ENABLE(kdrive-kbd, AS_HELP_STRING([--enable-kdrive-kbd], [Build kbd driver for kdrive (default: auto)]), [KDRIVE_KBD=$enableval], [KDRIVE_KBD=auto])
-AC_ARG_ENABLE(kdrive-mouse, AC_HELP_STRING([--enable-kdrive-mouse], [Build mouse driver for kdrive (default: auto)]), [KDRIVE_MOUSE=$enableval], [KDRIVE_MOUSE=auto])
-AC_ARG_ENABLE(kdrive-evdev, AC_HELP_STRING([--enable-kdrive-evdev], [Build evdev driver for kdrive (default: auto)]), [KDRIVE_EVDEV=$enableval], [KDRIVE_EVDEV=auto])
-
-
-dnl chown/chmod to be setuid root as part of build
-dnl Replaces InstallXserverSetUID in imake
-AC_ARG_ENABLE(install-setuid,
- AS_HELP_STRING([--enable-install-setuid],
- [Install Xorg server as owned by root with setuid bit (default: auto)]),
- [SETUID=$enableval], [SETUID=auto])
-AC_MSG_CHECKING([to see if we can install the Xorg server as root])
-if test "x$SETUID" = "xauto" ; then
- case $host_os in
- cygwin*) SETUID="no" ;;
- darwin*) SETUID="no" ;;
- *)
- case $host_cpu in
- sparc) SETUID="no" ;;
- *) SETUID="yes" ;;
- esac
- esac
- if test "x$SETUID" = xyes; then
- touch testfile
- chown root testfile > /dev/null 2>&1 || SETUID="no"
- rm -f testfile
- fi
-fi
-AC_MSG_RESULT([$SETUID])
-AM_CONDITIONAL(INSTALL_SETUID, [test "x$SETUID" = "xyes"])
-
-dnl Issue an error if xtrans.m4 was not found and XTRANS_CONNECTION_FLAGS macro
-dnl was not expanded, since xorg-server with no transport types is rather useless.
-dnl
-dnl If you're seeing an error here, be sure you installed the lib/xtrans module
-dnl first and if it's not in the default location, that you set the ACLOCAL
-dnl environment variable to find it, such as:
-dnl ACLOCAL="aclocal -I ${PREFIX}/share/aclocal"
-m4_pattern_forbid([^XTRANS_CONNECTION_FLAGS$])
-
-# Transport selection macro from xtrans.m4
-XTRANS_CONNECTION_FLAGS
-
-# Secure RPC detection macro from xtrans.m4
-XTRANS_SECURE_RPC_FLAGS
-AM_CONDITIONAL(SECURE_RPC, [test "x$SECURE_RPC" = xyes])
-
-AM_CONDITIONAL(INT10_VM86, [test "x$INT10" = xvm86])
-AM_CONDITIONAL(INT10_X86EMU, [test "x$INT10" = xx86emu])
-AM_CONDITIONAL(INT10_STUB, [test "x$INT10" = xstub])
-if test "x$INT10" = xyes; then
- dnl VM86 headers
- AC_CHECK_HEADERS([sys/vm86.h sys/io.h])
-fi
-
-dnl Handle installing libxf86config
-AM_CONDITIONAL(INSTALL_LIBXF86CONFIG, [test "x$INSTALL_LIBXF86CONFIG" = xyes])
-
-dnl DDX Detection... Yes, it's ugly to have it here... but we need to
-dnl handle this early on so that we don't require unsupported extensions
-case $host_os in
- cygwin*)
- DGA=no
- DRI2=no
- XF86VIDMODE=no
- XSELINUX=no
- XV=no
- ;;
- darwin*)
- DRI2=no
-
- 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
-
- AC_CHECK_FUNC(dispatch_async,
- AC_DEFINE([HAVE_LIBDISPATCH], 1, [Define to 1 if you have the libdispatch (GCD) available]),
- [])
-
- if test "x$XQUARTZ" = xyes ; then
- XQUARTZ=yes
- XVFB=no
- XNEST=no
-
- COMPOSITE=no
- DGA=no
- DPMSExtension=no
- XF86VIDMODE=no
- fi
- ;;
- *) XQUARTZ=no ;;
-esac
-
-dnl ---------------------------------------------------------------------------
-dnl Extension section
-dnl ---------------------------------------------------------------------------
-XEXT_INC='-I$(top_srcdir)/Xext'
-XEXT_LIB='$(top_builddir)/Xext/libXext.la'
-XEXTXORG_LIB='$(top_builddir)/Xext/libXextbuiltin.la'
-
-dnl Optional modules
-VIDEOPROTO="videoproto"
-COMPOSITEPROTO="compositeproto >= 0.4"
-RECORDPROTO="recordproto >= 1.13.99.1"
-SCRNSAVERPROTO="scrnsaverproto >= 1.1"
-RESOURCEPROTO="resourceproto"
-DRIPROTO="xf86driproto >= 2.1.0"
-DRI2PROTO="dri2proto >= 2.3"
-XINERAMAPROTO="xineramaproto"
-BIGFONTPROTO="xf86bigfontproto >= 1.2.0"
-DGAPROTO="xf86dgaproto >= 2.0.99.1"
-GLPROTO="glproto >= 1.4.10"
-DMXPROTO="dmxproto >= 2.2.99.1"
-VIDMODEPROTO="xf86vidmodeproto >= 2.2.99.1"
-WINDOWSWMPROTO="windowswmproto"
-APPLEWMPROTO="applewmproto >= 1.4"
-
-dnl Core modules for most extensions, et al.
-SDK_REQUIRED_MODULES="[xproto >= 7.0.17] [randrproto >= 1.2.99.3] [renderproto >= 0.11] [xextproto >= 7.1.99] [inputproto >= 1.9.99.902] [kbproto >= 1.0.3] fontsproto"
-# Make SDK_REQUIRED_MODULES available for inclusion in xorg-server.pc
-AC_SUBST(SDK_REQUIRED_MODULES)
-
-dnl List of libraries that require a specific version
-LIBAPPLEWM="applewm >= 1.4"
-LIBDMX="dmx >= 1.0.99.1"
-LIBDRI="dri >= 7.8.0"
-LIBDRM="libdrm >= 2.3.0"
-LIBGL="gl >= 7.1.0"
-LIBXEXT="xext >= 1.0.99.4"
-LIBXFONT="xfont >= 1.4.2"
-LIBXI="xi >= 1.2.99.1"
-LIBXTST="xtst >= 1.0.99.2"
-LIBPCIACCESS="pciaccess >= 0.8.0"
-LIBUDEV="libudev >= 143"
-LIBSELINUX="libselinux >= 2.0.86"
-LIBDBUS="dbus-1 >= 1.0"
-LIBPIXMAN="pixman-1 >= 0.21.8"
-
-dnl Pixman is always required, but we separate it out so we can link
-dnl specific modules against it
-PKG_CHECK_MODULES(PIXMAN, $LIBPIXMAN)
-REQUIRED_LIBS="$REQUIRED_LIBS $LIBPIXMAN $LIBXFONT xau"
-
-REQUIRED_MODULES="[fixesproto >= 4.1] [damageproto >= 1.1] [xcmiscproto >= 1.2.0] [xtrans >= 1.2.2] [bigreqsproto >= 1.1.0] $SDK_REQUIRED_MODULES"
-
-if test "x$CONFIG_UDEV" = xyes &&
- { test "x$CONFIG_DBUS_API" = xyes || test "x$CONFIG_HAL" = xyes; }; then
- AC_MSG_ERROR([Hotplugging through both libudev and dbus/hal not allowed])
-fi
-
-PKG_CHECK_MODULES(UDEV, $LIBUDEV, [HAVE_LIBUDEV=yes], [HAVE_LIBUDEV=no])
-if test "x$CONFIG_UDEV" = xauto; then
- CONFIG_UDEV="$HAVE_LIBUDEV"
-fi
-AM_CONDITIONAL(CONFIG_UDEV, [test "x$CONFIG_UDEV" = xyes])
-if test "x$CONFIG_UDEV" = xyes; then
- CONFIG_DBUS_API=no
- CONFIG_HAL=no
- if ! test "x$HAVE_LIBUDEV" = xyes; then
- AC_MSG_ERROR([udev configuration API requested, but libudev is not installed])
- fi
- AC_DEFINE(CONFIG_UDEV, 1, [Use libudev for input hotplug])
-fi
-
-dnl HAVE_DBUS is true if we actually have the D-Bus library, whereas
-dnl CONFIG_DBUS_API is true if we want to enable the D-Bus config
-dnl API.
-PKG_CHECK_MODULES(DBUS, $LIBDBUS, [HAVE_DBUS=yes], [HAVE_DBUS=no])
-if test "x$HAVE_DBUS" = xyes; then
- AC_DEFINE(HAVE_DBUS, 1, [Have D-Bus support])
-fi
-AM_CONDITIONAL(HAVE_DBUS, [test "x$HAVE_DBUS" = xyes])
-
-if test "x$CONFIG_DBUS_API" = xauto; then
- CONFIG_DBUS_API="$HAVE_DBUS"
-fi
-if test "x$CONFIG_DBUS_API" = xyes; then
- if ! test "x$HAVE_DBUS" = xyes; then
- AC_MSG_ERROR([D-Bus configuration API requested, but D-Bus is not installed.])
- fi
-
- AC_DEFINE(CONFIG_DBUS_API, 1, [Use the D-Bus input configuration API])
- CONFIG_NEED_DBUS="yes"
-fi
-AM_CONDITIONAL(CONFIG_DBUS_API, [test "x$CONFIG_DBUS_API" = xyes])
-
-PKG_CHECK_MODULES(HAL, hal, [HAVE_HAL=yes], [HAVE_HAL=no])
-if test "x$CONFIG_HAL" = xauto; then
- CONFIG_HAL="$HAVE_HAL"
-fi
-if test "x$CONFIG_HAL" = xyes; then
- if ! test "x$HAVE_HAL" = xyes; then
- AC_MSG_ERROR([HAL hotplug API requested, but HAL is not installed.])
- fi
-
- AC_DEFINE(CONFIG_HAL, 1, [Use the HAL hotplug API])
- CONFIG_NEED_DBUS="yes"
-fi
-AM_CONDITIONAL(CONFIG_HAL, [test "x$CONFIG_HAL" = xyes])
-
-if test "x$CONFIG_NEED_DBUS" = xyes; then
- AC_DEFINE(CONFIG_NEED_DBUS, 1, [Use D-Bus for input hotplug])
-fi
-AM_CONDITIONAL(CONFIG_NEED_DBUS, [test "x$CONFIG_NEED_DBUS" = xyes])
-
-if test "x$USE_SIGIO_BY_DEFAULT" = xyes; then
- USE_SIGIO_BY_DEFAULT_VALUE=TRUE
-else
- USE_SIGIO_BY_DEFAULT_VALUE=FALSE
-fi
-AC_DEFINE_UNQUOTED([USE_SIGIO_BY_DEFAULT], [$USE_SIGIO_BY_DEFAULT_VALUE],
- [Use SIGIO handlers for input device events by default])
-
-AC_MSG_CHECKING([for glibc...])
-AC_PREPROC_IFELSE([
-#include <features.h>
-#ifndef __GLIBC__
-#error
-#endif
-], glibc=yes, glibc=no)
-AC_MSG_RESULT([$glibc])
-
-AC_CHECK_FUNCS([clock_gettime], [have_clock_gettime=yes],
- [AC_CHECK_LIB([rt], [clock_gettime], [have_clock_gettime=-lrt],
- [have_clock_gettime=no])])
-
-AC_MSG_CHECKING([for a useful monotonic clock ...])
-
-if ! test "x$have_clock_gettime" = xno; then
- if ! test "x$have_clock_gettime" = xyes; then
- CLOCK_LIBS="$have_clock_gettime"
- else
- CLOCK_LIBS=""
- fi
-
- LIBS_SAVE="$LIBS"
- LIBS="$CLOCK_LIBS"
- CPPFLAGS_SAVE="$CPPFLAGS"
-
- if test x"$glibc" = xyes; then
- CPPFLAGS="$CPPFLAGS -D_POSIX_C_SOURCE=200112L"
- fi
-
- AC_RUN_IFELSE([
-#include <time.h>
-
-int main(int argc, char *argv[[]]) {
- struct timespec tp;
-
- if (clock_gettime(CLOCK_MONOTONIC, &tp) == 0)
- return 0;
- else
- return 1;
-}
- ], [MONOTONIC_CLOCK=yes], [MONOTONIC_CLOCK=no],
- [MONOTONIC_CLOCK="cross compiling"])
-
- LIBS="$LIBS_SAVE"
- CPPFLAGS="$CPPFLAGS_SAVE"
-else
- MONOTONIC_CLOCK=no
-fi
-
-AC_MSG_RESULT([$MONOTONIC_CLOCK])
-
-if test "x$MONOTONIC_CLOCK" = xyes; then
- AC_DEFINE(MONOTONIC_CLOCK, 1, [Have monotonic clock from clock_gettime()])
- LIBS="$LIBS $CLOCK_LIBS"
-fi
-
-AM_CONDITIONAL(XV, [test "x$XV" = xyes])
-if test "x$XV" = xyes; then
- AC_DEFINE(XV, 1, [Support Xv extension])
- AC_DEFINE(XvExtension, 1, [Build Xv extension])
- REQUIRED_MODULES="$REQUIRED_MODULES $VIDEOPROTO"
- SDK_REQUIRED_MODULES="$SDK_REQUIRED_MODULES $VIDEOPROTO"
-else
- XVMC=no
-fi
-
-AM_CONDITIONAL(XVMC, [test "x$XVMC" = xyes])
-if test "x$XVMC" = xyes; then
- AC_DEFINE(XvMCExtension, 1, [Build XvMC extension])
-fi
-
-AM_CONDITIONAL(XREGISTRY, [test "x$XREGISTRY" = xyes])
-if test "x$XREGISTRY" = xyes; then
- AC_DEFINE(XREGISTRY, 1, [Build registry module])
-fi
-
-AM_CONDITIONAL(COMPOSITE, [test "x$COMPOSITE" = xyes])
-if test "x$COMPOSITE" = xyes; then
- AC_DEFINE(COMPOSITE, 1, [Support Composite Extension])
- REQUIRED_MODULES="$REQUIRED_MODULES $COMPOSITEPROTO"
- COMPOSITE_LIB='$(top_builddir)/composite/libcomposite.la'
- COMPOSITE_INC='-I$(top_srcdir)/composite'
-fi
-
-AM_CONDITIONAL(MITSHM, [test "x$MITSHM" = xyes])
-if test "x$MITSHM" = xyes; then
- AC_DEFINE(MITSHM, 1, [Support MIT-SHM extension])
- AC_DEFINE(HAS_SHM, 1, [Support SHM])
-fi
-
-AM_CONDITIONAL(RECORD, [test "x$RECORD" = xyes])
-if test "x$RECORD" = xyes; then
- AC_DEFINE(XRECORD, 1, [Support Record extension])
- REQUIRED_MODULES="$REQUIRED_MODULES $RECORDPROTO"
- RECORD_LIB='$(top_builddir)/record/librecord.la'
-fi
-
-AM_CONDITIONAL(SCREENSAVER, [test "x$SCREENSAVER" = xyes])
-if test "x$SCREENSAVER" = xyes; then
- AC_DEFINE(SCREENSAVER, 1, [Support MIT-SCREEN-SAVER extension])
- REQUIRED_MODULES="$REQUIRED_MODULES $SCRNSAVERPROTO"
-fi
-
-AM_CONDITIONAL(RES, [test "x$RES" = xyes])
-if test "x$RES" = xyes; then
- AC_DEFINE(RES, 1, [Support X resource extension])
- REQUIRED_MODULES="$REQUIRED_MODULES $RESOURCEPROTO"
-fi
-
-# The XRes extension may support client ID tracking only if it has
-# been specifically enabled. Client ID tracking is implicitly not
-# supported if XRes extension is disabled.
-AC_MSG_CHECKING([whether to track client ids])
-if test "x$RES" = xyes && test "x$CLIENTIDS" = xyes; then
- AC_DEFINE(CLIENTIDS, 1, [Support client ID tracking])
-else
- CLIENTIDS=no
-fi
-AC_MSG_RESULT([$CLIENTIDS])
-AM_CONDITIONAL(CLIENTIDS, [test "x$CLIENTIDS" = xyes])
-
-if test "x$GLX" = xyes; then
- PKG_CHECK_MODULES([XLIB], [x11])
- PKG_CHECK_MODULES([GL], $GLPROTO $LIBGL)
- AC_SUBST(XLIB_CFLAGS)
- AC_DEFINE(GLXEXT, 1, [Build GLX extension])
- GLX_LIBS='$(top_builddir)/glx/libglx.la'
- GLX_SYS_LIBS="$GLX_SYS_LIBS"
-else
- GLX=no
-fi
-AM_CONDITIONAL(GLX, test "x$GLX" = xyes)
-
-if test "x$GLX" = xno; then
- AIGLX=no
-fi
-
-if test "x$AIGLX" = xyes -a \( "x$DRI" = xyes -o "x$DRI2" = xyes \); then
- AC_DEFINE(AIGLX, 1, [Build AIGLX loader])
-fi
-AM_CONDITIONAL(AIGLX_DRI_LOADER, { test "x$DRI" = xyes || test "x$DRI2" = xyes; } && test "x$AIGLX" = xyes)
-
-if test "x$GLX_USE_TLS" = xyes ; then
- GLX_DEFINES="-DGLX_USE_TLS -DPTHREADS"
- GLX_SYS_LIBS="$GLX_SYS_LIBS -lpthread"
-fi
-AC_SUBST([GLX_DEFINES])
-
-AM_CONDITIONAL(DRI, test "x$DRI" = xyes)
-if test "x$DRI" = xyes; then
- AC_DEFINE(XF86DRI, 1, [Build DRI extension])
- PKG_CHECK_MODULES([DRIPROTO], [$DRIPROTO])
- PKG_CHECK_MODULES([DRI], $GLPROTO $LIBDRI)
- AC_SUBST(DRIPROTO_CFLAGS)
-fi
-
-PKG_CHECK_MODULES([DRI2PROTO], $DRI2PROTO,
- [HAVE_DRI2PROTO=yes], [HAVE_DRI2PROTO=no])
-case "$DRI2,$HAVE_DRI2PROTO" in
- yes,no)
- AC_MSG_ERROR([DRI2 requested, but dri2proto not found.])
- ;;
- yes,yes | auto,yes)
- AC_DEFINE(DRI2, 1, [Build DRI2 extension])
- DRI2=yes
- SDK_REQUIRED_MODULES="$SDK_REQUIRED_MODULES $DRI2PROTO"
- ;;
-esac
-AM_CONDITIONAL(DRI2, test "x$DRI2" = xyes)
-
-if test "x$DRI" = xyes || test "x$DRI2" = xyes; then
- if test "x$DRM" = xyes; then
- AC_DEFINE(WITH_LIBDRM, 1, [Building with libdrm support])
- PKG_CHECK_MODULES([LIBDRM], $LIBDRM)
- fi
-fi
-
-if test "x$DRI2" = xyes; then
- save_CFLAGS=$CFLAGS
- CFLAGS="$GL_CFLAGS $LIBDRM_CFLAGS"
- AC_COMPILE_IFELSE([AC_LANG_SOURCE([[#include <GL/gl.h>
-#include <GL/internal/dri_interface.h>
-#ifndef __DRI_DRI2
-#error DRI2 extension not available.
-#endif]])],
- [HAVE_DRI2EXTENSION=yes],
- [HAVE_DRI2EXTENSION=no])
- CFLAGS=$save_CFLAGS
- if test "x$HAVE_DRI2EXTENSION" = xyes; then
- AC_DEFINE(DRI2_AIGLX, 1, [Build DRI2 AIGLX loader])
- DRI2_AIGLX=yes
- else
- AC_MSG_NOTICE([DRI2 AIGLX disabled, __DRI_DRI2 not defined in dri_interface.h.])
- DRI2_AIGLX=no
- fi
-fi
-AM_CONDITIONAL(DRI2_AIGLX, test "x$DRI2_AIGLX" = xyes)
-
-
-AM_CONDITIONAL(XINERAMA, [test "x$XINERAMA" = xyes])
-if test "x$XINERAMA" = xyes; then
- AC_DEFINE(XINERAMA, 1, [Support Xinerama extension])
- AC_DEFINE(PANORAMIX, 1, [Internal define for Xinerama])
- REQUIRED_MODULES="$REQUIRED_MODULES $XINERAMAPROTO"
- SDK_REQUIRED_MODULES="$SDK_REQUIRED_MODULES $XINERAMAPROTO"
-fi
-
-AM_CONDITIONAL(XACE, [test "x$XACE" = xyes])
-if test "x$XACE" = xyes; then
- AC_DEFINE(XACE, 1, [Build X-ACE extension])
-fi
-
-AM_CONDITIONAL(XSELINUX, [test "x$XSELINUX" = xyes])
-if test "x$XSELINUX" = xyes; then
- if test "x$XACE" != xyes; then
- AC_MSG_ERROR([cannot build SELinux extension without X-ACE])
- fi
- AC_CHECK_HEADERS([libaudit.h], [], AC_MSG_ERROR([SELinux extension requires audit system headers]))
- AC_CHECK_LIB(audit, audit_open, [], AC_MSG_ERROR([SELinux extension requires audit system library]))
- PKG_CHECK_MODULES([SELINUX], $LIBSELINUX)
- SELINUX_LIBS="$SELINUX_LIBS -laudit"
- AC_DEFINE(XSELINUX, 1, [Build SELinux extension])
-fi
-
-AM_CONDITIONAL(XCSECURITY, [test "x$XCSECURITY" = xyes])
-if test "x$XCSECURITY" = xyes; then
- if test "x$XACE" != xyes; then
- AC_MSG_ERROR([cannot build Security extension without X-ACE])
- fi
- AC_DEFINE(XCSECURITY, 1, [Build Security extension])
-fi
-
-AM_CONDITIONAL(DBE, [test "x$DBE" = xyes])
-if test "x$DBE" = xyes; then
- AC_DEFINE(DBE, 1, [Support DBE extension])
- DBE_LIB='$(top_builddir)/dbe/libdbe.la'
-fi
-
-AM_CONDITIONAL(XF86BIGFONT, [test "x$XF86BIGFONT" = xyes])
-if test "x$XF86BIGFONT" = xyes; then
- AC_DEFINE(XF86BIGFONT, 1, [Support XF86 Big font extension])
- REQUIRED_MODULES="$REQUIRED_MODULES $BIGFONTPROTO"
-fi
-
-AM_CONDITIONAL(DPMSExtension, [test "x$DPMSExtension" = xyes])
-if test "x$DPMSExtension" = xyes; then
- AC_DEFINE(DPMSExtension, 1, [Support DPMS extension])
-fi
-
-AC_DEFINE(RENDER, 1, [Support RENDER extension])
-RENDER_LIB='$(top_builddir)/render/librender.la'
-RENDER_INC='-I$(top_srcdir)/render'
-
-AC_DEFINE(RANDR, 1, [Support RANDR extension])
-RANDR_LIB='$(top_builddir)/randr/librandr.la'
-RANDR_INC='-I$(top_srcdir)/randr'
-
-AC_DEFINE(XFIXES,1,[Support XFixes extension])
-FIXES_LIB='$(top_builddir)/xfixes/libxfixes.la'
-FIXES_INC='-I$(top_srcdir)/xfixes'
-
-AC_DEFINE(DAMAGE,1,[Support Damage extension])
-DAMAGE_LIB='$(top_builddir)/damageext/libdamageext.la'
-DAMAGE_INC='-I$(top_srcdir)/damageext'
-MIEXT_DAMAGE_LIB='$(top_builddir)/miext/damage/libdamage.la'
-MIEXT_DAMAGE_INC='-I$(top_srcdir)/miext/damage'
-
-# XINPUT extension is integral part of the server
-AC_DEFINE(XINPUT, 1, [Support X Input extension])
-XI_LIB='$(top_builddir)/Xi/libXi.la'
-XI_INC='-I$(top_srcdir)/Xi'
-
-AM_CONDITIONAL(XF86UTILS, test "x$XF86UTILS" = xyes)
-AM_CONDITIONAL(XAA, test "x$XAA" = xyes)
-AM_CONDITIONAL(VGAHW, test "x$VGAHW" = xyes)
-AM_CONDITIONAL(VBE, test "x$VBE" = xyes)
-AM_CONDITIONAL(INT10MODULE, test "x$INT10MODULE" = xyes)
-
-AC_DEFINE(SHAPE, 1, [Support SHAPE extension])
-
-AC_DEFINE_DIR(XKB_BASE_DIRECTORY, XKBPATH, [Path to XKB data])
-AC_ARG_WITH(xkb-bin-directory,
- AS_HELP_STRING([--with-xkb-bin-directory=DIR], [Directory containing xkbcomp program]),
- [XKB_BIN_DIRECTORY="$withval"],
- [XKB_BIN_DIRECTORY="$bindir"])
-
-AC_DEFINE_DIR(XKB_BIN_DIRECTORY, XKB_BIN_DIRECTORY, [Path to XKB bin dir])
-
-dnl Make sure XKM_OUTPUT_DIR is an absolute path
-XKBOUTPUT_FIRSTCHAR=`echo $XKBOUTPUT | cut -b 1`
-if [[ x$XKBOUTPUT_FIRSTCHAR != x/ -a x$XKBOUTPUT_FIRSTCHAR != 'x$' ]] ; then
- XKBOUTPUT="$XKB_BASE_DIRECTORY/$XKBOUTPUT"
-fi
-
-dnl XKM_OUTPUT_DIR (used in code) must end in / or file names get hosed
-dnl XKB_COMPILED_DIR (used in Makefiles) must not or install-sh gets confused
-
-XKBOUTPUT=`echo $XKBOUTPUT/ | $SED 's|/*$|/|'`
-XKB_COMPILED_DIR=`echo $XKBOUTPUT | $SED 's|/*$||'`
-AC_DEFINE_DIR(XKM_OUTPUT_DIR, XKBOUTPUT, [Path to XKB output dir])
-AC_SUBST(XKB_COMPILED_DIR)
-
-if test "x$XKB_DFLT_RULES" = x; then
- case $host_os in
- linux*)
- dnl doesn't take AutoAddDevices into account, but whatever.
- if test "x$CONFIG_HAL" = xyes; then
- XKB_DFLT_RULES="evdev"
- else
- XKB_DFLT_RULES="base"
- fi
- ;;
- *)
- XKB_DFLT_RULES="base"
- ;;
- esac
-fi
-AC_DEFINE_UNQUOTED(XKB_DFLT_RULES, ["$XKB_DFLT_RULES"], [Default XKB ruleset])
-AC_DEFINE_UNQUOTED(XKB_DFLT_MODEL, ["$XKB_DFLT_MODEL"], [Default XKB model])
-AC_DEFINE_UNQUOTED(XKB_DFLT_LAYOUT, ["$XKB_DFLT_LAYOUT"], [Default XKB layout])
-AC_DEFINE_UNQUOTED(XKB_DFLT_VARIANT, ["$XKB_DFLT_VARIANT"], [Default XKB variant])
-AC_DEFINE_UNQUOTED(XKB_DFLT_OPTIONS, ["$XKB_DFLT_OPTIONS"], [Default XKB options])
-
-XKB_LIB='$(top_builddir)/xkb/libxkb.la'
-XKB_STUB_LIB='$(top_builddir)/xkb/libxkbstubs.la'
-REQUIRED_MODULES="$REQUIRED_MODULES xkbfile"
-
-AC_CHECK_FUNC(strcasecmp, [], AC_DEFINE([NEED_STRCASECMP], 1,
- [Do not have 'strcasecmp'.]))
-AC_CHECK_FUNC(strncasecmp, [], AC_DEFINE([NEED_STRNCASECMP], 1,
- [Do not have 'strncasecmp'.]))
-AC_CHECK_FUNC(strcasestr, [], AC_DEFINE([NEED_STRCASESTR], 1,
- [Do not have 'strcasestr'.]))
-
-PKG_CHECK_MODULES([XDMCP], [xdmcp], [have_libxdmcp="yes"], [have_libxdmcp="no"])
-if test "x$have_libxdmcp" = xyes; then
- AC_CHECK_LIB(Xdmcp, XdmcpWrap, [have_xdmcpwrap="yes"], [have_xdmcpwrap="no"], [$XDMCP_LIBS])
-fi
-if test "x$XDMCP" = xauto; then
- if test "x$have_libxdmcp" = xyes; then
- XDMCP=yes
- else
- XDMCP=no
- fi
-fi
-if test "x$XDMAUTH" = xauto; then
- if test "x$have_libxdmcp" = xyes && test "x$have_xdmcpwrap" = xyes; then
- XDMAUTH=yes
- else
- XDMAUTH=no
- fi
-fi
-
-AM_CONDITIONAL(XDMCP, [test "x$XDMCP" = xyes])
-if test "x$XDMCP" = xyes; then
- AC_DEFINE(XDMCP, 1, [Support XDM Control Protocol])
- REQUIRED_LIBS="$REQUIRED_LIBS xdmcp"
- XDMCP_MODULES="xdmcp"
-fi
-
-AM_CONDITIONAL(XDMAUTH, [test "x$XDMAUTH" = xyes])
-if test "x$XDMAUTH" = xyes; then
- AC_DEFINE(HASXDMAUTH,1,[Support XDM-AUTH*-1])
- if ! test "x$XDMCP" = xyes; then
- REQUIRED_LIBS="$REQUIRED_LIBS xdmcp"
- XDMCP_MODULES="xdmcp"
- fi
-fi
-
-AC_DEFINE_DIR(COMPILEDDEFAULTFONTPATH, FONTPATH, [Default font path])
-AC_DEFINE_DIR(PCI_TXT_IDS_PATH, PCI_TXT_IDS_DIR, [Default PCI text file ID path])
-AC_DEFINE_DIR(SERVER_MISC_CONFIG_PATH, SERVERCONFIG, [Server miscellaneous config path])
-AC_DEFINE_DIR(BASE_FONT_PATH, FONTROOTDIR, [Default base font path])
-dridriverdir=`$PKG_CONFIG --variable=dridriverdir dri`
-AC_DEFINE_DIR(DRI_DRIVER_PATH, dridriverdir, [Default DRI driver path])
-AC_DEFINE_UNQUOTED(XVENDORNAME, ["$VENDOR_NAME"], [Vendor name])
-AC_DEFINE_UNQUOTED(XVENDORNAMESHORT, ["$VENDOR_NAME_SHORT"], [Short vendor name])
-AC_DEFINE_UNQUOTED(XORG_DATE, ["$RELEASE_DATE"], [Vendor release])
-AC_DEFINE_UNQUOTED(XORG_MAN_VERSION, ["$VENDOR_MAN_VERSION"], [Vendor man version])
-AC_DEFINE_UNQUOTED(BUILDERADDR, ["$BUILDERADDR"], [Builder address])
-
-if test -z "$OSNAME"; then
- OSNAME="UNKNOWN"
-fi
-
-AC_DEFINE_UNQUOTED(OSNAME, ["$OSNAME"], [Operating System Name])
-AC_DEFINE_UNQUOTED(OSVENDOR, ["$OSVENDOR"], [Operating System Vendor])
-AC_DEFINE_UNQUOTED(BUILDERSTRING, ["$BUILDERSTRING"], [Builder string])
-
-AC_SUBST([VENDOR_NAME_SHORT])
-AC_DEFINE_UNQUOTED(VENDOR_NAME, ["$VENDOR_NAME"], [Vendor name])
-AC_DEFINE_UNQUOTED(VENDOR_NAME_SHORT, ["$VENDOR_NAME_SHORT"], [Vendor name])
-AC_DEFINE_UNQUOTED(VENDOR_RELEASE, [$VENDOR_RELEASE], [Vendor release])
-AC_DEFINE_UNQUOTED(VENDOR_MAN_VERSION, ["$VENDOR_MAN_VERSION"], [Vendor man version])
-
-AC_DEFINE(NO_LIBCWRAPPER, 1, [Define to 1 if modules should avoid the libcwrapper])
-
-if test "x$DEBUGGING" = xyes; then
- AC_DEFINE(DEBUG, 1, [Enable debugging code])
-fi
-AM_CONDITIONAL(DEBUG, [test "x$DEBUGGING" = xyes])
-
-AC_DEFINE(XTEST, 1, [Support XTest extension])
-AC_DEFINE(XSYNC, 1, [Support XSync extension])
-AC_DEFINE(XCMISC, 1, [Support XCMisc extension])
-AC_DEFINE(BIGREQS, 1, [Support BigRequests extension])
-
-if test "x$SPECIAL_DTRACE_OBJECTS" = "xyes" ; then
- DIX_LIB='$(top_builddir)/dix/dix.O'
- OS_LIB='$(top_builddir)/os/os.O $(SHA1_LIBS) $(DLOPEN_LIBS)'
-else
- DIX_LIB='$(top_builddir)/dix/libdix.la'
- OS_LIB='$(top_builddir)/os/libos.la'
-fi
-AC_SUBST([DIX_LIB])
-AC_SUBST([OS_LIB])
-
-MAIN_LIB='$(top_builddir)/dix/libmain.la'
-AC_SUBST([MAIN_LIB])
-
-MI_LIB='$(top_builddir)/mi/libmi.la'
-MI_EXT_LIB='$(top_builddir)/mi/libmiext.la'
-MI_INC='-I$(top_srcdir)/mi'
-FB_LIB='$(top_builddir)/fb/libfb.la'
-FB_INC='-I$(top_srcdir)/fb'
-MIEXT_SHADOW_INC='-I$(top_srcdir)/miext/shadow'
-MIEXT_SHADOW_LIB='$(top_builddir)/miext/shadow/libshadow.la'
-MIEXT_SYNC_INC='-I$(top_srcdir)/miext/sync'
-MIEXT_SYNC_LIB='$(top_builddir)/miext/sync/libsync.la'
-CORE_INCS='-I$(top_srcdir)/include -I$(top_builddir)/include'
-
-# SHA1 hashing
-AC_ARG_WITH([sha1],
- [AS_HELP_STRING([--with-sha1=libc|libmd|libgcrypt|libcrypto|libsha1|CommonCrypto],
- [choose SHA1 implementation])])
-AC_CHECK_FUNC([SHA1Init], [HAVE_SHA1_IN_LIBC=yes])
-if test "x$with_sha1" = x && test "x$HAVE_SHA1_IN_LIBC" = xyes; then
- with_sha1=libc
-fi
-if test "x$with_sha1" = xlibc && test "x$HAVE_SHA1_IN_LIBC" != xyes; then
- AC_MSG_ERROR([libc requested but not found])
-fi
-if test "x$with_sha1" = xlibc; then
- AC_DEFINE([HAVE_SHA1_IN_LIBC], [1],
- [Use libc SHA1 functions])
- SHA1_LIBS=""
-fi
-AC_CHECK_FUNC([CC_SHA1_Init], [HAVE_SHA1_IN_COMMONCRYPTO=yes])
-if test "x$with_sha1" = x && test "x$HAVE_SHA1_IN_COMMONCRYPTO" = xyes; then
- with_sha1=CommonCrypto
-fi
-if test "x$with_sha1" = xCommonCrypto && test "x$HAVE_SHA1_IN_COMMONCRYPTO" != xyes; then
- AC_MSG_ERROR([CommonCrypto requested but not found])
-fi
-if test "x$with_sha1" = xCommonCrypto; then
- AC_DEFINE([HAVE_SHA1_IN_COMMONCRYPTO], [1],
- [Use CommonCrypto SHA1 functions])
- SHA1_LIBS=""
-fi
-AC_CHECK_LIB([md], [SHA1Init], [HAVE_LIBMD=yes])
-if test "x$with_sha1" = x && test "x$HAVE_LIBMD" = xyes; then
- with_sha1=libmd
-fi
-if test "x$with_sha1" = xlibmd && test "x$HAVE_LIBMD" != xyes; then
- AC_MSG_ERROR([libmd requested but not found])
-fi
-if test "x$with_sha1" = xlibmd; then
- AC_DEFINE([HAVE_SHA1_IN_LIBMD], [1],
- [Use libmd SHA1 functions])
- SHA1_LIBS=-lmd
-fi
-PKG_CHECK_MODULES([LIBSHA1], [libsha1], [HAVE_LIBSHA1=yes], [HAVE_LIBSHA1=no])
-if test "x$with_sha1" = x && test "x$HAVE_LIBSHA1" = xyes; then
- with_sha1=libsha1
-fi
-if test "x$with_sha1" = xlibsha1 && test "x$HAVE_LIBSHA1" != xyes; then
- AC_MSG_ERROR([libsha1 requested but not found])
-fi
-if test "x$with_sha1" = xlibsha1; then
- AC_DEFINE([HAVE_SHA1_IN_LIBSHA1], [1],
- [Use libsha1 for SHA1])
- SHA1_LIBS=-lsha1
-fi
-AC_CHECK_LIB([gcrypt], [gcry_md_open], [HAVE_LIBGCRYPT=yes])
-if test "x$with_sha1" = x && test "x$HAVE_LIBGCRYPT" = xyes; then
- with_sha1=libgcrypt
-fi
-if test "x$with_sha1" = xlibgcrypt && test "x$HAVE_LIBGCRYPT" != xyes; then
- AC_MSG_ERROR([libgcrypt requested but not found])
-fi
-if test "x$with_sha1" = xlibgcrypt; then
- AC_DEFINE([HAVE_SHA1_IN_LIBGCRYPT], [1],
- [Use libgcrypt SHA1 functions])
- SHA1_LIBS=-lgcrypt
-fi
-# We don't need all of the OpenSSL libraries, just libcrypto
-AC_CHECK_LIB([crypto], [SHA1_Init], [HAVE_LIBCRYPTO=yes])
-PKG_CHECK_MODULES([OPENSSL], [openssl], [HAVE_OPENSSL_PKC=yes],
- [HAVE_OPENSSL_PKC=no])
-if test "x$HAVE_LIBCRYPTO" = xyes || test "x$HAVE_OPENSSL_PKC" = xyes; then
- if test "x$with_sha1" = x; then
- with_sha1=libcrypto
- fi
-else
- if test "x$with_sha1" = xlibcrypto; then
- AC_MSG_ERROR([OpenSSL libcrypto requested but not found])
- fi
-fi
-if test "x$with_sha1" = xlibcrypto; then
- if test "x$HAVE_LIBCRYPTO" = xyes; then
- SHA1_LIBS=-lcrypto
- else
- SHA1_LIBS="$OPENSSL_LIBS"
- SHA1_CFLAGS="$OPENSSL_CFLAGS"
- fi
-fi
-AC_MSG_CHECKING([for SHA1 implementation])
-if test "x$with_sha1" = x; then
- AC_MSG_ERROR([No suitable SHA1 implementation found])
-fi
-AC_MSG_RESULT([$with_sha1])
-AC_SUBST(SHA1_LIBS)
-AC_SUBST(SHA1_CFLAGS)
-
-PKG_CHECK_MODULES([XSERVERCFLAGS], [$REQUIRED_MODULES $REQUIRED_LIBS])
-PKG_CHECK_MODULES([XSERVERLIBS], [$REQUIRED_LIBS])
-
-# Autotools has some unfortunate issues with library handling. In order to
-# get a server to rebuild when a dependency in the tree is changed, it must
-# be listed in SERVERNAME_DEPENDENCIES. However, no system libraries may be
-# listed there, or some versions of autotools will break (especially if a -L
-# is required to find the library). So, we keep two sets of libraries
-# detected: NAMESPACE_LIBS for in-tree libraries to be linked against, which
-# will go into the _DEPENDENCIES and _LDADD of the server, and
-# NAMESPACE_SYS_LIBS which will go into only the _LDADD. The
-# NAMESPACEMODULES_LIBS detected from pkgconfig should always go in
-# NAMESPACE_SYS_LIBS.
-#
-# XSERVER_LIBS is the set of in-tree libraries which all servers require.
-# XSERVER_SYS_LIBS is the set of out-of-tree libraries which all servers
-# require.
-#
-XSERVER_CFLAGS="${XSERVER_CFLAGS} ${XSERVERCFLAGS_CFLAGS}"
-XSERVER_LIBS="$DIX_LIB $MI_LIB $OS_LIB"
-XSERVER_SYS_LIBS="${XSERVERLIBS_LIBS} ${SYS_LIBS} ${LIBS}"
-AC_SUBST([XSERVER_LIBS])
-AC_SUBST([XSERVER_SYS_LIBS])
-
-UTILS_SYS_LIBS="${SYS_LIBS}"
-AC_SUBST([UTILS_SYS_LIBS])
-
-# The Xorg binary needs to export symbols so that they can be used from modules
-# Some platforms require extra flags to do this. libtool should set the
-# necessary flags for each platform when -export-dynamic is passed to it.
-LD_EXPORT_SYMBOLS_FLAG="-export-dynamic"
-AC_SUBST([LD_EXPORT_SYMBOLS_FLAG])
-
-dnl Imake defines SVR4 on SVR4 systems, and many files check for it, so
-dnl we need to replicate that here until those can all be fixed
-AC_MSG_CHECKING([if SVR4 needs to be defined])
-AC_EGREP_CPP([I_AM_SVR4],[
-#if defined(SVR4) || defined(__svr4__) || defined(__SVR4)
- I_AM_SVR4
-#endif
-],[
-AC_DEFINE([SVR4],1,[Define to 1 on systems derived from System V Release 4])
-AC_MSG_RESULT([yes])], AC_MSG_RESULT([no]))
-
-XSERVER_CFLAGS="$XSERVER_CFLAGS $CORE_INCS $XEXT_INC $COMPOSITE_INC $DAMAGE_INC $FIXES_INC $XI_INC $MI_INC $MIEXT_SYNC_INC $MIEXT_SHADOW_INC $MIEXT_LAYER_INC $MIEXT_DAMAGE_INC $RENDER_INC $RANDR_INC $FB_INC"
-
-dnl ---------------------------------------------------------------------------
-dnl DDX section.
-dnl ---------------------------------------------------------------------------
-
-dnl Xvfb DDX
-
-AC_MSG_CHECKING([whether to build Xvfb DDX])
-AC_MSG_RESULT([$XVFB])
-AM_CONDITIONAL(XVFB, [test "x$XVFB" = xyes])
-
-if test "x$XVFB" = xyes; then
- XVFB_LIBS="$FB_LIB $FIXES_LIB $XEXT_LIB $DBE_LIB $RECORD_LIB $GLX_LIBS $RANDR_LIB $RENDER_LIB $DAMAGE_LIB $MIEXT_SYNC_LIB $MIEXT_DAMAGE_LIB $MIEXT_SHADOW_LIB $XI_LIB $XKB_LIB $XKB_STUB_LIB $COMPOSITE_LIB"
- XVFB_SYS_LIBS="$XVFBMODULES_LIBS $GLX_SYS_LIBS"
- AC_SUBST([XVFB_LIBS])
- AC_SUBST([XVFB_SYS_LIBS])
-fi
-
-
-dnl Xnest DDX
-
-PKG_CHECK_MODULES(XNESTMODULES, [$LIBXEXT x11 xau $XDMCP_MODULES], [have_xnest=yes], [have_xnest=no])
-AC_MSG_CHECKING([whether to build Xnest DDX])
-if test "x$XNEST" = xauto; then
- XNEST="$have_xnest"
-fi
-AC_MSG_RESULT([$XNEST])
-AM_CONDITIONAL(XNEST, [test "x$XNEST" = xyes])
-
-if test "x$XNEST" = xyes; then
- if test "x$have_xnest" = xno; then
- AC_MSG_ERROR([Xnest build explicitly requested, but required modules not found.])
- fi
- XNEST_LIBS="$FB_LIB $FIXES_LIB $MI_LIB $XEXT_LIB $DBE_LIB $RECORD_LIB $GLX_LIBS $RANDR_LIB $RENDER_LIB $DAMAGE_LIB $MIEXT_SYNC_LIB $MIEXT_DAMAGE_LIB $MIEXT_SHADOW_LIB $XI_LIB $XKB_LIB $XKB_STUB_LIB $COMPOSITE_LIB $MAIN_LIB $DIX_LIB $OS_LIB"
- XNEST_SYS_LIBS="$XNESTMODULES_LIBS $GLX_SYS_LIBS"
- AC_SUBST([XNEST_LIBS])
- AC_SUBST([XNEST_SYS_LIBS])
-fi
-
-
-dnl Xorg DDX
-
-AC_MSG_CHECKING([whether to build Xorg DDX])
-if test "x$XORG" = xauto; then
- XORG="yes"
- case $host_os in
- cygwin*) XORG="no" ;;
- darwin*) XORG="no" ;;
- esac
-fi
-AC_MSG_RESULT([$XORG])
-
-xorg_bus_linuxpci=no
-xorg_bus_bsdpci=no
-xorg_bus_sparc=no
-
-if test "x$XORG" = xyes; then
- XORG_DDXINCS='-I$(top_srcdir)/hw/xfree86 -I$(top_srcdir)/hw/xfree86/include -I$(top_srcdir)/hw/xfree86/common'
- XORG_OSINCS='-I$(top_srcdir)/hw/xfree86/os-support -I$(top_srcdir)/hw/xfree86/os-support/bus -I$(top_srcdir)/os'
- XORG_INCS="$XORG_DDXINCS $XORG_OSINCS"
- XORG_CFLAGS="$XORGSERVER_CFLAGS -DHAVE_XORG_CONFIG_H"
- XORG_LIBS="$COMPOSITE_LIB $FIXES_LIB $XEXTXORG_LIB $GLX_LIBS $RANDR_LIB $RENDER_LIB $DAMAGE_LIB $MIEXT_SYNC_LIB $MIEXT_DAMAGE_LIB $MIEXT_SHADOW_LIB $XI_LIB $XKB_LIB"
-
- dnl ==================================================================
- dnl symbol visibility
- symbol_visibility=
- have_visibility=disabled
- if test x$SYMBOL_VISIBILITY != xno; then
- AC_MSG_CHECKING(for symbol visibility support)
- if test x$GCC = xyes; then
- VISIBILITY_CFLAGS="-fvisibility=hidden"
- else
- AC_CHECK_DECL([__SUNPRO_C], [SUNCC="yes"], [SUNCC="no"])
- if test x$SUNCC = xyes; then
- VISIBILITY_CFLAGS="-xldscope=hidden"
- else
- have_visibility=no
- fi
- fi
- if test x$have_visibility != xno; then
- save_CFLAGS="$CFLAGS"
- CFLAGS="$CFLAGS $VISIBILITY_CFLAGS"
- AC_TRY_COMPILE(
- [#include <X11/Xfuncproto.h>
- extern _X_HIDDEN int hidden_int;
- extern _X_EXPORT int public_int;
- extern _X_HIDDEN int hidden_int_func(void);
- extern _X_EXPORT int public_int_func(void);],
- [],
- have_visibility=yes,
- have_visibility=no)
- CFLAGS=$save_CFLAGS
- fi
- AC_MSG_RESULT([$have_visibility])
- if test x$have_visibility != xno; then
- symbol_visibility=$VISIBILITY_CFLAGS
- XORG_CFLAGS="$XORG_CFLAGS $VISIBILITY_CFLAGS"
- XSERVER_CFLAGS="$XSERVER_CFLAGS $VISIBILITY_CFLAGS"
- fi
- fi
- dnl added to xorg-server.pc
- AC_SUBST([symbol_visibility])
- dnl ===================================================================
-
- PKG_CHECK_MODULES([PCIACCESS], $LIBPCIACCESS)
- SAVE_LIBS=$LIBS
- SAVE_CFLAGS=$CFLAGS
- CFLAGS=$PCIACCESS_CFLAGS
- LIBS=$PCIACCESS_LIBS
- AC_CHECK_FUNCS([pci_system_init_dev_mem])
- AC_CHECK_FUNCS([pci_device_enable])
- AC_CHECK_FUNCS([pci_device_is_boot_vga])
- AC_CHECK_FUNCS([pci_device_vgaarb_init])
- LIBS=$SAVE_LIBS
- CFLAGS=$SAVE_CFLAGS
- XORG_SYS_LIBS="$XORG_SYS_LIBS $PCIACCESS_LIBS $GLX_SYS_LIBS"
- XORG_CFLAGS="$XORG_CFLAGS $PCIACCESS_CFLAGS"
-
- case $host_os in
- linux*)
- if test "x$LNXAPM" = xyes; then
- XORG_CFLAGS="$XORG_CFLAGS -DXF86PM"
- fi
- XORG_OS="linux"
- XORG_OS_SUBDIR="linux"
- xorg_bus_linuxpci="yes"
- linux_acpi="no"
- case $host_cpu in
- ia64*)
- linux_ia64=yes
- linux_acpi="yes"
- ;;
- alpha*)
- linux_alpha=yes
- ;;
- i*86|amd64*|x86_64*)
- linux_acpi="yes"
- ;;
- *)
- ;;
- esac
- ;;
- freebsd* | kfreebsd*-gnu | dragonfly*)
- XORG_OS="freebsd"
- XORG_OS_SUBDIR="bsd"
- xorg_bus_bsdpci="yes"
- ;;
- netbsd*)
- XORG_OS="netbsd"
- XORG_OS_SUBDIR="bsd"
- xorg_bus_bsdpci="yes"
- ;;
- openbsd*)
- if test "x$ac_cv_BSD_APM" = xyes \
- -o "x$ac_cv_BSD_KQUEUE_APM" = xyes; then
- XORG_CFLAGS="$XORG_CFLAGS -DXF86PM"
- fi
- XORG_OS="openbsd"
- XORG_OS_SUBDIR="bsd"
- xorg_bus_bsdpci="yes"
- ;;
- solaris*)
- XORG_OS="solaris"
- XORG_OS_SUBDIR="solaris"
- XORG_CFLAGS="$XORG_CFLAGS -DXF86PM"
- # Use the same stubs as BSD for old functions, since we now
- # use libpciaccess for PCI
- xorg_bus_bsdpci="yes"
- AC_CHECK_HEADERS([sys/kd.h])
- AC_CHECK_HEADERS([sys/vt.h], [solaris_vt=yes], [solaris_vt=no])
- # Check for minimum supported release
- AC_MSG_CHECKING([Solaris version])
- OS_MINOR=`echo ${host_os}|$SED -e 's/^.*solaris2\.//' -e s'/\..*$//'`
- if test "${OS_MINOR}" -ge 7 ; then
- AC_MSG_RESULT(Solaris ${OS_MINOR})
- else
- AC_MSG_RESULT(Solaris `echo ${host_os}|$SED -e 's/^.*solaris//`)
- fi
- if test "${OS_MINOR}" -lt 8 ; then
- AC_MSG_ERROR([This release no longer supports Solaris versions older than Solaris 8.])
- fi
- AC_CHECK_DECL([__SUNPRO_C], [SUNCC="yes"], [SUNCC="no"])
- if test "x$SUNCC" = "xyes"; then
- solaris_asm_inline="yes"
- fi
- AC_CHECK_DECL([_LP64], [SOLARIS_64="yes"], [SOLARIS_64="no"])
-
- case $host_cpu in
- sparc*)
- SOLARIS_INOUT_ARCH="sparcv8plus"
- ;;
- i*86)
- if test x$SOLARIS_64 = xyes ; then
- SOLARIS_INOUT_ARCH="amd64"
- else
- SOLARIS_INOUT_ARCH="ia32"
- fi
- ;;
- *)
- AC_MSG_ERROR([Unsupported Solaris platform. Only SPARC & x86 \
- are supported on Solaris in this release. If you are \
- interested in porting Xorg to your platform, please email \
- xorg@lists.freedesktop.org.]) ;;
- esac
- AC_SUBST([SOLARIS_INOUT_ARCH])
- if test x$solaris_asm_inline = xyes ; then
- SOLARIS_ASM_CFLAGS='$(top_srcdir)/hw/xfree86/os-support/solaris/solaris-$(SOLARIS_INOUT_ARCH).il'
- XORG_CFLAGS="${XORG_CFLAGS} "'$(SOLARIS_ASM_CFLAGS)'
- fi
- AC_SUBST([SOLARIS_ASM_CFLAGS])
- if test "x$SUPPORT_PC98" = xauto; then
- SUPPORT_PC98="no"
- fi
- ;;
- gnu*)
- XORG_OS="gnu"
- XORG_OS_SUBDIR="hurd"
- # Use the same stubs as BSD for old functions, since we now
- # use libpciaccess for PCI
- xorg_bus_bsdpci="yes"
- ;;
- *)
- XORG_OS="unknown"
- XORG_OS_SUBDIR="unknown"
- AC_MSG_ERROR([m4_text_wrap(m4_join([ ],
- [Your OS is unknown. Xorg currently only supports Linux,],
- [Free/Open/Net/DragonFlyBSD, Solaris/OpenSolaris, & GNU Hurd.],
- [If you are interested in porting Xorg to your platform,],
- [please email xorg@lists.freedesktop.org.]))])
- ;;
- esac
-
- case $host_cpu in
- sparc*)
- xorg_bus_sparc="yes"
- ;;
- i*86)
- if test "x$SUPPORT_PC98" = xauto; then
- SUPPORT_PC98="yes"
- fi
- ;;
- esac
-
- if test "x$SUPPORT_PC98" = xauto; then
- SUPPORT_PC98="no"
- fi
- if test "x$SUPPORT_PC98" = xyes; then
- AC_DEFINE(SUPPORT_PC98, 1, [Support PC98])
- fi
- if test "x$XORG_OS_PCI" = x ; then
- XORG_OS_PCI=$XORG_OS
- fi
- if test "x$DGA" = xauto; then
- PKG_CHECK_MODULES(DGA, $DGAPROTO, [DGA=yes], [DGA=no])
- fi
- if test "x$DGA" = xyes; then
- XORG_MODULES="$XORG_MODULES $DGAPROTO"
- PKG_CHECK_MODULES(DGA, $DGAPROTO)
- AC_DEFINE(DGA, 1, [Support DGA extension])
- AC_DEFINE(XFreeXDGA, 1, [Build XDGA support])
- fi
-
- if test "x$XF86VIDMODE" = xauto; then
- PKG_CHECK_MODULES(XF86VIDMODE, $VIDMODEPROTO, [XF86VIDMODE=yes], [XF86VIDMODE=no])
- fi
- if test "x$XF86VIDMODE" = xyes; then
- XORG_MODULES="$XORG_MODULES $VIDMODEPROTO"
- PKG_CHECK_MODULES(XF86VIDMODE, $VIDMODEPROTO)
- AC_DEFINE(XF86VIDMODE, 1, [Support XFree86 Video Mode extension])
- fi
-
- if test -n "$XORG_MODULES"; then
- PKG_CHECK_MODULES(XORG_MODULES, [$XORG_MODULES])
- XORG_CFLAGS="$XORG_CFLAGS $XORG_MODULES_CFLAGS"
- XORG_SYS_LIBS="$XORG_SYS_LIBS $XORG_MODULES_LIBS"
- fi
-
- AC_SUBST([XORG_LIBS])
- AC_SUBST([XORG_SYS_LIBS])
- AC_SUBST([XORG_INCS])
- AC_SUBST([XORG_OS])
- AC_SUBST([XORG_OS_SUBDIR])
-
- AC_PATH_PROG(PERL, perl, no)
- dnl unlikely as this may be ...
- if test "x$PERL" = xno; then
- AC_MSG_ERROR([Perl is required to build the XFree86/Xorg DDX.])
- fi
- AC_SUBST(PERL)
-
- AC_SUBST([XORG_CFLAGS])
-
- dnl these only go in xorg-config.h
- XF86CONFIGFILE="xorg.conf"
- XF86CONFIGDIR="xorg.conf.d"
- AC_SUBST(XF86CONFIGDIR)
- CONFIGFILE="$sysconfdir/$XF86CONFIGFILE"
- LOGPREFIX="$logdir/Xorg."
- AC_DEFINE(XORG_SERVER, 1, [Building Xorg server])
- AC_DEFINE(XORGSERVER, 1, [Building Xorg server])
- AC_DEFINE(XFree86Server, 1, [Building XFree86 server])
- AC_DEFINE(XFree86LOADER, 1, [Building loadable XFree86 server])
- AC_DEFINE_UNQUOTED(XORG_VERSION_CURRENT, [$VENDOR_RELEASE], [Current Xorg version])
- AC_DEFINE(NEED_XF86_TYPES, 1, [Need XFree86 typedefs])
- AC_DEFINE(NEED_XF86_PROTOTYPES, 1, [Need XFree86 helper functions])
- AC_DEFINE(__XSERVERNAME__, "Xorg", [Name of X server])
- AC_DEFINE_DIR(__XCONFIGFILE__, XF86CONFIGFILE, [Name of configuration file])
- AC_DEFINE_DIR(XF86CONFIGFILE, XF86CONFIGFILE, [Name of configuration file])
- AC_DEFINE_DIR(__XCONFIGDIR__, XF86CONFIGDIR, [Name of configuration directory])
- AC_DEFINE_DIR(DEFAULT_MODULE_PATH, moduledir, [Default module search path])
- AC_DEFINE_DIR(DEFAULT_LIBRARY_PATH, libdir, [Default library install path])
- AC_DEFINE_DIR(DEFAULT_LOGPREFIX, LOGPREFIX, [Default log location])
- AC_DEFINE_UNQUOTED(__VENDORDWEBSUPPORT__, ["$VENDOR_WEB"], [Vendor web address for support])
- AC_DEFINE(XSERVER_LIBPCIACCESS, 1, [Use libpciaccess for all pci manipulation])
- if test "x$VGAHW" = xyes; then
- AC_DEFINE(WITH_VGAHW, 1, [Building vgahw module])
- fi
-
- driverdir="$moduledir/drivers"
- AC_SUBST([moduledir])
- AC_SUBST([driverdir])
- sdkdir="$includedir/xorg"
- extdir="$includedir/X11/extensions"
- sysconfigdir="$datadir/X11/$XF86CONFIGDIR"
- AC_SUBST([sdkdir])
- AC_SUBST([extdir])
- AC_SUBST([sysconfigdir])
- AC_SUBST([logdir])
-
- # stuff the ABI versions into the pc file too
- extract_abi() {
- grep ^.define.*${1}_VERSION ${srcdir}/hw/xfree86/common/xf86Module.h | tr '(),' ' .' | awk '{ print $4$5 }'
- }
- abi_ansic=`extract_abi ANSIC`
- abi_videodrv=`extract_abi VIDEODRV`
- abi_xinput=`extract_abi XINPUT`
- abi_extension=`extract_abi EXTENSION`
- AC_SUBST([abi_ansic])
- AC_SUBST([abi_videodrv])
- AC_SUBST([abi_xinput])
- AC_SUBST([abi_extension])
-fi
-AM_CONDITIONAL([XORG], [test "x$XORG" = xyes])
-AM_CONDITIONAL([XORG_BUS_LINUXPCI], [test "x$xorg_bus_linuxpci" = xyes])
-AM_CONDITIONAL([XORG_BUS_BSDPCI], [test "x$xorg_bus_bsdpci" = xyes])
-AM_CONDITIONAL([XORG_BUS_SPARC], [test "x$xorg_bus_sparc" = xyes])
-AM_CONDITIONAL([LINUX_IA64], [test "x$linux_ia64" = xyes])
-AM_CONDITIONAL([LINUX_ALPHA], [test "x$linux_alpha" = xyes])
-AM_CONDITIONAL([LNXACPI], [test "x$linux_acpi" = xyes])
-AM_CONDITIONAL([SOLARIS_ASM_INLINE], [test "x$solaris_asm_inline" = xyes])
-AM_CONDITIONAL([SOLARIS_VT], [test "x$solaris_vt" = xyes])
-AM_CONDITIONAL([DGA], [test "x$DGA" = xyes])
-AM_CONDITIONAL([XF86VIDMODE], [test "x$XF86VIDMODE" = xyes])
-
-dnl XWin DDX
-
-AC_MSG_CHECKING([whether to build XWin DDX])
-if test "x$XWIN" = xauto; then
- case $host_os in
- cygwin*) XWIN="yes" ;;
- mingw*) XWIN="yes" ;;
- *) XWIN="no" ;;
- esac
-fi
-AC_MSG_RESULT([$XWIN])
-
-if test "x$XWIN" = xyes; then
- AC_DEFINE_DIR(SYSCONFDIR, sysconfdir, [Location of system.XWinrc])
- AC_DEFINE_DIR(DEFAULT_LOGDIR, logdir, [Default log location])
- AC_DEFINE_UNQUOTED(XORG_VERSION_CURRENT, [$VENDOR_RELEASE], [Current Xorg version])
- AC_DEFINE_UNQUOTED(__VENDORDWEBSUPPORT__, ["$VENDOR_WEB"], [Vendor web address for support])
- AC_CHECK_TOOL(WINDRES, windres)
-
- PKG_CHECK_MODULES([XWINMODULES],[x11 xdmcp xau])
-
- if test "x$WINDOWSWM" = xauto; then
- PKG_CHECK_EXISTS($WINDOWSWMPROTO, [WINDOWSWM=yes], [WINDOWSWM=no])
- fi
- if test "x$WINDOWSWM" = xyes ; then
- PKG_CHECK_MODULES(WINDOWSWM, $WINDOWSWMPROTO)
- XWINMODULES_CFLAGS="$XWINMODULES_CFLAGS $WINDOWSWM_CFLAGS"
- AC_DEFINE(ROOTLESS,1,[Build Rootless code])
- fi
-
- case $host_os in
- cygwin*)
- XWIN_SERVER_NAME=XWin
- AC_DEFINE(HAS_DEVWINDOWS,1,[Cygwin has /dev/windows for signaling new win32 messages])
- ;;
- mingw*)
- XWIN_SERVER_NAME=Xming
- AC_DEFINE(RELOCATE_PROJECTROOT,1,[Make PROJECT_ROOT relative to the xserver location])
- AC_DEFINE(HAS_WINSOCK,1,[Use Windows sockets])
- XWIN_SYS_LIBS=-lwinsock2
- ;;
- esac
- XWIN_LIBS="$FB_LIB $MI_LIB $FIXES_LIB $XEXT_LIB $RANDR_LIB $RENDER_LIB $DBE_LIB $RECORD_LIB $GLX_LIBS $XKB_LIB $XKB_STUB_LIB $COMPOSITE_LIB $DAMAGE_LIB $MIEXT_SYNC_LIB $MIEXT_DAMAGE_LIB $MIEXT_SHADOW_LIB $XI_LIB $OS_LIB"
- XWIN_SYS_LIBS="$XWIN_SYS_LIBS $XWINMODULES_LIBS"
- AC_SUBST(XWIN_LIBS)
- AC_SUBST(XWIN_SERVER_NAME)
- AC_SUBST(XWIN_SYS_LIBS)
-
- if test "x$DEBUGGING" = xyes; then
- AC_DEFINE(CYGDEBUG, 1, [Simple debug messages])
- AC_DEFINE(CYGWINDOWING_DEBUG, 1, [Debug messages for window handling])
- AC_DEFINE(CYGMULTIWINDOW_DEBUG, 1, [Debug window manager])
- fi
-
- AC_DEFINE(DDXOSVERRORF, 1, [Use OsVendorVErrorF])
- AC_DEFINE(DDXBEFORERESET, 1, [Use ddxBeforeReset ])
-
-dnl XWin with AIGLX requires OpenGL spec files in order to generate wrapper code for native GL functions
- if [test "x$XWIN" = xyes && test "x$AIGLX" = xyes] ; then
- if test "x$KHRONOS_SPEC_DIR" = "xauto" ; then
- PKG_CHECK_MODULES([KHRONOS_OPENGL_REGISTRY], [khronos-opengl-registry])
- KHRONOS_SPEC_DIR=`pkg-config khronos-opengl-registry --variable=specdir`
- fi
- AC_SUBST(KHRONOS_SPEC_DIR)
- fi
-
-fi
-AM_CONDITIONAL(XWIN, [test "x$XWIN" = xyes])
-AM_CONDITIONAL(XWIN_MULTIWINDOW, [test "x$XWIN" = xyes])
-AM_CONDITIONAL(XWIN_MULTIWINDOWEXTWM, [test "x$XWIN" = xyes && test "x$WINDOWSWM" = xyes])
-AM_CONDITIONAL(XWIN_CLIPBOARD, [test "x$XWIN" = xyes])
-AM_CONDITIONAL(XWIN_GLX_WINDOWS, [test "x$XWIN" = xyes && test "x$AIGLX" = xyes])
-AM_CONDITIONAL(XWIN_NATIVEGDI, [test "x$XWIN" = xyes])
-AM_CONDITIONAL(XWIN_PRIMARYFB, [test "x$XWIN" = xyes])
-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" = xyes; then
- AC_DEFINE(XQUARTZ,1,[Have Quartz])
- AC_DEFINE(ROOTLESS,1,[Build Rootless code])
-
- DARWIN_LIBS="$MI_LIB $OS_LIB $DIX_LIB $MAIN_LIB $FB_LIB $FIXES_LIB $XEXT_LIB $DBE_LIB $RECORD_LIB $RANDR_LIB $RENDER_LIB $DAMAGE_LIB $MIEXT_SYNC_LIB $MIEXT_DAMAGE_LIB $MIEXT_SHADOW_LIB $XI_LIB $XKB_LIB $XKB_STUB_LIB $XPSTUBS_LIB"
- AC_SUBST([DARWIN_LIBS])
-
- AC_CHECK_LIB([Xplugin],[xp_init],[:])
-
- CFLAGS="${CFLAGS} -DROOTLESS_WORKAROUND -DROOTLESS_SAFEALPHA -DNO_ALLOCA"
-
- PKG_CHECK_MODULES(XPBPROXY, $APPLEWMPROTO $LIBAPPLEWM xfixes x11)
-
- if test "x$XQUARTZ_SPARKLE" = xyes ; then
- AC_DEFINE(XQUARTZ_SPARKLE,1,[Support application updating through sparkle.])
- fi
-
- if test "x$STANDALONE_XPBPROXY" = xyes ; then
- AC_DEFINE(STANDALONE_XPBPROXY,1,[Build a standalone xpbproxy])
- fi
-fi
-
-# Support for objc in autotools is minimal and not documented.
-OBJC='$(CC)'
-OBJCLD='$(CCLD)'
-OBJCLINK='$(LINK)'
-OBJCFLAGS='$(CFLAGS)'
-AC_SUBST([OBJC])
-AC_SUBST([OBJCCLD])
-AC_SUBST([OBJCLINK])
-AC_SUBST([OBJCFLAGS])
-# internal, undocumented automake func follows :(
-_AM_DEPENDENCIES([OBJC])
-AM_CONDITIONAL(XQUARTZ, [test "x$XQUARTZ" = xyes])
-AM_CONDITIONAL(XQUARTZ_SPARKLE, [test "x$XQUARTZ_SPARKLE" != "xno"])
-AM_CONDITIONAL(STANDALONE_XPBPROXY, [test "x$STANDALONE_XPBPROXY" = xyes])
-
-dnl DMX DDX
-PKG_CHECK_MODULES(
- [DMXMODULES],
- [xmuu $LIBXEXT x11 xrender xfixes $LIBXI $DMXPROTO xau $XDMCP_MODULES],
- [PKG_CHECK_MODULES(
- [XDMXCONFIG_DEP],
- [xaw7 xmu xt xpm x11],
- [have_dmx=yes],
- [have_dmx=no])],
- [have_dmx=no])
-AC_MSG_CHECKING([whether to build Xdmx DDX])
-if test "x$DMX" = xauto; then
- DMX="$have_dmx"
- case $host_os in
- cygwin*) DMX="no" ;;
- darwin*) DMX="no" ;;
- esac
-fi
-AC_MSG_RESULT([$DMX])
-AM_CONDITIONAL(DMX, [test "x$DMX" = xyes])
-
-if test "x$DMX" = xyes; then
- if test "x$have_dmx" = xno; then
- AC_MSG_ERROR([Xdmx build explicitly requested, but required
- modules not found.])
- fi
- DMX_INCLUDES="$XEXT_INC $RENDER_INC $RECORD_INC"
- XDMX_CFLAGS="$DMXMODULES_CFLAGS"
- XDMX_LIBS="$FB_LIB $MI_LIB $XEXT_LIB $RENDER_LIB $RECORD_LIB $XI_LIB $XKB_LIB $XKB_STUB_LIB $MIEXT_SYNC_LIB $MIEXT_SHADOW_LIB $MIEXT_DAMAGE_LIB $COMPOSITE_LIB $DAMAGE_LIB $MAIN_LIB $DIX_LIB $CONFIG_LIB $OS_LIB $FIXES_LIB"
- XDMX_SYS_LIBS="$DMXMODULES_LIBS"
- AC_SUBST([XDMX_CFLAGS])
- AC_SUBST([XDMX_LIBS])
- AC_SUBST([XDMX_SYS_LIBS])
-
-dnl USB sources in DMX require <linux/input.h>
- AC_CHECK_HEADER([linux/input.h], DMX_BUILD_USB="yes",
- DMX_BUILD_USB="no")
-dnl Linux sources in DMX require <linux/keyboard.h>
- AC_CHECK_HEADER([linux/keyboard.h], DMX_BUILD_LNX="yes",
- DMX_BUILD_LNX="no")
- AC_SUBST(XDMXCONFIG_DEP_CFLAGS)
- AC_SUBST(XDMXCONFIG_DEP_LIBS)
- PKG_CHECK_MODULES([DMXEXAMPLES_DEP], [$LIBDMX $LIBXEXT x11])
- AC_SUBST(DMXEXAMPLES_DEP_LIBS)
- PKG_CHECK_MODULES([DMXXMUEXAMPLES_DEP], [$LIBDMX xmu $LIBXEXT x11])
- AC_SUBST(DMXXMUEXAMPLES_DEP_LIBS)
- PKG_CHECK_MODULES([DMXXIEXAMPLES_DEP], [$LIBDMX $LIBXI $LIBXEXT x11])
- AC_SUBST(DMXXIEXAMPLES_DEP_LIBS)
- PKG_CHECK_MODULES([XTSTEXAMPLES_DEP], [$LIBXTST $LIBXEXT x11])
- AC_SUBST(XTSTEXAMPLES_DEP_LIBS)
- PKG_CHECK_MODULES([XRESEXAMPLES_DEP], [xres $LIBXEXT x11])
- AC_SUBST(XRESEXAMPLES_DEP_LIBS)
- PKG_CHECK_MODULES([X11EXAMPLES_DEP], [$LIBXEXT x11])
- AC_SUBST(X11EXAMPLES_DEP_LIBS)
-
-fi
-AM_CONDITIONAL([DMX_BUILD_LNX], [test "x$DMX_BUILD_LNX" = xyes])
-AM_CONDITIONAL([DMX_BUILD_USB], [test "x$DMX_BUILD_USB" = xyes])
-
-dnl kdrive DDX
-
-XEPHYR_LIBS=
-XEPHYR_INCS=
-
-AM_CONDITIONAL(KDRIVE, [test x$KDRIVE = xyes])
-
-if test "$KDRIVE" = yes; then
- AC_DEFINE(KDRIVESERVER,1,[Build Kdrive X server])
- AC_DEFINE(KDRIVEDDXACTIONS,,[Build kdrive ddx])
-
- AC_CHECK_HEADERS([linux/fb.h])
- if test "$ac_cv_header_linux_fb_h" = yes && test "x$XFBDEV" = xauto; then
- XFBDEV=yes
- fi
-
- if test "x$XFBDEV" = xyes; then
- KDRIVEFBDEVLIB=yes
- AC_DEFINE(KDRIVEFBDEV, 1, [Build fbdev-based kdrive server])
- fi
-
-
- PKG_CHECK_MODULES([TSLIB], [tslib-0.0], [HAVE_TSLIB="yes"], [HAVE_TSLIB="no"])
- if test "x$HAVE_TSLIB" = xno; then
- AC_CHECK_LIB(ts, ts_open, [
- HAVE_TSLIB="yes"
- TSLIB_LIBS="-lts"
- ])
- fi
-
- if test "xTSLIB" = xauto; then
- TSLIB="$HAVE_TSLIB"
- fi
-
- if test "x$TSLIB" = xyes; then
- if ! test "x$HAVE_TSLIB" = xyes; then
- AC_MSG_ERROR([tslib must be installed to build the tslib driver. See http://tslib.berlios.de/])
- else
- AC_DEFINE(TSLIB, 1, [Have tslib support])
- fi
- fi
-
- if test "x$KDRIVE_KBD" = xyes; then
- AC_DEFINE(KDRIVE_KBD, 1, [Enable KDrive kbd driver])
- fi
- if test "x$KDRIVE_EVDEV" = xyes; then
- AC_DEFINE(KDRIVE_EVDEV, 1, [Enable KDrive evdev driver])
- fi
- if test "x$KDRIVE_MOUSE" = xyes; then
- AC_DEFINE(KDRIVE_MOUSE, 1, [Enable KDrive mouse driver])
- fi
-
- XEPHYR_REQUIRED_LIBS="x11 $LIBXEXT xau xdmcp"
- 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 $LIBGL libdrm"
- fi
-
- PKG_CHECK_MODULES(XEPHYR, $XEPHYR_REQUIRED_LIBS, [xephyr="yes"], [xephyr="no"])
- if test "x$XEPHYR" = xauto; then
- XEPHYR=$xephyr
- fi
- if test "x$XEPHYR" = xyes && test "x$xephyr" = xno; then
- AC_MSG_ERROR([Xephyr dependencies missing])
- fi
-
- # Xephyr needs nanosleep() which is in librt on Solaris
- AC_CHECK_FUNC([nanosleep], [],
- AC_CHECK_LIB([rt], [nanosleep], XEPHYR_LIBS="$XEPHYR_LIBS -lrt"))
-
- # damage shadow extension glx (NOTYET) fb mi
- KDRIVE_INC='-I$(top_srcdir)/hw/kdrive/src'
- KDRIVE_PURE_INCS="$KDRIVE_INC $MIEXT_SYNC_INC $MIEXT_DAMAGE_INC $MIEXT_SHADOW_INC $XEXT_INC $FB_INC $MI_INC"
- KDRIVE_OS_INC='-I$(top_srcdir)/hw/kdrive/linux'
- KDRIVE_INCS="$KDRIVE_PURE_INCS $KDRIVE_OS_INC"
-
- KDRIVE_CFLAGS="$XSERVER_CFLAGS -DHAVE_KDRIVE_CONFIG_H $TSLIB_CFLAGS"
-
- KDRIVE_PURE_LIBS="$FB_LIB $MI_LIB $FIXES_LIB $XEXT_LIB $DBE_LIB $RECORD_LIB $GLX_LIBS $RANDR_LIB $RENDER_LIB $DAMAGE_LIB $MIEXT_SYNC_LIB $MIEXT_DAMAGE_LIB $MIEXT_SHADOW_LIB $XI_LIB $XKB_LIB $XKB_STUB_LIB $COMPOSITE_LIB $OS_LIB"
- KDRIVE_LIB='$(top_builddir)/hw/kdrive/src/libkdrive.la'
- case $host_os in
- *linux*)
- KDRIVE_OS_LIB='$(top_builddir)/hw/kdrive/linux/liblinux.la'
- KDRIVELINUX=yes
- if test "x$KDRIVE_EVDEV" = xauto; then
- KDRIVE_EVDEV=yes
- fi
- if test "x$KDRIVE_KBD" = xauto; then
- KDRIVE_KBD=yes
- fi
- if test "x$KDRIVE_MOUSE" = xauto; then
- KDRIVE_MOUSE=yes
- fi
- ;;
- *)
- if test "x$KDRIVE_EVDEV" = xauto; then
- KDRIVE_EVDEV=no
- fi
- if test "x$KDRIVE_KBD" = xauto; then
- KDRIVE_KBD=no
- fi
- if test "x$KDRIVE_MOUSE" = xauto; then
- KDRIVE_MOUSE=no
- fi
- ;;
- esac
- KDRIVE_STUB_LIB='$(top_builddir)/hw/kdrive/src/libkdrivestubs.la'
- KDRIVE_LOCAL_LIBS="$MAIN_LIB $DIX_LIB $KDRIVE_LIB $KDRIVE_STUB_LIB"
- KDRIVE_LOCAL_LIBS="$KDRIVE_LOCAL_LIBS $FB_LIB $MI_LIB $KDRIVE_PURE_LIBS"
- KDRIVE_LOCAL_LIBS="$KDRIVE_LOCAL_LIBS $KDRIVE_OS_LIB"
- KDRIVE_LIBS="$KDRIVE_LOCAL_LIBS $XSERVER_SYS_LIBS $GLX_SYS_LIBS $DLOPEN_LIBS $TSLIB_LIBS"
-
- AC_SUBST([XEPHYR_LIBS])
- AC_SUBST([XEPHYR_INCS])
-fi
-AC_SUBST([KDRIVE_INCS])
-AC_SUBST([KDRIVE_PURE_INCS])
-AC_SUBST([KDRIVE_CFLAGS])
-AC_SUBST([KDRIVE_PURE_LIBS])
-AC_SUBST([KDRIVE_LOCAL_LIBS])
-AC_SUBST([KDRIVE_LIBS])
-AM_CONDITIONAL(KDRIVELINUX, [test "x$KDRIVELINUX" = xyes])
-AM_CONDITIONAL(KDRIVE_EVDEV, [test "x$KDRIVE_EVDEV" = xyes])
-AM_CONDITIONAL(KDRIVE_KBD, [test "x$KDRIVE_KBD" = xyes])
-AM_CONDITIONAL(KDRIVE_MOUSE, [test "x$KDRIVE_MOUSE" = xyes])
-AM_CONDITIONAL(TSLIB, [test "x$HAVE_TSLIB" = xyes])
-AM_CONDITIONAL(KDRIVEFBDEV, [test "x$XFBDEV" = 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(XFAKESERVER, [test "x$KDRIVE" = xyes && test "x$XFAKE" = xyes])
-
-dnl and the rest of these are generic, so they're in config.h
-dnl
-dnl though, thanks to the passing of some significant amount of time, the
-dnl above is probably a complete fallacy, and you should not rely on it.
-dnl but this is still actually better than imake, honest. -daniels
-
-AC_TRY_COMPILE([
-#include <features.h>
-#ifndef __GLIBC__
-#error not glibc
-#endif
-], [], [AC_DEFINE(_GNU_SOURCE, 1,
- [ Enable GNU and other extensions to the C environment for glibc])])
-
-AC_DEFINE_DIR(PROJECTROOT, prefix, [Overall prefix])
-
-AC_SUBST([RELEASE_DATE])
-BUILD_DATE="`date +'%Y%m%d'`"
-AC_SUBST([BUILD_DATE])
-BUILD_TIME="`date +'1%H%M%S'`"
-AC_SUBST([BUILD_TIME])
-
-DIX_CFLAGS="-DHAVE_DIX_CONFIG_H $XSERVER_CFLAGS"
-
-AC_SUBST([DIX_CFLAGS])
-
-AC_SUBST([libdir])
-AC_SUBST([exec_prefix])
-AC_SUBST([prefix])
-
-AC_CONFIG_COMMANDS([sdksyms], [touch hw/xfree86/loader/sdksyms.dep])
-
-AC_OUTPUT([
-Makefile
-glx/Makefile
-include/Makefile
-composite/Makefile
-damageext/Makefile
-dbe/Makefile
-dix/Makefile
-doc/Makefile
-doc/man/Makefile
-doc/xml/Makefile
-doc/xml/dtrace/Makefile
-doc/xml/xserver.ent
-fb/Makefile
-record/Makefile
-config/Makefile
-mi/Makefile
-miext/Makefile
-miext/sync/Makefile
-miext/damage/Makefile
-miext/shadow/Makefile
-miext/cw/Makefile
-miext/rootless/Makefile
-os/Makefile
-randr/Makefile
-render/Makefile
-xkb/Makefile
-Xext/Makefile
-Xi/Makefile
-xfixes/Makefile
-exa/Makefile
-hw/Makefile
-hw/xfree86/Makefile
-hw/xfree86/common/Makefile
-hw/xfree86/common/xf86Build.h
-hw/xfree86/ddc/Makefile
-hw/xfree86/dixmods/Makefile
-hw/xfree86/dixmods/extmod/Makefile
-hw/xfree86/doc/Makefile
-hw/xfree86/doc/devel/Makefile
-hw/xfree86/doc/sgml/Makefile
-hw/xfree86/dri/Makefile
-hw/xfree86/dri2/Makefile
-hw/xfree86/exa/Makefile
-hw/xfree86/exa/man/Makefile
-hw/xfree86/fbdevhw/Makefile
-hw/xfree86/fbdevhw/man/Makefile
-hw/xfree86/i2c/Makefile
-hw/xfree86/int10/Makefile
-hw/xfree86/loader/Makefile
-hw/xfree86/man/Makefile
-hw/xfree86/modes/Makefile
-hw/xfree86/os-support/Makefile
-hw/xfree86/os-support/bsd/Makefile
-hw/xfree86/os-support/bus/Makefile
-hw/xfree86/os-support/hurd/Makefile
-hw/xfree86/os-support/misc/Makefile
-hw/xfree86/os-support/linux/Makefile
-hw/xfree86/os-support/solaris/Makefile
-hw/xfree86/parser/Makefile
-hw/xfree86/ramdac/Makefile
-hw/xfree86/shadowfb/Makefile
-hw/xfree86/vbe/Makefile
-hw/xfree86/vgahw/Makefile
-hw/xfree86/x86emu/Makefile
-hw/xfree86/xaa/Makefile
-hw/xfree86/utils/Makefile
-hw/xfree86/utils/man/Makefile
-hw/xfree86/utils/cvt/Makefile
-hw/xfree86/utils/gtf/Makefile
-hw/dmx/config/Makefile
-hw/dmx/config/man/Makefile
-hw/dmx/doc/Makefile
-hw/dmx/doc/doxygen.conf
-hw/dmx/examples/Makefile
-hw/dmx/input/Makefile
-hw/dmx/glxProxy/Makefile
-hw/dmx/Makefile
-hw/dmx/man/Makefile
-hw/vfb/Makefile
-hw/vfb/man/Makefile
-hw/xnest/Makefile
-hw/xnest/man/Makefile
-hw/xwin/Makefile
-hw/xwin/glx/Makefile
-hw/xwin/man/Makefile
-hw/xquartz/Makefile
-hw/xquartz/GL/Makefile
-hw/xquartz/bundle/Makefile
-hw/xquartz/man/Makefile
-hw/xquartz/mach-startup/Makefile
-hw/xquartz/pbproxy/Makefile
-hw/xquartz/xpr/Makefile
-hw/kdrive/Makefile
-hw/kdrive/ephyr/Makefile
-hw/kdrive/ephyr/man/Makefile
-hw/kdrive/fake/Makefile
-hw/kdrive/fbdev/Makefile
-hw/kdrive/linux/Makefile
-hw/kdrive/src/Makefile
-test/Makefile
-test/xi2/Makefile
-xorg-server.pc
-])
+dnl Copyright © 2003-2007 Keith Packard, Daniel Stone
+dnl
+dnl Permission is hereby granted, free of charge, to any person obtaining a
+dnl copy of this software and associated documentation files (the "Software"),
+dnl to deal in the Software without restriction, including without limitation
+dnl the rights to use, copy, modify, merge, publish, distribute, sublicense,
+dnl and/or sell copies of the Software, and to permit persons to whom the
+dnl Software is furnished to do so, subject to the following conditions:
+dnl
+dnl The above copyright notice and this permission notice (including the next
+dnl paragraph) shall be included in all copies or substantial portions of the
+dnl Software.
+dnl
+dnl THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+dnl IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+dnl FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+dnl THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+dnl LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+dnl FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+dnl DEALINGS IN THE SOFTWARE.
+dnl
+dnl Authors: Keith Packard <keithp@keithp.com>
+dnl Daniel Stone <daniel@fooishbar.org>
+dnl an unwitting cast of miscellaneous others
+dnl
+dnl Process this file with autoconf to create configure.
+
+AC_PREREQ(2.57)
+AC_INIT([xorg-server], 1.10.99.1, [https://bugs.freedesktop.org/enter_bug.cgi?product=xorg], xorg-server)
+RELEASE_DATE="unreleased"
+AC_CONFIG_SRCDIR([Makefile.am])
+AM_INIT_AUTOMAKE([foreign dist-bzip2])
+AM_MAINTAINER_MODE
+
+# Require xorg-macros minimum of 1.13 for XORG_ENABLE_UNIT_TESTS
+m4_ifndef([XORG_MACROS_VERSION],
+ [m4_fatal([must install xorg-macros 1.13 or later before running autoconf/autogen])])
+XORG_MACROS_VERSION(1.13)
+XORG_DEFAULT_OPTIONS
+XORG_WITH_DOXYGEN(1.6.1)
+XORG_CHECK_SGML_DOCTOOLS(1.7)
+XORG_ENABLE_DOCS
+XORG_ENABLE_DEVEL_DOCS
+XORG_WITH_XMLTO(0.0.20)
+XORG_WITH_FOP
+XORG_WITH_XSLTPROC
+XORG_ENABLE_UNIT_TESTS
+XORG_LD_WRAP
+
+m4_ifndef([XORG_FONT_MACROS_VERSION], [m4_fatal([must install fontutil 1.1 or later before running autoconf/autogen])])
+XORG_FONT_MACROS_VERSION(1.1)
+
+dnl this gets generated by autoheader, and thus contains all the defines. we
+dnl don't ever actually use it, internally.
+AC_CONFIG_HEADERS(include/do-not-use-config.h)
+dnl xorg-server.h is an external header, designed to be included by loadable
+dnl drivers.
+AC_CONFIG_HEADERS(include/xorg-server.h)
+dnl dix-config.h covers most of the DIX (i.e. everything but the DDX, not just
+dnl dix/).
+AC_CONFIG_HEADERS(include/dix-config.h)
+dnl xorg-config.h covers the Xorg DDX.
+AC_CONFIG_HEADERS(include/xorg-config.h)
+dnl xkb-config.h covers XKB for the Xorg and Xnest DDXs.
+AC_CONFIG_HEADERS(include/xkb-config.h)
+dnl xwin-config.h covers the XWin DDX.
+AC_CONFIG_HEADERS(include/xwin-config.h)
+dnl kdrive-config.h covers the kdrive DDX
+AC_CONFIG_HEADERS(include/kdrive-config.h)
+dnl version-config.h covers the version numbers so they can be bumped without
+dnl forcing an entire recompile.x
+AC_CONFIG_HEADERS(include/version-config.h)
+
+AM_PROG_AS
+AC_PROG_LN_S
+AC_LIBTOOL_WIN32_DLL
+AC_DISABLE_STATIC
+AC_PROG_LIBTOOL
+AC_PROG_MAKE_SET
+PKG_PROG_PKG_CONFIG
+AC_PROG_LEX
+AC_PROG_YACC
+AC_SYS_LARGEFILE
+XORG_PROG_RAWCPP
+
+# Quoted so that make will expand $(CWARNFLAGS) in makefiles to allow
+# easier overrides at build time.
+XSERVER_CFLAGS='$(CWARNFLAGS)'
+
+dnl Check for dtrace program (needed to build Xserver dtrace probes)
+dnl Also checks for <sys/sdt.h>, since some Linux distros have an
+dnl ISDN trace program named dtrace
+AC_ARG_WITH(dtrace, AS_HELP_STRING([--with-dtrace=PATH],
+ [Enable dtrace probes (default: enabled if dtrace found)]),
+ [WDTRACE=$withval], [WDTRACE=auto])
+if test "x$WDTRACE" = "xyes" -o "x$WDTRACE" = "xauto" ; then
+ AC_PATH_PROG(DTRACE, [dtrace], [not_found], [$PATH:/usr/sbin])
+ if test "x$DTRACE" = "xnot_found" ; then
+ if test "x$WDTRACE" = "xyes" ; then
+ AC_MSG_FAILURE([dtrace requested but not found])
+ fi
+ WDTRACE="no"
+ else
+ AC_CHECK_HEADER(sys/sdt.h, [HAS_SDT_H="yes"], [HAS_SDT_H="no"])
+ if test "x$WDTRACE" = "xauto" -a "x$HAS_SDT_H" = "xno" ; then
+ WDTRACE="no"
+ fi
+ fi
+fi
+if test "x$WDTRACE" != "xno" ; then
+ AC_DEFINE(XSERVER_DTRACE, 1,
+ [Define to 1 if the DTrace Xserver provider probes should be built in.])
+
+# Solaris/OpenSolaris require dtrace -G to build dtrace probe information into
+# object files, and require linking with those as relocatable objects, not .a
+# archives. MacOS X handles all this in the normal compiler toolchain, and on
+# some releases (like Tiger), will error out on dtrace -G. For now, other
+# platforms with Dtrace ports are assumed to support -G (the FreeBSD and Linux
+# ports appear to, based on my web searches, but have not yet been tested).
+ case $host_os in
+ darwin*) SPECIAL_DTRACE_OBJECTS=no ;;
+ *) SPECIAL_DTRACE_OBJECTS=yes ;;
+ esac
+fi
+AM_CONDITIONAL(XSERVER_DTRACE, [test "x$WDTRACE" != "xno"])
+AM_CONDITIONAL(SPECIAL_DTRACE_OBJECTS, [test "x$SPECIAL_DTRACE_OBJECTS" = "xyes"])
+
+AC_HEADER_DIRENT
+AC_HEADER_STDC
+AC_CHECK_HEADERS([fcntl.h stdlib.h string.h unistd.h dlfcn.h stropts.h fnmatch.h sys/utsname.h])
+
+dnl Checks for typedefs, structures, and compiler characteristics.
+AC_C_CONST
+AC_C_BIGENDIAN([ENDIAN="X_BIG_ENDIAN"], [ENDIAN="X_LITTLE_ENDIAN"])
+
+AC_CHECK_SIZEOF([unsigned long])
+if test "$ac_cv_sizeof_unsigned_long" = 8; then
+ AC_DEFINE(_XSERVER64, 1, [Define to 1 if unsigned long is 64 bits.])
+fi
+
+AC_TYPE_PID_T
+
+# Checks for headers/macros for byte swapping
+# Known variants:
+# <byteswap.h> bswap_16, bswap_32, bswap_64 (glibc)
+# <sys/endian.h> __swap16, __swap32, __swap64 (OpenBSD)
+# <sys/endian.h> bswap16, bswap32, bswap64 (other BSD's)
+# and a fallback to local macros if none of the above are found
+
+# if <byteswap.h> is found, assume it's the correct version
+AC_CHECK_HEADERS([byteswap.h])
+
+# if <sys/endian.h> is found, have to check which version
+AC_CHECK_HEADER([sys/endian.h], [HAVE_SYS_ENDIAN_H="yes"], [HAVE_SYS_ENDIAN_H="no"])
+
+if test "x$HAVE_SYS_ENDIAN_H" = "xyes" ; then
+ AC_MSG_CHECKING([for __swap16 variant of <sys/endian.h> byteswapping macros])
+ AC_LINK_IFELSE([AC_LANG_PROGRAM([
+#include <sys/types.h>
+#include <sys/endian.h>
+ ], [
+int a = 1, b;
+b = __swap16(a);
+ ])
+], [SYS_ENDIAN__SWAP='yes'], [SYS_ENDIAN__SWAP='no'])
+ AC_MSG_RESULT([$SYS_ENDIAN__SWAP])
+
+ AC_MSG_CHECKING([for bswap16 variant of <sys/endian.h> byteswapping macros])
+ AC_LINK_IFELSE([AC_LANG_PROGRAM([
+#include <sys/types.h>
+#include <sys/endian.h>
+ ], [
+int a = 1, b;
+b = bswap16(a);
+ ])
+], [SYS_ENDIAN_BSWAP='yes'], [SYS_ENDIAN_BSWAP='no'])
+ AC_MSG_RESULT([$SYS_ENDIAN_BSWAP])
+
+ if test "$SYS_ENDIAN_BSWAP" = "yes" ; then
+ USE_SYS_ENDIAN_H=yes
+ BSWAP=bswap
+ else
+ if test "$SYS_ENDIAN__SWAP" = "yes" ; then
+ USE_SYS_ENDIAN_H=yes
+ BSWAP=__swap
+ else
+ USE_SYS_ENDIAN_H=no
+ fi
+ fi
+
+ if test "$USE_SYS_ENDIAN_H" = "yes" ; then
+ AC_DEFINE([USE_SYS_ENDIAN_H], 1,
+ [Define to use byteswap macros from <sys/endian.h>])
+ AC_DEFINE_UNQUOTED([bswap_16], ${BSWAP}16,
+ [Define to 16-bit byteswap macro])
+ AC_DEFINE_UNQUOTED([bswap_32], ${BSWAP}32,
+ [Define to 32-bit byteswap macro])
+ AC_DEFINE_UNQUOTED([bswap_64], ${BSWAP}64,
+ [Define to 64-bit byteswap macro])
+ fi
+fi
+
+dnl Check to see if dlopen is in default libraries (like Solaris, which
+dnl has it in libc), or if libdl is needed to get it.
+AC_CHECK_FUNC([dlopen], [],
+ AC_CHECK_LIB([dl], [dlopen], DLOPEN_LIBS="-ldl"))
+AC_SUBST(DLOPEN_LIBS)
+
+dnl Checks for library functions.
+AC_FUNC_VPRINTF
+AC_CHECK_FUNCS([geteuid getuid link memmove memset mkstemp strchr strrchr \
+ strtol getopt getopt_long vsnprintf walkcontext backtrace \
+ getisax getzoneid shmctl64 strcasestr ffs vasprintf])
+AC_FUNC_ALLOCA
+dnl Old HAS_* names used in os/*.c.
+AC_CHECK_FUNC([getdtablesize],
+ AC_DEFINE(HAS_GETDTABLESIZE, 1, [Have the 'getdtablesize' function.]))
+AC_CHECK_FUNC([getifaddrs],
+ AC_DEFINE(HAS_GETIFADDRS, 1, [Have the 'getifaddrs' function.]))
+AC_CHECK_FUNC([getpeereid],
+ AC_DEFINE(HAS_GETPEEREID, 1, [Have the 'getpeereid' function.]))
+AC_CHECK_FUNC([getpeerucred],
+ AC_DEFINE(HAS_GETPEERUCRED, 1, [Have the 'getpeerucred' function.]))
+AC_CHECK_FUNC([strlcat], HAVE_STRLCAT=yes, HAVE_STRLCAT=no)
+AM_CONDITIONAL(NEED_STRLCAT, [test x$HAVE_STRLCAT = xno])
+AC_CHECK_FUNC([strlcpy], AC_DEFINE(HAS_STRLCPY, 1, [Have the 'strlcpy' function]))
+
+AM_CONDITIONAL(NEED_VSNPRINTF, [test x$HAVE_VSNPRINTF = xno])
+
+dnl Check for mmap support for Xvfb
+AC_CHECK_FUNC([mmap], AC_DEFINE(HAS_MMAP, 1, [Have the 'mmap' function.]))
+
+dnl Find the math libary
+AC_CHECK_LIB(m, sqrt)
+AC_CHECK_LIB(m, cbrt, AC_DEFINE(HAVE_CBRT, 1, [Have the 'cbrt' function]))
+
+AC_CHECK_HEADERS([ndbm.h dbm.h rpcsvc/dbm.h])
+
+dnl AGPGART headers
+AC_CHECK_HEADERS([linux/agpgart.h sys/agpio.h sys/agpgart.h], AGP=yes)
+AM_CONDITIONAL(AGP, [test "x$AGP" = xyes])
+
+dnl APM header
+AC_CHECK_HEADERS([linux/apm_bios.h], LNXAPM=yes)
+AM_CONDITIONAL(LNXAPM, [test "x$LNXAPM" = xyes])
+
+dnl fbdev header
+AC_CHECK_HEADERS([linux/fb.h], FBDEV=yes)
+AM_CONDITIONAL(FBDEVHW, [test "x$FBDEV" = xyes])
+
+dnl MTRR header
+AC_CHECK_HEADERS([asm/mtrr.h], ac_cv_asm_mtrr_h=yes)
+if test "x$ac_cv_asm_mtrr_h" = xyes; then
+ HAVE_MTRR=yes
+fi
+
+dnl BSD MTRR header
+AC_CHECK_HEADERS([sys/memrange.h], ac_cv_memrange_h=yes)
+if test "x$ac_cv_memrange_h" = xyes; then
+ HAVE_MTRR=yes
+fi
+
+if test "x$HAVE_MTRR" = xyes; then
+ AC_DEFINE(HAS_MTRR_SUPPORT, 1, [MTRR support available])
+fi
+
+dnl A NetBSD MTRR header
+AC_CHECK_HEADERS([machine/mtrr.h], ac_cv_machine_mtrr_h=yes)
+if test "x$ac_cv_machine_mtrr_h" = xyes; then
+ AC_DEFINE(HAS_MTRR_BUILTIN, 1, [Define to 1 if NetBSD built-in MTRR
+ support is available])
+fi
+
+dnl FreeBSD kldload support (sys/linker.h)
+AC_CHECK_HEADERS([sys/linker.h],
+ [ac_cv_sys_linker_h=yes],
+ [ac_cv_sys_linker_h=no],
+ [#include <sys/param.h>])
+AM_CONDITIONAL(FREEBSD_KLDLOAD, [test "x$ac_cv_sys_linker_h" = xyes])
+
+AC_CACHE_CHECK([for SYSV IPC],
+ ac_cv_sysv_ipc,
+ [AC_TRY_LINK([
+#include <sys/types.h>
+#include <sys/ipc.h>
+#include <sys/shm.h>
+],[
+{
+ int id;
+ id = shmget(IPC_PRIVATE, 512, SHM_W | SHM_R);
+ if (id < 0) return -1;
+ return shmctl(id, IPC_RMID, 0);
+}],
+ [ac_cv_sysv_ipc=yes],
+ [ac_cv_sysv_ipc=no])])
+if test "x$ac_cv_sysv_ipc" = xyes; then
+ AC_DEFINE(HAVE_SYSV_IPC, 1, [Define to 1 if SYSV IPC is available])
+fi
+
+dnl OpenBSD /dev/xf86 aperture driver
+if test -c /dev/xf86 ; then
+ AC_DEFINE(HAS_APERTURE_DRV, 1, [System has /dev/xf86 aperture driver])
+fi
+
+dnl BSD APM support
+AC_CHECK_HEADER([machine/apmvar.h],[
+ AC_CHECK_HEADER([sys/event.h],
+ ac_cv_BSD_KQUEUE_APM=yes,
+ ac_cv_BSD_APM=yes)])
+
+AM_CONDITIONAL(BSD_APM, [test "x$ac_cv_BSD_APM" = xyes])
+AM_CONDITIONAL(BSD_KQUEUE_APM, [test "x$ac_cv_BSD_KQUEUE_APM" = xyes])
+
+dnl glibc backtrace support check (hw/xfree86/common/xf86Events.c)
+AC_CHECK_HEADER([execinfo.h],[
+ AC_CHECK_LIB(c, backtrace, [
+ AC_DEFINE(HAVE_BACKTRACE, 1, [Has backtrace support])
+ AC_DEFINE(HAVE_EXECINFO_H, 1, [Have execinfo.h])
+ ])]
+)
+
+dnl ---------------------------------------------------------------------------
+dnl Bus options and CPU capabilities. Replaces logic in
+dnl hw/xfree86/os-support/bus/Makefile.am, among others.
+dnl ---------------------------------------------------------------------------
+DEFAULT_INT10="x86emu"
+
+dnl Override defaults as needed for specific platforms:
+
+case $host_cpu in
+ alpha*)
+ ALPHA_VIDEO=yes
+ case $host_os in
+ *freebsd*) SYS_LIBS=-lio ;;
+ *netbsd*) AC_DEFINE(USE_ALPHA_PIO, 1, [NetBSD PIO alpha IO]) ;;
+ esac
+ GLX_ARCH_DEFINES="-D__GLX_ALIGN64 -mieee"
+ ;;
+ arm*)
+ ARM_VIDEO=yes
+ ;;
+ i*86)
+ I386_VIDEO=yes
+ case $host_os in
+ *freebsd*) AC_DEFINE(USE_DEV_IO) ;;
+ *dragonfly*) AC_DEFINE(USE_DEV_IO) ;;
+ *netbsd*) AC_DEFINE(USE_I386_IOPL)
+ SYS_LIBS=-li386
+ ;;
+ *openbsd*) AC_DEFINE(USE_I386_IOPL)
+ SYS_LIBS=-li386
+ ;;
+ esac
+ ;;
+ powerpc*)
+ PPC_VIDEO=yes
+ case $host_os in
+ *freebsd*) DEFAULT_INT10=stub ;;
+ esac
+ ;;
+ sparc*)
+ SPARC64_VIDEO=yes
+ BSD_ARCH_SOURCES="sparc64_video.c ioperm_noop.c"
+ GLX_ARCH_DEFINES="-D__GLX_ALIGN64"
+ ;;
+ x86_64*|amd64*)
+ I386_VIDEO=yes
+ case $host_os in
+ *freebsd*) AC_DEFINE(USE_DEV_IO, 1, [BSD /dev/io]) ;;
+ *dragonfly*) AC_DEFINE(USE_DEV_IO, 1, [BSD /dev/io]) ;;
+ *netbsd*) AC_DEFINE(USE_I386_IOPL, 1, [BSD i386 iopl])
+ SYS_LIBS=-lx86_64
+ ;;
+ *openbsd*) AC_DEFINE(USE_AMD64_IOPL, 1, [BSD AMD64 iopl])
+ SYS_LIBS=-lamd64
+ ;;
+ esac
+ GLX_ARCH_DEFINES="-D__GLX_ALIGN64"
+ ;;
+ ia64*)
+ GLX_ARCH_DEFINES="-D__GLX_ALIGN64"
+ ;;
+ s390*)
+ GLX_ARCH_DEFINES="-D__GLX_ALIGN64"
+ ;;
+esac
+AC_SUBST(GLX_ARCH_DEFINES)
+
+dnl BSD *_video.c selection
+AM_CONDITIONAL(ALPHA_VIDEO, [test "x$ALPHA_VIDEO" = xyes])
+AM_CONDITIONAL(ARM_VIDEO, [test "x$ARM_VIDEO" = xyes])
+AM_CONDITIONAL(I386_VIDEO, [test "x$I386_VIDEO" = xyes])
+AM_CONDITIONAL(PPC_VIDEO, [test "x$PPC_VIDEO" = xyes])
+AM_CONDITIONAL(SPARC64_VIDEO, [test "x$SPARC64_VIDEO" = xyes])
+
+DRI=no
+USE_SIGIO_BY_DEFAULT="yes"
+dnl it would be nice to autodetect these *CONS_SUPPORTs
+case $host_os in
+ *freebsd* | *dragonfly*)
+ case $host_os in
+ kfreebsd*-gnu) ;;
+ *) AC_DEFINE(CSRG_BASED, 1, [System is BSD-like]) ;;
+ esac
+ AC_DEFINE(PCCONS_SUPPORT, 1, [System has PC console])
+ AC_DEFINE(PCVT_SUPPORT, 1, [System has PCVT console])
+ AC_DEFINE(SYSCONS_SUPPORT, 1, [System has syscons console])
+ DRI=yes
+ ;;
+ *netbsd*)
+ AC_DEFINE(CSRG_BASED, 1, [System is BSD-like])
+ AC_DEFINE(PCCONS_SUPPORT, 1, [System has PC console])
+ AC_DEFINE(PCVT_SUPPORT, 1, [System has PCVT console])
+ AC_DEFINE(WSCONS_SUPPORT, 1, [System has wscons console])
+ DRI=yes
+ ;;
+ *openbsd*)
+ AC_DEFINE(CSRG_BASED, 1, [System is BSD-like])
+ AC_DEFINE(PCVT_SUPPORT, 1, [System has PC console])
+ AC_DEFINE(WSCONS_SUPPORT, 1, [System has wscons console])
+ ;;
+ *linux*)
+ DRI=yes
+ ;;
+ *solaris*)
+ PKG_CHECK_EXISTS(libdrm, DRI=yes, DRI=no)
+ # Disable use of SIGIO by default until some system bugs are
+ # fixed - see Sun/OpenSolaris bug id 6879897
+ USE_SIGIO_BY_DEFAULT="no"
+ ;;
+ darwin*)
+ AC_DEFINE(CSRG_BASED, 1, [System is BSD-like])
+ ;;
+ cygwin*)
+ CFLAGS="$CFLAGS -DFD_SETSIZE=256"
+ ;;
+esac
+
+dnl augment XORG_RELEASE_VERSION for our snapshot number and to expose the
+dnl major number
+PVMAJOR=`echo $PACKAGE_VERSION | cut -d . -f 1`
+PVS=`echo $PACKAGE_VERSION | cut -d . -f 4 | cut -d - -f 1`
+if test "x$PVS" = "x"; then
+ PVS="0"
+fi
+
+VENDOR_RELEASE="((($PVMAJOR) * 10000000) + (($PVM) * 100000) + (($PVP) * 1000) + $PVS)"
+VENDOR_MAN_VERSION="Version ${PACKAGE_VERSION}"
+
+VENDOR_NAME="The X.Org Foundation"
+VENDOR_NAME_SHORT="X.Org"
+VENDOR_WEB="http://wiki.x.org"
+
+m4_ifdef([AS_HELP_STRING], , [m4_define([AS_HELP_STRING], m4_defn([AC_HELP_STRING]))])
+
+dnl Build options.
+AC_ARG_ENABLE(werror, AS_HELP_STRING([--enable-werror],
+ [Obsolete - use --enable-strict-compilation instead]),
+ AC_MSG_ERROR([--enable-werror has been replaced by --enable-strict-compilation]))
+
+AC_ARG_ENABLE(debug, AS_HELP_STRING([--enable-debug],
+ [Enable debugging (default: disabled)]),
+ [DEBUGGING=$enableval], [DEBUGGING=no])
+AC_ARG_ENABLE(use-sigio-by-default, AS_HELP_STRING([--enable-use-sigio-by-default]
+ [Enable SIGIO input handlers by default (default: $USE_SIGIO_BY_DEFAULT)]),
+ [USE_SIGIO_BY_DEFAULT=$enableval], [])
+AC_ARG_WITH(int10, AS_HELP_STRING([--with-int10=BACKEND], [int10 backend: vm86, x86emu or stub]),
+ [INT10="$withval"],
+ [INT10="$DEFAULT_INT10"])
+AC_ARG_WITH(vendor-name, AS_HELP_STRING([--with-vendor-name=VENDOR],
+ [Vendor string reported by the server]),
+ [ VENDOR_NAME="$withval" ], [])
+AC_ARG_WITH(vendor-name-short, AS_HELP_STRING([--with-vendor-name-short=VENDOR],
+ [Short version of vendor string reported by the server]),
+ [ VENDOR_NAME_SHORT="$withval" ], [])
+AC_ARG_WITH(vendor-web, AS_HELP_STRING([--with-vendor-web=URL],
+ [Vendor web address reported by the server]),
+ [ VENDOR_WEB="$withval" ], [])
+AC_ARG_WITH(module-dir, AS_HELP_STRING([--with-module-dir=DIR],
+ [Directory where modules are installed (default: $libdir/xorg/modules)]),
+ [ moduledir="$withval" ],
+ [ moduledir="${libdir}/xorg/modules" ])
+AC_ARG_WITH(log-dir, AS_HELP_STRING([--with-log-dir=DIR],
+ [Directory where log files are kept (default: $localstatedir/log)]),
+ [ logdir="$withval" ],
+ [ logdir="$localstatedir/log" ])
+AC_ARG_WITH(builder-addr, AS_HELP_STRING([--with-builder-addr=ADDRESS],
+ [Builder address (default: xorg@lists.freedesktop.org)]),
+ [ BUILDERADDR="$withval" ],
+ [ BUILDERADDR="xorg@lists.freedesktop.org" ])
+AC_ARG_WITH(os-name, AS_HELP_STRING([--with-os-name=OSNAME], [Name of OS (default: output of "uname -srm")]),
+ [ OSNAME="$withval" ],
+ [ OSNAME=`uname -srm` ])
+AC_ARG_WITH(os-vendor, AS_HELP_STRING([--with-os-vendor=OSVENDOR], [Name of OS vendor]),
+ [ OSVENDOR="$withval" ],
+ [ OSVENDOR="" ])
+AC_ARG_WITH(builderstring, AS_HELP_STRING([--with-builderstring=BUILDERSTRING], [Additional builder string]),
+ [ BUILDERSTRING="$withval" ]
+ [ ])
+
+dnl Determine font path
+XORG_FONTROOTDIR
+XORG_FONTSUBDIR(FONTMISCDIR, fontmiscdir, misc)
+XORG_FONTSUBDIR(FONTOTFDIR, fontotfdir, OTF)
+XORG_FONTSUBDIR(FONTTTFDIR, fontttfdir, TTF)
+XORG_FONTSUBDIR(FONTTYPE1DIR, fonttype1dir, Type1)
+XORG_FONTSUBDIR(FONT75DPIDIR, font75dpidir, 75dpi)
+XORG_FONTSUBDIR(FONT100DPIDIR, font100dpidir, 100dpi)
+
+dnl Uses --default-font-path if set, otherwise checks for /etc/X11/fontpath.d,
+dnl otherwise uses standard subdirectories of FONTROOTDIR. When cross
+dnl compiling, assume default font path uses standard FONTROOTDIR directories.
+DEFAULT_FONT_PATH="${FONTMISCDIR}/,${FONTTTFDIR}/,${FONTOTFDIR}/,${FONTTYPE1DIR}/,${FONT100DPIDIR}/,${FONT75DPIDIR}/"
+if test "$cross_compiling" != yes; then
+ AC_CHECK_FILE([${sysconfdir}/X11/fontpath.d],
+ [DEFAULT_FONT_PATH='catalogue:${sysconfdir}/X11/fontpath.d'],
+ [case $host_os in
+ darwin*) DEFAULT_FONT_PATH="${DEFAULT_FONT_PATH},/Library/Fonts,/System/Library/Fonts" ;;
+ esac])
+fi
+AC_ARG_WITH(default-font-path, AS_HELP_STRING([--with-default-font-path=PATH], [Comma separated list of font dirs]),
+ [ FONTPATH="$withval" ],
+ [ FONTPATH="${DEFAULT_FONT_PATH}" ])
+
+AC_MSG_CHECKING([for default font path])
+AC_MSG_RESULT([$FONTPATH])
+
+AC_ARG_WITH(xkb-path, AS_HELP_STRING([--with-xkb-path=PATH], [Path to XKB base dir (default: ${datadir}/X11/xkb)]),
+ [ XKBPATH="$withval" ],
+ [ XKBPATH="${datadir}/X11/xkb" ])
+AC_ARG_WITH(xkb-output, AS_HELP_STRING([--with-xkb-output=PATH], [Path to XKB output dir (default: ${datadir}/X11/xkb/compiled)]),
+ [ XKBOUTPUT="$withval" ],
+ [ XKBOUTPUT="compiled" ])
+AC_ARG_WITH(default-xkb-rules, AS_HELP_STRING([--with-default-xkb-rules=RULES],
+ [Keyboard ruleset (default: base/evdev)]),
+ [ XKB_DFLT_RULES="$withval" ],
+ [ XKB_DFLT_RULES="" ])
+AC_ARG_WITH(default-xkb-model, AS_HELP_STRING([--with-default-xkb-model=MODEL],
+ [Keyboard model (default: pc105)]),
+ [ XKB_DFLT_MODEL="$withval" ],
+ [ XKB_DFLT_MODEL="pc105" ])
+AC_ARG_WITH(default-xkb-layout, AS_HELP_STRING([--with-default-xkb-layout=LAYOUT],
+ [Keyboard layout (default: us)]),
+ [ XKB_DFLT_LAYOUT="$withval" ],
+ [ XKB_DFLT_LAYOUT="us" ])
+AC_ARG_WITH(default-xkb-variant, AS_HELP_STRING([--with-default-xkb-variant=VARIANT],
+ [Keyboard variant (default: (none))]),
+ [ XKB_DFLT_VARIANT="$withval" ],
+ [ XKB_DFLT_VARIANT="" ])
+AC_ARG_WITH(default-xkb-options, AS_HELP_STRING([--with-default-xkb-options=OPTIONS],
+ [Keyboard layout options (default: (none))]),
+ [ XKB_DFLT_OPTIONS="$withval" ],
+ [ XKB_DFLT_OPTIONS="" ])
+AC_ARG_WITH(serverconfig-path, AS_HELP_STRING([--with-serverconfig-path=PATH],
+ [Directory where ancillary server config files are installed (default: ${libdir}/xorg)]),
+ [ SERVERCONFIG="$withval" ],
+ [ SERVERCONFIG="${libdir}/xorg" ])
+AC_ARG_WITH(apple-applications-dir,AS_HELP_STRING([--with-apple-applications-dir=PATH], [Path to the Applications directory (default: /Applications/Utilities)]),
+ [ APPLE_APPLICATIONS_DIR="${withval}" ],
+ [ APPLE_APPLICATIONS_DIR="/Applications/Utilities" ])
+AC_SUBST([APPLE_APPLICATIONS_DIR])
+AC_ARG_WITH(apple-application-name,AS_HELP_STRING([--with-apple-application-name=NAME], [Name for the .app (default: X11)]),
+ [ APPLE_APPLICATION_NAME="${withval}" ],
+ [ APPLE_APPLICATION_NAME="X11" ])
+AC_SUBST([APPLE_APPLICATION_NAME])
+AC_ARG_WITH(launchd-id-prefix, AS_HELP_STRING([--with-launchd-id-prefix=PATH], [Deprecated: Use --with-bundle-id-prefix.]),
+ [ BUNDLE_ID_PREFIX="${withval}" ],
+ [ BUNDLE_ID_PREFIX="org.x" ])
+AC_ARG_WITH(bundle-id-prefix, AS_HELP_STRING([--with-bundle-id-prefix=PATH], [Prefix to use for bundle identifiers (default: org.x)]),
+ [ BUNDLE_ID_PREFIX="${withval}" ])
+AC_SUBST([BUNDLE_ID_PREFIX])
+AC_DEFINE_UNQUOTED(BUNDLE_ID_PREFIX, "$BUNDLE_ID_PREFIX", [Prefix to use for bundle identifiers])
+AC_ARG_ENABLE(sparkle,AS_HELP_STRING([--enable-sparkle], [Enable updating of X11.app using the Sparkle Framework (default: disabled)]),
+ [ XQUARTZ_SPARKLE="${enableval}" ],
+ [ XQUARTZ_SPARKLE="no" ])
+AC_SUBST([XQUARTZ_SPARKLE])
+AC_ARG_ENABLE(install-libxf86config,
+ AS_HELP_STRING([--enable-install-libxf86config],
+ [Install libxf86config (default: disabled)]),
+ [INSTALL_LIBXF86CONFIG=$enableval],
+ [INSTALL_LIBXF86CONFIG=no])
+AC_ARG_ENABLE(visibility, AC_HELP_STRING([--enable-visibility], [Enable symbol visibility (default: auto)]),
+ [SYMBOL_VISIBILITY=$enableval],
+ [SYMBOL_VISIBILITY=auto])
+AC_ARG_ENABLE(pc98, AC_HELP_STRING([--enable-pc98], [Enable PC98 support in Xorg (default: auto)]),
+ [SUPPORT_PC98=$enableval],
+ [SUPPORT_PC98=auto])
+
+dnl GLX build options
+AC_ARG_ENABLE(aiglx, AS_HELP_STRING([--enable-aiglx], [Build accelerated indirect GLX (default: enabled)]),
+ [AIGLX=$enableval],
+ [AIGLX=yes])
+XORG_TLS
+AC_ARG_ENABLE(glx-tls, AS_HELP_STRING([--enable-glx-tls], [Build GLX with TLS support (default: auto)]),
+ [GLX_USE_TLS=$enableval
+ if test "x$GLX_USE_TLS" = "xyes" && test "${ac_cv_tls}" = "none" ; then
+ AC_MSG_ERROR([GLX with TLS support requested, but the compiler does not support it.])
+ fi],
+ [GLX_USE_TLS=no
+ if test "${ac_cv_tls}" != "none" ; then
+ GLX_USE_TLS=yes
+ fi])
+AC_SUBST(GLX_TLS, ${GLX_USE_TLS})
+AC_ARG_WITH(khronos-spec-dir, AS_HELP_STRING([--with-khronos-spec-dir=PATH], [Path to Khronos OpenGL registry database files (default: auto)]),
+ [KHRONOS_SPEC_DIR="${withval}"],
+ [KHRONOS_SPEC_DIR=auto])
+
+dnl Extensions.
+AC_ARG_ENABLE(registry, AS_HELP_STRING([--disable-registry], [Build string registry module (default: enabled)]), [XREGISTRY=$enableval], [XREGISTRY=yes])
+AC_ARG_ENABLE(composite, AS_HELP_STRING([--disable-composite], [Build Composite extension (default: enabled)]), [COMPOSITE=$enableval], [COMPOSITE=yes])
+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(record, AS_HELP_STRING([--disable-record], [Build Record extension (default: enabled)]), [RECORD=$enableval], [RECORD=yes])
+AC_ARG_ENABLE(xv, AS_HELP_STRING([--disable-xv], [Build Xv extension (default: enabled)]), [XV=$enableval], [XV=yes])
+AC_ARG_ENABLE(xvmc, AS_HELP_STRING([--disable-xvmc], [Build XvMC extension (default: enabled)]), [XVMC=$enableval], [XVMC=yes])
+AC_ARG_ENABLE(dga, AS_HELP_STRING([--disable-dga], [Build DGA extension (default: auto)]), [DGA=$enableval], [DGA=auto])
+AC_ARG_ENABLE(screensaver, AS_HELP_STRING([--disable-screensaver], [Build ScreenSaver extension (default: enabled)]), [SCREENSAVER=$enableval], [SCREENSAVER=yes])
+AC_ARG_ENABLE(xdmcp, AS_HELP_STRING([--disable-xdmcp], [Build XDMCP extension (default: auto)]), [XDMCP=$enableval], [XDMCP=auto])
+AC_ARG_ENABLE(xdm-auth-1, AS_HELP_STRING([--disable-xdm-auth-1], [Build XDM-Auth-1 extension (default: auto)]), [XDMAUTH=$enableval], [XDMAUTH=auto])
+AC_ARG_ENABLE(glx, AS_HELP_STRING([--disable-glx], [Build GLX extension (default: enabled)]), [GLX=$enableval], [GLX=yes])
+AC_ARG_ENABLE(dri, AS_HELP_STRING([--enable-dri], [Build DRI extension (default: auto)]), [DRI=$enableval])
+AC_ARG_ENABLE(dri2, AS_HELP_STRING([--enable-dri2], [Build DRI2 extension (default: auto)]), [DRI2=$enableval], [DRI2=auto])
+AC_ARG_ENABLE(xinerama, AS_HELP_STRING([--disable-xinerama], [Build Xinerama extension (default: enabled)]), [XINERAMA=$enableval], [XINERAMA=yes])
+AC_ARG_ENABLE(xf86vidmode, AS_HELP_STRING([--disable-xf86vidmode], [Build XF86VidMode extension (default: auto)]), [XF86VIDMODE=$enableval], [XF86VIDMODE=auto])
+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([--enable-xselinux], [Build SELinux extension (default: disabled)]), [XSELINUX=$enableval], [XSELINUX=no])
+AC_ARG_ENABLE(xcsecurity, AS_HELP_STRING([--enable-xcsecurity], [Build Security extension (default: disabled)]), [XCSECURITY=$enableval], [XCSECURITY=no])
+AC_ARG_ENABLE(tslib, AS_HELP_STRING([--enable-tslib], [Build kdrive tslib touchscreen support (default: disabled)]), [TSLIB=$enableval], [TSLIB=no])
+AC_ARG_ENABLE(dbe, AS_HELP_STRING([--disable-dbe], [Build DBE extension (default: enabled)]), [DBE=$enableval], [DBE=yes])
+AC_ARG_ENABLE(xf86bigfont, AS_HELP_STRING([--enable-xf86bigfont], [Build XF86 Big Font extension (default: disabled)]), [XF86BIGFONT=$enableval], [XF86BIGFONT=no])
+AC_ARG_ENABLE(dpms, AS_HELP_STRING([--disable-dpms], [Build DPMS extension (default: enabled)]), [DPMSExtension=$enableval], [DPMSExtension=yes])
+AC_ARG_ENABLE(config-udev, AS_HELP_STRING([--enable-config-udev], [Build udev support (default: auto)]), [CONFIG_UDEV=$enableval], [CONFIG_UDEV=auto])
+AC_ARG_ENABLE(config-dbus, AS_HELP_STRING([--enable-config-dbus], [Build D-BUS API support (default: no)]), [CONFIG_DBUS_API=$enableval], [CONFIG_DBUS_API=no])
+AC_ARG_ENABLE(config-hal, AS_HELP_STRING([--disable-config-hal], [Build HAL support (default: auto)]), [CONFIG_HAL=$enableval], [CONFIG_HAL=auto])
+AC_ARG_ENABLE(xfree86-utils, AS_HELP_STRING([--enable-xfree86-utils], [Build xfree86 DDX utilities (default: enabled)]), [XF86UTILS=$enableval], [XF86UTILS=yes])
+AC_ARG_ENABLE(xaa, AS_HELP_STRING([--enable-xaa], [Build XAA (default: enabled)]), [XAA=$enableval], [XAA=yes])
+AC_ARG_ENABLE(vgahw, AS_HELP_STRING([--enable-vgahw], [Build Xorg with vga access (default: enabled)]), [VGAHW=$enableval], [VGAHW=yes])
+AC_ARG_ENABLE(vbe, AS_HELP_STRING([--enable-vbe], [Build Xorg with VBE module (default: enabled)]), [VBE=$enableval], [VBE=yes])
+AC_ARG_ENABLE(int10-module, AS_HELP_STRING([--enable-int10-module], [Build Xorg with int10 module (default: enabled)]), [INT10MODULE=$enableval], [INT10MODULE=yes])
+AC_ARG_ENABLE(windowswm, AS_HELP_STRING([--enable-windowswm], [Build XWin with WindowsWM extension (default: no)]), [WINDOWSWM=$enableval], [WINDOWSWM=no])
+AC_ARG_ENABLE(libdrm, AS_HELP_STRING([--enable-libdrm], [Build Xorg with libdrm support (default: enabled)]), [DRM=$enableval],[DRM=yes])
+AC_ARG_ENABLE(clientids, AS_HELP_STRING([--disable-clientids], [Build Xorg with client ID tracking (default: enabled)]), [CLIENTIDS=$enableval], [CLIENTIDS=yes])
+
+dnl DDXes.
+AC_ARG_ENABLE(xorg, AS_HELP_STRING([--enable-xorg], [Build Xorg server (default: auto)]), [XORG=$enableval], [XORG=auto])
+AC_ARG_ENABLE(dmx, AS_HELP_STRING([--enable-dmx], [Build DMX server (default: auto)]), [DMX=$enableval], [DMX=auto])
+AC_ARG_ENABLE(xvfb, AS_HELP_STRING([--enable-xvfb], [Build Xvfb server (default: yes)]), [XVFB=$enableval], [XVFB=yes])
+AC_ARG_ENABLE(xnest, AS_HELP_STRING([--enable-xnest], [Build Xnest server (default: auto)]), [XNEST=$enableval], [XNEST=auto])
+AC_ARG_ENABLE(xquartz, AS_HELP_STRING([--enable-xquartz], [Build Xquartz server for OS-X (default: auto)]), [XQUARTZ=$enableval], [XQUARTZ=auto])
+AC_ARG_ENABLE(standalone-xpbproxy, AS_HELP_STRING([--enable-standalone-xpbproxy], [Build a standalone xpbproxy (in addition to the one integrated into Xquartz as a separate thread) (default: no)]), [STANDALONE_XPBPROXY=$enableval], [STANDALONE_XPBPROXY=no])
+AC_ARG_ENABLE(xwin, AS_HELP_STRING([--enable-xwin], [Build XWin server (default: auto)]), [XWIN=$enableval], [XWIN=auto])
+dnl kdrive and its subsystems
+AC_ARG_ENABLE(kdrive, AS_HELP_STRING([--enable-kdrive], [Build kdrive servers (default: no)]), [KDRIVE=$enableval], [KDRIVE=no])
+AC_ARG_ENABLE(xephyr, AS_HELP_STRING([--enable-xephyr], [Build the kdrive Xephyr server (default: auto)]), [XEPHYR=$enableval], [XEPHYR=auto])
+AC_ARG_ENABLE(xfake, AS_HELP_STRING([--enable-xfake], [Build the kdrive 'fake' server (default: auto)]), [XFAKE=$enableval], [XFAKE=auto])
+AC_ARG_ENABLE(xfbdev, AS_HELP_STRING([--enable-xfbdev], [Build the kdrive framebuffer device server (default: auto)]), [XFBDEV=$enableval], [XFBDEV=auto])
+dnl kdrive options
+AC_ARG_ENABLE(kdrive-kbd, AS_HELP_STRING([--enable-kdrive-kbd], [Build kbd driver for kdrive (default: auto)]), [KDRIVE_KBD=$enableval], [KDRIVE_KBD=auto])
+AC_ARG_ENABLE(kdrive-mouse, AC_HELP_STRING([--enable-kdrive-mouse], [Build mouse driver for kdrive (default: auto)]), [KDRIVE_MOUSE=$enableval], [KDRIVE_MOUSE=auto])
+AC_ARG_ENABLE(kdrive-evdev, AC_HELP_STRING([--enable-kdrive-evdev], [Build evdev driver for kdrive (default: auto)]), [KDRIVE_EVDEV=$enableval], [KDRIVE_EVDEV=auto])
+
+
+dnl chown/chmod to be setuid root as part of build
+dnl Replaces InstallXserverSetUID in imake
+AC_ARG_ENABLE(install-setuid,
+ AS_HELP_STRING([--enable-install-setuid],
+ [Install Xorg server as owned by root with setuid bit (default: auto)]),
+ [SETUID=$enableval], [SETUID=auto])
+AC_MSG_CHECKING([to see if we can install the Xorg server as root])
+if test "x$SETUID" = "xauto" ; then
+ case $host_os in
+ cygwin*) SETUID="no" ;;
+ darwin*) SETUID="no" ;;
+ *)
+ case $host_cpu in
+ sparc) SETUID="no" ;;
+ *) SETUID="yes" ;;
+ esac
+ esac
+ if test "x$SETUID" = xyes; then
+ touch testfile
+ chown root testfile > /dev/null 2>&1 || SETUID="no"
+ rm -f testfile
+ fi
+fi
+AC_MSG_RESULT([$SETUID])
+AM_CONDITIONAL(INSTALL_SETUID, [test "x$SETUID" = "xyes"])
+
+dnl Issue an error if xtrans.m4 was not found and XTRANS_CONNECTION_FLAGS macro
+dnl was not expanded, since xorg-server with no transport types is rather useless.
+dnl
+dnl If you're seeing an error here, be sure you installed the lib/xtrans module
+dnl first and if it's not in the default location, that you set the ACLOCAL
+dnl environment variable to find it, such as:
+dnl ACLOCAL="aclocal -I ${PREFIX}/share/aclocal"
+m4_pattern_forbid([^XTRANS_CONNECTION_FLAGS$])
+
+# Transport selection macro from xtrans.m4
+XTRANS_CONNECTION_FLAGS
+
+# Secure RPC detection macro from xtrans.m4
+XTRANS_SECURE_RPC_FLAGS
+AM_CONDITIONAL(SECURE_RPC, [test "x$SECURE_RPC" = xyes])
+
+AM_CONDITIONAL(INT10_VM86, [test "x$INT10" = xvm86])
+AM_CONDITIONAL(INT10_X86EMU, [test "x$INT10" = xx86emu])
+AM_CONDITIONAL(INT10_STUB, [test "x$INT10" = xstub])
+if test "x$INT10" = xyes; then
+ dnl VM86 headers
+ AC_CHECK_HEADERS([sys/vm86.h sys/io.h])
+fi
+
+dnl Handle installing libxf86config
+AM_CONDITIONAL(INSTALL_LIBXF86CONFIG, [test "x$INSTALL_LIBXF86CONFIG" = xyes])
+
+dnl DDX Detection... Yes, it's ugly to have it here... but we need to
+dnl handle this early on so that we don't require unsupported extensions
+case $host_os in
+ cygwin*)
+ DGA=no
+ DRI2=no
+ XF86VIDMODE=no
+ XSELINUX=no
+ XV=no
+ ;;
+ darwin*)
+ DRI2=no
+
+ 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
+
+ AC_CHECK_FUNC(dispatch_async,
+ AC_DEFINE([HAVE_LIBDISPATCH], 1, [Define to 1 if you have the libdispatch (GCD) available]),
+ [])
+
+ if test "x$XQUARTZ" = xyes ; then
+ XQUARTZ=yes
+ XVFB=no
+ XNEST=no
+
+ COMPOSITE=no
+ DGA=no
+ DPMSExtension=no
+ XF86VIDMODE=no
+ fi
+ ;;
+ *) XQUARTZ=no ;;
+esac
+
+dnl ---------------------------------------------------------------------------
+dnl Extension section
+dnl ---------------------------------------------------------------------------
+XEXT_INC='-I$(top_srcdir)/Xext'
+XEXT_LIB='$(top_builddir)/Xext/libXext.la'
+XEXTXORG_LIB='$(top_builddir)/Xext/libXextbuiltin.la'
+
+dnl Optional modules
+VIDEOPROTO="videoproto"
+COMPOSITEPROTO="compositeproto >= 0.4"
+RECORDPROTO="recordproto >= 1.13.99.1"
+SCRNSAVERPROTO="scrnsaverproto >= 1.1"
+RESOURCEPROTO="resourceproto"
+DRIPROTO="xf86driproto >= 2.1.0"
+DRI2PROTO="dri2proto >= 2.3"
+XINERAMAPROTO="xineramaproto"
+BIGFONTPROTO="xf86bigfontproto >= 1.2.0"
+DGAPROTO="xf86dgaproto >= 2.0.99.1"
+GLPROTO="glproto >= 1.4.10"
+DMXPROTO="dmxproto >= 2.2.99.1"
+VIDMODEPROTO="xf86vidmodeproto >= 2.2.99.1"
+WINDOWSWMPROTO="windowswmproto"
+APPLEWMPROTO="applewmproto >= 1.4"
+
+dnl Core modules for most extensions, et al.
+SDK_REQUIRED_MODULES="[xproto >= 7.0.17] [randrproto >= 1.2.99.3] [renderproto >= 0.11] [xextproto >= 7.1.99] [inputproto >= 1.9.99.902] [kbproto >= 1.0.3] fontsproto"
+# Make SDK_REQUIRED_MODULES available for inclusion in xorg-server.pc
+AC_SUBST(SDK_REQUIRED_MODULES)
+
+dnl List of libraries that require a specific version
+LIBAPPLEWM="applewm >= 1.4"
+LIBDMX="dmx >= 1.0.99.1"
+LIBDRI="dri >= 7.8.0"
+LIBDRM="libdrm >= 2.3.0"
+LIBGL="gl >= 7.1.0"
+LIBXEXT="xext >= 1.0.99.4"
+LIBXFONT="xfont >= 1.4.2"
+LIBXI="xi >= 1.2.99.1"
+LIBXTST="xtst >= 1.0.99.2"
+LIBPCIACCESS="pciaccess >= 0.8.0"
+LIBUDEV="libudev >= 143"
+LIBSELINUX="libselinux >= 2.0.86"
+LIBDBUS="dbus-1 >= 1.0"
+LIBPIXMAN="pixman-1 >= 0.21.8"
+
+dnl Pixman is always required, but we separate it out so we can link
+dnl specific modules against it
+PKG_CHECK_MODULES(PIXMAN, $LIBPIXMAN)
+REQUIRED_LIBS="$REQUIRED_LIBS $LIBPIXMAN $LIBXFONT xau"
+
+REQUIRED_MODULES="[fixesproto >= 4.1] [damageproto >= 1.1] [xcmiscproto >= 1.2.0] [xtrans >= 1.2.2] [bigreqsproto >= 1.1.0] $SDK_REQUIRED_MODULES"
+
+if test "x$CONFIG_UDEV" = xyes &&
+ { test "x$CONFIG_DBUS_API" = xyes || test "x$CONFIG_HAL" = xyes; }; then
+ AC_MSG_ERROR([Hotplugging through both libudev and dbus/hal not allowed])
+fi
+
+PKG_CHECK_MODULES(UDEV, $LIBUDEV, [HAVE_LIBUDEV=yes], [HAVE_LIBUDEV=no])
+if test "x$CONFIG_UDEV" = xauto; then
+ CONFIG_UDEV="$HAVE_LIBUDEV"
+fi
+AM_CONDITIONAL(CONFIG_UDEV, [test "x$CONFIG_UDEV" = xyes])
+if test "x$CONFIG_UDEV" = xyes; then
+ CONFIG_DBUS_API=no
+ CONFIG_HAL=no
+ if ! test "x$HAVE_LIBUDEV" = xyes; then
+ AC_MSG_ERROR([udev configuration API requested, but libudev is not installed])
+ fi
+ AC_DEFINE(CONFIG_UDEV, 1, [Use libudev for input hotplug])
+fi
+
+dnl HAVE_DBUS is true if we actually have the D-Bus library, whereas
+dnl CONFIG_DBUS_API is true if we want to enable the D-Bus config
+dnl API.
+PKG_CHECK_MODULES(DBUS, $LIBDBUS, [HAVE_DBUS=yes], [HAVE_DBUS=no])
+if test "x$HAVE_DBUS" = xyes; then
+ AC_DEFINE(HAVE_DBUS, 1, [Have D-Bus support])
+fi
+AM_CONDITIONAL(HAVE_DBUS, [test "x$HAVE_DBUS" = xyes])
+
+if test "x$CONFIG_DBUS_API" = xauto; then
+ CONFIG_DBUS_API="$HAVE_DBUS"
+fi
+if test "x$CONFIG_DBUS_API" = xyes; then
+ if ! test "x$HAVE_DBUS" = xyes; then
+ AC_MSG_ERROR([D-Bus configuration API requested, but D-Bus is not installed.])
+ fi
+
+ AC_DEFINE(CONFIG_DBUS_API, 1, [Use the D-Bus input configuration API])
+ CONFIG_NEED_DBUS="yes"
+fi
+AM_CONDITIONAL(CONFIG_DBUS_API, [test "x$CONFIG_DBUS_API" = xyes])
+
+PKG_CHECK_MODULES(HAL, hal, [HAVE_HAL=yes], [HAVE_HAL=no])
+if test "x$CONFIG_HAL" = xauto; then
+ CONFIG_HAL="$HAVE_HAL"
+fi
+if test "x$CONFIG_HAL" = xyes; then
+ if ! test "x$HAVE_HAL" = xyes; then
+ AC_MSG_ERROR([HAL hotplug API requested, but HAL is not installed.])
+ fi
+
+ AC_DEFINE(CONFIG_HAL, 1, [Use the HAL hotplug API])
+ CONFIG_NEED_DBUS="yes"
+fi
+AM_CONDITIONAL(CONFIG_HAL, [test "x$CONFIG_HAL" = xyes])
+
+if test "x$CONFIG_NEED_DBUS" = xyes; then
+ AC_DEFINE(CONFIG_NEED_DBUS, 1, [Use D-Bus for input hotplug])
+fi
+AM_CONDITIONAL(CONFIG_NEED_DBUS, [test "x$CONFIG_NEED_DBUS" = xyes])
+
+if test "x$USE_SIGIO_BY_DEFAULT" = xyes; then
+ USE_SIGIO_BY_DEFAULT_VALUE=TRUE
+else
+ USE_SIGIO_BY_DEFAULT_VALUE=FALSE
+fi
+AC_DEFINE_UNQUOTED([USE_SIGIO_BY_DEFAULT], [$USE_SIGIO_BY_DEFAULT_VALUE],
+ [Use SIGIO handlers for input device events by default])
+
+AC_MSG_CHECKING([for glibc...])
+AC_PREPROC_IFELSE([
+#include <features.h>
+#ifndef __GLIBC__
+#error
+#endif
+], glibc=yes, glibc=no)
+AC_MSG_RESULT([$glibc])
+
+AC_CHECK_FUNCS([clock_gettime], [have_clock_gettime=yes],
+ [AC_CHECK_LIB([rt], [clock_gettime], [have_clock_gettime=-lrt],
+ [have_clock_gettime=no])])
+
+AC_MSG_CHECKING([for a useful monotonic clock ...])
+
+if ! test "x$have_clock_gettime" = xno; then
+ if ! test "x$have_clock_gettime" = xyes; then
+ CLOCK_LIBS="$have_clock_gettime"
+ else
+ CLOCK_LIBS=""
+ fi
+
+ LIBS_SAVE="$LIBS"
+ LIBS="$CLOCK_LIBS"
+ CPPFLAGS_SAVE="$CPPFLAGS"
+
+ if test x"$glibc" = xyes; then
+ CPPFLAGS="$CPPFLAGS -D_POSIX_C_SOURCE=200112L"
+ fi
+
+ AC_RUN_IFELSE([
+#include <time.h>
+
+int main(int argc, char *argv[[]]) {
+ struct timespec tp;
+
+ if (clock_gettime(CLOCK_MONOTONIC, &tp) == 0)
+ return 0;
+ else
+ return 1;
+}
+ ], [MONOTONIC_CLOCK=yes], [MONOTONIC_CLOCK=no],
+ [MONOTONIC_CLOCK="cross compiling"])
+
+ LIBS="$LIBS_SAVE"
+ CPPFLAGS="$CPPFLAGS_SAVE"
+else
+ MONOTONIC_CLOCK=no
+fi
+
+AC_MSG_RESULT([$MONOTONIC_CLOCK])
+
+if test "x$MONOTONIC_CLOCK" = xyes; then
+ AC_DEFINE(MONOTONIC_CLOCK, 1, [Have monotonic clock from clock_gettime()])
+ LIBS="$LIBS $CLOCK_LIBS"
+fi
+
+AM_CONDITIONAL(XV, [test "x$XV" = xyes])
+if test "x$XV" = xyes; then
+ AC_DEFINE(XV, 1, [Support Xv extension])
+ AC_DEFINE(XvExtension, 1, [Build Xv extension])
+ REQUIRED_MODULES="$REQUIRED_MODULES $VIDEOPROTO"
+ SDK_REQUIRED_MODULES="$SDK_REQUIRED_MODULES $VIDEOPROTO"
+else
+ XVMC=no
+fi
+
+AM_CONDITIONAL(XVMC, [test "x$XVMC" = xyes])
+if test "x$XVMC" = xyes; then
+ AC_DEFINE(XvMCExtension, 1, [Build XvMC extension])
+fi
+
+AM_CONDITIONAL(XREGISTRY, [test "x$XREGISTRY" = xyes])
+if test "x$XREGISTRY" = xyes; then
+ AC_DEFINE(XREGISTRY, 1, [Build registry module])
+fi
+
+AM_CONDITIONAL(COMPOSITE, [test "x$COMPOSITE" = xyes])
+if test "x$COMPOSITE" = xyes; then
+ AC_DEFINE(COMPOSITE, 1, [Support Composite Extension])
+ REQUIRED_MODULES="$REQUIRED_MODULES $COMPOSITEPROTO"
+ COMPOSITE_LIB='$(top_builddir)/composite/libcomposite.la'
+ COMPOSITE_INC='-I$(top_srcdir)/composite'
+fi
+
+AM_CONDITIONAL(MITSHM, [test "x$MITSHM" = xyes])
+if test "x$MITSHM" = xyes; then
+ AC_DEFINE(MITSHM, 1, [Support MIT-SHM extension])
+ AC_DEFINE(HAS_SHM, 1, [Support SHM])
+fi
+
+AM_CONDITIONAL(RECORD, [test "x$RECORD" = xyes])
+if test "x$RECORD" = xyes; then
+ AC_DEFINE(XRECORD, 1, [Support Record extension])
+ REQUIRED_MODULES="$REQUIRED_MODULES $RECORDPROTO"
+ RECORD_LIB='$(top_builddir)/record/librecord.la'
+fi
+
+AM_CONDITIONAL(SCREENSAVER, [test "x$SCREENSAVER" = xyes])
+if test "x$SCREENSAVER" = xyes; then
+ AC_DEFINE(SCREENSAVER, 1, [Support MIT-SCREEN-SAVER extension])
+ REQUIRED_MODULES="$REQUIRED_MODULES $SCRNSAVERPROTO"
+fi
+
+AM_CONDITIONAL(RES, [test "x$RES" = xyes])
+if test "x$RES" = xyes; then
+ AC_DEFINE(RES, 1, [Support X resource extension])
+ REQUIRED_MODULES="$REQUIRED_MODULES $RESOURCEPROTO"
+fi
+
+# The XRes extension may support client ID tracking only if it has
+# been specifically enabled. Client ID tracking is implicitly not
+# supported if XRes extension is disabled.
+AC_MSG_CHECKING([whether to track client ids])
+if test "x$RES" = xyes && test "x$CLIENTIDS" = xyes; then
+ AC_DEFINE(CLIENTIDS, 1, [Support client ID tracking])
+else
+ CLIENTIDS=no
+fi
+AC_MSG_RESULT([$CLIENTIDS])
+AM_CONDITIONAL(CLIENTIDS, [test "x$CLIENTIDS" = xyes])
+
+if test "x$GLX" = xyes; then
+ PKG_CHECK_MODULES([XLIB], [x11])
+ PKG_CHECK_MODULES([GL], $GLPROTO $LIBGL)
+ AC_SUBST(XLIB_CFLAGS)
+ AC_DEFINE(GLXEXT, 1, [Build GLX extension])
+ GLX_LIBS='$(top_builddir)/glx/libglx.la'
+ GLX_SYS_LIBS="$GLX_SYS_LIBS"
+else
+ GLX=no
+fi
+AM_CONDITIONAL(GLX, test "x$GLX" = xyes)
+
+if test "x$GLX" = xno; then
+ AIGLX=no
+fi
+
+if test "x$AIGLX" = xyes -a \( "x$DRI" = xyes -o "x$DRI2" = xyes \); then
+ AC_DEFINE(AIGLX, 1, [Build AIGLX loader])
+fi
+AM_CONDITIONAL(AIGLX_DRI_LOADER, { test "x$DRI" = xyes || test "x$DRI2" = xyes; } && test "x$AIGLX" = xyes)
+
+if test "x$GLX_USE_TLS" = xyes ; then
+ GLX_DEFINES="-DGLX_USE_TLS -DPTHREADS"
+ GLX_SYS_LIBS="$GLX_SYS_LIBS -lpthread"
+fi
+AC_SUBST([GLX_DEFINES])
+
+AM_CONDITIONAL(DRI, test "x$DRI" = xyes)
+if test "x$DRI" = xyes; then
+ AC_DEFINE(XF86DRI, 1, [Build DRI extension])
+ PKG_CHECK_MODULES([DRIPROTO], [$DRIPROTO])
+ PKG_CHECK_MODULES([DRI], $GLPROTO $LIBDRI)
+ AC_SUBST(DRIPROTO_CFLAGS)
+fi
+
+PKG_CHECK_MODULES([DRI2PROTO], $DRI2PROTO,
+ [HAVE_DRI2PROTO=yes], [HAVE_DRI2PROTO=no])
+case "$DRI2,$HAVE_DRI2PROTO" in
+ yes,no)
+ AC_MSG_ERROR([DRI2 requested, but dri2proto not found.])
+ ;;
+ yes,yes | auto,yes)
+ AC_DEFINE(DRI2, 1, [Build DRI2 extension])
+ DRI2=yes
+ SDK_REQUIRED_MODULES="$SDK_REQUIRED_MODULES $DRI2PROTO"
+ ;;
+esac
+AM_CONDITIONAL(DRI2, test "x$DRI2" = xyes)
+
+if test "x$DRI" = xyes || test "x$DRI2" = xyes; then
+ if test "x$DRM" = xyes; then
+ AC_DEFINE(WITH_LIBDRM, 1, [Building with libdrm support])
+ PKG_CHECK_MODULES([LIBDRM], $LIBDRM)
+ fi
+fi
+
+if test "x$DRI2" = xyes; then
+ save_CFLAGS=$CFLAGS
+ CFLAGS="$GL_CFLAGS $LIBDRM_CFLAGS"
+ AC_COMPILE_IFELSE([AC_LANG_SOURCE([[#include <GL/gl.h>
+#include <GL/internal/dri_interface.h>
+#ifndef __DRI_DRI2
+#error DRI2 extension not available.
+#endif]])],
+ [HAVE_DRI2EXTENSION=yes],
+ [HAVE_DRI2EXTENSION=no])
+ CFLAGS=$save_CFLAGS
+ if test "x$HAVE_DRI2EXTENSION" = xyes; then
+ AC_DEFINE(DRI2_AIGLX, 1, [Build DRI2 AIGLX loader])
+ DRI2_AIGLX=yes
+ else
+ AC_MSG_NOTICE([DRI2 AIGLX disabled, __DRI_DRI2 not defined in dri_interface.h.])
+ DRI2_AIGLX=no
+ fi
+fi
+AM_CONDITIONAL(DRI2_AIGLX, test "x$DRI2_AIGLX" = xyes)
+
+
+AM_CONDITIONAL(XINERAMA, [test "x$XINERAMA" = xyes])
+if test "x$XINERAMA" = xyes; then
+ AC_DEFINE(XINERAMA, 1, [Support Xinerama extension])
+ AC_DEFINE(PANORAMIX, 1, [Internal define for Xinerama])
+ REQUIRED_MODULES="$REQUIRED_MODULES $XINERAMAPROTO"
+ SDK_REQUIRED_MODULES="$SDK_REQUIRED_MODULES $XINERAMAPROTO"
+fi
+
+AM_CONDITIONAL(XACE, [test "x$XACE" = xyes])
+if test "x$XACE" = xyes; then
+ AC_DEFINE(XACE, 1, [Build X-ACE extension])
+fi
+
+AM_CONDITIONAL(XSELINUX, [test "x$XSELINUX" = xyes])
+if test "x$XSELINUX" = xyes; then
+ if test "x$XACE" != xyes; then
+ AC_MSG_ERROR([cannot build SELinux extension without X-ACE])
+ fi
+ AC_CHECK_HEADERS([libaudit.h], [], AC_MSG_ERROR([SELinux extension requires audit system headers]))
+ AC_CHECK_LIB(audit, audit_open, [], AC_MSG_ERROR([SELinux extension requires audit system library]))
+ PKG_CHECK_MODULES([SELINUX], $LIBSELINUX)
+ SELINUX_LIBS="$SELINUX_LIBS -laudit"
+ AC_DEFINE(XSELINUX, 1, [Build SELinux extension])
+fi
+
+AM_CONDITIONAL(XCSECURITY, [test "x$XCSECURITY" = xyes])
+if test "x$XCSECURITY" = xyes; then
+ if test "x$XACE" != xyes; then
+ AC_MSG_ERROR([cannot build Security extension without X-ACE])
+ fi
+ AC_DEFINE(XCSECURITY, 1, [Build Security extension])
+fi
+
+AM_CONDITIONAL(DBE, [test "x$DBE" = xyes])
+if test "x$DBE" = xyes; then
+ AC_DEFINE(DBE, 1, [Support DBE extension])
+ DBE_LIB='$(top_builddir)/dbe/libdbe.la'
+fi
+
+AM_CONDITIONAL(XF86BIGFONT, [test "x$XF86BIGFONT" = xyes])
+if test "x$XF86BIGFONT" = xyes; then
+ AC_DEFINE(XF86BIGFONT, 1, [Support XF86 Big font extension])
+ REQUIRED_MODULES="$REQUIRED_MODULES $BIGFONTPROTO"
+fi
+
+AM_CONDITIONAL(DPMSExtension, [test "x$DPMSExtension" = xyes])
+if test "x$DPMSExtension" = xyes; then
+ AC_DEFINE(DPMSExtension, 1, [Support DPMS extension])
+fi
+
+AC_DEFINE(RENDER, 1, [Support RENDER extension])
+RENDER_LIB='$(top_builddir)/render/librender.la'
+RENDER_INC='-I$(top_srcdir)/render'
+
+AC_DEFINE(RANDR, 1, [Support RANDR extension])
+RANDR_LIB='$(top_builddir)/randr/librandr.la'
+RANDR_INC='-I$(top_srcdir)/randr'
+
+AC_DEFINE(XFIXES,1,[Support XFixes extension])
+FIXES_LIB='$(top_builddir)/xfixes/libxfixes.la'
+FIXES_INC='-I$(top_srcdir)/xfixes'
+
+AC_DEFINE(DAMAGE,1,[Support Damage extension])
+DAMAGE_LIB='$(top_builddir)/damageext/libdamageext.la'
+DAMAGE_INC='-I$(top_srcdir)/damageext'
+MIEXT_DAMAGE_LIB='$(top_builddir)/miext/damage/libdamage.la'
+MIEXT_DAMAGE_INC='-I$(top_srcdir)/miext/damage'
+
+# XINPUT extension is integral part of the server
+AC_DEFINE(XINPUT, 1, [Support X Input extension])
+XI_LIB='$(top_builddir)/Xi/libXi.la'
+XI_INC='-I$(top_srcdir)/Xi'
+
+AM_CONDITIONAL(XF86UTILS, test "x$XF86UTILS" = xyes)
+AM_CONDITIONAL(XAA, test "x$XAA" = xyes)
+AM_CONDITIONAL(VGAHW, test "x$VGAHW" = xyes)
+AM_CONDITIONAL(VBE, test "x$VBE" = xyes)
+AM_CONDITIONAL(INT10MODULE, test "x$INT10MODULE" = xyes)
+
+AC_DEFINE(SHAPE, 1, [Support SHAPE extension])
+
+AC_DEFINE_DIR(XKB_BASE_DIRECTORY, XKBPATH, [Path to XKB data])
+AC_ARG_WITH(xkb-bin-directory,
+ AS_HELP_STRING([--with-xkb-bin-directory=DIR], [Directory containing xkbcomp program]),
+ [XKB_BIN_DIRECTORY="$withval"],
+ [XKB_BIN_DIRECTORY="$bindir"])
+
+AC_DEFINE_DIR(XKB_BIN_DIRECTORY, XKB_BIN_DIRECTORY, [Path to XKB bin dir])
+
+dnl Make sure XKM_OUTPUT_DIR is an absolute path
+XKBOUTPUT_FIRSTCHAR=`echo $XKBOUTPUT | cut -b 1`
+if [[ x$XKBOUTPUT_FIRSTCHAR != x/ -a x$XKBOUTPUT_FIRSTCHAR != 'x$' ]] ; then
+ XKBOUTPUT="$XKB_BASE_DIRECTORY/$XKBOUTPUT"
+fi
+
+dnl XKM_OUTPUT_DIR (used in code) must end in / or file names get hosed
+dnl XKB_COMPILED_DIR (used in Makefiles) must not or install-sh gets confused
+
+XKBOUTPUT=`echo $XKBOUTPUT/ | $SED 's|/*$|/|'`
+XKB_COMPILED_DIR=`echo $XKBOUTPUT | $SED 's|/*$||'`
+AC_DEFINE_DIR(XKM_OUTPUT_DIR, XKBOUTPUT, [Path to XKB output dir])
+AC_SUBST(XKB_COMPILED_DIR)
+
+if test "x$XKB_DFLT_RULES" = x; then
+ case $host_os in
+ linux*)
+ dnl doesn't take AutoAddDevices into account, but whatever.
+ if test "x$CONFIG_HAL" = xyes; then
+ XKB_DFLT_RULES="evdev"
+ else
+ XKB_DFLT_RULES="base"
+ fi
+ ;;
+ *)
+ XKB_DFLT_RULES="base"
+ ;;
+ esac
+fi
+AC_DEFINE_UNQUOTED(XKB_DFLT_RULES, ["$XKB_DFLT_RULES"], [Default XKB ruleset])
+AC_DEFINE_UNQUOTED(XKB_DFLT_MODEL, ["$XKB_DFLT_MODEL"], [Default XKB model])
+AC_DEFINE_UNQUOTED(XKB_DFLT_LAYOUT, ["$XKB_DFLT_LAYOUT"], [Default XKB layout])
+AC_DEFINE_UNQUOTED(XKB_DFLT_VARIANT, ["$XKB_DFLT_VARIANT"], [Default XKB variant])
+AC_DEFINE_UNQUOTED(XKB_DFLT_OPTIONS, ["$XKB_DFLT_OPTIONS"], [Default XKB options])
+
+XKB_LIB='$(top_builddir)/xkb/libxkb.la'
+XKB_STUB_LIB='$(top_builddir)/xkb/libxkbstubs.la'
+REQUIRED_MODULES="$REQUIRED_MODULES xkbfile"
+
+AC_CHECK_FUNC(strcasecmp, [], AC_DEFINE([NEED_STRCASECMP], 1,
+ [Do not have 'strcasecmp'.]))
+AC_CHECK_FUNC(strncasecmp, [], AC_DEFINE([NEED_STRNCASECMP], 1,
+ [Do not have 'strncasecmp'.]))
+AC_CHECK_FUNC(strcasestr, [], AC_DEFINE([NEED_STRCASESTR], 1,
+ [Do not have 'strcasestr'.]))
+
+PKG_CHECK_MODULES([XDMCP], [xdmcp], [have_libxdmcp="yes"], [have_libxdmcp="no"])
+if test "x$have_libxdmcp" = xyes; then
+ AC_CHECK_LIB(Xdmcp, XdmcpWrap, [have_xdmcpwrap="yes"], [have_xdmcpwrap="no"], [$XDMCP_LIBS])
+fi
+if test "x$XDMCP" = xauto; then
+ if test "x$have_libxdmcp" = xyes; then
+ XDMCP=yes
+ else
+ XDMCP=no
+ fi
+fi
+if test "x$XDMAUTH" = xauto; then
+ if test "x$have_libxdmcp" = xyes && test "x$have_xdmcpwrap" = xyes; then
+ XDMAUTH=yes
+ else
+ XDMAUTH=no
+ fi
+fi
+
+AM_CONDITIONAL(XDMCP, [test "x$XDMCP" = xyes])
+if test "x$XDMCP" = xyes; then
+ AC_DEFINE(XDMCP, 1, [Support XDM Control Protocol])
+ REQUIRED_LIBS="$REQUIRED_LIBS xdmcp"
+ XDMCP_MODULES="xdmcp"
+fi
+
+AM_CONDITIONAL(XDMAUTH, [test "x$XDMAUTH" = xyes])
+if test "x$XDMAUTH" = xyes; then
+ AC_DEFINE(HASXDMAUTH,1,[Support XDM-AUTH*-1])
+ if ! test "x$XDMCP" = xyes; then
+ REQUIRED_LIBS="$REQUIRED_LIBS xdmcp"
+ XDMCP_MODULES="xdmcp"
+ fi
+fi
+
+AC_DEFINE_DIR(COMPILEDDEFAULTFONTPATH, FONTPATH, [Default font path])
+AC_DEFINE_DIR(PCI_TXT_IDS_PATH, PCI_TXT_IDS_DIR, [Default PCI text file ID path])
+AC_DEFINE_DIR(SERVER_MISC_CONFIG_PATH, SERVERCONFIG, [Server miscellaneous config path])
+AC_DEFINE_DIR(BASE_FONT_PATH, FONTROOTDIR, [Default base font path])
+dridriverdir=`$PKG_CONFIG --variable=dridriverdir dri`
+AC_DEFINE_DIR(DRI_DRIVER_PATH, dridriverdir, [Default DRI driver path])
+AC_DEFINE_UNQUOTED(XVENDORNAME, ["$VENDOR_NAME"], [Vendor name])
+AC_DEFINE_UNQUOTED(XVENDORNAMESHORT, ["$VENDOR_NAME_SHORT"], [Short vendor name])
+AC_DEFINE_UNQUOTED(XORG_DATE, ["$RELEASE_DATE"], [Vendor release])
+AC_DEFINE_UNQUOTED(XORG_MAN_VERSION, ["$VENDOR_MAN_VERSION"], [Vendor man version])
+AC_DEFINE_UNQUOTED(BUILDERADDR, ["$BUILDERADDR"], [Builder address])
+
+if test -z "$OSNAME"; then
+ OSNAME="UNKNOWN"
+fi
+
+AC_DEFINE_UNQUOTED(OSNAME, ["$OSNAME"], [Operating System Name])
+AC_DEFINE_UNQUOTED(OSVENDOR, ["$OSVENDOR"], [Operating System Vendor])
+AC_DEFINE_UNQUOTED(BUILDERSTRING, ["$BUILDERSTRING"], [Builder string])
+
+AC_SUBST([VENDOR_NAME_SHORT])
+AC_DEFINE_UNQUOTED(VENDOR_NAME, ["$VENDOR_NAME"], [Vendor name])
+AC_DEFINE_UNQUOTED(VENDOR_NAME_SHORT, ["$VENDOR_NAME_SHORT"], [Vendor name])
+AC_DEFINE_UNQUOTED(VENDOR_RELEASE, [$VENDOR_RELEASE], [Vendor release])
+AC_DEFINE_UNQUOTED(VENDOR_MAN_VERSION, ["$VENDOR_MAN_VERSION"], [Vendor man version])
+
+AC_DEFINE(NO_LIBCWRAPPER, 1, [Define to 1 if modules should avoid the libcwrapper])
+
+if test "x$DEBUGGING" = xyes; then
+ AC_DEFINE(DEBUG, 1, [Enable debugging code])
+fi
+AM_CONDITIONAL(DEBUG, [test "x$DEBUGGING" = xyes])
+
+AC_DEFINE(XTEST, 1, [Support XTest extension])
+AC_DEFINE(XSYNC, 1, [Support XSync extension])
+AC_DEFINE(XCMISC, 1, [Support XCMisc extension])
+AC_DEFINE(BIGREQS, 1, [Support BigRequests extension])
+
+if test "x$SPECIAL_DTRACE_OBJECTS" = "xyes" ; then
+ DIX_LIB='$(top_builddir)/dix/dix.O'
+ OS_LIB='$(top_builddir)/os/os.O $(SHA1_LIBS) $(DLOPEN_LIBS)'
+else
+ DIX_LIB='$(top_builddir)/dix/libdix.la'
+ OS_LIB='$(top_builddir)/os/libos.la'
+fi
+AC_SUBST([DIX_LIB])
+AC_SUBST([OS_LIB])
+
+MAIN_LIB='$(top_builddir)/dix/libmain.la'
+AC_SUBST([MAIN_LIB])
+
+MI_LIB='$(top_builddir)/mi/libmi.la'
+MI_EXT_LIB='$(top_builddir)/mi/libmiext.la'
+MI_INC='-I$(top_srcdir)/mi'
+FB_LIB='$(top_builddir)/fb/libfb.la'
+FB_INC='-I$(top_srcdir)/fb'
+MIEXT_SHADOW_INC='-I$(top_srcdir)/miext/shadow'
+MIEXT_SHADOW_LIB='$(top_builddir)/miext/shadow/libshadow.la'
+MIEXT_SYNC_INC='-I$(top_srcdir)/miext/sync'
+MIEXT_SYNC_LIB='$(top_builddir)/miext/sync/libsync.la'
+CORE_INCS='-I$(top_srcdir)/include -I$(top_builddir)/include'
+
+# SHA1 hashing
+AC_ARG_WITH([sha1],
+ [AS_HELP_STRING([--with-sha1=libc|libmd|libgcrypt|libcrypto|libsha1|CommonCrypto],
+ [choose SHA1 implementation])])
+AC_CHECK_FUNC([SHA1Init], [HAVE_SHA1_IN_LIBC=yes])
+if test "x$with_sha1" = x && test "x$HAVE_SHA1_IN_LIBC" = xyes; then
+ with_sha1=libc
+fi
+if test "x$with_sha1" = xlibc && test "x$HAVE_SHA1_IN_LIBC" != xyes; then
+ AC_MSG_ERROR([libc requested but not found])
+fi
+if test "x$with_sha1" = xlibc; then
+ AC_DEFINE([HAVE_SHA1_IN_LIBC], [1],
+ [Use libc SHA1 functions])
+ SHA1_LIBS=""
+fi
+AC_CHECK_FUNC([CC_SHA1_Init], [HAVE_SHA1_IN_COMMONCRYPTO=yes])
+if test "x$with_sha1" = x && test "x$HAVE_SHA1_IN_COMMONCRYPTO" = xyes; then
+ with_sha1=CommonCrypto
+fi
+if test "x$with_sha1" = xCommonCrypto && test "x$HAVE_SHA1_IN_COMMONCRYPTO" != xyes; then
+ AC_MSG_ERROR([CommonCrypto requested but not found])
+fi
+if test "x$with_sha1" = xCommonCrypto; then
+ AC_DEFINE([HAVE_SHA1_IN_COMMONCRYPTO], [1],
+ [Use CommonCrypto SHA1 functions])
+ SHA1_LIBS=""
+fi
+AC_CHECK_LIB([md], [SHA1Init], [HAVE_LIBMD=yes])
+if test "x$with_sha1" = x && test "x$HAVE_LIBMD" = xyes; then
+ with_sha1=libmd
+fi
+if test "x$with_sha1" = xlibmd && test "x$HAVE_LIBMD" != xyes; then
+ AC_MSG_ERROR([libmd requested but not found])
+fi
+if test "x$with_sha1" = xlibmd; then
+ AC_DEFINE([HAVE_SHA1_IN_LIBMD], [1],
+ [Use libmd SHA1 functions])
+ SHA1_LIBS=-lmd
+fi
+PKG_CHECK_MODULES([LIBSHA1], [libsha1], [HAVE_LIBSHA1=yes], [HAVE_LIBSHA1=no])
+if test "x$with_sha1" = x && test "x$HAVE_LIBSHA1" = xyes; then
+ with_sha1=libsha1
+fi
+if test "x$with_sha1" = xlibsha1 && test "x$HAVE_LIBSHA1" != xyes; then
+ AC_MSG_ERROR([libsha1 requested but not found])
+fi
+if test "x$with_sha1" = xlibsha1; then
+ AC_DEFINE([HAVE_SHA1_IN_LIBSHA1], [1],
+ [Use libsha1 for SHA1])
+ SHA1_LIBS=-lsha1
+fi
+AC_CHECK_LIB([gcrypt], [gcry_md_open], [HAVE_LIBGCRYPT=yes])
+if test "x$with_sha1" = x && test "x$HAVE_LIBGCRYPT" = xyes; then
+ with_sha1=libgcrypt
+fi
+if test "x$with_sha1" = xlibgcrypt && test "x$HAVE_LIBGCRYPT" != xyes; then
+ AC_MSG_ERROR([libgcrypt requested but not found])
+fi
+if test "x$with_sha1" = xlibgcrypt; then
+ AC_DEFINE([HAVE_SHA1_IN_LIBGCRYPT], [1],
+ [Use libgcrypt SHA1 functions])
+ SHA1_LIBS=-lgcrypt
+fi
+# We don't need all of the OpenSSL libraries, just libcrypto
+AC_CHECK_LIB([crypto], [SHA1_Init], [HAVE_LIBCRYPTO=yes])
+PKG_CHECK_MODULES([OPENSSL], [openssl], [HAVE_OPENSSL_PKC=yes],
+ [HAVE_OPENSSL_PKC=no])
+if test "x$HAVE_LIBCRYPTO" = xyes || test "x$HAVE_OPENSSL_PKC" = xyes; then
+ if test "x$with_sha1" = x; then
+ with_sha1=libcrypto
+ fi
+else
+ if test "x$with_sha1" = xlibcrypto; then
+ AC_MSG_ERROR([OpenSSL libcrypto requested but not found])
+ fi
+fi
+if test "x$with_sha1" = xlibcrypto; then
+ if test "x$HAVE_LIBCRYPTO" = xyes; then
+ SHA1_LIBS=-lcrypto
+ else
+ SHA1_LIBS="$OPENSSL_LIBS"
+ SHA1_CFLAGS="$OPENSSL_CFLAGS"
+ fi
+fi
+AC_MSG_CHECKING([for SHA1 implementation])
+if test "x$with_sha1" = x; then
+ AC_MSG_ERROR([No suitable SHA1 implementation found])
+fi
+AC_MSG_RESULT([$with_sha1])
+AC_SUBST(SHA1_LIBS)
+AC_SUBST(SHA1_CFLAGS)
+
+PKG_CHECK_MODULES([XSERVERCFLAGS], [$REQUIRED_MODULES $REQUIRED_LIBS])
+PKG_CHECK_MODULES([XSERVERLIBS], [$REQUIRED_LIBS])
+
+# Autotools has some unfortunate issues with library handling. In order to
+# get a server to rebuild when a dependency in the tree is changed, it must
+# be listed in SERVERNAME_DEPENDENCIES. However, no system libraries may be
+# listed there, or some versions of autotools will break (especially if a -L
+# is required to find the library). So, we keep two sets of libraries
+# detected: NAMESPACE_LIBS for in-tree libraries to be linked against, which
+# will go into the _DEPENDENCIES and _LDADD of the server, and
+# NAMESPACE_SYS_LIBS which will go into only the _LDADD. The
+# NAMESPACEMODULES_LIBS detected from pkgconfig should always go in
+# NAMESPACE_SYS_LIBS.
+#
+# XSERVER_LIBS is the set of in-tree libraries which all servers require.
+# XSERVER_SYS_LIBS is the set of out-of-tree libraries which all servers
+# require.
+#
+XSERVER_CFLAGS="${XSERVER_CFLAGS} ${XSERVERCFLAGS_CFLAGS}"
+XSERVER_LIBS="$DIX_LIB $MI_LIB $OS_LIB"
+XSERVER_SYS_LIBS="${XSERVERLIBS_LIBS} ${SYS_LIBS} ${LIBS}"
+AC_SUBST([XSERVER_LIBS])
+AC_SUBST([XSERVER_SYS_LIBS])
+
+UTILS_SYS_LIBS="${SYS_LIBS}"
+AC_SUBST([UTILS_SYS_LIBS])
+
+# The Xorg binary needs to export symbols so that they can be used from modules
+# Some platforms require extra flags to do this. libtool should set the
+# necessary flags for each platform when -export-dynamic is passed to it.
+LD_EXPORT_SYMBOLS_FLAG="-export-dynamic"
+AC_SUBST([LD_EXPORT_SYMBOLS_FLAG])
+
+dnl Imake defines SVR4 on SVR4 systems, and many files check for it, so
+dnl we need to replicate that here until those can all be fixed
+AC_MSG_CHECKING([if SVR4 needs to be defined])
+AC_EGREP_CPP([I_AM_SVR4],[
+#if defined(SVR4) || defined(__svr4__) || defined(__SVR4)
+ I_AM_SVR4
+#endif
+],[
+AC_DEFINE([SVR4],1,[Define to 1 on systems derived from System V Release 4])
+AC_MSG_RESULT([yes])], AC_MSG_RESULT([no]))
+
+XSERVER_CFLAGS="$XSERVER_CFLAGS $CORE_INCS $XEXT_INC $COMPOSITE_INC $DAMAGE_INC $FIXES_INC $XI_INC $MI_INC $MIEXT_SYNC_INC $MIEXT_SHADOW_INC $MIEXT_LAYER_INC $MIEXT_DAMAGE_INC $RENDER_INC $RANDR_INC $FB_INC"
+
+dnl ---------------------------------------------------------------------------
+dnl DDX section.
+dnl ---------------------------------------------------------------------------
+
+dnl Xvfb DDX
+
+AC_MSG_CHECKING([whether to build Xvfb DDX])
+AC_MSG_RESULT([$XVFB])
+AM_CONDITIONAL(XVFB, [test "x$XVFB" = xyes])
+
+if test "x$XVFB" = xyes; then
+ XVFB_LIBS="$FB_LIB $FIXES_LIB $XEXT_LIB $DBE_LIB $RECORD_LIB $GLX_LIBS $RANDR_LIB $RENDER_LIB $DAMAGE_LIB $MIEXT_SYNC_LIB $MIEXT_DAMAGE_LIB $MIEXT_SHADOW_LIB $XI_LIB $XKB_LIB $XKB_STUB_LIB $COMPOSITE_LIB"
+ XVFB_SYS_LIBS="$XVFBMODULES_LIBS $GLX_SYS_LIBS"
+ AC_SUBST([XVFB_LIBS])
+ AC_SUBST([XVFB_SYS_LIBS])
+fi
+
+
+dnl Xnest DDX
+
+PKG_CHECK_MODULES(XNESTMODULES, [$LIBXEXT x11 xau $XDMCP_MODULES], [have_xnest=yes], [have_xnest=no])
+AC_MSG_CHECKING([whether to build Xnest DDX])
+if test "x$XNEST" = xauto; then
+ XNEST="$have_xnest"
+fi
+AC_MSG_RESULT([$XNEST])
+AM_CONDITIONAL(XNEST, [test "x$XNEST" = xyes])
+
+if test "x$XNEST" = xyes; then
+ if test "x$have_xnest" = xno; then
+ AC_MSG_ERROR([Xnest build explicitly requested, but required modules not found.])
+ fi
+ XNEST_LIBS="$FB_LIB $FIXES_LIB $MI_LIB $XEXT_LIB $DBE_LIB $RECORD_LIB $GLX_LIBS $RANDR_LIB $RENDER_LIB $DAMAGE_LIB $MIEXT_SYNC_LIB $MIEXT_DAMAGE_LIB $MIEXT_SHADOW_LIB $XI_LIB $XKB_LIB $XKB_STUB_LIB $COMPOSITE_LIB $MAIN_LIB $DIX_LIB $OS_LIB"
+ XNEST_SYS_LIBS="$XNESTMODULES_LIBS $GLX_SYS_LIBS"
+ AC_SUBST([XNEST_LIBS])
+ AC_SUBST([XNEST_SYS_LIBS])
+fi
+
+
+dnl Xorg DDX
+
+AC_MSG_CHECKING([whether to build Xorg DDX])
+if test "x$XORG" = xauto; then
+ XORG="yes"
+ case $host_os in
+ cygwin*) XORG="no" ;;
+ darwin*) XORG="no" ;;
+ esac
+fi
+AC_MSG_RESULT([$XORG])
+
+xorg_bus_linuxpci=no
+xorg_bus_bsdpci=no
+xorg_bus_sparc=no
+
+if test "x$XORG" = xyes; then
+ XORG_DDXINCS='-I$(top_srcdir)/hw/xfree86 -I$(top_srcdir)/hw/xfree86/include -I$(top_srcdir)/hw/xfree86/common'
+ XORG_OSINCS='-I$(top_srcdir)/hw/xfree86/os-support -I$(top_srcdir)/hw/xfree86/os-support/bus -I$(top_srcdir)/os'
+ XORG_INCS="$XORG_DDXINCS $XORG_OSINCS"
+ XORG_CFLAGS="$XORGSERVER_CFLAGS -DHAVE_XORG_CONFIG_H"
+ XORG_LIBS="$COMPOSITE_LIB $FIXES_LIB $XEXTXORG_LIB $GLX_LIBS $RANDR_LIB $RENDER_LIB $DAMAGE_LIB $MIEXT_SYNC_LIB $MIEXT_DAMAGE_LIB $MIEXT_SHADOW_LIB $XI_LIB $XKB_LIB"
+
+ dnl ==================================================================
+ dnl symbol visibility
+ symbol_visibility=
+ have_visibility=disabled
+ if test x$SYMBOL_VISIBILITY != xno; then
+ AC_MSG_CHECKING(for symbol visibility support)
+ if test x$GCC = xyes; then
+ VISIBILITY_CFLAGS="-fvisibility=hidden"
+ else
+ AC_CHECK_DECL([__SUNPRO_C], [SUNCC="yes"], [SUNCC="no"])
+ if test x$SUNCC = xyes; then
+ VISIBILITY_CFLAGS="-xldscope=hidden"
+ else
+ have_visibility=no
+ fi
+ fi
+ if test x$have_visibility != xno; then
+ save_CFLAGS="$CFLAGS"
+ CFLAGS="$CFLAGS $VISIBILITY_CFLAGS"
+ AC_TRY_COMPILE(
+ [#include <X11/Xfuncproto.h>
+ extern _X_HIDDEN int hidden_int;
+ extern _X_EXPORT int public_int;
+ extern _X_HIDDEN int hidden_int_func(void);
+ extern _X_EXPORT int public_int_func(void);],
+ [],
+ have_visibility=yes,
+ have_visibility=no)
+ CFLAGS=$save_CFLAGS
+ fi
+ AC_MSG_RESULT([$have_visibility])
+ if test x$have_visibility != xno; then
+ symbol_visibility=$VISIBILITY_CFLAGS
+ XORG_CFLAGS="$XORG_CFLAGS $VISIBILITY_CFLAGS"
+ XSERVER_CFLAGS="$XSERVER_CFLAGS $VISIBILITY_CFLAGS"
+ fi
+ fi
+ dnl added to xorg-server.pc
+ AC_SUBST([symbol_visibility])
+ dnl ===================================================================
+
+ PKG_CHECK_MODULES([PCIACCESS], $LIBPCIACCESS)
+ SAVE_LIBS=$LIBS
+ SAVE_CFLAGS=$CFLAGS
+ CFLAGS=$PCIACCESS_CFLAGS
+ LIBS=$PCIACCESS_LIBS
+ AC_CHECK_FUNCS([pci_system_init_dev_mem])
+ AC_CHECK_FUNCS([pci_device_enable])
+ AC_CHECK_FUNCS([pci_device_is_boot_vga])
+ AC_CHECK_FUNCS([pci_device_vgaarb_init])
+ LIBS=$SAVE_LIBS
+ CFLAGS=$SAVE_CFLAGS
+ XORG_SYS_LIBS="$XORG_SYS_LIBS $PCIACCESS_LIBS $GLX_SYS_LIBS"
+ XORG_CFLAGS="$XORG_CFLAGS $PCIACCESS_CFLAGS"
+
+ case $host_os in
+ linux*)
+ if test "x$LNXAPM" = xyes; then
+ XORG_CFLAGS="$XORG_CFLAGS -DXF86PM"
+ fi
+ XORG_OS="linux"
+ XORG_OS_SUBDIR="linux"
+ xorg_bus_linuxpci="yes"
+ linux_acpi="no"
+ case $host_cpu in
+ ia64*)
+ linux_ia64=yes
+ linux_acpi="yes"
+ ;;
+ alpha*)
+ linux_alpha=yes
+ ;;
+ i*86|amd64*|x86_64*)
+ linux_acpi="yes"
+ ;;
+ *)
+ ;;
+ esac
+ ;;
+ freebsd* | kfreebsd*-gnu | dragonfly*)
+ XORG_OS="freebsd"
+ XORG_OS_SUBDIR="bsd"
+ xorg_bus_bsdpci="yes"
+ ;;
+ netbsd*)
+ XORG_OS="netbsd"
+ XORG_OS_SUBDIR="bsd"
+ xorg_bus_bsdpci="yes"
+ ;;
+ openbsd*)
+ if test "x$ac_cv_BSD_APM" = xyes \
+ -o "x$ac_cv_BSD_KQUEUE_APM" = xyes; then
+ XORG_CFLAGS="$XORG_CFLAGS -DXF86PM"
+ fi
+ XORG_OS="openbsd"
+ XORG_OS_SUBDIR="bsd"
+ xorg_bus_bsdpci="yes"
+ ;;
+ solaris*)
+ XORG_OS="solaris"
+ XORG_OS_SUBDIR="solaris"
+ XORG_CFLAGS="$XORG_CFLAGS -DXF86PM"
+ # Use the same stubs as BSD for old functions, since we now
+ # use libpciaccess for PCI
+ xorg_bus_bsdpci="yes"
+ AC_CHECK_HEADERS([sys/kd.h])
+ AC_CHECK_HEADERS([sys/vt.h], [solaris_vt=yes], [solaris_vt=no])
+ # Check for minimum supported release
+ AC_MSG_CHECKING([Solaris version])
+ OS_MINOR=`echo ${host_os}|$SED -e 's/^.*solaris2\.//' -e s'/\..*$//'`
+ if test "${OS_MINOR}" -ge 7 ; then
+ AC_MSG_RESULT(Solaris ${OS_MINOR})
+ else
+ AC_MSG_RESULT(Solaris `echo ${host_os}|$SED -e 's/^.*solaris//`)
+ fi
+ if test "${OS_MINOR}" -lt 8 ; then
+ AC_MSG_ERROR([This release no longer supports Solaris versions older than Solaris 8.])
+ fi
+ AC_CHECK_DECL([__SUNPRO_C], [SUNCC="yes"], [SUNCC="no"])
+ if test "x$SUNCC" = "xyes"; then
+ solaris_asm_inline="yes"
+ fi
+ AC_CHECK_DECL([_LP64], [SOLARIS_64="yes"], [SOLARIS_64="no"])
+
+ case $host_cpu in
+ sparc*)
+ SOLARIS_INOUT_ARCH="sparcv8plus"
+ ;;
+ i*86)
+ if test x$SOLARIS_64 = xyes ; then
+ SOLARIS_INOUT_ARCH="amd64"
+ else
+ SOLARIS_INOUT_ARCH="ia32"
+ fi
+ ;;
+ *)
+ AC_MSG_ERROR([Unsupported Solaris platform. Only SPARC & x86 \
+ are supported on Solaris in this release. If you are \
+ interested in porting Xorg to your platform, please email \
+ xorg@lists.freedesktop.org.]) ;;
+ esac
+ AC_SUBST([SOLARIS_INOUT_ARCH])
+ if test x$solaris_asm_inline = xyes ; then
+ SOLARIS_ASM_CFLAGS='$(top_srcdir)/hw/xfree86/os-support/solaris/solaris-$(SOLARIS_INOUT_ARCH).il'
+ XORG_CFLAGS="${XORG_CFLAGS} "'$(SOLARIS_ASM_CFLAGS)'
+ fi
+ AC_SUBST([SOLARIS_ASM_CFLAGS])
+ if test "x$SUPPORT_PC98" = xauto; then
+ SUPPORT_PC98="no"
+ fi
+ ;;
+ gnu*)
+ XORG_OS="gnu"
+ XORG_OS_SUBDIR="hurd"
+ # Use the same stubs as BSD for old functions, since we now
+ # use libpciaccess for PCI
+ xorg_bus_bsdpci="yes"
+ ;;
+ *)
+ XORG_OS="unknown"
+ XORG_OS_SUBDIR="unknown"
+ AC_MSG_ERROR([m4_text_wrap(m4_join([ ],
+ [Your OS is unknown. Xorg currently only supports Linux,],
+ [Free/Open/Net/DragonFlyBSD, Solaris/OpenSolaris, & GNU Hurd.],
+ [If you are interested in porting Xorg to your platform,],
+ [please email xorg@lists.freedesktop.org.]))])
+ ;;
+ esac
+
+ case $host_cpu in
+ sparc*)
+ xorg_bus_sparc="yes"
+ ;;
+ i*86)
+ if test "x$SUPPORT_PC98" = xauto; then
+ SUPPORT_PC98="yes"
+ fi
+ ;;
+ esac
+
+ if test "x$SUPPORT_PC98" = xauto; then
+ SUPPORT_PC98="no"
+ fi
+ if test "x$SUPPORT_PC98" = xyes; then
+ AC_DEFINE(SUPPORT_PC98, 1, [Support PC98])
+ fi
+ if test "x$XORG_OS_PCI" = x ; then
+ XORG_OS_PCI=$XORG_OS
+ fi
+ if test "x$DGA" = xauto; then
+ PKG_CHECK_MODULES(DGA, $DGAPROTO, [DGA=yes], [DGA=no])
+ fi
+ if test "x$DGA" = xyes; then
+ XORG_MODULES="$XORG_MODULES $DGAPROTO"
+ PKG_CHECK_MODULES(DGA, $DGAPROTO)
+ AC_DEFINE(DGA, 1, [Support DGA extension])
+ AC_DEFINE(XFreeXDGA, 1, [Build XDGA support])
+ fi
+
+ if test "x$XF86VIDMODE" = xauto; then
+ PKG_CHECK_MODULES(XF86VIDMODE, $VIDMODEPROTO, [XF86VIDMODE=yes], [XF86VIDMODE=no])
+ fi
+ if test "x$XF86VIDMODE" = xyes; then
+ XORG_MODULES="$XORG_MODULES $VIDMODEPROTO"
+ PKG_CHECK_MODULES(XF86VIDMODE, $VIDMODEPROTO)
+ AC_DEFINE(XF86VIDMODE, 1, [Support XFree86 Video Mode extension])
+ fi
+
+ if test -n "$XORG_MODULES"; then
+ PKG_CHECK_MODULES(XORG_MODULES, [$XORG_MODULES])
+ XORG_CFLAGS="$XORG_CFLAGS $XORG_MODULES_CFLAGS"
+ XORG_SYS_LIBS="$XORG_SYS_LIBS $XORG_MODULES_LIBS"
+ fi
+
+ AC_SUBST([XORG_LIBS])
+ AC_SUBST([XORG_SYS_LIBS])
+ AC_SUBST([XORG_INCS])
+ AC_SUBST([XORG_OS])
+ AC_SUBST([XORG_OS_SUBDIR])
+
+ AC_PATH_PROG(PERL, perl, no)
+ dnl unlikely as this may be ...
+ if test "x$PERL" = xno; then
+ AC_MSG_ERROR([Perl is required to build the XFree86/Xorg DDX.])
+ fi
+ AC_SUBST(PERL)
+
+ AC_SUBST([XORG_CFLAGS])
+
+ dnl these only go in xorg-config.h
+ XF86CONFIGFILE="xorg.conf"
+ XF86CONFIGDIR="xorg.conf.d"
+ AC_SUBST(XF86CONFIGDIR)
+ CONFIGFILE="$sysconfdir/$XF86CONFIGFILE"
+ LOGPREFIX="$logdir/Xorg."
+ AC_DEFINE(XORG_SERVER, 1, [Building Xorg server])
+ AC_DEFINE(XORGSERVER, 1, [Building Xorg server])
+ AC_DEFINE(XFree86Server, 1, [Building XFree86 server])
+ AC_DEFINE(XFree86LOADER, 1, [Building loadable XFree86 server])
+ AC_DEFINE_UNQUOTED(XORG_VERSION_CURRENT, [$VENDOR_RELEASE], [Current Xorg version])
+ AC_DEFINE(NEED_XF86_TYPES, 1, [Need XFree86 typedefs])
+ AC_DEFINE(NEED_XF86_PROTOTYPES, 1, [Need XFree86 helper functions])
+ AC_DEFINE(__XSERVERNAME__, "Xorg", [Name of X server])
+ AC_DEFINE_DIR(__XCONFIGFILE__, XF86CONFIGFILE, [Name of configuration file])
+ AC_DEFINE_DIR(XF86CONFIGFILE, XF86CONFIGFILE, [Name of configuration file])
+ AC_DEFINE_DIR(__XCONFIGDIR__, XF86CONFIGDIR, [Name of configuration directory])
+ AC_DEFINE_DIR(DEFAULT_MODULE_PATH, moduledir, [Default module search path])
+ AC_DEFINE_DIR(DEFAULT_LIBRARY_PATH, libdir, [Default library install path])
+ AC_DEFINE_DIR(DEFAULT_LOGPREFIX, LOGPREFIX, [Default log location])
+ AC_DEFINE_UNQUOTED(__VENDORDWEBSUPPORT__, ["$VENDOR_WEB"], [Vendor web address for support])
+ AC_DEFINE(XSERVER_LIBPCIACCESS, 1, [Use libpciaccess for all pci manipulation])
+ if test "x$VGAHW" = xyes; then
+ AC_DEFINE(WITH_VGAHW, 1, [Building vgahw module])
+ fi
+
+ driverdir="$moduledir/drivers"
+ AC_SUBST([moduledir])
+ AC_SUBST([driverdir])
+ sdkdir="$includedir/xorg"
+ extdir="$includedir/X11/extensions"
+ sysconfigdir="$datadir/X11/$XF86CONFIGDIR"
+ AC_SUBST([sdkdir])
+ AC_SUBST([extdir])
+ AC_SUBST([sysconfigdir])
+ AC_SUBST([logdir])
+
+ # stuff the ABI versions into the pc file too
+ extract_abi() {
+ grep ^.define.*${1}_VERSION ${srcdir}/hw/xfree86/common/xf86Module.h | tr '(),' ' .' | awk '{ print $4$5 }'
+ }
+ abi_ansic=`extract_abi ANSIC`
+ abi_videodrv=`extract_abi VIDEODRV`
+ abi_xinput=`extract_abi XINPUT`
+ abi_extension=`extract_abi EXTENSION`
+ AC_SUBST([abi_ansic])
+ AC_SUBST([abi_videodrv])
+ AC_SUBST([abi_xinput])
+ AC_SUBST([abi_extension])
+fi
+AM_CONDITIONAL([XORG], [test "x$XORG" = xyes])
+AM_CONDITIONAL([XORG_BUS_LINUXPCI], [test "x$xorg_bus_linuxpci" = xyes])
+AM_CONDITIONAL([XORG_BUS_BSDPCI], [test "x$xorg_bus_bsdpci" = xyes])
+AM_CONDITIONAL([XORG_BUS_SPARC], [test "x$xorg_bus_sparc" = xyes])
+AM_CONDITIONAL([LINUX_IA64], [test "x$linux_ia64" = xyes])
+AM_CONDITIONAL([LINUX_ALPHA], [test "x$linux_alpha" = xyes])
+AM_CONDITIONAL([LNXACPI], [test "x$linux_acpi" = xyes])
+AM_CONDITIONAL([SOLARIS_ASM_INLINE], [test "x$solaris_asm_inline" = xyes])
+AM_CONDITIONAL([SOLARIS_VT], [test "x$solaris_vt" = xyes])
+AM_CONDITIONAL([DGA], [test "x$DGA" = xyes])
+AM_CONDITIONAL([XF86VIDMODE], [test "x$XF86VIDMODE" = xyes])
+
+dnl XWin DDX
+
+AC_MSG_CHECKING([whether to build XWin DDX])
+if test "x$XWIN" = xauto; then
+ case $host_os in
+ cygwin*) XWIN="yes" ;;
+ mingw*) XWIN="yes" ;;
+ *) XWIN="no" ;;
+ esac
+fi
+AC_MSG_RESULT([$XWIN])
+
+if test "x$XWIN" = xyes; then
+ AC_DEFINE_DIR(SYSCONFDIR, sysconfdir, [Location of system.XWinrc])
+ AC_DEFINE_DIR(DEFAULT_LOGDIR, logdir, [Default log location])
+ AC_DEFINE_UNQUOTED(XORG_VERSION_CURRENT, [$VENDOR_RELEASE], [Current Xorg version])
+ AC_DEFINE_UNQUOTED(__VENDORDWEBSUPPORT__, ["$VENDOR_WEB"], [Vendor web address for support])
+ AC_CHECK_TOOL(WINDRES, windres)
+
+ PKG_CHECK_MODULES([XWINMODULES],[x11 xdmcp xau])
+
+ if test "x$WINDOWSWM" = xauto; then
+ PKG_CHECK_EXISTS($WINDOWSWMPROTO, [WINDOWSWM=yes], [WINDOWSWM=no])
+ fi
+ if test "x$WINDOWSWM" = xyes ; then
+ PKG_CHECK_MODULES(WINDOWSWM, $WINDOWSWMPROTO)
+ XWINMODULES_CFLAGS="$XWINMODULES_CFLAGS $WINDOWSWM_CFLAGS"
+ AC_DEFINE(ROOTLESS,1,[Build Rootless code])
+ fi
+
+ case $host_os in
+ cygwin*)
+ XWIN_SERVER_NAME=XWin
+ AC_DEFINE(HAS_DEVWINDOWS,1,[Cygwin has /dev/windows for signaling new win32 messages])
+ ;;
+ mingw*)
+ XWIN_SERVER_NAME=Xming
+ AC_DEFINE(RELOCATE_PROJECTROOT,1,[Make PROJECT_ROOT relative to the xserver location])
+ AC_DEFINE(HAS_WINSOCK,1,[Use Windows sockets])
+ XWIN_SYS_LIBS=-lwinsock2
+ ;;
+ esac
+ XWIN_LIBS="$FB_LIB $MI_LIB $FIXES_LIB $XEXT_LIB $RANDR_LIB $RENDER_LIB $DBE_LIB $RECORD_LIB $GLX_LIBS $XKB_LIB $XKB_STUB_LIB $COMPOSITE_LIB $DAMAGE_LIB $MIEXT_SYNC_LIB $MIEXT_DAMAGE_LIB $MIEXT_SHADOW_LIB $XI_LIB $OS_LIB"
+ XWIN_SYS_LIBS="$XWIN_SYS_LIBS $XWINMODULES_LIBS"
+ AC_SUBST(XWIN_LIBS)
+ AC_SUBST(XWIN_SERVER_NAME)
+ AC_SUBST(XWIN_SYS_LIBS)
+
+ if test "x$DEBUGGING" = xyes; then
+ AC_DEFINE(CYGDEBUG, 1, [Simple debug messages])
+ AC_DEFINE(CYGWINDOWING_DEBUG, 1, [Debug messages for window handling])
+ AC_DEFINE(CYGMULTIWINDOW_DEBUG, 1, [Debug window manager])
+ fi
+
+ AC_DEFINE(DDXOSVERRORF, 1, [Use OsVendorVErrorF])
+ AC_DEFINE(DDXBEFORERESET, 1, [Use ddxBeforeReset ])
+
+dnl XWin with AIGLX requires OpenGL spec files in order to generate wrapper code for native GL functions
+ if [test "x$XWIN" = xyes && test "x$AIGLX" = xyes] ; then
+ if test "x$KHRONOS_SPEC_DIR" = "xauto" ; then
+ PKG_CHECK_MODULES([KHRONOS_OPENGL_REGISTRY], [khronos-opengl-registry])
+ KHRONOS_SPEC_DIR=`pkg-config khronos-opengl-registry --variable=specdir`
+ fi
+ AC_SUBST(KHRONOS_SPEC_DIR)
+ fi
+
+fi
+AM_CONDITIONAL(XWIN, [test "x$XWIN" = xyes])
+AM_CONDITIONAL(XWIN_MULTIWINDOW, [test "x$XWIN" = xyes])
+AM_CONDITIONAL(XWIN_MULTIWINDOWEXTWM, [test "x$XWIN" = xyes && test "x$WINDOWSWM" = xyes])
+AM_CONDITIONAL(XWIN_CLIPBOARD, [test "x$XWIN" = xyes])
+AM_CONDITIONAL(XWIN_GLX_WINDOWS, [test "x$XWIN" = xyes && test "x$AIGLX" = xyes])
+AM_CONDITIONAL(XWIN_NATIVEGDI, [test "x$XWIN" = xyes])
+AM_CONDITIONAL(XWIN_PRIMARYFB, [test "x$XWIN" = xyes])
+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" = xyes; then
+ AC_DEFINE(XQUARTZ,1,[Have Quartz])
+ AC_DEFINE(ROOTLESS,1,[Build Rootless code])
+
+ DARWIN_LIBS="$MI_LIB $OS_LIB $DIX_LIB $MAIN_LIB $FB_LIB $FIXES_LIB $XEXT_LIB $DBE_LIB $RECORD_LIB $RANDR_LIB $RENDER_LIB $DAMAGE_LIB $MIEXT_SYNC_LIB $MIEXT_DAMAGE_LIB $MIEXT_SHADOW_LIB $XI_LIB $XKB_LIB $XKB_STUB_LIB $XPSTUBS_LIB"
+ AC_SUBST([DARWIN_LIBS])
+
+ AC_CHECK_LIB([Xplugin],[xp_init],[:])
+
+ CFLAGS="${CFLAGS} -DROOTLESS_WORKAROUND -DROOTLESS_SAFEALPHA -DNO_ALLOCA"
+
+ PKG_CHECK_MODULES(XPBPROXY, $APPLEWMPROTO $LIBAPPLEWM xfixes x11)
+
+ if test "x$XQUARTZ_SPARKLE" = xyes ; then
+ AC_DEFINE(XQUARTZ_SPARKLE,1,[Support application updating through sparkle.])
+ fi
+
+ if test "x$STANDALONE_XPBPROXY" = xyes ; then
+ AC_DEFINE(STANDALONE_XPBPROXY,1,[Build a standalone xpbproxy])
+ fi
+fi
+
+# Support for objc in autotools is minimal and not documented.
+OBJC='$(CC)'
+OBJCLD='$(CCLD)'
+OBJCLINK='$(LINK)'
+OBJCFLAGS='$(CFLAGS)'
+AC_SUBST([OBJC])
+AC_SUBST([OBJCCLD])
+AC_SUBST([OBJCLINK])
+AC_SUBST([OBJCFLAGS])
+# internal, undocumented automake func follows :(
+_AM_DEPENDENCIES([OBJC])
+AM_CONDITIONAL(XQUARTZ, [test "x$XQUARTZ" = xyes])
+AM_CONDITIONAL(XQUARTZ_SPARKLE, [test "x$XQUARTZ_SPARKLE" != "xno"])
+AM_CONDITIONAL(STANDALONE_XPBPROXY, [test "x$STANDALONE_XPBPROXY" = xyes])
+
+dnl DMX DDX
+PKG_CHECK_MODULES(
+ [DMXMODULES],
+ [xmuu $LIBXEXT x11 xrender xfixes $LIBXI $DMXPROTO xau $XDMCP_MODULES],
+ [PKG_CHECK_MODULES(
+ [XDMXCONFIG_DEP],
+ [xaw7 xmu xt xpm x11],
+ [have_dmx=yes],
+ [have_dmx=no])],
+ [have_dmx=no])
+AC_MSG_CHECKING([whether to build Xdmx DDX])
+if test "x$DMX" = xauto; then
+ DMX="$have_dmx"
+ case $host_os in
+ cygwin*) DMX="no" ;;
+ darwin*) DMX="no" ;;
+ esac
+fi
+AC_MSG_RESULT([$DMX])
+AM_CONDITIONAL(DMX, [test "x$DMX" = xyes])
+
+if test "x$DMX" = xyes; then
+ if test "x$have_dmx" = xno; then
+ AC_MSG_ERROR([Xdmx build explicitly requested, but required
+ modules not found.])
+ fi
+ DMX_INCLUDES="$XEXT_INC $RENDER_INC $RECORD_INC"
+ XDMX_CFLAGS="$DMXMODULES_CFLAGS"
+ XDMX_LIBS="$FB_LIB $MI_LIB $XEXT_LIB $RENDER_LIB $RECORD_LIB $XI_LIB $XKB_LIB $XKB_STUB_LIB $MIEXT_SYNC_LIB $MIEXT_SHADOW_LIB $MIEXT_DAMAGE_LIB $COMPOSITE_LIB $DAMAGE_LIB $MAIN_LIB $DIX_LIB $CONFIG_LIB $OS_LIB $FIXES_LIB"
+ XDMX_SYS_LIBS="$DMXMODULES_LIBS"
+ AC_SUBST([XDMX_CFLAGS])
+ AC_SUBST([XDMX_LIBS])
+ AC_SUBST([XDMX_SYS_LIBS])
+
+dnl USB sources in DMX require <linux/input.h>
+ AC_CHECK_HEADER([linux/input.h], DMX_BUILD_USB="yes",
+ DMX_BUILD_USB="no")
+dnl Linux sources in DMX require <linux/keyboard.h>
+ AC_CHECK_HEADER([linux/keyboard.h], DMX_BUILD_LNX="yes",
+ DMX_BUILD_LNX="no")
+ AC_SUBST(XDMXCONFIG_DEP_CFLAGS)
+ AC_SUBST(XDMXCONFIG_DEP_LIBS)
+ PKG_CHECK_MODULES([DMXEXAMPLES_DEP], [$LIBDMX $LIBXEXT x11])
+ AC_SUBST(DMXEXAMPLES_DEP_LIBS)
+ PKG_CHECK_MODULES([DMXXMUEXAMPLES_DEP], [$LIBDMX xmu $LIBXEXT x11])
+ AC_SUBST(DMXXMUEXAMPLES_DEP_LIBS)
+ PKG_CHECK_MODULES([DMXXIEXAMPLES_DEP], [$LIBDMX $LIBXI $LIBXEXT x11])
+ AC_SUBST(DMXXIEXAMPLES_DEP_LIBS)
+ PKG_CHECK_MODULES([XTSTEXAMPLES_DEP], [$LIBXTST $LIBXEXT x11])
+ AC_SUBST(XTSTEXAMPLES_DEP_LIBS)
+ PKG_CHECK_MODULES([XRESEXAMPLES_DEP], [xres $LIBXEXT x11])
+ AC_SUBST(XRESEXAMPLES_DEP_LIBS)
+ PKG_CHECK_MODULES([X11EXAMPLES_DEP], [$LIBXEXT x11])
+ AC_SUBST(X11EXAMPLES_DEP_LIBS)
+
+fi
+AM_CONDITIONAL([DMX_BUILD_LNX], [test "x$DMX_BUILD_LNX" = xyes])
+AM_CONDITIONAL([DMX_BUILD_USB], [test "x$DMX_BUILD_USB" = xyes])
+
+dnl kdrive DDX
+
+XEPHYR_LIBS=
+XEPHYR_INCS=
+
+AM_CONDITIONAL(KDRIVE, [test x$KDRIVE = xyes])
+
+if test "$KDRIVE" = yes; then
+ AC_DEFINE(KDRIVESERVER,1,[Build Kdrive X server])
+ AC_DEFINE(KDRIVEDDXACTIONS,,[Build kdrive ddx])
+
+ AC_CHECK_HEADERS([linux/fb.h])
+ if test "$ac_cv_header_linux_fb_h" = yes && test "x$XFBDEV" = xauto; then
+ XFBDEV=yes
+ fi
+
+ if test "x$XFBDEV" = xyes; then
+ KDRIVEFBDEVLIB=yes
+ AC_DEFINE(KDRIVEFBDEV, 1, [Build fbdev-based kdrive server])
+ fi
+
+
+ PKG_CHECK_MODULES([TSLIB], [tslib-0.0], [HAVE_TSLIB="yes"], [HAVE_TSLIB="no"])
+ if test "x$HAVE_TSLIB" = xno; then
+ AC_CHECK_LIB(ts, ts_open, [
+ HAVE_TSLIB="yes"
+ TSLIB_LIBS="-lts"
+ ])
+ fi
+
+ if test "xTSLIB" = xauto; then
+ TSLIB="$HAVE_TSLIB"
+ fi
+
+ if test "x$TSLIB" = xyes; then
+ if ! test "x$HAVE_TSLIB" = xyes; then
+ AC_MSG_ERROR([tslib must be installed to build the tslib driver. See http://tslib.berlios.de/])
+ else
+ AC_DEFINE(TSLIB, 1, [Have tslib support])
+ fi
+ fi
+
+ if test "x$KDRIVE_KBD" = xyes; then
+ AC_DEFINE(KDRIVE_KBD, 1, [Enable KDrive kbd driver])
+ fi
+ if test "x$KDRIVE_EVDEV" = xyes; then
+ AC_DEFINE(KDRIVE_EVDEV, 1, [Enable KDrive evdev driver])
+ fi
+ if test "x$KDRIVE_MOUSE" = xyes; then
+ AC_DEFINE(KDRIVE_MOUSE, 1, [Enable KDrive mouse driver])
+ fi
+
+ XEPHYR_REQUIRED_LIBS="x11 $LIBXEXT xau xdmcp"
+ 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 $LIBGL libdrm"
+ fi
+
+ PKG_CHECK_MODULES(XEPHYR, $XEPHYR_REQUIRED_LIBS, [xephyr="yes"], [xephyr="no"])
+ if test "x$XEPHYR" = xauto; then
+ XEPHYR=$xephyr
+ fi
+ if test "x$XEPHYR" = xyes && test "x$xephyr" = xno; then
+ AC_MSG_ERROR([Xephyr dependencies missing])
+ fi
+
+ # Xephyr needs nanosleep() which is in librt on Solaris
+ AC_CHECK_FUNC([nanosleep], [],
+ AC_CHECK_LIB([rt], [nanosleep], XEPHYR_LIBS="$XEPHYR_LIBS -lrt"))
+
+ # damage shadow extension glx (NOTYET) fb mi
+ KDRIVE_INC='-I$(top_srcdir)/hw/kdrive/src'
+ KDRIVE_PURE_INCS="$KDRIVE_INC $MIEXT_SYNC_INC $MIEXT_DAMAGE_INC $MIEXT_SHADOW_INC $XEXT_INC $FB_INC $MI_INC"
+ KDRIVE_OS_INC='-I$(top_srcdir)/hw/kdrive/linux'
+ KDRIVE_INCS="$KDRIVE_PURE_INCS $KDRIVE_OS_INC"
+
+ KDRIVE_CFLAGS="$XSERVER_CFLAGS -DHAVE_KDRIVE_CONFIG_H $TSLIB_CFLAGS"
+
+ KDRIVE_PURE_LIBS="$FB_LIB $MI_LIB $FIXES_LIB $XEXT_LIB $DBE_LIB $RECORD_LIB $GLX_LIBS $RANDR_LIB $RENDER_LIB $DAMAGE_LIB $MIEXT_SYNC_LIB $MIEXT_DAMAGE_LIB $MIEXT_SHADOW_LIB $XI_LIB $XKB_LIB $XKB_STUB_LIB $COMPOSITE_LIB $OS_LIB"
+ KDRIVE_LIB='$(top_builddir)/hw/kdrive/src/libkdrive.la'
+ case $host_os in
+ *linux*)
+ KDRIVE_OS_LIB='$(top_builddir)/hw/kdrive/linux/liblinux.la'
+ KDRIVELINUX=yes
+ if test "x$KDRIVE_EVDEV" = xauto; then
+ KDRIVE_EVDEV=yes
+ fi
+ if test "x$KDRIVE_KBD" = xauto; then
+ KDRIVE_KBD=yes
+ fi
+ if test "x$KDRIVE_MOUSE" = xauto; then
+ KDRIVE_MOUSE=yes
+ fi
+ ;;
+ *)
+ if test "x$KDRIVE_EVDEV" = xauto; then
+ KDRIVE_EVDEV=no
+ fi
+ if test "x$KDRIVE_KBD" = xauto; then
+ KDRIVE_KBD=no
+ fi
+ if test "x$KDRIVE_MOUSE" = xauto; then
+ KDRIVE_MOUSE=no
+ fi
+ ;;
+ esac
+ KDRIVE_STUB_LIB='$(top_builddir)/hw/kdrive/src/libkdrivestubs.la'
+ KDRIVE_LOCAL_LIBS="$MAIN_LIB $DIX_LIB $KDRIVE_LIB $KDRIVE_STUB_LIB"
+ KDRIVE_LOCAL_LIBS="$KDRIVE_LOCAL_LIBS $FB_LIB $MI_LIB $KDRIVE_PURE_LIBS"
+ KDRIVE_LOCAL_LIBS="$KDRIVE_LOCAL_LIBS $KDRIVE_OS_LIB"
+ KDRIVE_LIBS="$KDRIVE_LOCAL_LIBS $XSERVER_SYS_LIBS $GLX_SYS_LIBS $DLOPEN_LIBS $TSLIB_LIBS"
+
+ AC_SUBST([XEPHYR_LIBS])
+ AC_SUBST([XEPHYR_INCS])
+fi
+AC_SUBST([KDRIVE_INCS])
+AC_SUBST([KDRIVE_PURE_INCS])
+AC_SUBST([KDRIVE_CFLAGS])
+AC_SUBST([KDRIVE_PURE_LIBS])
+AC_SUBST([KDRIVE_LOCAL_LIBS])
+AC_SUBST([KDRIVE_LIBS])
+AM_CONDITIONAL(KDRIVELINUX, [test "x$KDRIVELINUX" = xyes])
+AM_CONDITIONAL(KDRIVE_EVDEV, [test "x$KDRIVE_EVDEV" = xyes])
+AM_CONDITIONAL(KDRIVE_KBD, [test "x$KDRIVE_KBD" = xyes])
+AM_CONDITIONAL(KDRIVE_MOUSE, [test "x$KDRIVE_MOUSE" = xyes])
+AM_CONDITIONAL(TSLIB, [test "x$HAVE_TSLIB" = xyes])
+AM_CONDITIONAL(KDRIVEFBDEV, [test "x$XFBDEV" = 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(XFAKESERVER, [test "x$KDRIVE" = xyes && test "x$XFAKE" = xyes])
+
+dnl and the rest of these are generic, so they're in config.h
+dnl
+dnl though, thanks to the passing of some significant amount of time, the
+dnl above is probably a complete fallacy, and you should not rely on it.
+dnl but this is still actually better than imake, honest. -daniels
+
+AC_TRY_COMPILE([
+#include <features.h>
+#ifndef __GLIBC__
+#error not glibc
+#endif
+], [], [AC_DEFINE(_GNU_SOURCE, 1,
+ [ Enable GNU and other extensions to the C environment for glibc])])
+
+AC_DEFINE_DIR(PROJECTROOT, prefix, [Overall prefix])
+
+AC_SUBST([RELEASE_DATE])
+BUILD_DATE="`date +'%Y%m%d'`"
+AC_SUBST([BUILD_DATE])
+BUILD_TIME="`date +'1%H%M%S'`"
+AC_SUBST([BUILD_TIME])
+
+DIX_CFLAGS="-DHAVE_DIX_CONFIG_H $XSERVER_CFLAGS"
+
+AC_SUBST([DIX_CFLAGS])
+
+AC_SUBST([libdir])
+AC_SUBST([exec_prefix])
+AC_SUBST([prefix])
+
+AC_CONFIG_COMMANDS([sdksyms], [touch hw/xfree86/loader/sdksyms.dep])
+
+AC_OUTPUT([
+Makefile
+glx/Makefile
+include/Makefile
+composite/Makefile
+damageext/Makefile
+dbe/Makefile
+dix/Makefile
+doc/Makefile
+doc/dtrace/Makefile
+man/Makefile
+fb/Makefile
+record/Makefile
+config/Makefile
+mi/Makefile
+miext/Makefile
+miext/sync/Makefile
+miext/damage/Makefile
+miext/shadow/Makefile
+miext/cw/Makefile
+miext/rootless/Makefile
+os/Makefile
+randr/Makefile
+render/Makefile
+xkb/Makefile
+Xext/Makefile
+Xi/Makefile
+xfixes/Makefile
+exa/Makefile
+hw/Makefile
+hw/xfree86/Makefile
+hw/xfree86/common/Makefile
+hw/xfree86/common/xf86Build.h
+hw/xfree86/ddc/Makefile
+hw/xfree86/dixmods/Makefile
+hw/xfree86/dixmods/extmod/Makefile
+hw/xfree86/doc/Makefile
+hw/xfree86/dri/Makefile
+hw/xfree86/dri2/Makefile
+hw/xfree86/exa/Makefile
+hw/xfree86/exa/man/Makefile
+hw/xfree86/fbdevhw/Makefile
+hw/xfree86/fbdevhw/man/Makefile
+hw/xfree86/i2c/Makefile
+hw/xfree86/int10/Makefile
+hw/xfree86/loader/Makefile
+hw/xfree86/man/Makefile
+hw/xfree86/modes/Makefile
+hw/xfree86/os-support/Makefile
+hw/xfree86/os-support/bsd/Makefile
+hw/xfree86/os-support/bus/Makefile
+hw/xfree86/os-support/hurd/Makefile
+hw/xfree86/os-support/misc/Makefile
+hw/xfree86/os-support/linux/Makefile
+hw/xfree86/os-support/solaris/Makefile
+hw/xfree86/parser/Makefile
+hw/xfree86/ramdac/Makefile
+hw/xfree86/shadowfb/Makefile
+hw/xfree86/vbe/Makefile
+hw/xfree86/vgahw/Makefile
+hw/xfree86/x86emu/Makefile
+hw/xfree86/xaa/Makefile
+hw/xfree86/utils/Makefile
+hw/xfree86/utils/man/Makefile
+hw/xfree86/utils/cvt/Makefile
+hw/xfree86/utils/gtf/Makefile
+hw/dmx/config/Makefile
+hw/dmx/config/man/Makefile
+hw/dmx/doc/Makefile
+hw/dmx/doxygen/doxygen.conf
+hw/dmx/doxygen/Makefile
+hw/dmx/examples/Makefile
+hw/dmx/input/Makefile
+hw/dmx/glxProxy/Makefile
+hw/dmx/Makefile
+hw/dmx/man/Makefile
+hw/vfb/Makefile
+hw/vfb/man/Makefile
+hw/xnest/Makefile
+hw/xnest/man/Makefile
+hw/xwin/Makefile
+hw/xwin/glx/Makefile
+hw/xwin/man/Makefile
+hw/xquartz/Makefile
+hw/xquartz/GL/Makefile
+hw/xquartz/bundle/Makefile
+hw/xquartz/man/Makefile
+hw/xquartz/mach-startup/Makefile
+hw/xquartz/pbproxy/Makefile
+hw/xquartz/xpr/Makefile
+hw/kdrive/Makefile
+hw/kdrive/ephyr/Makefile
+hw/kdrive/ephyr/man/Makefile
+hw/kdrive/fake/Makefile
+hw/kdrive/fbdev/Makefile
+hw/kdrive/linux/Makefile
+hw/kdrive/src/Makefile
+test/Makefile
+test/xi2/Makefile
+xserver.ent
+xorg-server.pc
+])
diff --git a/xorg-server/dbe/dbe.c b/xorg-server/dbe/dbe.c
index d1074a2fb..51bbdc6c9 100644
--- a/xorg-server/dbe/dbe.c
+++ b/xorg-server/dbe/dbe.c
@@ -1,1661 +1,1658 @@
-/******************************************************************************
- *
- * Copyright (c) 1994, 1995 Hewlett-Packard Company
- *
- * 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 HEWLETT-PACKARD COMPANY 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 Hewlett-Packard
- * Company 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 Hewlett-Packard Company.
- *
- * DIX DBE code
- *
- *****************************************************************************/
-
-
-/* INCLUDES */
-
-#ifdef HAVE_DIX_CONFIG_H
-#include <dix-config.h>
-#endif
-
-#include <string.h>
-#if HAVE_STDINT_H
-#include <stdint.h>
-#elif !defined(UINT32_MAX)
-#define UINT32_MAX 0xffffffffU
-#endif
-
-#include <X11/X.h>
-#include <X11/Xproto.h>
-#include "scrnintstr.h"
-#include "extnsionst.h"
-#include "gcstruct.h"
-#include "dixstruct.h"
-#define NEED_DBE_PROTOCOL
-#include "dbestruct.h"
-#include "midbe.h"
-#include "xace.h"
-
-/* GLOBALS */
-
-/* These are globals for use by DDX */
-DevPrivateKeyRec dbeScreenPrivKeyRec;
-DevPrivateKeyRec dbeWindowPrivKeyRec;
-
-/* These are globals for use by DDX */
-RESTYPE dbeDrawableResType;
-RESTYPE dbeWindowPrivResType;
-
-/* Used to generate DBE's BadBuffer error. */
-static int dbeErrorBase;
-
-/******************************************************************************
- *
- * DBE DIX Procedure: DbeStubScreen
- *
- * Description:
- *
- * This is function stubs the function pointers in the given DBE screen
- * private and increments the number of stubbed screens.
- *
- *****************************************************************************/
-
-static void
-DbeStubScreen(DbeScreenPrivPtr pDbeScreenPriv, int *nStubbedScreens)
-{
- /* Stub DIX. */
- pDbeScreenPriv->SetupBackgroundPainter = NULL;
-
- /* Do not unwrap PositionWindow nor DestroyWindow. If the DDX
- * initialization function failed, we assume that it did not wrap
- * PositionWindow. Also, DestroyWindow is only wrapped if the DDX
- * initialization function succeeded.
- */
-
- /* Stub DDX. */
- pDbeScreenPriv->GetVisualInfo = NULL;
- pDbeScreenPriv->AllocBackBufferName = NULL;
- pDbeScreenPriv->SwapBuffers = NULL;
- pDbeScreenPriv->BeginIdiom = NULL;
- pDbeScreenPriv->EndIdiom = NULL;
- pDbeScreenPriv->WinPrivDelete = NULL;
- pDbeScreenPriv->ResetProc = NULL;
-
- (*nStubbedScreens)++;
-
-} /* DbeStubScreen() */
-
-
-
-/******************************************************************************
- *
- * DBE DIX Procedure: ProcDbeGetVersion
- *
- * Description:
- *
- * This function is for processing a DbeGetVersion request.
- * This request returns the major and minor version numbers of this
- * extension.
- *
- * Return Values:
- *
- * Success
- *
- *****************************************************************************/
-
-static int
-ProcDbeGetVersion(ClientPtr client)
-{
- /* REQUEST(xDbeGetVersionReq); */
- xDbeGetVersionReply rep;
- register int n;
-
-
- REQUEST_SIZE_MATCH(xDbeGetVersionReq);
-
- rep.type = X_Reply;
- rep.length = 0;
- rep.sequenceNumber = client->sequence;
- rep.majorVersion = DBE_MAJOR_VERSION;
- rep.minorVersion = DBE_MINOR_VERSION;
-
- if (client->swapped)
- {
- swaps(&rep.sequenceNumber, n);
- }
-
- WriteToClient(client, sizeof(xDbeGetVersionReply), (char *)&rep);
-
- return Success;
-
-} /* ProcDbeGetVersion() */
-
-
-/******************************************************************************
- *
- * DBE DIX Procedure: ProcDbeAllocateBackBufferName
- *
- * Description:
- *
- * This function is for processing a DbeAllocateBackBufferName request.
- * This request allocates a drawable ID used to refer to the back buffer
- * of a window.
- *
- * Return Values:
- *
- * BadAlloc - server can not allocate resources
- * BadIDChoice - id is out of range for client; id is already in use
- * BadMatch - window is not an InputOutput window;
- * visual of window is not on list returned by
- * DBEGetVisualInfo;
- * BadValue - invalid swap action is specified
- * BadWindow - window is not a valid window
- * Success
- *
- *****************************************************************************/
-
-static int
-ProcDbeAllocateBackBufferName(ClientPtr client)
-{
- REQUEST(xDbeAllocateBackBufferNameReq);
- WindowPtr pWin;
- DbeScreenPrivPtr pDbeScreenPriv;
- DbeWindowPrivPtr pDbeWindowPriv;
- XdbeScreenVisualInfo scrVisInfo;
- register int i;
- Bool visualMatched = FALSE;
- xDbeSwapAction swapAction;
- VisualID visual;
- int status;
- int add_index;
-
-
- REQUEST_SIZE_MATCH(xDbeAllocateBackBufferNameReq);
-
- /* The window must be valid. */
- status = dixLookupWindow(&pWin, stuff->window, client, DixManageAccess);
- if (status != Success)
- return status;
-
- /* The window must be InputOutput. */
- if (pWin->drawable.class != InputOutput)
- {
- return BadMatch;
- }
-
- /* The swap action must be valid. */
- swapAction = stuff->swapAction; /* use local var for performance. */
- if ((swapAction != XdbeUndefined ) &&
- (swapAction != XdbeBackground) &&
- (swapAction != XdbeUntouched ) &&
- (swapAction != XdbeCopied ))
- {
- return BadValue;
- }
-
- /* The id must be in range and not already in use. */
- LEGAL_NEW_RESOURCE(stuff->buffer, client);
-
- /* The visual of the window must be in the list returned by
- * GetVisualInfo.
- */
- pDbeScreenPriv = DBE_SCREEN_PRIV_FROM_WINDOW(pWin);
- if (!pDbeScreenPriv->GetVisualInfo)
- return BadMatch; /* screen doesn't support double buffering */
-
- if (!(*pDbeScreenPriv->GetVisualInfo)(pWin->drawable.pScreen, &scrVisInfo))
- {
- /* GetVisualInfo() failed to allocate visual info data. */
- return BadAlloc;
- }
-
- /* See if the window's visual is on the list. */
- visual = wVisual(pWin);
- for (i = 0; (i < scrVisInfo.count) && !visualMatched; i++)
- {
- if (scrVisInfo.visinfo[i].visual == visual)
- {
- visualMatched = TRUE;
- }
- }
-
- /* Free what was allocated by the GetVisualInfo() call above. */
- free(scrVisInfo.visinfo);
-
- if (!visualMatched)
- {
- return BadMatch;
- }
-
- if ((pDbeWindowPriv = DBE_WINDOW_PRIV(pWin)) == NULL)
- {
- /* There is no buffer associated with the window.
- * Allocate a window priv.
- */
-
- pDbeWindowPriv = dixAllocateObjectWithPrivates(DbeWindowPrivRec, PRIVATE_DBE_WINDOW);
- if (!pDbeWindowPriv)
- return BadAlloc;
-
- /* Fill out window priv information. */
- pDbeWindowPriv->pWindow = pWin;
- pDbeWindowPriv->width = pWin->drawable.width;
- pDbeWindowPriv->height = pWin->drawable.height;
- pDbeWindowPriv->x = pWin->drawable.x;
- pDbeWindowPriv->y = pWin->drawable.y;
- pDbeWindowPriv->nBufferIDs = 0;
-
- /* Set the buffer ID array pointer to the initial (static) array). */
- pDbeWindowPriv->IDs = pDbeWindowPriv->initIDs;
-
- /* Initialize the buffer ID list. */
- pDbeWindowPriv->maxAvailableIDs = DBE_INIT_MAX_IDS;
- pDbeWindowPriv->IDs[0] = stuff->buffer;
-
- add_index = 0;
- for (i = 0; i < DBE_INIT_MAX_IDS; i++)
- {
- pDbeWindowPriv->IDs[i] = DBE_FREE_ID_ELEMENT;
- }
-
- /* Actually connect the window priv to the window. */
- dixSetPrivate(&pWin->devPrivates, dbeWindowPrivKey, pDbeWindowPriv);
-
- } /* if -- There is no buffer associated with the window. */
-
- else
- {
- /* A buffer is already associated with the window.
- * Add the new buffer ID to the array, reallocating the array memory
- * if necessary.
- */
-
- /* Determine if there is a free element in the ID array. */
- for (i = 0; i < pDbeWindowPriv->maxAvailableIDs; i++)
- {
- if (pDbeWindowPriv->IDs[i] == DBE_FREE_ID_ELEMENT)
- {
- /* There is still room in the ID array. */
- break;
- }
- }
-
- if (i == pDbeWindowPriv->maxAvailableIDs)
- {
- /* No more room in the ID array -- reallocate another array. */
- XID *pIDs;
-
- /* Setup an array pointer for the realloc operation below. */
- if (pDbeWindowPriv->maxAvailableIDs == DBE_INIT_MAX_IDS)
- {
- /* We will malloc a new array. */
- pIDs = NULL;
- }
- else
- {
- /* We will realloc a new array. */
- pIDs = pDbeWindowPriv->IDs;
- }
-
- /* malloc/realloc a new array and initialize all elements to 0. */
- pDbeWindowPriv->IDs = (XID *)realloc(pIDs,
- (pDbeWindowPriv->maxAvailableIDs+DBE_INCR_MAX_IDS)*sizeof(XID));
- if (!pDbeWindowPriv->IDs)
- {
- return BadAlloc;
- }
- memset(&pDbeWindowPriv->IDs[pDbeWindowPriv->nBufferIDs], 0,
- (pDbeWindowPriv->maxAvailableIDs + DBE_INCR_MAX_IDS -
- pDbeWindowPriv->nBufferIDs) * sizeof(XID));
-
- if (pDbeWindowPriv->maxAvailableIDs == DBE_INIT_MAX_IDS)
- {
- /* We just went from using the initial (static) array to a
- * newly allocated array. Copy the IDs from the initial array
- * to the new array.
- */
- memcpy(pDbeWindowPriv->IDs, pDbeWindowPriv->initIDs,
- DBE_INIT_MAX_IDS * sizeof(XID));
- }
-
- pDbeWindowPriv->maxAvailableIDs += DBE_INCR_MAX_IDS;
- }
-
- add_index = i;
-
- } /* else -- A buffer is already associated with the window. */
-
-
- /* Call the DDX routine to allocate the back buffer. */
- status = (*pDbeScreenPriv->AllocBackBufferName)(pWin, stuff->buffer,
- stuff->swapAction);
-
- if (status == Success)
- {
- pDbeWindowPriv->IDs[add_index] = stuff->buffer;
- if (!AddResource(stuff->buffer, dbeWindowPrivResType,
- (pointer)pDbeWindowPriv))
- {
- pDbeWindowPriv->IDs[add_index] = DBE_FREE_ID_ELEMENT;
-
- if (pDbeWindowPriv->nBufferIDs == 0) {
- status = BadAlloc;
- goto out_free;
- }
- }
- } else {
- /* The DDX buffer allocation routine failed for the first buffer of
- * this window.
- */
- if (pDbeWindowPriv->nBufferIDs == 0) {
- goto out_free;
- }
- }
-
- /* Increment the number of buffers (XIDs) associated with this window. */
- pDbeWindowPriv->nBufferIDs++;
-
- /* Set swap action on all calls. */
- pDbeWindowPriv->swapAction = stuff->swapAction;
-
- return status;
-
-out_free:
- dixSetPrivate(&pWin->devPrivates, dbeWindowPrivKey, NULL);
- free(pDbeWindowPriv);
- return status;
-
-} /* ProcDbeAllocateBackBufferName() */
-
-
-/******************************************************************************
- *
- * DBE DIX Procedure: ProcDbeDeallocateBackBufferName
- *
- * Description:
- *
- * This function is for processing a DbeDeallocateBackBufferName request.
- * This request frees a drawable ID that was obtained by a
- * DbeAllocateBackBufferName request.
- *
- * Return Values:
- *
- * BadBuffer - buffer to deallocate is not associated with a window
- * Success
- *
- *****************************************************************************/
-
-static int
-ProcDbeDeallocateBackBufferName(ClientPtr client)
-{
- REQUEST(xDbeDeallocateBackBufferNameReq);
- DbeWindowPrivPtr pDbeWindowPriv;
- int rc, i;
- pointer val;
-
-
- REQUEST_SIZE_MATCH(xDbeDeallocateBackBufferNameReq);
-
- /* Buffer name must be valid */
- rc = dixLookupResourceByType((pointer *)&pDbeWindowPriv, stuff->buffer,
- dbeWindowPrivResType, client,
- DixDestroyAccess);
- if (rc != Success)
- return rc;
-
- rc = dixLookupResourceByType(&val, stuff->buffer, dbeDrawableResType,
- client, DixDestroyAccess);
- if (rc != Success)
- return rc;
-
- /* Make sure that the id is valid for the window.
- * This is paranoid code since we already looked up the ID by type
- * above.
- */
-
- for (i = 0; i < pDbeWindowPriv->nBufferIDs; i++)
- {
- /* Loop through the ID list to find the ID. */
- if (pDbeWindowPriv->IDs[i] == stuff->buffer)
- {
- break;
- }
- }
-
- if (i == pDbeWindowPriv->nBufferIDs)
- {
- /* We did not find the ID in the ID list. */
- client->errorValue = stuff->buffer;
- return dbeErrorBase + DbeBadBuffer;
- }
-
- FreeResource(stuff->buffer, RT_NONE);
-
- return Success;
-
-} /* ProcDbeDeallocateBackBufferName() */
-
-
-/******************************************************************************
- *
- * DBE DIX Procedure: ProcDbeSwapBuffers
- *
- * Description:
- *
- * This function is for processing a DbeSwapBuffers request.
- * This request swaps the buffers for all windows listed, applying the
- * appropriate swap action for each window.
- *
- * Return Values:
- *
- * BadAlloc - local allocation failed; this return value is not defined
- * by the protocol
- * BadMatch - a window in request is not double-buffered; a window in
- * request is listed more than once
- * BadValue - invalid swap action is specified; no swap action is
- * specified
- * BadWindow - a window in request is not valid
- * Success
- *
- *****************************************************************************/
-
-static int
-ProcDbeSwapBuffers(ClientPtr client)
-{
- REQUEST(xDbeSwapBuffersReq);
- WindowPtr pWin;
- DbeScreenPrivPtr pDbeScreenPriv;
- DbeSwapInfoPtr swapInfo;
- xDbeSwapInfo *dbeSwapInfo;
- int error;
- register int i, j;
- int nStuff;
-
-
- REQUEST_AT_LEAST_SIZE(xDbeSwapBuffersReq);
- nStuff = stuff->n; /* use local variable for performance. */
-
- if (nStuff == 0)
- {
- return Success;
- }
-
- if (nStuff > UINT32_MAX / sizeof(DbeSwapInfoRec))
- return BadAlloc;
-
- /* Get to the swap info appended to the end of the request. */
- dbeSwapInfo = (xDbeSwapInfo *)&stuff[1];
-
- /* Allocate array to record swap information. */
- swapInfo = (DbeSwapInfoPtr)malloc(nStuff * sizeof(DbeSwapInfoRec));
- if (swapInfo == NULL)
- {
- return BadAlloc;
- }
-
-
- for (i = 0; i < nStuff; i++)
- {
- /* Check all windows to swap. */
-
- /* Each window must be a valid window - BadWindow. */
- error = dixLookupWindow(&pWin, dbeSwapInfo[i].window, client,
- DixWriteAccess);
- if (error != Success) {
- free(swapInfo);
- return error;
- }
-
- /* Each window must be double-buffered - BadMatch. */
- if (DBE_WINDOW_PRIV(pWin) == NULL)
- {
- free(swapInfo);
- return BadMatch;
- }
-
- /* Each window must only be specified once - BadMatch. */
- for (j = i + 1; j < nStuff; j++)
- {
- if (dbeSwapInfo[i].window == dbeSwapInfo[j].window)
- {
- free(swapInfo);
- return BadMatch;
- }
- }
-
- /* Each swap action must be valid - BadValue. */
- if ((dbeSwapInfo[i].swapAction != XdbeUndefined ) &&
- (dbeSwapInfo[i].swapAction != XdbeBackground) &&
- (dbeSwapInfo[i].swapAction != XdbeUntouched ) &&
- (dbeSwapInfo[i].swapAction != XdbeCopied ))
- {
- free(swapInfo);
- return BadValue;
- }
-
- /* Everything checks out OK. Fill in the swap info array. */
- swapInfo[i].pWindow = pWin;
- swapInfo[i].swapAction = dbeSwapInfo[i].swapAction;
-
- } /* for (i = 0; i < nStuff; i++) */
-
-
- /* Call the DDX routine to perform the swap(s). The DDX routine should
- * scan the swap list (swap info), swap any buffers that it knows how to
- * handle, delete them from the list, and update nStuff to indicate how
- * many windows it did not handle.
- *
- * This scheme allows a range of sophistication in the DDX SwapBuffers()
- * implementation. Naive implementations could just swap the first buffer
- * in the list, move the last buffer to the front, decrement nStuff, and
- * return. The next level of sophistication could be to scan the whole
- * list for windows on the same screen. Up another level, the DDX routine
- * could deal with cross-screen synchronization.
- */
-
- while (nStuff > 0)
- {
- pDbeScreenPriv = DBE_SCREEN_PRIV_FROM_WINDOW(swapInfo[0].pWindow);
- error = (*pDbeScreenPriv->SwapBuffers)(client, &nStuff, swapInfo);
- if (error != Success)
- {
- free(swapInfo);
- return error;
- }
- }
-
- free(swapInfo);
- return Success;
-
-} /* ProcDbeSwapBuffers() */
-
-
-/******************************************************************************
- *
- * DBE DIX Procedure: ProcDbeBeginIdiom
- *
- * Description:
- *
- * This function is for processing a DbeBeginIdiom request.
- * This request informs the server that a complex swap will immediately
- * follow this request.
- *
- * Return Values:
- *
- * Success
- *
- *****************************************************************************/
-
-static int
-ProcDbeBeginIdiom(ClientPtr client)
-{
- /* REQUEST(xDbeBeginIdiomReq); */
- DbeScreenPrivPtr pDbeScreenPriv;
- register int i;
-
-
- REQUEST_SIZE_MATCH(xDbeBeginIdiomReq);
-
- for (i = 0; i < screenInfo.numScreens; i++)
- {
- pDbeScreenPriv = DBE_SCREEN_PRIV(screenInfo.screens[i]);
-
- /* Call the DDX begin idiom procedure if there is one. */
- if (pDbeScreenPriv->BeginIdiom)
- {
- (*pDbeScreenPriv->BeginIdiom)(client);
- }
- }
-
- return Success;
-
-} /* ProcDbeBeginIdiom() */
-
-
-/******************************************************************************
- *
- * DBE DIX Procedure: ProcDbeGetVisualInfo
- *
- * Description:
- *
- * This function is for processing a ProcDbeGetVisualInfo request.
- * This request returns information about which visuals support
- * double buffering.
- *
- * Return Values:
- *
- * BadDrawable - value in screen specifiers is not a valid drawable
- * Success
- *
- *****************************************************************************/
-
-static int
-ProcDbeGetVisualInfo(ClientPtr client)
-{
- REQUEST(xDbeGetVisualInfoReq);
- DbeScreenPrivPtr pDbeScreenPriv;
- xDbeGetVisualInfoReply rep;
- Drawable *drawables;
- DrawablePtr *pDrawables = NULL;
- register int i, j, n, rc;
- register int count; /* number of visual infos in reply */
- register int length; /* length of reply */
- ScreenPtr pScreen;
- XdbeScreenVisualInfo *pScrVisInfo;
-
-
- REQUEST_AT_LEAST_SIZE(xDbeGetVisualInfoReq);
-
- if (stuff->n > UINT32_MAX / sizeof(DrawablePtr))
- return BadAlloc;
- /* Make sure any specified drawables are valid. */
- if (stuff->n != 0)
- {
- if (!(pDrawables = (DrawablePtr *)malloc(stuff->n *
- sizeof(DrawablePtr))))
- {
- return BadAlloc;
- }
-
- drawables = (Drawable *)&stuff[1];
-
- for (i = 0; i < stuff->n; i++)
- {
- rc = dixLookupDrawable(pDrawables+i, drawables[i], client, 0,
- DixGetAttrAccess);
- if (rc != Success) {
- free(pDrawables);
- return rc;
- }
- }
- }
-
- count = (stuff->n == 0) ? screenInfo.numScreens : stuff->n;
- if (!(pScrVisInfo = (XdbeScreenVisualInfo *)malloc(count *
- sizeof(XdbeScreenVisualInfo))))
- {
- free(pDrawables);
-
- return BadAlloc;
- }
-
- length = 0;
-
- for (i = 0; i < count; i++)
- {
- pScreen = (stuff->n == 0) ? screenInfo.screens[i] :
- pDrawables[i]->pScreen;
- pDbeScreenPriv = DBE_SCREEN_PRIV(pScreen);
-
- rc = XaceHook(XACE_SCREEN_ACCESS, client, pScreen, DixGetAttrAccess);
- if ((rc != Success) ||
- !(*pDbeScreenPriv->GetVisualInfo)(pScreen, &pScrVisInfo[i]))
- {
- /* We failed to alloc pScrVisInfo[i].visinfo. */
-
- /* Free visinfos that we allocated for previous screen infos.*/
- for (j = 0; j < i; j++)
- {
- free(pScrVisInfo[j].visinfo);
- }
-
- /* Free pDrawables if we needed to allocate it above. */
- free(pDrawables);
-
- return (rc == Success) ? BadAlloc : rc;
- }
-
- /* Account for n, number of xDbeVisInfo items in list. */
- length += sizeof(CARD32);
-
- /* Account for n xDbeVisInfo items */
- length += pScrVisInfo[i].count * sizeof(xDbeVisInfo);
- }
-
- rep.type = X_Reply;
- rep.sequenceNumber = client->sequence;
- rep.length = bytes_to_int32(length);
- rep.m = count;
-
- if (client->swapped)
- {
- swaps(&rep.sequenceNumber, n);
- swapl(&rep.length, n);
- swapl(&rep.m, n);
- }
-
- /* Send off reply. */
- WriteToClient(client, sizeof(xDbeGetVisualInfoReply), (char *)&rep);
-
- for (i = 0; i < count; i++)
- {
- CARD32 data32;
-
- /* For each screen in the reply, send off the visual info */
-
- /* Send off number of visuals. */
- data32 = (CARD32)pScrVisInfo[i].count;
-
- if (client->swapped)
- {
- swapl(&data32, n);
- }
-
- WriteToClient(client, sizeof(CARD32), (char *)&data32);
-
- /* Now send off visual info items. */
- for (j = 0; j < pScrVisInfo[i].count; j++)
- {
- xDbeVisInfo visInfo;
-
- /* Copy the data in the client data structure to a protocol
- * data structure. We will send data to the client from the
- * protocol data structure.
- */
-
- visInfo.visualID = (CARD32)pScrVisInfo[i].visinfo[j].visual;
- visInfo.depth = (CARD8) pScrVisInfo[i].visinfo[j].depth;
- visInfo.perfLevel = (CARD8) pScrVisInfo[i].visinfo[j].perflevel;
-
- if (client->swapped)
- {
- swapl(&visInfo.visualID, n);
-
- /* We do not need to swap depth and perfLevel since they are
- * already 1 byte quantities.
- */
- }
-
- /* Write visualID(32), depth(8), perfLevel(8), and pad(16). */
- WriteToClient(client, 2*sizeof(CARD32), (char *)&visInfo.visualID);
- }
- }
-
- /* Clean up memory. */
- for (i = 0; i < count; i++)
- {
- free(pScrVisInfo[i].visinfo);
- }
- free(pScrVisInfo);
-
- free(pDrawables);
-
- return Success;
-
-} /* ProcDbeGetVisualInfo() */
-
-
-/******************************************************************************
- *
- * DBE DIX Procedure: ProcDbeGetbackBufferAttributes
- *
- * Description:
- *
- * This function is for processing a ProcDbeGetbackBufferAttributes
- * request. This request returns information about a back buffer.
- *
- * Return Values:
- *
- * Success
- *
- *****************************************************************************/
-
-static int
-ProcDbeGetBackBufferAttributes(ClientPtr client)
-{
- REQUEST(xDbeGetBackBufferAttributesReq);
- xDbeGetBackBufferAttributesReply rep;
- DbeWindowPrivPtr pDbeWindowPriv;
- int rc, n;
-
-
- REQUEST_SIZE_MATCH(xDbeGetBackBufferAttributesReq);
-
- rc = dixLookupResourceByType((pointer *)&pDbeWindowPriv, stuff->buffer,
- dbeWindowPrivResType, client,
- DixGetAttrAccess);
- if (rc == Success)
- {
- rep.attributes = pDbeWindowPriv->pWindow->drawable.id;
- }
- else
- {
- rep.attributes = None;
- }
-
- rep.type = X_Reply;
- rep.sequenceNumber = client->sequence;
- rep.length = 0;
-
- if (client->swapped)
- {
- swaps(&rep.sequenceNumber, n);
- swapl(&rep.length, n);
- swapl(&rep.attributes, n);
- }
-
- WriteToClient(client, sizeof(xDbeGetBackBufferAttributesReply),
- (char *)&rep);
- return Success;
-
-} /* ProcDbeGetbackBufferAttributes() */
-
-
-/******************************************************************************
- *
- * DBE DIX Procedure: ProcDbeDispatch
- *
- * Description:
- *
- * This function dispatches DBE requests.
- *
- *****************************************************************************/
-
-static int
-ProcDbeDispatch(ClientPtr client)
-{
- REQUEST(xReq);
-
-
- switch (stuff->data)
- {
- case X_DbeGetVersion:
- return(ProcDbeGetVersion(client));
-
- case X_DbeAllocateBackBufferName:
- return(ProcDbeAllocateBackBufferName(client));
-
- case X_DbeDeallocateBackBufferName:
- return(ProcDbeDeallocateBackBufferName(client));
-
- case X_DbeSwapBuffers:
- return(ProcDbeSwapBuffers(client));
-
- case X_DbeBeginIdiom:
- return(ProcDbeBeginIdiom(client));
-
- case X_DbeEndIdiom:
- return Success;
-
- case X_DbeGetVisualInfo:
- return(ProcDbeGetVisualInfo(client));
-
- case X_DbeGetBackBufferAttributes:
- return(ProcDbeGetBackBufferAttributes(client));
-
- default:
- return BadRequest;
- }
-
-} /* ProcDbeDispatch() */
-
-
-/******************************************************************************
- *
- * DBE DIX Procedure: SProcDbeGetVersion
- *
- * Description:
- *
- * This function is for processing a DbeGetVersion request on a swapped
- * server. This request returns the major and minor version numbers of
- * this extension.
- *
- * Return Values:
- *
- * Success
- *
- *****************************************************************************/
-
-static int
-SProcDbeGetVersion(ClientPtr client)
-{
- REQUEST(xDbeGetVersionReq);
- register int n;
-
-
- swaps(&stuff->length, n);
- return(ProcDbeGetVersion(client));
-
-} /* SProcDbeGetVersion() */
-
-
-/******************************************************************************
- *
- * DBE DIX Procedure: SProcDbeAllocateBackBufferName
- *
- * Description:
- *
- * This function is for processing a DbeAllocateBackBufferName request on
- * a swapped server. This request allocates a drawable ID used to refer
- * to the back buffer of a window.
- *
- * Return Values:
- *
- * BadAlloc - server can not allocate resources
- * BadIDChoice - id is out of range for client; id is already in use
- * BadMatch - window is not an InputOutput window;
- * visual of window is not on list returned by
- * DBEGetVisualInfo;
- * BadValue - invalid swap action is specified
- * BadWindow - window is not a valid window
- * Success
- *
- *****************************************************************************/
-
-static int
-SProcDbeAllocateBackBufferName(ClientPtr client)
-{
- REQUEST(xDbeAllocateBackBufferNameReq);
- register int n;
-
- swaps(&stuff->length, n);
- REQUEST_SIZE_MATCH(xDbeAllocateBackBufferNameReq);
-
- swapl(&stuff->window, n);
- swapl(&stuff->buffer, n);
- /* stuff->swapAction is a byte. We do not need to swap this field. */
-
- return(ProcDbeAllocateBackBufferName(client));
-
-} /* SProcDbeAllocateBackBufferName() */
-
-
-/******************************************************************************
- *
- * DBE DIX Procedure: SProcDbeDeallocateBackBufferName
- *
- * Description:
- *
- * This function is for processing a DbeDeallocateBackBufferName request
- * on a swapped server. This request frees a drawable ID that was
- * obtained by a DbeAllocateBackBufferName request.
- *
- * Return Values:
- *
- * BadBuffer - buffer to deallocate is not associated with a window
- * Success
- *
- *****************************************************************************/
-
-static int
-SProcDbeDeallocateBackBufferName(ClientPtr client)
-{
- REQUEST (xDbeDeallocateBackBufferNameReq);
- register int n;
-
-
- swaps(&stuff->length, n);
- REQUEST_SIZE_MATCH(xDbeDeallocateBackBufferNameReq);
-
- swapl(&stuff->buffer, n);
-
- return(ProcDbeDeallocateBackBufferName(client));
-
-} /* SProcDbeDeallocateBackBufferName() */
-
-
-/******************************************************************************
- *
- * DBE DIX Procedure: SProcDbeSwapBuffers
- *
- * Description:
- *
- * This function is for processing a DbeSwapBuffers request on a swapped
- * server. This request swaps the buffers for all windows listed,
- * applying the appropriate swap action for each window.
- *
- * Return Values:
- *
- * BadMatch - a window in request is not double-buffered; a window in
- * request is listed more than once; all windows in request do
- * not have the same root
- * BadValue - invalid swap action is specified
- * BadWindow - a window in request is not valid
- * Success
- *
- *****************************************************************************/
-
-static int
-SProcDbeSwapBuffers(ClientPtr client)
-{
- REQUEST(xDbeSwapBuffersReq);
- register int i, n;
- xDbeSwapInfo *pSwapInfo;
-
-
- swaps(&stuff->length, n);
- REQUEST_AT_LEAST_SIZE(xDbeSwapBuffersReq);
-
- swapl(&stuff->n, n);
-
- if (stuff->n != 0)
- {
- pSwapInfo = (xDbeSwapInfo *)stuff+1;
-
- /* The swap info following the fix part of this request is a window(32)
- * followed by a 1 byte swap action and then 3 pad bytes. We only need
- * to swap the window information.
- */
- for (i = 0; i < stuff->n; i++)
- {
- swapl(&pSwapInfo->window, n);
- }
- }
-
- return(ProcDbeSwapBuffers(client));
-
-} /* SProcDbeSwapBuffers() */
-
-
-/******************************************************************************
- *
- * DBE DIX Procedure: SProcDbeBeginIdiom
- *
- * Description:
- *
- * This function is for processing a DbeBeginIdiom request on a swapped
- * server. This request informs the server that a complex swap will
- * immediately follow this request.
- *
- * Return Values:
- *
- * Success
- *
- *****************************************************************************/
-
-static int
-SProcDbeBeginIdiom(ClientPtr client)
-{
- REQUEST(xDbeBeginIdiomReq);
- register int n;
-
- swaps(&stuff->length, n);
- return(ProcDbeBeginIdiom(client));
-
-} /* SProcDbeBeginIdiom() */
-
-
-/******************************************************************************
- *
- * DBE DIX Procedure: SProcDbeGetVisualInfo
- *
- * Description:
- *
- * This function is for processing a ProcDbeGetVisualInfo request on a
- * swapped server. This request returns information about which visuals
- * support double buffering.
- *
- * Return Values:
- *
- * BadDrawable - value in screen specifiers is not a valid drawable
- * Success
- *
- *****************************************************************************/
-
-static int
-SProcDbeGetVisualInfo(ClientPtr client)
-{
- REQUEST(xDbeGetVisualInfoReq);
- register int n;
-
-
- swaps(&stuff->length, n);
- REQUEST_AT_LEAST_SIZE(xDbeGetVisualInfoReq);
-
- swapl(&stuff->n, n);
- SwapRestL(stuff);
-
- return(ProcDbeGetVisualInfo(client));
-
-} /* SProcDbeGetVisualInfo() */
-
-
-/******************************************************************************
- *
- * DBE DIX Procedure: SProcDbeGetbackBufferAttributes
- *
- * Description:
- *
- * This function is for processing a ProcDbeGetbackBufferAttributes
- * request on a swapped server. This request returns information about a
- * back buffer.
- *
- * Return Values:
- *
- * Success
- *
- *****************************************************************************/
-
-static int
-SProcDbeGetBackBufferAttributes(ClientPtr client)
-{
- REQUEST (xDbeGetBackBufferAttributesReq);
- register int n;
-
- swaps(&stuff->length, n);
- REQUEST_SIZE_MATCH(xDbeGetBackBufferAttributesReq);
-
- swapl(&stuff->buffer, n);
-
- return(ProcDbeGetBackBufferAttributes(client));
-
-} /* SProcDbeGetBackBufferAttributes() */
-
-
-/******************************************************************************
- *
- * DBE DIX Procedure: SProcDbeDispatch
- *
- * Description:
- *
- * This function dispatches DBE requests on a swapped server.
- *
- *****************************************************************************/
-
-static int
-SProcDbeDispatch(ClientPtr client)
-{
- REQUEST(xReq);
-
-
- switch (stuff->data)
- {
- case X_DbeGetVersion:
- return(SProcDbeGetVersion(client));
-
- case X_DbeAllocateBackBufferName:
- return(SProcDbeAllocateBackBufferName(client));
-
- case X_DbeDeallocateBackBufferName:
- return(SProcDbeDeallocateBackBufferName(client));
-
- case X_DbeSwapBuffers:
- return(SProcDbeSwapBuffers(client));
-
- case X_DbeBeginIdiom:
- return(SProcDbeBeginIdiom(client));
-
- case X_DbeEndIdiom:
- return Success;
-
- case X_DbeGetVisualInfo:
- return(SProcDbeGetVisualInfo(client));
-
- case X_DbeGetBackBufferAttributes:
- return(SProcDbeGetBackBufferAttributes(client));
-
- default:
- return BadRequest;
- }
-
-} /* SProcDbeDispatch() */
-
-
-/******************************************************************************
- *
- * DBE DIX Procedure: DbeSetupBackgroundPainter
- *
- * Description:
- *
- * This function sets up pGC to clear pixmaps.
- *
- * Return Values:
- *
- * TRUE - setup was successful
- * FALSE - the window's background state is NONE
- *
- *****************************************************************************/
-
-static Bool
-DbeSetupBackgroundPainter(WindowPtr pWin, GCPtr pGC)
-{
- ChangeGCVal gcvalues[4];
- int ts_x_origin, ts_y_origin;
- PixUnion background;
- int backgroundState;
- Mask gcmask;
-
-
- /* First take care of any ParentRelative stuff by altering the
- * tile/stipple origin to match the coordinates of the upper-left
- * corner of the first ancestor without a ParentRelative background.
- * This coordinate is, of course, negative.
- */
- ts_x_origin = ts_y_origin = 0;
- while (pWin->backgroundState == ParentRelative)
- {
- ts_x_origin -= pWin->origin.x;
- ts_y_origin -= pWin->origin.y;
-
- pWin = pWin->parent;
- }
- backgroundState = pWin->backgroundState;
- background = pWin->background;
-
- switch (backgroundState)
- {
- case BackgroundPixel:
- gcvalues[0].val = background.pixel;
- gcvalues[1].val = FillSolid;
- gcmask = GCForeground|GCFillStyle;
- break;
-
- case BackgroundPixmap:
- gcvalues[0].val = FillTiled;
- gcvalues[1].ptr = background.pixmap;
- gcvalues[2].val = ts_x_origin;
- gcvalues[3].val = ts_y_origin;
- gcmask = GCFillStyle|GCTile|GCTileStipXOrigin|GCTileStipYOrigin;
- break;
-
- default:
- /* pWin->backgroundState == None */
- return FALSE;
- }
-
- return ChangeGC(NullClient, pGC, gcmask, gcvalues) == 0;
-} /* DbeSetupBackgroundPainter() */
-
-
-/******************************************************************************
- *
- * DBE DIX Procedure: DbeDrawableDelete
- *
- * Description:
- *
- * This is the resource delete function for dbeDrawableResType.
- * It is registered when the drawable resource type is created in
- * DbeExtensionInit().
- *
- * To make resource deletion simple, we do not do anything in this function
- * and leave all resource deleteion to DbeWindowPrivDelete(), which will
- * eventually be called or already has been called. Deletion functions are
- * not guaranteed to be called in any particular order.
- *
- *****************************************************************************/
-static int
-DbeDrawableDelete(pointer pDrawable, XID id)
-{
- return Success;
-
-} /* DbeDrawableDelete() */
-
-
-/******************************************************************************
- *
- * DBE DIX Procedure: DbeWindowPrivDelete
- *
- * Description:
- *
- * This is the resource delete function for dbeWindowPrivResType.
- * It is registered when the drawable resource type is created in
- * DbeExtensionInit().
- *
- *****************************************************************************/
-static int
-DbeWindowPrivDelete(pointer pDbeWinPriv, XID id)
-{
- DbeScreenPrivPtr pDbeScreenPriv;
- DbeWindowPrivPtr pDbeWindowPriv = (DbeWindowPrivPtr)pDbeWinPriv;
- int i;
-
-
- /*
- **************************************************************************
- ** Remove the buffer ID from the ID array.
- **************************************************************************
- */
-
- /* Find the ID in the ID array. */
- i = 0;
- while ((i < pDbeWindowPriv->nBufferIDs) && (pDbeWindowPriv->IDs[i] != id))
- {
- i++;
- }
-
- if (i == pDbeWindowPriv->nBufferIDs)
- {
- /* We did not find the ID in the array. We should never get here. */
- return BadValue;
- }
-
- /* Remove the ID from the array. */
-
- if (i < (pDbeWindowPriv->nBufferIDs - 1))
- {
- /* Compress the buffer ID array, overwriting the ID in the process. */
- memmove(&pDbeWindowPriv->IDs[i], &pDbeWindowPriv->IDs[i+1],
- (pDbeWindowPriv->nBufferIDs - i - 1) * sizeof(XID));
- }
- else
- {
- /* We are removing the last ID in the array, in which case, the
- * assignement below is all that we need to do.
- */
- }
- pDbeWindowPriv->IDs[pDbeWindowPriv->nBufferIDs - 1] = DBE_FREE_ID_ELEMENT;
-
- pDbeWindowPriv->nBufferIDs--;
-
- /* If an extended array was allocated, then check to see if the remaining
- * buffer IDs will fit in the static array.
- */
-
- if ((pDbeWindowPriv->maxAvailableIDs > DBE_INIT_MAX_IDS) &&
- (pDbeWindowPriv->nBufferIDs == DBE_INIT_MAX_IDS))
- {
- /* Copy the IDs back into the static array. */
- memcpy(pDbeWindowPriv->initIDs, pDbeWindowPriv->IDs,
- DBE_INIT_MAX_IDS * sizeof(XID));
-
- /* Free the extended array; use the static array. */
- free(pDbeWindowPriv->IDs);
- pDbeWindowPriv->IDs = pDbeWindowPriv->initIDs;
- pDbeWindowPriv->maxAvailableIDs = DBE_INIT_MAX_IDS;
- }
-
-
- /*
- **************************************************************************
- ** Perform DDX level tasks.
- **************************************************************************
- */
-
- pDbeScreenPriv = DBE_SCREEN_PRIV_FROM_WINDOW_PRIV(
- (DbeWindowPrivPtr)pDbeWindowPriv);
- (*pDbeScreenPriv->WinPrivDelete)((DbeWindowPrivPtr)pDbeWindowPriv, id);
-
-
- /*
- **************************************************************************
- ** Perform miscellaneous tasks if this is the last buffer associated
- ** with the window.
- **************************************************************************
- */
-
- if (pDbeWindowPriv->nBufferIDs == 0)
- {
- /* Reset the DBE window priv pointer. */
- dixSetPrivate(&pDbeWindowPriv->pWindow->devPrivates, dbeWindowPrivKey,
- NULL);
-
- /* We are done with the window priv. */
- dixFreeObjectWithPrivates(pDbeWindowPriv, PRIVATE_DBE_WINDOW);
- }
-
- return Success;
-
-} /* DbeWindowPrivDelete() */
-
-
-/******************************************************************************
- *
- * DBE DIX Procedure: DbeResetProc
- *
- * Description:
- *
- * This routine is called at the end of every server generation.
- * It deallocates any memory reserved for the extension and performs any
- * other tasks related to shutting down the extension.
- *
- *****************************************************************************/
-static void
-DbeResetProc(ExtensionEntry *extEntry)
-{
- int i;
- ScreenPtr pScreen;
- DbeScreenPrivPtr pDbeScreenPriv;
-
- for (i = 0; i < screenInfo.numScreens; i++)
- {
- pScreen = screenInfo.screens[i];
- pDbeScreenPriv = DBE_SCREEN_PRIV(pScreen);
-
- if (pDbeScreenPriv)
- {
- /* Unwrap DestroyWindow, which was wrapped in DbeExtensionInit().*/
- pScreen->DestroyWindow = pDbeScreenPriv->DestroyWindow;
-
- if (pDbeScreenPriv->ResetProc)
- (*pDbeScreenPriv->ResetProc)(pScreen);
-
- free(pDbeScreenPriv);
- }
- }
-} /* DbeResetProc() */
-
-
-/******************************************************************************
- *
- * DBE DIX Procedure: DbeDestroyWindow
- *
- * Description:
- *
- * This is the wrapper for pScreen->DestroyWindow.
- * This function frees buffer resources for a window before it is
- * destroyed.
- *
- *****************************************************************************/
-
-static Bool
-DbeDestroyWindow(WindowPtr pWin)
-{
- DbeScreenPrivPtr pDbeScreenPriv;
- DbeWindowPrivPtr pDbeWindowPriv;
- ScreenPtr pScreen;
- Bool ret;
-
-
- /*
- **************************************************************************
- ** 1. Unwrap the member routine.
- **************************************************************************
- */
-
- pScreen = pWin->drawable.pScreen;
- pDbeScreenPriv = DBE_SCREEN_PRIV(pScreen);
- pScreen->DestroyWindow = pDbeScreenPriv->DestroyWindow;
-
- /*
- **************************************************************************
- ** 2. Do any work necessary before the member routine is called.
- **
- ** Call the window priv delete function for all buffer IDs associated
- ** with this window.
- **************************************************************************
- */
-
- if ((pDbeWindowPriv = DBE_WINDOW_PRIV(pWin)))
- {
- while (pDbeWindowPriv)
- {
- /* *DbeWinPrivDelete() will free the window private and set it to
- * NULL if there are no more buffer IDs associated with this
- * window.
- */
- FreeResource(pDbeWindowPriv->IDs[0], RT_NONE);
- pDbeWindowPriv = DBE_WINDOW_PRIV(pWin);
- }
- }
-
- /*
- **************************************************************************
- ** 3. Call the member routine, saving its result if necessary.
- **************************************************************************
- */
-
- ret = (*pScreen->DestroyWindow)(pWin);
-
- /*
- **************************************************************************
- ** 4. Rewrap the member routine, restoring the wrapper value first in case
- ** the wrapper (or something that it wrapped) change this value.
- **************************************************************************
- */
-
- pDbeScreenPriv->DestroyWindow = pScreen->DestroyWindow;
- pScreen->DestroyWindow = DbeDestroyWindow;
-
- /*
- **************************************************************************
- ** 5. Do any work necessary after the member routine has been called.
- **
- ** In this case we do not need to do anything.
- **************************************************************************
- */
-
- return ret;
-
-} /* DbeDestroyWindow() */
-
-
-/******************************************************************************
- *
- * DBE DIX Procedure: DbeExtensionInit
- *
- * Description:
- *
- * Called from InitExtensions in main()
- *
- *****************************************************************************/
-
-void
-DbeExtensionInit(void)
-{
- ExtensionEntry *extEntry;
- register int i, j;
- ScreenPtr pScreen = NULL;
- DbeScreenPrivPtr pDbeScreenPriv;
- int nStubbedScreens = 0;
- Bool ddxInitSuccess;
-
-#ifdef PANORAMIX
- if(!noPanoramiXExtension) return;
-#endif
-
- /* Create the resource types. */
- dbeDrawableResType =
- CreateNewResourceType(DbeDrawableDelete, "dbeDrawable");
- if (!dbeDrawableResType)
- return;
- dbeDrawableResType |= RC_DRAWABLE;
-
- dbeWindowPrivResType =
- CreateNewResourceType(DbeWindowPrivDelete, "dbeWindow");
- if (!dbeWindowPrivResType)
- return;
-
- if (!dixRegisterPrivateKey(&dbeScreenPrivKeyRec, PRIVATE_SCREEN, 0))
- return;
-
- if (!dixRegisterPrivateKey(&dbeWindowPrivKeyRec, PRIVATE_WINDOW, 0))
- return;
-
- for (i = 0; i < screenInfo.numScreens; i++)
- {
- /* For each screen, set up DBE screen privates and init DIX and DDX
- * interface.
- */
-
- pScreen = screenInfo.screens[i];
-
- if (!(pDbeScreenPriv = malloc (sizeof (DbeScreenPrivRec))))
- {
- /* If we can not alloc a window or screen private,
- * then free any privates that we already alloc'ed and return
- */
-
- for (j = 0; j < i; j++)
- {
- free(dixLookupPrivate(&screenInfo.screens[j]->devPrivates,
- dbeScreenPrivKey));
- dixSetPrivate(&screenInfo.screens[j]->devPrivates,
- dbeScreenPrivKey, NULL);
- }
- return;
- }
-
- dixSetPrivate(&pScreen->devPrivates, dbeScreenPrivKey, pDbeScreenPriv);
-
- {
- /* We don't have DDX support for DBE anymore */
-
-#ifndef DISABLE_MI_DBE_BY_DEFAULT
- /* Setup DIX. */
- pDbeScreenPriv->SetupBackgroundPainter = DbeSetupBackgroundPainter;
-
- /* Setup DDX. */
- ddxInitSuccess = miDbeInit(pScreen, pDbeScreenPriv);
-
- /* DDX DBE initialization may have the side affect of
- * reallocating pDbeScreenPriv, so we need to update it.
- */
- pDbeScreenPriv = DBE_SCREEN_PRIV(pScreen);
-
- if (ddxInitSuccess)
- {
- /* Wrap DestroyWindow. The DDX initialization function
- * already wrapped PositionWindow for us.
- */
-
- pDbeScreenPriv->DestroyWindow = pScreen->DestroyWindow;
- pScreen->DestroyWindow = DbeDestroyWindow;
- }
- else
- {
- /* DDX initialization failed. Stub the screen. */
- DbeStubScreen(pDbeScreenPriv, &nStubbedScreens);
- }
-#else
- DbeStubScreen(pDbeScreenPriv, &nStubbedScreens);
-#endif
-
- }
-
- } /* for (i = 0; i < screenInfo.numScreens; i++) */
-
-
- if (nStubbedScreens == screenInfo.numScreens)
- {
- /* All screens stubbed. Clean up and return. */
-
- for (i = 0; i < screenInfo.numScreens; i++)
- {
- free(dixLookupPrivate(&screenInfo.screens[i]->devPrivates,
- dbeScreenPrivKey));
- dixSetPrivate(&pScreen->devPrivates, dbeScreenPrivKey, NULL);
- }
- return;
- }
-
-
- /* Now add the extension. */
- extEntry = AddExtension(DBE_PROTOCOL_NAME, DbeNumberEvents,
- DbeNumberErrors, ProcDbeDispatch, SProcDbeDispatch,
- DbeResetProc, StandardMinorOpcode);
-
- dbeErrorBase = extEntry->errorBase;
- SetResourceTypeErrorValue(dbeWindowPrivResType, dbeErrorBase + DbeBadBuffer);
- SetResourceTypeErrorValue(dbeDrawableResType, dbeErrorBase + DbeBadBuffer);
-
-} /* DbeExtensionInit() */
-
+/******************************************************************************
+ *
+ * Copyright (c) 1994, 1995 Hewlett-Packard Company
+ *
+ * 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 HEWLETT-PACKARD COMPANY 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 Hewlett-Packard
+ * Company 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 Hewlett-Packard Company.
+ *
+ * DIX DBE code
+ *
+ *****************************************************************************/
+
+
+/* INCLUDES */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <string.h>
+#if HAVE_STDINT_H
+#include <stdint.h>
+#elif !defined(UINT32_MAX)
+#define UINT32_MAX 0xffffffffU
+#endif
+
+#include <X11/X.h>
+#include <X11/Xproto.h>
+#include "scrnintstr.h"
+#include "extnsionst.h"
+#include "gcstruct.h"
+#include "dixstruct.h"
+#define NEED_DBE_PROTOCOL
+#include "dbestruct.h"
+#include "midbe.h"
+#include "xace.h"
+
+/* GLOBALS */
+
+/* These are globals for use by DDX */
+DevPrivateKeyRec dbeScreenPrivKeyRec;
+DevPrivateKeyRec dbeWindowPrivKeyRec;
+
+/* These are globals for use by DDX */
+RESTYPE dbeDrawableResType;
+RESTYPE dbeWindowPrivResType;
+
+/* Used to generate DBE's BadBuffer error. */
+static int dbeErrorBase;
+
+/******************************************************************************
+ *
+ * DBE DIX Procedure: DbeStubScreen
+ *
+ * Description:
+ *
+ * This is function stubs the function pointers in the given DBE screen
+ * private and increments the number of stubbed screens.
+ *
+ *****************************************************************************/
+
+static void
+DbeStubScreen(DbeScreenPrivPtr pDbeScreenPriv, int *nStubbedScreens)
+{
+ /* Stub DIX. */
+ pDbeScreenPriv->SetupBackgroundPainter = NULL;
+
+ /* Do not unwrap PositionWindow nor DestroyWindow. If the DDX
+ * initialization function failed, we assume that it did not wrap
+ * PositionWindow. Also, DestroyWindow is only wrapped if the DDX
+ * initialization function succeeded.
+ */
+
+ /* Stub DDX. */
+ pDbeScreenPriv->GetVisualInfo = NULL;
+ pDbeScreenPriv->AllocBackBufferName = NULL;
+ pDbeScreenPriv->SwapBuffers = NULL;
+ pDbeScreenPriv->BeginIdiom = NULL;
+ pDbeScreenPriv->EndIdiom = NULL;
+ pDbeScreenPriv->WinPrivDelete = NULL;
+ pDbeScreenPriv->ResetProc = NULL;
+
+ (*nStubbedScreens)++;
+
+} /* DbeStubScreen() */
+
+
+
+/******************************************************************************
+ *
+ * DBE DIX Procedure: ProcDbeGetVersion
+ *
+ * Description:
+ *
+ * This function is for processing a DbeGetVersion request.
+ * This request returns the major and minor version numbers of this
+ * extension.
+ *
+ * Return Values:
+ *
+ * Success
+ *
+ *****************************************************************************/
+
+static int
+ProcDbeGetVersion(ClientPtr client)
+{
+ /* REQUEST(xDbeGetVersionReq); */
+ xDbeGetVersionReply rep;
+ register int n;
+
+
+ REQUEST_SIZE_MATCH(xDbeGetVersionReq);
+
+ rep.type = X_Reply;
+ rep.length = 0;
+ rep.sequenceNumber = client->sequence;
+ rep.majorVersion = DBE_MAJOR_VERSION;
+ rep.minorVersion = DBE_MINOR_VERSION;
+
+ if (client->swapped)
+ {
+ swaps(&rep.sequenceNumber, n);
+ }
+
+ WriteToClient(client, sizeof(xDbeGetVersionReply), (char *)&rep);
+
+ return Success;
+
+} /* ProcDbeGetVersion() */
+
+
+/******************************************************************************
+ *
+ * DBE DIX Procedure: ProcDbeAllocateBackBufferName
+ *
+ * Description:
+ *
+ * This function is for processing a DbeAllocateBackBufferName request.
+ * This request allocates a drawable ID used to refer to the back buffer
+ * of a window.
+ *
+ * Return Values:
+ *
+ * BadAlloc - server can not allocate resources
+ * BadIDChoice - id is out of range for client; id is already in use
+ * BadMatch - window is not an InputOutput window;
+ * visual of window is not on list returned by
+ * DBEGetVisualInfo;
+ * BadValue - invalid swap action is specified
+ * BadWindow - window is not a valid window
+ * Success
+ *
+ *****************************************************************************/
+
+static int
+ProcDbeAllocateBackBufferName(ClientPtr client)
+{
+ REQUEST(xDbeAllocateBackBufferNameReq);
+ WindowPtr pWin;
+ DbeScreenPrivPtr pDbeScreenPriv;
+ DbeWindowPrivPtr pDbeWindowPriv;
+ XdbeScreenVisualInfo scrVisInfo;
+ register int i;
+ Bool visualMatched = FALSE;
+ xDbeSwapAction swapAction;
+ VisualID visual;
+ int status;
+ int add_index;
+
+
+ REQUEST_SIZE_MATCH(xDbeAllocateBackBufferNameReq);
+
+ /* The window must be valid. */
+ status = dixLookupWindow(&pWin, stuff->window, client, DixManageAccess);
+ if (status != Success)
+ return status;
+
+ /* The window must be InputOutput. */
+ if (pWin->drawable.class != InputOutput)
+ {
+ return BadMatch;
+ }
+
+ /* The swap action must be valid. */
+ swapAction = stuff->swapAction; /* use local var for performance. */
+ if ((swapAction != XdbeUndefined ) &&
+ (swapAction != XdbeBackground) &&
+ (swapAction != XdbeUntouched ) &&
+ (swapAction != XdbeCopied ))
+ {
+ return BadValue;
+ }
+
+ /* The id must be in range and not already in use. */
+ LEGAL_NEW_RESOURCE(stuff->buffer, client);
+
+ /* The visual of the window must be in the list returned by
+ * GetVisualInfo.
+ */
+ pDbeScreenPriv = DBE_SCREEN_PRIV_FROM_WINDOW(pWin);
+ if (!pDbeScreenPriv->GetVisualInfo)
+ return BadMatch; /* screen doesn't support double buffering */
+
+ if (!(*pDbeScreenPriv->GetVisualInfo)(pWin->drawable.pScreen, &scrVisInfo))
+ {
+ /* GetVisualInfo() failed to allocate visual info data. */
+ return BadAlloc;
+ }
+
+ /* See if the window's visual is on the list. */
+ visual = wVisual(pWin);
+ for (i = 0; (i < scrVisInfo.count) && !visualMatched; i++)
+ {
+ if (scrVisInfo.visinfo[i].visual == visual)
+ {
+ visualMatched = TRUE;
+ }
+ }
+
+ /* Free what was allocated by the GetVisualInfo() call above. */
+ free(scrVisInfo.visinfo);
+
+ if (!visualMatched)
+ {
+ return BadMatch;
+ }
+
+ if ((pDbeWindowPriv = DBE_WINDOW_PRIV(pWin)) == NULL)
+ {
+ /* There is no buffer associated with the window.
+ * Allocate a window priv.
+ */
+
+ pDbeWindowPriv = dixAllocateObjectWithPrivates(DbeWindowPrivRec, PRIVATE_DBE_WINDOW);
+ if (!pDbeWindowPriv)
+ return BadAlloc;
+
+ /* Fill out window priv information. */
+ pDbeWindowPriv->pWindow = pWin;
+ pDbeWindowPriv->width = pWin->drawable.width;
+ pDbeWindowPriv->height = pWin->drawable.height;
+ pDbeWindowPriv->x = pWin->drawable.x;
+ pDbeWindowPriv->y = pWin->drawable.y;
+ pDbeWindowPriv->nBufferIDs = 0;
+
+ /* Set the buffer ID array pointer to the initial (static) array). */
+ pDbeWindowPriv->IDs = pDbeWindowPriv->initIDs;
+
+ /* Initialize the buffer ID list. */
+ pDbeWindowPriv->maxAvailableIDs = DBE_INIT_MAX_IDS;
+ pDbeWindowPriv->IDs[0] = stuff->buffer;
+
+ add_index = 0;
+ for (i = 0; i < DBE_INIT_MAX_IDS; i++)
+ {
+ pDbeWindowPriv->IDs[i] = DBE_FREE_ID_ELEMENT;
+ }
+
+ /* Actually connect the window priv to the window. */
+ dixSetPrivate(&pWin->devPrivates, dbeWindowPrivKey, pDbeWindowPriv);
+
+ } /* if -- There is no buffer associated with the window. */
+
+ else
+ {
+ /* A buffer is already associated with the window.
+ * Add the new buffer ID to the array, reallocating the array memory
+ * if necessary.
+ */
+
+ /* Determine if there is a free element in the ID array. */
+ for (i = 0; i < pDbeWindowPriv->maxAvailableIDs; i++)
+ {
+ if (pDbeWindowPriv->IDs[i] == DBE_FREE_ID_ELEMENT)
+ {
+ /* There is still room in the ID array. */
+ break;
+ }
+ }
+
+ if (i == pDbeWindowPriv->maxAvailableIDs)
+ {
+ /* No more room in the ID array -- reallocate another array. */
+ XID *pIDs;
+
+ /* Setup an array pointer for the realloc operation below. */
+ if (pDbeWindowPriv->maxAvailableIDs == DBE_INIT_MAX_IDS)
+ {
+ /* We will malloc a new array. */
+ pIDs = NULL;
+ }
+ else
+ {
+ /* We will realloc a new array. */
+ pIDs = pDbeWindowPriv->IDs;
+ }
+
+ /* malloc/realloc a new array and initialize all elements to 0. */
+ pDbeWindowPriv->IDs = (XID *)realloc(pIDs,
+ (pDbeWindowPriv->maxAvailableIDs+DBE_INCR_MAX_IDS)*sizeof(XID));
+ if (!pDbeWindowPriv->IDs)
+ {
+ return BadAlloc;
+ }
+ memset(&pDbeWindowPriv->IDs[pDbeWindowPriv->nBufferIDs], 0,
+ (pDbeWindowPriv->maxAvailableIDs + DBE_INCR_MAX_IDS -
+ pDbeWindowPriv->nBufferIDs) * sizeof(XID));
+
+ if (pDbeWindowPriv->maxAvailableIDs == DBE_INIT_MAX_IDS)
+ {
+ /* We just went from using the initial (static) array to a
+ * newly allocated array. Copy the IDs from the initial array
+ * to the new array.
+ */
+ memcpy(pDbeWindowPriv->IDs, pDbeWindowPriv->initIDs,
+ DBE_INIT_MAX_IDS * sizeof(XID));
+ }
+
+ pDbeWindowPriv->maxAvailableIDs += DBE_INCR_MAX_IDS;
+ }
+
+ add_index = i;
+
+ } /* else -- A buffer is already associated with the window. */
+
+
+ /* Call the DDX routine to allocate the back buffer. */
+ status = (*pDbeScreenPriv->AllocBackBufferName)(pWin, stuff->buffer,
+ stuff->swapAction);
+
+ if (status == Success)
+ {
+ pDbeWindowPriv->IDs[add_index] = stuff->buffer;
+ if (!AddResource(stuff->buffer, dbeWindowPrivResType,
+ (pointer)pDbeWindowPriv))
+ {
+ pDbeWindowPriv->IDs[add_index] = DBE_FREE_ID_ELEMENT;
+
+ if (pDbeWindowPriv->nBufferIDs == 0) {
+ status = BadAlloc;
+ goto out_free;
+ }
+ }
+ } else {
+ /* The DDX buffer allocation routine failed for the first buffer of
+ * this window.
+ */
+ if (pDbeWindowPriv->nBufferIDs == 0) {
+ goto out_free;
+ }
+ }
+
+ /* Increment the number of buffers (XIDs) associated with this window. */
+ pDbeWindowPriv->nBufferIDs++;
+
+ /* Set swap action on all calls. */
+ pDbeWindowPriv->swapAction = stuff->swapAction;
+
+ return status;
+
+out_free:
+ dixSetPrivate(&pWin->devPrivates, dbeWindowPrivKey, NULL);
+ free(pDbeWindowPriv);
+ return status;
+
+} /* ProcDbeAllocateBackBufferName() */
+
+
+/******************************************************************************
+ *
+ * DBE DIX Procedure: ProcDbeDeallocateBackBufferName
+ *
+ * Description:
+ *
+ * This function is for processing a DbeDeallocateBackBufferName request.
+ * This request frees a drawable ID that was obtained by a
+ * DbeAllocateBackBufferName request.
+ *
+ * Return Values:
+ *
+ * BadBuffer - buffer to deallocate is not associated with a window
+ * Success
+ *
+ *****************************************************************************/
+
+static int
+ProcDbeDeallocateBackBufferName(ClientPtr client)
+{
+ REQUEST(xDbeDeallocateBackBufferNameReq);
+ DbeWindowPrivPtr pDbeWindowPriv;
+ int rc, i;
+ pointer val;
+
+
+ REQUEST_SIZE_MATCH(xDbeDeallocateBackBufferNameReq);
+
+ /* Buffer name must be valid */
+ rc = dixLookupResourceByType((pointer *)&pDbeWindowPriv, stuff->buffer,
+ dbeWindowPrivResType, client,
+ DixDestroyAccess);
+ if (rc != Success)
+ return rc;
+
+ rc = dixLookupResourceByType(&val, stuff->buffer, dbeDrawableResType,
+ client, DixDestroyAccess);
+ if (rc != Success)
+ return rc;
+
+ /* Make sure that the id is valid for the window.
+ * This is paranoid code since we already looked up the ID by type
+ * above.
+ */
+
+ for (i = 0; i < pDbeWindowPriv->nBufferIDs; i++)
+ {
+ /* Loop through the ID list to find the ID. */
+ if (pDbeWindowPriv->IDs[i] == stuff->buffer)
+ {
+ break;
+ }
+ }
+
+ if (i == pDbeWindowPriv->nBufferIDs)
+ {
+ /* We did not find the ID in the ID list. */
+ client->errorValue = stuff->buffer;
+ return dbeErrorBase + DbeBadBuffer;
+ }
+
+ FreeResource(stuff->buffer, RT_NONE);
+
+ return Success;
+
+} /* ProcDbeDeallocateBackBufferName() */
+
+
+/******************************************************************************
+ *
+ * DBE DIX Procedure: ProcDbeSwapBuffers
+ *
+ * Description:
+ *
+ * This function is for processing a DbeSwapBuffers request.
+ * This request swaps the buffers for all windows listed, applying the
+ * appropriate swap action for each window.
+ *
+ * Return Values:
+ *
+ * BadAlloc - local allocation failed; this return value is not defined
+ * by the protocol
+ * BadMatch - a window in request is not double-buffered; a window in
+ * request is listed more than once
+ * BadValue - invalid swap action is specified; no swap action is
+ * specified
+ * BadWindow - a window in request is not valid
+ * Success
+ *
+ *****************************************************************************/
+
+static int
+ProcDbeSwapBuffers(ClientPtr client)
+{
+ REQUEST(xDbeSwapBuffersReq);
+ WindowPtr pWin;
+ DbeScreenPrivPtr pDbeScreenPriv;
+ DbeSwapInfoPtr swapInfo;
+ xDbeSwapInfo *dbeSwapInfo;
+ int error;
+ register int i, j;
+ int nStuff;
+
+
+ REQUEST_AT_LEAST_SIZE(xDbeSwapBuffersReq);
+ nStuff = stuff->n; /* use local variable for performance. */
+
+ if (nStuff == 0)
+ {
+ return Success;
+ }
+
+ if (nStuff > UINT32_MAX / sizeof(DbeSwapInfoRec))
+ return BadAlloc;
+
+ /* Get to the swap info appended to the end of the request. */
+ dbeSwapInfo = (xDbeSwapInfo *)&stuff[1];
+
+ /* Allocate array to record swap information. */
+ swapInfo = (DbeSwapInfoPtr)malloc(nStuff * sizeof(DbeSwapInfoRec));
+ if (swapInfo == NULL)
+ {
+ return BadAlloc;
+ }
+
+
+ for (i = 0; i < nStuff; i++)
+ {
+ /* Check all windows to swap. */
+
+ /* Each window must be a valid window - BadWindow. */
+ error = dixLookupWindow(&pWin, dbeSwapInfo[i].window, client,
+ DixWriteAccess);
+ if (error != Success) {
+ free(swapInfo);
+ return error;
+ }
+
+ /* Each window must be double-buffered - BadMatch. */
+ if (DBE_WINDOW_PRIV(pWin) == NULL)
+ {
+ free(swapInfo);
+ return BadMatch;
+ }
+
+ /* Each window must only be specified once - BadMatch. */
+ for (j = i + 1; j < nStuff; j++)
+ {
+ if (dbeSwapInfo[i].window == dbeSwapInfo[j].window)
+ {
+ free(swapInfo);
+ return BadMatch;
+ }
+ }
+
+ /* Each swap action must be valid - BadValue. */
+ if ((dbeSwapInfo[i].swapAction != XdbeUndefined ) &&
+ (dbeSwapInfo[i].swapAction != XdbeBackground) &&
+ (dbeSwapInfo[i].swapAction != XdbeUntouched ) &&
+ (dbeSwapInfo[i].swapAction != XdbeCopied ))
+ {
+ free(swapInfo);
+ return BadValue;
+ }
+
+ /* Everything checks out OK. Fill in the swap info array. */
+ swapInfo[i].pWindow = pWin;
+ swapInfo[i].swapAction = dbeSwapInfo[i].swapAction;
+
+ } /* for (i = 0; i < nStuff; i++) */
+
+
+ /* Call the DDX routine to perform the swap(s). The DDX routine should
+ * scan the swap list (swap info), swap any buffers that it knows how to
+ * handle, delete them from the list, and update nStuff to indicate how
+ * many windows it did not handle.
+ *
+ * This scheme allows a range of sophistication in the DDX SwapBuffers()
+ * implementation. Naive implementations could just swap the first buffer
+ * in the list, move the last buffer to the front, decrement nStuff, and
+ * return. The next level of sophistication could be to scan the whole
+ * list for windows on the same screen. Up another level, the DDX routine
+ * could deal with cross-screen synchronization.
+ */
+
+ while (nStuff > 0)
+ {
+ pDbeScreenPriv = DBE_SCREEN_PRIV_FROM_WINDOW(swapInfo[0].pWindow);
+ error = (*pDbeScreenPriv->SwapBuffers)(client, &nStuff, swapInfo);
+ if (error != Success)
+ {
+ free(swapInfo);
+ return error;
+ }
+ }
+
+ free(swapInfo);
+ return Success;
+
+} /* ProcDbeSwapBuffers() */
+
+
+/******************************************************************************
+ *
+ * DBE DIX Procedure: ProcDbeBeginIdiom
+ *
+ * Description:
+ *
+ * This function is for processing a DbeBeginIdiom request.
+ * This request informs the server that a complex swap will immediately
+ * follow this request.
+ *
+ * Return Values:
+ *
+ * Success
+ *
+ *****************************************************************************/
+
+static int
+ProcDbeBeginIdiom(ClientPtr client)
+{
+ /* REQUEST(xDbeBeginIdiomReq); */
+ DbeScreenPrivPtr pDbeScreenPriv;
+ register int i;
+
+
+ REQUEST_SIZE_MATCH(xDbeBeginIdiomReq);
+
+ for (i = 0; i < screenInfo.numScreens; i++)
+ {
+ pDbeScreenPriv = DBE_SCREEN_PRIV(screenInfo.screens[i]);
+
+ /* Call the DDX begin idiom procedure if there is one. */
+ if (pDbeScreenPriv->BeginIdiom)
+ {
+ (*pDbeScreenPriv->BeginIdiom)(client);
+ }
+ }
+
+ return Success;
+
+} /* ProcDbeBeginIdiom() */
+
+
+/******************************************************************************
+ *
+ * DBE DIX Procedure: ProcDbeGetVisualInfo
+ *
+ * Description:
+ *
+ * This function is for processing a ProcDbeGetVisualInfo request.
+ * This request returns information about which visuals support
+ * double buffering.
+ *
+ * Return Values:
+ *
+ * BadDrawable - value in screen specifiers is not a valid drawable
+ * Success
+ *
+ *****************************************************************************/
+
+static int
+ProcDbeGetVisualInfo(ClientPtr client)
+{
+ REQUEST(xDbeGetVisualInfoReq);
+ DbeScreenPrivPtr pDbeScreenPriv;
+ xDbeGetVisualInfoReply rep;
+ Drawable *drawables;
+ DrawablePtr *pDrawables = NULL;
+ register int i, j, n, rc;
+ register int count; /* number of visual infos in reply */
+ register int length; /* length of reply */
+ ScreenPtr pScreen;
+ XdbeScreenVisualInfo *pScrVisInfo;
+
+
+ REQUEST_AT_LEAST_SIZE(xDbeGetVisualInfoReq);
+
+ if (stuff->n > UINT32_MAX / sizeof(DrawablePtr))
+ return BadAlloc;
+ /* Make sure any specified drawables are valid. */
+ if (stuff->n != 0)
+ {
+ if (!(pDrawables = (DrawablePtr *)malloc(stuff->n *
+ sizeof(DrawablePtr))))
+ {
+ return BadAlloc;
+ }
+
+ drawables = (Drawable *)&stuff[1];
+
+ for (i = 0; i < stuff->n; i++)
+ {
+ rc = dixLookupDrawable(pDrawables+i, drawables[i], client, 0,
+ DixGetAttrAccess);
+ if (rc != Success) {
+ free(pDrawables);
+ return rc;
+ }
+ }
+ }
+
+ count = (stuff->n == 0) ? screenInfo.numScreens : stuff->n;
+ if (!(pScrVisInfo = calloc(count, sizeof(XdbeScreenVisualInfo))))
+ {
+ free(pDrawables);
+
+ return BadAlloc;
+ }
+
+ length = 0;
+
+ for (i = 0; i < count; i++)
+ {
+ pScreen = (stuff->n == 0) ? screenInfo.screens[i] :
+ pDrawables[i]->pScreen;
+ pDbeScreenPriv = DBE_SCREEN_PRIV(pScreen);
+
+ rc = XaceHook(XACE_SCREEN_ACCESS, client, pScreen, DixGetAttrAccess);
+ if (rc != Success)
+ goto freeScrVisInfo;
+
+ if (!(*pDbeScreenPriv->GetVisualInfo)(pScreen, &pScrVisInfo[i]))
+ {
+ /* We failed to alloc pScrVisInfo[i].visinfo. */
+ rc = BadAlloc;
+
+ /* Free visinfos that we allocated for previous screen infos.*/
+ goto freeScrVisInfo;
+ }
+
+ /* Account for n, number of xDbeVisInfo items in list. */
+ length += sizeof(CARD32);
+
+ /* Account for n xDbeVisInfo items */
+ length += pScrVisInfo[i].count * sizeof(xDbeVisInfo);
+ }
+
+ rep.type = X_Reply;
+ rep.sequenceNumber = client->sequence;
+ rep.length = bytes_to_int32(length);
+ rep.m = count;
+
+ if (client->swapped)
+ {
+ swaps(&rep.sequenceNumber, n);
+ swapl(&rep.length, n);
+ swapl(&rep.m, n);
+ }
+
+ /* Send off reply. */
+ WriteToClient(client, sizeof(xDbeGetVisualInfoReply), (char *)&rep);
+
+ for (i = 0; i < count; i++)
+ {
+ CARD32 data32;
+
+ /* For each screen in the reply, send off the visual info */
+
+ /* Send off number of visuals. */
+ data32 = (CARD32)pScrVisInfo[i].count;
+
+ if (client->swapped)
+ {
+ swapl(&data32, n);
+ }
+
+ WriteToClient(client, sizeof(CARD32), (char *)&data32);
+
+ /* Now send off visual info items. */
+ for (j = 0; j < pScrVisInfo[i].count; j++)
+ {
+ xDbeVisInfo visInfo;
+
+ /* Copy the data in the client data structure to a protocol
+ * data structure. We will send data to the client from the
+ * protocol data structure.
+ */
+
+ visInfo.visualID = (CARD32)pScrVisInfo[i].visinfo[j].visual;
+ visInfo.depth = (CARD8) pScrVisInfo[i].visinfo[j].depth;
+ visInfo.perfLevel = (CARD8) pScrVisInfo[i].visinfo[j].perflevel;
+
+ if (client->swapped)
+ {
+ swapl(&visInfo.visualID, n);
+
+ /* We do not need to swap depth and perfLevel since they are
+ * already 1 byte quantities.
+ */
+ }
+
+ /* Write visualID(32), depth(8), perfLevel(8), and pad(16). */
+ WriteToClient(client, 2*sizeof(CARD32), (char *)&visInfo.visualID);
+ }
+ }
+
+ rc = Success;
+
+ freeScrVisInfo:
+ /* Clean up memory. */
+ for (i = 0; i < count; i++)
+ {
+ free(pScrVisInfo[i].visinfo);
+ }
+ free(pScrVisInfo);
+
+ free(pDrawables);
+
+ return rc;
+
+} /* ProcDbeGetVisualInfo() */
+
+
+/******************************************************************************
+ *
+ * DBE DIX Procedure: ProcDbeGetbackBufferAttributes
+ *
+ * Description:
+ *
+ * This function is for processing a ProcDbeGetbackBufferAttributes
+ * request. This request returns information about a back buffer.
+ *
+ * Return Values:
+ *
+ * Success
+ *
+ *****************************************************************************/
+
+static int
+ProcDbeGetBackBufferAttributes(ClientPtr client)
+{
+ REQUEST(xDbeGetBackBufferAttributesReq);
+ xDbeGetBackBufferAttributesReply rep;
+ DbeWindowPrivPtr pDbeWindowPriv;
+ int rc, n;
+
+
+ REQUEST_SIZE_MATCH(xDbeGetBackBufferAttributesReq);
+
+ rc = dixLookupResourceByType((pointer *)&pDbeWindowPriv, stuff->buffer,
+ dbeWindowPrivResType, client,
+ DixGetAttrAccess);
+ if (rc == Success)
+ {
+ rep.attributes = pDbeWindowPriv->pWindow->drawable.id;
+ }
+ else
+ {
+ rep.attributes = None;
+ }
+
+ rep.type = X_Reply;
+ rep.sequenceNumber = client->sequence;
+ rep.length = 0;
+
+ if (client->swapped)
+ {
+ swaps(&rep.sequenceNumber, n);
+ swapl(&rep.length, n);
+ swapl(&rep.attributes, n);
+ }
+
+ WriteToClient(client, sizeof(xDbeGetBackBufferAttributesReply),
+ (char *)&rep);
+ return Success;
+
+} /* ProcDbeGetbackBufferAttributes() */
+
+
+/******************************************************************************
+ *
+ * DBE DIX Procedure: ProcDbeDispatch
+ *
+ * Description:
+ *
+ * This function dispatches DBE requests.
+ *
+ *****************************************************************************/
+
+static int
+ProcDbeDispatch(ClientPtr client)
+{
+ REQUEST(xReq);
+
+
+ switch (stuff->data)
+ {
+ case X_DbeGetVersion:
+ return(ProcDbeGetVersion(client));
+
+ case X_DbeAllocateBackBufferName:
+ return(ProcDbeAllocateBackBufferName(client));
+
+ case X_DbeDeallocateBackBufferName:
+ return(ProcDbeDeallocateBackBufferName(client));
+
+ case X_DbeSwapBuffers:
+ return(ProcDbeSwapBuffers(client));
+
+ case X_DbeBeginIdiom:
+ return(ProcDbeBeginIdiom(client));
+
+ case X_DbeEndIdiom:
+ return Success;
+
+ case X_DbeGetVisualInfo:
+ return(ProcDbeGetVisualInfo(client));
+
+ case X_DbeGetBackBufferAttributes:
+ return(ProcDbeGetBackBufferAttributes(client));
+
+ default:
+ return BadRequest;
+ }
+
+} /* ProcDbeDispatch() */
+
+
+/******************************************************************************
+ *
+ * DBE DIX Procedure: SProcDbeGetVersion
+ *
+ * Description:
+ *
+ * This function is for processing a DbeGetVersion request on a swapped
+ * server. This request returns the major and minor version numbers of
+ * this extension.
+ *
+ * Return Values:
+ *
+ * Success
+ *
+ *****************************************************************************/
+
+static int
+SProcDbeGetVersion(ClientPtr client)
+{
+ REQUEST(xDbeGetVersionReq);
+ register int n;
+
+
+ swaps(&stuff->length, n);
+ return(ProcDbeGetVersion(client));
+
+} /* SProcDbeGetVersion() */
+
+
+/******************************************************************************
+ *
+ * DBE DIX Procedure: SProcDbeAllocateBackBufferName
+ *
+ * Description:
+ *
+ * This function is for processing a DbeAllocateBackBufferName request on
+ * a swapped server. This request allocates a drawable ID used to refer
+ * to the back buffer of a window.
+ *
+ * Return Values:
+ *
+ * BadAlloc - server can not allocate resources
+ * BadIDChoice - id is out of range for client; id is already in use
+ * BadMatch - window is not an InputOutput window;
+ * visual of window is not on list returned by
+ * DBEGetVisualInfo;
+ * BadValue - invalid swap action is specified
+ * BadWindow - window is not a valid window
+ * Success
+ *
+ *****************************************************************************/
+
+static int
+SProcDbeAllocateBackBufferName(ClientPtr client)
+{
+ REQUEST(xDbeAllocateBackBufferNameReq);
+ register int n;
+
+ swaps(&stuff->length, n);
+ REQUEST_SIZE_MATCH(xDbeAllocateBackBufferNameReq);
+
+ swapl(&stuff->window, n);
+ swapl(&stuff->buffer, n);
+ /* stuff->swapAction is a byte. We do not need to swap this field. */
+
+ return(ProcDbeAllocateBackBufferName(client));
+
+} /* SProcDbeAllocateBackBufferName() */
+
+
+/******************************************************************************
+ *
+ * DBE DIX Procedure: SProcDbeDeallocateBackBufferName
+ *
+ * Description:
+ *
+ * This function is for processing a DbeDeallocateBackBufferName request
+ * on a swapped server. This request frees a drawable ID that was
+ * obtained by a DbeAllocateBackBufferName request.
+ *
+ * Return Values:
+ *
+ * BadBuffer - buffer to deallocate is not associated with a window
+ * Success
+ *
+ *****************************************************************************/
+
+static int
+SProcDbeDeallocateBackBufferName(ClientPtr client)
+{
+ REQUEST (xDbeDeallocateBackBufferNameReq);
+ register int n;
+
+
+ swaps(&stuff->length, n);
+ REQUEST_SIZE_MATCH(xDbeDeallocateBackBufferNameReq);
+
+ swapl(&stuff->buffer, n);
+
+ return(ProcDbeDeallocateBackBufferName(client));
+
+} /* SProcDbeDeallocateBackBufferName() */
+
+
+/******************************************************************************
+ *
+ * DBE DIX Procedure: SProcDbeSwapBuffers
+ *
+ * Description:
+ *
+ * This function is for processing a DbeSwapBuffers request on a swapped
+ * server. This request swaps the buffers for all windows listed,
+ * applying the appropriate swap action for each window.
+ *
+ * Return Values:
+ *
+ * BadMatch - a window in request is not double-buffered; a window in
+ * request is listed more than once; all windows in request do
+ * not have the same root
+ * BadValue - invalid swap action is specified
+ * BadWindow - a window in request is not valid
+ * Success
+ *
+ *****************************************************************************/
+
+static int
+SProcDbeSwapBuffers(ClientPtr client)
+{
+ REQUEST(xDbeSwapBuffersReq);
+ register int i, n;
+ xDbeSwapInfo *pSwapInfo;
+
+
+ swaps(&stuff->length, n);
+ REQUEST_AT_LEAST_SIZE(xDbeSwapBuffersReq);
+
+ swapl(&stuff->n, n);
+
+ if (stuff->n != 0)
+ {
+ pSwapInfo = (xDbeSwapInfo *)stuff+1;
+
+ /* The swap info following the fix part of this request is a window(32)
+ * followed by a 1 byte swap action and then 3 pad bytes. We only need
+ * to swap the window information.
+ */
+ for (i = 0; i < stuff->n; i++)
+ {
+ swapl(&pSwapInfo->window, n);
+ }
+ }
+
+ return(ProcDbeSwapBuffers(client));
+
+} /* SProcDbeSwapBuffers() */
+
+
+/******************************************************************************
+ *
+ * DBE DIX Procedure: SProcDbeBeginIdiom
+ *
+ * Description:
+ *
+ * This function is for processing a DbeBeginIdiom request on a swapped
+ * server. This request informs the server that a complex swap will
+ * immediately follow this request.
+ *
+ * Return Values:
+ *
+ * Success
+ *
+ *****************************************************************************/
+
+static int
+SProcDbeBeginIdiom(ClientPtr client)
+{
+ REQUEST(xDbeBeginIdiomReq);
+ register int n;
+
+ swaps(&stuff->length, n);
+ return(ProcDbeBeginIdiom(client));
+
+} /* SProcDbeBeginIdiom() */
+
+
+/******************************************************************************
+ *
+ * DBE DIX Procedure: SProcDbeGetVisualInfo
+ *
+ * Description:
+ *
+ * This function is for processing a ProcDbeGetVisualInfo request on a
+ * swapped server. This request returns information about which visuals
+ * support double buffering.
+ *
+ * Return Values:
+ *
+ * BadDrawable - value in screen specifiers is not a valid drawable
+ * Success
+ *
+ *****************************************************************************/
+
+static int
+SProcDbeGetVisualInfo(ClientPtr client)
+{
+ REQUEST(xDbeGetVisualInfoReq);
+ register int n;
+
+
+ swaps(&stuff->length, n);
+ REQUEST_AT_LEAST_SIZE(xDbeGetVisualInfoReq);
+
+ swapl(&stuff->n, n);
+ SwapRestL(stuff);
+
+ return(ProcDbeGetVisualInfo(client));
+
+} /* SProcDbeGetVisualInfo() */
+
+
+/******************************************************************************
+ *
+ * DBE DIX Procedure: SProcDbeGetbackBufferAttributes
+ *
+ * Description:
+ *
+ * This function is for processing a ProcDbeGetbackBufferAttributes
+ * request on a swapped server. This request returns information about a
+ * back buffer.
+ *
+ * Return Values:
+ *
+ * Success
+ *
+ *****************************************************************************/
+
+static int
+SProcDbeGetBackBufferAttributes(ClientPtr client)
+{
+ REQUEST (xDbeGetBackBufferAttributesReq);
+ register int n;
+
+ swaps(&stuff->length, n);
+ REQUEST_SIZE_MATCH(xDbeGetBackBufferAttributesReq);
+
+ swapl(&stuff->buffer, n);
+
+ return(ProcDbeGetBackBufferAttributes(client));
+
+} /* SProcDbeGetBackBufferAttributes() */
+
+
+/******************************************************************************
+ *
+ * DBE DIX Procedure: SProcDbeDispatch
+ *
+ * Description:
+ *
+ * This function dispatches DBE requests on a swapped server.
+ *
+ *****************************************************************************/
+
+static int
+SProcDbeDispatch(ClientPtr client)
+{
+ REQUEST(xReq);
+
+
+ switch (stuff->data)
+ {
+ case X_DbeGetVersion:
+ return(SProcDbeGetVersion(client));
+
+ case X_DbeAllocateBackBufferName:
+ return(SProcDbeAllocateBackBufferName(client));
+
+ case X_DbeDeallocateBackBufferName:
+ return(SProcDbeDeallocateBackBufferName(client));
+
+ case X_DbeSwapBuffers:
+ return(SProcDbeSwapBuffers(client));
+
+ case X_DbeBeginIdiom:
+ return(SProcDbeBeginIdiom(client));
+
+ case X_DbeEndIdiom:
+ return Success;
+
+ case X_DbeGetVisualInfo:
+ return(SProcDbeGetVisualInfo(client));
+
+ case X_DbeGetBackBufferAttributes:
+ return(SProcDbeGetBackBufferAttributes(client));
+
+ default:
+ return BadRequest;
+ }
+
+} /* SProcDbeDispatch() */
+
+
+/******************************************************************************
+ *
+ * DBE DIX Procedure: DbeSetupBackgroundPainter
+ *
+ * Description:
+ *
+ * This function sets up pGC to clear pixmaps.
+ *
+ * Return Values:
+ *
+ * TRUE - setup was successful
+ * FALSE - the window's background state is NONE
+ *
+ *****************************************************************************/
+
+static Bool
+DbeSetupBackgroundPainter(WindowPtr pWin, GCPtr pGC)
+{
+ ChangeGCVal gcvalues[4];
+ int ts_x_origin, ts_y_origin;
+ PixUnion background;
+ int backgroundState;
+ Mask gcmask;
+
+
+ /* First take care of any ParentRelative stuff by altering the
+ * tile/stipple origin to match the coordinates of the upper-left
+ * corner of the first ancestor without a ParentRelative background.
+ * This coordinate is, of course, negative.
+ */
+ ts_x_origin = ts_y_origin = 0;
+ while (pWin->backgroundState == ParentRelative)
+ {
+ ts_x_origin -= pWin->origin.x;
+ ts_y_origin -= pWin->origin.y;
+
+ pWin = pWin->parent;
+ }
+ backgroundState = pWin->backgroundState;
+ background = pWin->background;
+
+ switch (backgroundState)
+ {
+ case BackgroundPixel:
+ gcvalues[0].val = background.pixel;
+ gcvalues[1].val = FillSolid;
+ gcmask = GCForeground|GCFillStyle;
+ break;
+
+ case BackgroundPixmap:
+ gcvalues[0].val = FillTiled;
+ gcvalues[1].ptr = background.pixmap;
+ gcvalues[2].val = ts_x_origin;
+ gcvalues[3].val = ts_y_origin;
+ gcmask = GCFillStyle|GCTile|GCTileStipXOrigin|GCTileStipYOrigin;
+ break;
+
+ default:
+ /* pWin->backgroundState == None */
+ return FALSE;
+ }
+
+ return ChangeGC(NullClient, pGC, gcmask, gcvalues) == 0;
+} /* DbeSetupBackgroundPainter() */
+
+
+/******************************************************************************
+ *
+ * DBE DIX Procedure: DbeDrawableDelete
+ *
+ * Description:
+ *
+ * This is the resource delete function for dbeDrawableResType.
+ * It is registered when the drawable resource type is created in
+ * DbeExtensionInit().
+ *
+ * To make resource deletion simple, we do not do anything in this function
+ * and leave all resource deleteion to DbeWindowPrivDelete(), which will
+ * eventually be called or already has been called. Deletion functions are
+ * not guaranteed to be called in any particular order.
+ *
+ *****************************************************************************/
+static int
+DbeDrawableDelete(pointer pDrawable, XID id)
+{
+ return Success;
+
+} /* DbeDrawableDelete() */
+
+
+/******************************************************************************
+ *
+ * DBE DIX Procedure: DbeWindowPrivDelete
+ *
+ * Description:
+ *
+ * This is the resource delete function for dbeWindowPrivResType.
+ * It is registered when the drawable resource type is created in
+ * DbeExtensionInit().
+ *
+ *****************************************************************************/
+static int
+DbeWindowPrivDelete(pointer pDbeWinPriv, XID id)
+{
+ DbeScreenPrivPtr pDbeScreenPriv;
+ DbeWindowPrivPtr pDbeWindowPriv = (DbeWindowPrivPtr)pDbeWinPriv;
+ int i;
+
+
+ /*
+ **************************************************************************
+ ** Remove the buffer ID from the ID array.
+ **************************************************************************
+ */
+
+ /* Find the ID in the ID array. */
+ i = 0;
+ while ((i < pDbeWindowPriv->nBufferIDs) && (pDbeWindowPriv->IDs[i] != id))
+ {
+ i++;
+ }
+
+ if (i == pDbeWindowPriv->nBufferIDs)
+ {
+ /* We did not find the ID in the array. We should never get here. */
+ return BadValue;
+ }
+
+ /* Remove the ID from the array. */
+
+ if (i < (pDbeWindowPriv->nBufferIDs - 1))
+ {
+ /* Compress the buffer ID array, overwriting the ID in the process. */
+ memmove(&pDbeWindowPriv->IDs[i], &pDbeWindowPriv->IDs[i+1],
+ (pDbeWindowPriv->nBufferIDs - i - 1) * sizeof(XID));
+ }
+ else
+ {
+ /* We are removing the last ID in the array, in which case, the
+ * assignement below is all that we need to do.
+ */
+ }
+ pDbeWindowPriv->IDs[pDbeWindowPriv->nBufferIDs - 1] = DBE_FREE_ID_ELEMENT;
+
+ pDbeWindowPriv->nBufferIDs--;
+
+ /* If an extended array was allocated, then check to see if the remaining
+ * buffer IDs will fit in the static array.
+ */
+
+ if ((pDbeWindowPriv->maxAvailableIDs > DBE_INIT_MAX_IDS) &&
+ (pDbeWindowPriv->nBufferIDs == DBE_INIT_MAX_IDS))
+ {
+ /* Copy the IDs back into the static array. */
+ memcpy(pDbeWindowPriv->initIDs, pDbeWindowPriv->IDs,
+ DBE_INIT_MAX_IDS * sizeof(XID));
+
+ /* Free the extended array; use the static array. */
+ free(pDbeWindowPriv->IDs);
+ pDbeWindowPriv->IDs = pDbeWindowPriv->initIDs;
+ pDbeWindowPriv->maxAvailableIDs = DBE_INIT_MAX_IDS;
+ }
+
+
+ /*
+ **************************************************************************
+ ** Perform DDX level tasks.
+ **************************************************************************
+ */
+
+ pDbeScreenPriv = DBE_SCREEN_PRIV_FROM_WINDOW_PRIV(
+ (DbeWindowPrivPtr)pDbeWindowPriv);
+ (*pDbeScreenPriv->WinPrivDelete)((DbeWindowPrivPtr)pDbeWindowPriv, id);
+
+
+ /*
+ **************************************************************************
+ ** Perform miscellaneous tasks if this is the last buffer associated
+ ** with the window.
+ **************************************************************************
+ */
+
+ if (pDbeWindowPriv->nBufferIDs == 0)
+ {
+ /* Reset the DBE window priv pointer. */
+ dixSetPrivate(&pDbeWindowPriv->pWindow->devPrivates, dbeWindowPrivKey,
+ NULL);
+
+ /* We are done with the window priv. */
+ dixFreeObjectWithPrivates(pDbeWindowPriv, PRIVATE_DBE_WINDOW);
+ }
+
+ return Success;
+
+} /* DbeWindowPrivDelete() */
+
+
+/******************************************************************************
+ *
+ * DBE DIX Procedure: DbeResetProc
+ *
+ * Description:
+ *
+ * This routine is called at the end of every server generation.
+ * It deallocates any memory reserved for the extension and performs any
+ * other tasks related to shutting down the extension.
+ *
+ *****************************************************************************/
+static void
+DbeResetProc(ExtensionEntry *extEntry)
+{
+ int i;
+ ScreenPtr pScreen;
+ DbeScreenPrivPtr pDbeScreenPriv;
+
+ for (i = 0; i < screenInfo.numScreens; i++)
+ {
+ pScreen = screenInfo.screens[i];
+ pDbeScreenPriv = DBE_SCREEN_PRIV(pScreen);
+
+ if (pDbeScreenPriv)
+ {
+ /* Unwrap DestroyWindow, which was wrapped in DbeExtensionInit().*/
+ pScreen->DestroyWindow = pDbeScreenPriv->DestroyWindow;
+
+ if (pDbeScreenPriv->ResetProc)
+ (*pDbeScreenPriv->ResetProc)(pScreen);
+
+ free(pDbeScreenPriv);
+ }
+ }
+} /* DbeResetProc() */
+
+
+/******************************************************************************
+ *
+ * DBE DIX Procedure: DbeDestroyWindow
+ *
+ * Description:
+ *
+ * This is the wrapper for pScreen->DestroyWindow.
+ * This function frees buffer resources for a window before it is
+ * destroyed.
+ *
+ *****************************************************************************/
+
+static Bool
+DbeDestroyWindow(WindowPtr pWin)
+{
+ DbeScreenPrivPtr pDbeScreenPriv;
+ DbeWindowPrivPtr pDbeWindowPriv;
+ ScreenPtr pScreen;
+ Bool ret;
+
+
+ /*
+ **************************************************************************
+ ** 1. Unwrap the member routine.
+ **************************************************************************
+ */
+
+ pScreen = pWin->drawable.pScreen;
+ pDbeScreenPriv = DBE_SCREEN_PRIV(pScreen);
+ pScreen->DestroyWindow = pDbeScreenPriv->DestroyWindow;
+
+ /*
+ **************************************************************************
+ ** 2. Do any work necessary before the member routine is called.
+ **
+ ** Call the window priv delete function for all buffer IDs associated
+ ** with this window.
+ **************************************************************************
+ */
+
+ if ((pDbeWindowPriv = DBE_WINDOW_PRIV(pWin)))
+ {
+ while (pDbeWindowPriv)
+ {
+ /* *DbeWinPrivDelete() will free the window private and set it to
+ * NULL if there are no more buffer IDs associated with this
+ * window.
+ */
+ FreeResource(pDbeWindowPriv->IDs[0], RT_NONE);
+ pDbeWindowPriv = DBE_WINDOW_PRIV(pWin);
+ }
+ }
+
+ /*
+ **************************************************************************
+ ** 3. Call the member routine, saving its result if necessary.
+ **************************************************************************
+ */
+
+ ret = (*pScreen->DestroyWindow)(pWin);
+
+ /*
+ **************************************************************************
+ ** 4. Rewrap the member routine, restoring the wrapper value first in case
+ ** the wrapper (or something that it wrapped) change this value.
+ **************************************************************************
+ */
+
+ pDbeScreenPriv->DestroyWindow = pScreen->DestroyWindow;
+ pScreen->DestroyWindow = DbeDestroyWindow;
+
+ /*
+ **************************************************************************
+ ** 5. Do any work necessary after the member routine has been called.
+ **
+ ** In this case we do not need to do anything.
+ **************************************************************************
+ */
+
+ return ret;
+
+} /* DbeDestroyWindow() */
+
+
+/******************************************************************************
+ *
+ * DBE DIX Procedure: DbeExtensionInit
+ *
+ * Description:
+ *
+ * Called from InitExtensions in main()
+ *
+ *****************************************************************************/
+
+void
+DbeExtensionInit(void)
+{
+ ExtensionEntry *extEntry;
+ register int i, j;
+ ScreenPtr pScreen = NULL;
+ DbeScreenPrivPtr pDbeScreenPriv;
+ int nStubbedScreens = 0;
+ Bool ddxInitSuccess;
+
+#ifdef PANORAMIX
+ if(!noPanoramiXExtension) return;
+#endif
+
+ /* Create the resource types. */
+ dbeDrawableResType =
+ CreateNewResourceType(DbeDrawableDelete, "dbeDrawable");
+ if (!dbeDrawableResType)
+ return;
+ dbeDrawableResType |= RC_DRAWABLE;
+
+ dbeWindowPrivResType =
+ CreateNewResourceType(DbeWindowPrivDelete, "dbeWindow");
+ if (!dbeWindowPrivResType)
+ return;
+
+ if (!dixRegisterPrivateKey(&dbeScreenPrivKeyRec, PRIVATE_SCREEN, 0))
+ return;
+
+ if (!dixRegisterPrivateKey(&dbeWindowPrivKeyRec, PRIVATE_WINDOW, 0))
+ return;
+
+ for (i = 0; i < screenInfo.numScreens; i++)
+ {
+ /* For each screen, set up DBE screen privates and init DIX and DDX
+ * interface.
+ */
+
+ pScreen = screenInfo.screens[i];
+
+ if (!(pDbeScreenPriv = malloc (sizeof (DbeScreenPrivRec))))
+ {
+ /* If we can not alloc a window or screen private,
+ * then free any privates that we already alloc'ed and return
+ */
+
+ for (j = 0; j < i; j++)
+ {
+ free(dixLookupPrivate(&screenInfo.screens[j]->devPrivates,
+ dbeScreenPrivKey));
+ dixSetPrivate(&screenInfo.screens[j]->devPrivates,
+ dbeScreenPrivKey, NULL);
+ }
+ return;
+ }
+
+ dixSetPrivate(&pScreen->devPrivates, dbeScreenPrivKey, pDbeScreenPriv);
+
+ {
+ /* We don't have DDX support for DBE anymore */
+
+#ifndef DISABLE_MI_DBE_BY_DEFAULT
+ /* Setup DIX. */
+ pDbeScreenPriv->SetupBackgroundPainter = DbeSetupBackgroundPainter;
+
+ /* Setup DDX. */
+ ddxInitSuccess = miDbeInit(pScreen, pDbeScreenPriv);
+
+ /* DDX DBE initialization may have the side affect of
+ * reallocating pDbeScreenPriv, so we need to update it.
+ */
+ pDbeScreenPriv = DBE_SCREEN_PRIV(pScreen);
+
+ if (ddxInitSuccess)
+ {
+ /* Wrap DestroyWindow. The DDX initialization function
+ * already wrapped PositionWindow for us.
+ */
+
+ pDbeScreenPriv->DestroyWindow = pScreen->DestroyWindow;
+ pScreen->DestroyWindow = DbeDestroyWindow;
+ }
+ else
+ {
+ /* DDX initialization failed. Stub the screen. */
+ DbeStubScreen(pDbeScreenPriv, &nStubbedScreens);
+ }
+#else
+ DbeStubScreen(pDbeScreenPriv, &nStubbedScreens);
+#endif
+
+ }
+
+ } /* for (i = 0; i < screenInfo.numScreens; i++) */
+
+
+ if (nStubbedScreens == screenInfo.numScreens)
+ {
+ /* All screens stubbed. Clean up and return. */
+
+ for (i = 0; i < screenInfo.numScreens; i++)
+ {
+ free(dixLookupPrivate(&screenInfo.screens[i]->devPrivates,
+ dbeScreenPrivKey));
+ dixSetPrivate(&pScreen->devPrivates, dbeScreenPrivKey, NULL);
+ }
+ return;
+ }
+
+
+ /* Now add the extension. */
+ extEntry = AddExtension(DBE_PROTOCOL_NAME, DbeNumberEvents,
+ DbeNumberErrors, ProcDbeDispatch, SProcDbeDispatch,
+ DbeResetProc, StandardMinorOpcode);
+
+ dbeErrorBase = extEntry->errorBase;
+ SetResourceTypeErrorValue(dbeWindowPrivResType, dbeErrorBase + DbeBadBuffer);
+ SetResourceTypeErrorValue(dbeDrawableResType, dbeErrorBase + DbeBadBuffer);
+
+} /* DbeExtensionInit() */
+
diff --git a/xorg-server/devbook.am b/xorg-server/devbook.am
new file mode 100644
index 000000000..4e23bb78e
--- /dev/null
+++ b/xorg-server/devbook.am
@@ -0,0 +1,62 @@
+#
+# Generate output formats for a single DocBook/XML with/without chapters
+#
+# Variables set by the calling Makefile:
+# noinst_DATA: developers docs are not installed
+# docbook: the main DocBook/XML file, no chapters, appendix or image files
+# chapters: all files pulled in by an XInclude statement and images.
+#
+
+#
+# This makefile is intended for Developers Documentation and is not installed.
+# Do not use for Users docs or Specs which need to be installed and require olink support
+# Refer to http://www.x.org/releases/X11R7.6/doc/xorg-docs/ReleaseNotes.html#id2584393
+# for an explanation on documents classification.
+#
+
+# Developers documnetation is not installed
+noinst_DATA =
+
+# DocBook/XML file with chapters, appendix and images it includes
+dist_noinst_DATA = $(docbook) $(chapters)
+
+#
+# Generate DocBook/XML output formats with or without stylesheets
+#
+
+# Stylesheets are available if the package xorg-sgml-doctools is installed
+if HAVE_STYLESHEETS
+
+# The location where all cross reference databases are installed
+XMLTO_FLAGS = \
+ --searchpath "$(XORG_SGML_PATH)/X11" \
+ --searchpath "$(abs_top_builddir)" \
+ --stringparam current.docid="$(<:.xml=)"
+
+XMLTO_XHTML_FLAGS = \
+ -m $(STYLESHEET_SRCDIR)/xorg-xhtml.xsl \
+ --stringparam html.stylesheet=$(STYLESHEET_SRCDIR)/xorg.css
+
+XMLTO_FO_FLAGS = \
+ -m $(STYLESHEET_SRCDIR)/xorg-fo.xsl
+endif HAVE_STYLESHEETS
+
+noinst_DATA += $(docbook:.xml=.html)
+%.html: %.xml $(chapters)
+ $(AM_V_GEN)$(XMLTO) $(XMLTO_FLAGS) $(XMLTO_XHTML_FLAGS) xhtml-nochunks $<
+
+if HAVE_FOP
+noinst_DATA += $(docbook:.xml=.pdf) $(docbook:.xml=.ps)
+%.pdf: %.xml $(chapters)
+ $(AM_V_GEN)$(XMLTO) $(XMLTO_FLAGS) $(XMLTO_FO_FLAGS) --with-fop pdf $<
+%.ps: %.xml $(chapters)
+ $(AM_V_GEN)$(XMLTO) $(XMLTO_FLAGS) $(XMLTO_FO_FLAGS) --with-fop ps $<
+endif HAVE_FOP
+
+if HAVE_XMLTO_TEXT
+noinst_DATA += $(docbook:.xml=.txt)
+%.txt: %.xml $(chapters)
+ $(AM_V_GEN)$(XMLTO) $(XMLTO_FLAGS) $(XMLTO_XHTML_FLAGS) txt $<
+endif HAVE_XMLTO_TEXT
+
+CLEANFILES = $(noinst_DATA)
diff --git a/xorg-server/dix/devices.c b/xorg-server/dix/devices.c
index 3f46ad6fb..9a4498b9f 100644
--- a/xorg-server/dix/devices.c
+++ b/xorg-server/dix/devices.c
@@ -2365,10 +2365,10 @@ RecalculateMasterButtons(DeviceIntPtr slave)
* Generate release events for all keys/button currently down on this
* device.
*/
-static void
+void
ReleaseButtonsAndKeys(DeviceIntPtr dev)
{
- EventListPtr eventlist = InitEventList(GetMaximumEventsNum());
+ InternalEvent* eventlist = InitEventList(GetMaximumEventsNum());
ButtonClassPtr b = dev->button;
KeyClassPtr k = dev->key;
int i, j, nevents;
@@ -2383,7 +2383,7 @@ ReleaseButtonsAndKeys(DeviceIntPtr dev)
{
nevents = GetPointerEvents(eventlist, dev, ButtonRelease, i, 0, NULL);
for (j = 0; j < nevents; j++)
- mieqProcessDeviceEvent(dev, (InternalEvent*)(eventlist+j)->event, NULL);
+ mieqProcessDeviceEvent(dev, &eventlist[j], NULL);
}
}
@@ -2394,7 +2394,7 @@ ReleaseButtonsAndKeys(DeviceIntPtr dev)
{
nevents = GetKeyboardEvents(eventlist, dev, KeyRelease, i, NULL);
for (j = 0; j < nevents; j++)
- mieqProcessDeviceEvent(dev, (InternalEvent*)(eventlist+j)->event, NULL);
+ mieqProcessDeviceEvent(dev, &eventlist[j], NULL);
}
}
@@ -2434,8 +2434,6 @@ AttachDevice(ClientPtr client, DeviceIntPtr dev, DeviceIntPtr master)
free(dev->spriteInfo->sprite);
}
- ReleaseButtonsAndKeys(dev);
-
oldmaster = GetMaster(dev, MASTER_ATTACHED);
dev->master = master;
diff --git a/xorg-server/dix/eventconvert.c b/xorg-server/dix/eventconvert.c
index 14731f4f6..024f2e833 100644
--- a/xorg-server/dix/eventconvert.c
+++ b/xorg-server/dix/eventconvert.c
@@ -156,7 +156,7 @@ EventToCore(InternalEvent *event, xEvent **core_out, int *count_out)
case ET_RawButtonRelease:
case ET_RawMotion:
ret = BadMatch;
- goto out;
+ break;
default:
/* XXX: */
ErrorF("[dix] EventToCore: Not implemented yet \n");
diff --git a/xorg-server/dix/events.c b/xorg-server/dix/events.c
index d70d62fd8..14f6f909e 100644
--- a/xorg-server/dix/events.c
+++ b/xorg-server/dix/events.c
@@ -176,12 +176,23 @@ typedef const char *string;
#define AllEventMasks (LastEventMask|(LastEventMask-1))
-#define CORE_EVENT(event) \
- (!((event)->u.u.type & EXTENSION_EVENT_BASE) && \
- (event)->u.u.type != GenericEvent)
-#define XI2_EVENT(event) \
- (((event)->u.u.type == GenericEvent) && \
- ((xGenericEvent*)(event))->extension == IReqCode)
+/* @return the core event type or 0 if the event is not a core event */
+static inline int
+core_get_type(const xEvent *event)
+{
+ int type = event->u.u.type;
+
+ return ((type & EXTENSION_EVENT_BASE) || type == GenericEvent) ? 0 : type;
+}
+
+/* @return the XI2 event type or 0 if the event is not a XI2 event */
+static inline int
+xi2_get_type(const xEvent *event)
+{
+ xGenericEvent* e = (xGenericEvent*)event;
+
+ return (e->type != GenericEvent || e->extension != IReqCode) ? 0 : e->evtype;
+}
/**
* Used to indicate a implicit passive grab created by a ButtonPress event.
@@ -345,8 +356,8 @@ extern int DeviceMotionNotify;
/**
* Event masks for each event type.
*
- * One set of filters for each device, but only the first layer
- * is initialized. The rest is memcpy'd in InitEvents.
+ * One set of filters for each device, initialized by memcpy of
+ * default_filter in InitEvents.
*
* Filters are used whether a given event may be delivered to a client,
* usually in the form of if (window-event-mask & filter); then deliver event.
@@ -355,7 +366,9 @@ extern int DeviceMotionNotify;
* time a button is pressed, the filter is modified to also contain the
* matching ButtonXMotion mask.
*/
-static Mask filters[MAXDEVICES][128] = {
+static Mask filters[MAXDEVICES][128];
+
+static const Mask default_filter[128] =
{
NoSuchEvent, /* 0 */
NoSuchEvent, /* 1 */
@@ -392,7 +405,7 @@ static Mask filters[MAXDEVICES][128] = {
ColormapChangeMask, /* ColormapNotify */
CantBeFiltered, /* ClientMessage */
CantBeFiltered /* MappingNotify */
-}};
+};
/**
* For the given event, return the matching event filter. This filter may then
@@ -412,10 +425,12 @@ static Mask filters[MAXDEVICES][128] = {
Mask
GetEventFilter(DeviceIntPtr dev, xEvent *event)
{
+ int evtype = 0;
+
if (event->u.u.type != GenericEvent)
return filters[dev ? dev->id : 0][event->u.u.type];
- else if (XI2_EVENT(event))
- return (1 << (((xXIDeviceEvent*)event)->evtype % 8));
+ else if ((evtype = xi2_get_type(event)))
+ return (1 << (evtype % 8));
ErrorF("[dix] Unknown device type %d. No filter\n", event->u.u.type);
return 0;
}
@@ -430,7 +445,7 @@ GetWindowXI2Mask(DeviceIntPtr dev, WindowPtr win, xEvent* ev)
int filter;
int evtype;
- if (!inputMasks || !XI2_EVENT(ev))
+ if (!inputMasks || xi2_get_type(ev) == 0)
return 0;
evtype = ((xGenericEvent*)ev)->evtype;
@@ -444,14 +459,16 @@ GetWindowXI2Mask(DeviceIntPtr dev, WindowPtr win, xEvent* ev)
Mask
GetEventMask(DeviceIntPtr dev, xEvent *event, InputClients* other)
{
+ int evtype;
+
/* XI2 filters are only ever 8 bit, so let's return a 8 bit mask */
- if (XI2_EVENT(event))
+ if ((evtype = xi2_get_type(event)))
{
- int byte = ((xGenericEvent*)event)->evtype / 8;
+ int byte = evtype / 8;
return (other->xi2mask[dev->id][byte] |
other->xi2mask[XIAllDevices][byte] |
(IsMaster(dev)? other->xi2mask[XIAllMasterDevices][byte] : 0));
- } else if (CORE_EVENT(event))
+ } else if (core_get_type(event) != 0)
return other->mask[XIAllDevices];
else
return other->mask[dev->id];
@@ -1937,6 +1954,159 @@ TryClientEvents (ClientPtr client, DeviceIntPtr dev, xEvent *pEvents,
return 1;
}
+static BOOL
+ActivateImplicitGrab(DeviceIntPtr dev, ClientPtr client, WindowPtr win,
+ xEvent *event, Mask deliveryMask)
+{
+ GrabRec tempGrab;
+ OtherInputMasks *inputMasks;
+ CARD8 type = event->u.u.type;
+ GrabType grabtype;
+
+ if (type == ButtonPress)
+ grabtype = GRABTYPE_CORE;
+ else if (type == DeviceButtonPress)
+ grabtype = GRABTYPE_XI;
+ else if ((type = xi2_get_type(event)) == XI_ButtonPress)
+ grabtype = GRABTYPE_XI2;
+ else
+ return FALSE;
+
+ memset(&tempGrab, 0, sizeof(GrabRec));
+ tempGrab.next = NULL;
+ tempGrab.device = dev;
+ tempGrab.resource = client->clientAsMask;
+ tempGrab.window = win;
+ tempGrab.ownerEvents = (deliveryMask & OwnerGrabButtonMask) ? TRUE : FALSE;
+ tempGrab.eventMask = deliveryMask;
+ tempGrab.keyboardMode = GrabModeAsync;
+ tempGrab.pointerMode = GrabModeAsync;
+ tempGrab.confineTo = NullWindow;
+ tempGrab.cursor = NullCursor;
+ tempGrab.type = type;
+ tempGrab.grabtype = grabtype;
+
+ /* get the XI and XI2 device mask */
+ inputMasks = wOtherInputMasks(win);
+ tempGrab.deviceMask = (inputMasks) ? inputMasks->inputEvents[dev->id]: 0;
+
+ if (inputMasks)
+ memcpy(tempGrab.xi2mask, inputMasks->xi2mask,
+ sizeof(tempGrab.xi2mask));
+
+ (*dev->deviceGrab.ActivateGrab)(dev, &tempGrab,
+ currentTime, TRUE | ImplicitGrabMask);
+ return TRUE;
+}
+
+enum EventDeliveryState {
+ EVENT_DELIVERED, /**< Event has been delivered to a client */
+ EVENT_NOT_DELIVERED, /**< Event was not delivered to any client */
+ EVENT_SKIP, /**< Event can be discarded by the caller */
+ EVENT_REJECTED, /**< Event was rejected for delivery to the client */
+};
+
+/**
+ * Attempt event delivery to the client owning the window.
+ */
+static enum EventDeliveryState
+DeliverToWindowOwner(DeviceIntPtr dev, WindowPtr win,
+ xEvent *events, int count, Mask filter,
+ GrabPtr grab)
+{
+ /* if nobody ever wants to see this event, skip some work */
+ if (filter != CantBeFiltered &&
+ !((wOtherEventMasks(win)|win->eventMask) & filter))
+ return EVENT_SKIP;
+
+ if (IsInterferingGrab(wClient(win), dev, events))
+ return EVENT_SKIP;
+
+ if (!XaceHook(XACE_RECEIVE_ACCESS, wClient(win), win, events, count))
+ {
+ int attempt = TryClientEvents(wClient(win), dev, events,
+ count, win->eventMask,
+ filter, grab);
+ if (attempt > 0)
+ return EVENT_DELIVERED;
+ if (attempt < 0)
+ return EVENT_REJECTED;
+ }
+
+ return EVENT_NOT_DELIVERED;
+}
+
+/**
+ * Deliver events to clients registered on the window.
+ *
+ * @param client_return On successful delivery, set to the recipient.
+ * @param mask_return On successful delivery, set to the recipient's event
+ * mask for this event.
+ */
+static enum EventDeliveryState
+DeliverEventToClients(DeviceIntPtr dev, WindowPtr win, xEvent *events,
+ int count, Mask filter, GrabPtr grab,
+ ClientPtr *client_return, Mask *mask_return)
+{
+ int attempt;
+ enum EventDeliveryState rc = EVENT_SKIP;
+ InputClients *other;
+
+ if (core_get_type(events) != 0)
+ other = (InputClients *)wOtherClients(win);
+ else if (xi2_get_type(events) != 0)
+ {
+ OtherInputMasks *inputMasks = wOtherInputMasks(win);
+ /* Has any client selected for the event? */
+ if (!GetWindowXI2Mask(dev, win, events))
+ goto out;
+ other = inputMasks->inputClients;
+ } else {
+ OtherInputMasks *inputMasks = wOtherInputMasks(win);
+ /* Has any client selected for the event? */
+ if (!inputMasks ||
+ !(inputMasks->inputEvents[dev->id] & filter))
+ goto out;
+
+ other = inputMasks->inputClients;
+ }
+
+ rc = EVENT_NOT_DELIVERED;
+
+ for (; other; other = other->next)
+ {
+ Mask mask;
+ ClientPtr client = rClient(other);
+
+ if (IsInterferingGrab(client, dev, events))
+ continue;
+
+ mask = GetEventMask(dev, events, other);
+
+ if (XaceHook(XACE_RECEIVE_ACCESS, client, win,
+ events, count))
+ /* do nothing */;
+ else if ( (attempt = TryClientEvents(client, dev,
+ events, count,
+ mask, filter, grab)) )
+ {
+ if (attempt > 0)
+ {
+ rc = EVENT_DELIVERED;
+ *client_return = client;
+ *mask_return = mask;
+ /* Success overrides non-success, so if we've been
+ * successful on one client, return that */
+ } else if (rc == EVENT_NOT_DELIVERED)
+ rc = EVENT_REJECTED;
+ }
+ }
+
+out:
+ return rc;
+}
+
+
/**
* Deliver events to a window. At this point, we do not yet know if the event
* actually needs to be delivered. May activate a grab if the event is a
@@ -1955,152 +2125,84 @@ TryClientEvents (ClientPtr client, DeviceIntPtr dev, xEvent *pEvents,
* @param filter Mask based on event type.
* @param grab Possible grab on the device that caused the event.
*
- * @return Number of events delivered to various clients.
+ * @return a positive number if at least one successful delivery has been
+ * made, 0 if no events were delivered, or a negative number if the event
+ * has not been delivered _and_ rejected by at least one client.
*/
int
DeliverEventsToWindow(DeviceIntPtr pDev, WindowPtr pWin, xEvent
*pEvents, int count, Mask filter, GrabPtr grab)
{
int deliveries = 0, nondeliveries = 0;
- int attempt;
- InputClients *other;
ClientPtr client = NullClient;
Mask deliveryMask = 0; /* If a grab occurs due to a button press, then
this mask is the mask of the grab. */
int type = pEvents->u.u.type;
-
/* Deliver to window owner */
- if ((filter == CantBeFiltered) || CORE_EVENT(pEvents))
+ if ((filter == CantBeFiltered) || core_get_type(pEvents) != 0)
{
- /* if nobody ever wants to see this event, skip some work */
- if (filter != CantBeFiltered &&
- !((wOtherEventMasks(pWin)|pWin->eventMask) & filter))
- return 0;
+ enum EventDeliveryState rc;
- if (IsInterferingGrab(wClient(pWin), pDev, pEvents))
- return 0;
+ rc = DeliverToWindowOwner(pDev, pWin, pEvents, count, filter, grab);
- if (XaceHook(XACE_RECEIVE_ACCESS, wClient(pWin), pWin, pEvents, count))
- /* do nothing */;
- else if ( (attempt = TryClientEvents(wClient(pWin), pDev, pEvents,
- count, pWin->eventMask,
- filter, grab)) )
- {
- if (attempt > 0)
- {
- deliveries++;
- client = wClient(pWin);
- deliveryMask = pWin->eventMask;
- } else
- nondeliveries--;
- }
+ switch(rc)
+ {
+ case EVENT_SKIP:
+ return 0;
+ case EVENT_REJECTED:
+ nondeliveries--;
+ break;
+ case EVENT_DELIVERED:
+ /* We delivered to the owner, with our event mask */
+ deliveries++;
+ client = wClient(pWin);
+ deliveryMask = pWin->eventMask;
+ break;
+ case EVENT_NOT_DELIVERED:
+ break;
+ }
}
/* CantBeFiltered means only window owner gets the event */
if (filter != CantBeFiltered)
{
- if (CORE_EVENT(pEvents))
- other = (InputClients *)wOtherClients(pWin);
- else if (XI2_EVENT(pEvents))
- {
- OtherInputMasks *inputMasks = wOtherInputMasks(pWin);
- /* Has any client selected for the event? */
- if (!GetWindowXI2Mask(pDev, pWin, pEvents))
- return 0;
- other = inputMasks->inputClients;
- } else {
- OtherInputMasks *inputMasks = wOtherInputMasks(pWin);
- /* Has any client selected for the event? */
- if (!inputMasks ||
- !(inputMasks->inputEvents[pDev->id] & filter))
- return 0;
+ enum EventDeliveryState rc;
- other = inputMasks->inputClients;
- }
+ rc = DeliverEventToClients(pDev, pWin, pEvents, count, filter, grab,
+ &client, &deliveryMask);
- for (; other; other = other->next)
+ switch(rc)
{
- Mask mask;
- if (IsInterferingGrab(rClient(other), pDev, pEvents))
- continue;
-
- mask = GetEventMask(pDev, pEvents, other);
-
- if (XaceHook(XACE_RECEIVE_ACCESS, rClient(other), pWin,
- pEvents, count))
- /* do nothing */;
- else if ( (attempt = TryClientEvents(rClient(other), pDev,
- pEvents, count,
- mask, filter, grab)) )
- {
- if (attempt > 0)
- {
- deliveries++;
- client = rClient(other);
- deliveryMask = mask;
- } else
- nondeliveries--;
- }
+ case EVENT_SKIP:
+ return 0;
+ case EVENT_REJECTED:
+ nondeliveries--;
+ break;
+ case EVENT_DELIVERED:
+ deliveries++;
+ break;
+ case EVENT_NOT_DELIVERED:
+ break;
}
}
- /*
- * Note that since core events are delivered first, an implicit grab may
- * be activated on a core grab, stopping the XI events.
- */
- if ((type == DeviceButtonPress || type == ButtonPress ||
- ((XI2_EVENT(pEvents) && ((xGenericEvent*)pEvents)->evtype == XI_ButtonPress)))
- && deliveries
- && (!grab))
- {
- GrabRec tempGrab;
- OtherInputMasks *inputMasks;
- memset(&tempGrab, 0, sizeof(GrabRec));
- tempGrab.next = NULL;
- tempGrab.device = pDev;
- tempGrab.resource = client->clientAsMask;
- tempGrab.window = pWin;
- tempGrab.ownerEvents = (deliveryMask & OwnerGrabButtonMask) ? TRUE : FALSE;
- tempGrab.eventMask = deliveryMask;
- tempGrab.keyboardMode = GrabModeAsync;
- tempGrab.pointerMode = GrabModeAsync;
- tempGrab.confineTo = NullWindow;
- tempGrab.cursor = NullCursor;
- tempGrab.type = type;
- if (type == ButtonPress)
- tempGrab.grabtype = GRABTYPE_CORE;
- else if (type == DeviceButtonPress)
- tempGrab.grabtype = GRABTYPE_XI;
- else
- {
- tempGrab.type = ((xGenericEvent*)pEvents)->evtype;
- tempGrab.grabtype = GRABTYPE_XI2;
- }
-
- /* get the XI and XI2 device mask */
- inputMasks = wOtherInputMasks(pWin);
- tempGrab.deviceMask = (inputMasks) ? inputMasks->inputEvents[pDev->id]: 0;
-
- if (inputMasks)
- memcpy(tempGrab.xi2mask, inputMasks->xi2mask,
- sizeof(tempGrab.xi2mask));
-
- (*pDev->deviceGrab.ActivateGrab)(pDev, &tempGrab,
- currentTime, TRUE | ImplicitGrabMask);
- }
- else if ((type == MotionNotify) && deliveries)
- pDev->valuator->motionHintWindow = pWin;
- else
- {
- if ((type == DeviceMotionNotify || type == DeviceButtonPress) &&
- deliveries)
- CheckDeviceGrabAndHintWindow (pWin, type,
- (deviceKeyButtonPointer*) pEvents,
- grab, client, deliveryMask);
- }
if (deliveries)
+ {
+ /*
+ * Note that since core events are delivered first, an implicit grab may
+ * be activated on a core grab, stopping the XI events.
+ */
+ if (!grab && ActivateImplicitGrab(pDev, client, pWin, pEvents, deliveryMask))
+ /* grab activated */;
+ else if ((type == MotionNotify))
+ pDev->valuator->motionHintWindow = pWin;
+ else if (type == DeviceMotionNotify || type == DeviceButtonPress)
+ CheckDeviceGrabAndHintWindow (pWin, type,
+ (deviceKeyButtonPointer*) pEvents,
+ grab, client, deliveryMask);
return deliveries;
+ }
return nondeliveries;
}
@@ -2180,7 +2282,7 @@ MaybeDeliverEventsToClient(WindowPtr pWin, xEvent *pEvents,
static Window FindChildForEvent(SpritePtr pSprite, WindowPtr event)
{
- WindowPtr w = pSprite->spriteTrace[pSprite->spriteTraceGood-1];
+ WindowPtr w = DeepestSpriteWin(pSprite);
Window child = None;
/* If the search ends up past the root should the child field be
@@ -2224,22 +2326,29 @@ FixUpEventFromWindow(
Window child,
Bool calcChild)
{
+ int evtype;
+
if (calcChild)
child = FindChildForEvent(pSprite, pWin);
- if (XI2_EVENT(xE))
+ if ((evtype = xi2_get_type(xE)))
{
xXIDeviceEvent* event = (xXIDeviceEvent*)xE;
- if (event->evtype == XI_RawKeyPress ||
- event->evtype == XI_RawKeyRelease ||
- event->evtype == XI_RawButtonPress ||
- event->evtype == XI_RawButtonRelease ||
- event->evtype == XI_RawMotion ||
- event->evtype == XI_DeviceChanged ||
- event->evtype == XI_HierarchyChanged ||
- event->evtype == XI_PropertyEvent)
- return;
+ switch (evtype)
+ {
+ case XI_RawKeyPress:
+ case XI_RawKeyRelease:
+ case XI_RawButtonPress:
+ case XI_RawButtonRelease:
+ case XI_RawMotion:
+ case XI_DeviceChanged:
+ case XI_HierarchyChanged:
+ case XI_PropertyEvent:
+ return;
+ default:
+ break;
+ }
event->root = RootWindow(pSprite)->drawable.id;
event->event = pWin->drawable.id;
@@ -2375,7 +2484,7 @@ DeliverDeviceEvents(WindowPtr pWin, InternalEvent *event, GrabPtr grab,
xEvent *xE = NULL, *core = NULL;
int rc, mask, count = 0;
- CHECKEVENT(event);
+ verify_internal_event(event);
while (pWin)
{
@@ -2623,7 +2732,7 @@ XYToWindow(SpritePtr pSprite, int x, int y)
else
pWin = pWin->nextSib;
}
- return pSprite->spriteTrace[pSprite->spriteTraceGood-1];
+ return DeepestSpriteWin(pSprite);
}
/**
@@ -2661,7 +2770,8 @@ ActivateFocusInGrab(DeviceIntPtr dev, WindowPtr old, WindowPtr win)
event.deviceid = dev->id;
event.sourceid = dev->id;
event.detail.button = 0;
- rc = (CheckPassiveGrabsOnWindow(win, dev, &event, FALSE, TRUE) != NULL);
+ rc = (CheckPassiveGrabsOnWindow(win, dev, (InternalEvent *) &event, FALSE,
+ TRUE) != NULL);
if (rc)
DoEnterLeaveEvents(dev, dev->id, old, win, XINotifyPassiveUngrab);
return rc;
@@ -2698,7 +2808,8 @@ ActivateEnterGrab(DeviceIntPtr dev, WindowPtr old, WindowPtr win)
event.deviceid = dev->id;
event.sourceid = dev->id;
event.detail.button = 0;
- rc = (CheckPassiveGrabsOnWindow(win, dev, &event, FALSE, TRUE) != NULL);
+ rc = (CheckPassiveGrabsOnWindow(win, dev, (InternalEvent *) &event, FALSE,
+ TRUE) != NULL);
if (rc)
DoEnterLeaveEvents(dev, dev->id, old, win, XINotifyPassiveGrab);
return rc;
@@ -2721,7 +2832,7 @@ CheckMotion(DeviceEvent *ev, DeviceIntPtr pDev)
WindowPtr prevSpriteWin, newSpriteWin;
SpritePtr pSprite = pDev->spriteInfo->sprite;
- CHECKEVENT(ev);
+ verify_internal_event(ev);
prevSpriteWin = pSprite->win;
@@ -3385,7 +3496,7 @@ GrabPtr
CheckPassiveGrabsOnWindow(
WindowPtr pWin,
DeviceIntPtr device,
- DeviceEvent *event,
+ InternalEvent *event,
BOOL checkCore,
BOOL activate)
{
@@ -3402,9 +3513,22 @@ CheckPassiveGrabsOnWindow(
return NULL;
/* Fill out the grab details, but leave the type for later before
* comparing */
+ switch (event->any.type)
+ {
+ case ET_KeyPress:
+ case ET_KeyRelease:
+ tempGrab.detail.exact = event->device_event.detail.key;
+ break;
+ case ET_ButtonPress:
+ case ET_ButtonRelease:
+ tempGrab.detail.exact = event->device_event.detail.button;
+ break;
+ default:
+ tempGrab.detail.exact = 0;
+ break;
+ }
tempGrab.window = pWin;
tempGrab.device = device;
- tempGrab.detail.exact = event->detail.key;
tempGrab.detail.pMask = NULL;
tempGrab.modifiersDetail.pMask = NULL;
tempGrab.next = NULL;
@@ -3412,6 +3536,8 @@ CheckPassiveGrabsOnWindow(
{
DeviceIntPtr gdev;
XkbSrvInfoPtr xkbi = NULL;
+ xEvent *xE = NULL;
+ int count, rc;
gdev= grab->modifierDevice;
if (grab->grabtype == GRABTYPE_CORE)
@@ -3437,16 +3563,15 @@ CheckPassiveGrabsOnWindow(
tempGrab.modifiersDetail.exact = xkbi ? xkbi->state.grab_mods : 0;
/* Check for XI2 and XI grabs first */
- tempGrab.type = GetXI2Type((InternalEvent*)event);
+ tempGrab.type = GetXI2Type(event);
tempGrab.grabtype = GRABTYPE_XI2;
if (GrabMatchesSecond(&tempGrab, grab, FALSE))
match = XI2_MATCH;
- tempGrab.detail.exact = event->detail.key;
if (!match)
{
tempGrab.grabtype = GRABTYPE_XI;
- if ((tempGrab.type = GetXIType((InternalEvent*)event)) &&
+ if ((tempGrab.type = GetXIType(event)) &&
(GrabMatchesSecond(&tempGrab, grab, FALSE)))
match = XI_MATCH;
}
@@ -3455,122 +3580,134 @@ CheckPassiveGrabsOnWindow(
if (!match && checkCore)
{
tempGrab.grabtype = GRABTYPE_CORE;
- if ((tempGrab.type = GetCoreType((InternalEvent*)event)) &&
+ if ((tempGrab.type = GetCoreType(event)) &&
(GrabMatchesSecond(&tempGrab, grab, TRUE)))
match = CORE_MATCH;
}
- if (match && (!grab->confineTo ||
- (grab->confineTo->realized &&
- BorderSizeNotEmpty(device, grab->confineTo))))
- {
- int rc, count = 0;
- xEvent *xE = NULL;
-
- event->corestate &= 0x1f00;
- event->corestate |= tempGrab.modifiersDetail.exact & (~0x1f00);
- grabinfo = &device->deviceGrab;
- /* In some cases a passive core grab may exist, but the client
- * already has a core grab on some other device. In this case we
- * must not get the grab, otherwise we may never ungrab the
- * device.
- */
-
- if (grab->grabtype == GRABTYPE_CORE)
+ if (!match || (grab->confineTo &&
+ (!grab->confineTo->realized ||
+ !BorderSizeNotEmpty(device, grab->confineTo))))
+ continue;
+
+ grabinfo = &device->deviceGrab;
+ /* In some cases a passive core grab may exist, but the client
+ * already has a core grab on some other device. In this case we
+ * must not get the grab, otherwise we may never ungrab the
+ * device.
+ */
+
+ if (grab->grabtype == GRABTYPE_CORE)
+ {
+ DeviceIntPtr other;
+ BOOL interfering = FALSE;
+
+ /* A passive grab may have been created for a different device
+ than it is assigned to at this point in time.
+ Update the grab's device and modifier device to reflect the
+ current state.
+ Since XGrabDeviceButton requires to specify the
+ modifierDevice explicitly, we don't override this choice.
+ */
+ if (tempGrab.type < GenericEvent)
{
- DeviceIntPtr other;
- BOOL interfering = FALSE;
-
- /* A passive grab may have been created for a different device
- than it is assigned to at this point in time.
- Update the grab's device and modifier device to reflect the
- current state.
- Since XGrabDeviceButton requires to specify the
- modifierDevice explicitly, we don't override this choice.
- */
- if (tempGrab.type < GenericEvent)
- {
- grab->device = device;
- grab->modifierDevice = GetPairedDevice(device);
- }
+ grab->device = device;
+ grab->modifierDevice = GetPairedDevice(device);
+ }
- for (other = inputInfo.devices; other; other = other->next)
+ for (other = inputInfo.devices; other; other = other->next)
+ {
+ GrabPtr othergrab = other->deviceGrab.grab;
+ if (othergrab && othergrab->grabtype == GRABTYPE_CORE &&
+ SameClient(grab, rClient(othergrab)) &&
+ ((IsPointerDevice(grab->device) &&
+ IsPointerDevice(othergrab->device)) ||
+ (IsKeyboardDevice(grab->device) &&
+ IsKeyboardDevice(othergrab->device))))
{
- GrabPtr othergrab = other->deviceGrab.grab;
- if (othergrab && othergrab->grabtype == GRABTYPE_CORE &&
- SameClient(grab, rClient(othergrab)) &&
- ((IsPointerDevice(grab->device) &&
- IsPointerDevice(othergrab->device)) ||
- (IsKeyboardDevice(grab->device) &&
- IsKeyboardDevice(othergrab->device))))
- {
- interfering = TRUE;
- break;
- }
+ interfering = TRUE;
+ break;
}
- if (interfering)
- continue;
}
+ if (interfering)
+ continue;
+ }
- if (!activate)
- return grab;
+ if (!activate)
+ {
+ return grab;
+ }
+ else if (!GetXIType(event) && !GetCoreType(event))
+ {
+ ErrorF("Event type %d in CheckPassiveGrabsOnWindow is neither"
+ " XI 1.x nor core\n", event->any.type);
+ return NULL;
+ }
- if (match & CORE_MATCH)
+ /* The only consumers of corestate are Xi 1.x and core events, which
+ * are guaranteed to come from DeviceEvents. */
+ if (match & (XI_MATCH | CORE_MATCH))
+ {
+ event->device_event.corestate &= 0x1f00;
+ event->device_event.corestate |= tempGrab.modifiersDetail.exact &
+ (~0x1f00);
+ }
+
+ if (match & CORE_MATCH)
+ {
+ rc = EventToCore(event, &xE, &count);
+ if (rc != Success)
{
- rc = EventToCore((InternalEvent*)event, &xE, &count);
- if (rc != Success)
- {
- if (rc != BadMatch)
- ErrorF("[dix] %s: core conversion failed in CPGFW "
- "(%d, %d).\n", device->name, event->type, rc);
- continue;
- }
- } else if (match & XI2_MATCH)
+ if (rc != BadMatch)
+ ErrorF("[dix] %s: core conversion failed in CPGFW "
+ "(%d, %d).\n", device->name, event->any.type, rc);
+ continue;
+ }
+ } else if (match & XI2_MATCH)
+ {
+ rc = EventToXI2(event, &xE);
+ if (rc != Success)
{
- rc = EventToXI2((InternalEvent*)event, &xE);
- if (rc != Success)
- {
- if (rc != BadMatch)
- ErrorF("[dix] %s: XI2 conversion failed in CPGFW "
- "(%d, %d).\n", device->name, event->type, rc);
- continue;
- }
- count = 1;
- } else
+ if (rc != BadMatch)
+ ErrorF("[dix] %s: XI2 conversion failed in CPGFW "
+ "(%d, %d).\n", device->name, event->any.type, rc);
+ continue;
+ }
+ count = 1;
+ } else
+ {
+ rc = EventToXI(event, &xE, &count);
+ if (rc != Success)
{
- rc = EventToXI((InternalEvent*)event, &xE, &count);
- if (rc != Success)
- {
- if (rc != BadMatch)
- ErrorF("[dix] %s: XI conversion failed in CPGFW "
- "(%d, %d).\n", device->name, event->type, rc);
- continue;
- }
+ if (rc != BadMatch)
+ ErrorF("[dix] %s: XI conversion failed in CPGFW "
+ "(%d, %d).\n", device->name, event->any.type, rc);
+ continue;
}
+ }
- (*grabinfo->ActivateGrab)(device, grab, currentTime, TRUE);
+ (*grabinfo->ActivateGrab)(device, grab, currentTime, TRUE);
- if (xE)
- {
- FixUpEventFromWindow(pSprite, xE, grab->window, None, TRUE);
+ if (xE)
+ {
+ FixUpEventFromWindow(pSprite, xE, grab->window, None, TRUE);
- /* XXX: XACE? */
- TryClientEvents(rClient(grab), device, xE, count,
- GetEventFilter(device, xE),
- GetEventFilter(device, xE), grab);
- }
+ /* XXX: XACE? */
+ TryClientEvents(rClient(grab), device, xE, count,
+ GetEventFilter(device, xE),
+ GetEventFilter(device, xE), grab);
+ }
- if (grabinfo->sync.state == FROZEN_NO_EVENT)
- {
- if (!grabinfo->sync.event)
- grabinfo->sync.event = calloc(1, sizeof(InternalEvent));
- *grabinfo->sync.event = *event;
- grabinfo->sync.state = FROZEN_WITH_EVENT;
- }
+ if (grabinfo->sync.state == FROZEN_NO_EVENT)
+ {
+ if (!grabinfo->sync.event)
+ grabinfo->sync.event = calloc(1, sizeof(DeviceEvent));
+ *grabinfo->sync.event = event->device_event;
+ grabinfo->sync.state = FROZEN_WITH_EVENT;
+ }
- free(xE);
- return grab;
- }
+ free(xE);
+ return grab;
}
return NULL;
#undef CORE_MATCH
@@ -3639,7 +3776,8 @@ CheckDeviceGrabs(DeviceIntPtr device, DeviceEvent *event, WindowPtr ancestor)
for (; i < focus->traceGood; i++)
{
pWin = focus->trace[i];
- if (CheckPassiveGrabsOnWindow(pWin, device, event, sendCore, TRUE))
+ if (CheckPassiveGrabsOnWindow(pWin, device, (InternalEvent *) event,
+ sendCore, TRUE))
{
ret = TRUE;
goto out;
@@ -3655,7 +3793,8 @@ CheckDeviceGrabs(DeviceIntPtr device, DeviceEvent *event, WindowPtr ancestor)
for (; i < device->spriteInfo->sprite->spriteTraceGood; i++)
{
pWin = device->spriteInfo->sprite->spriteTrace[i];
- if (CheckPassiveGrabsOnWindow(pWin, device, event, sendCore, TRUE))
+ if (CheckPassiveGrabsOnWindow(pWin, device, (InternalEvent *) event,
+ sendCore, TRUE))
{
ret = TRUE;
goto out;
@@ -3766,8 +3905,10 @@ unwind:
* grab. If not, TryClientEvents() is used.
*
* @param deactivateGrab True if the device's grab should be deactivated.
+ *
+ * @return The number of events delivered.
*/
-void
+int
DeliverGrabbedEvent(InternalEvent *event, DeviceIntPtr thisDev,
Bool deactivateGrab)
{
@@ -3935,6 +4076,8 @@ DeliverGrabbedEvent(InternalEvent *event, DeviceIntPtr thisDev,
free(core);
free(xi);
free(xi2);
+
+ return deliveries;
}
/* This function is used to set the key pressed or key released state -
@@ -4977,12 +5120,9 @@ InitEvents(void)
inputInfo.off_devices = (DeviceIntPtr)NULL;
inputInfo.keyboard = (DeviceIntPtr)NULL;
inputInfo.pointer = (DeviceIntPtr)NULL;
- /* The mask for pointer motion events may have changed in the last server
- * generation. See comment above definition of filters. */
- filters[0][PointerMotionMask] = MotionNotify;
- for (i = 1; i < MAXDEVICES; i++)
+ for (i = 0; i < MAXDEVICES; i++)
{
- memcpy(&filters[i], filters[0], sizeof(filters[0]));
+ memcpy(&filters[i], default_filter, sizeof(default_filter));
}
syncEvents.replayDev = (DeviceIntPtr)NULL;
@@ -5006,8 +5146,7 @@ InitEvents(void)
DontPropagateRefCnts[i] = 0;
}
- InputEventListLen = GetMaximumEventsNum();
- InputEventList = InitEventList(InputEventListLen);
+ InputEventList = InitEventList(GetMaximumEventsNum());
if (!InputEventList)
FatalError("[dix] Failed to allocate input event list.\n");
}
@@ -5015,8 +5154,7 @@ InitEvents(void)
void
CloseDownEvents(void)
{
- FreeEventList(InputEventList, InputEventListLen);
- InputEventListLen = 0;
+ FreeEventList(InputEventList, GetMaximumEventsNum());
InputEventList = NULL;
}
diff --git a/xorg-server/dix/getevents.c b/xorg-server/dix/getevents.c
index 4267b61cb..13789f6a2 100644
--- a/xorg-server/dix/getevents.c
+++ b/xorg-server/dix/getevents.c
@@ -47,6 +47,7 @@
#include "eventstr.h"
#include "eventconvert.h"
#include "inpututils.h"
+#include "mi.h"
#include <X11/extensions/XKBproto.h>
#include "xkbsrv.h"
@@ -67,19 +68,12 @@
/* Number of motion history events to store. */
#define MOTION_HISTORY_SIZE 256
-/* InputEventList is the container list for all input events generated by the
- * DDX. The DDX is expected to call GetEventList() and then pass the list into
- * Get{Pointer|Keyboard}Events.
+/**
+ * InputEventList is the storage for input events generated by
+ * QueuePointerEvents, QueueKeyboardEvents, and QueueProximityEvents.
+ * This list is allocated on startup by the DIX.
*/
-EventListPtr InputEventList = NULL;
-int InputEventListLen = 0;
-
-int
-GetEventList(EventListPtr* list)
-{
- *list = InputEventList;
- return InputEventListLen;
-}
+InternalEvent* InputEventList = NULL;
/**
* Pick some arbitrary size for Xi motion history.
@@ -223,7 +217,7 @@ set_valuators(DeviceIntPtr dev, DeviceEvent* event, ValuatorMask *mask)
}
void
-CreateClassesChangedEvent(EventList* event,
+CreateClassesChangedEvent(InternalEvent* event,
DeviceIntPtr master,
DeviceIntPtr slave,
int type)
@@ -232,7 +226,7 @@ CreateClassesChangedEvent(EventList* event,
DeviceChangedEvent *dce;
CARD32 ms = GetTimeInMillis();
- dce = (DeviceChangedEvent*)event->event;
+ dce = &event->changed_event;
memset(dce, 0, sizeof(DeviceChangedEvent));
dce->deviceid = slave->id;
dce->masterid = master->id;
@@ -676,15 +670,15 @@ clipValuators(DeviceIntPtr pDev, ValuatorMask *mask)
* is done in the event processing).
* Pull in the coordinates from the MD if necessary.
*
- * @param events Pointer to a pre-allocated event list.
+ * @param events Pointer to a pre-allocated event array.
* @param dev The slave device that generated an event.
* @param type Either DEVCHANGE_POINTER_EVENT and/or DEVCHANGE_KEYBOARD_EVENT
* @param num_events The current number of events, returns the number of
* events if a DCCE was generated.
* @return The updated @events pointer.
*/
-EventListPtr
-UpdateFromMaster(EventListPtr events, DeviceIntPtr dev, int type, int *num_events)
+InternalEvent*
+UpdateFromMaster(InternalEvent* events, DeviceIntPtr dev, int type, int *num_events)
{
DeviceIntPtr master;
@@ -924,16 +918,49 @@ updateHistory(DeviceIntPtr dev, ValuatorMask *mask, CARD32 ms)
}
}
+static void
+queueEventList(DeviceIntPtr device, InternalEvent *events, int nevents)
+{
+ int i;
+ for (i = 0; i < nevents; i++)
+ mieqEnqueue(device, &events[i]);
+}
+
+/**
+ * Generate internal events representing this keyboard event and enqueue
+ * them on the event queue.
+ *
+ * This function is not reentrant. Disable signals before calling.
+ *
+ * FIXME: flags for relative/abs motion?
+ *
+ * @param device The device to generate the event for
+ * @param type Event type, one of KeyPress or KeyRelease
+ * @param keycode Key code of the pressed/released key
+ * @param mask Valuator mask for valuators present for this event.
+ *
+ */
+void
+QueueKeyboardEvents(DeviceIntPtr device, int type,
+ int keycode, const ValuatorMask *mask)
+{
+ int nevents;
+
+ nevents = GetKeyboardEvents(InputEventList, device, type, keycode, mask);
+ queueEventList(device, InputEventList, nevents);
+}
+
/**
* Returns a set of InternalEvents for KeyPress/KeyRelease, optionally
* also with valuator events.
*
- * events is not NULL-terminated; the return value is the number of events.
- * The DDX is responsible for allocating the event structure in the first
- * place via GetMaximumEventsNum(), and for freeing it.
+ * The DDX is responsible for allocating the event list in the first
+ * place via InitEventList(), and for freeing it.
+ *
+ * @return the number of events written into events.
*/
int
-GetKeyboardEvents(EventList *events, DeviceIntPtr pDev, int type,
+GetKeyboardEvents(InternalEvent *events, DeviceIntPtr pDev, int type,
int key_code, const ValuatorMask *mask_in) {
int num_events = 0;
CARD32 ms = 0;
@@ -966,7 +993,7 @@ GetKeyboardEvents(EventList *events, DeviceIntPtr pDev, int type,
ms = GetTimeInMillis();
- raw = (RawDeviceEvent*)events->event;
+ raw = &events->raw_event;
events++;
num_events++;
@@ -979,7 +1006,7 @@ GetKeyboardEvents(EventList *events, DeviceIntPtr pDev, int type,
set_raw_valuators(raw, &mask, raw->valuators.data);
- event = (DeviceEvent*) events->event;
+ event = &events->device_event;
init_event(pDev, event, ms);
event->detail.key = key_code;
@@ -1000,37 +1027,16 @@ GetKeyboardEvents(EventList *events, DeviceIntPtr pDev, int type,
}
/**
- * Initialize an event list and fill with 32 byte sized events.
+ * Initialize an event array large enough for num_events arrays.
* This event list is to be passed into GetPointerEvents() and
* GetKeyboardEvents().
*
* @param num_events Number of elements in list.
*/
-EventListPtr
+InternalEvent*
InitEventList(int num_events)
{
- EventListPtr events;
- int i;
-
- events = (EventListPtr)calloc(num_events, sizeof(EventList));
- if (!events)
- return NULL;
-
- for (i = 0; i < num_events; i++)
- {
- events[i].evlen = sizeof(InternalEvent);
- events[i].event = calloc(1, sizeof(InternalEvent));
- if (!events[i].event)
- {
- /* rollback */
- while(i--)
- free(events[i].event);
- free(events);
- events = NULL;
- break;
- }
- }
-
+ InternalEvent *events = calloc(num_events, sizeof(InternalEvent));
return events;
}
@@ -1041,41 +1047,50 @@ InitEventList(int num_events)
* @param num_events Number of elements in list.
*/
void
-FreeEventList(EventListPtr list, int num_events)
+FreeEventList(InternalEvent *list, int num_events)
{
- if (!list)
- return;
- while(num_events--)
- free(list[num_events].event);
free(list);
}
static void
-transformAbsolute(DeviceIntPtr dev, ValuatorMask *mask)
+transformAbsolute(DeviceIntPtr dev, ValuatorMask *mask, int *x, int *y)
{
- struct pixman_f_vector p;
-
- /* p' = M * p in homogeneous coordinates */
- p.v[0] = (valuator_mask_isset(mask, 0) ? valuator_mask_get(mask, 0) :
- dev->last.valuators[0]);
- p.v[1] = (valuator_mask_isset(mask, 1) ? valuator_mask_get(mask, 1) :
- dev->last.valuators[1]);
- p.v[2] = 1.0;
+ struct pixman_f_vector p = {.v = {*x, *y, 1}};
pixman_f_transform_point(&dev->transform, &p);
- if (lround(p.v[0]) != dev->last.valuators[0])
- valuator_mask_set(mask, 0, lround(p.v[0]));
- if (lround(p.v[1]) != dev->last.valuators[1])
- valuator_mask_set(mask, 1, lround(p.v[1]));
+ *x = lround(p.v[0]);
+ *y = lround(p.v[1]);
}
/**
- * Generate a series of InternalEvents (filled into the EventList)
- * representing pointer motion, or button presses.
+ * Generate internal events representing this pointer event and enqueue them
+ * on the event queue.
+ *
+ * This function is not reentrant. Disable signals before calling.
*
- * events is not NULL-terminated; the return value is the number of events.
- * The DDX is responsible for allocating the event structure in the first
+ * @param device The device to generate the event for
+ * @param type Event type, one of ButtonPress, ButtonRelease, MotionNotify
+ * @param buttons Button number of the buttons modified. Must be 0 for
+ * MotionNotify
+ * @param flags Event modification flags
+ * @param mask Valuator mask for valuators present for this event.
+ */
+void
+QueuePointerEvents(DeviceIntPtr device, int type,
+ int buttons, int flags, const ValuatorMask *mask)
+{
+ int nevents;
+
+ nevents = GetPointerEvents(InputEventList, device, type, buttons, flags, mask);
+ queueEventList(device, InputEventList, nevents);
+}
+
+/**
+ * Generate a series of InternalEvents representing pointer motion, or
+ * button presses.
+ *
+ * The DDX is responsible for allocating the events in the first
* place via InitEventList() and GetMaximumEventsNum(), and for freeing it.
*
* In the generated events rootX/Y will be in absolute screen coords and
@@ -1085,9 +1100,11 @@ transformAbsolute(DeviceIntPtr dev, ValuatorMask *mask)
* last.valuators[x] of the master device is in absolute screen coords.
*
* master->last.valuators[x] for x > 2 is undefined.
+ *
+ * @return the number of events written into events.
*/
int
-GetPointerEvents(EventList *events, DeviceIntPtr pDev, int type, int buttons,
+GetPointerEvents(InternalEvent *events, DeviceIntPtr pDev, int type, int buttons,
int flags, const ValuatorMask *mask_in) {
int num_events = 1;
CARD32 ms;
@@ -1125,7 +1142,7 @@ GetPointerEvents(EventList *events, DeviceIntPtr pDev, int type, int buttons,
events = UpdateFromMaster(events, pDev, DEVCHANGE_POINTER_EVENT, &num_events);
- raw = (RawDeviceEvent*)events->event;
+ raw = &events->raw_event;
events++;
num_events++;
@@ -1158,7 +1175,16 @@ GetPointerEvents(EventList *events, DeviceIntPtr pDev, int type, int buttons,
}
}
- transformAbsolute(pDev, &mask);
+ x = (valuator_mask_isset(&mask, 0) ? valuator_mask_get(&mask, 0) :
+ pDev->last.valuators[0]);
+ y = (valuator_mask_isset(&mask, 1) ? valuator_mask_get(&mask, 1) :
+ pDev->last.valuators[1]);
+ transformAbsolute(pDev, &mask, &x, &y);
+ if (valuator_mask_isset(&mask, 0))
+ valuator_mask_set(&mask, 0, x);
+ if (valuator_mask_isset(&mask, 1))
+ valuator_mask_set(&mask, 1, y);
+
moveAbsolute(pDev, &x, &y, &mask);
} else {
if (flags & POINTER_ACCELERATE) {
@@ -1185,7 +1211,7 @@ GetPointerEvents(EventList *events, DeviceIntPtr pDev, int type, int buttons,
clipValuators(pDev, &mask);
- event = (DeviceEvent*) events->event;
+ event = &events->device_event;
init_event(pDev, event, ms);
if (type == MotionNotify) {
@@ -1214,17 +1240,39 @@ GetPointerEvents(EventList *events, DeviceIntPtr pDev, int type, int buttons,
return num_events;
}
+/**
+ * Generate internal events representing this proximity event and enqueue
+ * them on the event queue.
+ *
+ * This function is not reentrant. Disable signals before calling.
+ *
+ * @param device The device to generate the event for
+ * @param type Event type, one of ProximityIn or ProximityOut
+ * @param keycode Key code of the pressed/released key
+ * @param mask Valuator mask for valuators present for this event.
+ *
+ */
+void
+QueueProximityEvents(DeviceIntPtr device, int type,
+ const ValuatorMask *mask)
+{
+ int nevents;
+
+ nevents = GetProximityEvents(InputEventList, device, type, mask);
+ queueEventList(device, InputEventList, nevents);
+}
/**
* Generate ProximityIn/ProximityOut InternalEvents, accompanied by
* valuators.
*
- * events is not NULL-terminated; the return value is the number of events.
- * The DDX is responsible for allocating the event structure in the first
- * place via GetMaximumEventsNum(), and for freeing it.
+ * The DDX is responsible for allocating the events in the first place via
+ * InitEventList(), and for freeing it.
+ *
+ * @return the number of events written into events.
*/
int
-GetProximityEvents(EventList *events, DeviceIntPtr pDev, int type, const ValuatorMask *mask_in)
+GetProximityEvents(InternalEvent *events, DeviceIntPtr pDev, int type, const ValuatorMask *mask_in)
{
int num_events = 1, i;
DeviceEvent *event;
@@ -1256,7 +1304,7 @@ GetProximityEvents(EventList *events, DeviceIntPtr pDev, int type, const Valuato
events = UpdateFromMaster(events, pDev, DEVCHANGE_POINTER_EVENT, &num_events);
- event = (DeviceEvent *) events->event;
+ event = &events->device_event;
init_event(pDev, event, GetTimeInMillis());
event->type = (type == ProximityIn) ? ET_ProximityIn : ET_ProximityOut;
diff --git a/xorg-server/dix/inpututils.c b/xorg-server/dix/inpututils.c
index 077ffce01..aeace6ef8 100644
--- a/xorg-server/dix/inpututils.c
+++ b/xorg-server/dix/inpututils.c
@@ -36,6 +36,7 @@
#include "xkbsrv.h"
#include "xkbstr.h"
#include "inpututils.h"
+#include "eventstr.h"
/* Check if a button map change is okay with the device.
* Returns -1 for BadValue, as it collides with MappingBusy. */
@@ -556,3 +557,30 @@ CountBits(const uint8_t *mask, int len)
return ret;
}
+
+/**
+ * Verifies sanity of the event. If the event is not an internal event,
+ * memdumps the first 32 bytes of event to the log, a backtrace, then kill
+ * the server.
+ */
+void verify_internal_event(const InternalEvent *ev)
+{
+ if (ev && ev->any.header != ET_Internal)
+ {
+ int i;
+ unsigned char *data = (unsigned char*)ev;
+
+ ErrorF("dix: invalid event type %d\n", ev->any.header);
+
+ for (i = 0; i < sizeof(xEvent); i++, data++)
+ {
+ ErrorF("%02hx ", *data);
+
+ if ((i % 8) == 7)
+ ErrorF("\n");
+ }
+
+ xorg_backtrace();
+ FatalError("Wrong event type %d. Aborting server\n", ev->any.header);
+ }
+}
diff --git a/xorg-server/doc/Makefile.am b/xorg-server/doc/Makefile.am
index 8cb3649fe..e6974fef1 100644
--- a/xorg-server/doc/Makefile.am
+++ b/xorg-server/doc/Makefile.am
@@ -1,3 +1,15 @@
-SUBDIRS = man xml
-
-dist_noinst_DATA = smartsched
+SUBDIRS = dtrace
+
+if ENABLE_DEVEL_DOCS
+if HAVE_XMLTO
+
+# Main DocBook/XML files (DOCTYPE book)
+docbook = Xserver-spec.xml Xinput.xml
+
+# Generate DocBook/XML output formats with or without stylesheets
+include $(top_srcdir)/devbook.am
+
+endif HAVE_XMLTO
+endif ENABLE_DEVEL_DOCS
+
+EXTRA_DIST = smartsched
diff --git a/xorg-server/doc/Xinput.xml b/xorg-server/doc/Xinput.xml
new file mode 100644
index 000000000..1ae7afe7b
--- /dev/null
+++ b/xorg-server/doc/Xinput.xml
@@ -0,0 +1,1209 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.3//EN"
+ "http://www.oasis-open.org/docbook/xml/4.3/docbookx.dtd">
+
+
+<!-- lifted from troff+ms+XMan by doclifter -->
+<book id="porting">
+
+<bookinfo>
+ <title>X11 Input Extension Porting Document</title>
+ <releaseinfo>X Version 11, Release 6.7</releaseinfo>
+ <authorgroup>
+ <author>
+ <firstname>George</firstname><surname>Sachs</surname>
+ <affiliation><orgname>Hewlett-Packard</orgname></affiliation>
+ </author>
+ </authorgroup>
+ <corpname>X Consortium Standard</corpname>
+ <copyright><year>1989</year><holder>Hewlett-Packard Company</holder></copyright>
+ <copyright><year>1990</year><holder>Hewlett-Packard Company</holder></copyright>
+ <copyright><year>1991</year><holder>Hewlett-Packard Company</holder></copyright>
+
+ <copyright><year>1989</year><holder>X Consortium</holder></copyright>
+ <copyright><year>1990</year><holder>X Consortium</holder></copyright>
+ <copyright><year>1991</year><holder>X Consortium</holder></copyright>
+ <affiliation><orgname>X Consortium</orgname></affiliation>
+ <productnumber>X Version 11, Release 6.7</productnumber>
+
+<legalnotice>
+
+
+<para>
+Permission to use, copy, modify, and distribute this documentation for any purpose and without fee is
+hereby granted, provided that the above copyright notice and this permission notice appear in all copies.
+Hewlett-Packard makes no representations about the suitability for any purpose of the information in this
+document. It is provided "as is" without express or implied warranty. This document is only a draft stan-
+dard of the X Consortium and is therefore subject to change.
+</para>
+
+<para>Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the &ldquo;Software&rdquo;), 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:</para>
+
+<para>Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the &ldquo;Software&rdquo;), 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:</para>
+
+<para>The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.</para>
+
+<para>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 X CONSORTIUM 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.</para>
+
+<para>Except as contained in this notice, the name of the X Consortium 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 X Consortium.</para>
+
+<para>X Window System is a trademark of The Open Group.</para>
+</legalnotice>
+
+</bookinfo>
+
+<chapter id="x11_input_extension_porting_document">
+<title>X11 Input Extension Porting Document</title>
+
+<para>
+This document is intended to aid the process of integrating the
+X11 Input Extension into an X server.
+</para>
+<para>
+<!-- .LP -->
+Most of the functionality provided by the input extension is
+device- and implementation-independent, and should require no changes.
+The functionality is implemented by
+routines that typically reside in the server source tree directory
+extensions/server/xinput.
+This extension includes functions to enable and disable input extension devices,
+select input, grab and focus those device, query and change key
+and button mappings, and others. The only input extension requirements
+for the device-dependent part of X are that the input devices be
+correctly initialized and input events from those devices be correctly
+generated. Device-dependent X is responsible for reading input data from
+the input device hardware and if necessary, reformatting it into X events.
+</para>
+<para>
+<!-- .LP -->
+The process of initializing input extension devices is similar to that used
+for the core devices, and is described in the following sections. When
+multiple input devices are attached to X server, the choice of which devices
+to initially use as the core X pointer and keyboard is left
+implementation-dependent. It is also up to each implementation to decide
+whether all input devices will be opened by the server during its
+initialization and kept open for the life of the server. The alternative is
+to open only the X keyboard and X pointer during server initialization, and
+open other input devices only when requested by a client to do so. Either
+type of implementation is supported by the input extension.
+</para>
+<para>
+<!-- .LP -->
+Input extension events generated by the X server use the same 32-byte xEvent
+wire event as do core input events. However, additional information must be
+sent for input extension devices, requiring that multiple xEvents be generated
+each time data is received from an input extension device. These xEvents are
+combined into a single client XEvent by the input extension library. A later
+section of this document describes the format and generation of input extension
+events.
+</para>
+<sect1 id="Initializing_Extension_Devices">
+<title>Initializing Extension Devices</title>
+<para>
+<!-- .LP -->
+Extension input devices are initialized in the same manner as the core
+X input devices. Device-Independent X provides functions that can be
+called from DDX to initialize these devices. Which functions are called
+and when will vary by implementation, and will depend on whether the
+implementation opens all the input devices available to X when X is initialized,
+or waits until a client requests that a device be opened.
+In the simplest case, DDX will open all input devices as part of its
+initialization, when the InitInput routine is called.
+</para>
+<sect2 id="Summary_of_Calling_Sequence">
+<title>Summary of Calling Sequence</title>
+<para>
+<!-- .LP -->
+<literallayout class="monospaced">
+Device-Independent X | Device-Dependent X
+-------------------- | -------------------
+ |
+InitInput --------------&gt; | - do device-specific initialization
+ |
+ | - call AddInputDevice (deviceProc,AutoStart)
+AddInputDevice |
+ - creates DeviceIntRec |
+ - records deviceProc |
+ - adds new device to |
+ list of off_devices. |
+sets dev-&gt;startup=AutoStart|
+ | - call one of:
+ | - RegisterPointerDevice (X pointer)
+ | - processInputProc = ProcessPointerEvents
+ | - RegisterKeyboardDevice (X keyboard)
+ | - processInputProc = ProcessKeyboardEvents
+ | - RegisterOtherDevice (extension device)
+ | - processInputProc = ProcessOtherEvents
+ |
+ |
+InitAndStartDevices -----&gt; | - calls deviceProc with parameters
+ | (DEVICE_INIT, AutoStart)
+sets dev-&gt;inited = return |
+ value from deviceProc |
+ |
+ | - in deviceProc, do one of:
+ | - call InitPointerDeviceStruct (X pointer)
+ | - call InitKeyboardDeviceStruct (X keybd)
+ | - init extension device by calling some of:
+ | - InitKeyClassDeviceStruct
+ | - InitButtonClassDeviceStruct
+ | - InitValuatorClassDeviceStruct
+ | - InitValuatorAxisStruct
+ | - InitFocusClassDeviceStruct
+ | - InitProximityClassDeviceStruct
+ | - InitKbdFeedbackClassDeviceStruct
+ | - InitPtrFeedbackClassDeviceStruct
+ | - InitLedFeedbackClassDeviceStruct
+ | - InitStringFeedbackClassDeviceStruct
+ | - InitIntegerFeedbackClassDeviceStruct
+ | - InitBellFeedbackClassDeviceStruct
+ | - init device name and type by:
+ | - calling MakeAtom with one of the
+ | predefined names
+ | - calling AssignTypeAndName
+ |
+ |
+for each device added |
+ by AddInputDevice, |
+ InitAndStartDevices |
+ calls EnableDevice if | - EnableDevice calls deviceProc with
+ dev-&gt;startup &amp; | (DEVICE_ON, AutoStart)
+ dev-&gt;inited |
+ |
+If deviceProc returns | - core devices are now enabled, extension
+ Success, EnableDevice | devices are now available to be accessed
+ move the device from | through the input extension protocol
+ inputInfo.off_devices | requests.
+ to inputInfo.devices |
+</literallayout>
+</para>
+</sect2>
+<sect2 id="Initialization_Called_From_InitInput">
+<title>Initialization Called From InitInput</title>
+<para>
+<!-- .LP -->
+InitInput is the first DDX input entry point called during X server startup.
+This routine is responsible for
+device- and implementation- specific initialization, and for calling
+AddInputDevice to create and initialize the DeviceIntRec structure for each
+input device. AddInputDevice is passed the address of a procedure to be called
+by the DIX routine InitAndStartDevices when input devices are enabled.
+This procedure is expected to perform X initialization for the input device.
+</para>
+<para>
+<!-- .LP -->
+If the device is to be used as the X pointer, DDX should then call
+RegisterPointerDevice, passing the DeviceIntRec pointer,
+to initialize the device as the X pointer.
+</para>
+<para>
+<!-- .LP -->
+If the device is to be used as the X keyboard, DDX should instead call
+RegisterKeyboardDevice to initialize the device as the X keyboard.
+</para>
+<para>
+<!-- .LP -->
+If the device is to be used as an extension device, DDX should instead
+call RegisterOtherDevice, passing the DeviceIntPtr returned by
+AddInputDevice.
+</para>
+<para>
+<!-- .LP -->
+A sample InitInput implementation is shown below.
+</para>
+<para>
+<!-- .LP -->
+<literallayout class="monospaced">
+InitInput(argc,argv)
+ {
+ int i, numdevs, ReadInput();
+ DeviceIntPtr dev;
+ LocalDevice localdevs[LOCAL_MAX_DEVS];
+ DeviceProc kbdproc, ptrproc, extproc;
+
+ /**************************************************************
+ * Open the appropriate input devices, determine which are
+ * available, and choose an X pointer and X keyboard device
+ * in some implementation-dependent manner.
+ ***************************************************************/
+
+ open_input_devices (&amp;numdevs, localdevs);
+
+ /**************************************************************
+ * Register a WakeupHandler to handle input when it is generated.
+ ***************************************************************/
+
+ RegisterBlockAndWakeupHandlers (NoopDDA, ReadInput, NULL);
+
+ /**************************************************************
+ * Register the input devices with DIX.
+ ***************************************************************/
+
+ for (i=0; i&lt;numdevs; i++)
+ {
+ if (localdevs[i].use == IsXKeyboard)
+ {
+ dev = AddInputDevice (kbdproc, TRUE);
+ RegisterKeyboardDevice (dev);
+ }
+ else if (localdevs[i].use == IsXPointer)
+ {
+ dev = AddInputDevice (ptrproc, TRUE);
+ RegisterPointerDevice (dev);
+ }
+ else
+ {
+ dev = AddInputDevice (extproc, FALSE);
+ RegisterOtherDevice (dev);
+ }
+ if (dev == NULL)
+ FatalError ("Too many input devices.");
+ dev-&gt;devicePrivate = (pointer) &amp;localdevs[i];
+ }
+</literallayout>
+</para>
+</sect2>
+<sect2 id="Initialization_Called_From_InitAndStartDevices">
+<title>Initialization Called From InitAndStartDevices</title>
+<para>
+<!-- .LP -->
+After InitInput has returned,
+InitAndStartDevices is the DIX routine that is called to enable input devices.
+It calls the device control routine that was passed to AddInputDevice,
+with a mode value of DEVICE_INIT. The action taken by the device control
+routine depends on how the device is to be used. If the device is to be
+the X pointer, the device control routine should call
+InitPointerDeviceStruct to initialize it. If the device is to be the
+X keyboard, the device control routine should call
+InitKeyboardDeviceStruct. Since input extension devices may support various
+combinations of keys, buttons, valuators, and feedbacks,
+each class of input that it supports must be initialized.
+Entry points are defined by DIX to initialize each of the supported classes of
+input, and are described in the following sections.
+</para>
+<para>
+<!-- .LP -->
+A sample device control routine called from InitAndStartDevices is
+shown below.
+</para>
+<para>
+<!-- .LP -->
+<literallayout class="monospaced">
+Bool extproc (dev, mode)
+ DeviceIntPtr dev;
+ int mode;
+ {
+ LocalDevice *localdev = (LocalDevice *) dev-&gt;devicePrivate;
+
+ switch (mode)
+ {
+ case DEVICE_INIT:
+ if (strcmp(localdev-&gt;name, XI_TABLET) == 0)
+ {
+ /****************************************************
+ * This device reports proximity, has buttons,
+ * reports two axes of motion, and can be focused.
+ * It also supports the same feedbacks as the X pointer
+ * (acceleration and threshold can be set).
+ ****************************************************/
+
+ InitButtonClassDeviceStruct (dev, button_count, button_map);
+ InitValuatorClassDeviceStruct (dev, localdev-&gt;n_axes,);
+ motionproc, MOTION_BUF_SIZE, Absolute);
+ for (i=0; i&lt;localdev-&gt;n_axes; i++)
+ InitValuatorAxisStruct (dev, i, min_val, max_val,
+ resolution);
+ InitFocusClassDeviceStruct (dev);
+ InitProximityClassDeviceStruct (dev);
+ InitPtrFeedbackClassDeviceStruct (dev, p_controlproc);
+ }
+ else if (strcmp(localdev-&gt;name, XI_BUTTONBOX) == 0)
+ {
+ /****************************************************
+ * This device has keys and LEDs, and can be focused.
+ ****************************************************/
+
+ InitKeyClassDeviceStruct (dev, syms, modmap);
+ InitFocusClassDeviceStruct (dev);
+ InitLedFeedbackClassDeviceStruct (dev, ledcontrol);
+ }
+ else if (strcmp(localdev-&gt;name, XI_KNOBBOX) == 0)
+ {
+ /****************************************************
+ * This device reports motion.
+ * It can be focused.
+ ****************************************************/
+
+ InitValuatorClassDeviceStruct (dev, localdev-&gt;n_axes,);
+ motionproc, MOTION_BUF_SIZE, Absolute);
+ for (i=0; i&lt;localdev-&gt;n_axes; i++)
+ InitValuatorAxisStruct (dev, i, min_val, max_val,
+ resolution);
+ InitFocusClassDeviceStruct (dev);
+ }
+ localdev-&gt;atom =
+ MakeAtom(localdev-&gt;name, strlen(localdev-&gt;name), FALSE);
+ AssignTypeAndName (dev, localdev-&gt;atom, localdev-&gt;name);
+ break;
+ case DEVICE_ON:
+ AddEnabledDevice (localdev-&gt;file_ds);
+ dev-&gt;on = TRUE;
+ break;
+ case DEVICE_OFF:
+ dev-&gt;on = FALSE;
+ RemoveEnabledDevice (localdev-&gt;file_ds);
+ break;
+ case DEVICE_CLOSE:
+ break;
+ }
+ }
+</literallayout>
+</para>
+<para>
+<!-- .LP -->
+The device control routine is called with a mode value of DEVICE_ON
+by the DIX routine EnableDevice, which is called from InitAndStartDevices.
+When called with this mode, it should call AddEnabledDevice to cause the
+server to begin checking for available input from this device.
+</para>
+<para>
+<!-- .LP -->
+&gt;From InitAndStartDevices, EnableDevice is called for all devices that have
+the "inited" and "startup" fields in the DeviceIntRec set to TRUE. The
+"inited" field is set by InitAndStartDevices to the value returned by
+the deviceproc when called with a mode value of DEVICE_INIT. The "startup"
+field is set by AddInputDevice to value of the second parameter (autoStart).
+</para>
+<para>
+<!-- .LP -->
+When the server is first initialized, it should only be checking for input
+from the core X keyboard and pointer. One way to accomplish this is to
+call AddInputDevice for the core X keyboard and pointer with an
+autoStart value equal to TRUE, while calling AddInputDevice for
+input extension devices with an autoStart value equal to FALSE. If this is
+done, EnableDevice will skip all input extension devices during server
+initialization. In this case,
+the OpenInputDevice routine should set the "startup" field to TRUE
+when called for input extension devices. This will cause ProcXOpenInputDevice
+to call EnableDevice for those devices when a client first does an
+XOpenDevice request.
+</para>
+</sect2>
+<sect2 id="DIX_Input_Class_Initialization_Routines">
+<title>DIX Input Class Initialization Routines</title>
+<para>
+<!-- .LP -->
+DIX routines are defined to initialize each of the defined input classes.
+The defined classes are:
+<!-- .RS -->
+<!-- .in +5n -->
+</para>
+<itemizedlist>
+ <listitem>
+ <para>
+KeyClass - the device has keys.
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ButtonClass - the device has buttons.
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ValuatorClass - the device reports motion data or positional data.
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+Proximitylass - the device reports proximity information.
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+FocusClass - the device can be focused.
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+FeedbackClass - the device supports some kind of feedback
+<!-- .in -5n -->
+<!-- .RE -->
+ </para>
+ </listitem>
+</itemizedlist>
+<para>
+<!-- .LP -->
+DIX routines are provided to initialize the X pointer and keyboard, as in
+previous releases of X. During X initialization, InitPointerDeviceStruct
+is called to initialize the X pointer, and InitKeyboardDeviceStruct is
+called to initialize the X keyboard. There is no
+corresponding routine for extension input devices, since they do not all
+support the same classes of input. Instead, DDX is responsible for the
+initialization of the input classes supported by extension devices.
+A description of the routines provided by DIX to perform that initialization
+follows.
+</para>
+<sect3 id="InitKeyClassDeviceStruct">
+<title>InitKeyClassDeviceStruct</title>
+<para>
+<!-- .LP -->
+This function is provided to allocate and initialize a KeyClassRec, and
+should be called for extension devices that have keys. It is passed a pointer
+to the device, and pointers to arrays of keysyms and modifiers reported by
+the device. It returns FALSE if the KeyClassRec could not be allocated,
+or if the maps for the keysyms and and modifiers could not be allocated.
+Its parameters are:
+</para>
+<para>
+<!-- .LP -->
+<literallayout class="monospaced">
+Bool
+InitKeyClassDeviceStruct(dev, pKeySyms, pModifiers)
+ DeviceIntPtr dev;
+ KeySymsPtr pKeySyms;
+ CARD8 pModifiers[];
+</literallayout>
+</para>
+<para>
+<!-- .LP -->
+The DIX entry point InitKeyboardDeviceStruct calls this routine for the
+core X keyboard. It must be called explicitly for extension devices
+that have keys.
+</para>
+</sect3>
+<sect3 id="InitButtonClassDeviceStruct">
+<title>InitButtonClassDeviceStruct</title>
+<para>
+<!-- .LP -->
+This function is provided to allocate and initialize a ButtonClassRec, and
+should be called for extension devices that have buttons. It is passed a
+pointer to the device, the number of buttons supported, and a map of the
+reported button codes. It returns FALSE if the ButtonClassRec could not be
+allocated. Its parameters are:
+</para>
+<para>
+<!-- .LP -->
+<literallayout class="monospaced">
+Bool
+InitButtonClassDeviceStruct(dev, numButtons, map)
+ register DeviceIntPtr dev;
+ int numButtons;
+ CARD8 *map;
+</literallayout>
+</para>
+<para>
+<!-- .LP -->
+The DIX entry point InitPointerDeviceStruct calls this routine for the
+core X pointer. It must be called explicitly for extension devices that
+have buttons.
+</para>
+</sect3>
+<sect3 id="InitValuatorClassDeviceStruct">
+<title>InitValuatorClassDeviceStruct</title>
+<para>
+<!-- .LP -->
+This function is provided to allocate and initialize a ValuatorClassRec, and
+should be called for extension devices that have valuators. It is passed the
+number of axes of motion reported by the device, the address of the motion
+history procedure for the device, the size of the motion history buffer,
+and the mode (Absolute or Relative) of the device. It returns FALSE if
+the ValuatorClassRec could not be allocated. Its parameters are:
+</para>
+<para>
+<!-- .LP -->
+<literallayout class="monospaced">
+Bool
+InitValuatorClassDeviceStruct(dev, numAxes, motionProc, numMotionEvents, mode)
+ DeviceIntPtr dev;
+ int (*motionProc)();
+ int numAxes;
+ int numMotionEvents;
+ int mode;
+</literallayout>
+</para>
+<para>
+<!-- .LP -->
+The DIX entry point InitPointerDeviceStruct calls this routine for the
+core X pointer. It must be called explicitly for extension devices that
+report motion.
+</para>
+</sect3>
+<sect3 id="InitValuatorAxisStruct">
+<title>InitValuatorAxisStruct</title>
+<para>
+<!-- .LP -->
+This function is provided to initialize an XAxisInfoRec, and
+should be called for core and extension devices that have valuators.
+The space for the XAxisInfoRec is allocated by
+the InitValuatorClassDeviceStruct function, but is not initialized.
+</para>
+<para>
+<!-- .LP -->
+InitValuatorAxisStruct should be called once for each axis of motion
+reported by the device. Each
+invocation should be passed the axis number (starting with 0), the
+minimum value for that axis, the maximum value for that axis, and the
+resolution of the device in counts per meter. If the device reports
+relative motion, 0 should be reported as the minimum and maximum values.
+InitValuatorAxisStruct has the following parameters:
+<literallayout class="monospaced">
+InitValuatorAxisStruct(dev, axnum, minval, maxval, resolution)
+ DeviceIntPtr dev;
+ int axnum;
+ int minval;
+ int maxval;
+ int resolution;
+</literallayout>
+</para>
+<para>
+<!-- .LP -->
+This routine is not called by InitPointerDeviceStruct for the
+core X pointer. It must be called explicitly for core and extension devices
+that report motion.
+</para>
+</sect3>
+<sect3 id="InitFocusClassDeviceStruct">
+<title>InitFocusClassDeviceStruct</title>
+<para>
+<!-- .LP -->
+This function is provided to allocate and initialize a FocusClassRec, and
+should be called for extension devices that can be focused. It is passed a
+pointer to the device, and returns FALSE if the allocation fails.
+It has the following parameter:
+<literallayout class="monospaced">
+Bool
+InitFocusClassDeviceStruct(dev)
+ DeviceIntPtr dev;
+</literallayout>
+</para>
+<para>
+<!-- .LP -->
+The DIX entry point InitKeyboardDeviceStruct calls this routine for the
+core X keyboard. It must be called explicitly for extension devices
+that can be focused. Whether or not a particular device can be focused
+is left implementation-dependent.
+</para>
+</sect3>
+<sect3 id="InitProximityClassDeviceStruct">
+<title>InitProximityClassDeviceStruct</title>
+<para>
+<!-- .LP -->
+This function is provided to allocate and initialize a ProximityClassRec, and
+should be called for extension absolute pointing devices that report proximity.
+It is passed a pointer to the device, and returns FALSE if the allocation fails.
+It has the following parameter:
+<literallayout class="monospaced">
+Bool
+InitProximityClassDeviceStruct(dev)
+ DeviceIntPtr dev;
+</literallayout>
+</para>
+</sect3>
+<sect3 id="Initializing_Feedbacks">
+<title>Initializing Feedbacks</title>
+<para>
+<!-- .LP -->
+</para>
+<sect4 id="InitKbdFeedbackClassDeviceStruct">
+<title>InitKbdFeedbackClassDeviceStruct</title>
+<para>
+<!-- .LP -->
+This function is provided to allocate and initialize a KbdFeedbackClassRec, and
+may be called for extension devices that support some or all of the
+feedbacks that the core keyboard supports. It is passed a
+pointer to the device, a pointer to the procedure that sounds the bell,
+and a pointer to the device control procedure.
+It returns FALSE if the allocation fails, and has the following parameters:
+<literallayout class="monospaced">
+Bool
+InitKbdFeedbackClassDeviceStruct(dev, bellProc, controlProc)
+ DeviceIntPtr dev;
+ void (*bellProc)();
+ void (*controlProc)();
+</literallayout>
+The DIX entry point InitKeyboardDeviceStruct calls this routine for the
+core X keyboard. It must be called explicitly for extension devices
+that have the same feedbacks as a keyboard. Some feedbacks, such as LEDs and
+bell, can be supported either with a KbdFeedbackClass or with BellFeedbackClass
+and LedFeedbackClass feedbacks.
+</para>
+</sect4>
+<sect4 id="InitPtrFeedbackClassDeviceStruct">
+<title>InitPtrFeedbackClassDeviceStruct</title>
+<para>
+<!-- .LP -->
+This function is provided to allocate and initialize a PtrFeedbackClassRec, and
+should be called for extension devices that allow the setting of acceleration
+and threshold. It is passed a pointer to the device,
+and a pointer to the device control procedure.
+It returns FALSE if the allocation fails, and has the following parameters:
+<literallayout class="monospaced">
+Bool
+InitPtrFeedbackClassDeviceStruct(dev, controlProc)
+ DeviceIntPtr dev;
+ void (*controlProc)();
+</literallayout>
+</para>
+<para>
+<!-- .LP -->
+The DIX entry point InitPointerDeviceStruct calls this routine for the
+core X pointer. It must be called explicitly for extension devices
+that support the setting of acceleration and threshold.
+</para>
+</sect4>
+<sect4 id="InitLedFeedbackClassDeviceStruct">
+<title>InitLedFeedbackClassDeviceStruct</title>
+<para>
+<!-- .LP -->
+This function is provided to allocate and initialize a LedFeedbackClassRec, and
+should be called for extension devices that have LEDs.
+It is passed a pointer to the device,
+and a pointer to the device control procedure.
+It returns FALSE if the allocation fails, and has the following parameters:
+<literallayout class="monospaced">
+Bool
+InitLedFeedbackClassDeviceStruct(dev, controlProc)
+ DeviceIntPtr dev;
+ void (*controlProc)();
+</literallayout>
+</para>
+<para>
+<!-- .LP -->
+Up to 32 LEDs per feedback can be supported, and a device may have
+multiple feedbacks of the same type.
+</para>
+</sect4>
+<sect4 id="InitBellFeedbackClassDeviceStruct">
+<title>InitBellFeedbackClassDeviceStruct</title>
+<para>
+<!-- .LP -->
+This function is provided to allocate and initialize a BellFeedbackClassRec,
+and should be called for extension devices that have a bell.
+It is passed a pointer to the device,
+and a pointer to the device control procedure.
+It returns FALSE if the allocation fails, and has the following parameters:
+<literallayout class="monospaced">
+Bool
+InitBellFeedbackClassDeviceStruct(dev, bellProc, controlProc)
+ DeviceIntPtr dev;
+ void (*bellProc)();
+ void (*controlProc)();
+</literallayout>
+</para>
+</sect4>
+<sect4 id="InitStringFeedbackClassDeviceStruct">
+<title>InitStringFeedbackClassDeviceStruct</title>
+<para>
+<!-- .LP -->
+This function is provided to allocate and initialize a StringFeedbackClassRec,
+and should be called for extension devices that have a display upon which a
+string can be displayed.
+It is passed a pointer to the device,
+and a pointer to the device control procedure.
+It returns FALSE if the allocation fails, and has the following parameters:
+<literallayout class="monospaced">
+Bool
+InitStringFeedbackClassDeviceStruct(dev, controlProc, max_symbols,
+ num_symbols_supported, symbols)
+ DeviceIntPtr dev;
+ void (*controlProc)();
+ int max_symbols:
+ int num_symbols_supported;
+ KeySym *symbols;
+</literallayout>
+</para>
+</sect4>
+<sect4 id="InitIntegerFeedbackClassDeviceStruct">
+<title>InitIntegerFeedbackClassDeviceStruct</title>
+<para>
+<!-- .LP -->
+This function is provided to allocate and initialize an
+IntegerFeedbackClassRec,
+and should be called for extension devices that have a display upon which an
+integer can be displayed.
+It is passed a pointer to the device,
+and a pointer to the device control procedure.
+It returns FALSE if the allocation fails, and has the following parameters:
+<literallayout class="monospaced">
+Bool
+InitIntegerFeedbackClassDeviceStruct(dev, controlProc)
+ DeviceIntPtr dev;
+ void (*controlProc)();
+</literallayout>
+</para>
+</sect4>
+</sect3>
+</sect2>
+<sect2 id="Initializing_The_Device_Name_And_Type">
+<title>Initializing The Device Name And Type</title>
+<para>
+<!-- .LP -->
+The device name and type can be initialized by calling AssignTypeAndName
+with the following parameters:
+<literallayout class="monospaced">
+void
+AssignTypeAndName(dev, type, name)
+ DeviceIntPtr dev;
+ Atom type;
+ char *name;
+</literallayout>
+</para>
+<para>
+<!-- .LP -->
+This will allocate space for the device name and copy the name that was passed.
+The device type can be obtained by calling MakeAtom with one of the names
+defined for input devices. MakeAtom has the following parameters:
+<literallayout class="monospaced">
+Atom
+MakeAtom(name, len, makeit)
+ char *name;
+ int len;
+ Bool makeit;
+</literallayout>
+</para>
+<para>
+<!-- .LP -->
+Since the atom was already made when the input extension was initialized, the
+value of makeit should be FALSE;
+</para>
+</sect2>
+</sect1>
+<sect1 id="Closing_Extension_Devices">
+<title>Closing Extension Devices</title>
+<para>
+<!-- .LP -->
+The DisableDevice entry point is provided by DIX to disable input devices.
+It calls the device control routine for the specified
+device with a mode value of DEVICE_OFF. The device control routine should
+call RemoveEnabledDevice to stop the server from checking for input from
+that device.
+</para>
+<para>
+<!-- .LP -->
+DisableDevice is not called by any input extension routines. It can be
+called from the CloseInputDevice routine, which is called by
+ProcXCloseDevice when a client makes an XCloseDevice request. If
+DisableDevice is called, it should only be called when the last client
+using the extension device has terminated or called XCloseDevice.
+</para>
+</sect1>
+<sect1 id="Implementation_Dependent_Routines">
+<title>Implementation-Dependent Routines</title>
+<para>
+<!-- .LP -->
+Several input extension protocol requests have
+implementation-dependent entry points. Default routines
+are defined for these entry points and contained in the source
+file extensions/server/xinput/xstubs.c. Some implementations may
+be able to use the default routines without change.
+The following sections describe each of these routines.
+</para>
+<sect2 id="AddOtherInputDevices">
+<title>AddOtherInputDevices</title>
+<para>
+<!-- .LP -->
+AddOtherInputDevice is called from ProcXListInputDevices as a result of
+an XListInputDevices protocol request. It may be needed by
+implementations that do not open extension input devices until requested
+to do so by some client. These implementations may not initialize
+all devices when the X server starts up, because some of those devices
+may be in use. Since the XListInputDevices
+function only lists those devices that have been initialized,
+AddOtherInputDevices is called to give DDX a chance to
+initialize any previously unavailable input devices.
+</para>
+<para>
+<!-- .LP -->
+A sample AddOtherInputDevices routine might look like the following:
+<literallayout class="monospaced">
+void
+AddOtherInputDevices ()
+ {
+ DeviceIntPtr dev;
+ int i;
+
+ for (i=0; i&lt;MAX_DEVICES; i++)
+ {
+ if (!local_dev[i].initialized &amp;&amp; available(local_dev[i]))
+ {
+ dev = (DeviceIntPtr) AddInputDevice (local_dev[i].deviceProc, TRUE);
+ dev-&gt;public.devicePrivate = local_dev[i];
+ RegisterOtherDevice (dev);
+ dev-&gt;inited = ((*dev-&gt;deviceProc)(dev, DEVICE_INIT) == Success);
+ }
+ }
+ }
+</literallayout>
+</para>
+<para>
+<!-- .LP -->
+The default AddOtherInputDevices routine in xstubs.c does nothing.
+If all input extension devices are initialized when the server
+starts up, it can be left as a null routine.
+</para>
+</sect2>
+<sect2 id="OpenInputDevice">
+<title>OpenInputDevice</title>
+<para>
+<!-- .LP -->
+Some X server implementations open all input devices when the server
+is initialized and never close them. Other implementations may open only
+the X pointer and keyboard devices during server initialization,
+and open other input devices only when some client makes an
+XOpenDevice request. This entry point is for the latter type of
+implementation.
+</para>
+<para>
+<!-- .LP -->
+If the physical device is not already open, it can be done in this routine.
+In this case, the server must keep track of the fact that one or more clients
+have the device open, and physically close it when the last client that has
+it open makes an XCloseDevice request.
+</para>
+<para>
+<!-- .LP -->
+The default implementation is to do nothing (assume all input devices
+are opened during X server initialization and kept open).
+</para>
+</sect2>
+<sect2 id="CloseInputDevice">
+<title>CloseInputDevice</title>
+<para>
+<!-- .LP -->
+Some implementations may close an input device when the last client
+using that device requests that it be closed, or terminates.
+CloseInputDevice is called from ProcXCloseDevice when a client
+makes an XCloseDevice protocol request.
+</para>
+<para>
+<!-- .LP -->
+The default implementation is to do nothing (assume all input devices
+are opened during X server initialization and kept open).
+</para>
+</sect2>
+<sect2 id="SetDeviceMode">
+<title>SetDeviceMode</title>
+<para>
+<!-- .LP -->
+Some implementations support input devices that can report
+either absolute positional data or relative motion. The XSetDeviceMode
+protocol request is provided to allow DDX to change the current mode of
+such a device.
+</para>
+<para>
+<!-- .LP -->
+The default implementation is to always return a BadMatch error. If the
+implementation does not support any input devices that are capable of
+reporting both relative motion and absolute position information, the
+default implementation may be left unchanged.
+</para>
+</sect2>
+<sect2 id="SetDeviceValuators">
+<title>SetDeviceValuators</title>
+<para>
+<!-- .LP -->
+Some implementations support input devices that allow their valuators to be
+set to an initial value. The XSetDeviceValuators
+protocol request is provided to allow DDX to set the valuators of
+such a device.
+</para>
+<para>
+<!-- .LP -->
+The default implementation is to always return a BadMatch error. If the
+implementation does not support any input devices that are allow their
+valuators to be set, the default implementation may be left unchanged.
+</para>
+</sect2>
+<sect2 id="ChangePointerDevice">
+<title>ChangePointerDevice</title>
+<para>
+<!-- .LP -->
+The XChangePointerDevice protocol request is provided to change which device is
+used as the X pointer. Some implementations may maintain information
+specific to the X pointer in the private data structure pointed to by
+the DeviceIntRec. ChangePointerDevice is called to allow such
+implementations to move that information to the new pointer device.
+The current location of the X cursor is an example of the type of
+information that might be affected.
+</para>
+<para>
+<!-- .LP -->
+The DeviceIntRec structure that describes the X pointer device does not
+contain a FocusRec. If the device that has been made into the new X pointer
+was previously a device that could be focused, ProcXChangePointerDevice will
+free the FocusRec associated with that device.
+</para>
+<para>
+<!-- .LP -->
+If the server implementation desires to allow clients to focus the old pointer
+device (which is now accessible through the input extension), it should call
+InitFocusClassDeviceStruct for the old pointer device.
+</para>
+<para>
+<!-- .LP -->
+The XChangePointerDevice protocol request also allows the client
+to choose which axes of the new pointer device are used to move
+the X cursor in the X- and Y- directions. If the axes are different
+than the default ones, the server implementation should record that fact.
+</para>
+<para>
+<!-- .LP -->
+If the server implementation supports input devices with valuators that
+are not allowed to be used as the X pointer, they should be screened out
+by this routine and a BadDevice error returned.
+</para>
+<para>
+<!-- .LP -->
+The default implementation is to do nothing.
+</para>
+</sect2>
+<sect2 id="ChangeKeyboardDevice">
+<title>ChangeKeyboardDevice</title>
+<para>
+<!-- .LP -->
+The XChangeKeyboardDevice protocol request is provided to change which device is
+used as the X keyboard. Some implementations may maintain information
+specific to the X keyboard in the private data structure pointed to by
+the DeviceIntRec. ChangeKeyboardDevice is called to allow such
+implementations to move that information to the new keyboard device.
+</para>
+<para>
+<!-- .LP -->
+The X keyboard device can be focused, and the DeviceIntRec that describes
+that device has a FocusRec. If the device that has been made into the new X
+keyboard did not previously have a FocusRec,
+ProcXChangeKeyboardDevice will allocate one for it.
+</para>
+<para>
+<!-- .LP -->
+If the implementation does not want clients to be able to focus the old X
+keyboard (which has now become available as an input extension device)
+it should call DeleteFocusClassDeviceStruct to free the FocusRec.
+</para>
+<para>
+<!-- .LP -->
+If the implementation supports input devices with keys that are not allowed
+to be used as the X keyboard, they should be checked for here, and a
+BadDevice error returned.
+</para>
+<para>
+<!-- .LP -->
+The default implementation is to do nothing.
+</para>
+</sect2>
+</sect1>
+<sect1 id="Input_Extension_Events">
+<title>Input Extension Events</title>
+<para>
+<!-- .LP -->
+Events accessed through the input extension are analogous to the core input
+events, but have different event types. They are of types
+<function>DeviceKeyPress</function>, <function>DeviceKeyRelease</function>, <function>DeviceButtonPress</function>,
+<function>DeviceButtonRelease</function>, <function>DeviceDeviceMotionNotify</function>,
+<function>DeviceProximityIn</function>, <function>DeviceProximityOut</function>, and <function>DeviceValuator</function>.
+These event types are not constants. Instead, they are external integers
+defined by the input extension. Their actual values will depend on which
+extensions are supported by a server, and the order in which they are
+initialized.
+</para>
+<para>
+<!-- .LP -->
+The data structures that define these
+events are defined in the file <function>extensions/include/XIproto.h</function>. Other
+input extension constants needed by DDX are defined in the file
+<function>extensions/include/XI.h</function>.
+</para>
+<para>
+<!-- .LP -->
+Some events defined by the input extension contain more information than can
+be contained in the 32-byte xEvent data structure. To send this information
+to clients, DDX must generate two or more 32-byte wire events. The following
+sections describe the contents of these events.
+</para>
+<sect2 id="Device_Key_Events">
+<title>Device Key Events</title>
+<para>
+<!-- .LP -->
+<function>DeviceKeyPresss</function> events contain all the information that is contained in
+a core <function>KeyPress</function> event, and also the following additional information:
+</para>
+<para>
+<!-- .LP -->
+<!-- .RS -->
+<!-- .in +5n -->
+</para>
+<itemizedlist>
+ <listitem>
+ <para>
+deviceid - the identifier of the device that generated the event.
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+device_state - the state of any modifiers on the device that generated the event
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+num_valuators - the number of valuators reported in this event.
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+first_valuator - the first valuator reported in this event.
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+valuator0 through valuator5 - the values of the valuators.
+<!-- .in -5n -->
+<!-- .RE -->
+ </para>
+ </listitem>
+</itemizedlist>
+<para>
+<!-- .LP -->
+In order to pass this information to the input extension library, two 32-byte
+wire events must be generated by DDX. The first has an event type of
+<function>DeviceKeyPress</function>, and the second has an event type of \fPDeviceValuator\fP.
+</para>
+<para>
+<!-- .LP -->
+The following code fragment shows how the two wire events could be initialized:
+</para>
+<para>
+<!-- .LP -->
+<literallayout class="monospaced">
+ extern int DeviceKeyPress;
+ DeviceIntPtr dev;
+ xEvent xE[2];
+ CARD8 id, num_valuators;
+ INT16 x, y, pointerx, pointery;
+ Time timestamp;
+ deviceKeyButtonPointer *xev = (deviceKeyButtonPointer *) xE;
+ deviceValuator *xv;
+
+ xev-&gt;type = DeviceKeyPress; /* defined by input extension */
+ xev-&gt;detail = keycode; /* key pressed on this device */
+ xev-&gt;time = timestamp; /* same as for core events */
+ xev-&gt;rootX = pointerx; /* x location of core pointer */
+ xev-&gt;rootY = pointery; /* y location of core pointer */
+
+ /******************************************************************/
+ /* */
+ /* The following field does not exist for core input events. */
+ /* It contains the device id for the device that generated the */
+ /* event, and also indicates whether more than one 32-byte wire */
+ /* event is being sent. */
+ /* */
+ /******************************************************************/
+
+ xev-&gt;deviceid = dev-&gt;id | MORE_EVENTS; /* sending more than 1*/
+
+ /******************************************************************/
+ /* Fields in the second 32-byte wire event: */
+ /******************************************************************/
+
+ xv = (deviceValuator *) ++xev;
+ xv-&gt;type = DeviceValuator; /* event type of second event */
+ xv-&gt;deviceid = dev-&gt;id; /* id of this device */
+ xv-&gt;num_valuators = 0; /* no valuators being sent */
+ xv-&gt;device_state = 0; /* will be filled in by DIX */
+</literallayout>
+</para>
+</sect2>
+<sect2 id="Device_Button_Events">
+<title>Device Button Events</title>
+<para>
+<!-- .LP -->
+<function>DeviceButton</function> events contain all the information that is contained in
+a core button event, and also the same additional information that a
+<function>DeviceKey</function> event contains.
+</para>
+</sect2>
+<sect2 id="Device_Motion_Events">
+<title>Device Motion Events</title>
+<para>
+<!-- .LP -->
+<function>DeviceMotion</function> events contain all the information that is contained in
+a core motion event, and also additional valuator information. At least
+two wire events are required to contain this information.
+The following code fragment shows how the two wire events could be initialized:
+</para>
+<para>
+<!-- .LP -->
+<literallayout class="monospaced">
+ extern int DeviceMotionNotify;
+ DeviceIntPtr dev;
+ xEvent xE[2];
+ CARD8 id, num_valuators;
+ INT16 x, y, pointerx, pointery;
+ Time timestamp;
+ deviceKeyButtonPointer *xev = (deviceKeyButtonPointer *) xE;
+ deviceValuator *xv;
+
+ xev-&gt;type = DeviceMotionNotify; /* defined by input extension */
+ xev-&gt;detail = keycode; /* key pressed on this device */
+ xev-&gt;time = timestamp; /* same as for core events */
+ xev-&gt;rootX = pointerx; /* x location of core pointer */
+ xev-&gt;rootY = pointery; /* y location of core pointer */
+
+ /******************************************************************/
+ /* */
+ /* The following field does not exist for core input events. */
+ /* It contains the device id for the device that generated the */
+ /* event, and also indicates whether more than one 32-byte wire */
+ /* event is being sent. */
+ /* */
+ /******************************************************************/
+
+ xev-&gt;deviceid = dev-&gt;id | MORE_EVENTS; /* sending more than 1*/
+
+ /******************************************************************/
+ /* Fields in the second 32-byte wire event: */
+ /******************************************************************/
+
+ xv = (deviceValuator *) ++xev;
+ xv-&gt;type = DeviceValuator; /* event type of second event */
+ xv-&gt;deviceid = dev-&gt;id; /* id of this device */
+ xv-&gt;num_valuators = 2; /* 2 valuators being sent */
+ xv-&gt;first_valuator = 0; /* first valuator being sent */
+ xv-&gt;device_state = 0; /* will be filled in by DIX */
+ xv-&gt;valuator0 = x; /* first axis of this device */
+ xv-&gt;valuator1 = y; /* second axis of this device */
+</literallayout>
+</para>
+<para>
+<!-- .LP -->
+Up to six axes can be reported in the deviceValuator event. If the device
+is reporting more than 6 axes, additional pairs of DeviceMotionNotify and
+DeviceValuator events should be sent, with the first_valuator field
+set correctly.
+</para>
+</sect2>
+<sect2 id="Device_Proximity_Events">
+<title>Device Proximity Events</title>
+<para>
+<!-- .LP -->
+Some input devices that report absolute positional information, such as
+graphics tablets and touchscreens, may report proximity events.
+<function>ProximityIn</function>
+events are generated when a pointing device like a stylus, or in the case
+of a touchscreen, the user's finger, comes into close proximity with the
+surface of the input device. <function>ProximityOut</function> events are generated when
+the stylus or finger leaves the proximity of the input devices surface.
+</para>
+<para>
+<!-- .LP -->
+<function>Proximity</function> events contain almost the same information as button events.
+The event type is <function>ProximityIn</function> or <function>ProximityOut</function>, and there is no
+detail information.
+<!-- .bp -->
+<!-- .\" .TC -->
+
+</para>
+</sect2>
+</sect1>
+</chapter>
+</book>
diff --git a/xorg-server/doc/xml/Xserver-spec.xml b/xorg-server/doc/Xserver-spec.xml
index a48e88754..a48e88754 100644
--- a/xorg-server/doc/xml/Xserver-spec.xml
+++ b/xorg-server/doc/Xserver-spec.xml
diff --git a/xorg-server/doc/dtrace/Makefile.am b/xorg-server/doc/dtrace/Makefile.am
new file mode 100644
index 000000000..aaf5a1267
--- /dev/null
+++ b/xorg-server/doc/dtrace/Makefile.am
@@ -0,0 +1,17 @@
+
+if ENABLE_DOCS
+if HAVE_XMLTO
+if XSERVER_DTRACE
+
+# Main DocBook/XML files (DOCTYPE book)
+docbook = Xserver-DTrace.xml
+
+# The location where the DocBook/XML files and their generated formats are installed
+shelfdir = $(docdir)
+
+# Generate DocBook/XML output formats with or without stylesheets
+include $(top_srcdir)/docbook.am
+
+endif XSERVER_DTRACE
+endif HAVE_XMLTO
+endif ENABLE_DOCS
diff --git a/xorg-server/doc/xml/dtrace/Xserver-DTrace.xml b/xorg-server/doc/dtrace/Xserver-DTrace.xml
index e0425c8ee..e0425c8ee 100644
--- a/xorg-server/doc/xml/dtrace/Xserver-DTrace.xml
+++ b/xorg-server/doc/dtrace/Xserver-DTrace.xml
diff --git a/xorg-server/doc/xml/Makefile.am b/xorg-server/doc/xml/Makefile.am
deleted file mode 100644
index 9feb1f03d..000000000
--- a/xorg-server/doc/xml/Makefile.am
+++ /dev/null
@@ -1,30 +0,0 @@
-#
-# Copyright (c) 2010, Oracle and/or its affiliates. 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 (including the next
-# paragraph) shall be included in all copies or substantial portions of the
-# Software.
-#
-# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
-# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
-# DEALINGS IN THE SOFTWARE.
-#
-
-SUBDIRS = dtrace
-doc_sources = Xserver-spec.xml
-
-# Developer's documentation is not installed
-if ENABLE_DEVEL_DOCS
-include $(top_srcdir)/doc/xml/xmlrules-noinst.in
-endif
diff --git a/xorg-server/doc/xml/dtrace/Makefile.am b/xorg-server/doc/xml/dtrace/Makefile.am
deleted file mode 100644
index 8bbe040d8..000000000
--- a/xorg-server/doc/xml/dtrace/Makefile.am
+++ /dev/null
@@ -1,36 +0,0 @@
-#
-# Copyright (c) 2010, Oracle and/or its affiliates. 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 (including the next
-# paragraph) shall be included in all copies or substantial portions of the
-# Software.
-#
-# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
-# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
-# DEALINGS IN THE SOFTWARE.
-#
-
-doc_sources = Xserver-DTrace.xml
-
-if ENABLE_DOCS
-
-# This user's documentation is installed only if tracing is available
-if XSERVER_DTRACE
-include $(top_srcdir)/doc/xml/xmlrules-inst.in
-else
-include $(top_srcdir)/doc/xml/xmlrules-noinst.in
-endif
-
-endif
-
diff --git a/xorg-server/doc/xml/xmlrules-inst.in b/xorg-server/doc/xml/xmlrules-inst.in
deleted file mode 100644
index d6965ff05..000000000
--- a/xorg-server/doc/xml/xmlrules-inst.in
+++ /dev/null
@@ -1,23 +0,0 @@
-
-# The doc_sources variable contains one or more DocBook/XML source file.
-# The generated documents will be installed in $(docdir),
-# The DocBook/XML files will always be included in the tarball
-
-dist_doc_DATA = $(doc_sources)
-
-if HAVE_XMLTO
-doc_DATA = $(doc_sources:.xml=.html)
-
-if HAVE_FOP
-doc_DATA += $(doc_sources:.xml=.pdf)
-endif
-
-if HAVE_XMLTO_TEXT
-doc_DATA += $(doc_sources:.xml=.txt)
-endif
-
-CLEANFILES = $(doc_DATA)
-include $(top_srcdir)/doc/xml/xmlrules.in
-
-endif HAVE_XMLTO
-
diff --git a/xorg-server/doc/xml/xmlrules-noinst.in b/xorg-server/doc/xml/xmlrules-noinst.in
deleted file mode 100644
index d582c2efd..000000000
--- a/xorg-server/doc/xml/xmlrules-noinst.in
+++ /dev/null
@@ -1,22 +0,0 @@
-
-# The doc_sources variable contains one or more DocBook/XML source file.
-# The generated documents will NOT be installed in $(docdir),
-# The DocBook/XML files will always be included in the tarball
-
-dist_noinst_DATA = $(doc_sources)
-
-if HAVE_XMLTO
-noinst_DATA = $(doc_sources:.xml=.html)
-
-if HAVE_FOP
-noinst_DATA += $(doc_sources:.xml=.pdf)
-endif
-
-if HAVE_XMLTO_TEXT
-noinst_DATA += $(doc_sources:.xml=.txt)
-endif
-
-CLEANFILES = $(noinst_DATA)
-include $(top_srcdir)/doc/xml/xmlrules.in
-
-endif HAVE_XMLTO
diff --git a/xorg-server/doc/xml/xmlrules.in b/xorg-server/doc/xml/xmlrules.in
deleted file mode 100644
index cc77ffc25..000000000
--- a/xorg-server/doc/xml/xmlrules.in
+++ /dev/null
@@ -1,47 +0,0 @@
-#
-# Copyright (c) 2010, Oracle and/or its affiliates. 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 (including the next
-# paragraph) shall be included in all copies or substantial portions of the
-# Software.
-#
-# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
-# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
-# DEALINGS IN THE SOFTWARE.
-#
-
-# This file provides pattern rules to generate html/pdf/txt from DocBook/XML
-# A stylesheet is used if xorg-sgml-doctools is installed
-# This file is included by xmlrules-inst.in for installable user's documentation
-# It is included by xmlrules-noinst for non installable developer's documentation
-# If the server version or release date changes, autogen && make
-
-XML_ENT_DIR = $(abs_top_builddir)/doc/xml
-SUFFIXES = .xml .txt .html .pdf
-
-XMLTO_FLAGS = --searchpath $(XML_ENT_DIR)
-
-if HAVE_STYLESHEETS
-XMLTO_FLAGS += -m $(XSL_STYLESHEET) \
- --stringparam html.stylesheet=$(STYLESHEET_SRCDIR)/xorg.css
-endif
-
-%.txt: %.xml $(XML_ENT_DIR)/xserver.ent
- $(AM_V_GEN)$(XMLTO) $(XMLTO_FLAGS) txt $<
-
-%.html: %.xml $(XML_ENT_DIR)/xserver.ent
- $(AM_V_GEN)$(XMLTO) $(XMLTO_FLAGS) xhtml-nochunks $<
-
-%.pdf: %.xml $(XML_ENT_DIR)/xserver.ent
- $(AM_V_GEN)$(XMLTO) $(XMLTO_FLAGS) --with-fop pdf $<
diff --git a/xorg-server/docbook.am b/xorg-server/docbook.am
new file mode 100644
index 000000000..7ab7a0050
--- /dev/null
+++ b/xorg-server/docbook.am
@@ -0,0 +1,96 @@
+#
+# Generate output formats for a single DocBook/XML with/without chapters
+#
+# Variables set by the calling Makefile:
+# shelfdir: the location where the docs/specs are installed. Typically $(docdir)
+# docbook: the main DocBook/XML file, no chapters, appendix or image files
+# chapters: all files pulled in by an XInclude statement and images.
+#
+
+#
+# This makefile is intended for Users Documentation and Functional Specifications.
+# Do not use for Developer Documentation which is not installed and does not require olink.
+# Refer to http://www.x.org/releases/X11R7.6/doc/xorg-docs/ReleaseNotes.html#id2584393
+# for an explanation on documents classification.
+#
+
+# DocBook/XML generated output formats to be installed
+shelf_DATA =
+
+# DocBook/XML file with chapters, appendix and images it includes
+dist_shelf_DATA = $(docbook) $(chapters)
+
+#
+# Generate DocBook/XML output formats with or without stylesheets
+#
+
+# Stylesheets are available if the package xorg-sgml-doctools is installed
+if HAVE_STYLESHEETS
+
+# The location where all cross reference databases are installed
+sgmldbsdir = $(XORG_SGML_PATH)/X11/dbs
+masterdb = "$(sgmldbsdir)/masterdb$(suffix $@).xml"
+XMLTO_FLAGS = \
+ --searchpath "$(XORG_SGML_PATH)/X11" \
+ --searchpath "$(abs_top_builddir)" \
+ --stringparam target.database.document=$(masterdb) \
+ --stringparam current.docid="$(<:.xml=)" \
+ --stringparam collect.xref.targets="no"
+
+XMLTO_XHTML_FLAGS = \
+ -x $(STYLESHEET_SRCDIR)/xorg-xhtml.xsl \
+ --stringparam html.stylesheet=$(STYLESHEET_SRCDIR)/xorg.css
+
+XMLTO_FO_FLAGS = \
+ -x $(STYLESHEET_SRCDIR)/xorg-fo.xsl
+endif HAVE_STYLESHEETS
+
+shelf_DATA += $(docbook:.xml=.html)
+%.html: %.xml $(chapters)
+ $(AM_V_GEN)$(XMLTO) $(XMLTO_FLAGS) $(XMLTO_XHTML_FLAGS) xhtml-nochunks $<
+
+if HAVE_FOP
+shelf_DATA += $(docbook:.xml=.pdf) $(docbook:.xml=.ps)
+%.pdf: %.xml $(chapters)
+ $(AM_V_GEN)$(XMLTO) $(XMLTO_FLAGS) $(XMLTO_FO_FLAGS) --with-fop pdf $<
+%.ps: %.xml $(chapters)
+ $(AM_V_GEN)$(XMLTO) $(XMLTO_FLAGS) $(XMLTO_FO_FLAGS) --with-fop ps $<
+endif HAVE_FOP
+
+if HAVE_XMLTO_TEXT
+shelf_DATA += $(docbook:.xml=.txt)
+%.txt: %.xml $(chapters)
+ $(AM_V_GEN)$(XMLTO) $(XMLTO_FLAGS) $(XMLTO_XHTML_FLAGS) txt $<
+endif HAVE_XMLTO_TEXT
+
+#
+# Generate documents cross-reference target databases
+#
+
+# This is only possible if the xorg-sgml-doctools package is installed
+if HAVE_STYLESHEETS
+if HAVE_XSLTPROC
+
+# DocBook/XML generated document cross-reference database
+sgmldbs_DATA = $(docbook:.xml=.html.db) $(docbook:.xml=.fo.db)
+
+# Generate DocBook/XML document cross-reference database
+# Flags for the XSL Transformation processor generating xref target databases
+XSLTPROC_FLAGS = \
+ --path "$(XORG_SGML_PATH)/X11" \
+ --stringparam targets.filename "$@" \
+ --stringparam collect.xref.targets "only" \
+ --nonet --xinclude
+
+%.html.db: %.xml $(chapters)
+ $(AM_V_GEN)$(XSLTPROC) $(XSLTPROC_FLAGS) \
+ http://docbook.sourceforge.net/release/xsl/current/xhtml/docbook.xsl $<
+
+%.fo.db: %.xml $(chapters)
+ $(AM_V_GEN)$(XSLTPROC) $(XSLTPROC_FLAGS) \
+ http://docbook.sourceforge.net/release/xsl/current/fo/docbook.xsl $<
+
+endif HAVE_XSLTPROC
+endif HAVE_STYLESHEETS
+
+CLEANFILES = $(shelf_DATA) $(sgmldbs_DATA)
diff --git a/xorg-server/hw/dmx/Makefile.am b/xorg-server/hw/dmx/Makefile.am
index e0b201b82..fb727e656 100644
--- a/xorg-server/hw/dmx/Makefile.am
+++ b/xorg-server/hw/dmx/Makefile.am
@@ -1,5 +1,5 @@
-SUBDIRS = input config examples doc man
+SUBDIRS = input config examples doc doxygen man
bin_PROGRAMS = Xdmx
if XINERAMA
diff --git a/xorg-server/hw/dmx/dmxwindow.c b/xorg-server/hw/dmx/dmxwindow.c
index ef912b6a3..704fcff54 100644
--- a/xorg-server/hw/dmx/dmxwindow.c
+++ b/xorg-server/hw/dmx/dmxwindow.c
@@ -1,1017 +1,1017 @@
-/*
- * Copyright 2001-2004 Red Hat Inc., Durham, North Carolina.
- *
- * 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, sublicense, and/or sell copies of the Software,
- * and to permit persons to whom the Software is furnished to do so,
- * subject to the following conditions:
- *
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial
- * portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NON-INFRINGEMENT. IN NO EVENT SHALL RED HAT 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.
- */
-
-/*
- * Authors:
- * Kevin E. Martin <kem@redhat.com>
- *
- */
-
-/** \file
- * This file provides support for window-related functions. */
-
-#ifdef HAVE_DMX_CONFIG_H
-#include <dmx-config.h>
-#endif
-
-#include "dmx.h"
-#include "dmxsync.h"
-#include "dmxwindow.h"
-#include "dmxpixmap.h"
-#include "dmxcmap.h"
-#include "dmxvisual.h"
-#include "dmxinput.h"
-#include "dmxextension.h"
-#include "dmxpict.h"
-
-#include "windowstr.h"
-
-static void dmxDoRestackWindow(WindowPtr pWindow);
-static void dmxDoChangeWindowAttributes(WindowPtr pWindow,
- unsigned long *mask,
- XSetWindowAttributes *attribs);
-
-static void dmxDoSetShape(WindowPtr pWindow);
-
-/** Initialize the private area for the window functions. */
-Bool dmxInitWindow(ScreenPtr pScreen)
-{
- if (!dixRegisterPrivateKey(&dmxWinPrivateKeyRec, PRIVATE_WINDOW, sizeof(dmxWinPrivRec)))
- return FALSE;
-
- return TRUE;
-}
-
-
-Window dmxCreateRootWindow(WindowPtr pWindow)
-{
- ScreenPtr pScreen = pWindow->drawable.pScreen;
- DMXScreenInfo *dmxScreen = &dmxScreens[pScreen->myNum];
- dmxWinPrivPtr pWinPriv = DMX_GET_WINDOW_PRIV(pWindow);
- Window parent;
- Visual *visual;
- unsigned long mask;
- XSetWindowAttributes attribs;
- ColormapPtr pCmap;
- dmxColormapPrivPtr pCmapPriv;
-
- /* Create root window */
-
- parent = dmxScreen->scrnWin; /* This is our "Screen" window */
- visual = dmxScreen->beVisuals[dmxScreen->beDefVisualIndex].visual;
-
- dixLookupResourceByType((pointer*) &pCmap, wColormap(pWindow),
- RT_COLORMAP, NullClient, DixUnknownAccess);
- pCmapPriv = DMX_GET_COLORMAP_PRIV(pCmap);
-
- mask = CWEventMask | CWBackingStore | CWColormap | CWBorderPixel;
- attribs.event_mask = ExposureMask;
- attribs.backing_store = NotUseful;
- attribs.colormap = pCmapPriv->cmap;
- attribs.border_pixel = 0;
-
- /* Incorporate new attributes, if needed */
- if (pWinPriv->attribMask) {
- dmxDoChangeWindowAttributes(pWindow, &pWinPriv->attribMask, &attribs);
- mask |= pWinPriv->attribMask;
- }
-
- return XCreateWindow(dmxScreen->beDisplay,
- parent,
- pWindow->origin.x - wBorderWidth(pWindow),
- pWindow->origin.y - wBorderWidth(pWindow),
- pWindow->drawable.width,
- pWindow->drawable.height,
- pWindow->borderWidth,
- pWindow->drawable.depth,
- pWindow->drawable.class,
- visual,
- mask,
- &attribs);
-}
-
-/** Change the location and size of the "screen" window. Called from
- * #dmxConfigureScreenWindow(). */
-void dmxResizeScreenWindow(ScreenPtr pScreen,
- int x, int y, int w, int h)
-{
- DMXScreenInfo *dmxScreen = &dmxScreens[pScreen->myNum];
- unsigned int m;
- XWindowChanges c;
-
- if (!dmxScreen->beDisplay)
- return;
-
- /* Handle resizing on back-end server */
- m = CWX | CWY | CWWidth | CWHeight;
- c.x = x;
- c.y = y;
- c.width = w;
- c.height = h;
-
- XConfigureWindow(dmxScreen->beDisplay, dmxScreen->scrnWin, m, &c);
- dmxSync(dmxScreen, False);
-}
-
-/** Change the location and size of the "root" window. Called from
- * #dmxConfigureRootWindow. */
-void dmxResizeRootWindow(WindowPtr pRoot,
- int x, int y, int w, int h)
-{
- DMXScreenInfo *dmxScreen = &dmxScreens[pRoot->drawable.pScreen->myNum];
- dmxWinPrivPtr pWinPriv = DMX_GET_WINDOW_PRIV(pRoot);
- unsigned int m;
- XWindowChanges c;
-
- /* Handle resizing on back-end server */
- if (dmxScreen->beDisplay) {
- m = CWX | CWY | CWWidth | CWHeight;
- c.x = x;
- c.y = y;
- c.width = (w > 0) ? w : 1;
- c.height = (h > 0) ? h : 1;
-
- XConfigureWindow(dmxScreen->beDisplay, pWinPriv->window, m, &c);
- }
-
- if (w == 0 || h == 0) {
- if (pWinPriv->mapped) {
- if (dmxScreen->beDisplay)
- XUnmapWindow(dmxScreen->beDisplay, pWinPriv->window);
- pWinPriv->mapped = FALSE;
- }
- } else if (!pWinPriv->mapped) {
- if (dmxScreen->beDisplay)
- XMapWindow(dmxScreen->beDisplay, pWinPriv->window);
- pWinPriv->mapped = TRUE;
- }
-
- if (dmxScreen->beDisplay)
- dmxSync(dmxScreen, False);
-}
-
-void dmxGetDefaultWindowAttributes(WindowPtr pWindow,
- Colormap *cmap,
- Visual **visual)
-{
- ScreenPtr pScreen = pWindow->drawable.pScreen;
-
- if (pWindow->drawable.class != InputOnly &&
- pWindow->optional &&
- pWindow->optional->visual != wVisual(pWindow->parent)) {
-
- /* Find the matching visual */
- *visual = dmxLookupVisualFromID(pScreen, wVisual(pWindow));
-
- /* Handle optional colormaps */
- if (pWindow->optional->colormap) {
- ColormapPtr pCmap;
- dmxColormapPrivPtr pCmapPriv;
-
- dixLookupResourceByType((pointer*) &pCmap, wColormap(pWindow),
- RT_COLORMAP, NullClient, DixUnknownAccess);
- pCmapPriv = DMX_GET_COLORMAP_PRIV(pCmap);
- *cmap = pCmapPriv->cmap;
- } else {
- *cmap = dmxColormapFromDefaultVisual(pScreen, *visual);
- }
- } else {
- *visual = CopyFromParent;
- *cmap = (Colormap)0;
- }
-}
-
-static Window dmxCreateNonRootWindow(WindowPtr pWindow)
-{
- ScreenPtr pScreen = pWindow->drawable.pScreen;
- DMXScreenInfo *dmxScreen = &dmxScreens[pScreen->myNum];
- dmxWinPrivPtr pWinPriv = DMX_GET_WINDOW_PRIV(pWindow);
- Window parent;
- unsigned long mask = 0L;
- XSetWindowAttributes attribs;
- dmxWinPrivPtr pParentPriv = DMX_GET_WINDOW_PRIV(pWindow->parent);
-
- /* Create window on back-end server */
-
- parent = pParentPriv->window;
-
- /* The parent won't exist if this call to CreateNonRootWindow came
- from ReparentWindow and the grandparent window has not yet been
- created */
- if (!parent) {
- dmxCreateAndRealizeWindow(pWindow->parent, FALSE);
- parent = pParentPriv->window;
- }
-
- /* Incorporate new attributes, if needed */
- if (pWinPriv->attribMask) {
- dmxDoChangeWindowAttributes(pWindow, &pWinPriv->attribMask, &attribs);
- mask |= pWinPriv->attribMask;
- }
-
- /* Add in default attributes */
- if (pWindow->drawable.class != InputOnly) {
- mask |= CWBackingStore;
- attribs.backing_store = NotUseful;
-
- if (!(mask & CWColormap) && pWinPriv->cmap) {
- mask |= CWColormap;
- attribs.colormap = pWinPriv->cmap;
- if (!(mask & CWBorderPixel)) {
- mask |= CWBorderPixel;
- attribs.border_pixel = 0;
- }
- }
- }
-
- /* Handle case where subwindows are being mapped, but created out of
- order -- if current window has a previous sibling, then it cannot
- be created on top of the stack, so we must restack the windows */
- pWinPriv->restacked = (pWindow->prevSib != NullWindow);
-
- return XCreateWindow(dmxScreen->beDisplay,
- parent,
- pWindow->origin.x - wBorderWidth(pWindow),
- pWindow->origin.y - wBorderWidth(pWindow),
- pWindow->drawable.width,
- pWindow->drawable.height,
- pWindow->borderWidth,
- pWindow->drawable.depth,
- pWindow->drawable.class,
- pWinPriv->visual,
- mask,
- &attribs);
-}
-
-/** This function handles lazy window creation and realization. Window
- * creation is handled by #dmxCreateNonRootWindow(). It also handles
- * any stacking changes that have occured since the window was
- * originally created by calling #dmxDoRestackWindow(). If the window
- * is shaped, the shape is set on the back-end server by calling
- * #dmxDoSetShape(), and if the window has pictures (from RENDER)
- * associated with it, those pictures are created on the back-end
- * server by calling #dmxCreatePictureList(). If \a doSync is TRUE,
- * then #dmxSync() is called. */
-void dmxCreateAndRealizeWindow(WindowPtr pWindow, Bool doSync)
-{
- ScreenPtr pScreen = pWindow->drawable.pScreen;
- DMXScreenInfo *dmxScreen = &dmxScreens[pScreen->myNum];
- dmxWinPrivPtr pWinPriv = DMX_GET_WINDOW_PRIV(pWindow);
-
- if (!dmxScreen->beDisplay) return;
-
- pWinPriv->window = dmxCreateNonRootWindow(pWindow);
- if (pWinPriv->restacked) dmxDoRestackWindow(pWindow);
- if (pWinPriv->isShaped) dmxDoSetShape(pWindow);
- if (pWinPriv->hasPict) dmxCreatePictureList(pWindow);
- if (pWinPriv->mapped) XMapWindow(dmxScreen->beDisplay,
- pWinPriv->window);
- if (doSync) dmxSync(dmxScreen, False);
-}
-
-/** Create \a pWindow on the back-end server. If the lazy window
- * creation optimization is enabled, then the actual creation and
- * realization of the window is handled by
- * #dmxCreateAndRealizeWindow(). */
-Bool dmxCreateWindow(WindowPtr pWindow)
-{
- ScreenPtr pScreen = pWindow->drawable.pScreen;
- DMXScreenInfo *dmxScreen = &dmxScreens[pScreen->myNum];
- dmxWinPrivPtr pWinPriv = DMX_GET_WINDOW_PRIV(pWindow);
- Bool ret = TRUE;
-
- DMX_UNWRAP(CreateWindow, dmxScreen, pScreen);
-#if 0
- if (pScreen->CreateWindow)
- ret = pScreen->CreateWindow(pWindow);
-#endif
-
- /* Set up the defaults */
- pWinPriv->window = (Window)0;
- pWinPriv->offscreen = TRUE;
- pWinPriv->mapped = FALSE;
- pWinPriv->restacked = FALSE;
- pWinPriv->attribMask = 0;
- pWinPriv->isShaped = FALSE;
- pWinPriv->hasPict = FALSE;
-#ifdef GLXEXT
- pWinPriv->swapGroup = NULL;
- pWinPriv->barrier = 0;
-#endif
-
- if (dmxScreen->beDisplay) {
- /* Only create the root window at this stage -- non-root windows are
- created when they are mapped and are on-screen */
- if (!pWindow->parent) {
- dmxScreen->rootWin = pWinPriv->window
- = dmxCreateRootWindow(pWindow);
- if (dmxScreen->scrnX != dmxScreen->rootX
- || dmxScreen->scrnY != dmxScreen->rootY
- || dmxScreen->scrnWidth != dmxScreen->rootWidth
- || dmxScreen->scrnHeight != dmxScreen->rootHeight) {
- dmxResizeRootWindow(pWindow,
- dmxScreen->rootX,
- dmxScreen->rootY,
- dmxScreen->rootWidth,
- dmxScreen->rootHeight);
- dmxUpdateScreenResources(screenInfo.screens[dmxScreen->index],
- dmxScreen->rootX,
- dmxScreen->rootY,
- dmxScreen->rootWidth,
- dmxScreen->rootHeight);
- pWindow->origin.x = dmxScreen->rootX;
- pWindow->origin.y = dmxScreen->rootY;
- }
- } else {
- dmxGetDefaultWindowAttributes(pWindow,
- &pWinPriv->cmap,
- &pWinPriv->visual);
-
- if (dmxLazyWindowCreation) {
- /* Save parent's visual for use later */
- if (pWinPriv->visual == CopyFromParent)
- pWinPriv->visual =
- dmxLookupVisualFromID(pScreen,
- wVisual(pWindow->parent));
- } else {
- pWinPriv->window = dmxCreateNonRootWindow(pWindow);
- }
- }
-
- dmxSync(dmxScreen, False);
- }
-
- DMX_WRAP(CreateWindow, dmxCreateWindow, dmxScreen, pScreen);
-
- return ret;
-}
-
-/** Destroy \a pWindow on the back-end server. */
-Bool dmxBEDestroyWindow(WindowPtr pWindow)
-{
- ScreenPtr pScreen = pWindow->drawable.pScreen;
- DMXScreenInfo *dmxScreen = &dmxScreens[pScreen->myNum];
- dmxWinPrivPtr pWinPriv = DMX_GET_WINDOW_PRIV(pWindow);
-
- if (pWinPriv->window) {
- XDestroyWindow(dmxScreen->beDisplay, pWinPriv->window);
- pWinPriv->window = (Window)0;
- return TRUE;
- }
-
- return FALSE;
-}
-
-/** Destroy \a pWindow on the back-end server. If any RENDER pictures
- were created, destroy them as well. */
-Bool dmxDestroyWindow(WindowPtr pWindow)
-{
- ScreenPtr pScreen = pWindow->drawable.pScreen;
- DMXScreenInfo *dmxScreen = &dmxScreens[pScreen->myNum];
- Bool ret = TRUE;
- Bool needSync = FALSE;
-#ifdef GLXEXT
- dmxWinPrivPtr pWinPriv = DMX_GET_WINDOW_PRIV(pWindow);
-#endif
-
- DMX_UNWRAP(DestroyWindow, dmxScreen, pScreen);
-
- /* Destroy any picture list associated with this window */
- needSync |= dmxDestroyPictureList(pWindow);
-
- /* Destroy window on back-end server */
- needSync |= dmxBEDestroyWindow(pWindow);
- if (needSync) dmxSync(dmxScreen, FALSE);
-
-#ifdef GLXEXT
- if (pWinPriv->swapGroup && pWinPriv->windowDestroyed)
- pWinPriv->windowDestroyed(pWindow);
-#endif
-
- if (pScreen->DestroyWindow)
- ret = pScreen->DestroyWindow(pWindow);
-
- DMX_WRAP(DestroyWindow, dmxDestroyWindow, dmxScreen, pScreen);
-
- return ret;
-}
-
-/** Change the position of \a pWindow to be \a x, \a y. */
-Bool dmxPositionWindow(WindowPtr pWindow, int x, int y)
-{
- ScreenPtr pScreen = pWindow->drawable.pScreen;
- DMXScreenInfo *dmxScreen = &dmxScreens[pScreen->myNum];
- Bool ret = TRUE;
- dmxWinPrivPtr pWinPriv = DMX_GET_WINDOW_PRIV(pWindow);
- unsigned int m;
- XWindowChanges c;
-
- DMX_UNWRAP(PositionWindow, dmxScreen, pScreen);
-#if 0
- if (pScreen->PositionWindow)
- ret = pScreen->PositionWindow(pWindow, x, y);
-#endif
-
- /* Determine if the window is completely off the visible portion of
- the screen */
- pWinPriv->offscreen = DMX_WINDOW_OFFSCREEN(pWindow);
-
- /* If the window is now on-screen and it is mapped and it has not
- been created yet, create it and map it */
- if (!pWinPriv->window && pWinPriv->mapped && !pWinPriv->offscreen) {
- dmxCreateAndRealizeWindow(pWindow, TRUE);
- } else if (pWinPriv->window) {
- /* Position window on back-end server */
- m = CWX | CWY | CWWidth | CWHeight;
- c.x = pWindow->origin.x - wBorderWidth(pWindow);
- c.y = pWindow->origin.y - wBorderWidth(pWindow);
- c.width = pWindow->drawable.width;
- c.height = pWindow->drawable.height;
- if (pWindow->drawable.class != InputOnly) {
- m |= CWBorderWidth;
- c.border_width = pWindow->borderWidth;
- }
-
- XConfigureWindow(dmxScreen->beDisplay, pWinPriv->window, m, &c);
- dmxSync(dmxScreen, False);
- }
-
- DMX_WRAP(PositionWindow, dmxPositionWindow, dmxScreen, pScreen);
-
- return ret;
-}
-
-static void dmxDoChangeWindowAttributes(WindowPtr pWindow,
- unsigned long *mask,
- XSetWindowAttributes *attribs)
-{
- dmxPixPrivPtr pPixPriv;
-
- if (*mask & CWBackPixmap) {
- switch (pWindow->backgroundState) {
- case None:
- attribs->background_pixmap = None;
- break;
-
- case ParentRelative:
- attribs->background_pixmap = ParentRelative;
- break;
-
- case BackgroundPixmap:
- pPixPriv = DMX_GET_PIXMAP_PRIV(pWindow->background.pixmap);
- attribs->background_pixmap = pPixPriv->pixmap;
- break;
-
- case BackgroundPixel:
- *mask &= ~CWBackPixmap;
- break;
- }
- }
-
- if (*mask & CWBackPixel) {
- if (pWindow->backgroundState == BackgroundPixel)
- attribs->background_pixel = pWindow->background.pixel;
- else
- *mask &= ~CWBackPixel;
- }
-
- if (*mask & CWBorderPixmap) {
- if (pWindow->borderIsPixel)
- *mask &= ~CWBorderPixmap;
- else {
- pPixPriv = DMX_GET_PIXMAP_PRIV(pWindow->border.pixmap);
- attribs->border_pixmap = pPixPriv->pixmap;
- }
- }
-
- if (*mask & CWBorderPixel) {
- if (pWindow->borderIsPixel)
- attribs->border_pixel = pWindow->border.pixel;
- else
- *mask &= ~CWBorderPixel;
- }
-
- if (*mask & CWBitGravity)
- attribs->bit_gravity = pWindow->bitGravity;
-
- if (*mask & CWWinGravity)
- *mask &= ~CWWinGravity; /* Handled by dix */
-
- if (*mask & CWBackingStore)
- *mask &= ~CWBackingStore; /* Backing store not supported */
-
- if (*mask & CWBackingPlanes)
- *mask &= ~CWBackingPlanes; /* Backing store not supported */
-
- if (*mask & CWBackingPixel)
- *mask &= ~CWBackingPixel; /* Backing store not supported */
-
- if (*mask & CWOverrideRedirect)
- attribs->override_redirect = pWindow->overrideRedirect;
-
- if (*mask & CWSaveUnder)
- *mask &= ~CWSaveUnder; /* Save unders not supported */
-
- if (*mask & CWEventMask)
- *mask &= ~CWEventMask; /* Events are handled by dix */
-
- if (*mask & CWDontPropagate)
- *mask &= ~CWDontPropagate; /* Events are handled by dix */
-
- if (*mask & CWColormap) {
- ColormapPtr pCmap;
- dmxColormapPrivPtr pCmapPriv;
-
- dixLookupResourceByType((pointer*) &pCmap, wColormap(pWindow),
- RT_COLORMAP, NullClient, DixUnknownAccess);
- pCmapPriv = DMX_GET_COLORMAP_PRIV(pCmap);
- attribs->colormap = pCmapPriv->cmap;
- }
-
- if (*mask & CWCursor)
- *mask &= ~CWCursor; /* Handled by the cursor code */
-}
-
-/** Change the window attributes of \a pWindow. */
-Bool dmxChangeWindowAttributes(WindowPtr pWindow, unsigned long mask)
-{
- ScreenPtr pScreen = pWindow->drawable.pScreen;
- DMXScreenInfo *dmxScreen = &dmxScreens[pScreen->myNum];
- Bool ret = TRUE;
- dmxWinPrivPtr pWinPriv = DMX_GET_WINDOW_PRIV(pWindow);
- XSetWindowAttributes attribs;
-
- DMX_UNWRAP(ChangeWindowAttributes, dmxScreen, pScreen);
-#if 0
- if (pScreen->ChangeWindowAttributes)
- ret = pScreen->ChangeWindowAttributes(pWindow, mask);
-#endif
-
- /* Change window attribs on back-end server */
- dmxDoChangeWindowAttributes(pWindow, &mask, &attribs);
-
- /* Save mask for lazy window creation optimization */
- pWinPriv->attribMask |= mask;
-
- if (mask && pWinPriv->window) {
- XChangeWindowAttributes(dmxScreen->beDisplay, pWinPriv->window,
- mask, &attribs);
- dmxSync(dmxScreen, False);
- }
-
- DMX_WRAP(ChangeWindowAttributes, dmxChangeWindowAttributes, dmxScreen,
- pScreen);
-
- return ret;
-}
-
-/** Realize \a pWindow on the back-end server. If the lazy window
- * creation optimization is enabled, the window is only realized when
- * it at least partially overlaps the screen. */
-Bool dmxRealizeWindow(WindowPtr pWindow)
-{
- ScreenPtr pScreen = pWindow->drawable.pScreen;
- DMXScreenInfo *dmxScreen = &dmxScreens[pScreen->myNum];
- Bool ret = TRUE;
- dmxWinPrivPtr pWinPriv = DMX_GET_WINDOW_PRIV(pWindow);
-
- DMX_UNWRAP(RealizeWindow, dmxScreen, pScreen);
-#if 0
- if (pScreen->RealizeWindow)
- ret = pScreen->RealizeWindow(pWindow);
-#endif
-
- /* Determine if the window is completely off the visible portion of
- the screen */
- pWinPriv->offscreen = DMX_WINDOW_OFFSCREEN(pWindow);
-
- /* If the window hasn't been created and it's not offscreen, then
- create it */
- if (!pWinPriv->window && !pWinPriv->offscreen) {
- dmxCreateAndRealizeWindow(pWindow, FALSE);
- }
-
- if (pWinPriv->window) {
- /* Realize window on back-end server */
- XMapWindow(dmxScreen->beDisplay, pWinPriv->window);
- dmxSync(dmxScreen, False);
- }
-
- /* Let the other functions know that the window is now mapped */
- pWinPriv->mapped = TRUE;
-
- DMX_WRAP(RealizeWindow, dmxRealizeWindow, dmxScreen, pScreen);
-
- dmxUpdateWindowInfo(DMX_UPDATE_REALIZE, pWindow);
- return ret;
-}
-
-/** Unrealize \a pWindow on the back-end server. */
-Bool dmxUnrealizeWindow(WindowPtr pWindow)
-{
- ScreenPtr pScreen = pWindow->drawable.pScreen;
- DMXScreenInfo *dmxScreen = &dmxScreens[pScreen->myNum];
- Bool ret = TRUE;
- dmxWinPrivPtr pWinPriv = DMX_GET_WINDOW_PRIV(pWindow);
-
- DMX_UNWRAP(UnrealizeWindow, dmxScreen, pScreen);
-#if 0
- if (pScreen->UnrealizeWindow)
- ret = pScreen->UnrealizeWindow(pWindow);
-#endif
-
- if (pWinPriv->window) {
- /* Unrealize window on back-end server */
- XUnmapWindow(dmxScreen->beDisplay, pWinPriv->window);
- dmxSync(dmxScreen, False);
- }
-
- /* When unrealized (i.e., unmapped), the window is always considered
- off of the visible portion of the screen */
- pWinPriv->offscreen = TRUE;
- pWinPriv->mapped = FALSE;
-
-#ifdef GLXEXT
- if (pWinPriv->swapGroup && pWinPriv->windowUnmapped)
- pWinPriv->windowUnmapped(pWindow);
-#endif
-
- DMX_WRAP(UnrealizeWindow, dmxUnrealizeWindow, dmxScreen, pScreen);
-
- dmxUpdateWindowInfo(DMX_UPDATE_UNREALIZE, pWindow);
- return ret;
-}
-
-static void dmxDoRestackWindow(WindowPtr pWindow)
-{
- ScreenPtr pScreen = pWindow->drawable.pScreen;
- DMXScreenInfo *dmxScreen = &dmxScreens[pScreen->myNum];
- dmxWinPrivPtr pWinPriv = DMX_GET_WINDOW_PRIV(pWindow);
- WindowPtr pNextSib = pWindow->nextSib;
- unsigned int m;
- XWindowChanges c;
-
- if (pNextSib == NullWindow) {
- /* Window is at the bottom of the stack */
- m = CWStackMode;
- c.sibling = (Window)0;
- c.stack_mode = Below;
- XConfigureWindow(dmxScreen->beDisplay, pWinPriv->window, m, &c);
- } else {
- /* Window is not at the bottom of the stack */
- dmxWinPrivPtr pNextSibPriv = DMX_GET_WINDOW_PRIV(pNextSib);
-
- /* Handle case where siblings have not yet been created due to
- lazy window creation optimization by first finding the next
- sibling in the sibling list that has been created (if any)
- and then putting the current window just above that sibling,
- and if no next siblings have been created yet, then put it at
- the bottom of the stack (since it might have a previous
- sibling that should be above it). */
- while (!pNextSibPriv->window) {
- pNextSib = pNextSib->nextSib;
- if (pNextSib == NullWindow) {
- /* Window is at the bottom of the stack */
- m = CWStackMode;
- c.sibling = (Window)0;
- c.stack_mode = Below;
- XConfigureWindow(dmxScreen->beDisplay, pWinPriv->window, m, &c);
- return;
- }
- pNextSibPriv = DMX_GET_WINDOW_PRIV(pNextSib);
- }
-
- m = CWStackMode | CWSibling;
- c.sibling = pNextSibPriv->window;
- c.stack_mode = Above;
- XConfigureWindow(dmxScreen->beDisplay, pWinPriv->window, m, &c);
- }
-}
-
-/** Handle window restacking. The actual restacking occurs in
- * #dmxDoRestackWindow(). */
-void dmxRestackWindow(WindowPtr pWindow, WindowPtr pOldNextSib)
-{
- ScreenPtr pScreen = pWindow->drawable.pScreen;
- DMXScreenInfo *dmxScreen = &dmxScreens[pScreen->myNum];
- dmxWinPrivPtr pWinPriv = DMX_GET_WINDOW_PRIV(pWindow);
-
- DMX_UNWRAP(RestackWindow, dmxScreen, pScreen);
-#if 0
- if (pScreen->RestackWindow)
- pScreen->RestackWindow(pWindow, pOldNextSib);
-#endif
-
- if (pOldNextSib != pWindow->nextSib) {
- /* Track restacking for lazy window creation optimization */
- pWinPriv->restacked = TRUE;
-
- /* Restack window on back-end server */
- if (pWinPriv->window) {
- dmxDoRestackWindow(pWindow);
- dmxSync(dmxScreen, False);
- }
- }
-
- DMX_WRAP(RestackWindow, dmxRestackWindow, dmxScreen, pScreen);
- dmxUpdateWindowInfo(DMX_UPDATE_RESTACK, pWindow);
-}
-
-static Bool dmxWindowExposurePredicate(Display *dpy, XEvent *ev, XPointer ptr)
-{
- return (ev->type == Expose && ev->xexpose.window == *(Window *)ptr);
-}
-
-/** Handle exposures on \a pWindow. Since window exposures are handled
- * in DMX, the events that are generated by the back-end server are
- * redundant, so we eat them here. */
-void dmxWindowExposures(WindowPtr pWindow, RegionPtr prgn,
- RegionPtr other_exposed)
-{
- ScreenPtr pScreen = pWindow->drawable.pScreen;
- DMXScreenInfo *dmxScreen = &dmxScreens[pScreen->myNum];
- dmxWinPrivPtr pWinPriv = DMX_GET_WINDOW_PRIV(pWindow);
- XEvent ev;
-
- DMX_UNWRAP(WindowExposures, dmxScreen, pScreen);
-
- dmxSync(dmxScreen, False);
-
- if (pWinPriv->window) {
- while (XCheckIfEvent(dmxScreen->beDisplay, &ev,
- dmxWindowExposurePredicate,
- (XPointer)&pWinPriv->window)) {
- /* Handle expose events -- this should not be necessary
- since the base window in which the root window was
- created is guaranteed to be on top (override_redirect),
- so we should just swallow these events. If for some
- reason the window is not on top, then we'd need to
- collect these events and send them to the client later
- (e.g., during the block handler as Xnest does). */
- }
- }
-
-#if 1
- if (pScreen->WindowExposures)
- pScreen->WindowExposures(pWindow, prgn, other_exposed);
-#endif
- DMX_WRAP(WindowExposures, dmxWindowExposures, dmxScreen, pScreen);
-}
-
-/** Move \a pWindow on the back-end server. Determine whether or not it
- * is on or offscreen, and realize it if it is newly on screen and the
- * lazy window creation optimization is enabled. */
-void dmxCopyWindow(WindowPtr pWindow, DDXPointRec ptOldOrg, RegionPtr prgnSrc)
-{
- ScreenPtr pScreen = pWindow->drawable.pScreen;
- DMXScreenInfo *dmxScreen = &dmxScreens[pScreen->myNum];
- dmxWinPrivPtr pWinPriv = DMX_GET_WINDOW_PRIV(pWindow);
- unsigned int m;
- XWindowChanges c;
-
- DMX_UNWRAP(CopyWindow, dmxScreen, pScreen);
-#if 0
- if (pScreen->CopyWindow)
- pScreen->CopyWindow(pWindow, ptOldOrg, prgnSrc);
-#endif
-
- /* Determine if the window is completely off the visible portion of
- the screen */
- pWinPriv->offscreen = DMX_WINDOW_OFFSCREEN(pWindow);
-
- /* If the window is now on-screen and it is mapped and it has not
- been created yet, create it and map it */
- if (!pWinPriv->window && pWinPriv->mapped && !pWinPriv->offscreen) {
- dmxCreateAndRealizeWindow(pWindow, TRUE);
- } else if (pWinPriv->window) {
- /* Move window on back-end server */
- m = CWX | CWY | CWWidth | CWHeight;
- c.x = pWindow->origin.x - wBorderWidth(pWindow);
- c.y = pWindow->origin.y - wBorderWidth(pWindow);
- c.width = pWindow->drawable.width;
- c.height = pWindow->drawable.height;
-
- XConfigureWindow(dmxScreen->beDisplay, pWinPriv->window, m, &c);
- dmxSync(dmxScreen, False);
- }
-
- DMX_WRAP(CopyWindow, dmxCopyWindow, dmxScreen, pScreen);
- dmxUpdateWindowInfo(DMX_UPDATE_COPY, pWindow);
-}
-
-/** Resize \a pWindow on the back-end server. Determine whether or not
- * it is on or offscreen, and realize it if it is newly on screen and
- * the lazy window creation optimization is enabled. */
-void dmxResizeWindow(WindowPtr pWindow, int x, int y,
- unsigned int w, unsigned int h, WindowPtr pSib)
-{
- ScreenPtr pScreen = pWindow->drawable.pScreen;
- DMXScreenInfo *dmxScreen = &dmxScreens[pScreen->myNum];
- dmxWinPrivPtr pWinPriv = DMX_GET_WINDOW_PRIV(pWindow);
- dmxWinPrivPtr pSibPriv;
- unsigned int m;
- XWindowChanges c;
-
- if (pSib)
- pSibPriv = DMX_GET_WINDOW_PRIV(pSib);
-
- DMX_UNWRAP(ResizeWindow, dmxScreen, pScreen);
-#if 1
- if (pScreen->ResizeWindow)
- pScreen->ResizeWindow(pWindow, x, y, w, h, pSib);
-#endif
-
- /* Determine if the window is completely off the visible portion of
- the screen */
- pWinPriv->offscreen = DMX_WINDOW_OFFSCREEN(pWindow);
-
- /* If the window is now on-screen and it is mapped and it has not
- been created yet, create it and map it */
- if (!pWinPriv->window && pWinPriv->mapped && !pWinPriv->offscreen) {
- dmxCreateAndRealizeWindow(pWindow, TRUE);
- } else if (pWinPriv->window) {
- /* Handle resizing on back-end server */
- m = CWX | CWY | CWWidth | CWHeight;
- c.x = pWindow->origin.x - wBorderWidth(pWindow);
- c.y = pWindow->origin.y - wBorderWidth(pWindow);
- c.width = pWindow->drawable.width;
- c.height = pWindow->drawable.height;
-
- XConfigureWindow(dmxScreen->beDisplay, pWinPriv->window, m, &c);
- dmxSync(dmxScreen, False);
- }
-
- DMX_WRAP(ResizeWindow, dmxResizeWindow, dmxScreen, pScreen);
- dmxUpdateWindowInfo(DMX_UPDATE_RESIZE, pWindow);
-}
-
-/** Reparent \a pWindow on the back-end server. */
-void dmxReparentWindow(WindowPtr pWindow, WindowPtr pPriorParent)
-{
- ScreenPtr pScreen = pWindow->drawable.pScreen;
- DMXScreenInfo *dmxScreen = &dmxScreens[pScreen->myNum];
- dmxWinPrivPtr pWinPriv = DMX_GET_WINDOW_PRIV(pWindow);
- dmxWinPrivPtr pParentPriv = DMX_GET_WINDOW_PRIV(pWindow->parent);
-
- DMX_UNWRAP(ReparentWindow, dmxScreen, pScreen);
-#if 0
- if (pScreen->ReparentWindow)
- pScreen->ReparentWindow(pWindow, pPriorParent);
-#endif
-
- if (pWinPriv->window) {
- if (!pParentPriv->window) {
- dmxCreateAndRealizeWindow(pWindow->parent, FALSE);
- }
-
- /* Handle reparenting on back-end server */
- XReparentWindow(dmxScreen->beDisplay, pWinPriv->window,
- pParentPriv->window,
- pWindow->origin.x - wBorderWidth(pWindow),
- pWindow->origin.x - wBorderWidth(pWindow));
- dmxSync(dmxScreen, False);
- }
-
- DMX_WRAP(ReparentWindow, dmxReparentWindow, dmxScreen, pScreen);
- dmxUpdateWindowInfo(DMX_UPDATE_REPARENT, pWindow);
-}
-
-/** Change border width for \a pWindow to \a width pixels. */
-void dmxChangeBorderWidth(WindowPtr pWindow, unsigned int width)
-{
- ScreenPtr pScreen = pWindow->drawable.pScreen;
- DMXScreenInfo *dmxScreen = &dmxScreens[pScreen->myNum];
- dmxWinPrivPtr pWinPriv = DMX_GET_WINDOW_PRIV(pWindow);
- unsigned int m;
- XWindowChanges c;
-
- DMX_UNWRAP(ChangeBorderWidth, dmxScreen, pScreen);
-#if 1
- if (pScreen->ChangeBorderWidth)
- pScreen->ChangeBorderWidth(pWindow, width);
-#endif
-
- /* NOTE: Do we need to check for on/off screen here? */
-
- if (pWinPriv->window) {
- /* Handle border width change on back-end server */
- m = CWBorderWidth;
- c.border_width = width;
-
- XConfigureWindow(dmxScreen->beDisplay, pWinPriv->window, m, &c);
- dmxSync(dmxScreen, False);
- }
-
- DMX_WRAP(ChangeBorderWidth, dmxChangeBorderWidth, dmxScreen, pScreen);
-}
-
-static void dmxDoSetShape(WindowPtr pWindow)
-{
- ScreenPtr pScreen = pWindow->drawable.pScreen;
- DMXScreenInfo *dmxScreen = &dmxScreens[pScreen->myNum];
- dmxWinPrivPtr pWinPriv = DMX_GET_WINDOW_PRIV(pWindow);
- int nBox;
- BoxPtr pBox;
- int nRect;
- XRectangle *pRect;
- XRectangle *pRectFirst;
-
- /* First, set the bounding shape */
- if (wBoundingShape(pWindow)) {
- pBox = RegionRects(wBoundingShape(pWindow));
- nRect = nBox = RegionNumRects(wBoundingShape(pWindow));
- pRectFirst = pRect = malloc(nRect * sizeof(*pRect));
- while (nBox--) {
- pRect->x = pBox->x1;
- pRect->y = pBox->y1;
- pRect->width = pBox->x2 - pBox->x1;
- pRect->height = pBox->y2 - pBox->y1;
- pBox++;
- pRect++;
- }
- XShapeCombineRectangles(dmxScreen->beDisplay, pWinPriv->window,
- ShapeBounding, 0, 0,
- pRectFirst, nRect,
- ShapeSet, YXBanded);
- free(pRectFirst);
- } else {
- XShapeCombineMask(dmxScreen->beDisplay, pWinPriv->window,
- ShapeBounding, 0, 0, None, ShapeSet);
- }
-
- /* Next, set the clip shape */
- if (wClipShape(pWindow)) {
- pBox = RegionRects(wClipShape(pWindow));
- nRect = nBox = RegionNumRects(wClipShape(pWindow));
- pRectFirst = pRect = malloc(nRect * sizeof(*pRect));
- while (nBox--) {
- pRect->x = pBox->x1;
- pRect->y = pBox->y1;
- pRect->width = pBox->x2 - pBox->x1;
- pRect->height = pBox->y2 - pBox->y1;
- pBox++;
- pRect++;
- }
- XShapeCombineRectangles(dmxScreen->beDisplay, pWinPriv->window,
- ShapeClip, 0, 0,
- pRectFirst, nRect,
- ShapeSet, YXBanded);
- free(pRectFirst);
- } else {
- XShapeCombineMask(dmxScreen->beDisplay, pWinPriv->window,
- ShapeClip, 0, 0, None, ShapeSet);
- }
-
- if (XShapeInputSelected(dmxScreen->beDisplay, pWinPriv->window)) {
- ErrorF("Input selected for window %x on Screen %d\n",
- (unsigned int)pWinPriv->window, pScreen->myNum);
- }
-}
-
-/** Set shape of \a pWindow on the back-end server. */
-void dmxSetShape(WindowPtr pWindow, int kind)
-{
- ScreenPtr pScreen = pWindow->drawable.pScreen;
- DMXScreenInfo *dmxScreen = &dmxScreens[pScreen->myNum];
- dmxWinPrivPtr pWinPriv = DMX_GET_WINDOW_PRIV(pWindow);
-
- DMX_UNWRAP(SetShape, dmxScreen, pScreen);
-#if 1
- if (pScreen->SetShape)
- pScreen->SetShape(pWindow, kind);
-#endif
-
- if (pWinPriv->window) {
- /* Handle setting the current shape on the back-end server */
- dmxDoSetShape(pWindow);
- dmxSync(dmxScreen, False);
- } else {
- pWinPriv->isShaped = TRUE;
- }
-
- DMX_WRAP(SetShape, dmxSetShape, dmxScreen, pScreen);
-}
+/*
+ * Copyright 2001-2004 Red Hat Inc., Durham, North Carolina.
+ *
+ * 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, sublicense, and/or sell copies of the Software,
+ * and to permit persons to whom the Software is furnished to do so,
+ * subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial
+ * portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NON-INFRINGEMENT. IN NO EVENT SHALL RED HAT 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.
+ */
+
+/*
+ * Authors:
+ * Kevin E. Martin <kem@redhat.com>
+ *
+ */
+
+/** \file
+ * This file provides support for window-related functions. */
+
+#ifdef HAVE_DMX_CONFIG_H
+#include <dmx-config.h>
+#endif
+
+#include "dmx.h"
+#include "dmxsync.h"
+#include "dmxwindow.h"
+#include "dmxpixmap.h"
+#include "dmxcmap.h"
+#include "dmxvisual.h"
+#include "dmxinput.h"
+#include "dmxextension.h"
+#include "dmxpict.h"
+
+#include "windowstr.h"
+
+static void dmxDoRestackWindow(WindowPtr pWindow);
+static void dmxDoChangeWindowAttributes(WindowPtr pWindow,
+ unsigned long *mask,
+ XSetWindowAttributes *attribs);
+
+static void dmxDoSetShape(WindowPtr pWindow);
+
+/** Initialize the private area for the window functions. */
+Bool dmxInitWindow(ScreenPtr pScreen)
+{
+ if (!dixRegisterPrivateKey(&dmxWinPrivateKeyRec, PRIVATE_WINDOW, sizeof(dmxWinPrivRec)))
+ return FALSE;
+
+ return TRUE;
+}
+
+
+Window dmxCreateRootWindow(WindowPtr pWindow)
+{
+ ScreenPtr pScreen = pWindow->drawable.pScreen;
+ DMXScreenInfo *dmxScreen = &dmxScreens[pScreen->myNum];
+ dmxWinPrivPtr pWinPriv = DMX_GET_WINDOW_PRIV(pWindow);
+ Window parent;
+ Visual *visual;
+ unsigned long mask;
+ XSetWindowAttributes attribs;
+ ColormapPtr pCmap;
+ dmxColormapPrivPtr pCmapPriv;
+
+ /* Create root window */
+
+ parent = dmxScreen->scrnWin; /* This is our "Screen" window */
+ visual = dmxScreen->beVisuals[dmxScreen->beDefVisualIndex].visual;
+
+ dixLookupResourceByType((pointer*) &pCmap, wColormap(pWindow),
+ RT_COLORMAP, NullClient, DixUnknownAccess);
+ pCmapPriv = DMX_GET_COLORMAP_PRIV(pCmap);
+
+ mask = CWEventMask | CWBackingStore | CWColormap | CWBorderPixel;
+ attribs.event_mask = ExposureMask;
+ attribs.backing_store = NotUseful;
+ attribs.colormap = pCmapPriv->cmap;
+ attribs.border_pixel = 0;
+
+ /* Incorporate new attributes, if needed */
+ if (pWinPriv->attribMask) {
+ dmxDoChangeWindowAttributes(pWindow, &pWinPriv->attribMask, &attribs);
+ mask |= pWinPriv->attribMask;
+ }
+
+ return XCreateWindow(dmxScreen->beDisplay,
+ parent,
+ pWindow->origin.x - wBorderWidth(pWindow),
+ pWindow->origin.y - wBorderWidth(pWindow),
+ pWindow->drawable.width,
+ pWindow->drawable.height,
+ pWindow->borderWidth,
+ pWindow->drawable.depth,
+ pWindow->drawable.class,
+ visual,
+ mask,
+ &attribs);
+}
+
+/** Change the location and size of the "screen" window. Called from
+ * dmxextension.c dmxConfigureScreenWindow(). */
+void dmxResizeScreenWindow(ScreenPtr pScreen,
+ int x, int y, int w, int h)
+{
+ DMXScreenInfo *dmxScreen = &dmxScreens[pScreen->myNum];
+ unsigned int m;
+ XWindowChanges c;
+
+ if (!dmxScreen->beDisplay)
+ return;
+
+ /* Handle resizing on back-end server */
+ m = CWX | CWY | CWWidth | CWHeight;
+ c.x = x;
+ c.y = y;
+ c.width = w;
+ c.height = h;
+
+ XConfigureWindow(dmxScreen->beDisplay, dmxScreen->scrnWin, m, &c);
+ dmxSync(dmxScreen, False);
+}
+
+/** Change the location and size of the "root" window. Called from
+ * #dmxCreateWindow. */
+void dmxResizeRootWindow(WindowPtr pRoot,
+ int x, int y, int w, int h)
+{
+ DMXScreenInfo *dmxScreen = &dmxScreens[pRoot->drawable.pScreen->myNum];
+ dmxWinPrivPtr pWinPriv = DMX_GET_WINDOW_PRIV(pRoot);
+ unsigned int m;
+ XWindowChanges c;
+
+ /* Handle resizing on back-end server */
+ if (dmxScreen->beDisplay) {
+ m = CWX | CWY | CWWidth | CWHeight;
+ c.x = x;
+ c.y = y;
+ c.width = (w > 0) ? w : 1;
+ c.height = (h > 0) ? h : 1;
+
+ XConfigureWindow(dmxScreen->beDisplay, pWinPriv->window, m, &c);
+ }
+
+ if (w == 0 || h == 0) {
+ if (pWinPriv->mapped) {
+ if (dmxScreen->beDisplay)
+ XUnmapWindow(dmxScreen->beDisplay, pWinPriv->window);
+ pWinPriv->mapped = FALSE;
+ }
+ } else if (!pWinPriv->mapped) {
+ if (dmxScreen->beDisplay)
+ XMapWindow(dmxScreen->beDisplay, pWinPriv->window);
+ pWinPriv->mapped = TRUE;
+ }
+
+ if (dmxScreen->beDisplay)
+ dmxSync(dmxScreen, False);
+}
+
+void dmxGetDefaultWindowAttributes(WindowPtr pWindow,
+ Colormap *cmap,
+ Visual **visual)
+{
+ ScreenPtr pScreen = pWindow->drawable.pScreen;
+
+ if (pWindow->drawable.class != InputOnly &&
+ pWindow->optional &&
+ pWindow->optional->visual != wVisual(pWindow->parent)) {
+
+ /* Find the matching visual */
+ *visual = dmxLookupVisualFromID(pScreen, wVisual(pWindow));
+
+ /* Handle optional colormaps */
+ if (pWindow->optional->colormap) {
+ ColormapPtr pCmap;
+ dmxColormapPrivPtr pCmapPriv;
+
+ dixLookupResourceByType((pointer*) &pCmap, wColormap(pWindow),
+ RT_COLORMAP, NullClient, DixUnknownAccess);
+ pCmapPriv = DMX_GET_COLORMAP_PRIV(pCmap);
+ *cmap = pCmapPriv->cmap;
+ } else {
+ *cmap = dmxColormapFromDefaultVisual(pScreen, *visual);
+ }
+ } else {
+ *visual = CopyFromParent;
+ *cmap = (Colormap)0;
+ }
+}
+
+static Window dmxCreateNonRootWindow(WindowPtr pWindow)
+{
+ ScreenPtr pScreen = pWindow->drawable.pScreen;
+ DMXScreenInfo *dmxScreen = &dmxScreens[pScreen->myNum];
+ dmxWinPrivPtr pWinPriv = DMX_GET_WINDOW_PRIV(pWindow);
+ Window parent;
+ unsigned long mask = 0L;
+ XSetWindowAttributes attribs;
+ dmxWinPrivPtr pParentPriv = DMX_GET_WINDOW_PRIV(pWindow->parent);
+
+ /* Create window on back-end server */
+
+ parent = pParentPriv->window;
+
+ /* The parent won't exist if this call to CreateNonRootWindow came
+ from ReparentWindow and the grandparent window has not yet been
+ created */
+ if (!parent) {
+ dmxCreateAndRealizeWindow(pWindow->parent, FALSE);
+ parent = pParentPriv->window;
+ }
+
+ /* Incorporate new attributes, if needed */
+ if (pWinPriv->attribMask) {
+ dmxDoChangeWindowAttributes(pWindow, &pWinPriv->attribMask, &attribs);
+ mask |= pWinPriv->attribMask;
+ }
+
+ /* Add in default attributes */
+ if (pWindow->drawable.class != InputOnly) {
+ mask |= CWBackingStore;
+ attribs.backing_store = NotUseful;
+
+ if (!(mask & CWColormap) && pWinPriv->cmap) {
+ mask |= CWColormap;
+ attribs.colormap = pWinPriv->cmap;
+ if (!(mask & CWBorderPixel)) {
+ mask |= CWBorderPixel;
+ attribs.border_pixel = 0;
+ }
+ }
+ }
+
+ /* Handle case where subwindows are being mapped, but created out of
+ order -- if current window has a previous sibling, then it cannot
+ be created on top of the stack, so we must restack the windows */
+ pWinPriv->restacked = (pWindow->prevSib != NullWindow);
+
+ return XCreateWindow(dmxScreen->beDisplay,
+ parent,
+ pWindow->origin.x - wBorderWidth(pWindow),
+ pWindow->origin.y - wBorderWidth(pWindow),
+ pWindow->drawable.width,
+ pWindow->drawable.height,
+ pWindow->borderWidth,
+ pWindow->drawable.depth,
+ pWindow->drawable.class,
+ pWinPriv->visual,
+ mask,
+ &attribs);
+}
+
+/** This function handles lazy window creation and realization. Window
+ * creation is handled by #dmxCreateNonRootWindow(). It also handles
+ * any stacking changes that have occured since the window was
+ * originally created by calling #dmxDoRestackWindow(). If the window
+ * is shaped, the shape is set on the back-end server by calling
+ * #dmxDoSetShape(), and if the window has pictures (from RENDER)
+ * associated with it, those pictures are created on the back-end
+ * server by calling #dmxCreatePictureList(). If \a doSync is TRUE,
+ * then #dmxSync() is called. */
+void dmxCreateAndRealizeWindow(WindowPtr pWindow, Bool doSync)
+{
+ ScreenPtr pScreen = pWindow->drawable.pScreen;
+ DMXScreenInfo *dmxScreen = &dmxScreens[pScreen->myNum];
+ dmxWinPrivPtr pWinPriv = DMX_GET_WINDOW_PRIV(pWindow);
+
+ if (!dmxScreen->beDisplay) return;
+
+ pWinPriv->window = dmxCreateNonRootWindow(pWindow);
+ if (pWinPriv->restacked) dmxDoRestackWindow(pWindow);
+ if (pWinPriv->isShaped) dmxDoSetShape(pWindow);
+ if (pWinPriv->hasPict) dmxCreatePictureList(pWindow);
+ if (pWinPriv->mapped) XMapWindow(dmxScreen->beDisplay,
+ pWinPriv->window);
+ if (doSync) dmxSync(dmxScreen, False);
+}
+
+/** Create \a pWindow on the back-end server. If the lazy window
+ * creation optimization is enabled, then the actual creation and
+ * realization of the window is handled by
+ * #dmxCreateAndRealizeWindow(). */
+Bool dmxCreateWindow(WindowPtr pWindow)
+{
+ ScreenPtr pScreen = pWindow->drawable.pScreen;
+ DMXScreenInfo *dmxScreen = &dmxScreens[pScreen->myNum];
+ dmxWinPrivPtr pWinPriv = DMX_GET_WINDOW_PRIV(pWindow);
+ Bool ret = TRUE;
+
+ DMX_UNWRAP(CreateWindow, dmxScreen, pScreen);
+#if 0
+ if (pScreen->CreateWindow)
+ ret = pScreen->CreateWindow(pWindow);
+#endif
+
+ /* Set up the defaults */
+ pWinPriv->window = (Window)0;
+ pWinPriv->offscreen = TRUE;
+ pWinPriv->mapped = FALSE;
+ pWinPriv->restacked = FALSE;
+ pWinPriv->attribMask = 0;
+ pWinPriv->isShaped = FALSE;
+ pWinPriv->hasPict = FALSE;
+#ifdef GLXEXT
+ pWinPriv->swapGroup = NULL;
+ pWinPriv->barrier = 0;
+#endif
+
+ if (dmxScreen->beDisplay) {
+ /* Only create the root window at this stage -- non-root windows are
+ created when they are mapped and are on-screen */
+ if (!pWindow->parent) {
+ dmxScreen->rootWin = pWinPriv->window
+ = dmxCreateRootWindow(pWindow);
+ if (dmxScreen->scrnX != dmxScreen->rootX
+ || dmxScreen->scrnY != dmxScreen->rootY
+ || dmxScreen->scrnWidth != dmxScreen->rootWidth
+ || dmxScreen->scrnHeight != dmxScreen->rootHeight) {
+ dmxResizeRootWindow(pWindow,
+ dmxScreen->rootX,
+ dmxScreen->rootY,
+ dmxScreen->rootWidth,
+ dmxScreen->rootHeight);
+ dmxUpdateScreenResources(screenInfo.screens[dmxScreen->index],
+ dmxScreen->rootX,
+ dmxScreen->rootY,
+ dmxScreen->rootWidth,
+ dmxScreen->rootHeight);
+ pWindow->origin.x = dmxScreen->rootX;
+ pWindow->origin.y = dmxScreen->rootY;
+ }
+ } else {
+ dmxGetDefaultWindowAttributes(pWindow,
+ &pWinPriv->cmap,
+ &pWinPriv->visual);
+
+ if (dmxLazyWindowCreation) {
+ /* Save parent's visual for use later */
+ if (pWinPriv->visual == CopyFromParent)
+ pWinPriv->visual =
+ dmxLookupVisualFromID(pScreen,
+ wVisual(pWindow->parent));
+ } else {
+ pWinPriv->window = dmxCreateNonRootWindow(pWindow);
+ }
+ }
+
+ dmxSync(dmxScreen, False);
+ }
+
+ DMX_WRAP(CreateWindow, dmxCreateWindow, dmxScreen, pScreen);
+
+ return ret;
+}
+
+/** Destroy \a pWindow on the back-end server. */
+Bool dmxBEDestroyWindow(WindowPtr pWindow)
+{
+ ScreenPtr pScreen = pWindow->drawable.pScreen;
+ DMXScreenInfo *dmxScreen = &dmxScreens[pScreen->myNum];
+ dmxWinPrivPtr pWinPriv = DMX_GET_WINDOW_PRIV(pWindow);
+
+ if (pWinPriv->window) {
+ XDestroyWindow(dmxScreen->beDisplay, pWinPriv->window);
+ pWinPriv->window = (Window)0;
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
+/** Destroy \a pWindow on the back-end server. If any RENDER pictures
+ were created, destroy them as well. */
+Bool dmxDestroyWindow(WindowPtr pWindow)
+{
+ ScreenPtr pScreen = pWindow->drawable.pScreen;
+ DMXScreenInfo *dmxScreen = &dmxScreens[pScreen->myNum];
+ Bool ret = TRUE;
+ Bool needSync = FALSE;
+#ifdef GLXEXT
+ dmxWinPrivPtr pWinPriv = DMX_GET_WINDOW_PRIV(pWindow);
+#endif
+
+ DMX_UNWRAP(DestroyWindow, dmxScreen, pScreen);
+
+ /* Destroy any picture list associated with this window */
+ needSync |= dmxDestroyPictureList(pWindow);
+
+ /* Destroy window on back-end server */
+ needSync |= dmxBEDestroyWindow(pWindow);
+ if (needSync) dmxSync(dmxScreen, FALSE);
+
+#ifdef GLXEXT
+ if (pWinPriv->swapGroup && pWinPriv->windowDestroyed)
+ pWinPriv->windowDestroyed(pWindow);
+#endif
+
+ if (pScreen->DestroyWindow)
+ ret = pScreen->DestroyWindow(pWindow);
+
+ DMX_WRAP(DestroyWindow, dmxDestroyWindow, dmxScreen, pScreen);
+
+ return ret;
+}
+
+/** Change the position of \a pWindow to be \a x, \a y. */
+Bool dmxPositionWindow(WindowPtr pWindow, int x, int y)
+{
+ ScreenPtr pScreen = pWindow->drawable.pScreen;
+ DMXScreenInfo *dmxScreen = &dmxScreens[pScreen->myNum];
+ Bool ret = TRUE;
+ dmxWinPrivPtr pWinPriv = DMX_GET_WINDOW_PRIV(pWindow);
+ unsigned int m;
+ XWindowChanges c;
+
+ DMX_UNWRAP(PositionWindow, dmxScreen, pScreen);
+#if 0
+ if (pScreen->PositionWindow)
+ ret = pScreen->PositionWindow(pWindow, x, y);
+#endif
+
+ /* Determine if the window is completely off the visible portion of
+ the screen */
+ pWinPriv->offscreen = DMX_WINDOW_OFFSCREEN(pWindow);
+
+ /* If the window is now on-screen and it is mapped and it has not
+ been created yet, create it and map it */
+ if (!pWinPriv->window && pWinPriv->mapped && !pWinPriv->offscreen) {
+ dmxCreateAndRealizeWindow(pWindow, TRUE);
+ } else if (pWinPriv->window) {
+ /* Position window on back-end server */
+ m = CWX | CWY | CWWidth | CWHeight;
+ c.x = pWindow->origin.x - wBorderWidth(pWindow);
+ c.y = pWindow->origin.y - wBorderWidth(pWindow);
+ c.width = pWindow->drawable.width;
+ c.height = pWindow->drawable.height;
+ if (pWindow->drawable.class != InputOnly) {
+ m |= CWBorderWidth;
+ c.border_width = pWindow->borderWidth;
+ }
+
+ XConfigureWindow(dmxScreen->beDisplay, pWinPriv->window, m, &c);
+ dmxSync(dmxScreen, False);
+ }
+
+ DMX_WRAP(PositionWindow, dmxPositionWindow, dmxScreen, pScreen);
+
+ return ret;
+}
+
+static void dmxDoChangeWindowAttributes(WindowPtr pWindow,
+ unsigned long *mask,
+ XSetWindowAttributes *attribs)
+{
+ dmxPixPrivPtr pPixPriv;
+
+ if (*mask & CWBackPixmap) {
+ switch (pWindow->backgroundState) {
+ case None:
+ attribs->background_pixmap = None;
+ break;
+
+ case ParentRelative:
+ attribs->background_pixmap = ParentRelative;
+ break;
+
+ case BackgroundPixmap:
+ pPixPriv = DMX_GET_PIXMAP_PRIV(pWindow->background.pixmap);
+ attribs->background_pixmap = pPixPriv->pixmap;
+ break;
+
+ case BackgroundPixel:
+ *mask &= ~CWBackPixmap;
+ break;
+ }
+ }
+
+ if (*mask & CWBackPixel) {
+ if (pWindow->backgroundState == BackgroundPixel)
+ attribs->background_pixel = pWindow->background.pixel;
+ else
+ *mask &= ~CWBackPixel;
+ }
+
+ if (*mask & CWBorderPixmap) {
+ if (pWindow->borderIsPixel)
+ *mask &= ~CWBorderPixmap;
+ else {
+ pPixPriv = DMX_GET_PIXMAP_PRIV(pWindow->border.pixmap);
+ attribs->border_pixmap = pPixPriv->pixmap;
+ }
+ }
+
+ if (*mask & CWBorderPixel) {
+ if (pWindow->borderIsPixel)
+ attribs->border_pixel = pWindow->border.pixel;
+ else
+ *mask &= ~CWBorderPixel;
+ }
+
+ if (*mask & CWBitGravity)
+ attribs->bit_gravity = pWindow->bitGravity;
+
+ if (*mask & CWWinGravity)
+ *mask &= ~CWWinGravity; /* Handled by dix */
+
+ if (*mask & CWBackingStore)
+ *mask &= ~CWBackingStore; /* Backing store not supported */
+
+ if (*mask & CWBackingPlanes)
+ *mask &= ~CWBackingPlanes; /* Backing store not supported */
+
+ if (*mask & CWBackingPixel)
+ *mask &= ~CWBackingPixel; /* Backing store not supported */
+
+ if (*mask & CWOverrideRedirect)
+ attribs->override_redirect = pWindow->overrideRedirect;
+
+ if (*mask & CWSaveUnder)
+ *mask &= ~CWSaveUnder; /* Save unders not supported */
+
+ if (*mask & CWEventMask)
+ *mask &= ~CWEventMask; /* Events are handled by dix */
+
+ if (*mask & CWDontPropagate)
+ *mask &= ~CWDontPropagate; /* Events are handled by dix */
+
+ if (*mask & CWColormap) {
+ ColormapPtr pCmap;
+ dmxColormapPrivPtr pCmapPriv;
+
+ dixLookupResourceByType((pointer*) &pCmap, wColormap(pWindow),
+ RT_COLORMAP, NullClient, DixUnknownAccess);
+ pCmapPriv = DMX_GET_COLORMAP_PRIV(pCmap);
+ attribs->colormap = pCmapPriv->cmap;
+ }
+
+ if (*mask & CWCursor)
+ *mask &= ~CWCursor; /* Handled by the cursor code */
+}
+
+/** Change the window attributes of \a pWindow. */
+Bool dmxChangeWindowAttributes(WindowPtr pWindow, unsigned long mask)
+{
+ ScreenPtr pScreen = pWindow->drawable.pScreen;
+ DMXScreenInfo *dmxScreen = &dmxScreens[pScreen->myNum];
+ Bool ret = TRUE;
+ dmxWinPrivPtr pWinPriv = DMX_GET_WINDOW_PRIV(pWindow);
+ XSetWindowAttributes attribs;
+
+ DMX_UNWRAP(ChangeWindowAttributes, dmxScreen, pScreen);
+#if 0
+ if (pScreen->ChangeWindowAttributes)
+ ret = pScreen->ChangeWindowAttributes(pWindow, mask);
+#endif
+
+ /* Change window attribs on back-end server */
+ dmxDoChangeWindowAttributes(pWindow, &mask, &attribs);
+
+ /* Save mask for lazy window creation optimization */
+ pWinPriv->attribMask |= mask;
+
+ if (mask && pWinPriv->window) {
+ XChangeWindowAttributes(dmxScreen->beDisplay, pWinPriv->window,
+ mask, &attribs);
+ dmxSync(dmxScreen, False);
+ }
+
+ DMX_WRAP(ChangeWindowAttributes, dmxChangeWindowAttributes, dmxScreen,
+ pScreen);
+
+ return ret;
+}
+
+/** Realize \a pWindow on the back-end server. If the lazy window
+ * creation optimization is enabled, the window is only realized when
+ * it at least partially overlaps the screen. */
+Bool dmxRealizeWindow(WindowPtr pWindow)
+{
+ ScreenPtr pScreen = pWindow->drawable.pScreen;
+ DMXScreenInfo *dmxScreen = &dmxScreens[pScreen->myNum];
+ Bool ret = TRUE;
+ dmxWinPrivPtr pWinPriv = DMX_GET_WINDOW_PRIV(pWindow);
+
+ DMX_UNWRAP(RealizeWindow, dmxScreen, pScreen);
+#if 0
+ if (pScreen->RealizeWindow)
+ ret = pScreen->RealizeWindow(pWindow);
+#endif
+
+ /* Determine if the window is completely off the visible portion of
+ the screen */
+ pWinPriv->offscreen = DMX_WINDOW_OFFSCREEN(pWindow);
+
+ /* If the window hasn't been created and it's not offscreen, then
+ create it */
+ if (!pWinPriv->window && !pWinPriv->offscreen) {
+ dmxCreateAndRealizeWindow(pWindow, FALSE);
+ }
+
+ if (pWinPriv->window) {
+ /* Realize window on back-end server */
+ XMapWindow(dmxScreen->beDisplay, pWinPriv->window);
+ dmxSync(dmxScreen, False);
+ }
+
+ /* Let the other functions know that the window is now mapped */
+ pWinPriv->mapped = TRUE;
+
+ DMX_WRAP(RealizeWindow, dmxRealizeWindow, dmxScreen, pScreen);
+
+ dmxUpdateWindowInfo(DMX_UPDATE_REALIZE, pWindow);
+ return ret;
+}
+
+/** Unrealize \a pWindow on the back-end server. */
+Bool dmxUnrealizeWindow(WindowPtr pWindow)
+{
+ ScreenPtr pScreen = pWindow->drawable.pScreen;
+ DMXScreenInfo *dmxScreen = &dmxScreens[pScreen->myNum];
+ Bool ret = TRUE;
+ dmxWinPrivPtr pWinPriv = DMX_GET_WINDOW_PRIV(pWindow);
+
+ DMX_UNWRAP(UnrealizeWindow, dmxScreen, pScreen);
+#if 0
+ if (pScreen->UnrealizeWindow)
+ ret = pScreen->UnrealizeWindow(pWindow);
+#endif
+
+ if (pWinPriv->window) {
+ /* Unrealize window on back-end server */
+ XUnmapWindow(dmxScreen->beDisplay, pWinPriv->window);
+ dmxSync(dmxScreen, False);
+ }
+
+ /* When unrealized (i.e., unmapped), the window is always considered
+ off of the visible portion of the screen */
+ pWinPriv->offscreen = TRUE;
+ pWinPriv->mapped = FALSE;
+
+#ifdef GLXEXT
+ if (pWinPriv->swapGroup && pWinPriv->windowUnmapped)
+ pWinPriv->windowUnmapped(pWindow);
+#endif
+
+ DMX_WRAP(UnrealizeWindow, dmxUnrealizeWindow, dmxScreen, pScreen);
+
+ dmxUpdateWindowInfo(DMX_UPDATE_UNREALIZE, pWindow);
+ return ret;
+}
+
+static void dmxDoRestackWindow(WindowPtr pWindow)
+{
+ ScreenPtr pScreen = pWindow->drawable.pScreen;
+ DMXScreenInfo *dmxScreen = &dmxScreens[pScreen->myNum];
+ dmxWinPrivPtr pWinPriv = DMX_GET_WINDOW_PRIV(pWindow);
+ WindowPtr pNextSib = pWindow->nextSib;
+ unsigned int m;
+ XWindowChanges c;
+
+ if (pNextSib == NullWindow) {
+ /* Window is at the bottom of the stack */
+ m = CWStackMode;
+ c.sibling = (Window)0;
+ c.stack_mode = Below;
+ XConfigureWindow(dmxScreen->beDisplay, pWinPriv->window, m, &c);
+ } else {
+ /* Window is not at the bottom of the stack */
+ dmxWinPrivPtr pNextSibPriv = DMX_GET_WINDOW_PRIV(pNextSib);
+
+ /* Handle case where siblings have not yet been created due to
+ lazy window creation optimization by first finding the next
+ sibling in the sibling list that has been created (if any)
+ and then putting the current window just above that sibling,
+ and if no next siblings have been created yet, then put it at
+ the bottom of the stack (since it might have a previous
+ sibling that should be above it). */
+ while (!pNextSibPriv->window) {
+ pNextSib = pNextSib->nextSib;
+ if (pNextSib == NullWindow) {
+ /* Window is at the bottom of the stack */
+ m = CWStackMode;
+ c.sibling = (Window)0;
+ c.stack_mode = Below;
+ XConfigureWindow(dmxScreen->beDisplay, pWinPriv->window, m, &c);
+ return;
+ }
+ pNextSibPriv = DMX_GET_WINDOW_PRIV(pNextSib);
+ }
+
+ m = CWStackMode | CWSibling;
+ c.sibling = pNextSibPriv->window;
+ c.stack_mode = Above;
+ XConfigureWindow(dmxScreen->beDisplay, pWinPriv->window, m, &c);
+ }
+}
+
+/** Handle window restacking. The actual restacking occurs in
+ * #dmxDoRestackWindow(). */
+void dmxRestackWindow(WindowPtr pWindow, WindowPtr pOldNextSib)
+{
+ ScreenPtr pScreen = pWindow->drawable.pScreen;
+ DMXScreenInfo *dmxScreen = &dmxScreens[pScreen->myNum];
+ dmxWinPrivPtr pWinPriv = DMX_GET_WINDOW_PRIV(pWindow);
+
+ DMX_UNWRAP(RestackWindow, dmxScreen, pScreen);
+#if 0
+ if (pScreen->RestackWindow)
+ pScreen->RestackWindow(pWindow, pOldNextSib);
+#endif
+
+ if (pOldNextSib != pWindow->nextSib) {
+ /* Track restacking for lazy window creation optimization */
+ pWinPriv->restacked = TRUE;
+
+ /* Restack window on back-end server */
+ if (pWinPriv->window) {
+ dmxDoRestackWindow(pWindow);
+ dmxSync(dmxScreen, False);
+ }
+ }
+
+ DMX_WRAP(RestackWindow, dmxRestackWindow, dmxScreen, pScreen);
+ dmxUpdateWindowInfo(DMX_UPDATE_RESTACK, pWindow);
+}
+
+static Bool dmxWindowExposurePredicate(Display *dpy, XEvent *ev, XPointer ptr)
+{
+ return (ev->type == Expose && ev->xexpose.window == *(Window *)ptr);
+}
+
+/** Handle exposures on \a pWindow. Since window exposures are handled
+ * in DMX, the events that are generated by the back-end server are
+ * redundant, so we eat them here. */
+void dmxWindowExposures(WindowPtr pWindow, RegionPtr prgn,
+ RegionPtr other_exposed)
+{
+ ScreenPtr pScreen = pWindow->drawable.pScreen;
+ DMXScreenInfo *dmxScreen = &dmxScreens[pScreen->myNum];
+ dmxWinPrivPtr pWinPriv = DMX_GET_WINDOW_PRIV(pWindow);
+ XEvent ev;
+
+ DMX_UNWRAP(WindowExposures, dmxScreen, pScreen);
+
+ dmxSync(dmxScreen, False);
+
+ if (pWinPriv->window) {
+ while (XCheckIfEvent(dmxScreen->beDisplay, &ev,
+ dmxWindowExposurePredicate,
+ (XPointer)&pWinPriv->window)) {
+ /* Handle expose events -- this should not be necessary
+ since the base window in which the root window was
+ created is guaranteed to be on top (override_redirect),
+ so we should just swallow these events. If for some
+ reason the window is not on top, then we'd need to
+ collect these events and send them to the client later
+ (e.g., during the block handler as Xnest does). */
+ }
+ }
+
+#if 1
+ if (pScreen->WindowExposures)
+ pScreen->WindowExposures(pWindow, prgn, other_exposed);
+#endif
+ DMX_WRAP(WindowExposures, dmxWindowExposures, dmxScreen, pScreen);
+}
+
+/** Move \a pWindow on the back-end server. Determine whether or not it
+ * is on or offscreen, and realize it if it is newly on screen and the
+ * lazy window creation optimization is enabled. */
+void dmxCopyWindow(WindowPtr pWindow, DDXPointRec ptOldOrg, RegionPtr prgnSrc)
+{
+ ScreenPtr pScreen = pWindow->drawable.pScreen;
+ DMXScreenInfo *dmxScreen = &dmxScreens[pScreen->myNum];
+ dmxWinPrivPtr pWinPriv = DMX_GET_WINDOW_PRIV(pWindow);
+ unsigned int m;
+ XWindowChanges c;
+
+ DMX_UNWRAP(CopyWindow, dmxScreen, pScreen);
+#if 0
+ if (pScreen->CopyWindow)
+ pScreen->CopyWindow(pWindow, ptOldOrg, prgnSrc);
+#endif
+
+ /* Determine if the window is completely off the visible portion of
+ the screen */
+ pWinPriv->offscreen = DMX_WINDOW_OFFSCREEN(pWindow);
+
+ /* If the window is now on-screen and it is mapped and it has not
+ been created yet, create it and map it */
+ if (!pWinPriv->window && pWinPriv->mapped && !pWinPriv->offscreen) {
+ dmxCreateAndRealizeWindow(pWindow, TRUE);
+ } else if (pWinPriv->window) {
+ /* Move window on back-end server */
+ m = CWX | CWY | CWWidth | CWHeight;
+ c.x = pWindow->origin.x - wBorderWidth(pWindow);
+ c.y = pWindow->origin.y - wBorderWidth(pWindow);
+ c.width = pWindow->drawable.width;
+ c.height = pWindow->drawable.height;
+
+ XConfigureWindow(dmxScreen->beDisplay, pWinPriv->window, m, &c);
+ dmxSync(dmxScreen, False);
+ }
+
+ DMX_WRAP(CopyWindow, dmxCopyWindow, dmxScreen, pScreen);
+ dmxUpdateWindowInfo(DMX_UPDATE_COPY, pWindow);
+}
+
+/** Resize \a pWindow on the back-end server. Determine whether or not
+ * it is on or offscreen, and realize it if it is newly on screen and
+ * the lazy window creation optimization is enabled. */
+void dmxResizeWindow(WindowPtr pWindow, int x, int y,
+ unsigned int w, unsigned int h, WindowPtr pSib)
+{
+ ScreenPtr pScreen = pWindow->drawable.pScreen;
+ DMXScreenInfo *dmxScreen = &dmxScreens[pScreen->myNum];
+ dmxWinPrivPtr pWinPriv = DMX_GET_WINDOW_PRIV(pWindow);
+ dmxWinPrivPtr pSibPriv;
+ unsigned int m;
+ XWindowChanges c;
+
+ if (pSib)
+ pSibPriv = DMX_GET_WINDOW_PRIV(pSib);
+
+ DMX_UNWRAP(ResizeWindow, dmxScreen, pScreen);
+#if 1
+ if (pScreen->ResizeWindow)
+ pScreen->ResizeWindow(pWindow, x, y, w, h, pSib);
+#endif
+
+ /* Determine if the window is completely off the visible portion of
+ the screen */
+ pWinPriv->offscreen = DMX_WINDOW_OFFSCREEN(pWindow);
+
+ /* If the window is now on-screen and it is mapped and it has not
+ been created yet, create it and map it */
+ if (!pWinPriv->window && pWinPriv->mapped && !pWinPriv->offscreen) {
+ dmxCreateAndRealizeWindow(pWindow, TRUE);
+ } else if (pWinPriv->window) {
+ /* Handle resizing on back-end server */
+ m = CWX | CWY | CWWidth | CWHeight;
+ c.x = pWindow->origin.x - wBorderWidth(pWindow);
+ c.y = pWindow->origin.y - wBorderWidth(pWindow);
+ c.width = pWindow->drawable.width;
+ c.height = pWindow->drawable.height;
+
+ XConfigureWindow(dmxScreen->beDisplay, pWinPriv->window, m, &c);
+ dmxSync(dmxScreen, False);
+ }
+
+ DMX_WRAP(ResizeWindow, dmxResizeWindow, dmxScreen, pScreen);
+ dmxUpdateWindowInfo(DMX_UPDATE_RESIZE, pWindow);
+}
+
+/** Reparent \a pWindow on the back-end server. */
+void dmxReparentWindow(WindowPtr pWindow, WindowPtr pPriorParent)
+{
+ ScreenPtr pScreen = pWindow->drawable.pScreen;
+ DMXScreenInfo *dmxScreen = &dmxScreens[pScreen->myNum];
+ dmxWinPrivPtr pWinPriv = DMX_GET_WINDOW_PRIV(pWindow);
+ dmxWinPrivPtr pParentPriv = DMX_GET_WINDOW_PRIV(pWindow->parent);
+
+ DMX_UNWRAP(ReparentWindow, dmxScreen, pScreen);
+#if 0
+ if (pScreen->ReparentWindow)
+ pScreen->ReparentWindow(pWindow, pPriorParent);
+#endif
+
+ if (pWinPriv->window) {
+ if (!pParentPriv->window) {
+ dmxCreateAndRealizeWindow(pWindow->parent, FALSE);
+ }
+
+ /* Handle reparenting on back-end server */
+ XReparentWindow(dmxScreen->beDisplay, pWinPriv->window,
+ pParentPriv->window,
+ pWindow->origin.x - wBorderWidth(pWindow),
+ pWindow->origin.x - wBorderWidth(pWindow));
+ dmxSync(dmxScreen, False);
+ }
+
+ DMX_WRAP(ReparentWindow, dmxReparentWindow, dmxScreen, pScreen);
+ dmxUpdateWindowInfo(DMX_UPDATE_REPARENT, pWindow);
+}
+
+/** Change border width for \a pWindow to \a width pixels. */
+void dmxChangeBorderWidth(WindowPtr pWindow, unsigned int width)
+{
+ ScreenPtr pScreen = pWindow->drawable.pScreen;
+ DMXScreenInfo *dmxScreen = &dmxScreens[pScreen->myNum];
+ dmxWinPrivPtr pWinPriv = DMX_GET_WINDOW_PRIV(pWindow);
+ unsigned int m;
+ XWindowChanges c;
+
+ DMX_UNWRAP(ChangeBorderWidth, dmxScreen, pScreen);
+#if 1
+ if (pScreen->ChangeBorderWidth)
+ pScreen->ChangeBorderWidth(pWindow, width);
+#endif
+
+ /* NOTE: Do we need to check for on/off screen here? */
+
+ if (pWinPriv->window) {
+ /* Handle border width change on back-end server */
+ m = CWBorderWidth;
+ c.border_width = width;
+
+ XConfigureWindow(dmxScreen->beDisplay, pWinPriv->window, m, &c);
+ dmxSync(dmxScreen, False);
+ }
+
+ DMX_WRAP(ChangeBorderWidth, dmxChangeBorderWidth, dmxScreen, pScreen);
+}
+
+static void dmxDoSetShape(WindowPtr pWindow)
+{
+ ScreenPtr pScreen = pWindow->drawable.pScreen;
+ DMXScreenInfo *dmxScreen = &dmxScreens[pScreen->myNum];
+ dmxWinPrivPtr pWinPriv = DMX_GET_WINDOW_PRIV(pWindow);
+ int nBox;
+ BoxPtr pBox;
+ int nRect;
+ XRectangle *pRect;
+ XRectangle *pRectFirst;
+
+ /* First, set the bounding shape */
+ if (wBoundingShape(pWindow)) {
+ pBox = RegionRects(wBoundingShape(pWindow));
+ nRect = nBox = RegionNumRects(wBoundingShape(pWindow));
+ pRectFirst = pRect = malloc(nRect * sizeof(*pRect));
+ while (nBox--) {
+ pRect->x = pBox->x1;
+ pRect->y = pBox->y1;
+ pRect->width = pBox->x2 - pBox->x1;
+ pRect->height = pBox->y2 - pBox->y1;
+ pBox++;
+ pRect++;
+ }
+ XShapeCombineRectangles(dmxScreen->beDisplay, pWinPriv->window,
+ ShapeBounding, 0, 0,
+ pRectFirst, nRect,
+ ShapeSet, YXBanded);
+ free(pRectFirst);
+ } else {
+ XShapeCombineMask(dmxScreen->beDisplay, pWinPriv->window,
+ ShapeBounding, 0, 0, None, ShapeSet);
+ }
+
+ /* Next, set the clip shape */
+ if (wClipShape(pWindow)) {
+ pBox = RegionRects(wClipShape(pWindow));
+ nRect = nBox = RegionNumRects(wClipShape(pWindow));
+ pRectFirst = pRect = malloc(nRect * sizeof(*pRect));
+ while (nBox--) {
+ pRect->x = pBox->x1;
+ pRect->y = pBox->y1;
+ pRect->width = pBox->x2 - pBox->x1;
+ pRect->height = pBox->y2 - pBox->y1;
+ pBox++;
+ pRect++;
+ }
+ XShapeCombineRectangles(dmxScreen->beDisplay, pWinPriv->window,
+ ShapeClip, 0, 0,
+ pRectFirst, nRect,
+ ShapeSet, YXBanded);
+ free(pRectFirst);
+ } else {
+ XShapeCombineMask(dmxScreen->beDisplay, pWinPriv->window,
+ ShapeClip, 0, 0, None, ShapeSet);
+ }
+
+ if (XShapeInputSelected(dmxScreen->beDisplay, pWinPriv->window)) {
+ ErrorF("Input selected for window %x on Screen %d\n",
+ (unsigned int)pWinPriv->window, pScreen->myNum);
+ }
+}
+
+/** Set shape of \a pWindow on the back-end server. */
+void dmxSetShape(WindowPtr pWindow, int kind)
+{
+ ScreenPtr pScreen = pWindow->drawable.pScreen;
+ DMXScreenInfo *dmxScreen = &dmxScreens[pScreen->myNum];
+ dmxWinPrivPtr pWinPriv = DMX_GET_WINDOW_PRIV(pWindow);
+
+ DMX_UNWRAP(SetShape, dmxScreen, pScreen);
+#if 1
+ if (pScreen->SetShape)
+ pScreen->SetShape(pWindow, kind);
+#endif
+
+ if (pWinPriv->window) {
+ /* Handle setting the current shape on the back-end server */
+ dmxDoSetShape(pWindow);
+ dmxSync(dmxScreen, False);
+ } else {
+ pWinPriv->isShaped = TRUE;
+ }
+
+ DMX_WRAP(SetShape, dmxSetShape, dmxScreen, pScreen);
+}
diff --git a/xorg-server/hw/dmx/doc/Makefile.am b/xorg-server/hw/dmx/doc/Makefile.am
index d3acf23b7..0713884cd 100644
--- a/xorg-server/hw/dmx/doc/Makefile.am
+++ b/xorg-server/hw/dmx/doc/Makefile.am
@@ -1,277 +1,34 @@
-# Copyright 2005 Red Hat, 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.
-
-doc_sources = dmx.xml scaled.xml
-
-# Developer's documentation is not installed
-if ENABLE_DEVEL_DOCS
-include $(top_srcdir)/doc/xml/xmlrules-noinst.in
-endif ENABLE_DEVEL_DOCS
-
-DOXYGEN_HEAD=\
- html/annotated.html
-
-DOXYGEN_REST= \
- html/ChkNotMaskEv_8c.html \
- html/ChkNotMaskEv_8h.html \
- html/ChkNotMaskEv_8h_source.html \
- html/classes.html \
- html/dmx_8h.html \
- html/dmx_8h_source.html \
- html/dmxarg_8c.html \
- html/dmxarg_8h.html \
- html/dmxarg_8h_source.html \
- html/dmxbackend_8c.html \
- html/dmxbackend_8h.html \
- html/dmxbackend_8h_source.html \
- html/dmxcb_8c.html \
- html/dmxcb_8h.html \
- html/dmxcb_8h_source.html \
- html/dmxclient_8h.html \
- html/dmxclient_8h_source.html \
- html/dmxcmap_8c.html \
- html/dmxcmap_8h.html \
- html/dmxcmap_8h_source.html \
- html/dmxcommon_8c.html \
- html/dmxcommon_8h.html \
- html/dmxcommon_8h_source.html \
- html/dmxcompat_8c.html \
- html/dmxcompat_8h.html \
- html/dmxcompat_8h_source.html \
- html/dmxconfig_8c.html \
- html/dmxconfig_8h.html \
- html/dmxconfig_8h_source.html \
- html/dmxconsole_8c.html \
- html/dmxconsole_8h.html \
- html/dmxconsole_8h_source.html \
- html/dmxcursor_8c.html \
- html/dmxcursor_8h.html \
- html/dmxcursor_8h_source.html \
- html/dmxdetach_8c.html \
- html/dmxdpms_8c.html \
- html/dmxdpms_8h.html \
- html/dmxdpms_8h_source.html \
- html/dmxdummy_8c.html \
- html/dmxdummy_8h.html \
- html/dmxdummy_8h_source.html \
- html/dmxevents_8c.html \
- html/dmxevents_8h.html \
- html/dmxevents_8h_source.html \
- html/dmxextension_8c.html \
- html/dmxextension_8h.html \
- html/dmxextension_8h_source.html \
- html/dmxfont_8c.html \
- html/dmxfont_8h.html \
- html/dmxfont_8h_source.html \
- html/dmxgc_8c.html \
- html/dmxgc_8h.html \
- html/dmxgc_8h_source.html \
- html/dmxgcops_8c.html \
- html/dmxgcops_8h.html \
- html/dmxgcops_8h_source.html \
- html/dmx__glxvisuals_8h_source.html \
- html/dmxinit_8c.html \
- html/dmxinit_8h.html \
- html/dmxinit_8h_source.html \
- html/dmxinput_8c.html \
- html/dmxinput_8h.html \
- html/dmxinput_8h_source.html \
- html/dmxinputinit_8c.html \
- html/dmxinputinit_8h.html \
- html/dmxinputinit_8h_source.html \
- html/dmxlog_8c.html \
- html/dmxlog_8h.html \
- html/dmxlog_8h_source.html \
- html/dmxmap_8c.html \
- html/dmxmap_8h.html \
- html/dmxmap_8h_source.html \
- html/dmxmotion_8c.html \
- html/dmxmotion_8h.html \
- html/dmxmotion_8h_source.html \
- html/dmxparse_8c.html \
- html/dmxparse_8h.html \
- html/dmxparse_8h_source.html \
- html/dmxpict_8c.html \
- html/dmxpict_8h.html \
- html/dmxpict_8h_source.html \
- html/dmxpixmap_8c.html \
- html/dmxpixmap_8h.html \
- html/dmxpixmap_8h_source.html \
- html/dmxprint_8c.html \
- html/dmxprint_8h.html \
- html/dmxprint_8h_source.html \
- html/dmxprop_8c.html \
- html/dmxprop_8h.html \
- html/dmxprop_8h_source.html \
- html/dmxscrinit_8c.html \
- html/dmxscrinit_8h.html \
- html/dmxscrinit_8h_source.html \
- html/dmxshadow_8c.html \
- html/dmxshadow_8h.html \
- html/dmxshadow_8h_source.html \
- html/dmxsigio_8c.html \
- html/dmxsigio_8h.html \
- html/dmxsigio_8h_source.html \
- html/dmxstat_8c.html \
- html/dmxstat_8h.html \
- html/dmxstat_8h_source.html \
- html/dmxsync_8c.html \
- html/dmxsync_8h.html \
- html/dmxsync_8h_source.html \
- html/dmxvisual_8c.html \
- html/dmxvisual_8h.html \
- html/dmxvisual_8h_source.html \
- html/dmxwindow_8c.html \
- html/dmxwindow_8h.html \
- html/dmxwindow_8h_source.html \
- html/dmxxinput_8c.html \
- html/doxygen.css \
- html/doxygen.png \
- html/files.html \
- html/ftv2blank.png \
- html/ftv2doc.png \
- html/ftv2folderclosed.png \
- html/ftv2folderopen.png \
- html/ftv2lastnode.png \
- html/ftv2link.png \
- html/ftv2mlastnode.png \
- html/ftv2mnode.png \
- html/ftv2node.png \
- html/ftv2plastnode.png \
- html/ftv2pnode.png \
- html/ftv2vertline.png \
- html/functions.html \
- html/functions_vars.html \
- html/globals_defs.html \
- html/globals_enum.html \
- html/globals_eval.html \
- html/globals_func.html \
- html/globals.html \
- html/globals_type.html \
- html/globals_vars.html \
- html/index.html \
- html/lnx-keyboard_8c.html \
- html/lnx-keyboard_8h.html \
- html/lnx-keyboard_8h_source.html \
- html/lnx-ms_8c.html \
- html/lnx-ms_8h.html \
- html/lnx-ms_8h_source.html \
- html/lnx-ps2_8c.html \
- html/lnx-ps2_8h.html \
- html/lnx-ps2_8h_source.html \
- html/main.html \
- html/struct__dmxArg.html \
- html/struct__dmxColormapPriv.html \
- html/structDMXConfigCmdStruct.html \
- html/struct__DMXConfigComment.html \
- html/struct__DMXConfigDisplay.html \
- html/struct__DMXConfigEntry.html \
- html/struct__DMXConfigFullDim.html \
- html/structDMXConfigListStruct.html \
- html/struct__DMXConfigNumber.html \
- html/struct__DMXConfigOption.html \
- html/struct__DMXConfigPair.html \
- html/struct__DMXConfigParam.html \
- html/struct__DMXConfigPartDim.html \
- html/struct__DMXConfigString.html \
- html/struct__DMXConfigSub.html \
- html/struct__DMXConfigToken.html \
- html/struct__DMXConfigVirtual.html \
- html/struct__DMXConfigWall.html \
- html/struct__dmxCursorPriv.html \
- html/structDMXDesktopAttributesRec.html \
- html/struct__DMXEventMap.html \
- html/struct__dmxFontPriv.html \
- html/struct__dmxGCPriv.html \
- html/structdmxGlxVisualPrivate.html \
- html/struct__dmxGlyphPriv.html \
- html/structDMXInputAttributesRec.html \
- html/struct__DMXInputInfo.html \
- html/struct__DMXLocalInitInfo.html \
- html/struct__DMXLocalInputInfo.html \
- html/struct__dmxPictPriv.html \
- html/struct__dmxPixPriv.html \
- html/structDMXScreenAttributesRec.html \
- html/struct__DMXScreenInfo.html \
- html/struct__DMXStatAvg.html \
- html/struct__DMXStatInfo.html \
- html/structDMXWindowAttributesRec.html \
- html/struct__dmxWinPriv.html \
- html/struct__myPrivate.html \
- html/tree.html \
- html/usb-common_8c.html \
- html/usb-common_8h.html \
- html/usb-common_8h_source.html \
- html/usb-keyboard_8c.html \
- html/usb-keyboard_8h.html \
- html/usb-keyboard_8h_source.html \
- html/usb-mouse_8c.html \
- html/usb-mouse_8h.html \
- html/usb-mouse_8h_source.html \
- html/usb-other_8c.html \
- html/usb-other_8h.html \
- html/usb-other_8h_source.html \
- html/usb-private_8h.html \
- html/usb-private_8h_source.html
-
-DOXYGEN_FILES=$(DOXYGEN_HEAD) $(DOXYGEN_REST)
-
-EXTRA_DIST = \
- DMXSpec.txt \
- DMXSpec-v1.txt \
- doxygen.conf \
- doxygen.css \
- doxygen.foot \
- doxygen.head \
- $(DOXYGEN_FILES)
-
-if ENABLE_DEVEL_DOCS
-if HAVE_DOXYGEN
-
-DOXYGEN_SRC=doxygen.head doxygen.foot doxygen.css doxygen.conf
-
-all-local: $(DOXYGEN_FILES)
-
-dist-local: $(DOXYGEN_FILES)
-
-$(DOXYGEN_HEAD): $(DOXYGEN_SRC)
- $(DOXYGEN) doxygen.conf
-
-$(DOXYGEN_REST): $(DOXYGEN_HEAD)
-
-maintainer-clean-local:
- rm -rf html/
-
-distclean-local:
- rm -rf html/
-
-endif HAVE_DOXYGEN
-endif ENABLE_DEVEL_DOCS
-
-$(builddir)/doxygen.head:
- $(LN_S) $(srcdir)/doxygen.head $@
-
-$(builddir)/doxygen.foot:
- $(LN_S) $(srcdir)/doxygen.foot $@
-
-$(builddir)doxygen.css:
- $(LN_S) $(srcdir)/doxygen.css $@
-
+# Copyright 2005 Red Hat, 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.
+
+if ENABLE_DEVEL_DOCS
+if HAVE_XMLTO
+
+# Main DocBook/XML files (DOCTYPE book)
+docbook = dmx.xml scaled.xml
+
+# Generate DocBook/XML output formats with or without stylesheets
+include $(top_srcdir)/devbook.am
+
+endif HAVE_XMLTO
+endif ENABLE_DEVEL_DOCS
+
+EXTRA_DIST = DMXSpec.txt DMXSpec-v1.txt
diff --git a/xorg-server/hw/dmx/doc/doxygen.conf.in b/xorg-server/hw/dmx/doc/doxygen.conf.in
deleted file mode 100644
index f886a436f..000000000
--- a/xorg-server/hw/dmx/doc/doxygen.conf.in
+++ /dev/null
@@ -1,1053 +0,0 @@
-# Doxyfile 1.3.4
-
-# This file describes the settings to be used by the documentation system
-# doxygen (www.doxygen.org) for a project
-#
-# All text after a hash (#) is considered a comment and will be ignored
-# The format is:
-# TAG = value [value, ...]
-# For lists items can also be appended using:
-# TAG += value [value, ...]
-# Values that contain spaces should be placed between quotes (" ")
-
-#---------------------------------------------------------------------------
-# Project related configuration options
-#---------------------------------------------------------------------------
-
-# The PROJECT_NAME tag is a single word (or a sequence of words surrounded
-# by quotes) that should identify the project.
-
-PROJECT_NAME = "Distributed Multihead X"
-
-# The PROJECT_NUMBER tag can be used to enter a project or revision number.
-# This could be handy for archiving the generated documentation or
-# if some version control system is used.
-
-PROJECT_NUMBER = "dmx-1-2-20040604 and later"
-
-# The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute)
-# base path where the generated documentation will be put.
-# If a relative path is entered, it will be relative to the location
-# where doxygen was started. If left blank the current directory will be used.
-
-OUTPUT_DIRECTORY =
-
-# The OUTPUT_LANGUAGE tag is used to specify the language in which all
-# documentation generated by doxygen is written. Doxygen will use this
-# information to generate all constant output in the proper language.
-# The default language is English, other supported languages are:
-# Brazilian, Catalan, Chinese, Chinese-Traditional, Croatian, Czech, Danish, Dutch,
-# Finnish, French, German, Greek, Hungarian, Italian, Japanese, Japanese-en
-# (Japanese with English messages), Korean, Norwegian, Polish, Portuguese,
-# Romanian, Russian, Serbian, Slovak, Slovene, Spanish, Swedish, and Ukrainian.
-
-OUTPUT_LANGUAGE = English
-
-# If the BRIEF_MEMBER_DESC tag is set to YES (the default) Doxygen will
-# include brief member descriptions after the members that are listed in
-# the file and class documentation (similar to JavaDoc).
-# Set to NO to disable this.
-
-BRIEF_MEMBER_DESC = YES
-
-# If the REPEAT_BRIEF tag is set to YES (the default) Doxygen will prepend
-# the brief description of a member or function before the detailed description.
-# Note: if both HIDE_UNDOC_MEMBERS and BRIEF_MEMBER_DESC are set to NO, the
-# brief descriptions will be completely suppressed.
-
-REPEAT_BRIEF = YES
-
-# If the ALWAYS_DETAILED_SEC and REPEAT_BRIEF tags are both set to YES then
-# Doxygen will generate a detailed section even if there is only a brief
-# description.
-
-ALWAYS_DETAILED_SEC = YES
-
-# If the INLINE_INHERITED_MEMB tag is set to YES, doxygen will show all inherited
-# members of a class in the documentation of that class as if those members were
-# ordinary class members. Constructors, destructors and assignment operators of
-# the base classes will not be shown.
-
-INLINE_INHERITED_MEMB = NO
-
-# If the FULL_PATH_NAMES tag is set to YES then Doxygen will prepend the full
-# path before files name in the file list and in the header files. If set
-# to NO the shortest path that makes the file name unique will be used.
-
-FULL_PATH_NAMES = NO
-
-# If the FULL_PATH_NAMES tag is set to YES then the STRIP_FROM_PATH tag
-# can be used to strip a user-defined part of the path. Stripping is
-# only done if one of the specified strings matches the left-hand part of
-# the path. It is allowed to use relative paths in the argument list.
-
-STRIP_FROM_PATH =
-
-# If the SHORT_NAMES tag is set to YES, doxygen will generate much shorter
-# (but less readable) file names. This can be useful is your file systems
-# doesn't support long names like on DOS, Mac, or CD-ROM.
-
-SHORT_NAMES = NO
-
-# If the JAVADOC_AUTOBRIEF tag is set to YES then Doxygen
-# will interpret the first line (until the first dot) of a JavaDoc-style
-# comment as the brief description. If set to NO, the JavaDoc
-# comments will behave just like the Qt-style comments (thus requiring an
-# explict @brief command for a brief description.
-
-JAVADOC_AUTOBRIEF = NO
-
-# The MULTILINE_CPP_IS_BRIEF tag can be set to YES to make Doxygen
-# treat a multi-line C++ special comment block (i.e. a block of //! or ///
-# comments) as a brief description. This used to be the default behaviour.
-# The new default is to treat a multi-line C++ comment block as a detailed
-# description. Set this tag to YES if you prefer the old behaviour instead.
-
-MULTILINE_CPP_IS_BRIEF = NO
-
-# If the INHERIT_DOCS tag is set to YES (the default) then an undocumented
-# member inherits the documentation from any documented member that it
-# reimplements.
-
-INHERIT_DOCS = YES
-
-# If member grouping is used in the documentation and the DISTRIBUTE_GROUP_DOC
-# tag is set to YES, then doxygen will reuse the documentation of the first
-# member in the group (if any) for the other members of the group. By default
-# all members of a group must be documented explicitly.
-
-DISTRIBUTE_GROUP_DOC = NO
-
-# The TAB_SIZE tag can be used to set the number of spaces in a tab.
-# Doxygen uses this value to replace tabs by spaces in code fragments.
-
-TAB_SIZE = 8
-
-# This tag can be used to specify a number of aliases that acts
-# as commands in the documentation. An alias has the form "name=value".
-# For example adding "sideeffect=\par Side Effects:\n" will allow you to
-# put the command \sideeffect (or @sideeffect) in the documentation, which
-# will result in a user-defined paragraph with heading "Side Effects:".
-# You can put \n's in the value part of an alias to insert newlines.
-
-ALIASES =
-
-# Set the OPTIMIZE_OUTPUT_FOR_C tag to YES if your project consists of C sources
-# only. Doxygen will then generate output that is more tailored for C.
-# For instance, some of the names that are used will be different. The list
-# of all members will be omitted, etc.
-
-OPTIMIZE_OUTPUT_FOR_C = YES
-
-# Set the OPTIMIZE_OUTPUT_JAVA tag to YES if your project consists of Java sources
-# only. Doxygen will then generate output that is more tailored for Java.
-# For instance, namespaces will be presented as packages, qualified scopes
-# will look different, etc.
-
-OPTIMIZE_OUTPUT_JAVA = NO
-
-# Set the SUBGROUPING tag to YES (the default) to allow class member groups of
-# the same type (for instance a group of public functions) to be put as a
-# subgroup of that type (e.g. under the Public Functions section). Set it to
-# NO to prevent subgrouping. Alternatively, this can be done per class using
-# the \nosubgrouping command.
-
-SUBGROUPING = YES
-
-#---------------------------------------------------------------------------
-# Build related configuration options
-#---------------------------------------------------------------------------
-
-# If the EXTRACT_ALL tag is set to YES doxygen will assume all entities in
-# documentation are documented, even if no documentation was available.
-# Private class members and static file members will be hidden unless
-# the EXTRACT_PRIVATE and EXTRACT_STATIC tags are set to YES
-
-EXTRACT_ALL = YES
-
-# If the EXTRACT_PRIVATE tag is set to YES all private members of a class
-# will be included in the documentation.
-
-EXTRACT_PRIVATE = NO
-
-# If the EXTRACT_STATIC tag is set to YES all static members of a file
-# will be included in the documentation.
-
-EXTRACT_STATIC = YES
-
-# If the EXTRACT_LOCAL_CLASSES tag is set to YES classes (and structs)
-# defined locally in source files will be included in the documentation.
-# If set to NO only classes defined in header files are included.
-
-EXTRACT_LOCAL_CLASSES = YES
-
-# If the HIDE_UNDOC_MEMBERS tag is set to YES, Doxygen will hide all
-# undocumented members of documented classes, files or namespaces.
-# If set to NO (the default) these members will be included in the
-# various overviews, but no documentation section is generated.
-# This option has no effect if EXTRACT_ALL is enabled.
-
-HIDE_UNDOC_MEMBERS = YES
-
-# If the HIDE_UNDOC_CLASSES tag is set to YES, Doxygen will hide all
-# undocumented classes that are normally visible in the class hierarchy.
-# If set to NO (the default) these classes will be included in the various
-# overviews. This option has no effect if EXTRACT_ALL is enabled.
-
-HIDE_UNDOC_CLASSES = NO
-
-# If the HIDE_FRIEND_COMPOUNDS tag is set to YES, Doxygen will hide all
-# friend (class|struct|union) declarations.
-# If set to NO (the default) these declarations will be included in the
-# documentation.
-
-HIDE_FRIEND_COMPOUNDS = NO
-
-# If the HIDE_IN_BODY_DOCS tag is set to YES, Doxygen will hide any
-# documentation blocks found inside the body of a function.
-# If set to NO (the default) these blocks will be appended to the
-# function's detailed documentation block.
-
-HIDE_IN_BODY_DOCS = NO
-
-# The INTERNAL_DOCS tag determines if documentation
-# that is typed after a \internal command is included. If the tag is set
-# to NO (the default) then the documentation will be excluded.
-# Set it to YES to include the internal documentation.
-
-INTERNAL_DOCS = NO
-
-# If the CASE_SENSE_NAMES tag is set to NO then Doxygen will only generate
-# file names in lower-case letters. If set to YES upper-case letters are also
-# allowed. This is useful if you have classes or files whose names only differ
-# in case and if your file system supports case sensitive file names. Windows
-# users are advised to set this option to NO.
-
-CASE_SENSE_NAMES = YES
-
-# If the HIDE_SCOPE_NAMES tag is set to NO (the default) then Doxygen
-# will show members with their full class and namespace scopes in the
-# documentation. If set to YES the scope will be hidden.
-
-HIDE_SCOPE_NAMES = NO
-
-# If the SHOW_INCLUDE_FILES tag is set to YES (the default) then Doxygen
-# will put a list of the files that are included by a file in the documentation
-# of that file.
-
-SHOW_INCLUDE_FILES = YES
-
-# If the INLINE_INFO tag is set to YES (the default) then a tag [inline]
-# is inserted in the documentation for inline members.
-
-INLINE_INFO = YES
-
-# If the SORT_MEMBER_DOCS tag is set to YES (the default) then doxygen
-# will sort the (detailed) documentation of file and class members
-# alphabetically by member name. If set to NO the members will appear in
-# declaration order.
-
-SORT_MEMBER_DOCS = YES
-
-# The GENERATE_TODOLIST tag can be used to enable (YES) or
-# disable (NO) the todo list. This list is created by putting \todo
-# commands in the documentation.
-
-GENERATE_TODOLIST = YES
-
-# The GENERATE_TESTLIST tag can be used to enable (YES) or
-# disable (NO) the test list. This list is created by putting \test
-# commands in the documentation.
-
-GENERATE_TESTLIST = YES
-
-# The GENERATE_BUGLIST tag can be used to enable (YES) or
-# disable (NO) the bug list. This list is created by putting \bug
-# commands in the documentation.
-
-GENERATE_BUGLIST = YES
-
-# The GENERATE_DEPRECATEDLIST tag can be used to enable (YES) or
-# disable (NO) the deprecated list. This list is created by putting
-# \deprecated commands in the documentation.
-
-GENERATE_DEPRECATEDLIST= YES
-
-# The ENABLED_SECTIONS tag can be used to enable conditional
-# documentation sections, marked by \if sectionname ... \endif.
-
-ENABLED_SECTIONS =
-
-# The MAX_INITIALIZER_LINES tag determines the maximum number of lines
-# the initial value of a variable or define consists of for it to appear in
-# the documentation. If the initializer consists of more lines than specified
-# here it will be hidden. Use a value of 0 to hide initializers completely.
-# The appearance of the initializer of individual variables and defines in the
-# documentation can be controlled using \showinitializer or \hideinitializer
-# command in the documentation regardless of this setting.
-
-MAX_INITIALIZER_LINES = 30
-
-# Set the SHOW_USED_FILES tag to NO to disable the list of files generated
-# at the bottom of the documentation of classes and structs. If set to YES the
-# list will mention the files that were used to generate the documentation.
-
-SHOW_USED_FILES = YES
-
-#---------------------------------------------------------------------------
-# configuration options related to warning and progress messages
-#---------------------------------------------------------------------------
-
-# The QUIET tag can be used to turn on/off the messages that are generated
-# by doxygen. Possible values are YES and NO. If left blank NO is used.
-
-QUIET = YES
-
-# The WARNINGS tag can be used to turn on/off the warning messages that are
-# generated by doxygen. Possible values are YES and NO. If left blank
-# NO is used.
-
-WARNINGS = YES
-
-# If WARN_IF_UNDOCUMENTED is set to YES, then doxygen will generate warnings
-# for undocumented members. If EXTRACT_ALL is set to YES then this flag will
-# automatically be disabled.
-
-WARN_IF_UNDOCUMENTED = YES
-
-# If WARN_IF_DOC_ERROR is set to YES, doxygen will generate warnings for
-# potential errors in the documentation, such as not documenting some
-# parameters in a documented function, or documenting parameters that
-# don't exist or using markup commands wrongly.
-
-WARN_IF_DOC_ERROR = YES
-
-# The WARN_FORMAT tag determines the format of the warning messages that
-# doxygen can produce. The string should contain the $file, $line, and $text
-# tags, which will be replaced by the file and line number from which the
-# warning originated and the warning text.
-
-WARN_FORMAT = "$file:$line: $text"
-
-# The WARN_LOGFILE tag can be used to specify a file to which warning
-# and error messages should be written. If left blank the output is written
-# to stderr.
-
-WARN_LOGFILE =
-
-#---------------------------------------------------------------------------
-# configuration options related to the input files
-#---------------------------------------------------------------------------
-
-# The INPUT tag can be used to specify the files and/or directories that contain
-# documented source files. You may enter file names like "myfile.cpp" or
-# directories like "/usr/src/myproject". Separate the files or directories
-# with spaces.
-
-INPUT = @srcdir@/.. \
- @srcdir@/../input \
- @srcdir@/../config
-
-# If the value of the INPUT tag contains directories, you can use the
-# FILE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp
-# and *.h) to filter out the source-files in the directories. If left
-# blank the following patterns are tested:
-# *.c *.cc *.cxx *.cpp *.c++ *.java *.ii *.ixx *.ipp *.i++ *.inl *.h *.hh *.hxx *.hpp
-# *.h++ *.idl *.odl *.cs *.php *.php3 *.inc
-
-FILE_PATTERNS =
-
-# The RECURSIVE tag can be used to turn specify whether or not subdirectories
-# should be searched for input files as well. Possible values are YES and NO.
-# If left blank NO is used.
-
-RECURSIVE = NO
-
-# The EXCLUDE tag can be used to specify files and/or directories that should
-# excluded from the INPUT source files. This way you can easily exclude a
-# subdirectory from a directory tree whose root is specified with the INPUT tag.
-
-EXCLUDE = @srcdir@/../config/parser.c \
- @srcdir@/../config/parser.h \
- @srcdir@/../config/scanner.c
-
-# The EXCLUDE_SYMLINKS tag can be used select whether or not files or directories
-# that are symbolic links (a Unix filesystem feature) are excluded from the input.
-
-EXCLUDE_SYMLINKS = YES
-
-# If the value of the INPUT tag contains directories, you can use the
-# EXCLUDE_PATTERNS tag to specify one or more wildcard patterns to exclude
-# certain files from those directories.
-
-EXCLUDE_PATTERNS = atKeynames.h \
- Canvas*.*
-
-# The EXAMPLE_PATH tag can be used to specify one or more files or
-# directories that contain example code fragments that are included (see
-# the \include command).
-
-EXAMPLE_PATH =
-
-# If the value of the EXAMPLE_PATH tag contains directories, you can use the
-# EXAMPLE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp
-# and *.h) to filter out the source-files in the directories. If left
-# blank all files are included.
-
-EXAMPLE_PATTERNS =
-
-# If the EXAMPLE_RECURSIVE tag is set to YES then subdirectories will be
-# searched for input files to be used with the \include or \dontinclude
-# commands irrespective of the value of the RECURSIVE tag.
-# Possible values are YES and NO. If left blank NO is used.
-
-EXAMPLE_RECURSIVE = NO
-
-# The IMAGE_PATH tag can be used to specify one or more files or
-# directories that contain image that are included in the documentation (see
-# the \image command).
-
-IMAGE_PATH =
-
-# The INPUT_FILTER tag can be used to specify a program that doxygen should
-# invoke to filter for each input file. Doxygen will invoke the filter program
-# by executing (via popen()) the command <filter> <input-file>, where <filter>
-# is the value of the INPUT_FILTER tag, and <input-file> is the name of an
-# input file. Doxygen will then use the output that the filter program writes
-# to standard output.
-
-INPUT_FILTER =
-
-# If the FILTER_SOURCE_FILES tag is set to YES, the input filter (if set using
-# INPUT_FILTER) will be used to filter the input files when producing source
-# files to browse (i.e. when SOURCE_BROWSER is set to YES).
-
-FILTER_SOURCE_FILES = NO
-
-#---------------------------------------------------------------------------
-# configuration options related to source browsing
-#---------------------------------------------------------------------------
-
-# If the SOURCE_BROWSER tag is set to YES then a list of source files will
-# be generated. Documented entities will be cross-referenced with these sources.
-
-SOURCE_BROWSER = NO
-
-# Setting the INLINE_SOURCES tag to YES will include the body
-# of functions and classes directly in the documentation.
-
-INLINE_SOURCES = NO
-
-# Setting the STRIP_CODE_COMMENTS tag to YES (the default) will instruct
-# doxygen to hide any special comment blocks from generated source code
-# fragments. Normal C and C++ comments will always remain visible.
-
-STRIP_CODE_COMMENTS = YES
-
-# If the REFERENCED_BY_RELATION tag is set to YES (the default)
-# then for each documented function all documented
-# functions referencing it will be listed.
-
-REFERENCED_BY_RELATION = YES
-
-# If the REFERENCES_RELATION tag is set to YES (the default)
-# then for each documented function all documented entities
-# called/used by that function will be listed.
-
-REFERENCES_RELATION = YES
-
-# If the VERBATIM_HEADERS tag is set to YES (the default) then Doxygen
-# will generate a verbatim copy of the header file for each class for
-# which an include is specified. Set to NO to disable this.
-
-VERBATIM_HEADERS = YES
-
-#---------------------------------------------------------------------------
-# configuration options related to the alphabetical class index
-#---------------------------------------------------------------------------
-
-# If the ALPHABETICAL_INDEX tag is set to YES, an alphabetical index
-# of all compounds will be generated. Enable this if the project
-# contains a lot of classes, structs, unions or interfaces.
-
-ALPHABETICAL_INDEX = YES
-
-# If the alphabetical index is enabled (see ALPHABETICAL_INDEX) then
-# the COLS_IN_ALPHA_INDEX tag can be used to specify the number of columns
-# in which this list will be split (can be a number in the range [1..20])
-
-COLS_IN_ALPHA_INDEX = 5
-
-# In case all classes in a project start with a common prefix, all
-# classes will be put under the same header in the alphabetical index.
-# The IGNORE_PREFIX tag can be used to specify one or more prefixes that
-# should be ignored while generating the index headers.
-
-IGNORE_PREFIX =
-
-#---------------------------------------------------------------------------
-# configuration options related to the HTML output
-#---------------------------------------------------------------------------
-
-# If the GENERATE_HTML tag is set to YES (the default) Doxygen will
-# generate HTML output.
-
-GENERATE_HTML = YES
-
-# The HTML_OUTPUT tag is used to specify where the HTML docs will be put.
-# If a relative path is entered the value of OUTPUT_DIRECTORY will be
-# put in front of it. If left blank `html' will be used as the default path.
-
-HTML_OUTPUT = html
-
-# The HTML_FILE_EXTENSION tag can be used to specify the file extension for
-# each generated HTML page (for example: .htm,.php,.asp). If it is left blank
-# doxygen will generate files with .html extension.
-
-HTML_FILE_EXTENSION = .html
-
-# The HTML_HEADER tag can be used to specify a personal HTML header for
-# each generated HTML page. If it is left blank doxygen will generate a
-# standard header.
-
-HTML_HEADER = @srcdir@/doxygen.head
-
-# The HTML_FOOTER tag can be used to specify a personal HTML footer for
-# each generated HTML page. If it is left blank doxygen will generate a
-# standard footer.
-
-HTML_FOOTER = @srcdir@/doxygen.foot
-
-# The HTML_STYLESHEET tag can be used to specify a user-defined cascading
-# style sheet that is used by each HTML page. It can be used to
-# fine-tune the look of the HTML output. If the tag is left blank doxygen
-# will generate a default style sheet
-
-HTML_STYLESHEET = @srcdir@/doxygen.css
-
-# If the HTML_ALIGN_MEMBERS tag is set to YES, the members of classes,
-# files or namespaces will be aligned in HTML using tables. If set to
-# NO a bullet list will be used.
-
-HTML_ALIGN_MEMBERS = YES
-
-# If the GENERATE_HTMLHELP tag is set to YES, additional index files
-# will be generated that can be used as input for tools like the
-# Microsoft HTML help workshop to generate a compressed HTML help file (.chm)
-# of the generated HTML documentation.
-
-GENERATE_HTMLHELP = NO
-
-# If the GENERATE_HTMLHELP tag is set to YES, the CHM_FILE tag can
-# be used to specify the file name of the resulting .chm file. You
-# can add a path in front of the file if the result should not be
-# written to the html output dir.
-
-CHM_FILE =
-
-# If the GENERATE_HTMLHELP tag is set to YES, the HHC_LOCATION tag can
-# be used to specify the location (absolute path including file name) of
-# the HTML help compiler (hhc.exe). If non-empty doxygen will try to run
-# the HTML help compiler on the generated index.hhp.
-
-HHC_LOCATION =
-
-# If the GENERATE_HTMLHELP tag is set to YES, the GENERATE_CHI flag
-# controls if a separate .chi index file is generated (YES) or that
-# it should be included in the master .chm file (NO).
-
-GENERATE_CHI = NO
-
-# If the GENERATE_HTMLHELP tag is set to YES, the BINARY_TOC flag
-# controls whether a binary table of contents is generated (YES) or a
-# normal table of contents (NO) in the .chm file.
-
-BINARY_TOC = NO
-
-# The TOC_EXPAND flag can be set to YES to add extra items for group members
-# to the contents of the HTML help documentation and to the tree view.
-
-TOC_EXPAND = NO
-
-# The DISABLE_INDEX tag can be used to turn on/off the condensed index at
-# top of each HTML page. The value NO (the default) enables the index and
-# the value YES disables it.
-
-DISABLE_INDEX = NO
-
-# This tag can be used to set the number of enum values (range [1..20])
-# that doxygen will group on one line in the generated HTML documentation.
-
-ENUM_VALUES_PER_LINE = 4
-
-# If the GENERATE_TREEVIEW tag is set to YES, a side panel will be
-# generated containing a tree-like index structure (just like the one that
-# is generated for HTML Help). For this to work a browser that supports
-# JavaScript, DHTML, CSS and frames is required (for instance Mozilla 1.0+,
-# Netscape 6.0+, Internet explorer 5.0+, or Konqueror). Windows users are
-# probably better off using the HTML help feature.
-
-GENERATE_TREEVIEW = YES
-
-# If the treeview is enabled (see GENERATE_TREEVIEW) then this tag can be
-# used to set the initial width (in pixels) of the frame in which the tree
-# is shown.
-
-TREEVIEW_WIDTH = 250
-
-#---------------------------------------------------------------------------
-# configuration options related to the LaTeX output
-#---------------------------------------------------------------------------
-
-# If the GENERATE_LATEX tag is set to YES (the default) Doxygen will
-# generate Latex output.
-
-GENERATE_LATEX = NO
-
-# The LATEX_OUTPUT tag is used to specify where the LaTeX docs will be put.
-# If a relative path is entered the value of OUTPUT_DIRECTORY will be
-# put in front of it. If left blank `latex' will be used as the default path.
-
-LATEX_OUTPUT = latex
-
-# The LATEX_CMD_NAME tag can be used to specify the LaTeX command name to be
-# invoked. If left blank `latex' will be used as the default command name.
-
-LATEX_CMD_NAME = latex
-
-# The MAKEINDEX_CMD_NAME tag can be used to specify the command name to
-# generate index for LaTeX. If left blank `makeindex' will be used as the
-# default command name.
-
-MAKEINDEX_CMD_NAME = makeindex
-
-# If the COMPACT_LATEX tag is set to YES Doxygen generates more compact
-# LaTeX documents. This may be useful for small projects and may help to
-# save some trees in general.
-
-COMPACT_LATEX = NO
-
-# The PAPER_TYPE tag can be used to set the paper type that is used
-# by the printer. Possible values are: a4, a4wide, letter, legal and
-# executive. If left blank a4wide will be used.
-
-PAPER_TYPE = a4wide
-
-# The EXTRA_PACKAGES tag can be to specify one or more names of LaTeX
-# packages that should be included in the LaTeX output.
-
-EXTRA_PACKAGES =
-
-# The LATEX_HEADER tag can be used to specify a personal LaTeX header for
-# the generated latex document. The header should contain everything until
-# the first chapter. If it is left blank doxygen will generate a
-# standard header. Notice: only use this tag if you know what you are doing!
-
-LATEX_HEADER =
-
-# If the PDF_HYPERLINKS tag is set to YES, the LaTeX that is generated
-# is prepared for conversion to pdf (using ps2pdf). The pdf file will
-# contain links (just like the HTML output) instead of page references
-# This makes the output suitable for online browsing using a pdf viewer.
-
-PDF_HYPERLINKS = NO
-
-# If the USE_PDFLATEX tag is set to YES, pdflatex will be used instead of
-# plain latex in the generated Makefile. Set this option to YES to get a
-# higher quality PDF documentation.
-
-USE_PDFLATEX = NO
-
-# If the LATEX_BATCHMODE tag is set to YES, doxygen will add the \\batchmode.
-# command to the generated LaTeX files. This will instruct LaTeX to keep
-# running if errors occur, instead of asking the user for help.
-# This option is also used when generating formulas in HTML.
-
-LATEX_BATCHMODE = NO
-
-# If LATEX_HIDE_INDICES is set to YES then doxygen will not
-# include the index chapters (such as File Index, Compound Index, etc.)
-# in the output.
-
-LATEX_HIDE_INDICES = NO
-
-#---------------------------------------------------------------------------
-# configuration options related to the RTF output
-#---------------------------------------------------------------------------
-
-# If the GENERATE_RTF tag is set to YES Doxygen will generate RTF output
-# The RTF output is optimised for Word 97 and may not look very pretty with
-# other RTF readers or editors.
-
-GENERATE_RTF = NO
-
-# The RTF_OUTPUT tag is used to specify where the RTF docs will be put.
-# If a relative path is entered the value of OUTPUT_DIRECTORY will be
-# put in front of it. If left blank `rtf' will be used as the default path.
-
-RTF_OUTPUT = rtf
-
-# If the COMPACT_RTF tag is set to YES Doxygen generates more compact
-# RTF documents. This may be useful for small projects and may help to
-# save some trees in general.
-
-COMPACT_RTF = NO
-
-# If the RTF_HYPERLINKS tag is set to YES, the RTF that is generated
-# will contain hyperlink fields. The RTF file will
-# contain links (just like the HTML output) instead of page references.
-# This makes the output suitable for online browsing using WORD or other
-# programs which support those fields.
-# Note: wordpad (write) and others do not support links.
-
-RTF_HYPERLINKS = NO
-
-# Load stylesheet definitions from file. Syntax is similar to doxygen's
-# config file, i.e. a series of assigments. You only have to provide
-# replacements, missing definitions are set to their default value.
-
-RTF_STYLESHEET_FILE =
-
-# Set optional variables used in the generation of an rtf document.
-# Syntax is similar to doxygen's config file.
-
-RTF_EXTENSIONS_FILE =
-
-#---------------------------------------------------------------------------
-# configuration options related to the man page output
-#---------------------------------------------------------------------------
-
-# If the GENERATE_MAN tag is set to YES (the default) Doxygen will
-# generate man pages
-
-GENERATE_MAN = NO
-
-# The MAN_OUTPUT tag is used to specify where the man pages will be put.
-# If a relative path is entered the value of OUTPUT_DIRECTORY will be
-# put in front of it. If left blank `man' will be used as the default path.
-
-MAN_OUTPUT = man
-
-# The MAN_EXTENSION tag determines the extension that is added to
-# the generated man pages (default is the subroutine's section .3)
-
-MAN_EXTENSION = .3
-
-# If the MAN_LINKS tag is set to YES and Doxygen generates man output,
-# then it will generate one additional man file for each entity
-# documented in the real man page(s). These additional files
-# only source the real man page, but without them the man command
-# would be unable to find the correct page. The default is NO.
-
-MAN_LINKS = NO
-
-#---------------------------------------------------------------------------
-# configuration options related to the XML output
-#---------------------------------------------------------------------------
-
-# If the GENERATE_XML tag is set to YES Doxygen will
-# generate an XML file that captures the structure of
-# the code including all documentation. Note that this
-# feature is still experimental and incomplete at the
-# moment.
-
-GENERATE_XML = NO
-
-# The XML_OUTPUT tag is used to specify where the XML pages will be put.
-# If a relative path is entered the value of OUTPUT_DIRECTORY will be
-# put in front of it. If left blank `xml' will be used as the default path.
-
-XML_OUTPUT = xml
-
-# The XML_SCHEMA tag can be used to specify an XML schema,
-# which can be used by a validating XML parser to check the
-# syntax of the XML files.
-
-XML_SCHEMA =
-
-# The XML_DTD tag can be used to specify an XML DTD,
-# which can be used by a validating XML parser to check the
-# syntax of the XML files.
-
-XML_DTD =
-
-#---------------------------------------------------------------------------
-# configuration options for the AutoGen Definitions output
-#---------------------------------------------------------------------------
-
-# If the GENERATE_AUTOGEN_DEF tag is set to YES Doxygen will
-# generate an AutoGen Definitions (see autogen.sf.net) file
-# that captures the structure of the code including all
-# documentation. Note that this feature is still experimental
-# and incomplete at the moment.
-
-GENERATE_AUTOGEN_DEF = NO
-
-#---------------------------------------------------------------------------
-# configuration options related to the Perl module output
-#---------------------------------------------------------------------------
-
-# If the GENERATE_PERLMOD tag is set to YES Doxygen will
-# generate a Perl module file that captures the structure of
-# the code including all documentation. Note that this
-# feature is still experimental and incomplete at the
-# moment.
-
-GENERATE_PERLMOD = NO
-
-# If the PERLMOD_LATEX tag is set to YES Doxygen will generate
-# the necessary Makefile rules, Perl scripts and LaTeX code to be able
-# to generate PDF and DVI output from the Perl module output.
-
-PERLMOD_LATEX = NO
-
-# If the PERLMOD_PRETTY tag is set to YES the Perl module output will be
-# nicely formatted so it can be parsed by a human reader. This is useful
-# if you want to understand what is going on. On the other hand, if this
-# tag is set to NO the size of the Perl module output will be much smaller
-# and Perl will parse it just the same.
-
-PERLMOD_PRETTY = YES
-
-# The names of the make variables in the generated doxyrules.make file
-# are prefixed with the string contained in PERLMOD_MAKEVAR_PREFIX.
-# This is useful so different doxyrules.make files included by the same
-# Makefile don't overwrite each other's variables.
-
-PERLMOD_MAKEVAR_PREFIX =
-
-#---------------------------------------------------------------------------
-# Configuration options related to the preprocessor
-#---------------------------------------------------------------------------
-
-# If the ENABLE_PREPROCESSING tag is set to YES (the default) Doxygen will
-# evaluate all C-preprocessor directives found in the sources and include
-# files.
-
-ENABLE_PREPROCESSING = YES
-
-# If the MACRO_EXPANSION tag is set to YES Doxygen will expand all macro
-# names in the source code. If set to NO (the default) only conditional
-# compilation will be performed. Macro expansion can be done in a controlled
-# way by setting EXPAND_ONLY_PREDEF to YES.
-
-MACRO_EXPANSION = NO
-
-# If the EXPAND_ONLY_PREDEF and MACRO_EXPANSION tags are both set to YES
-# then the macro expansion is limited to the macros specified with the
-# PREDEFINED and EXPAND_AS_PREDEFINED tags.
-
-EXPAND_ONLY_PREDEF = NO
-
-# If the SEARCH_INCLUDES tag is set to YES (the default) the includes files
-# in the INCLUDE_PATH (see below) will be search if a #include is found.
-
-SEARCH_INCLUDES = YES
-
-# The INCLUDE_PATH tag can be used to specify one or more directories that
-# contain include files that are not input files but should be processed by
-# the preprocessor.
-
-INCLUDE_PATH =
-
-# You can use the INCLUDE_FILE_PATTERNS tag to specify one or more wildcard
-# patterns (like *.h and *.hpp) to filter out the header-files in the
-# directories. If left blank, the patterns specified with FILE_PATTERNS will
-# be used.
-
-INCLUDE_FILE_PATTERNS =
-
-# The PREDEFINED tag can be used to specify one or more macro names that
-# are defined before the preprocessor is started (similar to the -D option of
-# gcc). The argument of the tag is a list of macros of the form: name
-# or name=definition (no spaces). If the definition and the = are
-# omitted =1 is assumed.
-
-PREDEFINED = SHAPE \
- RENDER \
- XKB \
- XINPUT
-
-# If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then
-# this tag can be used to specify a list of macro names that should be expanded.
-# The macro definition that is found in the sources will be used.
-# Use the PREDEFINED tag if you want to use a different macro definition.
-
-EXPAND_AS_DEFINED =
-
-# If the SKIP_FUNCTION_MACROS tag is set to YES (the default) then
-# doxygen's preprocessor will remove all function-like macros that are alone
-# on a line, have an all uppercase name, and do not end with a semicolon. Such
-# function macros are typically used for boiler-plate code, and will confuse the
-# parser if not removed.
-
-SKIP_FUNCTION_MACROS = YES
-
-#---------------------------------------------------------------------------
-# Configuration::addtions related to external references
-#---------------------------------------------------------------------------
-
-# The TAGFILES option can be used to specify one or more tagfiles.
-# Optionally an initial location of the external documentation
-# can be added for each tagfile. The format of a tag file without
-# this location is as follows:
-# TAGFILES = file1 file2 ...
-# Adding location for the tag files is done as follows:
-# TAGFILES = file1=loc1 "file2 = loc2" ...
-# where "loc1" and "loc2" can be relative or absolute paths or
-# URLs. If a location is present for each tag, the installdox tool
-# does not have to be run to correct the links.
-# Note that each tag file must have a unique name
-# (where the name does NOT include the path)
-# If a tag file is not located in the directory in which doxygen
-# is run, you must also specify the path to the tagfile here.
-
-TAGFILES =
-
-# When a file name is specified after GENERATE_TAGFILE, doxygen will create
-# a tag file that is based on the input files it reads.
-
-GENERATE_TAGFILE =
-
-# If the ALLEXTERNALS tag is set to YES all external classes will be listed
-# in the class index. If set to NO only the inherited external classes
-# will be listed.
-
-ALLEXTERNALS = NO
-
-# If the EXTERNAL_GROUPS tag is set to YES all external groups will be listed
-# in the modules index. If set to NO, only the current project's groups will
-# be listed.
-
-EXTERNAL_GROUPS = YES
-
-# The PERL_PATH should be the absolute path and name of the perl script
-# interpreter (i.e. the result of `which perl').
-
-PERL_PATH = /usr/bin/perl
-
-#---------------------------------------------------------------------------
-# Configuration options related to the dot tool
-#---------------------------------------------------------------------------
-
-# If the CLASS_DIAGRAMS tag is set to YES (the default) Doxygen will
-# generate a inheritance diagram (in HTML, RTF and LaTeX) for classes with base or
-# super classes. Setting the tag to NO turns the diagrams off. Note that this
-# option is superceded by the HAVE_DOT option below. This is only a fallback. It is
-# recommended to install and use dot, since it yields more powerful graphs.
-
-CLASS_DIAGRAMS = YES
-
-# If set to YES, the inheritance and collaboration graphs will hide
-# inheritance and usage relations if the target is undocumented
-# or is not a class.
-
-HIDE_UNDOC_RELATIONS = YES
-
-# If you set the HAVE_DOT tag to YES then doxygen will assume the dot tool is
-# available from the path. This tool is part of Graphviz, a graph visualization
-# toolkit from AT&T and Lucent Bell Labs. The other options in this section
-# have no effect if this option is set to NO (the default)
-
-HAVE_DOT = NO
-
-# If the CLASS_GRAPH and HAVE_DOT tags are set to YES then doxygen
-# will generate a graph for each documented class showing the direct and
-# indirect inheritance relations. Setting this tag to YES will force the
-# the CLASS_DIAGRAMS tag to NO.
-
-CLASS_GRAPH = YES
-
-# If the COLLABORATION_GRAPH and HAVE_DOT tags are set to YES then doxygen
-# will generate a graph for each documented class showing the direct and
-# indirect implementation dependencies (inheritance, containment, and
-# class references variables) of the class with other documented classes.
-
-COLLABORATION_GRAPH = YES
-
-# If the UML_LOOK tag is set to YES doxygen will generate inheritance and
-# collaboration diagrams in a style similiar to the OMG's Unified Modeling
-# Language.
-
-UML_LOOK = NO
-
-# If set to YES, the inheritance and collaboration graphs will show the
-# relations between templates and their instances.
-
-TEMPLATE_RELATIONS = YES
-
-# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDE_GRAPH, and HAVE_DOT
-# tags are set to YES then doxygen will generate a graph for each documented
-# file showing the direct and indirect include dependencies of the file with
-# other documented files.
-
-INCLUDE_GRAPH = YES
-
-# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDED_BY_GRAPH, and
-# HAVE_DOT tags are set to YES then doxygen will generate a graph for each
-# documented header file showing the documented files that directly or
-# indirectly include this file.
-
-INCLUDED_BY_GRAPH = YES
-
-# If the CALL_GRAPH and HAVE_DOT tags are set to YES then doxygen will
-# generate a call dependency graph for every global function or class method.
-# Note that enabling this option will significantly increase the time of a run.
-# So in most cases it will be better to enable call graphs for selected
-# functions only using the \callgraph command.
-
-CALL_GRAPH = NO
-
-# If the GRAPHICAL_HIERARCHY and HAVE_DOT tags are set to YES then doxygen
-# will graphical hierarchy of all classes instead of a textual one.
-
-GRAPHICAL_HIERARCHY = YES
-
-# The DOT_IMAGE_FORMAT tag can be used to set the image format of the images
-# generated by dot. Possible values are png, jpg, or gif
-# If left blank png will be used.
-
-DOT_IMAGE_FORMAT = gif
-
-# The tag DOT_PATH can be used to specify the path where the dot tool can be
-# found. If left blank, it is assumed the dot tool can be found on the path.
-
-DOT_PATH =
-
-# The DOTFILE_DIRS tag can be used to specify one or more directories that
-# contain dot files that are included in the documentation (see the
-# \dotfile command).
-
-DOTFILE_DIRS =
-
-# The MAX_DOT_GRAPH_DEPTH tag can be used to set the maximum depth of the
-# graphs generated by dot. A depth value of 3 means that only nodes reachable
-# from the root by following a path via at most 3 edges will be shown. Nodes that
-# lay further from the root node will be omitted. Note that setting this option to
-# 1 or 2 may greatly reduce the computation time needed for large code bases. Also
-# note that a graph may be further truncated if the graph's image dimensions are
-# not sufficient to fit the graph (see MAX_DOT_GRAPH_WIDTH and MAX_DOT_GRAPH_HEIGHT).
-# If 0 is used for the depth value (the default), the graph is not depth-constrained.
-
-MAX_DOT_GRAPH_DEPTH = 0
-
-# If the GENERATE_LEGEND tag is set to YES (the default) Doxygen will
-# generate a legend page explaining the meaning of the various boxes and
-# arrows in the dot generated graphs.
-
-GENERATE_LEGEND = YES
-
-# If the DOT_CLEANUP tag is set to YES (the default) Doxygen will
-# remove the intermediate dot files that are used to generate
-# the various graphs.
-
-DOT_CLEANUP = YES
-
-#---------------------------------------------------------------------------
-# Configuration::addtions related to the search engine
-#---------------------------------------------------------------------------
-
-# The SEARCHENGINE tag specifies whether or not a search engine should be
-# used. If set to NO the values of all tags below this one will be ignored.
-
-SEARCHENGINE = NO
diff --git a/xorg-server/hw/dmx/doc/doxygen.css b/xorg-server/hw/dmx/doc/doxygen.css
deleted file mode 100644
index 841f709a7..000000000
--- a/xorg-server/hw/dmx/doc/doxygen.css
+++ /dev/null
@@ -1,49 +0,0 @@
-H1 { text-align: center; }
-CAPTION { font-weight: bold }
-A.qindex {}
-A.qindexRef {}
-A.el { text-decoration: none; font-weight: bold }
-A.elRef { font-weight: bold }
-A.code { text-decoration: none; font-weight: normal; color: #4444ee }
-A.codeRef { font-weight: normal; color: #4444ee }
-A:hover { text-decoration: none; background-color: #f2f2ff }
-DL.el { margin-left: -1cm }
-DIV.fragment { width: 100%; border: none; background-color: #eeeeee }
-DIV.ah { background-color: black; font-weight: bold; color: #ffffff; margin-bottom: 3px; margin-top: 3px }
-TD.md { background-color: #f2f2ff; font-weight: bold; }
-TD.mdname1 { background-color: #f2f2ff; font-weight: bold; color: #602020; }
-TD.mdname { background-color: #f2f2ff; font-weight: bold; color: #602020; width: 600px; }
-DIV.groupHeader { margin-left: 16px; margin-top: 12px; margin-bottom: 6px; font-weight: bold }
-DIV.groupText { margin-left: 16px; font-style: italic; font-size: smaller }
-BODY { background: white }
-TD.indexkey {
- background-color: #eeeeff;
- font-weight: bold;
- padding-right : 10px;
- padding-top : 2px;
- padding-left : 10px;
- padding-bottom : 2px;
- margin-left : 0px;
- margin-right : 0px;
- margin-top : 2px;
- margin-bottom : 2px
-}
-TD.indexvalue {
- background-color: #eeeeff;
- font-style: italic;
- padding-right : 10px;
- padding-top : 2px;
- padding-left : 10px;
- padding-bottom : 2px;
- margin-left : 0px;
- margin-right : 0px;
- margin-top : 2px;
- margin-bottom : 2px
-}
-FONT.keyword { color: #008000 }
-FONT.keywordtype { color: #604020 }
-FONT.keywordflow { color: #e08000 }
-FONT.comment { color: #800000 }
-FONT.preprocessor { color: #806020 }
-FONT.stringliteral { color: #002080 }
-FONT.charliteral { color: #008080 }
diff --git a/xorg-server/hw/dmx/doc/doxygen.foot b/xorg-server/hw/dmx/doc/doxygen.foot
deleted file mode 100644
index 3aca11763..000000000
--- a/xorg-server/hw/dmx/doc/doxygen.foot
+++ /dev/null
@@ -1,12 +0,0 @@
- <hr>
- <address>
- <small>
- Generated June 29, 2004 for <a
- href="http://dmx.sourceforge.net">Distributed Multihead X</a> by
- <a href="http://www.doxygen.org/index.html">doxygen</a>
- 1.3.4.
- </small>
- </addres>
- </hr>
- </body>
-</html>
diff --git a/xorg-server/hw/dmx/doc/doxygen.head b/xorg-server/hw/dmx/doc/doxygen.head
deleted file mode 100644
index 89bda8fda..000000000
--- a/xorg-server/hw/dmx/doc/doxygen.head
+++ /dev/null
@@ -1,8 +0,0 @@
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
-<html>
- <head>
- <meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
- <title>File Index</title>
- <link href="doxygen.css" rel="stylesheet" type="text/css">
- </head>
- <body>
diff --git a/xorg-server/hw/xfree86/doc/sgml/Makefile.am b/xorg-server/hw/dmx/doxygen/Makefile.am
index e6661c544..fe159df5c 100644
--- a/xorg-server/hw/xfree86/doc/sgml/Makefile.am
+++ b/xorg-server/hw/dmx/doxygen/Makefile.am
@@ -1,27 +1,36 @@
-# Copyright 2005 Red Hat, 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.
-
-doc_sources = DESIGN.xml
-
-# Developer's documentation is not installed
-if ENABLE_DEVEL_DOCS
-include $(top_srcdir)/doc/xml/xmlrules-noinst.in
-endif
+# Copyright 2005 Red Hat, 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.
+
+if ENABLE_DEVEL_DOCS
+if HAVE_DOXYGEN
+
+# Developers documentation is not installed
+noinst_DATA = html/index.html
+dist_noinst_DATA = doxygen.conf.in footer.html
+
+html/index.html:
+ $(AM_V_GEN)$(DOXYGEN) doxygen.conf
+
+clean-local:
+ $(AM_V_at)rm -fr html/
+
+endif HAVE_DOXYGEN
+endif ENABLE_DEVEL_DOCS
diff --git a/xorg-server/hw/dmx/doxygen/doxygen.conf.in b/xorg-server/hw/dmx/doxygen/doxygen.conf.in
new file mode 100644
index 000000000..3dbb27ec0
--- /dev/null
+++ b/xorg-server/hw/dmx/doxygen/doxygen.conf.in
@@ -0,0 +1,1559 @@
+# Doxyfile 1.6.2
+
+# This file describes the settings to be used by the documentation system
+# doxygen (www.doxygen.org) for a project
+#
+# All text after a hash (#) is considered a comment and will be ignored
+# The format is:
+# TAG = value [value, ...]
+# For lists items can also be appended using:
+# TAG += value [value, ...]
+# Values that contain spaces should be placed between quotes (" ")
+
+#---------------------------------------------------------------------------
+# Project related configuration options
+#---------------------------------------------------------------------------
+
+# This tag specifies the encoding used for all characters in the config file
+# that follow. The default is UTF-8 which is also the encoding used for all
+# text before the first occurrence of this tag. Doxygen uses libiconv (or the
+# iconv built into libc) for the transcoding. See
+# http://www.gnu.org/software/libiconv for the list of possible encodings.
+
+DOXYFILE_ENCODING = UTF-8
+
+# The PROJECT_NAME tag is a single word (or a sequence of words surrounded
+# by quotes) that should identify the project.
+
+PROJECT_NAME = "Distributed Multihead X"
+
+# The PROJECT_NUMBER tag can be used to enter a project or revision number.
+# This could be handy for archiving the generated documentation or
+# if some version control system is used.
+
+PROJECT_NUMBER = "@PACKAGE_VERSION@"
+
+# The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute)
+# base path where the generated documentation will be put.
+# If a relative path is entered, it will be relative to the location
+# where doxygen was started. If left blank the current directory will be used.
+
+OUTPUT_DIRECTORY =
+
+# If the CREATE_SUBDIRS tag is set to YES, then doxygen will create
+# 4096 sub-directories (in 2 levels) under the output directory of each output
+# format and will distribute the generated files over these directories.
+# Enabling this option can be useful when feeding doxygen a huge amount of
+# source files, where putting all generated files in the same directory would
+# otherwise cause performance problems for the file system.
+
+CREATE_SUBDIRS = NO
+
+# The OUTPUT_LANGUAGE tag is used to specify the language in which all
+# documentation generated by doxygen is written. Doxygen will use this
+# information to generate all constant output in the proper language.
+# The default language is English, other supported languages are:
+# Afrikaans, Arabic, Brazilian, Catalan, Chinese, Chinese-Traditional,
+# Croatian, Czech, Danish, Dutch, Esperanto, Farsi, Finnish, French, German,
+# Greek, Hungarian, Italian, Japanese, Japanese-en (Japanese with English
+# messages), Korean, Korean-en, Lithuanian, Norwegian, Macedonian, Persian,
+# Polish, Portuguese, Romanian, Russian, Serbian, Serbian-Cyrilic, Slovak,
+# Slovene, Spanish, Swedish, Ukrainian, and Vietnamese.
+
+OUTPUT_LANGUAGE = English
+
+# If the BRIEF_MEMBER_DESC tag is set to YES (the default) Doxygen will
+# include brief member descriptions after the members that are listed in
+# the file and class documentation (similar to JavaDoc).
+# Set to NO to disable this.
+
+BRIEF_MEMBER_DESC = YES
+
+# If the REPEAT_BRIEF tag is set to YES (the default) Doxygen will prepend
+# the brief description of a member or function before the detailed description.
+# Note: if both HIDE_UNDOC_MEMBERS and BRIEF_MEMBER_DESC are set to NO, the
+# brief descriptions will be completely suppressed.
+
+REPEAT_BRIEF = YES
+
+# This tag implements a quasi-intelligent brief description abbreviator
+# that is used to form the text in various listings. Each string
+# in this list, if found as the leading text of the brief description, will be
+# stripped from the text and the result after processing the whole list, is
+# used as the annotated text. Otherwise, the brief description is used as-is.
+# If left blank, the following values are used ("$name" is automatically
+# replaced with the name of the entity): "The $name class" "The $name widget"
+# "The $name file" "is" "provides" "specifies" "contains"
+# "represents" "a" "an" "the"
+
+ABBREVIATE_BRIEF =
+
+# If the ALWAYS_DETAILED_SEC and REPEAT_BRIEF tags are both set to YES then
+# Doxygen will generate a detailed section even if there is only a brief
+# description.
+
+ALWAYS_DETAILED_SEC = YES
+
+# If the INLINE_INHERITED_MEMB tag is set to YES, doxygen will show all
+# inherited members of a class in the documentation of that class as if those
+# members were ordinary class members. Constructors, destructors and assignment
+# operators of the base classes will not be shown.
+
+INLINE_INHERITED_MEMB = NO
+
+# If the FULL_PATH_NAMES tag is set to YES then Doxygen will prepend the full
+# path before files name in the file list and in the header files. If set
+# to NO the shortest path that makes the file name unique will be used.
+
+FULL_PATH_NAMES = NO
+
+# If the FULL_PATH_NAMES tag is set to YES then the STRIP_FROM_PATH tag
+# can be used to strip a user-defined part of the path. Stripping is
+# only done if one of the specified strings matches the left-hand part of
+# the path. The tag can be used to show relative paths in the file list.
+# If left blank the directory from which doxygen is run is used as the
+# path to strip.
+
+STRIP_FROM_PATH =
+
+# The STRIP_FROM_INC_PATH tag can be used to strip a user-defined part of
+# the path mentioned in the documentation of a class, which tells
+# the reader which header file to include in order to use a class.
+# If left blank only the name of the header file containing the class
+# definition is used. Otherwise one should specify the include paths that
+# are normally passed to the compiler using the -I flag.
+
+STRIP_FROM_INC_PATH =
+
+# If the SHORT_NAMES tag is set to YES, doxygen will generate much shorter
+# (but less readable) file names. This can be useful is your file systems
+# doesn't support long names like on DOS, Mac, or CD-ROM.
+
+SHORT_NAMES = NO
+
+# If the JAVADOC_AUTOBRIEF tag is set to YES then Doxygen
+# will interpret the first line (until the first dot) of a JavaDoc-style
+# comment as the brief description. If set to NO, the JavaDoc
+# comments will behave just like regular Qt-style comments
+# (thus requiring an explicit @brief command for a brief description.)
+
+JAVADOC_AUTOBRIEF = NO
+
+# If the QT_AUTOBRIEF tag is set to YES then Doxygen will
+# interpret the first line (until the first dot) of a Qt-style
+# comment as the brief description. If set to NO, the comments
+# will behave just like regular Qt-style comments (thus requiring
+# an explicit \brief command for a brief description.)
+
+QT_AUTOBRIEF = NO
+
+# The MULTILINE_CPP_IS_BRIEF tag can be set to YES to make Doxygen
+# treat a multi-line C++ special comment block (i.e. a block of //! or ///
+# comments) as a brief description. This used to be the default behaviour.
+# The new default is to treat a multi-line C++ comment block as a detailed
+# description. Set this tag to YES if you prefer the old behaviour instead.
+
+MULTILINE_CPP_IS_BRIEF = NO
+
+# If the INHERIT_DOCS tag is set to YES (the default) then an undocumented
+# member inherits the documentation from any documented member that it
+# re-implements.
+
+INHERIT_DOCS = YES
+
+# If the SEPARATE_MEMBER_PAGES tag is set to YES, then doxygen will produce
+# a new page for each member. If set to NO, the documentation of a member will
+# be part of the file/class/namespace that contains it.
+
+SEPARATE_MEMBER_PAGES = NO
+
+# The TAB_SIZE tag can be used to set the number of spaces in a tab.
+# Doxygen uses this value to replace tabs by spaces in code fragments.
+
+TAB_SIZE = 8
+
+# This tag can be used to specify a number of aliases that acts
+# as commands in the documentation. An alias has the form "name=value".
+# For example adding "sideeffect=\par Side Effects:\n" will allow you to
+# put the command \sideeffect (or @sideeffect) in the documentation, which
+# will result in a user-defined paragraph with heading "Side Effects:".
+# You can put \n's in the value part of an alias to insert newlines.
+
+ALIASES =
+
+# Set the OPTIMIZE_OUTPUT_FOR_C tag to YES if your project consists of C
+# sources only. Doxygen will then generate output that is more tailored for C.
+# For instance, some of the names that are used will be different. The list
+# of all members will be omitted, etc.
+
+OPTIMIZE_OUTPUT_FOR_C = YES
+
+# Set the OPTIMIZE_OUTPUT_JAVA tag to YES if your project consists of Java
+# sources only. Doxygen will then generate output that is more tailored for
+# Java. For instance, namespaces will be presented as packages, qualified
+# scopes will look different, etc.
+
+OPTIMIZE_OUTPUT_JAVA = NO
+
+# Set the OPTIMIZE_FOR_FORTRAN tag to YES if your project consists of Fortran
+# sources only. Doxygen will then generate output that is more tailored for
+# Fortran.
+
+OPTIMIZE_FOR_FORTRAN = NO
+
+# Set the OPTIMIZE_OUTPUT_VHDL tag to YES if your project consists of VHDL
+# sources. Doxygen will then generate output that is tailored for
+# VHDL.
+
+OPTIMIZE_OUTPUT_VHDL = NO
+
+# Doxygen selects the parser to use depending on the extension of the files it parses.
+# With this tag you can assign which parser to use for a given extension.
+# Doxygen has a built-in mapping, but you can override or extend it using this tag.
+# The format is ext=language, where ext is a file extension, and language is one of
+# the parsers supported by doxygen: IDL, Java, Javascript, C#, C, C++, D, PHP,
+# Objective-C, Python, Fortran, VHDL, C, C++. For instance to make doxygen treat
+# .inc files as Fortran files (default is PHP), and .f files as C (default is Fortran),
+# use: inc=Fortran f=C. Note that for custom extensions you also need to set FILE_PATTERNS otherwise the files are not read by doxygen.
+
+EXTENSION_MAPPING =
+
+# If you use STL classes (i.e. std::string, std::vector, etc.) but do not want
+# to include (a tag file for) the STL sources as input, then you should
+# set this tag to YES in order to let doxygen match functions declarations and
+# definitions whose arguments contain STL classes (e.g. func(std::string); v.s.
+# func(std::string) {}). This also make the inheritance and collaboration
+# diagrams that involve STL classes more complete and accurate.
+
+BUILTIN_STL_SUPPORT = NO
+
+# If you use Microsoft's C++/CLI language, you should set this option to YES to
+# enable parsing support.
+
+CPP_CLI_SUPPORT = NO
+
+# Set the SIP_SUPPORT tag to YES if your project consists of sip sources only.
+# Doxygen will parse them like normal C++ but will assume all classes use public
+# instead of private inheritance when no explicit protection keyword is present.
+
+SIP_SUPPORT = NO
+
+# For Microsoft's IDL there are propget and propput attributes to indicate getter
+# and setter methods for a property. Setting this option to YES (the default)
+# will make doxygen to replace the get and set methods by a property in the
+# documentation. This will only work if the methods are indeed getting or
+# setting a simple type. If this is not the case, or you want to show the
+# methods anyway, you should set this option to NO.
+
+IDL_PROPERTY_SUPPORT = YES
+
+# If member grouping is used in the documentation and the DISTRIBUTE_GROUP_DOC
+# tag is set to YES, then doxygen will reuse the documentation of the first
+# member in the group (if any) for the other members of the group. By default
+# all members of a group must be documented explicitly.
+
+DISTRIBUTE_GROUP_DOC = NO
+
+# Set the SUBGROUPING tag to YES (the default) to allow class member groups of
+# the same type (for instance a group of public functions) to be put as a
+# subgroup of that type (e.g. under the Public Functions section). Set it to
+# NO to prevent subgrouping. Alternatively, this can be done per class using
+# the \nosubgrouping command.
+
+SUBGROUPING = YES
+
+# When TYPEDEF_HIDES_STRUCT is enabled, a typedef of a struct, union, or enum
+# is documented as struct, union, or enum with the name of the typedef. So
+# typedef struct TypeS {} TypeT, will appear in the documentation as a struct
+# with name TypeT. When disabled the typedef will appear as a member of a file,
+# namespace, or class. And the struct will be named TypeS. This can typically
+# be useful for C code in case the coding convention dictates that all compound
+# types are typedef'ed and only the typedef is referenced, never the tag name.
+
+TYPEDEF_HIDES_STRUCT = NO
+
+# The SYMBOL_CACHE_SIZE determines the size of the internal cache use to
+# determine which symbols to keep in memory and which to flush to disk.
+# When the cache is full, less often used symbols will be written to disk.
+# For small to medium size projects (<1000 input files) the default value is
+# probably good enough. For larger projects a too small cache size can cause
+# doxygen to be busy swapping symbols to and from disk most of the time
+# causing a significant performance penality.
+# If the system has enough physical memory increasing the cache will improve the
+# performance by keeping more symbols in memory. Note that the value works on
+# a logarithmic scale so increasing the size by one will rougly double the
+# memory usage. The cache size is given by this formula:
+# 2^(16+SYMBOL_CACHE_SIZE). The valid range is 0..9, the default is 0,
+# corresponding to a cache size of 2^16 = 65536 symbols
+
+SYMBOL_CACHE_SIZE = 0
+
+#---------------------------------------------------------------------------
+# Build related configuration options
+#---------------------------------------------------------------------------
+
+# If the EXTRACT_ALL tag is set to YES doxygen will assume all entities in
+# documentation are documented, even if no documentation was available.
+# Private class members and static file members will be hidden unless
+# the EXTRACT_PRIVATE and EXTRACT_STATIC tags are set to YES
+
+EXTRACT_ALL = YES
+
+# If the EXTRACT_PRIVATE tag is set to YES all private members of a class
+# will be included in the documentation.
+
+EXTRACT_PRIVATE = NO
+
+# If the EXTRACT_STATIC tag is set to YES all static members of a file
+# will be included in the documentation.
+
+EXTRACT_STATIC = YES
+
+# If the EXTRACT_LOCAL_CLASSES tag is set to YES classes (and structs)
+# defined locally in source files will be included in the documentation.
+# If set to NO only classes defined in header files are included.
+
+EXTRACT_LOCAL_CLASSES = YES
+
+# This flag is only useful for Objective-C code. When set to YES local
+# methods, which are defined in the implementation section but not in
+# the interface are included in the documentation.
+# If set to NO (the default) only methods in the interface are included.
+
+EXTRACT_LOCAL_METHODS = NO
+
+# If this flag is set to YES, the members of anonymous namespaces will be
+# extracted and appear in the documentation as a namespace called
+# 'anonymous_namespace{file}', where file will be replaced with the base
+# name of the file that contains the anonymous namespace. By default
+# anonymous namespace are hidden.
+
+EXTRACT_ANON_NSPACES = NO
+
+# If the HIDE_UNDOC_MEMBERS tag is set to YES, Doxygen will hide all
+# undocumented members of documented classes, files or namespaces.
+# If set to NO (the default) these members will be included in the
+# various overviews, but no documentation section is generated.
+# This option has no effect if EXTRACT_ALL is enabled.
+
+HIDE_UNDOC_MEMBERS = YES
+
+# If the HIDE_UNDOC_CLASSES tag is set to YES, Doxygen will hide all
+# undocumented classes that are normally visible in the class hierarchy.
+# If set to NO (the default) these classes will be included in the various
+# overviews. This option has no effect if EXTRACT_ALL is enabled.
+
+HIDE_UNDOC_CLASSES = NO
+
+# If the HIDE_FRIEND_COMPOUNDS tag is set to YES, Doxygen will hide all
+# friend (class|struct|union) declarations.
+# If set to NO (the default) these declarations will be included in the
+# documentation.
+
+HIDE_FRIEND_COMPOUNDS = NO
+
+# If the HIDE_IN_BODY_DOCS tag is set to YES, Doxygen will hide any
+# documentation blocks found inside the body of a function.
+# If set to NO (the default) these blocks will be appended to the
+# function's detailed documentation block.
+
+HIDE_IN_BODY_DOCS = NO
+
+# The INTERNAL_DOCS tag determines if documentation
+# that is typed after a \internal command is included. If the tag is set
+# to NO (the default) then the documentation will be excluded.
+# Set it to YES to include the internal documentation.
+
+INTERNAL_DOCS = NO
+
+# If the CASE_SENSE_NAMES tag is set to NO then Doxygen will only generate
+# file names in lower-case letters. If set to YES upper-case letters are also
+# allowed. This is useful if you have classes or files whose names only differ
+# in case and if your file system supports case sensitive file names. Windows
+# and Mac users are advised to set this option to NO.
+
+CASE_SENSE_NAMES = YES
+
+# If the HIDE_SCOPE_NAMES tag is set to NO (the default) then Doxygen
+# will show members with their full class and namespace scopes in the
+# documentation. If set to YES the scope will be hidden.
+
+HIDE_SCOPE_NAMES = NO
+
+# If the SHOW_INCLUDE_FILES tag is set to YES (the default) then Doxygen
+# will put a list of the files that are included by a file in the documentation
+# of that file.
+
+SHOW_INCLUDE_FILES = YES
+
+# If the FORCE_LOCAL_INCLUDES tag is set to YES then Doxygen
+# will list include files with double quotes in the documentation
+# rather than with sharp brackets.
+
+FORCE_LOCAL_INCLUDES = NO
+
+# If the INLINE_INFO tag is set to YES (the default) then a tag [inline]
+# is inserted in the documentation for inline members.
+
+INLINE_INFO = YES
+
+# If the SORT_MEMBER_DOCS tag is set to YES (the default) then doxygen
+# will sort the (detailed) documentation of file and class members
+# alphabetically by member name. If set to NO the members will appear in
+# declaration order.
+
+SORT_MEMBER_DOCS = YES
+
+# If the SORT_BRIEF_DOCS tag is set to YES then doxygen will sort the
+# brief documentation of file, namespace and class members alphabetically
+# by member name. If set to NO (the default) the members will appear in
+# declaration order.
+
+SORT_BRIEF_DOCS = NO
+
+# If the SORT_MEMBERS_CTORS_1ST tag is set to YES then doxygen will sort the (brief and detailed) documentation of class members so that constructors and destructors are listed first. If set to NO (the default) the constructors will appear in the respective orders defined by SORT_MEMBER_DOCS and SORT_BRIEF_DOCS. This tag will be ignored for brief docs if SORT_BRIEF_DOCS is set to NO and ignored for detailed docs if SORT_MEMBER_DOCS is set to NO.
+
+SORT_MEMBERS_CTORS_1ST = NO
+
+# If the SORT_GROUP_NAMES tag is set to YES then doxygen will sort the
+# hierarchy of group names into alphabetical order. If set to NO (the default)
+# the group names will appear in their defined order.
+
+SORT_GROUP_NAMES = NO
+
+# If the SORT_BY_SCOPE_NAME tag is set to YES, the class list will be
+# sorted by fully-qualified names, including namespaces. If set to
+# NO (the default), the class list will be sorted only by class name,
+# not including the namespace part.
+# Note: This option is not very useful if HIDE_SCOPE_NAMES is set to YES.
+# Note: This option applies only to the class list, not to the
+# alphabetical list.
+
+SORT_BY_SCOPE_NAME = NO
+
+# The GENERATE_TODOLIST tag can be used to enable (YES) or
+# disable (NO) the todo list. This list is created by putting \todo
+# commands in the documentation.
+
+GENERATE_TODOLIST = YES
+
+# The GENERATE_TESTLIST tag can be used to enable (YES) or
+# disable (NO) the test list. This list is created by putting \test
+# commands in the documentation.
+
+GENERATE_TESTLIST = YES
+
+# The GENERATE_BUGLIST tag can be used to enable (YES) or
+# disable (NO) the bug list. This list is created by putting \bug
+# commands in the documentation.
+
+GENERATE_BUGLIST = YES
+
+# The GENERATE_DEPRECATEDLIST tag can be used to enable (YES) or
+# disable (NO) the deprecated list. This list is created by putting
+# \deprecated commands in the documentation.
+
+GENERATE_DEPRECATEDLIST= YES
+
+# The ENABLED_SECTIONS tag can be used to enable conditional
+# documentation sections, marked by \if sectionname ... \endif.
+
+ENABLED_SECTIONS =
+
+# The MAX_INITIALIZER_LINES tag determines the maximum number of lines
+# the initial value of a variable or define consists of for it to appear in
+# the documentation. If the initializer consists of more lines than specified
+# here it will be hidden. Use a value of 0 to hide initializers completely.
+# The appearance of the initializer of individual variables and defines in the
+# documentation can be controlled using \showinitializer or \hideinitializer
+# command in the documentation regardless of this setting.
+
+MAX_INITIALIZER_LINES = 30
+
+# Set the SHOW_USED_FILES tag to NO to disable the list of files generated
+# at the bottom of the documentation of classes and structs. If set to YES the
+# list will mention the files that were used to generate the documentation.
+
+SHOW_USED_FILES = YES
+
+# If the sources in your project are distributed over multiple directories
+# then setting the SHOW_DIRECTORIES tag to YES will show the directory hierarchy
+# in the documentation. The default is NO.
+
+SHOW_DIRECTORIES = NO
+
+# Set the SHOW_FILES tag to NO to disable the generation of the Files page.
+# This will remove the Files entry from the Quick Index and from the
+# Folder Tree View (if specified). The default is YES.
+
+SHOW_FILES = YES
+
+# Set the SHOW_NAMESPACES tag to NO to disable the generation of the
+# Namespaces page.
+# This will remove the Namespaces entry from the Quick Index
+# and from the Folder Tree View (if specified). The default is YES.
+
+SHOW_NAMESPACES = YES
+
+# The FILE_VERSION_FILTER tag can be used to specify a program or script that
+# doxygen should invoke to get the current version for each file (typically from
+# the version control system). Doxygen will invoke the program by executing (via
+# popen()) the command <command> <input-file>, where <command> is the value of
+# the FILE_VERSION_FILTER tag, and <input-file> is the name of an input file
+# provided by doxygen. Whatever the program writes to standard output
+# is used as the file version. See the manual for examples.
+
+FILE_VERSION_FILTER =
+
+# The LAYOUT_FILE tag can be used to specify a layout file which will be parsed by
+# doxygen. The layout file controls the global structure of the generated output files
+# in an output format independent way. The create the layout file that represents
+# doxygen's defaults, run doxygen with the -l option. You can optionally specify a
+# file name after the option, if omitted DoxygenLayout.xml will be used as the name
+# of the layout file.
+
+LAYOUT_FILE =
+
+#---------------------------------------------------------------------------
+# configuration options related to warning and progress messages
+#---------------------------------------------------------------------------
+
+# The QUIET tag can be used to turn on/off the messages that are generated
+# by doxygen. Possible values are YES and NO. If left blank NO is used.
+
+QUIET = YES
+
+# The WARNINGS tag can be used to turn on/off the warning messages that are
+# generated by doxygen. Possible values are YES and NO. If left blank
+# NO is used.
+
+WARNINGS = YES
+
+# If WARN_IF_UNDOCUMENTED is set to YES, then doxygen will generate warnings
+# for undocumented members. If EXTRACT_ALL is set to YES then this flag will
+# automatically be disabled.
+
+WARN_IF_UNDOCUMENTED = YES
+
+# If WARN_IF_DOC_ERROR is set to YES, doxygen will generate warnings for
+# potential errors in the documentation, such as not documenting some
+# parameters in a documented function, or documenting parameters that
+# don't exist or using markup commands wrongly.
+
+WARN_IF_DOC_ERROR = YES
+
+# This WARN_NO_PARAMDOC option can be abled to get warnings for
+# functions that are documented, but have no documentation for their parameters
+# or return value. If set to NO (the default) doxygen will only warn about
+# wrong or incomplete parameter documentation, but not about the absence of
+# documentation.
+
+WARN_NO_PARAMDOC = NO
+
+# The WARN_FORMAT tag determines the format of the warning messages that
+# doxygen can produce. The string should contain the $file, $line, and $text
+# tags, which will be replaced by the file and line number from which the
+# warning originated and the warning text. Optionally the format may contain
+# $version, which will be replaced by the version of the file (if it could
+# be obtained via FILE_VERSION_FILTER)
+
+WARN_FORMAT = "$file:$line: $text"
+
+# The WARN_LOGFILE tag can be used to specify a file to which warning
+# and error messages should be written. If left blank the output is written
+# to stderr.
+
+WARN_LOGFILE =
+
+#---------------------------------------------------------------------------
+# configuration options related to the input files
+#---------------------------------------------------------------------------
+
+# The INPUT tag can be used to specify the files and/or directories that contain
+# documented source files. You may enter file names like "myfile.cpp" or
+# directories like "/usr/src/myproject". Separate the files or directories
+# with spaces.
+
+INPUT = @srcdir@/.. \
+ @srcdir@/../input \
+ @srcdir@/../config
+
+# This tag can be used to specify the character encoding of the source files
+# that doxygen parses. Internally doxygen uses the UTF-8 encoding, which is
+# also the default input encoding. Doxygen uses libiconv (or the iconv built
+# into libc) for the transcoding. See http://www.gnu.org/software/libiconv for
+# the list of possible encodings.
+
+INPUT_ENCODING = UTF-8
+
+# If the value of the INPUT tag contains directories, you can use the
+# FILE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp
+# and *.h) to filter out the source-files in the directories. If left
+# blank the following patterns are tested:
+# *.c *.cc *.cxx *.cpp *.c++ *.java *.ii *.ixx *.ipp *.i++ *.inl *.h *.hh *.hxx
+# *.hpp *.h++ *.idl *.odl *.cs *.php *.php3 *.inc *.m *.mm *.py *.f90
+
+FILE_PATTERNS =
+
+# The RECURSIVE tag can be used to turn specify whether or not subdirectories
+# should be searched for input files as well. Possible values are YES and NO.
+# If left blank NO is used.
+
+RECURSIVE = NO
+
+# The EXCLUDE tag can be used to specify files and/or directories that should
+# excluded from the INPUT source files. This way you can easily exclude a
+# subdirectory from a directory tree whose root is specified with the INPUT tag.
+
+EXCLUDE = @srcdir@/../config/parser.c \
+ @srcdir@/../config/parser.h \
+ @srcdir@/../config/scanner.c
+
+# The EXCLUDE_SYMLINKS tag can be used select whether or not files or
+# directories that are symbolic links (a Unix filesystem feature) are excluded
+# from the input.
+
+EXCLUDE_SYMLINKS = YES
+
+# If the value of the INPUT tag contains directories, you can use the
+# EXCLUDE_PATTERNS tag to specify one or more wildcard patterns to exclude
+# certain files from those directories. Note that the wildcards are matched
+# against the file with absolute path, so to exclude all test directories
+# for example use the pattern */test/*
+
+EXCLUDE_PATTERNS = atKeynames.h \
+ Canvas*.*
+
+# The EXCLUDE_SYMBOLS tag can be used to specify one or more symbol names
+# (namespaces, classes, functions, etc.) that should be excluded from the
+# output. The symbol name can be a fully qualified name, a word, or if the
+# wildcard * is used, a substring. Examples: ANamespace, AClass,
+# AClass::ANamespace, ANamespace::*Test
+
+EXCLUDE_SYMBOLS =
+
+# The EXAMPLE_PATH tag can be used to specify one or more files or
+# directories that contain example code fragments that are included (see
+# the \include command).
+
+EXAMPLE_PATH =
+
+# If the value of the EXAMPLE_PATH tag contains directories, you can use the
+# EXAMPLE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp
+# and *.h) to filter out the source-files in the directories. If left
+# blank all files are included.
+
+EXAMPLE_PATTERNS =
+
+# If the EXAMPLE_RECURSIVE tag is set to YES then subdirectories will be
+# searched for input files to be used with the \include or \dontinclude
+# commands irrespective of the value of the RECURSIVE tag.
+# Possible values are YES and NO. If left blank NO is used.
+
+EXAMPLE_RECURSIVE = NO
+
+# The IMAGE_PATH tag can be used to specify one or more files or
+# directories that contain image that are included in the documentation (see
+# the \image command).
+
+IMAGE_PATH =
+
+# The INPUT_FILTER tag can be used to specify a program that doxygen should
+# invoke to filter for each input file. Doxygen will invoke the filter program
+# by executing (via popen()) the command <filter> <input-file>, where <filter>
+# is the value of the INPUT_FILTER tag, and <input-file> is the name of an
+# input file. Doxygen will then use the output that the filter program writes
+# to standard output.
+# If FILTER_PATTERNS is specified, this tag will be
+# ignored.
+
+INPUT_FILTER =
+
+# The FILTER_PATTERNS tag can be used to specify filters on a per file pattern
+# basis.
+# Doxygen will compare the file name with each pattern and apply the
+# filter if there is a match.
+# The filters are a list of the form:
+# pattern=filter (like *.cpp=my_cpp_filter). See INPUT_FILTER for further
+# info on how filters are used. If FILTER_PATTERNS is empty, INPUT_FILTER
+# is applied to all files.
+
+FILTER_PATTERNS =
+
+# If the FILTER_SOURCE_FILES tag is set to YES, the input filter (if set using
+# INPUT_FILTER) will be used to filter the input files when producing source
+# files to browse (i.e. when SOURCE_BROWSER is set to YES).
+
+FILTER_SOURCE_FILES = NO
+
+#---------------------------------------------------------------------------
+# configuration options related to source browsing
+#---------------------------------------------------------------------------
+
+# If the SOURCE_BROWSER tag is set to YES then a list of source files will
+# be generated. Documented entities will be cross-referenced with these sources.
+# Note: To get rid of all source code in the generated output, make sure also
+# VERBATIM_HEADERS is set to NO.
+
+SOURCE_BROWSER = NO
+
+# Setting the INLINE_SOURCES tag to YES will include the body
+# of functions and classes directly in the documentation.
+
+INLINE_SOURCES = NO
+
+# Setting the STRIP_CODE_COMMENTS tag to YES (the default) will instruct
+# doxygen to hide any special comment blocks from generated source code
+# fragments. Normal C and C++ comments will always remain visible.
+
+STRIP_CODE_COMMENTS = YES
+
+# If the REFERENCED_BY_RELATION tag is set to YES
+# then for each documented function all documented
+# functions referencing it will be listed.
+
+REFERENCED_BY_RELATION = YES
+
+# If the REFERENCES_RELATION tag is set to YES
+# then for each documented function all documented entities
+# called/used by that function will be listed.
+
+REFERENCES_RELATION = YES
+
+# If the REFERENCES_LINK_SOURCE tag is set to YES (the default)
+# and SOURCE_BROWSER tag is set to YES, then the hyperlinks from
+# functions in REFERENCES_RELATION and REFERENCED_BY_RELATION lists will
+# link to the source code.
+# Otherwise they will link to the documentation.
+
+REFERENCES_LINK_SOURCE = YES
+
+# If the USE_HTAGS tag is set to YES then the references to source code
+# will point to the HTML generated by the htags(1) tool instead of doxygen
+# built-in source browser. The htags tool is part of GNU's global source
+# tagging system (see http://www.gnu.org/software/global/global.html). You
+# will need version 4.8.6 or higher.
+
+USE_HTAGS = NO
+
+# If the VERBATIM_HEADERS tag is set to YES (the default) then Doxygen
+# will generate a verbatim copy of the header file for each class for
+# which an include is specified. Set to NO to disable this.
+
+VERBATIM_HEADERS = YES
+
+#---------------------------------------------------------------------------
+# configuration options related to the alphabetical class index
+#---------------------------------------------------------------------------
+
+# If the ALPHABETICAL_INDEX tag is set to YES, an alphabetical index
+# of all compounds will be generated. Enable this if the project
+# contains a lot of classes, structs, unions or interfaces.
+
+ALPHABETICAL_INDEX = YES
+
+# If the alphabetical index is enabled (see ALPHABETICAL_INDEX) then
+# the COLS_IN_ALPHA_INDEX tag can be used to specify the number of columns
+# in which this list will be split (can be a number in the range [1..20])
+
+COLS_IN_ALPHA_INDEX = 5
+
+# In case all classes in a project start with a common prefix, all
+# classes will be put under the same header in the alphabetical index.
+# The IGNORE_PREFIX tag can be used to specify one or more prefixes that
+# should be ignored while generating the index headers.
+
+IGNORE_PREFIX =
+
+#---------------------------------------------------------------------------
+# configuration options related to the HTML output
+#---------------------------------------------------------------------------
+
+# If the GENERATE_HTML tag is set to YES (the default) Doxygen will
+# generate HTML output.
+
+GENERATE_HTML = YES
+
+# The HTML_OUTPUT tag is used to specify where the HTML docs will be put.
+# If a relative path is entered the value of OUTPUT_DIRECTORY will be
+# put in front of it. If left blank `html' will be used as the default path.
+
+HTML_OUTPUT = html
+
+# The HTML_FILE_EXTENSION tag can be used to specify the file extension for
+# each generated HTML page (for example: .htm,.php,.asp). If it is left blank
+# doxygen will generate files with .html extension.
+
+HTML_FILE_EXTENSION = .html
+
+# The HTML_HEADER tag can be used to specify a personal HTML header for
+# each generated HTML page. If it is left blank doxygen will generate a
+# standard header.
+
+HTML_HEADER =
+
+# The HTML_FOOTER tag can be used to specify a personal HTML footer for
+# each generated HTML page. If it is left blank doxygen will generate a
+# standard footer.
+
+HTML_FOOTER = @srcdir@/footer.html
+
+# The HTML_STYLESHEET tag can be used to specify a user-defined cascading
+# style sheet that is used by each HTML page. It can be used to
+# fine-tune the look of the HTML output. If the tag is left blank doxygen
+# will generate a default style sheet. Note that doxygen will try to copy
+# the style sheet file to the HTML output directory, so don't put your own
+# stylesheet in the HTML output directory as well, or it will be erased!
+
+HTML_STYLESHEET =
+
+# If the HTML_TIMESTAMP tag is set to YES then the footer of each generated HTML
+# page will contain the date and time when the page was generated. Setting
+# this to NO can help when comparing the output of multiple runs.
+
+HTML_TIMESTAMP = NO
+
+# If the HTML_ALIGN_MEMBERS tag is set to YES, the members of classes,
+# files or namespaces will be aligned in HTML using tables. If set to
+# NO a bullet list will be used.
+
+HTML_ALIGN_MEMBERS = YES
+
+# If the HTML_DYNAMIC_SECTIONS tag is set to YES then the generated HTML
+# documentation will contain sections that can be hidden and shown after the
+# page has loaded. For this to work a browser that supports
+# JavaScript and DHTML is required (for instance Mozilla 1.0+, Firefox
+# Netscape 6.0+, Internet explorer 5.0+, Konqueror, or Safari).
+
+HTML_DYNAMIC_SECTIONS = NO
+
+# If the GENERATE_DOCSET tag is set to YES, additional index files
+# will be generated that can be used as input for Apple's Xcode 3
+# integrated development environment, introduced with OSX 10.5 (Leopard).
+# To create a documentation set, doxygen will generate a Makefile in the
+# HTML output directory. Running make will produce the docset in that
+# directory and running "make install" will install the docset in
+# ~/Library/Developer/Shared/Documentation/DocSets so that Xcode will find
+# it at startup.
+# See http://developer.apple.com/tools/creatingdocsetswithdoxygen.html for more information.
+
+GENERATE_DOCSET = NO
+
+# When GENERATE_DOCSET tag is set to YES, this tag determines the name of the
+# feed. A documentation feed provides an umbrella under which multiple
+# documentation sets from a single provider (such as a company or product suite)
+# can be grouped.
+
+DOCSET_FEEDNAME = "Doxygen generated docs"
+
+# When GENERATE_DOCSET tag is set to YES, this tag specifies a string that
+# should uniquely identify the documentation set bundle. This should be a
+# reverse domain-name style string, e.g. com.mycompany.MyDocSet. Doxygen
+# will append .docset to the name.
+
+DOCSET_BUNDLE_ID = org.doxygen.Project
+
+# If the GENERATE_HTMLHELP tag is set to YES, additional index files
+# will be generated that can be used as input for tools like the
+# Microsoft HTML help workshop to generate a compiled HTML help file (.chm)
+# of the generated HTML documentation.
+
+GENERATE_HTMLHELP = NO
+
+# If the GENERATE_HTMLHELP tag is set to YES, the CHM_FILE tag can
+# be used to specify the file name of the resulting .chm file. You
+# can add a path in front of the file if the result should not be
+# written to the html output directory.
+
+CHM_FILE =
+
+# If the GENERATE_HTMLHELP tag is set to YES, the HHC_LOCATION tag can
+# be used to specify the location (absolute path including file name) of
+# the HTML help compiler (hhc.exe). If non-empty doxygen will try to run
+# the HTML help compiler on the generated index.hhp.
+
+HHC_LOCATION =
+
+# If the GENERATE_HTMLHELP tag is set to YES, the GENERATE_CHI flag
+# controls if a separate .chi index file is generated (YES) or that
+# it should be included in the master .chm file (NO).
+
+GENERATE_CHI = NO
+
+# If the GENERATE_HTMLHELP tag is set to YES, the CHM_INDEX_ENCODING
+# is used to encode HtmlHelp index (hhk), content (hhc) and project file
+# content.
+
+CHM_INDEX_ENCODING =
+
+# If the GENERATE_HTMLHELP tag is set to YES, the BINARY_TOC flag
+# controls whether a binary table of contents is generated (YES) or a
+# normal table of contents (NO) in the .chm file.
+
+BINARY_TOC = NO
+
+# The TOC_EXPAND flag can be set to YES to add extra items for group members
+# to the contents of the HTML help documentation and to the tree view.
+
+TOC_EXPAND = NO
+
+# If the GENERATE_QHP tag is set to YES and both QHP_NAMESPACE and QHP_VIRTUAL_FOLDER
+# are set, an additional index file will be generated that can be used as input for
+# Qt's qhelpgenerator to generate a Qt Compressed Help (.qch) of the generated
+# HTML documentation.
+
+GENERATE_QHP = NO
+
+# If the QHG_LOCATION tag is specified, the QCH_FILE tag can
+# be used to specify the file name of the resulting .qch file.
+# The path specified is relative to the HTML output folder.
+
+QCH_FILE =
+
+# The QHP_NAMESPACE tag specifies the namespace to use when generating
+# Qt Help Project output. For more information please see
+# http://doc.trolltech.com/qthelpproject.html#namespace
+
+QHP_NAMESPACE = org.doxygen.Project
+
+# The QHP_VIRTUAL_FOLDER tag specifies the namespace to use when generating
+# Qt Help Project output. For more information please see
+# http://doc.trolltech.com/qthelpproject.html#virtual-folders
+
+QHP_VIRTUAL_FOLDER = doc
+
+# If QHP_CUST_FILTER_NAME is set, it specifies the name of a custom filter to add.
+# For more information please see
+# http://doc.trolltech.com/qthelpproject.html#custom-filters
+
+QHP_CUST_FILTER_NAME =
+
+# The QHP_CUST_FILT_ATTRS tag specifies the list of the attributes of the custom filter to add.For more information please see
+# <a href="http://doc.trolltech.com/qthelpproject.html#custom-filters">Qt Help Project / Custom Filters</a>.
+
+QHP_CUST_FILTER_ATTRS =
+
+# The QHP_SECT_FILTER_ATTRS tag specifies the list of the attributes this project's
+# filter section matches.
+# <a href="http://doc.trolltech.com/qthelpproject.html#filter-attributes">Qt Help Project / Filter Attributes</a>.
+
+QHP_SECT_FILTER_ATTRS =
+
+# If the GENERATE_QHP tag is set to YES, the QHG_LOCATION tag can
+# be used to specify the location of Qt's qhelpgenerator.
+# If non-empty doxygen will try to run qhelpgenerator on the generated
+# .qhp file.
+
+QHG_LOCATION =
+
+# If the GENERATE_ECLIPSEHELP tag is set to YES, additional index files
+# will be generated, which together with the HTML files, form an Eclipse help
+# plugin. To install this plugin and make it available under the help contents
+# menu in Eclipse, the contents of the directory containing the HTML and XML
+# files needs to be copied into the plugins directory of eclipse. The name of
+# the directory within the plugins directory should be the same as
+# the ECLIPSE_DOC_ID value. After copying Eclipse needs to be restarted before the help appears.
+
+GENERATE_ECLIPSEHELP = NO
+
+# A unique identifier for the eclipse help plugin. When installing the plugin
+# the directory name containing the HTML and XML files should also have
+# this name.
+
+ECLIPSE_DOC_ID = org.doxygen.Project
+
+# The DISABLE_INDEX tag can be used to turn on/off the condensed index at
+# top of each HTML page. The value NO (the default) enables the index and
+# the value YES disables it.
+
+DISABLE_INDEX = NO
+
+# This tag can be used to set the number of enum values (range [1..20])
+# that doxygen will group on one line in the generated HTML documentation.
+
+ENUM_VALUES_PER_LINE = 4
+
+# The GENERATE_TREEVIEW tag is used to specify whether a tree-like index
+# structure should be generated to display hierarchical information.
+# If the tag value is set to YES, a side panel will be generated
+# containing a tree-like index structure (just like the one that
+# is generated for HTML Help). For this to work a browser that supports
+# JavaScript, DHTML, CSS and frames is required (i.e. any modern browser).
+# Windows users are probably better off using the HTML help feature.
+
+GENERATE_TREEVIEW = YES
+
+# By enabling USE_INLINE_TREES, doxygen will generate the Groups, Directories,
+# and Class Hierarchy pages using a tree view instead of an ordered list.
+
+USE_INLINE_TREES = NO
+
+# If the treeview is enabled (see GENERATE_TREEVIEW) then this tag can be
+# used to set the initial width (in pixels) of the frame in which the tree
+# is shown.
+
+TREEVIEW_WIDTH = 250
+
+# Use this tag to change the font size of Latex formulas included
+# as images in the HTML documentation. The default is 10. Note that
+# when you change the font size after a successful doxygen run you need
+# to manually remove any form_*.png images from the HTML output directory
+# to force them to be regenerated.
+
+FORMULA_FONTSIZE = 10
+
+# When the SEARCHENGINE tag is enabled doxygen will generate a search box for the HTML output. The underlying search engine uses javascript
+# and DHTML and should work on any modern browser. Note that when using HTML help (GENERATE_HTMLHELP), Qt help (GENERATE_QHP), or docsets (GENERATE_DOCSET) there is already a search function so this one should
+# typically be disabled. For large projects the javascript based search engine
+# can be slow, then enabling SERVER_BASED_SEARCH may provide a better solution.
+
+SEARCHENGINE = NO
+
+# When the SERVER_BASED_SEARCH tag is enabled the search engine will be implemented using a PHP enabled web server instead of at the web client using Javascript. Doxygen will generate the search PHP script and index
+# file to put on the web server. The advantage of the server based approach is that it scales better to large projects and allows full text search. The disadvances is that it is more difficult to setup
+# and does not have live searching capabilities.
+
+SERVER_BASED_SEARCH = NO
+
+#---------------------------------------------------------------------------
+# configuration options related to the LaTeX output
+#---------------------------------------------------------------------------
+
+# If the GENERATE_LATEX tag is set to YES (the default) Doxygen will
+# generate Latex output.
+
+GENERATE_LATEX = NO
+
+# The LATEX_OUTPUT tag is used to specify where the LaTeX docs will be put.
+# If a relative path is entered the value of OUTPUT_DIRECTORY will be
+# put in front of it. If left blank `latex' will be used as the default path.
+
+LATEX_OUTPUT = latex
+
+# The LATEX_CMD_NAME tag can be used to specify the LaTeX command name to be
+# invoked. If left blank `latex' will be used as the default command name.
+# Note that when enabling USE_PDFLATEX this option is only used for
+# generating bitmaps for formulas in the HTML output, but not in the
+# Makefile that is written to the output directory.
+
+LATEX_CMD_NAME = latex
+
+# The MAKEINDEX_CMD_NAME tag can be used to specify the command name to
+# generate index for LaTeX. If left blank `makeindex' will be used as the
+# default command name.
+
+MAKEINDEX_CMD_NAME = makeindex
+
+# If the COMPACT_LATEX tag is set to YES Doxygen generates more compact
+# LaTeX documents. This may be useful for small projects and may help to
+# save some trees in general.
+
+COMPACT_LATEX = NO
+
+# The PAPER_TYPE tag can be used to set the paper type that is used
+# by the printer. Possible values are: a4, a4wide, letter, legal and
+# executive. If left blank a4wide will be used.
+
+PAPER_TYPE = a4wide
+
+# The EXTRA_PACKAGES tag can be to specify one or more names of LaTeX
+# packages that should be included in the LaTeX output.
+
+EXTRA_PACKAGES =
+
+# The LATEX_HEADER tag can be used to specify a personal LaTeX header for
+# the generated latex document. The header should contain everything until
+# the first chapter. If it is left blank doxygen will generate a
+# standard header. Notice: only use this tag if you know what you are doing!
+
+LATEX_HEADER =
+
+# If the PDF_HYPERLINKS tag is set to YES, the LaTeX that is generated
+# is prepared for conversion to pdf (using ps2pdf). The pdf file will
+# contain links (just like the HTML output) instead of page references
+# This makes the output suitable for online browsing using a pdf viewer.
+
+PDF_HYPERLINKS = NO
+
+# If the USE_PDFLATEX tag is set to YES, pdflatex will be used instead of
+# plain latex in the generated Makefile. Set this option to YES to get a
+# higher quality PDF documentation.
+
+USE_PDFLATEX = NO
+
+# If the LATEX_BATCHMODE tag is set to YES, doxygen will add the \\batchmode.
+# command to the generated LaTeX files. This will instruct LaTeX to keep
+# running if errors occur, instead of asking the user for help.
+# This option is also used when generating formulas in HTML.
+
+LATEX_BATCHMODE = NO
+
+# If LATEX_HIDE_INDICES is set to YES then doxygen will not
+# include the index chapters (such as File Index, Compound Index, etc.)
+# in the output.
+
+LATEX_HIDE_INDICES = NO
+
+# If LATEX_SOURCE_CODE is set to YES then doxygen will include source code with syntax highlighting in the LaTeX output. Note that which sources are shown also depends on other settings such as SOURCE_BROWSER.
+
+LATEX_SOURCE_CODE = NO
+
+#---------------------------------------------------------------------------
+# configuration options related to the RTF output
+#---------------------------------------------------------------------------
+
+# If the GENERATE_RTF tag is set to YES Doxygen will generate RTF output
+# The RTF output is optimized for Word 97 and may not look very pretty with
+# other RTF readers or editors.
+
+GENERATE_RTF = NO
+
+# The RTF_OUTPUT tag is used to specify where the RTF docs will be put.
+# If a relative path is entered the value of OUTPUT_DIRECTORY will be
+# put in front of it. If left blank `rtf' will be used as the default path.
+
+RTF_OUTPUT = rtf
+
+# If the COMPACT_RTF tag is set to YES Doxygen generates more compact
+# RTF documents. This may be useful for small projects and may help to
+# save some trees in general.
+
+COMPACT_RTF = NO
+
+# If the RTF_HYPERLINKS tag is set to YES, the RTF that is generated
+# will contain hyperlink fields. The RTF file will
+# contain links (just like the HTML output) instead of page references.
+# This makes the output suitable for online browsing using WORD or other
+# programs which support those fields.
+# Note: wordpad (write) and others do not support links.
+
+RTF_HYPERLINKS = NO
+
+# Load stylesheet definitions from file. Syntax is similar to doxygen's
+# config file, i.e. a series of assignments. You only have to provide
+# replacements, missing definitions are set to their default value.
+
+RTF_STYLESHEET_FILE =
+
+# Set optional variables used in the generation of an rtf document.
+# Syntax is similar to doxygen's config file.
+
+RTF_EXTENSIONS_FILE =
+
+#---------------------------------------------------------------------------
+# configuration options related to the man page output
+#---------------------------------------------------------------------------
+
+# If the GENERATE_MAN tag is set to YES (the default) Doxygen will
+# generate man pages
+
+GENERATE_MAN = NO
+
+# The MAN_OUTPUT tag is used to specify where the man pages will be put.
+# If a relative path is entered the value of OUTPUT_DIRECTORY will be
+# put in front of it. If left blank `man' will be used as the default path.
+
+MAN_OUTPUT = man
+
+# The MAN_EXTENSION tag determines the extension that is added to
+# the generated man pages (default is the subroutine's section .3)
+
+MAN_EXTENSION = .3
+
+# If the MAN_LINKS tag is set to YES and Doxygen generates man output,
+# then it will generate one additional man file for each entity
+# documented in the real man page(s). These additional files
+# only source the real man page, but without them the man command
+# would be unable to find the correct page. The default is NO.
+
+MAN_LINKS = NO
+
+#---------------------------------------------------------------------------
+# configuration options related to the XML output
+#---------------------------------------------------------------------------
+
+# If the GENERATE_XML tag is set to YES Doxygen will
+# generate an XML file that captures the structure of
+# the code including all documentation.
+
+GENERATE_XML = NO
+
+# The XML_OUTPUT tag is used to specify where the XML pages will be put.
+# If a relative path is entered the value of OUTPUT_DIRECTORY will be
+# put in front of it. If left blank `xml' will be used as the default path.
+
+XML_OUTPUT = xml
+
+# The XML_SCHEMA tag can be used to specify an XML schema,
+# which can be used by a validating XML parser to check the
+# syntax of the XML files.
+
+XML_SCHEMA =
+
+# The XML_DTD tag can be used to specify an XML DTD,
+# which can be used by a validating XML parser to check the
+# syntax of the XML files.
+
+XML_DTD =
+
+# If the XML_PROGRAMLISTING tag is set to YES Doxygen will
+# dump the program listings (including syntax highlighting
+# and cross-referencing information) to the XML output. Note that
+# enabling this will significantly increase the size of the XML output.
+
+XML_PROGRAMLISTING = YES
+
+#---------------------------------------------------------------------------
+# configuration options for the AutoGen Definitions output
+#---------------------------------------------------------------------------
+
+# If the GENERATE_AUTOGEN_DEF tag is set to YES Doxygen will
+# generate an AutoGen Definitions (see autogen.sf.net) file
+# that captures the structure of the code including all
+# documentation. Note that this feature is still experimental
+# and incomplete at the moment.
+
+GENERATE_AUTOGEN_DEF = NO
+
+#---------------------------------------------------------------------------
+# configuration options related to the Perl module output
+#---------------------------------------------------------------------------
+
+# If the GENERATE_PERLMOD tag is set to YES Doxygen will
+# generate a Perl module file that captures the structure of
+# the code including all documentation. Note that this
+# feature is still experimental and incomplete at the
+# moment.
+
+GENERATE_PERLMOD = NO
+
+# If the PERLMOD_LATEX tag is set to YES Doxygen will generate
+# the necessary Makefile rules, Perl scripts and LaTeX code to be able
+# to generate PDF and DVI output from the Perl module output.
+
+PERLMOD_LATEX = NO
+
+# If the PERLMOD_PRETTY tag is set to YES the Perl module output will be
+# nicely formatted so it can be parsed by a human reader.
+# This is useful
+# if you want to understand what is going on.
+# On the other hand, if this
+# tag is set to NO the size of the Perl module output will be much smaller
+# and Perl will parse it just the same.
+
+PERLMOD_PRETTY = YES
+
+# The names of the make variables in the generated doxyrules.make file
+# are prefixed with the string contained in PERLMOD_MAKEVAR_PREFIX.
+# This is useful so different doxyrules.make files included by the same
+# Makefile don't overwrite each other's variables.
+
+PERLMOD_MAKEVAR_PREFIX =
+
+#---------------------------------------------------------------------------
+# Configuration options related to the preprocessor
+#---------------------------------------------------------------------------
+
+# If the ENABLE_PREPROCESSING tag is set to YES (the default) Doxygen will
+# evaluate all C-preprocessor directives found in the sources and include
+# files.
+
+ENABLE_PREPROCESSING = YES
+
+# If the MACRO_EXPANSION tag is set to YES Doxygen will expand all macro
+# names in the source code. If set to NO (the default) only conditional
+# compilation will be performed. Macro expansion can be done in a controlled
+# way by setting EXPAND_ONLY_PREDEF to YES.
+
+MACRO_EXPANSION = NO
+
+# If the EXPAND_ONLY_PREDEF and MACRO_EXPANSION tags are both set to YES
+# then the macro expansion is limited to the macros specified with the
+# PREDEFINED and EXPAND_AS_DEFINED tags.
+
+EXPAND_ONLY_PREDEF = NO
+
+# If the SEARCH_INCLUDES tag is set to YES (the default) the includes files
+# in the INCLUDE_PATH (see below) will be search if a #include is found.
+
+SEARCH_INCLUDES = YES
+
+# The INCLUDE_PATH tag can be used to specify one or more directories that
+# contain include files that are not input files but should be processed by
+# the preprocessor.
+
+INCLUDE_PATH =
+
+# You can use the INCLUDE_FILE_PATTERNS tag to specify one or more wildcard
+# patterns (like *.h and *.hpp) to filter out the header-files in the
+# directories. If left blank, the patterns specified with FILE_PATTERNS will
+# be used.
+
+INCLUDE_FILE_PATTERNS =
+
+# The PREDEFINED tag can be used to specify one or more macro names that
+# are defined before the preprocessor is started (similar to the -D option of
+# gcc). The argument of the tag is a list of macros of the form: name
+# or name=definition (no spaces). If the definition and the = are
+# omitted =1 is assumed. To prevent a macro definition from being
+# undefined via #undef or recursively expanded use the := operator
+# instead of the = operator.
+
+PREDEFINED = SHAPE \
+ RENDER \
+ XKB \
+ XINPUT
+
+# If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then
+# this tag can be used to specify a list of macro names that should be expanded.
+# The macro definition that is found in the sources will be used.
+# Use the PREDEFINED tag if you want to use a different macro definition.
+
+EXPAND_AS_DEFINED =
+
+# If the SKIP_FUNCTION_MACROS tag is set to YES (the default) then
+# doxygen's preprocessor will remove all function-like macros that are alone
+# on a line, have an all uppercase name, and do not end with a semicolon. Such
+# function macros are typically used for boiler-plate code, and will confuse
+# the parser if not removed.
+
+SKIP_FUNCTION_MACROS = YES
+
+#---------------------------------------------------------------------------
+# Configuration::additions related to external references
+#---------------------------------------------------------------------------
+
+# The TAGFILES option can be used to specify one or more tagfiles.
+# Optionally an initial location of the external documentation
+# can be added for each tagfile. The format of a tag file without
+# this location is as follows:
+#
+# TAGFILES = file1 file2 ...
+# Adding location for the tag files is done as follows:
+#
+# TAGFILES = file1=loc1 "file2 = loc2" ...
+# where "loc1" and "loc2" can be relative or absolute paths or
+# URLs. If a location is present for each tag, the installdox tool
+# does not have to be run to correct the links.
+# Note that each tag file must have a unique name
+# (where the name does NOT include the path)
+# If a tag file is not located in the directory in which doxygen
+# is run, you must also specify the path to the tagfile here.
+
+TAGFILES =
+
+# When a file name is specified after GENERATE_TAGFILE, doxygen will create
+# a tag file that is based on the input files it reads.
+
+GENERATE_TAGFILE =
+
+# If the ALLEXTERNALS tag is set to YES all external classes will be listed
+# in the class index. If set to NO only the inherited external classes
+# will be listed.
+
+ALLEXTERNALS = NO
+
+# If the EXTERNAL_GROUPS tag is set to YES all external groups will be listed
+# in the modules index. If set to NO, only the current project's groups will
+# be listed.
+
+EXTERNAL_GROUPS = YES
+
+# The PERL_PATH should be the absolute path and name of the perl script
+# interpreter (i.e. the result of `which perl').
+
+PERL_PATH = /usr/bin/perl
+
+#---------------------------------------------------------------------------
+# Configuration options related to the dot tool
+#---------------------------------------------------------------------------
+
+# If the CLASS_DIAGRAMS tag is set to YES (the default) Doxygen will
+# generate a inheritance diagram (in HTML, RTF and LaTeX) for classes with base
+# or super classes. Setting the tag to NO turns the diagrams off. Note that
+# this option is superseded by the HAVE_DOT option below. This is only a
+# fallback. It is recommended to install and use dot, since it yields more
+# powerful graphs.
+
+CLASS_DIAGRAMS = YES
+
+# You can define message sequence charts within doxygen comments using the \msc
+# command. Doxygen will then run the mscgen tool (see
+# http://www.mcternan.me.uk/mscgen/) to produce the chart and insert it in the
+# documentation. The MSCGEN_PATH tag allows you to specify the directory where
+# the mscgen tool resides. If left empty the tool is assumed to be found in the
+# default search path.
+
+MSCGEN_PATH =
+
+# If set to YES, the inheritance and collaboration graphs will hide
+# inheritance and usage relations if the target is undocumented
+# or is not a class.
+
+HIDE_UNDOC_RELATIONS = YES
+
+# If you set the HAVE_DOT tag to YES then doxygen will assume the dot tool is
+# available from the path. This tool is part of Graphviz, a graph visualization
+# toolkit from AT&T and Lucent Bell Labs. The other options in this section
+# have no effect if this option is set to NO (the default)
+
+HAVE_DOT = NO
+
+# By default doxygen will write a font called FreeSans.ttf to the output
+# directory and reference it in all dot files that doxygen generates. This
+# font does not include all possible unicode characters however, so when you need
+# these (or just want a differently looking font) you can specify the font name
+# using DOT_FONTNAME. You need need to make sure dot is able to find the font,
+# which can be done by putting it in a standard location or by setting the
+# DOTFONTPATH environment variable or by setting DOT_FONTPATH to the directory
+# containing the font.
+
+DOT_FONTNAME = FreeSans
+
+# The DOT_FONTSIZE tag can be used to set the size of the font of dot graphs.
+# The default size is 10pt.
+
+DOT_FONTSIZE = 10
+
+# By default doxygen will tell dot to use the output directory to look for the
+# FreeSans.ttf font (which doxygen will put there itself). If you specify a
+# different font using DOT_FONTNAME you can set the path where dot
+# can find it using this tag.
+
+DOT_FONTPATH =
+
+# If the CLASS_GRAPH and HAVE_DOT tags are set to YES then doxygen
+# will generate a graph for each documented class showing the direct and
+# indirect inheritance relations. Setting this tag to YES will force the
+# the CLASS_DIAGRAMS tag to NO.
+
+CLASS_GRAPH = YES
+
+# If the COLLABORATION_GRAPH and HAVE_DOT tags are set to YES then doxygen
+# will generate a graph for each documented class showing the direct and
+# indirect implementation dependencies (inheritance, containment, and
+# class references variables) of the class with other documented classes.
+
+COLLABORATION_GRAPH = YES
+
+# If the GROUP_GRAPHS and HAVE_DOT tags are set to YES then doxygen
+# will generate a graph for groups, showing the direct groups dependencies
+
+GROUP_GRAPHS = YES
+
+# If the UML_LOOK tag is set to YES doxygen will generate inheritance and
+# collaboration diagrams in a style similar to the OMG's Unified Modeling
+# Language.
+
+UML_LOOK = NO
+
+# If set to YES, the inheritance and collaboration graphs will show the
+# relations between templates and their instances.
+
+TEMPLATE_RELATIONS = YES
+
+# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDE_GRAPH, and HAVE_DOT
+# tags are set to YES then doxygen will generate a graph for each documented
+# file showing the direct and indirect include dependencies of the file with
+# other documented files.
+
+INCLUDE_GRAPH = YES
+
+# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDED_BY_GRAPH, and
+# HAVE_DOT tags are set to YES then doxygen will generate a graph for each
+# documented header file showing the documented files that directly or
+# indirectly include this file.
+
+INCLUDED_BY_GRAPH = YES
+
+# If the CALL_GRAPH and HAVE_DOT options are set to YES then
+# doxygen will generate a call dependency graph for every global function
+# or class method. Note that enabling this option will significantly increase
+# the time of a run. So in most cases it will be better to enable call graphs
+# for selected functions only using the \callgraph command.
+
+CALL_GRAPH = NO
+
+# If the CALLER_GRAPH and HAVE_DOT tags are set to YES then
+# doxygen will generate a caller dependency graph for every global function
+# or class method. Note that enabling this option will significantly increase
+# the time of a run. So in most cases it will be better to enable caller
+# graphs for selected functions only using the \callergraph command.
+
+CALLER_GRAPH = NO
+
+# If the GRAPHICAL_HIERARCHY and HAVE_DOT tags are set to YES then doxygen
+# will graphical hierarchy of all classes instead of a textual one.
+
+GRAPHICAL_HIERARCHY = YES
+
+# If the DIRECTORY_GRAPH, SHOW_DIRECTORIES and HAVE_DOT tags are set to YES
+# then doxygen will show the dependencies a directory has on other directories
+# in a graphical way. The dependency relations are determined by the #include
+# relations between the files in the directories.
+
+DIRECTORY_GRAPH = YES
+
+# The DOT_IMAGE_FORMAT tag can be used to set the image format of the images
+# generated by dot. Possible values are png, jpg, or gif
+# If left blank png will be used.
+
+DOT_IMAGE_FORMAT = gif
+
+# The tag DOT_PATH can be used to specify the path where the dot tool can be
+# found. If left blank, it is assumed the dot tool can be found in the path.
+
+DOT_PATH =
+
+# The DOTFILE_DIRS tag can be used to specify one or more directories that
+# contain dot files that are included in the documentation (see the
+# \dotfile command).
+
+DOTFILE_DIRS =
+
+# The DOT_GRAPH_MAX_NODES tag can be used to set the maximum number of
+# nodes that will be shown in the graph. If the number of nodes in a graph
+# becomes larger than this value, doxygen will truncate the graph, which is
+# visualized by representing a node as a red box. Note that doxygen if the
+# number of direct children of the root node in a graph is already larger than
+# DOT_GRAPH_MAX_NODES then the graph will not be shown at all. Also note
+# that the size of a graph can be further restricted by MAX_DOT_GRAPH_DEPTH.
+
+DOT_GRAPH_MAX_NODES = 50
+
+# The MAX_DOT_GRAPH_DEPTH tag can be used to set the maximum depth of the
+# graphs generated by dot. A depth value of 3 means that only nodes reachable
+# from the root by following a path via at most 3 edges will be shown. Nodes
+# that lay further from the root node will be omitted. Note that setting this
+# option to 1 or 2 may greatly reduce the computation time needed for large
+# code bases. Also note that the size of a graph can be further restricted by
+# DOT_GRAPH_MAX_NODES. Using a depth of 0 means no depth restriction.
+
+MAX_DOT_GRAPH_DEPTH = 0
+
+# Set the DOT_TRANSPARENT tag to YES to generate images with a transparent
+# background. This is disabled by default, because dot on Windows does not
+# seem to support this out of the box. Warning: Depending on the platform used,
+# enabling this option may lead to badly anti-aliased labels on the edges of
+# a graph (i.e. they become hard to read).
+
+DOT_TRANSPARENT = NO
+
+# Set the DOT_MULTI_TARGETS tag to YES allow dot to generate multiple output
+# files in one run (i.e. multiple -o and -T options on the command line). This
+# makes dot run faster, but since only newer versions of dot (>1.8.10)
+# support this, this feature is disabled by default.
+
+DOT_MULTI_TARGETS = YES
+
+# If the GENERATE_LEGEND tag is set to YES (the default) Doxygen will
+# generate a legend page explaining the meaning of the various boxes and
+# arrows in the dot generated graphs.
+
+GENERATE_LEGEND = YES
+
+# If the DOT_CLEANUP tag is set to YES (the default) Doxygen will
+# remove the intermediate dot files that are used to generate
+# the various graphs.
+
+DOT_CLEANUP = YES
diff --git a/xorg-server/hw/dmx/doxygen/footer.html b/xorg-server/hw/dmx/doxygen/footer.html
new file mode 100644
index 000000000..f80dc8269
--- /dev/null
+++ b/xorg-server/hw/dmx/doxygen/footer.html
@@ -0,0 +1,4 @@
+<hr size="1"/><address style="text-align: right;"><small>
+Generated on $datetime for $projectname by&nbsp;<a href="http://www.doxygen.org/index.html"><img class="footer" src="doxygen.png" alt="doxygen"/></a> $doxygenversion</small></address>
+</body>
+</html>
diff --git a/xorg-server/hw/dmx/input/dmxevents.c b/xorg-server/hw/dmx/input/dmxevents.c
index 15d80f5bb..41bc4bf2d 100644
--- a/xorg-server/hw/dmx/input/dmxevents.c
+++ b/xorg-server/hw/dmx/input/dmxevents.c
@@ -176,19 +176,15 @@ static void enqueueMotion(DevicePtr pDev, int x, int y)
{
GETDMXLOCALFROMPDEV;
DeviceIntPtr p = dmxLocal->pDevice;
- int i, nevents, valuators[3];
- EventListPtr events;
+ int valuators[3];
int detail = 0; /* XXX should this be mask of pressed buttons? */
ValuatorMask mask;
valuators[0] = x;
valuators[1] = y;
valuator_mask_set_range(&mask, 0, 2, valuators);
- GetEventList(&events);
- nevents = GetPointerEvents(events, p, MotionNotify, detail,
- POINTER_ABSOLUTE | POINTER_SCREEN, &mask);
- for (i = 0; i < nevents; i++)
- mieqEnqueue(p, (InternalEvent*)(events + i)->event);
+ QueuePointerEvents(p, MotionNotify, detail,
+ POINTER_ABSOLUTE | POINTER_SCREEN, &mask);
return;
}
@@ -291,10 +287,7 @@ static void dmxExtMotion(DMXLocalInputInfoPtr dmxLocal,
deviceValuator *xv = (deviceValuator *)xev+1;
int thisX = 0;
int thisY = 0;
- int i;
int count;
- EventListPtr events;
- int nevents;
ValuatorMask mask;
memset(xE, 0, sizeof(xE));
@@ -348,6 +341,7 @@ static void dmxExtMotion(DMXLocalInputInfoPtr dmxLocal,
}
count = 2;
} else {
+ int i;
for (i = 0, count = 0; i < axesCount; i += 6) {
xev->time = GetTimeInMillis();
xev->type = DeviceMotionNotify;
@@ -375,11 +369,8 @@ static void dmxExtMotion(DMXLocalInputInfoPtr dmxLocal,
if (block)
dmxSigioBlock();
valuator_mask_set_range(&mask, firstAxis, axesCount, v);
- GetEventList(&events);
- nevents = GetPointerEvents(events, pDevice, MotionNotify, 0,
- POINTER_ABSOLUTE, &mask);
- for (i = 0; i < nevents; i++)
- mieqEnqueue(pDevice, (InternalEvent*)(events + i)->event);
+ QueuePointerEvents(pDevice, MotionNotify, 0,
+ POINTER_ABSOLUTE, &mask);
if (block)
dmxSigioUnblock();
@@ -394,8 +385,6 @@ static int dmxTranslateAndEnqueueExtEvent(DMXLocalInputInfoPtr dmxLocal,
XDeviceMotionEvent *me = (XDeviceMotionEvent *)e;
DeviceIntPtr pDevice = dmxLocal->pDevice;
int valuators[MAX_VALUATORS];
- EventListPtr events;
- int nevents, i;
ValuatorMask mask;
if (!e)
@@ -452,12 +441,7 @@ static int dmxTranslateAndEnqueueExtEvent(DMXLocalInputInfoPtr dmxLocal,
valuator_mask_set_range(&mask, ke->first_axis, ke->axes_count, valuators);
if (block)
dmxSigioBlock();
- GetEventList(&events);
- nevents = GetKeyboardEvents(events, pDevice, event,
- ke->keycode, &mask);
- for (i = 0; i < nevents; i++)
- mieqEnqueue(pDevice, (InternalEvent*)(events + i)->event);
-
+ QueueKeyboardEvents(pDevice, event, ke->keycode, &mask);
if (block)
dmxSigioUnblock();
break;
@@ -467,12 +451,8 @@ static int dmxTranslateAndEnqueueExtEvent(DMXLocalInputInfoPtr dmxLocal,
valuator_mask_set_range(&mask, ke->first_axis, ke->axes_count, valuators);
if (block)
dmxSigioBlock();
- GetEventList(&events);
- nevents = GetPointerEvents(events, pDevice, event, ke->keycode,
- POINTER_ABSOLUTE, &mask);
- for (i = 0; i < nevents; i++)
- mieqEnqueue(pDevice, (InternalEvent*)(events + i)->event);
-
+ QueuePointerEvents(pDevice, event, ke->keycode,
+ POINTER_ABSOLUTE, &mask);
if (block)
dmxSigioUnblock();
break;
@@ -482,11 +462,7 @@ static int dmxTranslateAndEnqueueExtEvent(DMXLocalInputInfoPtr dmxLocal,
valuator_mask_set_range(&mask, ke->first_axis, ke->axes_count, valuators);
if (block)
dmxSigioBlock();
- GetEventList(&events);
- nevents = GetProximityEvents(events, pDevice, event, &mask);
- for (i = 0; i < nevents; i++)
- mieqEnqueue(pDevice, (InternalEvent*)(events + i)->event);
-
+ QueueProximityEvents(pDevice, event, &mask);
if (block)
dmxSigioUnblock();
break;
@@ -667,8 +643,7 @@ void dmxEnqueue(DevicePtr pDev, int type, int detail, KeySym keySym,
GETDMXINPUTFROMPDEV;
xEvent xE;
DeviceIntPtr p = dmxLocal->pDevice;
- int i, nevents, valuators[3];
- EventListPtr events;
+ int valuators[3];
ValuatorMask mask;
DMXDBG2("dmxEnqueue: Enqueuing type=%d detail=0x%0x\n", type, detail);
@@ -683,34 +658,25 @@ void dmxEnqueue(DevicePtr pDev, int type, int detail, KeySym keySym,
if (dmxLocal->sendsCore && dmxLocal != dmxLocalCoreKeyboard)
xE.u.u.detail = dmxFixup(pDev, detail, keySym);
- GetEventList(&events);
/*ErrorF("KEY %d sym %d\n", detail, (int) keySym);*/
- nevents = GetKeyboardEvents(events, p, type, detail, NULL);
- for (i = 0; i < nevents; i++)
- mieqEnqueue(p, (InternalEvent*)(events + i)->event);
+ QueueKeyboardEvents(p, type, detail, NULL);
return;
case ButtonPress:
case ButtonRelease:
detail = dmxGetButtonMapping(dmxLocal, detail);
valuator_mask_zero(&mask);
- GetEventList(&events);
- nevents = GetPointerEvents(events, p, type, detail,
- POINTER_ABSOLUTE | POINTER_SCREEN, &mask);
- for (i = 0; i < nevents; i++)
- mieqEnqueue(p, (InternalEvent*)(events + i)->event);
+ QueuePointerEvents(p, type, detail,
+ POINTER_ABSOLUTE | POINTER_SCREEN, &mask);
return;
case MotionNotify:
- GetEventList(&events);
valuators[0] = e->xmotion.x;
valuators[1] = e->xmotion.y;
valuators[2] = e->xmotion.state; /* FIXME: WTF?? */
valuator_mask_set_range(&mask, 0, 3, valuators);
- nevents = GetPointerEvents(events, p, type, detail,
- POINTER_ABSOLUTE | POINTER_SCREEN, &mask);
- for (i = 0; i < nevents; i++)
- mieqEnqueue(p, (InternalEvent*)(events + i)->event);
+ QueuePointerEvents(p, type, detail,
+ POINTER_ABSOLUTE | POINTER_SCREEN, &mask);
return;
case EnterNotify:
diff --git a/xorg-server/hw/kdrive/src/kinput.c b/xorg-server/hw/kdrive/src/kinput.c
index f21475fb6..cdf55d7f9 100644
--- a/xorg-server/hw/kdrive/src/kinput.c
+++ b/xorg-server/hw/kdrive/src/kinput.c
@@ -66,8 +66,6 @@ static struct KdConfigDevice *kdConfigPointers = NULL;
static KdKeyboardDriver *kdKeyboardDrivers = NULL;
static KdPointerDriver *kdPointerDrivers = NULL;
-static EventListPtr kdEvents = NULL;
-
static Bool kdInputEnabled;
static Bool kdOffScreen;
static unsigned long kdOffScreenTime;
@@ -1793,7 +1791,7 @@ void
KdReleaseAllKeys (void)
{
#if 0
- int key, nEvents, i;
+ int key;
KdKeyboardInfo *ki;
KdBlockSigio ();
@@ -1803,10 +1801,7 @@ KdReleaseAllKeys (void)
key++) {
if (key_is_down(ki->dixdev, key, KEY_POSTED | KEY_PROCESSED)) {
KdHandleKeyboardEvent(ki, KeyRelease, key);
- GetEventList(&kdEvents);
- nEvents = GetKeyboardEvents(kdEvents, ki->dixdev, KeyRelease, key, NULL);
- for (i = 0; i < nEvents; i++)
- KdQueueEvent (ki->dixdev, (kdEvents + i)->event);
+ QueueGetKeyboardEvents(ki->dixdev, KeyRelease, key, NULL);
}
}
}
@@ -1842,7 +1837,7 @@ KdEnqueueKeyboardEvent(KdKeyboardInfo *ki,
unsigned char key_code;
KeyClassPtr keyc = NULL;
KeybdCtrl *ctrl = NULL;
- int type, nEvents, i;
+ int type;
if (!ki || !ki->dixdev || !ki->dixdev->kbdfeed || !ki->dixdev->key)
return;
@@ -1862,11 +1857,7 @@ KdEnqueueKeyboardEvent(KdKeyboardInfo *ki,
else
type = KeyPress;
- GetEventList(&kdEvents);
-
- nEvents = GetKeyboardEvents(kdEvents, ki->dixdev, type, key_code, NULL);
- for (i = 0; i < nEvents; i++)
- KdQueueEvent(ki->dixdev, (InternalEvent *)((kdEvents + i)->event));
+ QueueKeyboardEvents(ki->dixdev, type, key_code, NULL);
}
else {
ErrorF("driver %s wanted to post scancode %d outside of [%d, %d]!\n",
@@ -1965,7 +1956,6 @@ void
_KdEnqueuePointerEvent (KdPointerInfo *pi, int type, int x, int y, int z,
int b, int absrel, Bool force)
{
- int nEvents = 0, i = 0;
int valuators[3] = { x, y, z };
ValuatorMask mask;
@@ -1975,10 +1965,7 @@ _KdEnqueuePointerEvent (KdPointerInfo *pi, int type, int x, int y, int z,
valuator_mask_set_range(&mask, 0, 3, valuators);
- GetEventList(&kdEvents);
- nEvents = GetPointerEvents(kdEvents, pi->dixdev, type, b, absrel, &mask);
- for (i = 0; i < nEvents; i++)
- KdQueueEvent(pi->dixdev, (InternalEvent *)((kdEvents + i)->event));
+ QueuePointerEvents(pi->dixdev, type, b, absrel, &mask);
}
void
diff --git a/xorg-server/hw/xfree86/Makefile.am b/xorg-server/hw/xfree86/Makefile.am
index 94ef966e2..f1a759a27 100644
--- a/xorg-server/hw/xfree86/Makefile.am
+++ b/xorg-server/hw/xfree86/Makefile.am
@@ -1,118 +1,118 @@
-
-if DRI
-DRI_SUBDIR = dri
-endif
-
-if DRI2
-DRI2_SUBDIR = dri2
-endif
-
-if XF86UTILS
-XF86UTILS_SUBDIR = utils
-endif
-
-if XAA
-XAA_SUBDIR = xaa
-endif
-
-if VGAHW
-VGAHW_SUBDIR = vgahw
-endif
-
-if VBE
-VBE_SUBDIR = vbe
-endif
-
-if INT10MODULE
-INT10_SUBDIR = int10
-endif
-
-SUBDIRS = common ddc i2c x86emu $(INT10_SUBDIR) fbdevhw os-support parser \
- ramdac shadowfb $(VBE_SUBDIR) $(VGAHW_SUBDIR) $(XAA_SUBDIR) \
- loader dixmods exa modes \
- $(DRI_SUBDIR) $(DRI2_SUBDIR) $(XF86UTILS_SUBDIR) doc man
-
-DIST_SUBDIRS = common ddc i2c x86emu int10 fbdevhw os-support \
- parser ramdac shadowfb vbe vgahw xaa \
- loader dixmods dri dri2 exa modes \
- utils doc man
-
-bin_PROGRAMS = Xorg
-Xorg_SOURCES = xorg.c
-
-AM_CFLAGS = $(DIX_CFLAGS) @XORG_CFLAGS@
-INCLUDES = @XORG_INCS@
-
-noinst_LTLIBRARIES = libxorg.la
-libxorg_la_SOURCES = libxorg.c
-libxorg_la_LIBADD = \
- $(XSERVER_LIBS) \
- loader/libloader.la \
- os-support/libxorgos.la \
- common/libcommon.la \
- parser/libxf86config_internal.la \
- dixmods/libdixmods.la \
- modes/libxf86modes.la \
- ramdac/libramdac.la \
- ddc/libddc.la \
- i2c/libi2c.la \
- dixmods/libxorgxkb.la \
- $(top_builddir)/mi/libmi.la \
- $(top_builddir)/os/libos.la \
- @XORG_LIBS@
-
-libxorg_la_DEPENDENCIES = $(libxorg_la_LIBADD)
-
-libxorg.c xorg.c:
- touch $@
-
-DISTCLEANFILES = libxorg.c xorg.c
-
-Xorg_DEPENDENCIES = libxorg.la
-Xorg_LDADD = $(MAIN_LIB) libxorg.la $(XORG_SYS_LIBS) $(XSERVER_SYS_LIBS)
-
-Xorg_LDFLAGS = $(LD_EXPORT_SYMBOLS_FLAG)
-
-BUILT_SOURCES = xorg.conf.example
-DISTCLEANFILES += xorg.conf.example
-EXTRA_DIST = xorgconf.cpp
-
-if SPECIAL_DTRACE_OBJECTS
-# Re-add dtrace object code that gets lost when building static libraries
-Xorg_LDADD += $(XSERVER_LIBS)
-endif
-
-if SOLARIS_ASM_INLINE
-# Needs to be built before any files are compiled when using Sun compilers
-# so in*/out* inline definitions are properly processed.
-
-BUILT_SOURCES += os-support/solaris/solaris-@SOLARIS_INOUT_ARCH@.il
-
-os-support/solaris/solaris-@SOLARIS_INOUT_ARCH@.il:
- cd os-support/solaris ; \
- $(MAKE) $(AM_MAKEFLAGS) solaris-@SOLARIS_INOUT_ARCH@.il
-endif
-
-# do not use $(mkdir_p) if you want automake 1.7 to work
-install-data-local:
- mkdir -p $(DESTDIR)$(logdir)
-
-
-install-exec-local: install-binPROGRAMS
- (cd $(DESTDIR)$(bindir) && rm -f X && ln -s Xorg X)
-if INSTALL_SETUID
- chown root $(DESTDIR)$(bindir)/Xorg
- chmod u+s $(DESTDIR)$(bindir)/Xorg
-endif
-
-# Use variables from XORG_MANPAGE_SECTIONS and X Server configuration
-# Do not include manpages.am as values are not appropriate for rc files
-CONF_SUBSTS = -e 's|__filemansuffix__|$(FILE_MAN_SUFFIX)|g' \
- -e 's|MODULEPATH|$(DEFAULT_MODULE_PATH)|g' \
- -e 's|DEFAULTFONTPATH|$(COMPILEDDEFAULTFONTPATH)|g'
-
-xorg.conf.example: xorgconf.cpp
- $(AM_V_GEN)$(SED) $(CONF_SUBSTS) < $< > $@
-
-relink:
- $(AM_V_at)rm -f Xorg && $(MAKE) Xorg
+
+if DRI
+DRI_SUBDIR = dri
+endif
+
+if DRI2
+DRI2_SUBDIR = dri2
+endif
+
+if XF86UTILS
+XF86UTILS_SUBDIR = utils
+endif
+
+if XAA
+XAA_SUBDIR = xaa
+endif
+
+if VGAHW
+VGAHW_SUBDIR = vgahw
+endif
+
+if VBE
+VBE_SUBDIR = vbe
+endif
+
+if INT10MODULE
+INT10_SUBDIR = int10
+endif
+
+SUBDIRS = common ddc i2c x86emu $(INT10_SUBDIR) fbdevhw os-support parser \
+ ramdac shadowfb $(VBE_SUBDIR) $(VGAHW_SUBDIR) $(XAA_SUBDIR) \
+ loader dixmods exa modes \
+ $(DRI_SUBDIR) $(DRI2_SUBDIR) $(XF86UTILS_SUBDIR) doc man
+
+DIST_SUBDIRS = common ddc i2c x86emu int10 fbdevhw os-support \
+ parser ramdac shadowfb vbe vgahw xaa \
+ loader dixmods dri dri2 exa modes \
+ utils doc man
+
+bin_PROGRAMS = Xorg
+Xorg_SOURCES = xorg.c
+
+AM_CFLAGS = $(DIX_CFLAGS) @XORG_CFLAGS@
+INCLUDES = @XORG_INCS@
+
+noinst_LTLIBRARIES = libxorg.la
+libxorg_la_SOURCES = libxorg.c
+libxorg_la_LIBADD = \
+ $(XSERVER_LIBS) \
+ loader/libloader.la \
+ os-support/libxorgos.la \
+ common/libcommon.la \
+ parser/libxf86config_internal.la \
+ dixmods/libdixmods.la \
+ modes/libxf86modes.la \
+ ramdac/libramdac.la \
+ ddc/libddc.la \
+ i2c/libi2c.la \
+ dixmods/libxorgxkb.la \
+ $(top_builddir)/mi/libmi.la \
+ $(top_builddir)/os/libos.la \
+ @XORG_LIBS@
+
+libxorg_la_DEPENDENCIES = $(libxorg_la_LIBADD)
+
+libxorg.c xorg.c:
+ touch $@
+
+DISTCLEANFILES = libxorg.c xorg.c
+
+Xorg_DEPENDENCIES = libxorg.la
+Xorg_LDADD = $(MAIN_LIB) libxorg.la $(XORG_SYS_LIBS) $(XSERVER_SYS_LIBS)
+
+Xorg_LDFLAGS = $(LD_EXPORT_SYMBOLS_FLAG)
+
+BUILT_SOURCES = xorg.conf.example
+DISTCLEANFILES += xorg.conf.example
+EXTRA_DIST = xorgconf.cpp
+
+if SPECIAL_DTRACE_OBJECTS
+# Re-add dtrace object code that gets lost when building static libraries
+Xorg_LDADD += $(XSERVER_LIBS)
+endif
+
+if SOLARIS_ASM_INLINE
+# Needs to be built before any files are compiled when using Sun compilers
+# so in*/out* inline definitions are properly processed.
+
+BUILT_SOURCES += os-support/solaris/solaris-@SOLARIS_INOUT_ARCH@.il
+
+os-support/solaris/solaris-@SOLARIS_INOUT_ARCH@.il:
+ cd os-support/solaris ; \
+ $(MAKE) $(AM_MAKEFLAGS) solaris-@SOLARIS_INOUT_ARCH@.il
+endif
+
+# do not use $(mkdir_p) if you want automake 1.7 to work
+install-data-local:
+ mkdir -p $(DESTDIR)$(logdir)
+
+
+install-exec-local: install-binPROGRAMS
+ (cd $(DESTDIR)$(bindir) && rm -f X && ln -s Xorg X)
+if INSTALL_SETUID
+ chown root $(DESTDIR)$(bindir)/Xorg
+ chmod u+s $(DESTDIR)$(bindir)/Xorg
+endif
+
+# Use variables from XORG_MANPAGE_SECTIONS and X Server configuration
+# Do not include manpages.am as values are not appropriate for rc files
+CONF_SUBSTS = -e 's|__filemansuffix__|$(FILE_MAN_SUFFIX)|g' \
+ -e 's|MODULEPATH|$(DEFAULT_MODULE_PATH)|g' \
+ -e 's|DEFAULTFONTPATH|$(COMPILEDDEFAULTFONTPATH)|g'
+
+xorg.conf.example: xorgconf.cpp
+ $(AM_V_GEN)$(SED) $(CONF_SUBSTS) < $(srcdir)/xorgconf.cpp > $@
+
+relink:
+ $(AM_V_at)rm -f Xorg && $(MAKE) Xorg
diff --git a/xorg-server/hw/xfree86/common/xf86Events.c b/xorg-server/hw/xfree86/common/xf86Events.c
index 3006ad183..c4a4db9be 100644
--- a/xorg-server/hw/xfree86/common/xf86Events.c
+++ b/xorg-server/hw/xfree86/common/xf86Events.c
@@ -376,7 +376,7 @@ static void
xf86ReleaseKeys(DeviceIntPtr pDev)
{
KeyClassPtr keyc;
- int i, j, nevents, sigstate;
+ int i, sigstate;
if (!pDev || !pDev->key)
return;
@@ -399,9 +399,7 @@ xf86ReleaseKeys(DeviceIntPtr pDev)
i++) {
if (key_is_down(pDev, i, KEY_POSTED)) {
sigstate = xf86BlockSIGIO ();
- nevents = GetKeyboardEvents(xf86Events, pDev, KeyRelease, i, NULL);
- for (j = 0; j < nevents; j++)
- mieqEnqueue(pDev, (InternalEvent*)(xf86Events + j)->event);
+ QueueKeyboardEvents(pDev, KeyRelease, i, NULL);
xf86UnblockSIGIO(sigstate);
}
}
diff --git a/xorg-server/hw/xfree86/common/xf86Init.c b/xorg-server/hw/xfree86/common/xf86Init.c
index 0b36163c0..53f763aaf 100644
--- a/xorg-server/hw/xfree86/common/xf86Init.c
+++ b/xorg-server/hw/xfree86/common/xf86Init.c
@@ -806,8 +806,6 @@ InitInput(int argc, char **argv)
mieqInit();
- GetEventList(&xf86Events);
-
/* Initialize all configured input devices */
for (pDev = xf86ConfigLayout.inputs; pDev && *pDev; pDev++) {
/* Replace obsolete keyboard driver with kbd */
diff --git a/xorg-server/hw/xfree86/common/xf86Priv.h b/xorg-server/hw/xfree86/common/xf86Priv.h
index 7137a5363..5d91ab367 100644
--- a/xorg-server/hw/xfree86/common/xf86Priv.h
+++ b/xorg-server/hw/xfree86/common/xf86Priv.h
@@ -148,9 +148,6 @@ extern _X_EXPORT int xf86SetVerbosity(int verb);
extern _X_EXPORT int xf86SetLogVerbosity(int verb);
extern _X_EXPORT Bool xf86CallDriverProbe( struct _DriverRec * drv, Bool detect_only );
-/* xf86Xinput.c */
-extern _X_EXPORT EventList *xf86Events;
-
#endif /* _NO_XF86_PROTOTYPES */
diff --git a/xorg-server/hw/xfree86/common/xf86Xinput.c b/xorg-server/hw/xfree86/common/xf86Xinput.c
index ef4542c5f..e7e1ce1f0 100644
--- a/xorg-server/hw/xfree86/common/xf86Xinput.c
+++ b/xorg-server/hw/xfree86/common/xf86Xinput.c
@@ -99,8 +99,6 @@
return; \
}
-EventListPtr xf86Events = NULL;
-
static int
xf86InputDevicePostInit(DeviceIntPtr dev);
@@ -329,8 +327,8 @@ xf86ActivateDevice(InputInfoPtr pInfo)
dev->config_info = xf86SetStrOption(pInfo->options, "config_info", NULL);
if (serverGeneration == 1)
- xf86Msg(X_INFO, "XINPUT: Adding extended input device \"%s\" (type: %s)\n",
- pInfo->name, pInfo->type_name);
+ xf86Msg(X_INFO, "XINPUT: Adding extended input device \"%s\" (type: %s, id %d)\n",
+ pInfo->name, pInfo->type_name, dev->id);
return dev;
}
@@ -1012,7 +1010,6 @@ xf86PostMotionEventM(DeviceIntPtr device,
int is_absolute,
const ValuatorMask *mask)
{
- int i = 0, nevents = 0;
int flags = 0;
if (valuator_mask_num_valuators(mask) > 0)
@@ -1050,11 +1047,7 @@ xf86PostMotionEventM(DeviceIntPtr device,
}
#endif
- nevents = GetPointerEvents(xf86Events, device, MotionNotify, 0, flags, mask);
-
- for (i = 0; i < nevents; i++) {
- mieqEnqueue(device, (InternalEvent*)((xf86Events + i)->event));
- }
+ QueuePointerEvents(device, MotionNotify, 0, flags, mask);
}
void
@@ -1099,13 +1092,7 @@ xf86PostProximityEventM(DeviceIntPtr device,
int is_in,
const ValuatorMask *mask)
{
- int i, nevents;
-
- nevents = GetProximityEvents(xf86Events, device,
- is_in ? ProximityIn : ProximityOut, mask);
- for (i = 0; i < nevents; i++)
- mieqEnqueue(device, (InternalEvent*)((xf86Events + i)->event));
-
+ QueueProximityEvents(device, is_in ? ProximityIn : ProximityOut, mask);
}
void
@@ -1157,7 +1144,6 @@ xf86PostButtonEventM(DeviceIntPtr device,
int is_down,
const ValuatorMask *mask)
{
- int i = 0, nevents = 0;
int flags = 0;
if (valuator_mask_num_valuators(mask) > 0)
@@ -1177,13 +1163,9 @@ xf86PostButtonEventM(DeviceIntPtr device,
}
#endif
- nevents = GetPointerEvents(xf86Events, device,
- is_down ? ButtonPress : ButtonRelease, button,
- flags, mask);
-
- for (i = 0; i < nevents; i++)
- mieqEnqueue(device, (InternalEvent*)((xf86Events + i)->event));
-
+ QueuePointerEvents(device,
+ is_down ? ButtonPress : ButtonRelease, button,
+ flags, mask);
}
void
@@ -1235,8 +1217,6 @@ xf86PostKeyEventM(DeviceIntPtr device,
int is_absolute,
const ValuatorMask *mask)
{
- int i = 0, nevents = 0;
-
#if XFreeXDGA
DeviceIntPtr pointer;
@@ -1250,12 +1230,9 @@ xf86PostKeyEventM(DeviceIntPtr device,
}
#endif
- nevents = GetKeyboardEvents(xf86Events, device,
- is_down ? KeyPress : KeyRelease,
- key_code, mask);
-
- for (i = 0; i < nevents; i++)
- mieqEnqueue(device, (InternalEvent*)((xf86Events + i)->event));
+ QueueKeyboardEvents(device,
+ is_down ? KeyPress : KeyRelease,
+ key_code, mask);
}
void
diff --git a/xorg-server/hw/xfree86/doc/Makefile.am b/xorg-server/hw/xfree86/doc/Makefile.am
index acb8937f0..1c3620abb 100644
--- a/xorg-server/hw/xfree86/doc/Makefile.am
+++ b/xorg-server/hw/xfree86/doc/Makefile.am
@@ -1,4 +1,18 @@
-SUBDIRS = devel sgml
-
-EXTRA_DIST = \
- README.modes
+
+if ENABLE_DEVEL_DOCS
+if HAVE_XMLTO
+
+# Main DocBook/XML files (DOCTYPE book)
+docbook = ddxDesign.xml
+
+# Generate DocBook/XML output formats with or without stylesheets
+include $(top_srcdir)/devbook.am
+
+endif HAVE_XMLTO
+endif ENABLE_DEVEL_DOCS
+
+EXTRA_DIST = \
+ Registry \
+ exa-driver.txt \
+ README.DRIcomp \
+ README.modes
diff --git a/xorg-server/hw/xfree86/doc/devel/README.DRIcomp b/xorg-server/hw/xfree86/doc/README.DRIcomp
index 89f40a759..89f40a759 100644
--- a/xorg-server/hw/xfree86/doc/devel/README.DRIcomp
+++ b/xorg-server/hw/xfree86/doc/README.DRIcomp
diff --git a/xorg-server/hw/xfree86/doc/devel/Registry b/xorg-server/hw/xfree86/doc/Registry
index 89a5f10fa..89a5f10fa 100644
--- a/xorg-server/hw/xfree86/doc/devel/Registry
+++ b/xorg-server/hw/xfree86/doc/Registry
diff --git a/xorg-server/hw/xfree86/doc/sgml/DESIGN.xml b/xorg-server/hw/xfree86/doc/ddxDesign.xml
index 13e582877..02909602c 100644
--- a/xorg-server/hw/xfree86/doc/sgml/DESIGN.xml
+++ b/xorg-server/hw/xfree86/doc/ddxDesign.xml
@@ -1,9394 +1,9394 @@
-<?xml version="1.0" encoding="ISO-8859-1"?>
-<!DOCTYPE article PUBLIC "-//OASIS//DTD DocBook XML V4.3//EN"
- "http://www.oasis-open.org/docbook/xml/4.3/docbookx.dtd" [
- <!ENTITY % defs SYSTEM "/xserver/doc/xml/xserver.ent"> %defs;
- <!-- config file keyword markup -->
- <!-- specific config file keywords -->
- <!ENTITY k.device "<emphasis>Device</emphasis>">
- <!ENTITY k.monitor "<emphasis>Monitor</emphasis>">
- <!ENTITY k.display "<emphasis>Display</emphasis>">
- <!ENTITY k.inputdevice "<emphasis>InputDevice</emphasis>">
- <!ENTITY k.screen "<emphasis>Screen</emphasis>">
- <!ENTITY k.serverlayout "<emphasis>ServerLayout</emphasis>">
- <!ENTITY k.driver "<emphasis>Driver</emphasis>">
- <!ENTITY k.module "<emphasis>Module</emphasis>">
- <!ENTITY k.identifier "<emphasis>Identifier</emphasis>">
- <!ENTITY k.serverflags "<emphasis>ServerFlags</emphasis>">
-] >
-
-<article>
- <articleinfo>
-
- <title>XFree86 DDX Design (Xorg server version &xserver.version;)</title>
-
- <authorgroup>
- <corpauthor><ulink url="http://www.xfree86.org/">
- The XFree86 Project, Inc.</ulink></corpauthor>
- <corpauthor><ulink url="http://www.x.org/">
- The X.Org Foundation, Inc.</ulink></corpauthor>
-
- <othercredit>
- <firstname>Jim</firstname><surname>Gettys</surname>
- <contrib>Updates for X11R6.7</contrib>
- </othercredit>
- </authorgroup>
-
- <pubdate>&xserver.reldate;</pubdate>
- <releaseinfo>Xorg server version &xserver.version;</releaseinfo>
-
- </articleinfo>
-
- <note><para>
-This document describes software undergoing continual evolution, and
-the interfaces described here are subject to change without notice.
-This document is intended to cover the interfaces as found in the
-xorg-server-&xserver.version; release, but is probably not completely
-in sync with the code base.
- </para></note>
-
-
- <sect1>
- <title>Preface</title>
-
- <para>
-This document was originally the design spec for the DDX layer of the
-XFree86 4.0 X server. The X.Org Foundation adopted the XFree86 4.4rc2
-version of that server as the basis of the Xorg server project, and has
-evolved the XFree86 DDX layer greatly since forking. This document thus
-covers only the current implementation of the XFree86 DDX as found in the
-Xorg server &xserver.version; release, and no longer matches the XFree86
-server itself.
- </para>
-
- <para>
-The XFree86 Project's broad design principles for XFree86 4.0 were:
- <itemizedlist>
- <listitem><para>keep it reasonable
- <itemizedlist>
- <listitem><para>We cannot rewrite the complete server
- </para></listitem>
- <listitem><para>We don't want to re-invent the wheel
- </para></listitem>
- </itemizedlist></para></listitem>
- <listitem><para>keep it modular
- <itemizedlist>
- <listitem><para>As many things as possible should go into modules
- </para></listitem>
- <listitem><para>The basic loader binary should be minimal
- </para></listitem>
- <listitem><para>A clean design with well defined layering is
- important</para></listitem>
- <listitem><para>DDX specific global variables are a nono
- </para></listitem>
- <listitem><para>The structure should be flexible enough to allow
- future extensions</para></listitem>
- <listitem><para>The structure should minimize duplication of
- common code</para></listitem>
- </itemizedlist></para></listitem>
- <listitem><para>keep important features in mind
- <itemizedlist>
- <listitem><para>multiple screens, including multiple instances
- of drivers</para></listitem>
- <listitem><para>mixing different color depths and visuals on
- different and ideally even on the same screen
- </para></listitem>
- <listitem><para>better control of the PCI device used
- </para></listitem>
- <listitem><para>better config file parser</para></listitem>
- <listitem><para>get rid of all VGA compatibility assumptions
- </para></listitem>
- </itemizedlist></para></listitem>
- </itemizedlist>
- </para>
-
- <para>
-While the XFree86 project had a goal of avoiding changes to the DIX
-layer unless they found major deficiencies there, to avoid divergence from
-the X.Org sample implementation they were integrating changes from, the
-X.Org developers now maintain both sides, and make changes where they are
-most appropriate. This document concentrates on the XFree86 DDX layer used
-in the Xorg server itself (the code found in <filename>hw/xfree86</filename>
-in the source tree), and developers will also want to refer to the
-<filename>Xserver-spec</filename> documentation that covers the DIX layer
-routines common to all the X servers in the sample implementation.
- </para>
- </sect1>
-
- <sect1>
- <title>The xorg.conf File</title>
-
- <para>
-The xorg.conf file format is based on the XF86Config format from XFree86 4.4,
-which is in turn similar to the old XFree86 3.x XF86Config format, with the
-following changes:
- </para>
-
- <sect2>
- <title>&k.device; section</title>
-
- <para>
- The &k.device; sections are similar to what they used to be, and
- describe hardware-specific information for a single video card.
- &k.device;
- Some new keywords are added:
-
-
- <variablelist>
- <varlistentry><term>Driver "drivername"</term>
- <listitem><para>
- Specifies the name of the driver to be used for the card. This
- is mandatory.
- </para></listitem></varlistentry>
- <varlistentry><term>BusID "busslot"</term>
- <listitem><para>
- Specifies uniquely the location of the card on the bus. The
- purpose is to identify particular cards in a multi-headed
- configuration. The format of the argument is intentionally
- vague, and may be architecture dependent. For a PCI bus, it
- is something like "bus:slot:func".
- </para></listitem></varlistentry>
- </variablelist>
- </para>
-
- <para>
- A &k.device; section is considered <quote>active</quote> if there is a reference
- to it in an active &k.screen; section.
- </para>
- </sect2>
-
- <sect2>
- <title>&k.screen; section</title>
-
- <para>
- The &k.screen; sections are similar to what they used to be. They
- no longer have a &k.driver; keyword, but an &k.identifier; keyword
- is added. (The &k.driver; keyword may be accepted in place of the
- &k.identifier; keyword for compatibility purposes.) The identifier
- can be used to identify which screen is to be active when multiple
- &k.screen; sections are present. It is possible to specify the active
- screen from the command line. A default is chosen in the absence
- of one being specified. A &k.screen; section is considered <quote>active</quote>
- if there is a reference to it either from the command line, or from
- an active &k.serverlayout; section.
- </para>
- </sect2>
-
- <sect2>
- <title>&k.inputdevice; section</title>
-
- <para>
- The &k.inputdevice; section is a new section that describes
- configuration information for input devices. It replaces the old
- <emphasis>Keyboard</emphasis>, <emphasis>Pointer</emphasis> and <emphasis>XInput</emphasis>
- sections. Like the &k.device; section, it has two mandatory keywords:
- &k.identifier; and &k.driver;. For compatibility purposes the old
- <emphasis>Keyboard</emphasis> and <emphasis>Pointer</emphasis> sections are
- converted by the parser into &k.inputdevice; sections as follows:
-
- <variablelist>
- <varlistentry><term><emphasis>Keyboard</emphasis></term>
- <listitem><literallayout>
- &k.identifier; "Implicit Core Keyboard"
- &k.driver; "keyboard"
- </literallayout></listitem></varlistentry>
- <varlistentry><term><emphasis>Pointer</emphasis></term>
- <listitem><literallayout>
- &k.identifier; "Implicit Core Pointer"
- &k.driver; "mouse"
- </literallayout></listitem></varlistentry>
- </variablelist>
- </para>
-
- <para>
- An &k.inputdevice; section is considered active if there is a
- reference to it in an active &k.serverlayout; section. An
- &k.inputdevice; section may also be referenced implicitly if there
- is no &k.serverlayout; section, if the <option>-screen</option> command
- line options is used, or if the &k.serverlayout; section doesn't
- reference any &k.inputdevice; sections. In this case, the first
- sections with drivers "keyboard" and "mouse" are used as the core
- keyboard and pointer respectively.
- </para>
- </sect2>
-
- <sect2>
- <title>&k.serverlayout; section</title>
-
- <para>
- The &k.serverlayout; section is a new section that is used to identify
- which &k.screen; sections are to be used in a multi-headed configuration,
- and the relative layout of those screens. It also identifies which
- &k.inputdevice; sections are to be used. Each &k.serverlayout; section
- has an identifier, a list of &k.screen; section identifiers, and a list of
- &k.inputdevice; section identifiers. &k.serverflags; options may also be
- included in a &k.serverlayout; section, making it possible to override
- the global values in the &k.serverflags; section.
- </para>
-
- <para>
- A &k.serverlayout; section can be made active by being referenced on
- the command line. In the absence of this, a default will be chosen
- (the first one found). The screen names may optionally be followed
- by a number specifying the preferred screen number, and optionally
- by information specifying the physical positioning of the screen,
- either in absolute terms or relative to another screen (or screens).
- When no screen number is specified, they are numbered according to
- the order in which they are listed. The old (now obsolete) method
- of providing the positioning information is to give the names of
- the four adjacent screens. The order of these is top, bottom, left,
- right. Here is an example of a &k.serverlayout; section for two
- screens using the old method, with the second located to the right
- of the first:
-
- <programlisting>
- Section "ServerLayout"
- Identifier "Main Layout"
- Screen 0 "Screen 1" "" "" "" "Screen 2"
- Screen 1 "Screen 2"
- Screen "Screen 3"
- EndSection
- </programlisting>
- </para>
-
- <para>
- The preferred way of specifying the layout is to explicitly specify
- the screen's location in absolute terms or relative to another
- screen.
- </para>
-
- <para>
- In the absolute case, the upper left corner's coordinates are given
- after the <emphasis>Absolute</emphasis> keyword. If the coordinates are
- omitted, a value of <code>(0,0)</code> is assumed. An example
- of absolute positioning follows:
-
- <programlisting>
- Section "ServerLayout"
- Identifier "Main Layout"
- Screen 0 "Screen 1" Absolute 0 0
- Screen 1 "Screen 2" Absolute 1024 0
- Screen "Screen 3" Absolute 2048 0
- EndSection
- </programlisting>
- </para>
-
- <para>
- In the relative case, the position is specified by either using one of
- the following keywords followed by the name of the reference screen:
-
- <simplelist type='vert' columns='1'>
- <member><emphasis>RightOf</emphasis></member>
- <member><emphasis>LeftOf</emphasis></member>
- <member><emphasis>Above</emphasis></member>
- <member><emphasis>Below</emphasis></member>
- <member><emphasis>Relative</emphasis></member>
- </simplelist>
- </para>
-
- <para>
- When the <emphasis>Relative</emphasis> keyword is used, the reference screen
- name is followed by the coordinates of the new screen's origin
- relative to reference screen. The following example shows how to use
- some of the relative positioning options.
-
- <programlisting>
- Section "ServerLayout"
- Identifier "Main Layout"
- Screen 0 "Screen 1"
- Screen 1 "Screen 2" RightOf "Screen 1"
- Screen "Screen 3" Relative "Screen 1" 2048 0
- EndSection
- </programlisting>
- </para>
- </sect2>
-
- <sect2>
- <title>Options</title>
-
- <para>
- Options are used more extensively. They may appear in most sections
- now. Options related to drivers can be present in the &k.screen;,
- &k.device; and &k.monitor; sections and the &k.display; subsections.
- The order of precedence is &k.display;, &k.screen;, &k.monitor;,
- &k.device;. Options have been extended to allow an optional value
- to be specified in addition to the option name. For more details
- about options, see the <link linkend="options">Options</link> section
- for details.
- </para>
- </sect2>
- </sect1>
-
- <sect1>
- <title>Driver Interface</title>
-
- <para>
-The driver interface consists of a minimal set of entry points that are
-required based on the external events that the driver must react to.
-No non-essential structure is imposed on the way they are used beyond
-that. This is a significant difference compared with the old design.
- </para>
-
- <para>
-The entry points for drawing operations are already taken care of by
-the framebuffer code (including, XAA). Extensions and enhancements to
-framebuffer code are outside the scope of this document.
- </para>
-
- <para>
-This approach to the driver interface provides good flexibility, but does
-increase the complexity of drivers. To help address this, the XFree86
-common layer provides a set of <quote>helper</quote> functions to take care of things
-that most drivers need. These helpers help minimise the amount of code
-duplication between drivers. The use of helper functions by drivers is
-however optional, though encouraged. The basic philosophy behind the
-helper functions is that they should be useful to many drivers, that
-they should balance this against the complexity of their interface. It
-is inevitable that some drivers may find some helpers unsuitable and
-need to provide their own code.
- </para>
-
- <para>
-Events that a driver needs to react to are:
-
- <variablelist>
- <varlistentry><term>ScreenInit</term>
-
- <listitem><para>
- An initialisation function is called from the DIX layer for each
- screen at the start of each server generation.
- </para></listitem></varlistentry>
-
- <varlistentry><term>Enter VT</term>
-
- <listitem><para>
- The server takes control of the console.
- </para></listitem></varlistentry>
-
- <varlistentry><term>Leave VT</term>
-
- <listitem><para>
- The server releases control of the console.
- </para></listitem></varlistentry>
-
- <varlistentry><term>Mode Switch</term>
-
- <listitem><para>
- Change video mode.
- </para></listitem></varlistentry>
-
- <varlistentry><term>ViewPort change</term>
-
- <listitem><para>
- Change the origin of the physical view port.
- </para></listitem></varlistentry>
-
- <varlistentry><term>ScreenSaver state change</term>
-
- <listitem><para>
- Screen saver activation/deactivation.
- </para></listitem></varlistentry>
-
- <varlistentry><term>CloseScreen</term>
-
- <listitem><para>
- A close screen function is called from the DIX layer for each screen
- at the end of each server generation.
- </para></listitem></varlistentry>
- </variablelist>
- </para>
-
-
- <para>
-In addition to these events, the following functions are required by
-the XFree86 common layer:
-
- <variablelist>
- <varlistentry><term>Identify</term>
-
- <listitem><para>
- Print a driver identifying message.
- </para></listitem></varlistentry>
-
- <varlistentry><term>Probe</term>
-
- <listitem><para>
- This is how a driver identifies if there is any hardware present that
- it knows how to drive.
- </para></listitem></varlistentry>
-
- <varlistentry><term>PreInit</term>
-
- <listitem><para>
- Process information from the xorg.conf file, determine the
- full characteristics of the hardware, and determine if a valid
- configuration is present.
- </para></listitem></varlistentry>
- </variablelist>
- </para>
-
- <para>
-The VidMode extension also requires:
-
- <variablelist>
- <varlistentry><term>ValidMode</term>
-
- <listitem><para>
- Identify if a new mode is usable with the current configuration.
- The PreInit function (and/or helpers it calls) may also make use
- of the ValidMode function or something similar.
- </para></listitem></varlistentry>
- </variablelist>
- </para>
-
-
- <para>
-Other extensions may require other entry points. The drivers will
-inform the common layer of these in such cases.
- </para>
- </sect1>
-
- <sect1>
- <title>Resource Access Control Introduction</title>
-
- <para>
-Graphics devices are accessed through ranges in I/O or memory space.
-While most modern graphics devices allow relocation of such ranges many
-of them still require the use of well established interfaces such as
-VGA memory and IO ranges or 8514/A IO ranges. With modern buses (like
-PCI) it is possible for multiple video devices to share access to these
-resources. The RAC (Resource Access Control) subsystem provides a
-mechanism for this.
- </para>
-
- <sect2>
- <title>Terms and Definitions</title>
-
- <sect3>
- <title>Bus</title>
-
- <para>
- <quote>Bus</quote> is ambiguous as it is used for different things: it may refer
- to physical incompatible extension connectors in a computer system.
- The RAC system knows two such systems: The ISA bus and the PCI bus.
- (On the software level EISA, MCA and VL buses are currently treated
- like ISA buses). <quote>Bus</quote> may also refer to logically different
- entities on a single bus system which are connected via bridges. A
- PCI system may have several distinct PCI buses connecting each other
- by PCI-PCI bridges or to the host CPU by HOST-PCI bridges.
- </para>
-
- <para>
- Systems that host more than one bus system link these together using
- bridges. Bridges are a concern to RAC as they might block or pass
- specific resources. PCI-PCI bridges may be set up to pass VGA
- resources to the secondary bus. PCI-ISA buses pass any resources not
- decoded on the primary PCI bus to the ISA bus. This way VGA resources
- (although exclusive on the ISA bus) can be shared by ISA and PCI
- cards. Currently HOST-PCI bridges are not yet handled by RAC as they
- require specific drivers.
- </para>
- </sect3>
-
- <sect3>
- <title>Entity</title>
-
- <para>
- The smallest independently addressable unit on a system bus is
- referred to as an entity. So far we know ISA and PCI entities. PCI
- entities can be located on the PCI bus by an unique ID consisting of
- the bus, card and function number.
- </para>
- </sect3>
-
- <sect3>
- <title>Resource</title>
-
- <para>
- <quote>Resource</quote> refers to a range of memory or I/O addresses an entity
- can decode.
- </para>
-
- <para>
- If a device is capable of disabling this decoding the resource is
- called sharable. For PCI devices a generic method is provided to
- control resource decoding. Other devices will have to provide a
- device specific function to control decoding.
- </para>
-
- <para>
- If the entity is capable of decoding this range at a different
- location this resource is considered relocatable.
- </para>
-
- <para>
- Resources which start at a specific address and occupy a single
- continuous range are called block resources.
- </para>
-
- <para>
- Alternatively resource addresses can be decoded in a way that they
- satisfy the conditions:
- <programlisting>
- address &amp; mask == base
- </programlisting>
- and
- <programlisting>
- base &amp; mask == base
- </programlisting>
- Resources addressed in such a way are called sparse resources.
- </para>
-
- </sect3>
-
- <sect3>
- <title>Server States</title>
-
- <para>
- The resource access control system knows two server states: the
- SETUP and the OPERATING state. The SETUP state is entered whenever
- a mode change takes place or the server exits or does VT switching.
- During this state all entity resources are under resource access
- control. During OPERATING state only those entities are controlled
- which actually have shared resources that conflict with others.
- </para>
- </sect3>
- </sect2>
- </sect1>
-
- <sect1>
- <title>Control Flow in the Server and Mandatory Driver Functions</title>
-
- <para>
-At the start of each server generation, <function>main()</function>
-(<filename>dix/main.c</filename>) calls the DDX function
-<function>InitOutput()</function>. This is the first place that the DDX gets
-control. <function>InitOutput()</function> is expected to fill in the global
-<structname>screenInfo</structname> struct, and one
-<structfield>screenInfo.screen[]</structfield> entry for each screen present.
-Here is what <function>InitOutput()</function> does:
- </para>
-
- <sect2>
- <title>Parse the xorg.conf file</title>
-
- <para>
- This is done at the start of the first server generation only.
- </para>
-
- <para>
- The xorg.conf file is read in full, and the resulting information
- stored in data structures. None of the parsed information is
- processed at this point. The parser data structures are opaque to
- the video drivers and to most of the common layer code.
- </para>
-
- <para>
- The entire file is parsed first to remove any section ordering
- requirements.
- </para>
- </sect2>
-
-
- <sect2>
- <title>Initial processing of parsed information and command line options
- </title>
-
- <para>
- This is done at the start of the first server generation only.
- </para>
-
- <para>
- The initial processing is to determine paths like the
- <emphasis>ModulePath</emphasis>, etc, and to determine which &k.serverlayout;,
- &k.screen; and &k.device; sections are active.
- </para>
- </sect2>
-
-
- <sect2>
- <title>Enable port I/O access</title>
-
- <para>
- Port I/O access is controlled from the XFree86 common layer, and is
- <quote>all or nothing</quote>. It is enabled prior to calling driver probes, at
- the start of subsequent server generations, and when VT switching
- back to the Xserver. It is disabled at the end of server generations,
- and when VT switching away from the Xserver.
- </para>
-
- <para>
- The implementation details of this may vary on different platforms.
- </para>
- </sect2>
-
-
- <sect2>
- <title>General bus probe</title>
-
- <para>
- This is done at the start of the first server generation only.
- </para>
-
- <para>
- In the case of ix86 machines, this will be a general PCI probe.
- The full information obtained here will be available to the drivers.
- This information persists for the life of the Xserver. In the PCI
- case, the PCI information for all video cards found is available by
- calling <function>xf86GetPciVideoInfo()</function>.
- </para>
-
- <blockquote><para>
- <programlisting>
- pciVideoPtr *xf86GetPciVideoInfo(void);
- </programlisting>
- <blockquote><para>
- returns a pointer to a list of pointers to
- <structname>pciVideoRec</structname> entries, of which there is one for
- each detected PCI video card. The list is terminated with a
- <constant>NULL</constant> pointer. If no PCI video cards were
- detected, the return value is <constant>NULL</constant>.
-
- </para></blockquote>
- </para></blockquote>
-
- <para>
- After the bus probe, the resource broker is initialised.
- </para>
- </sect2>
-
-
- <sect2>
- <title>Load initial set of modules</title>
-
- <para>
- This is done at the start of the first server generation only.
- </para>
-
- <para>
- The core server contains a list of mandatory modules. These are loaded
- first. Currently the only module on this list is the bitmap font module.
- </para>
-
- <para>
- The next set of modules loaded are those specified explicitly in the
- &k.module; section of the config file.
- </para>
-
- <para>
- The final set of initial modules are the driver modules referenced
- by the active &k.device; and &k.inputdevice; sections in the config
- file. Each of these modules is loaded exactly once.
- </para>
- </sect2>
-
-
- <sect2>
- <title>Register Video and Input Drivers</title>
-
- <para>
- This is done at the start of the first server generation only.
- </para>
-
- <para>
- When a driver module is loaded, the loader calls its
- <function>Setup</function> function. For video drivers, this function
- calls <function>xf86AddDriver()</function> to register the driver's
- <structname>DriverRec</structname>, which contains a small set of essential
- details and driver entry points required during the early phase of
- <function>InitOutput()</function>. <function>xf86AddDriver()</function>
- adds it to the global <varname>xf86DriverList[]</varname> array.
- </para>
-
- <para>
- The <structname>DriverRec</structname> contains the driver canonical name,
- the <function>Identify()</function>,
- <function>Probe()</function> and <function>AvailableOptions()</function>
- function entry points as well as a pointer
- to the driver's module (as returned from the loader when the driver
- was loaded) and a reference count which keeps track of how many
- screens are using the driver. The entry driver entry points are
- those required prior to the driver allocating and filling in its
- <structname>ScrnInfoRec</structname>.
- </para>
-
- <para>
- For a static server, the <varname>xf86DriverList[]</varname> array is
- initialised at build time, and the loading of modules is not done.
- </para>
-
- <para>
- A similar procedure is used for input drivers. The input driver's
- <function>Setup</function> function calls
- <function>xf86AddInputDriver()</function> to register the driver's
- <structname>InputDriverRec</structname>, which contains a small set of
- essential details and driver entry points required during the early
- phase of <function>InitInput()</function>.
- <function>xf86AddInputDriver()</function> adds it to the global
- <varname>xf86InputDriverList[]</varname> array. For a static server,
- the <varname>xf86InputDriverList[]</varname> array is initialised at
- build time.
- </para>
-
- <para>
- Both the <varname>xf86DriverList[]</varname> and
- <varname>xf86InputDriverList[]</varname> arrays have been initialised
- by the end of this stage.
- </para>
-
- <para>
- Once all the drivers are registered, their
- <function>ChipIdentify()</function> functions are called.
- </para>
-
- <blockquote><para>
- <programlisting>
- void ChipIdentify(int flags);
- </programlisting>
- <blockquote><para>
- This is expected to print a message indicating the driver name,
- a short summary of what it supports, and a list of the chipset
- names that it supports. It may use the xf86PrintChipsets() helper
- to do this.
- </para></blockquote>
- </para></blockquote>
-
- <blockquote><para>
- <programlisting>
- void xf86PrintChipsets(const char *drvname, const char *drvmsg,
- SymTabPtr chips);
- </programlisting>
- <blockquote><para>
- This function provides an easy way for a driver's ChipIdentify
- function to format the identification message.
- </para></blockquote>
- </para></blockquote>
- </sect2>
-
- <sect2>
- <title>Initialise Access Control</title>
-
- <para>
- This is done at the start of the first server generation only.
- </para>
-
- <para>
- The Resource Access Control (RAC) subsystem is initialised before
- calling any driver functions that may access hardware. All generic
- bus information is probed and saved (for restoration later). All
- (shared resource) video devices are disabled at the generic bus
- level, and a probe is done to find the <quote>primary</quote> video device. These
- devices remain disabled for the next step.
- </para>
- </sect2>
-
-
- <sect2 id="probe">
- <title>Video Driver Probe</title>
-
- <para>
- This is done at the start of the first server generation only. The
- <function>ChipProbe()</function> function of each registered video driver
- is called.
- </para>
-
- <blockquote><para>
- <programlisting>
- Bool ChipProbe(DriverPtr drv, int flags);
- </programlisting>
- <blockquote><para>
- The purpose of this is to identify all instances of hardware
- supported by the driver. The flags value is currently either 0,
- <constant>PROBE_DEFAULT</constant> or <constant>PROBE_DETECT</constant>.
- <constant>PROBE_DETECT</constant> is used if "-configure" or "-probe"
- command line arguments are given and indicates to the
- <function>Probe()</function> function that it should not configure the
- bus entities and that no xorg.conf information is available.
- </para>
-
- <para>
- The probe must find the active device sections that match the
- driver by calling <function>xf86MatchDevice()</function>. The number
- of matches found limits the maximum number of instances for this
- driver. If no matches are found, the function should return
- <constant>FALSE</constant> immediately.
- </para>
-
- <para>
- Devices that cannot be identified by using device-independent
- methods should be probed at this stage (keeping in mind that access
- to all resources that can be disabled in a device-independent way
- are disabled during this phase). The probe must be a minimal
- probe. It should just determine if there is a card present that
- the driver can drive. It should use the least intrusive probe
- methods possible. It must not do anything that is not essential,
- like probing for other details such as the amount of memory
- installed, etc. It is recommended that the
- <function>xf86MatchPciInstances()</function> helper function be used
- for identifying matching PCI devices, and similarly the
- <function>xf86MatchIsaInstances()</function> for ISA (non-PCI) devices
- (see the <link linkend="rac">RAC</link> section). These helpers also
- checks and claims the appropriate entity. When not using the
- helper, that should be done with <function>xf86CheckPciSlot()</function>
- and <function>xf86ClaimPciSlot()</function> for PCI devices and
- <function>xf86ClaimIsaSlot()</function> for ISA devices (see the
- <link linkend="rac">RAC</link> section).
- </para>
-
- <para>
- The probe must register all non-relocatable resources at this
- stage. If a resource conflict is found between exclusive resources
- the driver will fail immediately. This is usually best done with
- the <function>xf86ConfigPciEntity()</function> helper function
- for PCI and <function>xf86ConfigIsaEntity()</function> for ISA
- (see the <link linkend="rac">RAC</link> section). It is possible to
- register some entity specific functions with those helpers. When
- not using the helpers, the <function>xf86AddEntityToScreen()</function>
- <function>xf86ClaimFixedResources()</function> and
- <function>xf86SetEntityFuncs()</function> should be used instead (see
- the <link linkend="rac">RAC</link> section).
- </para>
-
- <para>
- If a chipset is specified in an active device section which the
- driver considers relevant (ie it has no driver specified, or the
- driver specified matches the driver doing the probe), the Probe
- must return <constant>FALSE</constant> if the chipset doesn't match
- one supported by the driver.
- </para>
-
- <para>
- If there are no active device sections that the driver considers
- relevant, it must return <constant>FALSE</constant>.
- </para>
-
- <para>
- Allocate a <structname>ScrnInfoRec</structname> for each active instance of the
- hardware found, and fill in the basic information, including the
- other driver entry points. This is best done with the
- <function>xf86ConfigIsaEntity()</function> helper function for ISA
- instances or <function>xf86ConfigPciEntity()</function> for PCI instances.
- These functions allocate a <structname>ScrnInfoRec</structname> for active
- entities. Optionally <function>xf86AllocateScreen()</function>
- function may also be used to allocate the <structname>ScrnInfoRec</structname>.
- Any of these functions take care of initialising fields to defined
- <quote>unused</quote> values.
- </para>
-
- <para>
- Claim the entities for each instance of the hardware found. This
- prevents other drivers from claiming the same hardware.
- </para>
-
- <para>
- Must leave hardware in the same state it found it in, and must not
- do any hardware initialisation.
- </para>
-
- <para>
- All detection can be overridden via the config file, and that
- parsed information is available to the driver at this stage.
- </para>
-
- <para>
- Returns <constant>TRUE</constant> if one or more instances are found,
- and <constant>FALSE</constant> otherwise.
- </para>
-
- </blockquote></para></blockquote>
-
- <blockquote><para>
- <programlisting>
- int xf86MatchDevice(const char *drivername,
- GDevPtr **driversectlist)
- </programlisting>
- <blockquote><para>
- This function takes the name of the driver and returns via
- <parameter>driversectlist</parameter> a list of device sections that
- match the driver name. The function return value is the number
- of matches found. If a fatal error is encountered the return
- value is <literal>-1</literal>.
- </para>
-
- <para>
- The caller should use <function>xfree()</function> to free
- <parameter>*driversectlist</parameter> when it is no longer needed.
- </para>
-
- </blockquote></para></blockquote>
-
- <blockquote><para>
- <programlisting>
- ScrnInfoPtr xf86AllocateScreen(DriverPtr drv, int flags)
- </programlisting>
- <blockquote><para>
- This function allocates a new <structname>ScrnInfoRec</structname> in the
- <varname>xf86Screens[]</varname> array. This function is normally
- called by the video driver <function>ChipProbe()</function> functions.
- The return value is a pointer to the newly allocated
- <structname>ScrnInfoRec</structname>. The <structfield>scrnIndex</structfield>,
- <structfield>origIndex</structfield>, <structfield>module</structfield> and
- <structfield>drv</structfield> fields are initialised. The reference count
- in <parameter>drv</parameter> is incremented. The storage for any
- currently allocated <quote>privates</quote> pointers is also allocated and
- the <structfield>privates</structfield> field initialised (the privates data
- is of course not allocated or initialised). This function never
- returns on failure. If the allocation fails, the server exits
- with a fatal error. The flags value is not currently used, and
- should be set to zero.
- </para></blockquote>
- </para></blockquote>
-
- <para>
- At the completion of this, a list of <structname>ScrnInfoRecs</structname>
- have been allocated in the <varname>xf86Screens[]</varname> array, and
- the associated entities and fixed resources have been claimed. The
- following <structname>ScrnInfoRec</structname> fields must be initialised at
- this point:
-
- <literallayout>
- driverVersion
- driverName
- scrnIndex(*)
- origIndex(*)
- drv(*)
- module(*)
- name
- Probe
- PreInit
- ScreenInit
- EnterVT
- LeaveVT
- numEntities
- entityList
- access
- </literallayout>
-
- <literal>(*)</literal> These are initialised when the <structname>ScrnInfoRec</structname>
- is allocated, and not explicitly by the driver.
- </para>
-
- <para>
- The following <structname>ScrnInfoRec</structname> fields must be initialised
- if the driver is going to use them:
-
- <literallayout>
- SwitchMode
- AdjustFrame
- FreeScreen
- ValidMode
- </literallayout>
- </para>
- </sect2>
-
- <sect2>
- <title>Matching Screens</title>
-
- <para>
- This is done at the start of the first server generation only.
- </para>
-
- <para>
- After the Probe phase is finished, there will be some number of
- <structname>ScrnInfoRec</structname>s. These are then matched with the active
- &k.screen; sections in the xorg.conf, and those not having an active
- &k.screen; section are deleted. If the number of remaining screens
- is 0, <function>InitOutput()</function> sets
- <structfield>screenInfo.numScreens</structfield> to <constant>0</constant> and
- returns.
- </para>
-
- <para>
- At this point the following fields of the <structname>ScrnInfoRec</structname>s
- must be initialised:
-
- <literallayout>
- confScreen
- </literallayout>
- </para>
-
- </sect2>
-
- <sect2>
- <title>Allocate non-conflicting resources</title>
-
- <para>
- This is done at the start of the first server generation only.
- </para>
-
- <para>
- Before calling the drivers again, the resource information collected
- from the Probe phase is processed. This includes checking the extent
- of PCI resources for the probed devices, and resolving any conflicts
- in the relocatable PCI resources. It also reports conflicts, checks
- bus routing issues, and anything else that is needed to enable the
- entities for the next phase.
- </para>
-
- <para>
- If any drivers registered an <function>EntityInit()</function> function
- during the Probe phase, then they are called here.
- </para>
-
- </sect2>
-
- <sect2>
- <title>Sort the Screens and pre-check Monitor Information</title>
-
- <para>
- This is done at the start of the first server generation only.
- </para>
-
- <para>
- The list of screens is sorted to match the ordering requested in the
- config file.
- </para>
-
- <para>
- The list of modes for each active monitor is checked against the
- monitor's parameters. Invalid modes are pruned.
- </para>
-
- </sect2>
-
- <sect2>
- <title>PreInit</title>
-
- <para>
- This is done at the start of the first server generation only.
- </para>
-
- <para>
- For each <structname>ScrnInfoRec</structname>, enable access to the screens entities and call
- the <function>ChipPreInit()</function> function.
- </para>
-
- <blockquote><para>
- <programlisting>
- Bool ChipPreInit(ScrnInfoRec screen, int flags);
- </programlisting>
- <blockquote><para>
- The purpose of this function is to find out all the information
- required to determine if the configuration is usable, and to
- initialise those parts of the <structname>ScrnInfoRec</structname> that
- can be set once at the beginning of the first server generation.
- </para>
-
- <para>
- The number of entities registered for the screen should be checked
- against the expected number (most drivers expect only one). The
- entity information for each of them should be retrieved (with
- <function>xf86GetEntityInfo()</function>) and checked for the correct
- bus type and that none of the sharable resources registered during
- the Probe phase was rejected.
- </para>
-
- <para>
- Access to resources for the entities that can be controlled in a
- device-independent way are enabled before this function is called.
- If the driver needs to access any resources that it has disabled
- in an <function>EntityInit()</function> function that it registered,
- then it may enable them here providing that it disables them before
- this function returns.
- </para>
-
- <para>
- This includes probing for video memory, clocks, ramdac, and all
- other HW info that is needed. It includes determining the
- depth/bpp/visual and related info. It includes validating and
- determining the set of video modes that will be used (and anything
- that is required to determine that).
- </para>
-
- <para>
- This information should be determined in the least intrusive way
- possible. The state of the HW must remain unchanged by this
- function. Although video memory (including MMIO) may be mapped
- within this function, it must be unmapped before returning. Driver
- specific information should be stored in a structure hooked into
- the <structname>ScrnInfoRec</structname>'s <structfield>driverPrivate</structfield>
- field. Any other modules which require persistent data (ie data
- that persists across server generations) should be initialised in
- this function, and they should allocate a <quote>privates</quote> index to
- hook their data into by calling
- <function>xf86AllocateScrnInfoPrivateIndex()</function>. The <quote>privates</quote>
- data is persistent.
- </para>
-
- <para>
- Helper functions for some of these things are provided at the
- XFree86 common level, and the driver can choose to make use of
- them.
- </para>
-
- <para>
- All additional resources that the screen needs must be registered
- here. This should be done with
- <function>xf86RegisterResources()</function>. If some of the fixed
- resources registered in the Probe phase are not needed or not
- decoded by the hardware when in the OPERATING server state, their
- status should be updated with
- <function>xf86SetOperatingState()</function>.
- </para>
-
- <para>
- Modules may be loaded at any point in this function, and all
- modules that the driver will need must be loaded before the end
- of this function. Either the <function>xf86LoadSubModule()</function>
- or the <function>xf86LoadDrvSubModule()</function> function should be
- used to load modules depending on whether a
- <structname>ScrnInfoRec</structname> has been set up. A driver may unload
- a module within this function if it was only needed temporarily,
- and the <function>xf86UnloadSubModule()</function> function should be used
- to do that. Otherwise there is no need to explicitly unload modules
- because the loader takes care of module dependencies and will
- unload submodules automatically if/when the driver module is
- unloaded.
- </para>
-
- <para>
- The bulk of the <structname>ScrnInfoRec</structname> fields should be filled
- out in this function.
- </para>
-
- <para>
- <function>ChipPreInit()</function> returns <constant>FALSE</constant> when
- the configuration is unusable in some way (unsupported depth, no
- valid modes, not enough video memory, etc), and <constant>TRUE</constant>
- if it is usable.
- </para>
-
- <para>
- It is expected that if the <function>ChipPreInit()</function> function
- returns <constant>TRUE</constant>, then the only reasons that subsequent
- stages in the driver might fail are lack or resources (like xalloc
- failures). All other possible reasons for failure should be
- determined by the <function>ChipPreInit()</function> function.
- </para></blockquote>
- </para></blockquote>
-
- <para>
- The <structname>ScrnInfoRec</structname>s for screens where the <function>ChipPreInit()</function> fails are removed.
- If none remain, <function>InitOutput()</function> sets <structfield>screenInfo.numScreens</structfield> to <constant>0</constant> and returns.
- </para>
-
- <para>
- At this point, further fields of the <structname>ScrnInfoRec</structname>s would normally be
- filled in. Most are not strictly mandatory, but many are required
- by other layers and/or helper functions that the driver may choose
- to use. The documentation for those layers and helper functions
- indicates which they require.
- </para>
-
- <para>
- The following fields of the <structname>ScrnInfoRec</structname>s should be filled in if the
- driver is going to use them:
-
- <literallayout>
- monitor
- display
- depth
- pixmapBPP
- bitsPerPixel
- weight (&gt;8bpp only)
- mask (&gt;8bpp only)
- offset (&gt;8bpp only)
- rgbBits (8bpp only)
- gamma
- defaultVisual
- maxHValue
- maxVValue
- virtualX
- virtualY
- displayWidth
- frameX0
- frameY0
- frameX1
- frameY1
- zoomLocked
- modePool
- modes
- currentMode
- progClock (TRUE if clock is programmable)
- chipset
- ramdac
- clockchip
- numClocks (if not programmable)
- clock[] (if not programmable)
- videoRam
- biosBase
- memBase
- memClk
- driverPrivate
- chipID
- chipRev
- </literallayout>
- </para>
-
- <blockquote><para>
- <programlisting>
- pointer xf86LoadSubModule(ScrnInfoPtr pScrn, const char *name);
- and
- pointer xf86LoadDrvSubModule(DriverPtr drv, const char *name);
- </programlisting>
- <blockquote><para>
- Load a module that a driver depends on. This function loads the
- module <parameter>name</parameter> as a sub module of the driver. The
- return value is a handle identifying the new module. If the load
- fails, the return value will be <constant>NULL</constant>. If a driver
- needs to explicitly unload a module it has loaded in this way,
- the return value must be saved and passed to
- <function>xf86UnloadSubModule()</function> when unloading.
-
- </para></blockquote>
- </para></blockquote>
-
- <blockquote><para>
- <programlisting>
- void xf86UnloadSubModule(pointer module);
- </programlisting>
- <blockquote><para>
- Unloads the module referenced by <parameter>module</parameter>.
- <parameter>module</parameter> should be a pointer returned previously
- by <function>xf86LoadSubModule()</function> or
- <function>xf86LoadDrvSubModule()</function> .
-
- </para></blockquote>
- </para></blockquote>
- </sect2>
-
- <sect2>
- <title>Cleaning up Unused Drivers</title>
-
- <para>
- At this point it is known which screens will be in use, and which
- drivers are being used. Unreferenced drivers (and modules they
- may have loaded) are unloaded here.
- </para>
-
- </sect2>
-
- <sect2>
- <title>Consistency Checks</title>
-
- <para>
- The parameters that must be global to the server, like pixmap formats,
- bitmap bit order, bitmap scanline unit and image byte order are
- compared for each of the screens. If a mismatch is found, the server
- exits with an appropriate message.
- </para>
-
- </sect2>
-
- <sect2>
- <title>Check if Resource Control is Needed</title>
-
- <para>
- Determine if resource access control is needed. This is the case
- if more than one screen is used. If necessary the RAC wrapper module
- is loaded.
- </para>
- </sect2>
-
- <sect2>
- <title>AddScreen (ScreenInit)</title>
-
- <para>
- At this point, the valid screens are known.
- <function>AddScreen()</function> is called for each of them, passing
- <function>ChipScreenInit()</function> as the argument.
- <function>AddScreen()</function> is a DIX function that allocates a new
- <structfield>screenInfo.screen[]</structfield> entry (aka
- <varname>pScreen</varname>), and does some basic initialisation of it.
- It then calls the <function>ChipScreenInit()</function> function, with
- <parameter>pScreen</parameter> as one of its arguments. If
- <function>ChipScreenInit()</function> returns <constant>FALSE</constant>,
- <function>AddScreen()</function> returns <constant>-1</constant>. Otherwise
- it returns the index of the screen. <function>AddScreen()</function>
- should only fail because of programming errors or failure to allocate
- resources (like memory). All configuration problems should be
- detected BEFORE this point.
- </para>
-
- <blockquote><para>
- <programlisting>
- Bool ChipScreenInit(int index, ScreenPtr pScreen,
- int argc, char **argv);
- </programlisting>
- <blockquote><para>
- This is called at the start of each server generation.
- </para>
-
- <para>
- Fill in all of <parameter>pScreen</parameter>, possibly doing some of
- this by calling ScreenInit functions from other layers like mi,
- framebuffers (cfb, etc), and extensions.
- </para>
-
- <para>
- Decide which operations need to be placed under resource access
- control. The classes of operations are the frame buffer operations
- (<constant>RAC_FB</constant>), the pointer operations
- (<constant>RAC_CURSOR</constant>), the viewport change operations
- (<constant>RAC_VIEWPORT</constant>) and the colormap operations
- (<constant>RAC_COLORMAP</constant>). Any operation that requires
- resources which might be disabled during OPERATING state should
- be set to use RAC. This can be specified separately for memory
- and IO resources (the <structfield>racMemFlags</structfield> and
- <structfield>racIoFlags</structfield> fields of the <structname>ScrnInfoRec</structname>
- respectively).
- </para>
-
- <para>
- Map any video memory or other memory regions.
- </para>
-
- <para>
- Save the video card state. Enough state must be saved so that
- the original state can later be restored.
- </para>
-
- <para>
- Initialise the initial video mode. The <structname>ScrnInfoRec</structname>'s
- <structfield>vtSema</structfield> field should be set to <constant>TRUE</constant>
- just prior to changing the video hardware's state.
-
- </para></blockquote>
- </para></blockquote>
-
-
- <para>
- The <function>ChipScreenInit()</function> function (or functions from other
- layers that it calls) should allocate entries in the
- <structname>ScreenRec</structname>'s <structfield>devPrivates</structfield> area by
- calling <function>AllocateScreenPrivateIndex()</function> if it needs
- per-generation storage. Since the <structname>ScreenRec</structname>'s
- <structfield>devPrivates</structfield> information is cleared for each server
- generation, this is the correct place to initialise it.
- </para>
-
- <para>
- After <function>AddScreen()</function> has successfully returned, the
- following <structname>ScrnInfoRec</structname> fields are initialised:
-
- <literallayout>
- pScreen
- racMemFlags
- racIoFlags
- </literallayout>
- </para>
-
- <para>
- The <function>ChipScreenInit()</function> function should initialise the
- <structfield>CloseScreen</structfield> and <structfield>SaveScreen</structfield> fields
- of <parameter>pScreen</parameter>. The old value of
- <structfield>pScreen-&gt;CloseScreen</structfield> should be saved as part of
- the driver's per-screen private data, allowing it to be called from
- <function>ChipCloseScreen()</function>. This means that the existing
- <function>CloseScreen()</function> function is wrapped.
- </para>
- </sect2>
-
- <sect2>
- <title>Finalising RAC Initialisation</title>
-
- <para>
- After all the <function>ChipScreenInit()</function> functions have been
- called, each screen has registered its RAC requirements. This
- information is used to determine which shared resources are requested
- by more than one driver and set the access functions accordingly.
- This is done following these rules:
-
- <orderedlist>
- <listitem><para>
- The sharable resources registered by each entity are compared.
- If a resource is registered by more than one entity the entity
- will be marked to indicate that it needs to share this resources
- type (IO or MEM).
- </para></listitem>
-
- <listitem><para>
- A resource marked <quote>disabled</quote> during OPERATING state will be
- ignored entirely.
- </para></listitem>
-
- <listitem><para>
- A resource marked <quote>unused</quote> will only conflict with an overlapping
- resource of an other entity if the second is actually in use
- during OPERATING state.
- </para></listitem>
-
- <listitem><para>
- If an <quote>unused</quote> resource was found to conflict but the entity
- does not use any other resource of this type the entire resource
- type will be disabled for that entity.
- </para></listitem>
- </orderedlist>
- </para>
-
- </sect2>
-
- <sect2>
- <title>Finishing InitOutput()</title>
-
- <para>
- At this point <function>InitOutput()</function> is finished, and all the
- screens have been setup in their initial video mode.
- </para>
-
- </sect2>
-
- <sect2>
- <title>Mode Switching</title>
-
- <para>
- When a SwitchMode event is received, <function>ChipSwitchMode()</function>
- is called (when it exists):
- </para>
-
- <blockquote><para>
- <programlisting>
- Bool ChipSwitchMode(int index, DisplayModePtr mode, int flags);
- </programlisting>
- <blockquote><para>
- Initialises the new mode for the screen identified by
- <parameter>index;</parameter>. The viewport may need to be adjusted
- also.
-
- </para></blockquote>
- </para></blockquote>
-
- </sect2>
-
- <sect2>
- <title>Changing Viewport</title>
-
- <para>
- When a Change Viewport event is received,
- <function>ChipAdjustFrame()</function> is called (when it exists):
- </para>
-
- <blockquote><para>
- <programlisting>
- void ChipAdjustFrame(int index, int x, int y, int flags);
- </programlisting>
- <blockquote><para>
- Changes the viewport for the screen identified by
- <parameter>index;</parameter>.
- </para>
-
- <para>
- It should be noted that many chipsets impose restrictions on where the
- viewport may be placed in the virtual resolution, either for alignment
- reasons, or to prevent the start of the viewport from being positioned
- within a pixel (as can happen in a 24bpp mode). After calculating the
- value the chipset's panning registers need to be set to for non-DGA
- modes, this function should recalculate the ScrnInfoRec's
- <structfield>frameX0</structfield>, <structfield>frameY0</structfield>, <structfield>frameX1</structfield>
- and <structfield>frameY1</structfield> fields to correspond to that value. If
- this is not done, switching to another mode might cause the position
- of a hardware cursor to change.
-
- </para></blockquote>
- </para></blockquote>
-
- </sect2>
-
- <sect2>
- <title>VT Switching</title>
-
- <para>
- When a VT switch event is received, <function>xf86VTSwitch()</function>
- is called. <function>xf86VTSwitch()</function> does the following:
-
- <variablelist>
- <varlistentry><term>On ENTER:</term>
- <listitem>
- <itemizedlist>
- <listitem><para>
- enable port I/O access
- </para></listitem>
-
- <listitem><para>
- save and initialise the bus/resource state
- </para></listitem>
-
- <listitem><para>
- enter the SETUP server state
- </para></listitem>
-
- <listitem><para>
- calls <function>ChipEnterVT()</function> for each screen
- </para></listitem>
-
- <listitem><para>
- enter the OPERATING server state
- </para></listitem>
-
- <listitem><para>
- validate GCs
- </para></listitem>
-
- <listitem><para>
- Restore fb from saved pixmap for each screen
- </para></listitem>
-
- <listitem><para>
- Enable all input devices
- </para></listitem>
- </itemizedlist>
- </listitem>
- </varlistentry>
- <varlistentry>
- <term>On LEAVE:</term>
- <listitem>
- <itemizedlist>
- <listitem><para>
- Save fb to pixmap for each screen
- </para></listitem>
-
- <listitem><para>
- validate GCs
- </para></listitem>
-
- <listitem><para>
- enter the SETUP server state
- </para></listitem>
-
- <listitem><para>
- calls <function>ChipLeaveVT()</function> for each screen
- </para></listitem>
-
- <listitem><para>
- disable all input devices
- </para></listitem>
-
- <listitem><para>
- restore bus/resource state
- </para></listitem>
-
- <listitem><para>
- disables port I/O access
- </para></listitem>
- </itemizedlist>
- </listitem>
- </varlistentry>
- </variablelist>
- </para>
-
- <blockquote><para>
- <programlisting>
- Bool ChipEnterVT(int index, int flags);
- </programlisting>
- <blockquote><para>
- This function should initialise the current video mode and
- initialise the viewport, turn on the HW cursor if appropriate,
- etc.
- </para>
-
- <para>
- Should it re-save the video state before initialising the video
- mode?
- </para>
-
- </blockquote></para></blockquote>
-
- <blockquote><para>
- <programlisting>
- void ChipLeaveVT(int index, int flags);
- </programlisting>
- <blockquote><para>
- This function should restore the saved video state. If
- appropriate it should also turn off the HW cursor, and invalidate
- any pixmap/font caches.
- </para>
-
- </blockquote></para></blockquote>
-
- <para>
- Optionally, <function>ChipLeaveVT()</function> may also unmap memory
- regions. If so, <function>ChipEnterVT()</function> will need to remap
- them. Additionally, if an aperture used to access video memory is
- unmapped and remapped in this fashion, <function>ChipEnterVT()</function>
- will also need to notify the framebuffer layers of the aperture's new
- location in virtual memory. This is done with a call to the screen's
- <function>ModifyPixmapHeader()</function> function, as follows
- </para>
-
- <blockquote><para>
- <programlisting>
- (*pScreen-&gt;ModifyPixmapHeader)(pScrn-&gt;ppix,
- -1, -1, -1, -1, -1, NewApertureAddress);
- </programlisting>
- <blockquote><para>
- where the <structfield>ppix</structfield> field in a ScrnInfoRec
- points to the pixmap used by the screen's
- <function>SaveRestoreImage()</function> function to hold the screen's
- contents while switched out.
- </para>
-
- </blockquote></para></blockquote>
-
- <para>
- Other layers may wrap the <function>ChipEnterVT()</function> and
- <function>ChipLeaveVT()</function> functions if they need to take some
- action when these events are received.
- </para>
- </sect2>
-
- <sect2>
- <title>End of server generation</title>
-
- <para>
- At the end of each server generation, the DIX layer calls
- <function>ChipCloseScreen()</function> for each screen:
- </para>
-
- <blockquote><para>
- <programlisting>
- Bool ChipCloseScreen(int index, ScreenPtr pScreen);
- </programlisting>
- <blockquote><para>
- This function should restore the saved video state and unmap the
- memory regions.
- </para>
-
- <para>
- It should also free per-screen data structures allocated by the
- driver. Note that the persistent data held in the
- <structname>ScrnInfoRec</structname>'s <structfield>driverPrivate</structfield> field
- should not be freed here because it is needed by subsequent server
- generations.
- </para>
-
- <para>
- The <structname>ScrnInfoRec</structname>'s <structfield>vtSema</structfield> field
- should be set to <constant>FALSE</constant> once the video HW state
- has been restored.
- </para>
-
- <para>
- Before freeing the per-screen driver data the saved
- <structfield>CloseScreen</structfield> value should be restored to
- <structfield>pScreen-&gt;CloseScreen</structfield>, and that function should
- be called after freeing the data.
-
- </para></blockquote>
- </para></blockquote>
- </sect2>
- </sect1>
-
- <sect1>
- <title>Optional Driver Functions</title>
-
- <para>
-The functions outlined here can be called from the XFree86 common layer,
-but their presence is optional.
- </para>
-
- <sect2>
- <title>Mode Validation</title>
-
- <para>
- When a mode validation helper supplied by the XFree86-common layer is
- being used, it can be useful to provide a function to check for hw
- specific mode constraints:
- </para>
-
- <blockquote><para>
- <programlisting>
- ModeStatus ChipValidMode(int index, DisplayModePtr mode,
- Bool verbose, int flags);
- </programlisting>
- <blockquote><para>
- Check the passed mode for hw-specific constraints, and return the
- appropriate status value.
-
- </para></blockquote>
- </para></blockquote>
-
- <para>
-This function may also modify the effective timings and clock of the passed
-mode. These have been stored in the mode's <structfield>Crtc*</structfield> and
-<structfield>SynthClock</structfield> elements, and have already been adjusted for
-interlacing, doublescanning, multiscanning and clock multipliers and dividers.
-The function should not modify any other mode field, unless it wants to modify
-the mode timings reported to the user by <function>xf86PrintModes()</function>.
- </para>
-
- <para>
-The function is called once for every mode in the xorg.conf Monitor section
-assigned to the screen, with <parameter>flags</parameter> set to
-<constant>MODECHECK_INITIAL</constant>. It is subsequently called for every mode
-in the xorg.conf Display subsection assigned to the screen, with
-<parameter>flags</parameter> set to <constant>MODECHECK_FINAL</constant>. In the second
-case, the mode will have successfully passed all other tests. In addition,
-the <structname>ScrnInfoRec</structname>'s <structfield>virtualX</structfield>,
-<structfield>virtualY</structfield> and <structfield>displayWidth</structfield> fields will have been
-set as if the mode to be validated were to be the last mode accepted.
- </para>
-
- <para>
-In effect, calls with MODECHECK_INITIAL are intended for checks that do not
-depend on any mode other than the one being validated, while calls with
-MODECHECK_FINAL are intended for checks that may involve more than one mode.
- </para>
- </sect2>
-
- <sect2>
- <title>Free screen data</title>
-
- <para>
- When a screen is deleted prior to the completion of the ScreenInit
- phase the <function>ChipFreeScreen()</function> function is called when defined.
- </para>
-
- <blockquote><para>
- <programlisting>
- void ChipFreeScreen(int scrnindex, int flags);
- </programlisting>
- <blockquote><para>
- Free any driver-allocated data that may have been allocated up to
- and including an unsuccessful <function>ChipScreenInit()</function>
- call. This would predominantly be data allocated by
- <function>ChipPreInit()</function> that persists across server
- generations. It would include the <structfield>driverPrivate</structfield>,
- and any <quote>privates</quote> entries that modules may have allocated.
-
- </para></blockquote>
- </para></blockquote>
-
- </sect2>
-</sect1>
-
- <sect1>
- <title>Recommended driver functions</title>
-
- <para>
-The functions outlined here are for internal use by the driver only.
-They are entirely optional, and are never accessed directly from higher
-layers. The sample function declarations shown here are just examples.
-The interface (if any) used is up to the driver.
- </para>
-
- <sect2>
- <title>Save</title>
-
- <para>
- Save the video state. This could be called from <function>ChipScreenInit()</function> and
- (possibly) <function>ChipEnterVT()</function>.
- </para>
-
- <blockquote><para>
- <programlisting>
- void ChipSave(ScrnInfoPtr pScrn);
- </programlisting>
- <blockquote><para>
- Saves the current state. This will only be saving pre-server
- states or states before returning to the server. There is only
- one current saved state per screen and it is stored in private
- storage in the screen.
-
- </para></blockquote>
- </para></blockquote>
- </sect2>
-
- <sect2>
- <title>Restore</title>
-
- <para>
- Restore the original video state. This could be called from the
- <function>ChipLeaveVT()</function> and <function>ChipCloseScreen()</function>
- functions.
- </para>
-
- <blockquote><para>
- <programlisting>
- void ChipRestore(ScrnInfoPtr pScrn);
- </programlisting>
- <blockquote><para>
- Restores the saved state from the private storage. Usually only
- used for restoring text modes.
-
- </para></blockquote>
- </para></blockquote>
-
- </sect2>
-
- <sect2>
- <title>Initialise Mode</title>
-
- <para>
- Initialise a video mode. This could be called from the
- <function>ChipScreenInit()</function>, <function>ChipSwitchMode()</function>
- and <function>ChipEnterVT()</function> functions.
- </para>
-
- <blockquote><para>
- <programlisting>
- Bool ChipModeInit(ScrnInfoPtr pScrn, DisplayModePtr mode);
- </programlisting>
- <blockquote><para>
- Programs the hardware for the given video mode.
-
- </para></blockquote>
- </para></blockquote>
-
- </sect2>
- </sect1>
-
- <sect1>
- <title>Data and Data Structures</title>
-
- <sect2>
- <title>Command line data</title>
-
- <para>
-Command line options are typically global, and are stored in global
-variables. These variables are read-only and are available to drivers
-via a function call interface. Most of these command line values are
-processed via helper functions to ensure that they are treated consistently
-by all drivers. The other means of access is provided for cases where
-the supplied helper functions might not be appropriate.
- </para>
-
- <para>
-Some of them are:
-
- <literallayout>
- xf86Verbose verbosity level
- xf86Bpp -bpp from the command line
- xf86Depth -depth from the command line
- xf86Weight -weight from the command line
- xf86Gamma -{r,g,b,}gamma from the command line
- xf86FlipPixels -flippixels from the command line
- xf86ProbeOnly -probeonly from the command line
- defaultColorVisualClass -cc from the command line
- </literallayout>
- </para>
-
- <para>
-If we ever do allow for screen-specific command line options, we may
-need to rethink this.
- </para>
-
- <para>
-These can be accessed in a read-only manner by drivers with the following
-functions:
- </para>
-
- <blockquote><para>
- <programlisting>
- int xf86GetVerbosity();
- </programlisting>
- <blockquote><para>
- Returns the value of <varname>xf86Verbose</varname>.
- </para></blockquote>
-
- </para></blockquote>
-
- <blockquote><para>
- <programlisting>
- int xf86GetDepth();
- </programlisting>
- <blockquote><para>
- Returns the <option>-depth</option> command line setting. If not
- set on the command line, <constant>-1</constant> is returned.
- </para></blockquote>
-
- </para></blockquote>
-
- <blockquote><para>
- <programlisting>
- rgb xf86GetWeight();
- </programlisting>
- <blockquote><para>
- Returns the <option>-weight</option> command line setting. If not
- set on the command line, <literal remap="tt">{0, 0, 0}</literal> is returned.
- </para></blockquote>
-
- </para></blockquote>
-
- <blockquote><para>
- <programlisting>
- Gamma xf86GetGamma();
- </programlisting>
- <blockquote><para>
- Returns the <option>-gamma</option> or <option>-rgamma</option>,
- <option>-ggamma</option>, <option>-bgamma</option> command line settings.
- If not set on the command line, <literal remap="tt">{0.0, 0.0, 0.0}</literal>
- is returned.
- </para></blockquote>
-
- </para></blockquote>
-
- <blockquote><para>
- <programlisting>
- Bool xf86GetFlipPixels();
- </programlisting>
- <blockquote><para>
- Returns <constant>TRUE</constant> if <option>-flippixels</option> is
- present on the command line, and <constant>FALSE</constant> otherwise.
- </para></blockquote>
-
- </para></blockquote>
-
- <blockquote><para>
- <programlisting>
- const char *xf86GetServerName();
- </programlisting>
- <blockquote><para>
- Returns the name of the X server from the command line.
- </para></blockquote>
-
- </para></blockquote>
- </sect2>
-
- <sect2>
- <title>Data handling</title>
-
- <para>
-Config file data contains parts that are global, and parts that are
-Screen specific. All of it is parsed into data structures that neither
-the drivers or most other parts of the server need to know about.
- </para>
-
- <para>
-The global data is typically not required by drivers, and as such, most
-of it is stored in the private <structname>xf86InfoRec</structname>.
- </para>
-
- <para>
-The screen-specific data collected from the config file is stored in
-screen, device, display, monitor-specific data structures that are separate
-from the <varname>ScrnInfoRecs</varname>, with the appropriate elements/fields
-hooked into the <varname>ScrnInfoRecs</varname> as required. The screen
-config data is held in <structname>confScreenRec</structname>, device data in
-the <structname>GDevRec</structname>, monitor data in the <structname>MonRec</structname>,
-and display data in the <structname>DispRec</structname>.
- </para>
-
- <para>
-The XFree86 common layer's screen specific data (the actual data in use
-for each screen) is held in the <varname>ScrnInfoRecs</varname>. As has
-been outlined above, the <varname>ScrnInfoRecs</varname> are allocated at probe
-time, and it is the responsibility of the Drivers' <function>Probe()</function>
-and <function>PreInit()</function> functions to finish filling them in based
-on both data provided on the command line and data provided from the
-Config file. The precedence for this is:
-
- <blockquote><para>
- command line -&gt; config file -&gt; probed/default data
- </para></blockquote>
- </para>
-
- <para>
-For most things in this category there are helper functions that the
-drivers can use to ensure that the above precedence is consistently
-used.
- </para>
-
- <para>
-As well as containing screen-specific data that the XFree86 common layer
-(including essential parts of the server infrastructure as well as helper
-functions) needs to access, it also contains some data that drivers use
-internally. When considering whether to add a new field to the
-<structname>ScrnInfoRec</structname>, consider the balance between the convenience
-of things that lots of drivers need and the size/obscurity of the
-<structname>ScrnInfoRec</structname>.
- </para>
-
- <para>
-Per-screen driver specific data that cannot be accommodated with the
-static <structname>ScrnInfoRec</structname> fields is held in a driver-defined
-data structure, a pointer to which is assigned to the
-<structname>ScrnInfoRec</structname>'s <structfield>driverPrivate</structfield> field. This
-is per-screen data that persists across server generations (as does the
-bulk of the static <structname>ScrnInfoRec</structname> data). It would typically
-also include the video card's saved state.
- </para>
-
- <para>
-Per-screen data for other modules that the driver uses (for example,
-the XAA module) that is reset for each server generation is hooked into
-the <structname>ScrnInfoRec</structname> through it's <structfield>privates</structfield>
-field.
- </para>
-
- <para>
-Once it has stabilised, the data structures and variables accessible to
-video drivers will be documented here. In the meantime, those things
-defined in the <filename>xf86.h</filename> and <filename>xf86str.h</filename>
-files are visible to video drivers. Things defined in
-<filename>xf86Priv.h</filename> and <filename>xf86Privstr.h</filename> are NOT
-intended to be visible to video drivers, and it is an error for a driver
-to include those files.
- </para>
-
- </sect2>
-
- <sect2>
- <title>Accessing global data</title>
-
- <para>
-Some other global state information that the drivers may access via
-functions is as follows:
- </para>
-
- <blockquote><para>
- <programlisting>
- Bool xf86ServerIsExiting();
- </programlisting>
- <blockquote><para>
- Returns <constant>TRUE</constant> if the server is at the end of a
- generation and is in the process of exiting, and
- <constant>FALSE</constant> otherwise.
- </para></blockquote>
-
- </para></blockquote>
-
- <blockquote><para>
- <programlisting>
- Bool xf86ServerIsResetting();
- </programlisting>
- <blockquote><para>
- Returns <constant>TRUE</constant> if the server is at the end of a
- generation and is in the process of resetting, and
- <constant>FALSE</constant> otherwise.
- </para></blockquote>
-
- </para></blockquote>
-
- <blockquote><para>
- <programlisting>
- Bool xf86ServerIsInitialising();
- </programlisting>
- <blockquote><para>
- Returns <constant>TRUE</constant> if the server is at the beginning of
- a generation and is in the process of initialising, and
- <constant>FALSE</constant> otherwise.
- </para></blockquote>
-
- </para></blockquote>
-
- <blockquote><para>
- <programlisting>
- Bool xf86ServerIsOnlyProbing();
- </programlisting>
- <blockquote><para>
- Returns <constant>TRUE</constant> if the -probeonly command line flag
- was specified, and <constant>FALSE</constant> otherwise.
- </para></blockquote>
-
- </para></blockquote>
-
- <blockquote><para>
- <programlisting>
- Bool xf86CaughtSignal();
- </programlisting>
- <blockquote><para>
- Returns <constant>TRUE</constant> if the server has caught a signal,
- and <constant>FALSE</constant> otherwise.
- </para></blockquote>
-
- </para></blockquote>
- </sect2>
-
- <sect2>
- <title>Allocating private data</title>
-
- <para>
-A driver and any module it uses may allocate per-screen private storage
-in either the <structname>ScreenRec</structname> (DIX level) or
-<structname>ScrnInfoRec</structname> (XFree86 common layer level).
-<structname>ScreenRec</structname> storage persists only for a single server
-generation, and <structname>ScrnInfoRec</structname> storage persists across
-generations for the lifetime of the server.
- </para>
-
- <para>
-The <structname>ScreenRec</structname> <structfield>devPrivates</structfield> data must be
-reallocated/initialised at the start of each new generation. This is
-normally done from the <function>ChipScreenInit()</function> function, and
-Init functions for other modules that it calls. Data allocated in this
-way should be freed by the driver's <function>ChipCloseScreen()</function>
-functions, and Close functions for other modules that it calls. A new
-<structfield>devPrivates</structfield> entry is allocated by calling the
-<function>AllocateScreenPrivateIndex()</function> function.
- </para>
-
- <blockquote><para>
- <programlisting>
- int AllocateScreenPrivateIndex();
- </programlisting>
- <blockquote><para>
- This function allocates a new element in the
- <structfield>devPrivates</structfield> field of all currently existing
- <literal remap="tt">ScreenRecs</literal>. The return value is the index of this
- new element in the <structfield>devPrivates</structfield> array. The
- <structfield>devPrivates</structfield> field is of type
- <structname>DevUnion</structname>:
-
- <programlisting>
- typedef union _DevUnion {
- pointer ptr;
- long val;
- unsigned long uval;
- pointer (*fptr)(void);
- } DevUnion;
- </programlisting>
-
- which allows the element to be used for any of the above types.
- It is commonly used as a pointer to data that the caller allocates
- after the new index has been allocated.
- </para>
-
- <para>
- This function will return <constant>-1</constant> when there is an
- error allocating the new index.
- </para>
-
- </blockquote>
- </para></blockquote>
-
- <para>
-The <structname>ScrnInfoRec</structname> <structfield>privates</structfield> data persists
-for the life of the server, so only needs to be allocated once. This
-should be done from the <function>ChipPreInit()</function> function, and Init
-functions for other modules that it calls. Data allocated in this way
-should be freed by the driver's <function>ChipFreeScreen()</function> functions,
-and Free functions for other modules that it calls. A new
-<structfield>privates</structfield> entry is allocated by calling the
-<function>xf86AllocateScrnInfoPrivateIndex()</function> function.
- </para>
-
- <blockquote><para>
- <programlisting>
- int xf86AllocateScrnInfoPrivateIndex();
- </programlisting>
- <blockquote><para>
- This function allocates a new element in the <structfield>privates</structfield>
- field of all currently existing <varname>ScrnInfoRecs</varname>.
- The return value is the index of this new element in the
- <structfield>privates</structfield> array. The <structfield>privates</structfield>
- field is of type <structfield>DevUnion</structfield>:
-
- <programlisting>
- typedef union _DevUnion {
- pointer ptr;
- long val;
- unsigned long uval;
- pointer (*fptr)(void);
- } DevUnion;
- </programlisting>
-
- which allows the element to be used for any of the above types.
- It is commonly used as a pointer to data that the caller allocates
- after the new index has been allocated.
- </para>
-
- <para>
- This function will not return when there is an error allocating
- the new index. When there is an error it will cause the server
- to exit with a fatal error. The similar function for allocation
- privates in the <structname>ScreenRec</structname>
- (<function>AllocateScreenPrivateIndex()</function>) differs in this
- respect by returning <constant>-1</constant> when the allocation fails.
- </para>
-
- </blockquote>
- </para></blockquote>
- </sect2>
- </sect1>
-
- <sect1 id="rac">
- <title>Keeping Track of Bus Resources</title>
-
- <sect2>
- <title>Theory of Operation</title>
-
- <para>
-The XFree86 common layer has knowledge of generic access control mechanisms
-for devices on certain bus systems (currently the PCI bus) as well as
-of methods to enable or disable access to the buses itself. Furthermore
-it can access information on resources decoded by these devices and if
-necessary modify it.
- </para>
-
- <para>
-When first starting the Xserver collects all this information, saves it
-for restoration, checks it for consistency, and if necessary, corrects
-it. Finally it disables all resources on a generic level prior to
-calling any driver function.
- </para>
-
- <para>
-When the <function>Probe()</function> function of each driver is called the
-device sections are matched against the devices found in the system.
-The driver may probe devices at this stage that cannot be identified by
-using device independent methods. Access to all resources that can be
-controlled in a device independent way is disabled. The
-<function>Probe()</function> function should register all non-relocatable
-resources at this stage. If a resource conflict is found between
-exclusive resources the driver will fail immediately. Optionally the
-driver might specify an <function>EntityInit()</function>,
-<function>EntityLeave()</function> and <function>EntityEnter()</function> function.
- </para>
-
- <para>
-<function>EntityInit()</function> can be used to disable any shared resources
-that are not controlled by the generic access control functions. It is
-called prior to the PreInit phase regardless if an entity is active or
-not. When calling the <function>EntityInit()</function>,
-<function>EntityEnter()</function> and <function>EntityLeave()</function> functions
-the common level will disable access to all other entities on a generic
-level. Since the common level has no knowledge of device specific
-methods to disable access to resources it cannot be guaranteed that
-certain resources are not decoded by any other entity until the
-<function>EntityInit()</function> or <function>EntityEnter()</function> phase is
-finished. Device drivers should therefore register all those resources
-which they are going to disable. If these resources are never to be
-used by any driver function they may be flagged <constant>ResInit</constant>
-so that they can be removed from the resource list after processing all
-<function>EntityInit()</function> functions. <function>EntityEnter()</function>
-should disable decoding of all resources which are not registered as
-exclusive and which are not handled by the generic access control in
-the common level. The difference to <function>EntityInit()</function> is
-that the latter one is only called once during lifetime of the server.
-It can therefore be used to set up variables prior to disabling resources.
-<function>EntityLeave()</function> should restore the original state when
-exiting the server or switching to a different VT. It also needs to
-disable device specific access functions if they need to be disabled on
-server exit or VT switch. The default state is to enable them before
-giving up the VT.
- </para>
-
- <para>
-In <function>PreInit()</function> phase each driver should check if any
-sharable resources it has registered during <function>Probe()</function> has
-been denied and take appropriate action which could simply be to fail.
-If it needs to access resources it has disabled during
-<function>EntitySetup()</function> it can do so provided it has registered
-these and will disable them before returning from
-<function>PreInit()</function>. This also applies to all other driver
-functions. Several functions are provided to request resource ranges,
-register these, correct PCI config space and add replacements for the
-generic access functions. Resources may be marked <quote>disabled</quote> or
-<quote>unused</quote> during OPERATING stage. Although these steps could also be
-performed in <function>ScreenInit()</function>, this is not desirable.
- </para>
-
- <para>
-Following <function>PreInit()</function> phase the common level determines
-if resource access control is needed. This is the case if more than
-one screen is used. If necessary the RAC wrapper module is loaded. In
-<function>ScreenInit()</function> the drivers can decide which operations
-need to be placed under RAC. Available are the frame buffer operations,
-the pointer operations and the colormap operations. Any operation that
-requires resources which might be disabled during OPERATING state should
-be set to use RAC. This can be specified separately for memory and IO
-resources.
- </para>
-
- <para>
-When <function>ScreenInit()</function> phase is done the common level will
-determine which shared resources are requested by more than one driver
-and set the access functions accordingly. This is done following these
-rules:
-
- <orderedlist>
- <listitem><para>
- The sharable resources registered by each entity are compared. If
- a resource is registered by more than one entity the entity will be
- marked to need to share this resources type (<constant>IO</constant> or
- <constant>MEM</constant>).
- </para></listitem>
-
- <listitem><para>
- A resource marked <quote>disabled</quote> during OPERATING state will be ignored
- entirely.
- </para></listitem>
-
- <listitem><para>
- A resource marked <quote>unused</quote> will only conflicts with an overlapping
- resource of an other entity if the second is actually in use during
- OPERATING state.
- </para></listitem>
-
- <listitem><para>
- If an <quote>unused</quote> resource was found to conflict however the entity
- does not use any other resource of this type the entire resource type
- will be disabled for that entity.
- </para></listitem>
- </orderedlist>
- </para>
-
- <para>
-The driver has the choice among different ways to control access to
-certain resources:
-
- <orderedlist>
- <listitem><para>
- It can rely on the generic access functions. This is probably the
- most common case. Here the driver only needs to register any resource
- it is going to use.
- </para></listitem>
-
- <listitem><para>
- It can replace the generic access functions by driver specific
- ones. This will mostly be used in cases where no generic access
- functions are available. In this case the driver has to make sure
- these resources are disabled when entering the <function>PreInit()</function>
- stage. Since the replacement functions are registered in
- <function>PreInit()</function> the driver will have to enable these
- resources itself if it needs to access them during this state. The
- driver can specify if the replacement functions can control memory
- and/or I/O resources separately.
- </para></listitem>
-
- <listitem><para>
- The driver can enable resources itself when it needs them. Each
- driver function enabling them needs to disable them before it will
- return. This should be used if a resource which can be controlled
- in a device dependent way is only required during SETUP state. This
- way it can be marked <quote>unused</quote> during OPERATING state.
- </para></listitem>
- </orderedlist>
- </para>
-
- <para>
-A resource which is decoded during OPERATING state however never accessed
-by the driver should be marked unused.
- </para>
-
- <para>
-Since access switching latencies are an issue during Xserver operation,
-the common level attempts to minimize the number of entities that need
-to be placed under RAC control. When a wrapped operation is called,
-the <function>EnableAccess()</function> function is called before control is
-passed on. <function>EnableAccess()</function> checks if a screen is under
-access control. If not it just establishes bus routing and returns.
-If the screen needs to be under access control,
-<function>EnableAccess()</function> determines which resource types
-(<literal remap="tt">MEM</literal>, <literal remap="tt">IO</literal>) are required. Then it tests
-if this access is already established. If so it simply returns. If
-not it disables the currently established access, fixes bus routing and
-enables access to all entities registered for this screen.
- </para>
-
- <para>
-Whenever a mode switch or a VT-switch is performed the common level will
-return to SETUP state.
- </para>
- </sect2>
-
- <sect2>
- <title>Resource Types</title>
-
- <para>
-Resource have certain properties. When registering resources each range
-is accompanied by a flag consisting of the ORed flags of the different
-properties the resource has. Each resource range may be classified
-according to
-
- <itemizedlist>
- <listitem><para>
- its physical properties i.e., if it addresses
- memory (<constant>ResMem</constant>) or
- I/O space (<constant>ResIo</constant>),
- </para></listitem>
- <listitem><para>
- if it addresses a
- block (<constant>ResBlock</constant>) or
- sparse (<constant>ResSparse</constant>)
- range,
- </para></listitem>
- <listitem><para>
- its access properties.
- </para></listitem>
- </itemizedlist>
- </para>
-
- <para>
-There are two known access properties:
-
- <itemizedlist>
- <listitem><para>
- <constant>ResExclusive</constant>
- for resources which may not be shared with any other device and
- </para></listitem>
- <listitem><para>
- <constant>ResShared</constant>
- for resources which can be disabled and therefore can be shared.
- </para></listitem>
- </itemizedlist>
- </para>
-
- <para>
-If it is necessary to test a resource against any type a generic access
-type <constant>ResAny</constant> is provided. If this is set the resource
-will conflict with any resource of a different entity intersecting its
-range. Further it can be specified that a resource is decoded however
-never used during any stage (<constant>ResUnused</constant>) or during
-OPERATING state (<constant>ResUnusedOpr</constant>). A resource only visible
-during the init functions (ie. <function>EntityInit()</function>,
-<function>EntityEnter()</function> and <function>EntityLeave()</function> should
-be registered with the flag <constant>ResInit</constant>. A resource that
-might conflict with background resource ranges may be flagged with
-<constant>ResBios</constant>. This might be useful when registering resources
-ranges that were assigned by the system Bios.
- </para>
-
- <para>
-Several predefined resource lists are available for VGA and 8514/A
-resources in <filename>common/xf86Resources.h</filename>.
- </para>
- </sect2>
-
- <sect2 id="avail">
- <title>Available Functions</title>
-
- <para>
-The functions provided for resource management are listed in their order
-of use in the driver.
- </para>
-
- <sect3>
- <title>Probe Phase</title>
-
- <para>
-In this phase each driver detects those resources it is able to drive,
-creates an entity record for each of them, registers non-relocatable
-resources and allocates screens and adds the resources to screens.
- </para>
-
- <para>
-Two helper functions are provided for matching device sections in the
-xorg.conf file to the devices:
- </para>
-
- <blockquote><para>
- <programlisting>
- int xf86MatchPciInstances(const char *driverName, int vendorID,
- SymTabPtr chipsets, PciChipsets *PCIchipsets,
- GDevPtr *devList, int numDevs, DriverPtr drvp,
- int **foundEntities);
- </programlisting>
- <blockquote><para>
- This function finds matches between PCI cards that a driver supports
- and config file device sections. It is intended for use in the
- <function>ChipProbe()</function> function of drivers for PCI cards.
- Only probed PCI devices with a vendor ID matching
- <parameter>vendorID</parameter> are considered. <parameter>devList</parameter>
- and <parameter>numDevs</parameter> are typically those found from
- calling <function>xf86MatchDevice()</function>, and represent the active
- config file device sections relevant to the driver.
- <parameter>PCIchipsets</parameter> is a table that provides a mapping
- between the PCI device IDs, the driver's internal chipset tokens
- and a list of fixed resources.
- </para>
-
- <para>
- When a device section doesn't have a <emphasis>BusID</emphasis> entry it
- can only match the primary video device. Secondary devices are
- only matched with device sections that have a matching
- <emphasis>BusID</emphasis> entry.
- </para>
-
- <para>
- Once the preliminary matches have been found, a final match is
- confirmed by checking if the chipset override, ChipID override or
- probed PCI chipset type match one of those given in the
- <parameter>chipsets</parameter> and <parameter>PCIchipsets</parameter> lists.
- The <parameter>PCIchipsets</parameter> list includes a list of the PCI
- device IDs supported by the driver. The list should be terminated
- with an entry with PCI ID <constant>-1</constant>". The
- <parameter>chipsets</parameter> list is a table mapping the driver's
- internal chipset tokens to names, and should be terminated with
- a <constant>NULL</constant> entry. Only those entries with a
- corresponding entry in the <parameter>PCIchipsets</parameter> list are
- considered. The order of precedence is: config file chipset,
- config file ChipID, probed PCI device ID.
- </para>
-
- <para>
- In cases where a driver handles PCI chipsets with more than one
- vendor ID, it may set <parameter>vendorID</parameter> to
- <constant>0</constant>, and OR each devID in the list with (the
- vendor&nbsp;ID&nbsp;&lt;&lt;&nbsp;16).
- </para>
-
- <para>
- Entity index numbers for confirmed matches are returned as an
- array via <parameter>foundEntities</parameter>. The PCI information,
- chipset token and device section for each match are found in the
- <structname>EntityInfoRec</structname> referenced by the indices.
- </para>
-
- <para>
- The function return value is the number of confirmed matches. A
- return value of <constant>-1</constant> indicates an internal error.
- The returned <parameter>foundEntities</parameter> array should be freed
- by the driver with <function>xfree()</function> when it is no longer
- needed in cases where the return value is greater than zero.
- </para>
-
- </blockquote></para></blockquote>
-
- <blockquote><para>
- <programlisting>
- int xf86MatchIsaInstances(const char *driverName,
- SymTabPtr chipsets, IsaChipsets *ISAchipsets,
- DriverPtr drvp, FindIsaDevProc FindIsaDevice,
- GDevPtr *devList, int numDevs,
- int **foundEntities);
- </programlisting>
- <blockquote><para>
- This function finds matches between ISA cards that a driver supports
- and config file device sections. It is intended for use in the
- <function>ChipProbe()</function> function of drivers for ISA cards.
- <parameter>devList</parameter> and <parameter>numDevs</parameter> are
- typically those found from calling <function>xf86MatchDevice()</function>,
- and represent the active config file device sections relevant to
- the driver. <parameter>ISAchipsets</parameter> is a table that provides
- a mapping between the driver's internal chipset tokens and the
- resource classes. <parameter>FindIsaDevice</parameter> is a
- driver-provided function that probes the hardware and returns the
- chipset token corresponding to what was detected, and
- <constant>-1</constant> if nothing was detected.
- </para>
-
- <para>
- If the config file device section contains a chipset entry, then
- it is checked against the <parameter>chipsets</parameter> list. When
- no chipset entry is present, the <parameter>FindIsaDevice</parameter>
- function is called instead.
- </para>
-
- <para>
- Entity index numbers for confirmed matches are returned as an
- array via <parameter>foundEntities</parameter>. The chipset token and
- device section for each match are found in the
- <structname>EntityInfoRec</structname> referenced by the indices.
- </para>
-
- <para>
- The function return value is the number of confirmed matches. A
- return value of <constant>-1</constant> indicates an internal error.
- The returned <parameter>foundEntities</parameter> array should be freed
- by the driver with <function>xfree()</function> when it is no longer
- needed in cases where the return value is greater than zero.
- </para>
-
- </blockquote></para></blockquote>
-
- <para>
-These two helper functions make use of several core functions that are
-available at the driver level:
- </para>
-
- <blockquote><para>
- <programlisting>
- Bool xf86ParsePciBusString(const char *busID, int *bus,
- int *device, int *func);
- </programlisting>
- <blockquote><para>
- Takes a <parameter>BusID</parameter> string, and if it is in the correct
- format, returns the PCI <parameter>bus</parameter>, <parameter>device</parameter>,
- <parameter>func</parameter> values that it indicates. The format of the
- string is expected to be "PCI:bus:device:func" where each of <quote>bus</quote>,
- <quote>device</quote> and <quote>func</quote> are decimal integers. The ":func" part may
- be omitted, and the func value assumed to be zero, but this isn't
- encouraged. The "PCI" prefix may also be omitted. The prefix
- "AGP" is currently equivalent to the "PCI" prefix. If the string
- isn't a valid PCI BusID, the return value is <constant>FALSE</constant>.
- </para>
-
- </blockquote></para></blockquote>
-
- <blockquote><para>
- <programlisting>
- Bool xf86ComparePciBusString(const char *busID, int bus,
- int device, int func);
- </programlisting>
- <blockquote><para>
- Compares a <parameter>BusID</parameter> string with PCI <parameter>bus</parameter>,
- <parameter>device</parameter>, <parameter>func</parameter> values. If they
- match <constant>TRUE</constant> is returned, and <constant>FALSE</constant>
- if they don't.
- </para>
-
- </blockquote></para></blockquote>
-
- <blockquote><para>
- <programlisting>
- Bool xf86ParseIsaBusString(const char *busID);
- </programlisting>
- <blockquote><para>
- Compares a <parameter>BusID</parameter> string with the ISA bus ID string
- ("ISA" or "ISA:"). If they match <constant>TRUE</constant> is returned,
- and <constant>FALSE</constant> if they don't.
- </para>
-
- </blockquote></para></blockquote>
-
- <blockquote><para>
- <programlisting>
- Bool xf86CheckPciSlot(int bus, int device, int func);
- </programlisting>
- <blockquote><para>
- Checks if the PCI slot <literal remap="tt">bus:device:func</literal> has been
- claimed. If so, it returns <constant>FALSE</constant>, and otherwise
- <constant>TRUE</constant>.
- </para>
-
- </blockquote></para></blockquote>
-
- <blockquote><para>
- <programlisting>
- int xf86ClaimPciSlot(int bus, int device, int func, DriverPtr drvp,
- int chipset, GDevPtr dev, Bool active);
- </programlisting>
- <blockquote><para>
- This function is used to claim a PCI slot, allocate the associated
- entity record and initialise their data structures. The return
- value is the index of the newly allocated entity record, or
- <constant>-1</constant> if the claim fails. This function should always
- succeed if <function>xf86CheckPciSlot()</function> returned
- <constant>TRUE</constant> for the same PCI slot.
- </para>
-
- </blockquote></para></blockquote>
-
- <blockquote><para>
- <programlisting>
- Bool xf86IsPrimaryPci(void);
- </programlisting>
- <blockquote><para>
- This function returns <constant>TRUE</constant> if the primary card is
- a PCI device, and <constant>FALSE</constant> otherwise.
- </para>
-
- </blockquote></para></blockquote>
-
- <blockquote><para>
- <programlisting>
- int xf86ClaimIsaSlot(DriverPtr drvp, int chipset,
- GDevPtr dev, Bool active);
- </programlisting>
- <blockquote><para>
- This allocates an entity record entity and initialise the data
- structures. The return value is the index of the newly allocated
- entity record.
- </para>
-
- </blockquote></para></blockquote>
-
- <blockquote><para>
- <programlisting>
- Bool xf86IsPrimaryIsa(void);
- </programlisting>
- <blockquote><para>
- This function returns <constant>TRUE</constant> if the primary card is
- an ISA (non-PCI) device, and <constant>FALSE</constant> otherwise.
- </para>
-
- </blockquote></para></blockquote>
-
- <para>
-Two helper functions are provided to aid configuring entities:
- </para>
-
- <blockquote><para>
- <programlisting>
- ScrnInfoPtr xf86ConfigPciEntity(ScrnInfoPtr pScrn,
- int scrnFlag, int entityIndex,
- PciChipsets *p_chip,
- resList res, EntityProc init,
- EntityProc enter, EntityProc leave,
- pointer private);
-
- ScrnInfoPtr xf86ConfigIsaEntity(ScrnInfoPtr pScrn,
- int scrnFlag, int entityIndex,
- IsaChipsets *i_chip,
- resList res, EntityProc init,
- EntityProc enter, EntityProc leave,
- pointer private);
- </programlisting>
- <blockquote><para>
- These functions are used to register the non-relocatable resources
- for an entity, and the optional entity-specific <parameter>Init</parameter>, <parameter>Enter</parameter> and
- <parameter>Leave</parameter> functions. Usually the list of fixed resources is obtained
- from the Isa/PciChipsets lists. However an additional list of
- resources may be passed. Generally this is not required.
- For active entities a <structname>ScrnInfoRec</structname> is allocated
- if the <parameter>pScrn</parameter> argument is <constant>NULL</constant>.
-The
- return value is <constant>TRUE</constant> when successful. The init, enter, leave
- functions are defined as follows:
-
- <blockquote><para>
- <programlisting>
- typedef void (*EntityProc)(int entityIndex,
- pointer private);
- </programlisting>
- </para></blockquote>
-
- They are passed the entity index and a pointer to a private scratch
- area. This can be set up during <function>Probe()</function> and
- its address can be passed to
- <function>xf86ConfigIsaEntity()</function> and
- <function>xf86ConfigPciEntity()</function> as the last argument.
- </para>
-
- </blockquote></para></blockquote>
-
- <para>
-These two helper functions make use of several core functions that are
-available at the driver level:
-
- <blockquote><para>
- <programlisting>
- void xf86ClaimFixedResources(resList list, int entityIndex);
- </programlisting>
- <blockquote><para>
- This function registers the non-relocatable resources which cannot
- be disabled and which therefore would cause the server to fail
- immediately if they were found to conflict. It also records
- non-relocatable but sharable resources for processing after the
- <function>Probe()</function> phase.
- </para>
-
- </blockquote></para></blockquote>
-
- <blockquote><para>
- <programlisting>
- Bool xf86SetEntityFuncs(int entityIndex, EntityProc init,
- EntityProc enter, EntityProc leave, pointer);
- </programlisting>
- <blockquote><para>
- This function registers with an entity the <parameter>init</parameter>,
- <parameter>enter</parameter>, <parameter>leave</parameter> functions along
- with the pointer to their private area.
- </para>
-
- </blockquote></para></blockquote>
-
- <blockquote><para>
- <programlisting>
- void xf86AddEntityToScreen(ScrnInfoPtr pScrn, int entityIndex);
- </programlisting>
- <blockquote><para>
- This function associates the entity referenced by
- <parameter>entityIndex</parameter> with the screen.
- </para>
-
- </blockquote></para></blockquote>
- </para>
- </sect3>
-
- <sect3>
- <title>PreInit Phase</title>
-
- <para>
-During this phase the remaining resources should be registered.
-<function>PreInit()</function> should call <function>xf86GetEntityInfo()</function>
-to obtain a pointer to an <structname>EntityInfoRec</structname> for each entity
-it is able to drive and check if any resource are listed in its
-<structfield>resources</structfield> field. If resources registered in the Probe
-phase have been rejected in the post-Probe phase
-(<structfield>resources</structfield> is non-<constant>NULL</constant>), then the driver should
-decide if it can continue without using these or if it should fail.
- </para>
-
- <blockquote><para>
- <programlisting>
- EntityInfoPtr xf86GetEntityInfo(int entityIndex);
- </programlisting>
- <blockquote><para>
- This function returns a pointer to the <structname>EntityInfoRec</structname>
- referenced by <parameter>entityIndex</parameter>. The returned
- <structname>EntityInfoRec</structname> should be freed with
- <function>xfree()</function> when no longer needed.
- </para>
-
- </blockquote></para></blockquote>
-
- <para>
-Several functions are provided to simplify resource registration:
- <blockquote><para>
- <programlisting>
- Bool xf86IsEntityPrimary(int entityIndex);
- </programlisting>
- <blockquote><para>
- This function returns <constant>TRUE</constant> if the entity referenced
- by <parameter>entityIndex</parameter> is the primary display device (i.e.,
- the one initialised at boot time and used in text mode).
- </para>
-
- </blockquote></para></blockquote>
-
- <blockquote><para>
- <programlisting>
- Bool xf86IsScreenPrimary(int scrnIndex);
- </programlisting>
- <blockquote><para>
- This function returns <constant>TRUE</constant> if the primary entity
- is registered with the screen referenced by
- <parameter>scrnIndex</parameter>.
- </para>
-
- </blockquote></para></blockquote>
-
- <blockquote><para>
- <programlisting>
- pciVideoPtr xf86GetPciInfoForEntity(int entityIndex);
- </programlisting>
- <blockquote><para>
- This function returns a pointer to the <structname>pciVideoRec</structname>
- for the specified entity. If the entity is not a PCI device,
- <constant>NULL</constant> is returned.
- </para>
-
- </blockquote></para></blockquote>
- </para>
-
- <para>
-The primary function for registration of resources is:
- <blockquote><para>
- <programlisting>
- resPtr xf86RegisterResources(int entityIndex, resList list,
- int access);
- </programlisting>
- <blockquote><para>
- This function tries to register the resources in
- <parameter>list</parameter>. If list is <constant>NULL</constant> it tries
- to determine the resources automatically. This only works for
- entities that provide a generic way to read out the resource ranges
- they decode. So far this is only the case for PCI devices. By
- default the PCI resources are registered as shared
- (<constant>ResShared</constant>) if the driver wants to set a different
- access type it can do so by specifying the access flags in the
- third argument. A value of <constant>0</constant> means to use the
- default settings. If for any reason the resource broker is not
- able to register some of the requested resources the function will
- return a pointer to a list of the failed ones. In this case the
- driver may be able to move the resource to different locations.
- In case of PCI bus entities this is done by passing the list of
- failed resources to <function>xf86ReallocatePciResources()</function>.
- When the registration succeeds, the return value is
- <constant>NULL</constant>.
- </para>
-
- </blockquote></para></blockquote>
- </para>
-
- <blockquote><para>
- <programlisting>
- resPtr xf86ReallocatePciResources(int entityIndex, resPtr pRes);
- </programlisting>
- <blockquote><para>
- This function takes a list of PCI resources that need to be
- reallocated and returns <constant>NULL</constant> when all relocations are
- successful.
- <function>xf86RegisterResources()</function> should be called again to
- register the relocated resources with the broker.
- If the reallocation fails, a list of the resources that could not be
- relocated is returned.
- </para>
-
- </blockquote></para></blockquote>
-
-<para>
-Two functions are provided to obtain a resource range of a given type:
- <blockquote><para>
- <programlisting>
- resRange xf86GetBlock(long type, memType size,
- memType window_start, memType window_end,
- memType align_mask, resPtr avoid);
- </programlisting>
- <blockquote><para>
- This function tries to find a block range of size
- <parameter>size</parameter> and type <parameter>type</parameter> in a window
- bound by <parameter>window_start</parameter> and <parameter>window_end</parameter>
- with the alignment specified in <parameter>align_mask</parameter>.
- Optionally a list of resource ranges which should be avoided within
- the window can be supplied. On failure a zero-length range of
- type <constant>ResEnd</constant> will be returned.
- </para>
- </blockquote></para></blockquote>
-
- <blockquote><para>
- <programlisting>
- resRange xf86GetSparse(long type, memType fixed_bits,
- memType decode_mask, memType address_mask,
- resPtr avoid);
- </programlisting>
- <blockquote><para>
- This function is like the previous one, but attempts to find a
- sparse range instead of a block range. Here three values have to
- be specified: the <parameter>address_mask</parameter> which marks all
- bits of the mask part of the address, the <parameter>decode_mask</parameter>
- which masks out the bits which are hardcoded and are therefore
- not available for relocation and the values of the fixed bits.
- The function tries to find a base that satisfies the given condition.
- If the function fails it will return a zero range of type
- <constant>ResEnd</constant>. Optionally it might be passed a list of
- resource ranges to avoid.
- </para>
-
- </blockquote></para></blockquote>
- </para>
-
- <para>
-Some PCI devices are broken in the sense that they return invalid size
-information for a certain resource. In this case the driver can supply
-the correct size and make sure that the resource range allocated for
-the card is large enough to hold the address range decoded by the card.
-The function <function>xf86FixPciResource()</function> can be used to do this:
- <blockquote><para>
- <programlisting>
- Bool xf86FixPciResource(int entityIndex, unsigned int prt,
- CARD32 alignment, long type);
- </programlisting>
- <blockquote><para>
- This function fixes a PCI resource allocation. The
- <parameter>prt</parameter> parameter contains the number of the PCI base
- register that needs to be fixed (<constant>0-5</constant>, and
- <constant>6</constant> for the BIOS base register). The size is
- specified by the alignment. Since PCI resources need to span an
- integral range of size <literal remap="tt">2&circ;n</literal>, the alignm ent also
- specifies the number of addresses that will be decoded. If the
- driver specifies a type mask it can override the default type for
- PCI resources which is <constant>ResShared</constant>. The resource
- broker needs to know that to find a matching resource range. This
- function should be called before calling
- <function>xf86RegisterResources()</function>. The return value is
- <constant>TRUE</constant> when the function succeeds.
- </para>
-
- </blockquote></para></blockquote>
-
- <blockquote><para>
- <programlisting>
- Bool xf86CheckPciMemBase(pciVideoPtr pPci, memType base);
- </programlisting>
- <blockquote><para>
- This function checks that the memory base address specified matches
- one of the PCI base address register values for the given PCI
- device. This is mostly used to check that an externally provided
- base address (e.g., from a config file) matches an actual value
- allocated to a device.
- </para>
-
- </blockquote></para></blockquote>
- </para>
-
- <para>
-The driver may replace the generic access control functions for an entity.
-This is done with the <function>xf86SetAccessFuncs()</function>:
- <blockquote><para>
- <programlisting>
- void xf86SetAccessFuncs(EntityInfoPtr pEnt,
- xf86SetAccessFuncPtr funcs,
- xf86SetAccessFuncPtr oldFuncs);
- </programlisting>
- with:
- <programlisting>
- typedef struct {
- xf86AccessPtr mem;
- xf86AccessPtr io;
- xf86AccessPtr io_mem;
- } xf86SetAccessFuncRec, *xf86SetAccessFuncPtr;
- </programlisting>
- <blockquote><para>
- The driver can pass three functions: one for I/O access, one for
- memory access and one for combined memory and I/O access. If the
- memory access and combined access functions are identical the
- common level assumes that the memory access cannot be controlled
- independently of I/O access, if the I/O access function and the
- combined access functions are the same it is assumed that I/O can
- not be controlled independently. If memory and I/O have to be
- controlled together all three values should be the same. If a
- non <constant>NULL</constant> value is passed as third argument it is
- interpreted as an address where to store the old access record.
- If the third argument is <constant>NULL</constant> it will be assumed
- that the generic access should be enabled before replacing the
- access functions. Otherwise it will be disabled. The driver may
- enable them itself using the returned values. It should do this
- from its replacement access functions as the generic access may
- be disabled by the common level on certain occasions. If replacement
- functions are specified they must control all resources of the
- specific type registered for the entity.
- </para>
-
- </blockquote></para></blockquote>
- </para>
-
- <para>
-To find out if a specific resource range conflicts with another
-resource the <function>xf86ChkConflict()</function> function may be used:
- <blockquote><para>
- <programlisting>
- memType xf86ChkConflict(resRange *rgp, int entityIndex);
- </programlisting>
- <blockquote><para>
- This function checks if the resource range <parameter>rgp</parameter> of
- for the specified entity conflicts with with another resource.
- If a conflict is found, the address of the start of the conflict
- is returned. The return value is zero when there is no conflict.
- </para>
-
- </blockquote></para></blockquote>
- </para>
-
- <para>
-The OPERATING state properties of previously registered fixed resources
-can be set with the <function>xf86SetOperatingState()</function> function:
- <blockquote><para>
- <programlisting>
- resPtr xf86SetOperatingState(resList list, int entityIndex,
- int mask);
- </programlisting>
- <blockquote><para>
- This function is used to set the status of a resource during
- OPERATING state. <parameter>list</parameter> holds a list to which
- <parameter>mask</parameter> is to be applied. The parameter
- <parameter>mask</parameter> may have the value <constant>ResUnusedOpr</constant>
- and <constant>ResDisableOpr</constant>. The first one should be used
- if a resource isn't used by the driver during OPERATING state
- although it is decoded by the device, while the latter one indicates
- that the resource is not decoded during OPERATING state. Note
- that the resource ranges have to match those specified during
- registration. If a range has been specified starting at
- <literal remap="tt">A</literal> and ending at <literal remap="tt">B</literal> and suppose
- <literal remap="tt">C</literal> us a value satisfying
- <literal remap="tt">A&nbsp;&lt;&nbsp;C&nbsp;&lt;&nbsp;B</literal> one may not
- specify the resource range <literal remap="tt">(A,B)</literal> by splitting it
- into two ranges <literal remap="tt">(A,C)</literal> and <literal remap="tt">(C,B)</literal>.
- </para>
-
- </blockquote></para></blockquote>
- </para>
-
- <para>
-The following two functions are provided for special cases:
- <blockquote><para>
- <programlisting>
- void xf86RemoveEntityFromScreen(ScrnInfoPtr pScrn, int entityIndex);
- </programlisting>
- <blockquote><para>
- This function may be used to remove an entity from a screen. This
- only makes sense if a screen has more than one entity assigned or
- the screen is to be deleted. No test is made if the screen has
- any entities left.
- </para>
-
- </blockquote></para></blockquote>
-
- <blockquote><para>
- <programlisting>
- void xf86DeallocateResourcesForEntity(int entityIndex, long type);
- </programlisting>
- <blockquote><para>
- This function deallocates all resources of a given type registered
- for a certain entity from the resource broker list.
- </para>
-
- </blockquote></para></blockquote>
- </para>
-
- </sect3>
-
- <sect3>
- <title>ScreenInit Phase</title>
-
- <para>
-All that is required in this phase is to setup the RAC flags. Note that
-it is also permissible to set these flags up in the PreInit phase. The
-RAC flags are held in the <structfield>racIoFlags</structfield> and <structfield>racMemFlags</structfield> fields of the
-<structname>ScrnInfoRec</structname> for each screen. They specify which graphics operations
-might require the use of shared resources. This can be specified
-separately for memory and I/O resources. The available flags are defined
-in <filename>rac/xf86RAC.h</filename>. They are:
-
- <variablelist>
- <varlistentry><term><constant>RAC_FB</constant></term>
- <listitem><para>
- for framebuffer operations (including hw acceleration)
- </para></listitem></varlistentry>
- <varlistentry><term><constant>RAC_CURSOR</constant></term>
- <listitem><para>
- for Cursor operations
- (??? I'm not sure if we need this for SW cursor it depends
- on which level the sw cursor is drawn)
- </para></listitem></varlistentry>
- <varlistentry><term><constant>RAC_COLORMAP</constant></term>
- <listitem><para>
- for colormap operations
- </para></listitem></varlistentry>
- <varlistentry><term><constant>RAC_VIEWPORT</constant></term>
- <listitem><para>
- for the call to <function>ChipAdjustFrame()</function>
- </para></listitem></varlistentry>
- </variablelist>
-
-
-The flags are ORed together.
- </para>
- </sect3>
- </sect2>
- </sect1>
-
- <sect1 id="options">
- <title>Config file <quote>Option</quote> entries</title>
-
- <para>
-Option entries are permitted in most sections and subsections of the
-config file. There are two forms of option entries:
-
- <variablelist>
- <varlistentry><term>Option "option-name"</term>
- <listitem><para>
- A boolean option.
- </para></listitem></varlistentry>
- <varlistentry><term>Option "option-name" "option-value"</term>
- <listitem><para>
- An option with an arbitrary value.
- </para></listitem></varlistentry>
- </variablelist>
- </para>
-
- <para>
-The option entries are handled by the parser, and a list of the parsed
-options is included with each of the appropriate data structures that
-the drivers have access to. The data structures used to hold the option
-information are opaque to the driver, and a driver must not access the
-option data directly. Instead, the common layer provides a set of
-functions that may be used to access, check and manipulate the option
-data.
- </para>
-
- <para>
-First, the low level option handling functions. In most cases drivers
-would not need to use these directly.
- </para>
-
- <blockquote><para>
- <programlisting>
- pointer xf86FindOption(pointer options, const char *name);
- </programlisting>
- <blockquote><para>
- Takes a list of options and an option name, and returns a handle
- for the first option entry in the list matching the name. Returns
- <constant>NULL</constant> if no match is found.
- </para>
-
- </blockquote></para></blockquote>
-
- <blockquote><para>
- <programlisting>
- char *xf86FindOptionValue(pointer options, const char *name);
- </programlisting>
- <blockquote><para>
- Takes a list of options and an option name, and returns the value
- associated with the first option entry in the list matching the
- name. If the matching option has no value, an empty string
- (<constant>""</constant>) is returned. Returns <constant>NULL</constant>
- if no match is found.
- </para>
-
- </blockquote></para></blockquote>
-
- <blockquote><para>
- <programlisting>
- void xf86MarkOptionUsed(pointer option);
- </programlisting>
- <blockquote><para>
- Takes a handle for an option, and marks that option as used.
- </para>
-
- </blockquote></para></blockquote>
-
- <blockquote><para>
- <programlisting>
- void xf86MarkOptionUsedByName(pointer options, const char *name);
- </programlisting>
- <blockquote><para>
- Takes a list of options and an option name and marks the first
- option entry in the list matching the name as used.
- </para>
-
- </blockquote></para></blockquote>
-
- <para>
-Next, the higher level functions that most drivers would use.
- </para>
- <blockquote><para>
- <programlisting>
- void xf86CollectOptions(ScrnInfoPtr pScrn, pointer extraOpts);
- </programlisting>
- <blockquote><para>
- Collect the options from each of the config file sections used by
- the screen (<parameter>pScrn</parameter>) and return the merged list as
- <structfield>pScrn-&gt;options</structfield>. This function requires that
- <structfield>pScrn-&gt;confScreen</structfield>, <structfield>pScrn-&gt;display</structfield>,
- <structfield>pScrn-&gt;monitor</structfield>,
- <structfield>pScrn-&gt;numEntities</structfield>, and
- <structfield>pScrn-&gt;entityList</structfield> are initialised.
- <parameter>extraOpts</parameter> may optionally be set to an additional
- list of options to be combined with the others. The order of
- precedence for options is <parameter>extraOpts</parameter>, display,
- confScreen, monitor, device.
- </para>
-
- </blockquote></para></blockquote>
-
- <blockquote><para>
- <programlisting>
- void xf86ProcessOptions(int scrnIndex, pointer options,
- OptionInfoPtr optinfo);
- </programlisting>
- <blockquote><para>
- Processes a list of options according to the information in the
- array of <structname>OptionInfoRecs</structname> (<parameter>optinfo</parameter>).
- The resulting information is stored in the <structfield>value</structfield>
- fields of the appropriate <parameter>optinfo</parameter> entries. The
- <structfield>found</structfield> fields are set to <constant>TRUE</constant>
- when an option with a value of the correct type if found, and
- <constant>FALSE</constant> otherwise. The <structfield>type</structfield> field
- is used to determine the expected value type for each option.
- Each option in the list of options for which there is a name match
- (but not necessarily a value type match) is marked as used.
- Warning messages are printed when option values don't match the
- types specified in the optinfo data.
- </para>
-
- <para>
- NOTE: If this function is called before a driver's screen number
- is known (e.g., from the <function>ChipProbe()</function> function) a
- <parameter>scrnIndex</parameter> value of <constant>-1</constant> should be
- used.
- </para>
-
- <para>
- NOTE 2: Given that this function stores into the
- <literal remap="tt">OptionInfoRecs</literal> pointed to by <parameter>optinfo</parameter>,
- the caller should ensure the <literal remap="tt">OptionInfoRecs</literal> are
- (re-)initialised before the call, especially if the caller expects
- to use the predefined option values as defaults.
- </para>
-
- <para>
- The <structname>OptionInfoRec</structname> is defined as follows:
-
- <programlisting>
- typedef struct {
- double freq;
- int units;
- } OptFrequency;
-
- typedef union {
- unsigned long num;
- char * str;
- double realnum;
- Bool bool;
- OptFrequency freq;
- } ValueUnion;
-
- typedef enum {
- OPTV_NONE = 0,
- OPTV_INTEGER,
- OPTV_STRING, /* a non-empty string */
- OPTV_ANYSTR, /* Any string, including an empty one */
- OPTV_REAL,
- OPTV_BOOLEAN,
- OPTV_PERCENT,
- OPTV_FREQ
- } OptionValueType;
-
- typedef enum {
- OPTUNITS_HZ = 1,
- OPTUNITS_KHZ,
- OPTUNITS_MHZ
- } OptFreqUnits;
-
- typedef struct {
- int token;
- const char* name;
- OptionValueType type;
- ValueUnion value;
- Bool found;
- } OptionInfoRec, *OptionInfoPtr;
- </programlisting>
- </para>
- <para>
- <constant>OPTV_FREQ</constant> can be used for options values that are
- frequencies. These values are a floating point number with an
- optional unit name appended. The unit name can be one of "Hz",
- "kHz", "k", "MHz", "M". The multiplier associated with the unit
- is stored in <structfield>freq.units</structfield>, and the scaled frequency
- is stored in <structfield>freq.freq</structfield>. When no unit is specified,
- <structfield>freq.units</structfield> is set to <constant>0</constant>, and
- <structfield>freq.freq</structfield> is unscaled.
- </para>
-
- <para>
- <constant>OPTV_PERCENT</constant> can be used for option values that are
- specified in percent (e.g. "20%"). These values are a floating point
- number with a percent sign appended. If the percent sign is missing,
- the parser will fail to match the value.
- </para>
-
- <para>
- Typical usage is to setup an array of
- <structname>OptionInfoRec</structname>s with all fields initialised.
- The <structfield>value</structfield> and <structfield>found</structfield> fields get
- set by <function>xf86ProcessOptions()</function>. For cases where the
- value parsing is more complex, the driver should specify
- <constant>OPTV_STRING</constant>, and parse the string itself. An
- example of using this option handling is included in the
- <link linkend="sample">Sample Driver</link> section.
- </para>
-
- </blockquote></para></blockquote>
-
- <blockquote><para>
- <programlisting>
- void xf86ShowUnusedOptions(int scrnIndex, pointer options);
- </programlisting>
- <blockquote><para>
- Prints out warning messages for each option in the list of options
- that isn't marked as used. This is intended to show options that
- the driver hasn't recognised. It would normally be called near
- the end of the <function>ChipScreenInit()</function> function, but only
- when <code>serverGeneration&nbsp;==&nbsp;1</code>
- </para>
- </blockquote></para></blockquote>
-
- <blockquote><para>
- <programlisting>
- OptionInfoPtr xf86TokenToOptinfo(const OptionInfoRec *table,
- int token);
- </programlisting>
- <blockquote><para>
- Returns a pointer to the <structname>OptionInfoRec</structname> in
- <parameter>table</parameter> with a token field matching
- <parameter>token</parameter>. Returns <constant>NULL</constant> if no match
- is found.
- </para>
-
- </blockquote></para></blockquote>
-
- <blockquote><para>
- <programlisting>
- Bool xf86IsOptionSet(const OptionInfoRec *table, int token);
- </programlisting>
- <blockquote><para>
- Returns the <literal remap="tt">found</literal> field of the
- <structname>OptionInfoRec</structname> in <parameter>table</parameter> with a
- <structfield>token</structfield> field matching <parameter>token</parameter>. This
- can be used for options of all types. Note that for options of
- type <constant>OPTV_BOOLEAN</constant>, it isn't sufficient to check
- this to determine the value of the option. Returns
- <constant>FALSE</constant> if no match is found.
- </para>
-
- </blockquote></para></blockquote>
-
- <blockquote><para>
- <programlisting>
- char *xf86GetOptValString(const OptionInfoRec *table, int token);
- </programlisting>
- <blockquote><para>
- Returns the <structfield>value.str</structfield> field of the
- <structname>OptionInfoRec</structname> in <parameter>table</parameter> with a
- token field matching <parameter>token</parameter>. Returns
- <constant>NULL</constant> if no match is found.
- </para>
-
- </blockquote></para></blockquote>
-
- <blockquote><para>
- <programlisting>
- Bool xf86GetOptValInteger(const OptionInfoRec *table, int token,
-
- int *value);
- </programlisting>
- <blockquote><para>
- Returns via <parameter>*value</parameter> the <structfield>value.num</structfield>
- field of the <structname>OptionInfoRec</structname> in <parameter>table</parameter>
- with a <structfield>token</structfield> field matching <parameter>token</parameter>.
- <parameter>*value</parameter> is only changed when a match is found so
- it can be safely initialised with a default prior to calling this
- function. The function return value is as for
- <function>xf86IsOptionSet()</function>.
- </para>
-
- </blockquote></para></blockquote>
-
- <blockquote><para>
- <programlisting>
- Bool xf86GetOptValULong(const OptionInfoRec *table, int token,
- unsigned long *value);
- </programlisting>
- <blockquote><para>
- Like <function>xf86GetOptValInteger()</function>, except the value is
- treated as an <type>unsigned long</type>.
- </para>
-
- </blockquote></para></blockquote>
-
- <blockquote><para>
- <programlisting>
- Bool xf86GetOptValReal(const OptionInfoRec *table, int token,
- double *value);
- </programlisting>
- <blockquote><para>
- Like <function>xf86GetOptValInteger()</function>, except that
- <structfield>value.realnum</structfield> is used.
- </para>
-
- </blockquote></para></blockquote>
-
- <blockquote><para>
- <programlisting>
- Bool xf86GetOptValFreq(const OptionInfoRec *table, int token,
- OptFreqUnits expectedUnits, double *value);
- </programlisting>
- <blockquote><para>
- Like <function>xf86GetOptValInteger()</function>, except that the
- <structfield>value.freq</structfield> data is returned. The frequency value
- is scaled to the units indicated by <parameter>expectedUnits</parameter>.
- The scaling is exact when the units were specified explicitly in
- the option's value. Otherwise, the <parameter>expectedUnits</parameter>
- field is used as a hint when doing the scaling. In this case,
- values larger than <constant>1000</constant> are assumed to have be
- specified in the next smallest units. For example, if the Option
- value is "10000" and expectedUnits is <constant>OPTUNITS_MHZ</constant>,
- the value returned is <constant>10</constant>.
- </para>
-
- </blockquote></para></blockquote>
-
- <blockquote><para>
- <programlisting>
- Bool xf86GetOptValBool(const OptionInfoRec *table, int token, Bool *value);
- </programlisting>
- <blockquote><para>
- This function is used to check boolean options
- (<constant>OPTV_BOOLEAN</constant>). If the function return value is
- <constant>FALSE</constant>, it means the option wasn't set. Otherwise
- <parameter>*value</parameter> is set to the boolean value indicated by
- the option's value. No option <parameter>value</parameter> is interpreted
- as <constant>TRUE</constant>. Option values meaning <constant>TRUE</constant>
- are "1", "yes", "on", "true", and option values meaning
- <constant>FALSE</constant> are "0", "no", "off", "false". Option names
- both with the "no" prefix in their names, and with that prefix
- removed are also checked and handled in the obvious way.
- <parameter>*value</parameter> is not changed when the option isn't present.
- It should normally be set to a default value before calling this
- function.
- </para>
-
- </blockquote></para></blockquote>
-
- <blockquote><para>
- <programlisting>
- Bool xf86ReturnOptValBool(const OptionInfoRec *table, int token, Bool def);
- </programlisting>
- <blockquote><para>
- This function is used to check boolean options
- (<constant>OPTV_BOOLEAN</constant>). If the option is set, its value
- is returned. If the options is not set, the default value specified
- by <parameter>def</parameter> is returned. The option interpretation is
- the same as for <function>xf86GetOptValBool()</function>.
- </para>
-
- </blockquote></para></blockquote>
-
- <blockquote><para>
- <programlisting>
- int xf86NameCmp(const char *s1, const char *s2);
- </programlisting>
- <blockquote><para>
- This function should be used when comparing strings from the config
- file with expected values. It works like <function>strcmp()</function>,
- but is not case sensitive and space, tab, and <quote><literal>_</literal></quote> characters
- are ignored in the comparison. The use of this function isn't
- restricted to parsing option values. It may be used anywhere
- where this functionality required.
- </para>
-
- </blockquote></para></blockquote>
- </sect1>
-
- <sect1>
- <title>Modules, Drivers, Include Files and Interface Issues</title>
-
- <para>
-NOTE: this section is incomplete.
- </para>
-
-
- <sect2>
- <title>Include files</title>
-
- <para>
-The following include files are typically required by video drivers:
-
- <blockquote><para>
- All drivers should include these:
- <literallayout><filename>
- "xf86.h"
- "xf86_OSproc.h"
- "xf86_ansic.h"
- "xf86Resources.h"
- </filename></literallayout>
- Wherever inb/outb (and related things) are used the following should be
- included:
- <literallayout><filename>
- "compiler.h"
- </filename></literallayout>
- Note: in drivers, this must be included after <filename>"xf86_ansic.h"</filename>.
- </para>
-
- <para>
- Drivers that need to access PCI vendor/device definitions need this:
- <literallayout><filename>
- "xf86PciInfo.h"
- </filename></literallayout>
- </para>
-
- <para>
- Drivers that need to access the PCI config space need this:
- <literallayout><filename>
- "xf86Pci.h"
- </filename></literallayout>
- </para>
-
- <para>
- Drivers that initialise a SW cursor need this:
- <literallayout><filename>
- "mipointer.h"
- </filename></literallayout>
- </para>
-
- <para>
- All drivers implementing backing store need this:
- <literallayout><filename>
- "mibstore.h"
- </filename></literallayout>
- </para>
-
- <para>
- All drivers using the mi colourmap code need this:
- <literallayout><filename>
- "micmap.h"
- </filename></literallayout>
- </para>
-
- <para>
- If a driver uses the vgahw module, it needs this:
- <literallayout><filename>
- "vgaHW.h"
- </filename></literallayout>
- </para>
-
- <para>
- Drivers supporting VGA or Hercules monochrome screens need:
- <literallayout><filename>
- "xf1bpp.h"
- </filename></literallayout>
- </para>
-
- <para>
- Drivers supporting VGA or EGC 16-colour screens need:
- <literallayout><filename>
- "xf4bpp.h"
- </filename></literallayout>
- </para>
-
- <para>
- Drivers using cfb need:
- <programlisting>
- #define PSZ 8
- #include "cfb.h"
- #undef PSZ
- </programlisting>
- </para>
-
- <para>
- Drivers supporting bpp 16, 24 or 32 with cfb need one or more of:
- <literallayout><filename>
- "cfb16.h"
- "cfb24.h"
- "cfb32.h"
- </filename></literallayout>
- </para>
-
- <para>
- If a driver uses XAA, it needs these:
- <literallayout><filename>
- "xaa.h"
- "xaalocal.h"
- </filename></literallayout>
- </para>
-
- <para>
- If a driver uses the fb manager, it needs this:
- <literallayout><filename>
- "xf86fbman.h"
- </filename></literallayout>
- </para>
- </blockquote>
- </para>
-
- <para>
-Non-driver modules should include <filename>"xf86_ansic.h"</filename> to get the correct
-wrapping of ANSI C/libc functions.
- </para>
-
- <para>
-All modules must NOT include any system include files, or the following:
-
- <literallayout><filename>
- "xf86Priv.h"
- "xf86Privstr.h"
- "xf86_OSlib.h"
- "Xos.h"
- </filename></literallayout>
- </para>
-
- <para>
-In addition, "xf86_libc.h" must not be included explicitly. It is
-included implicitly by "xf86_ansic.h".
- </para>
-
- </sect2>
- </sect1>
-
- <sect1>
- <title>Offscreen Memory Manager</title>
-
- <para>
-Management of offscreen video memory may be handled by the XFree86
-framebuffer manager. Once the offscreen memory manager is running,
-drivers or extensions may allocate, free or resize areas of offscreen
-video memory using the following functions (definitions taken from
-<filename>xf86fbman.h</filename>):
-
- <programlisting>
- typedef struct _FBArea {
- ScreenPtr pScreen;
- BoxRec box;
- int granularity;
- void (*MoveAreaCallback)(struct _FBArea*, struct _FBArea*)
- void (*RemoveAreaCallback)(struct _FBArea*)
- DevUnion devPrivate;
- } FBArea, *FBAreaPtr;
-
- typedef void (*MoveAreaCallbackProcPtr)(FBAreaPtr from, FBAreaPtr to)
- typedef void (*RemoveAreaCallbackProcPtr)(FBAreaPtr)
-
- FBAreaPtr xf86AllocateOffscreenArea (
- ScreenPtr pScreen,
- int width, int height,
- int granularity,
- MoveAreaCallbackProcPtr MoveAreaCallback,
- RemoveAreaCallbackProcPtr RemoveAreaCallback,
- pointer privData
- )
-
- void xf86FreeOffscreenArea (FBAreaPtr area)
-
- Bool xf86ResizeOffscreenArea (
- FBAreaPtr area
- int w, int h
- )
- </programlisting>
- </para>
-
- <para>
-The function:
- <programlisting>
- Bool xf86FBManagerRunning(ScreenPtr pScreen);
- </programlisting>
-
-can be used by an extension to check if the driver has initialized
-the memory manager. The manager is not available if this returns
-<constant>FALSE</constant> and the functions above will all fail.
- </para>
-
-
- <para>
-<function>xf86AllocateOffscreenArea()</function> can be used to request a
-rectangle of dimensions <parameter>width</parameter>&nbsp;&times;&nbsp;<parameter>height</parameter>
-(in pixels) from unused offscreen memory. <parameter>granularity</parameter>
-specifies that the leftmost edge of the rectangle must lie on some
-multiple of <parameter>granularity</parameter> pixels. A granularity of zero
-means the same thing as a granularity of one - no alignment preference.
-A <parameter>MoveAreaCallback</parameter> can be provided to notify the requester
-when the offscreen area is moved. If no <parameter>MoveAreaCallback</parameter>
-is supplied then the area is considered to be immovable. The
-<parameter>privData</parameter> field will be stored in the manager's internal
-structure for that allocated area and will be returned to the requester
-in the <parameter>FBArea</parameter> passed via the
-<parameter>MoveAreaCallback</parameter>. An optional
-<parameter>RemoveAreaCallback</parameter> is provided. If the driver provides
-this it indicates that the area should be allocated with a lower priority.
-Such an area may be removed when a higher priority request (one that
-doesn't have a <parameter>RemoveAreaCallback</parameter>) is made. When this
-function is called, the driver will have an opportunity to do whatever
-cleanup it needs to do to deal with the loss of the area, but it must
-finish its cleanup before the function exits since the offscreen memory
-manager will free the area immediately after.
- </para>
-
- <para>
-<function>xf86AllocateOffscreenArea()</function> returns <constant>NULL</constant>
-if it was unable to allocate the requested area. When no longer needed,
-areas should be freed with <function>xf86FreeOffscreenArea()</function>.
- </para>
-
- <para>
-<function>xf86ResizeOffscreenArea()</function> resizes an existing
-<literal remap="tt">FBArea</literal>. <function>xf86ResizeOffscreenArea()</function>
-returns <constant>TRUE</constant> if the resize was successful. If
-<function>xf86ResizeOffscreenArea()</function> returns <constant>FALSE</constant>,
-the original <literal remap="tt">FBArea</literal> is left unmodified. Resizing an
-area maintains the area's original <literal remap="tt">granularity</literal>,
-<literal remap="tt">devPrivate</literal>, and <literal remap="tt">MoveAreaCallback</literal>.
-<function>xf86ResizeOffscreenArea()</function> has considerably less overhead
-than freeing the old area then reallocating the new size, so it should
-be used whenever possible.
- </para>
-
- <para>
-The function:
- <programlisting>
- Bool xf86QueryLargestOffscreenArea(
- ScreenPtr pScreen,
- int *width, int *height,
- int granularity,
- int preferences,
- int priority
- );
- </programlisting>
-
-is provided to query the width and height of the largest single
-<structname>FBArea</structname> allocatable given a particular priority.
-<parameter>preferences</parameter> can be one of the following to indicate
-whether width, height or area should be considered when determining
-which is the largest single <structname>FBArea</structname> available.
-
- <programlisting>
- FAVOR_AREA_THEN_WIDTH
- FAVOR_AREA_THEN_HEIGHT
- FAVOR_WIDTH_THEN_AREA
- FAVOR_HEIGHT_THEN_AREA
- </programlisting>
- </para>
-
- <para>
-<parameter>priority</parameter> is one of the following:
-
- <blockquote>
- <para>
- <constant>PRIORITY_LOW</constant>
- <blockquote><para>
- Return the largest block available without stealing anyone else's
- space. This corresponds to the priority of allocating a
- <structname>FBArea</structname> when a <function>RemoveAreaCallback</function>
- is provided.
- </para></blockquote>
- </para>
-
- <para>
- <constant>PRIORITY_NORMAL</constant>
- <blockquote><para>
- Return the largest block available if it is acceptable to steal a
- lower priority area from someone. This corresponds to the priority
- of allocating a <structname>FBArea</structname> without providing a
- <function>RemoveAreaCallback</function>.
- </para></blockquote>
- </para>
-
- <para>
- <constant>PRIORITY_EXTREME</constant>
- <blockquote><para>
- Return the largest block available if all <structname>FBArea</structname>s
- that aren't locked down were expunged from memory first. This
- corresponds to any allocation made directly after a call to
- <function>xf86PurgeUnlockedOffscreenAreas()</function>.
- </para></blockquote>
- </para>
-
- </blockquote>
- </para>
-
-
- <para>
-The function:
-
- <programlisting>
- Bool xf86PurgeUnlockedOffscreenAreas(ScreenPtr pScreen);
- </programlisting>
-
-is provided as an extreme method to free up offscreen memory. This
-will remove all removable <structname>FBArea</structname> allocations.
- </para>
-
-
- <para>
-Initialization of the XFree86 framebuffer manager is done via
-
- <programlisting>
- Bool xf86InitFBManager(ScreenPtr pScreen, BoxPtr FullBox);
- </programlisting>
-
-<parameter>FullBox</parameter> represents the area of the framebuffer that the
-manager is allowed to manage. This is typically a box with a width of
-<structfield>pScrn-&gt;displayWidth</structfield> and a height of as many lines as
-can be fit within the total video memory, however, the driver can reserve
-areas at the extremities by passing a smaller area to the manager.
- </para>
-
- <para>
-<function>xf86InitFBManager()</function> must be called before XAA is
-initialized since XAA uses the manager for it's pixmap cache.
- </para>
-
- <para>
-An alternative function is provided to allow the driver to initialize
-the framebuffer manager with a Region rather than a box.
-
- <programlisting>
- Bool xf86InitFBManagerRegion(ScreenPtr pScreen,
- RegionPtr FullRegion);
- </programlisting>
-
-<function>xf86InitFBManagerRegion()</function>, unlike
-<function>xf86InitFBManager()</function>, does not remove the area used for
-the visible screen so that area should not be included in the region
-passed to the function. <function>xf86InitFBManagerRegion()</function> is
-useful when non-contiguous areas are available to be managed, and is
-required when multiple framebuffers are stored in video memory (as in
-the case where an overlay of a different depth is stored as a second
-framebuffer in offscreen memory).
- </para>
-
- </sect1>
-
- <sect1 id="cmap">
- <title>Colormap Handling</title>
-
- <para>
-A generic colormap handling layer is provided within the XFree86 common
-layer. This layer takes care of most of the details, and only requires
-a function from the driver that loads the hardware palette when required.
-To use the colormap layer, a driver calls the
-<function>xf86HandleColormaps()</function> function.
-
- <blockquote><para>
- <programlisting>
- Bool xf86HandleColormaps(ScreenPtr pScreen, int maxColors,
- int sigRGBbits, LoadPaletteFuncPtr loadPalette,
- SetOverscanFuncPtr setOverscan,
- unsigned int flags);
- </programlisting>
- <blockquote><para>
- This function must be called after the default colormap has been
- initialised. The <structfield>pScrn-&gt;gamma</structfield> field must also
- be initialised, preferably by calling <function>xf86SetGamma()</function>.
- <parameter>maxColors</parameter> is the number of entries in the palette.
- <parameter>sigRGBbits</parameter> is the size in bits of each color
- component in the DAC's palette. <parameter>loadPalette</parameter>
- is a driver-provided function for loading a colormap into the
- hardware, and is described below. <parameter>setOverscan</parameter> is
- an optional function that may be provided when the overscan color
- is an index from the standard LUT and when it needs to be adjusted
- to keep it as close to black as possible. The
- <parameter>setOverscan</parameter> function programs the overscan index.
- It shouldn't normally be used for depths other than 8.
- <parameter>setOverscan</parameter> should be set to <constant>NULL</constant>
- when it isn't needed. <parameter>flags</parameter> may be set to the
- following (which may be ORed together):
-
- <variablelist>
- <varlistentry>
- <term><constant>CMAP_PALETTED_TRUECOLOR</constant></term>
- <listitem><para>
- the TrueColor visual is paletted and is
- just a special case of DirectColor.
- This flag is only valid for
- <code>bpp&nbsp;&gt;&nbsp;8</code>.
-
- </para></listitem></varlistentry>
- <varlistentry>
- <term><constant>CMAP_RELOAD_ON_MODE_SWITCH</constant></term>
- <listitem><para>
- reload the colormap automatically
- after mode switches. This is useful
- for when the driver is resetting the
- hardware during mode switches and
- corrupting or erasing the hardware
- palette.
-
- </para></listitem></varlistentry>
- <varlistentry>
- <term><constant>CMAP_LOAD_EVEN_IF_OFFSCREEN</constant></term>
- <listitem><para>
- reload the colormap even if the screen
- is switched out of the server's VC.
- The palette is <emphasis>not</emphasis> reloaded when
- the screen is switched back in, nor after
- mode switches. This is useful when the
- driver needs to keep track of palette
- changes.
-
- </para></listitem></varlistentry>
- </variablelist>
- </para>
-
- <para>
- The colormap layer normally reloads the palette after VT enters so it
- is not necessary for the driver to save and restore the palette
- when switching VTs. The driver must, however, still save the
- initial palette during server start up and restore it during
- server exit.
- </para>
-
- </blockquote></para></blockquote>
-
- <blockquote><para>
- <programlisting>
- void LoadPalette(ScrnInfoPtr pScrn, int numColors, int *indices,
- LOCO *colors, VisualPtr pVisual);
- </programlisting>
- <blockquote><para>
- <function>LoadPalette()</function> is a driver-provided function for
- loading a colormap into hardware. <parameter>colors</parameter> is the
- array of RGB values that represent the full colormap.
- <parameter>indices</parameter> is a list of index values into the colors
- array. These indices indicate the entries that need to be updated.
- <parameter>numColors</parameter> is the number of the indices to be
- updated.
- </para>
-
- </blockquote></para></blockquote>
-
- <blockquote><para>
- <programlisting>
- void SetOverscan(ScrnInfoPtr pScrn, int overscan);
- </programlisting>
- <blockquote><para>
- <function>SetOverscan()</function> is a driver-provided function for
- programming the <parameter>overscan</parameter> index. As described
- above, it is normally only appropriate for LUT modes where all
- colormap entries are available for the display, but where one of
- them is also used for the overscan (typically 8bpp for VGA compatible
- LUTs). It isn't required in cases where the overscan area is
- never visible.
- </para>
-
- </blockquote></para>
- </blockquote></para>
-
- </sect1>
-
- <sect1>
- <title>DPMS Extension</title>
-
- <para>
-Support code for the DPMS extension is included in the XFree86 common layer.
-This code provides an interface between the main extension code, and a means
-for drivers to initialise DPMS when they support it. One function is
-available to drivers to do this initialisation, and it is always available,
-even when the DPMS extension is not supported by the core server (in
-which case it returns a failure result).
- </para>
-
- <blockquote><para>
- <programlisting>
- Bool xf86DPMSInit(ScreenPtr pScreen, DPMSSetProcPtr set, int flags);
- </programlisting>
- <blockquote><para>
- This function registers a driver's DPMS level programming function
- <parameter>set</parameter>. It also checks
- <structfield>pScrn-&gt;options</structfield> for the "dpms" option, and when
- present marks DPMS as being enabled for that screen. The
- <parameter>set</parameter> function is called whenever the DPMS level
- changes, and is used to program the requested level.
- <parameter>flags</parameter> is currently not used, and should be
- <constant>0</constant>. If the initialisation fails for any reason,
- including when there is no DPMS support in the core server, the
- function returns <constant>FALSE</constant>.
- </para>
-
- </blockquote></para></blockquote>
-
-
- <para>
-Drivers that implement DPMS support must provide the following function,
-that gets called when the DPMS level is changed:
-
-
- <blockquote><para>
- <programlisting>
- void ChipDPMSSet(ScrnInfoPtr pScrn, int level, int flags);
- </programlisting>
- <blockquote><para>
- Program the DPMS level specified by <parameter>level</parameter>. Valid
- values of <parameter>level</parameter> are <constant>DPMSModeOn</constant>,
- <constant>DPMSModeStandby</constant>, <constant>DPMSModeSuspend</constant>,
- <constant>DPMSModeOff</constant>. These values are defined in
- <filename>"extensions/dpms.h"</filename>.
- </para>
-
- </blockquote></para></blockquote>
- </para>
-
- </sect1>
-
- <sect1>
- <title>DGA Extension</title>
-
- <para>
-Drivers can support the XFree86 Direct Graphics Architecture (DGA) by
-filling out a structure of function pointers and a list of modes and
-passing them to DGAInit.
- </para>
-
- <blockquote><para>
- <programlisting>
- Bool DGAInit(ScreenPtr pScreen, DGAFunctionPtr funcs,
- DGAModePtr modes, int num);
-
-/** The DGAModeRec **/
-
-typedef struct {
- int num;
- DisplayModePtr mode;
- int flags;
- int imageWidth;
- int imageHeight;
- int pixmapWidth;
- int pixmapHeight;
- int bytesPerScanline;
- int byteOrder;
- int depth;
- int bitsPerPixel;
- unsigned long red_mask;
- unsigned long green_mask;
- unsigned long blue_mask;
- int viewportWidth;
- int viewportHeight;
- int xViewportStep;
- int yViewportStep;
- int maxViewportX;
- int maxViewportY;
- int viewportFlags;
- int offset;
- unsigned char *address;
- int reserved1;
- int reserved2;
-} DGAModeRec, *DGAModePtr;
- </programlisting>
-
- <variablelist>
- <varlistentry>
- <term><structfield>num</structfield></term>
- <listitem><para>
- Can be ignored. The DGA DDX will assign these numbers.
- </para></listitem></varlistentry>
-
- <varlistentry>
- <term><structfield>mode</structfield></term>
- <listitem><para>
- A pointer to the <structname>DisplayModeRec</structname> for this mode.
- </para></listitem></varlistentry>
-
- <varlistentry>
- <term><structfield>flags</structfield></term>
- <listitem><para>
- The following flags are defined and may be OR'd together:
-
- <variablelist>
- <varlistentry>
- <term><constant>DGA_CONCURRENT_ACCESS</constant></term>
- <listitem><para>
- Indicates that the driver supports concurrent graphics
- accelerator and linear framebuffer access.
-
- </para></listitem></varlistentry>
-
- <varlistentry>
- <term><constant>DGA_FILL_RECT
- DGA_BLIT_RECT
- DGA_BLIT_RECT_TRANS</constant></term>
- <listitem><para>
- Indicates that the driver supports the FillRect, BlitRect
- or BlitTransRect functions in this mode.
-
- </para></listitem></varlistentry>
-
- <varlistentry>
- <term><constant>DGA_PIXMAP_AVAILABLE</constant></term>
- <listitem><para>
- Indicates that Xlib may be used on the framebuffer.
- This flag will usually be set unless the driver wishes
- to prohibit this for some reason.
-
- </para></listitem></varlistentry>
-
- <varlistentry>
- <term><constant>DGA_INTERLACED
- DGA_DOUBLESCAN</constant></term>
- <listitem><para>
- Indicates that these are interlaced or double scan modes.
-
- </para></listitem></varlistentry>
- </variablelist>
- </para></listitem></varlistentry>
-
- <varlistentry>
- <term><structfield>imageWidth
- imageHeight</structfield></term>
- <listitem><para>
- These are the dimensions of the linear framebuffer
- accessible by the client.
-
- </para></listitem></varlistentry>
-
- <varlistentry>
- <term><structfield>pixmapWidth
- pixmapHeight</structfield></term>
- <listitem><para>
- These are the dimensions of the area of the
- framebuffer accessible by the graphics accelerator.
-
- </para></listitem></varlistentry>
-
- <varlistentry>
- <term><structfield>bytesPerScanline</structfield></term>
- <listitem><para>
- Pitch of the framebuffer in bytes.
-
- </para></listitem></varlistentry>
-
- <varlistentry>
- <term><structfield>byteOrder</structfield></term>
- <listitem><para>
- Usually the same as
- <structfield>pScrn-&gt;imageByteOrder</structfield>.
-
- </para></listitem></varlistentry>
-
- <varlistentry>
- <term><structfield>depth</structfield></term>
- <listitem><para>
- The depth of the framebuffer in this mode.
-
- </para></listitem></varlistentry>
-
- <varlistentry>
- <term><structfield>bitsPerPixel</structfield></term>
- <listitem><para>
- The number of bits per pixel in this mode.
-
- </para></listitem></varlistentry>
-
- <varlistentry>
- <term><structfield>red_mask</structfield></term>
- <term><structfield>green_mask</structfield></term>
- <term><structfield>blue_mask</structfield></term>
- <listitem><para>
- The RGB masks for this mode, if applicable.
-
- </para></listitem></varlistentry>
-
- <varlistentry>
- <term><structfield>viewportWidth</structfield></term>
- <term><structfield>viewportHeight</structfield></term>
- <listitem><para>
- Dimensions of the visible part of the framebuffer.
- Usually <structfield>mode-&gt;HDisplay</structfield> and
- <structfield>mode-&gt;VDisplay</structfield>.
-
- </para></listitem></varlistentry>
-
- <varlistentry>
- <term><structfield>xViewportStep
- yViewportStep</structfield></term>
- <listitem><para>
- The granularity of x and y viewport positions that
- the driver supports in this mode.
-
- </para></listitem></varlistentry>
-
- <varlistentry>
- <term><structfield>maxViewportX
- maxViewportY</structfield></term>
- <listitem><para>
- The maximum viewport position supported by the
- driver in this mode.
- </para></listitem></varlistentry>
-
- <varlistentry>
- <term><structfield>viewportFlags</structfield></term>
- <listitem><para>
- The following may be OR'd together:
-
- <variablelist>
- <varlistentry>
- <term><constant>DGA_FLIP_IMMEDIATE</constant></term>
- <listitem><para>
- The driver supports immediate viewport changes.
- </para></listitem></varlistentry>
-
- <varlistentry>
- <term><constant>DGA_FLIP_RETRACE</constant></term>
-
- <listitem><para>
- The driver supports viewport changes at retrace.
- </para></listitem></varlistentry>
- </variablelist>
- </para></listitem></varlistentry>
-
- <varlistentry>
- <term><structfield>offset</structfield></term>
- <listitem><para>
- The offset into the linear framebuffer that corresponds to
- pixel (0,0) for this mode.
- </para></listitem></varlistentry>
-
- <varlistentry>
- <term><structfield>address</structfield></term>
- <listitem><para>
- The virtual address of the framebuffer as mapped by the driver.
- This is needed when DGA_PIXMAP_AVAILABLE is set.
- </para></listitem></varlistentry>
-
- </variablelist>
-
- <programlisting>
-/** The DGAFunctionRec **/
-
-typedef struct {
- Bool (*OpenFramebuffer)(
- ScrnInfoPtr pScrn,
- char **name,
- unsigned char **mem,
- int *size,
- int *offset,
- int *extra
- );
- void (*CloseFramebuffer)(ScrnInfoPtr pScrn);
- Bool (*SetMode)(ScrnInfoPtr pScrn, DGAModePtr pMode);
- void (*SetViewport)(ScrnInfoPtr pScrn, int x, int y, int flags);
- int (*GetViewport)(ScrnInfoPtr pScrn);
- void (*Sync)(ScrnInfoPtr);
- void (*FillRect)(
- ScrnInfoPtr pScrn,
- int x, int y, int w, int h,
- unsigned long color
- );
- void (*BlitRect)(
- ScrnInfoPtr pScrn,
- int srcx, int srcy,
- int w, int h,
- int dstx, int dsty
- );
- void (*BlitTransRect)(
- ScrnInfoPtr pScrn,
- int srcx, int srcy,
- int w, int h,
- int dstx, int dsty,
- unsigned long color
- );
-} DGAFunctionRec, *DGAFunctionPtr;
- </programlisting>
-
-
- <blockquote><para>
- <programlisting>
- Bool OpenFramebuffer (pScrn, name, mem, size, offset, extra);
- </programlisting>
- <blockquote><para>
- <function>OpenFramebuffer()</function> should pass the client everything
- it needs to know to be able to open the framebuffer. These
- parameters are OS specific and their meanings are to be interpreted
- by an OS specific client library.
-
- <variablelist>
- <varlistentry>
- <term><parameter>name</parameter></term>
- <listitem><para>
- The name of the device to open or <constant>NULL</constant> if
- there is no special device to open. A <constant>NULL</constant>
- name tells the client that it should open whatever device
- one would usually open to access physical memory.
- </para></listitem></varlistentry>
-
- <varlistentry>
- <term><parameter>mem</parameter></term>
- <listitem><para>
- The physical address of the start of the framebuffer.
- </para></listitem></varlistentry>
-
- <varlistentry>
- <term><parameter>size</parameter></term>
- <listitem><para>
- The size of the framebuffer in bytes.
- </para></listitem></varlistentry>
-
- <varlistentry>
- <term><parameter>offset</parameter></term>
- <listitem><para>
- Any offset into the device, if applicable.
- </para></listitem></varlistentry>
-
- <varlistentry>
- <term><parameter>flags</parameter></term>
- <listitem><para>
- Any additional information that the client may need.
- Currently, only the <constant>DGA_NEED_ROOT</constant> flag is
- defined.
- </para></listitem></varlistentry>
-
- </variablelist>
- </para></blockquote>
- </para></blockquote>
-
- <blockquote><para>
- <programlisting>
- void CloseFramebuffer (pScrn);
- </programlisting>
- <blockquote><para>
- <function>CloseFramebuffer()</function> merely informs the driver (if it
- even cares) that client no longer needs to access the framebuffer
- directly. This function is optional.
- </para>
-
- </blockquote></para></blockquote>
-
- <blockquote><para>
- <programlisting>
- Bool SetMode (pScrn, pMode);
- </programlisting>
- <blockquote><para>
- <function>SetMode()</function> tells the driver to initialize the mode
- passed to it. If <parameter>pMode</parameter> is <constant>NULL</constant>,
- then the driver should restore the original pre-DGA mode.
- </para>
-
- </blockquote></para></blockquote>
-
- <blockquote><para>
- <programlisting>
- void SetViewport (pScrn, x, y, flags);
- </programlisting>
- <blockquote><para>
- <function>SetViewport()</function> tells the driver to make the upper
- left-hand corner of the visible screen correspond to coordinate
- <literal remap="tt">(x,y)</literal> on the framebuffer. <parameter>flags</parameter>
- currently defined are:
-
- <variablelist>
- <varlistentry>
- <term><constant>DGA_FLIP_IMMEDIATE</constant></term>
- <listitem><para>
- The viewport change should occur immediately.
- </para></listitem></varlistentry>
-
- <varlistentry>
- <term><constant>DGA_FLIP_RETRACE</constant></term>
- <listitem><para>
- The viewport change should occur at the
- vertical retrace, but this function should
- return sooner if possible.
- </para></listitem></varlistentry>
- </variablelist>
- </para>
-
- <para>
- The <literal remap="tt">(x,y)</literal> locations will be passed as the client
- specified them, however, the driver is expected to round these
- locations down to the next supported location as specified by the
- <structfield>xViewportStep</structfield> and <structfield>yViewportStep</structfield>
- for the current mode.
- </para>
- </blockquote></para></blockquote>
-
- <blockquote><para>
- <programlisting>
- int GetViewport (pScrn);
- </programlisting>
- <blockquote><para>
- <function>GetViewport()</function> gets the current page flip status.
- Set bits in the returned int correspond to viewport change requests
- still pending. For instance, set bit zero if the last SetViewport
- request is still pending, bit one if the one before that is still
- pending, etc.
- </para>
-
- </blockquote></para></blockquote>
-
- <blockquote><para>
- <programlisting>
- void Sync (pScrn);
- </programlisting>
- <blockquote><para>
- This function should ensure that any graphics accelerator operations
- have finished. This function should not return until the graphics
- accelerator is idle.
- </para>
-
- </blockquote></para></blockquote>
-
- <blockquote><para>
- <programlisting>
- void FillRect (pScrn, x, y, w, h, color);
- </programlisting>
- <blockquote><para>
- This optional function should fill a rectangle
- <parameter>w&nbsp;&times;&nbsp;h</parameter> located at
- <parameter>(x,y)</parameter> in the given color.
- </para>
-
- </blockquote></para></blockquote>
-
- <blockquote><para>
- <programlisting>
- void BlitRect (pScrn, srcx, srcy, w, h, dstx, dsty);
- </programlisting>
- <blockquote><para>
- This optional function should copy an area
- <parameter>w&nbsp;&times;&nbsp;h</parameter> located at
- <parameter>(srcx,srcy)</parameter> to location <parameter>(dstx,dsty)</parameter>.
- This function will need to handle copy directions as appropriate.
- </para>
-
- </blockquote></para></blockquote>
-
- <blockquote><para>
- <programlisting>
- void BlitTransRect (pScrn, srcx, srcy, w, h, dstx, dsty, color);
- </programlisting>
- <blockquote><para>
- This optional function is the same as BlitRect except that pixels
- in the source corresponding to the color key <parameter>color</parameter>
- should be skipped.
- </para>
-
- </blockquote></para></blockquote>
- </para></blockquote>
-
- </sect1>
-
- <sect1>
- <title>The XFree86 X Video Extension (Xv) Device Dependent Layer</title>
-
- <para>
-XFree86 offers the X Video Extension which allows clients to treat video
-as any another primitive and <quote>Put</quote> video into drawables. By default,
-the extension reports no video adaptors as being available since the
-DDX layer has not been initialized. The driver can initialize the DDX
-layer by filling out one or more <literal remap="tt">XF86VideoAdaptorRecs</literal>
-as described later in this document and passing a list of
-<literal remap="tt">XF86VideoAdaptorPtr</literal> pointers to the following function:
-
- <programlisting>
- Bool xf86XVScreenInit(ScreenPtr pScreen,
- XF86VideoAdaptorPtr *adaptPtrs,
- int num);
- </programlisting>
- </para>
-
- <para>
-After doing this, the extension will report video adaptors as being
-available, providing the data in their respective
-<literal remap="tt">XF86VideoAdaptorRecs</literal> was valid.
-<function>xf86XVScreenInit()</function> <emphasis>copies</emphasis> data from the structure
-passed to it so the driver may free it after the initialization. At
-the moment, the DDX only supports rendering into Window drawables.
-Pixmap rendering will be supported after a sufficient survey of suitable
-hardware is completed.
- </para>
-
- <para>
-The <structname>XF86VideoAdaptorRec</structname>:
-
- <programlisting>
-typedef struct {
- unsigned int type;
- int flags;
- char *name;
- int nEncodings;
- XF86VideoEncodingPtr pEncodings;
- int nFormats;
- XF86VideoFormatPtr pFormats;
- int nPorts;
- DevUnion *pPortPrivates;
- int nAttributes;
- XF86AttributePtr pAttributes;
- int nImages;
- XF86ImagePtr pImages;
- PutVideoFuncPtr PutVideo;
- PutStillFuncPtr PutStill;
- GetVideoFuncPtr GetVideo;
- GetStillFuncPtr GetStill;
- StopVideoFuncPtr StopVideo;
- SetPortAttributeFuncPtr SetPortAttribute;
- GetPortAttributeFuncPtr GetPortAttribute;
- QueryBestSizeFuncPtr QueryBestSize;
- PutImageFuncPtr PutImage;
- QueryImageAttributesFuncPtr QueryImageAttributes;
-} XF86VideoAdaptorRec, *XF86VideoAdaptorPtr;
- </programlisting></para>
-
- <para>
-Each adaptor will have its own XF86VideoAdaptorRec. The fields are
-as follows:
-
- <variablelist>
- <varlistentry>
- <term><structfield>type</structfield></term>
- <listitem><para>
- This can be any of the following flags OR'd together.
-
- <variablelist>
- <varlistentry>
- <term><constant>XvInputMask</constant>
- <constant>XvOutputMask</constant></term>
- <listitem><para>
- These refer to the target drawable and are similar to a Window's
- class. <literal remap="tt">XvInputMask</literal> indicates that the adaptor
- can put video into a drawable. <literal remap="tt">XvOutputMask</literal>
- indicates that the adaptor can get video from a drawable.
- </para></listitem></varlistentry>
-
- <varlistentry>
- <term><constant>XvVideoMask</constant>
- <constant>XvStillMask</constant>
- <constant>XvImageMask</constant></term>
- <listitem><para>
- These indicate that the adaptor supports video, still or
- image primitives respectively.
- </para></listitem></varlistentry>
-
- <varlistentry>
- <term><constant>XvWindowMask</constant>
- <constant>XvPixmapMask</constant></term>
- <listitem><para>
- These indicate the types of drawables the adaptor is capable
- of rendering into. At the moment, Pixmap rendering is not
- supported and the <constant>XvPixmapMask</constant> flag is ignored.
- </para></listitem></varlistentry>
- </variablelist>
-
- </para></listitem></varlistentry>
-
- <varlistentry>
- <term><structfield>flags</structfield></term>
- <listitem><para>
- Currently, the following flags are defined:
-
- <variablelist>
- <varlistentry>
- <term><constant>VIDEO_NO_CLIPPING</constant></term>
- <listitem><para>
- This indicates that the video adaptor does not support
- clipping. The driver will never receive <quote>Put</quote> requests
- where less than the entire area determined by
- <parameter>drw_x</parameter>, <parameter>drw_y</parameter>,
- <parameter>drw_w</parameter> and <parameter>drw_h</parameter> is visible.
- This flag does not apply to <quote>Get</quote> requests. Hardware
- that is incapable of clipping <quote>Gets</quote> may punt or get
- the extents of the clipping region passed to it.
- </para></listitem>
-
- </varlistentry>
-
- <varlistentry>
- <term><constant>VIDEO_INVERT_CLIPLIST</constant></term>
- <listitem><para>
- This indicates that the video driver requires the clip
- list to contain the regions which are obscured rather
- than the regions which are are visible.
- </para></listitem>
-
- </varlistentry>
-
- <varlistentry>
- <term><constant>VIDEO_OVERLAID_STILLS</constant></term>
- <listitem><para>
- Implementing PutStill for hardware that does video as an
- overlay can be awkward since it's unclear how long to leave
- the video up for. When this flag is set, StopVideo will be
- called whenever the destination gets clipped or moved so that
- the still can be left up until then.
- </para></listitem>
-
- </varlistentry>
-
- <varlistentry>
- <term><constant>VIDEO_OVERLAID_IMAGES</constant></term>
- <listitem><para>
- Same as <constant>VIDEO_OVERLAID_STILLS</constant> but for images.
- </para></listitem>
- </varlistentry>
-
- <varlistentry>
- <term><constant>VIDEO_CLIP_TO_VIEWPORT</constant></term>
- <listitem><para>
- Indicates that the clip region passed to the driver functions
- should be clipped to the visible portion of the screen in the
- case where the viewport is smaller than the virtual desktop.
- </para></listitem></varlistentry>
-
- </variablelist>
- </para></listitem></varlistentry>
-
- <varlistentry>
- <term><structfield>name</structfield></term>
- <listitem><para>
- The name of the adaptor.
- </para></listitem></varlistentry>
-
-
- <varlistentry>
- <term><structfield>nEncodings</structfield>
- <structfield>pEncodings</structfield></term>
- <listitem><para>
- The number of encodings the adaptor is capable of and pointer
- to the <structname>XF86VideoEncodingRec</structname> array. The
- <structname>XF86VideoEncodingRec</structname> is described later on.
- For drivers that only support XvImages there should be an encoding
- named "XV_IMAGE" and the width and height should specify
- the maximum size source image supported.
- </para></listitem></varlistentry>
-
-
- <varlistentry>
- <term><structfield>nFormats</structfield>
- <structfield>pFormats</structfield></term>
- <listitem><para>
- The number of formats the adaptor is capable of and pointer to
- the <structname>XF86VideoFormatRec</structname> array. The
- <structname>XF86VideoFormatRec</structname> is described later on.
- </para></listitem></varlistentry>
-
-
- <varlistentry>
- <term><structfield>nPorts</structfield>
- <structfield>pPortPrivates</structfield></term>
- <listitem><para>
- The number of ports is the number of separate data streams which
- the adaptor can handle simultaneously. If you have more than
- one port, the adaptor is expected to be able to render into more
- than one window at a time. <structfield>pPortPrivates</structfield> is
- an array of pointers or ints - one for each port. A port's
- private data will be passed to the driver any time the port is
- requested to do something like put the video or stop the video.
- In the case where there may be many ports, this enables the
- driver to know which port the request is intended for. Most
- commonly, this will contain a pointer to the data structure
- containing information about the port. In Xv, all ports on
- a particular adaptor are expected to be identical in their
- functionality.
- </para></listitem></varlistentry>
-
-
- <varlistentry>
- <term><structfield>nAttributes</structfield>
- <structfield>pAttributes</structfield></term>
- <listitem><para>
- The number of attributes recognized by the adaptor and a pointer to
- the array of <structname>XF86AttributeRecs</structname>. The
- <structname>XF86AttributeRec</structname> is described later on.
- </para></listitem></varlistentry>
-
-
- <varlistentry>
- <term><structfield>nImages</structfield>
- <structfield>pImages</structfield></term>
- <listitem><para>
- The number of <structname>XF86ImageRecs</structname> supported by the adaptor
- and a pointer to the array of <structname>XF86ImageRecs</structname>. The
- <structname>XF86ImageRec</structname> is described later on.
- </para></listitem></varlistentry>
-
-
- <varlistentry>
- <term><structfield>
- PutVideo PutStill GetVideo GetStill StopVideo
- SetPortAttribute GetPortAttribute QueryBestSize PutImage
- QueryImageAttributes
- </structfield></term>
- <listitem><para>
- These functions define the DDX-&gt;driver interface. In each
- case, the pointer <parameter>data</parameter> is passed to the driver.
- This is the port private for that port as described above. All
- fields are required except under the following conditions:
-
- <orderedlist>
- <listitem><para>
- <structfield>PutVideo</structfield>, <structfield>PutStill</structfield> and
- the image routines <structfield>PutImage</structfield> and
- <structfield>QueryImageAttributes</structfield> are not required when the
- adaptor type does not contain <constant>XvInputMask</constant>.
- </para></listitem>
-
- <listitem><para>
- <structfield>GetVideo</structfield> and <structfield>GetStill</structfield>
- are not required when the adaptor type does not contain
- <constant>XvOutputMask</constant>.
- </para></listitem>
-
- <listitem><para>
- <structfield>GetVideo</structfield> and <structfield>PutVideo</structfield>
- are not required when the adaptor type does not contain
- <constant>XvVideoMask</constant>.
- </para></listitem>
-
- <listitem><para>
- <structfield>GetStill</structfield> and <structfield>PutStill</structfield>
- are not required when the adaptor type does not contain
- <constant>XvStillMask</constant>.
- </para></listitem>
-
- <listitem><para>
- <structfield>PutImage</structfield> and <structfield>QueryImageAttributes</structfield>
- are not required when the adaptor type does not contain
- <constant>XvImageMask</constant>.
- </para></listitem>
-
- </orderedlist>
-
- </para>
-
- <para>
- With the exception of <structfield>QueryImageAttributes</structfield>, these
- functions should return <constant>Success</constant> if the operation was
- completed successfully. They can return <constant>XvBadAlloc</constant>
- otherwise. <structfield>QueryImageAttributes</structfield> returns the size
- of the XvImage queried.
- </para>
-
- <para>
- If the <constant>VIDEO_NO_CLIPPING</constant>
- flag is set, the <literal remap="tt">clipBoxes</literal> may be ignored by
- the driver. <literal remap="tt">ClipBoxes</literal> is an <literal remap="tt">X-Y</literal>
- banded region identical to those used throughout the server.
- The clipBoxes represent the visible portions of the area determined
- by <literal remap="tt">drw_x</literal>, <literal remap="tt">drw_y</literal>,
- <literal remap="tt">drw_w</literal> and <literal remap="tt">drw_h</literal> in the Get/Put
- function. The boxes are in screen coordinates, are guaranteed
- not to overlap and an empty region will never be passed.
- If the driver has specified <constant>VIDEO_INVERT_CLIPLIST</constant>,
- <literal remap="tt">clipBoxes</literal> will indicate the areas of the primitive
- which are obscured rather than the areas visible.
-
- </para></listitem></varlistentry>
- </variablelist>
-
- <blockquote><para>
- <programlisting>
- typedef int (* PutVideoFuncPtr)( ScrnInfoPtr pScrn,
- short vid_x, short vid_y, short drw_x, short drw_y,
- short vid_w, short vid_h, short drw_w, short drw_h,
- RegionPtr clipBoxes, pointer data );
- </programlisting>
- <blockquote><para>
- This indicates that the driver should take a subsection
- <parameter>vid_w</parameter> by <parameter>vid_h</parameter> at location
- <parameter>(vid_x,vid_y)</parameter> from the video stream and direct
- it into the rectangle <parameter>drw_w</parameter> by <parameter>drw_h</parameter>
- at location <parameter>(drw_x,drw_y)</parameter> on the screen, scaling as
- necessary. Due to the large variations in capabilities of
- the various hardware expected to be used with this extension,
- it is not expected that all hardware will be able to do this
- exactly as described. In that case the driver should just do
- <quote>the best it can,</quote> scaling as closely to the target rectangle
- as it can without rendering outside of it. In the worst case,
- the driver can opt to just not turn on the video.
- </para>
-
- </blockquote></para></blockquote>
-
- <blockquote><para>
- <programlisting>
- typedef int (* PutStillFuncPtr)( ScrnInfoPtr pScrn,
- short vid_x, short vid_y, short drw_x, short drw_y,
- short vid_w, short vid_h, short drw_w, short drw_h,
- RegionPtr clipBoxes, pointer data );
- </programlisting>
- <blockquote><para>
- This is same as <structfield>PutVideo</structfield> except that the driver
- should place only one frame from the stream on the screen.
- </para>
-
- </blockquote></para></blockquote>
-
- <blockquote><para>
- <programlisting>
- typedef int (* GetVideoFuncPtr)( ScrnInfoPtr pScrn,
- short vid_x, short vid_y, short drw_x, short drw_y,
- short vid_w, short vid_h, short drw_w, short drw_h,
- RegionPtr clipBoxes, pointer data );
- </programlisting>
- <blockquote><para>
- This is same as <structfield>PutVideo</structfield> except that the driver
- gets video from the screen and outputs it. The driver should
- do the best it can to get the requested dimensions correct
- without reading from an area larger than requested.
- </para>
-
- </blockquote></para></blockquote>
-
- <blockquote><para>
- <programlisting>
- typedef int (* GetStillFuncPtr)( ScrnInfoPtr pScrn,
- short vid_x, short vid_y, short drw_x, short drw_y,
- short vid_w, short vid_h, short drw_w, short drw_h,
- RegionPtr clipBoxes, pointer data );
- </programlisting>
- <blockquote><para>
- This is the same as <literal remap="tt">GetVideo</literal> except that the
- driver should place only one frame from the screen into the
- output stream.
- </para>
-
- </blockquote></para></blockquote>
-
- <blockquote><para>
- <programlisting>
- typedef void (* StopVideoFuncPtr)(ScrnInfoPtr pScrn,
- pointer data, Bool cleanup);
- </programlisting>
- <blockquote><para>
- This indicates the driver should stop displaying the video.
- This is used to stop both input and output video. The
- <parameter>cleanup</parameter> field indicates that the video is
- being stopped because the client requested it to stop or
- because the server is exiting the current VT. In that case
- the driver should deallocate any offscreen memory areas (if
- there are any) being used to put the video to the screen. If
- <parameter>cleanup</parameter> is not set, the video is being stopped
- temporarily due to clipping or moving of the window, etc...
- and video will likely be restarted soon so the driver should
- not deallocate any offscreen areas associated with that port.
- </para>
-
- </blockquote></para></blockquote>
- <blockquote><para>
- <programlisting>
- typedef int (* SetPortAttributeFuncPtr)(ScrnInfoPtr pScrn,
- Atom attribute,INT32 value, pointer data);
- </programlisting>
-
- <programlisting>
- typedef int (* GetPortAttributeFuncPtr)(ScrnInfoPtr pScrn,
- Atom attribute,INT32 *value, pointer data);
- </programlisting>
- <blockquote><para>
- A port may have particular attributes such as hue,
- saturation, brightness or contrast. Xv clients set and
- get these attribute values by sending attribute strings
- (Atoms) to the server. Such requests end up at these
- driver functions. It is recommended that the driver provide
- at least the following attributes mentioned in the Xv client
- library docs:
- <literallayout><constant>
- XV_ENCODING
- XV_HUE
- XV_SATURATION
- XV_BRIGHTNESS
- XV_CONTRAST
- </constant></literallayout>
- but the driver may recognize as many atoms as it wishes. If
- a requested attribute is unknown by the driver it should return
- <constant>BadMatch</constant>. <constant>XV_ENCODING</constant> is the
- attribute intended to let the client specify which video
- encoding the particular port should be using (see the description
- of <structname>XF86VideoEncodingRec</structname> below). If the
- requested encoding is unsupported, the driver should return
- <constant>XvBadEncoding</constant>. If the value lies outside the
- advertised range <constant>BadValue</constant> may be returned.
- <constant>Success</constant> should be returned otherwise.
- </para>
-
- </blockquote></para></blockquote>
-
- <blockquote><para>
- <programlisting>
- typedef void (* QueryBestSizeFuncPtr)(ScrnInfoPtr pScrn,
- Bool motion, short vid_w, short vid_h,
- short drw_w, short drw_h,
- unsigned int *p_w, unsigned int *p_h, pointer data);
- </programlisting>
- <blockquote><para>
- <function>QueryBestSize</function> provides the client with a way
- to query what the destination dimensions would end up being
- if they were to request that an area
- <parameter>vid_w</parameter> by <parameter>vid_h</parameter> from the video
- stream be scaled to rectangle of
- <parameter>drw_w</parameter> by <parameter>drw_h</parameter> on the screen.
- Since it is not expected that all hardware will be able to
- get the target dimensions exactly, it is important that the
- driver provide this function.
- </para>
-
- </blockquote></para></blockquote>
-
- <blockquote><para>
- <programlisting>
- typedef int (* PutImageFuncPtr)( ScrnInfoPtr pScrn,
- short src_x, short src_y, short drw_x, short drw_y,
- short src_w, short src_h, short drw_w, short drw_h,
- int image, char *buf, short width, short height,
- Bool sync, RegionPtr clipBoxes, pointer data );
- </programlisting>
- <blockquote><para>
- This is similar to <structfield>PutStill</structfield> except that the
- source of the video is not a port but the data stored in a system
- memory buffer at <parameter>buf</parameter>. The data is in the format
- indicated by the <parameter>image</parameter> descriptor and represents a
- source of size <parameter>width</parameter> by <parameter>height</parameter>.
- If <parameter>sync</parameter> is TRUE the driver should not return
- from this function until it is through reading the data
- from <parameter>buf</parameter>. Returning when <parameter>sync</parameter>
- is TRUE indicates that it is safe for the data at <parameter>buf</parameter>
- to be replaced, freed, or modified.
- </para>
-
- </blockquote></para></blockquote>
-
- <blockquote><para>
- <programlisting>
- typedef int (* QueryImageAttributesFuncPtr)( ScrnInfoPtr pScrn,
- int image, short *width, short *height,
- int *pitches, int *offsets);
- </programlisting>
- <blockquote><para>
- This function is called to let the driver specify how data for
- a particular <parameter>image</parameter> of size <parameter>width</parameter>
- by <parameter>height</parameter> should be stored. Sometimes only
- the size and corrected width and height are needed. In that
- case <parameter>pitches</parameter> and <parameter>offsets</parameter> are
- NULL. The size of the memory required for the image is returned
- by this function. The <parameter>width</parameter> and
- <parameter>height</parameter> of the requested image can be altered by
- the driver to reflect format limitations (such as component
- sampling periods that are larger than one). If
- <parameter>pitches</parameter> and <parameter>offsets</parameter> are not NULL,
- these will be arrays with as many elements in them as there
- are planes in the <parameter>image</parameter> format. The driver
- should specify the pitch (in bytes) of each scanline in the
- particular plane as well as the offset to that plane (in bytes)
- from the beginning of the image.
- </para>
-
- </blockquote></para></blockquote>
- </para>
-
- <para>
-The XF86VideoEncodingRec:
-
- <blockquote><para>
- <programlisting>
-typedef struct {
- int id;
- char *name;
- unsigned short width, height;
- XvRationalRec rate;
-} XF86VideoEncodingRec, *XF86VideoEncodingPtr;
-
- </programlisting>
- <blockquote><para>
- The <structname>XF86VideoEncodingRec</structname> specifies what encodings
- the adaptor can support. Most of this data is just informational
- and for the client's benefit, and is what will be reported by
- <function>XvQueryEncodings</function>. The <parameter>id</parameter> field is
- expected to be a unique identifier to allow the client to request a
- certain encoding via the <constant>XV_ENCODING</constant> attribute string.
-
- </para>
- </blockquote></para></blockquote>
- </para>
-
- <para>
-The XF86VideoFormatRec:
-
- <blockquote><para>
- <programlisting>
-typedef struct {
- char depth;
- short class;
-} XF86VideoFormatRec, *XF86VideoFormatPtr;
-
- </programlisting>
- <blockquote><para>
- This specifies what visuals the video is viewable in.
- <parameter>depth</parameter> is the depth of the visual (not bpp).
- <parameter>class</parameter> is the visual class such as
- <constant>TrueColor</constant>, <constant>DirectColor</constant> or
- <constant>PseudoColor</constant>. Initialization of an adaptor will fail
- if none of the visuals on that screen are supported.
- </para>
-
- </blockquote></para></blockquote>
- </para>
-
- <para>
-The XF86AttributeRec:
-
- <blockquote><para>
- <programlisting>
-typedef struct {
- int flags;
- int min_value;
- int max_value;
- char *name;
-} XF86AttributeListRec, *XF86AttributeListPtr;
-
- </programlisting>
- <blockquote><para>
- Each adaptor may have an array of these advertising the attributes
- for its ports. Currently defined flags are <literal remap="tt">XvGettable</literal>
- and <literal remap="tt">XvSettable</literal> which may be OR'd together indicating that
- attribute is <quote>gettable</quote> or <quote>settable</quote> by the client. The
- <literal remap="tt">min</literal> and <literal remap="tt">max</literal> field specify the valid range
- for the value. <literal remap="tt">Name</literal> is a text string describing the
- attribute by name.
- </para>
-
- </blockquote></para></blockquote>
-
- </para>
-
- <para>
-The XF86ImageRec:
-
- <blockquote><para>
- <programlisting>
-typedef struct {
- int id;
- int type;
- int byte_order;
- char guid[16];
- int bits_per_pixel;
- int format;
- int num_planes;
-
- /* for RGB formats */
- int depth;
- unsigned int red_mask;
- unsigned int green_mask;
- unsigned int blue_mask;
-
- /* for YUV formats */
- unsigned int y_sample_bits;
- unsigned int u_sample_bits;
- unsigned int v_sample_bits;
- unsigned int horz_y_period;
- unsigned int horz_u_period;
- unsigned int horz_v_period;
- unsigned int vert_y_period;
- unsigned int vert_u_period;
- unsigned int vert_v_period;
- char component_order[32];
- int scanline_order;
-} XF86ImageRec, *XF86ImagePtr;
-
- </programlisting>
- <blockquote><para>
- XF86ImageRec describes how video source data is laid out in memory.
- The fields are as follows:
-
- <variablelist>
- <varlistentry>
- <term><structfield>id</structfield></term>
- <listitem><para>
- This is a unique descriptor for the format. It is often good to
- set this value to the FOURCC for the format when applicable.
- </para></listitem></varlistentry>
-
- <varlistentry>
- <term><structfield>type</structfield></term>
- <listitem><para>
- This is <constant>XvRGB</constant> or <constant>XvYUV</constant>.
- </para></listitem></varlistentry>
-
- <varlistentry>
- <term><structfield>byte_order</structfield></term>
- <listitem><para>
- This is <constant>LSBFirst</constant> or <constant>MSBFirst</constant>.
- </para></listitem></varlistentry>
-
- <varlistentry>
- <term><structfield>guid</structfield></term>
- <listitem><para>
- This is the Globally Unique IDentifier for the format. When
- not applicable, all characters should be NULL.
- </para></listitem></varlistentry>
-
- <varlistentry>
- <term><structfield>bits_per_pixel</structfield></term>
- <listitem><para>
- The number of bits taken up (but not necessarily used) by each
- pixel. Note that for some planar formats which have fractional
- bits per pixel (such as IF09) this number may be rounded _down_.
- </para></listitem></varlistentry>
-
- <varlistentry>
- <term><structfield>format</structfield></term>
- <listitem><para>
- This is <constant>XvPlanar</constant> or <constant>XvPacked</constant>.
- </para></listitem></varlistentry>
-
- <varlistentry>
- <term><structfield>num_planes</structfield></term>
- <listitem><para>
- The number of planes in planar formats. This should be set to
- one for packed formats.
- </para></listitem></varlistentry>
-
- <varlistentry>
- <term><structfield>depth</structfield></term>
- <listitem><para>
- The significant bits per pixel in RGB formats (analgous to the
- depth of a pixmap format).
- </para></listitem></varlistentry>
-
- <varlistentry>
- <term><structfield>red_mask</structfield></term>
- <term><structfield>green_mask</structfield></term>
- <term><structfield>blue_mask</structfield></term>
- <listitem><para>
- The red, green and blue bitmasks for packed RGB formats.
- </para></listitem></varlistentry>
-
- <varlistentry>
- <term><structfield>y_sample_bits</structfield></term>
- <term><structfield>u_sample_bits</structfield></term>
- <term><structfield>v_sample_bits</structfield></term>
- <listitem><para>
- The y, u and v sample sizes (in bits).
- </para></listitem></varlistentry>
-
- <varlistentry>
- <term><structfield>horz_y_period</structfield></term>
- <term><structfield>horz_u_period</structfield></term>
- <term><structfield>horz_v_period</structfield></term>
- <listitem><para>
- The y, u and v sampling periods in the horizontal direction.
- </para></listitem></varlistentry>
-
- <varlistentry>
- <term><structfield>vert_y_period</structfield></term>
- <term><structfield>vert_u_period</structfield></term>
- <term><structfield>vert_v_period</structfield></term>
- <listitem><para>
- The y, u and v sampling periods in the vertical direction.
- </para></listitem></varlistentry>
-
- <varlistentry>
- <term><structfield>component_order</structfield></term>
- <listitem><para>
- Uppercase ascii characters representing the order that
- samples are stored within packed formats. For planar formats
- this represents the ordering of the planes. Unused characters
- in the 32 byte string should be set to NULL.
- </para></listitem></varlistentry>
-
- <varlistentry>
- <term><structfield>scanline_order</structfield></term>
- <listitem><para>
- This is <constant>XvTopToBottom</constant> or <constant>XvBottomToTop</constant>.
- </para></listitem></varlistentry>
-
- </variablelist>
- </para>
-
- <para>
- Since some formats (particular some planar YUV formats) may not
-be completely defined by the parameters above, the guid, when
-available, should provide the most accurate description of the
-format.
- </para>
-
- </blockquote></para></blockquote>
- </para>
- </sect1>
-
- <sect1>
- <title>The Loader</title>
-
- <para>
-This section describes the interfaces to the module loader. The loader
-interfaces can be divided into two groups: those that are only available to
-the XFree86 common layer, and those that are also available to modules.
- </para>
-
- <sect2>
- <title>Loader Overview</title>
-
- <para>
-The loader is capable of loading modules in a range of object formats,
-and knowledge of these formats is built in to the loader. Knowledge of
-new object formats can be added to the loader in a straightforward
-manner. This makes it possible to provide OS-independent modules (for
-a given CPU architecture type). In addition to this, the loader can
-load modules via the OS-provided <function>dlopen(3)</function> service where
-available. Such modules are not platform independent, and the semantics
-of <function>dlopen()</function> on most systems results in significant
-limitations in the use of modules of this type. Support for
-<function>dlopen()</function> modules in the loader is primarily for
-experimental and development purposes.
- </para>
-
- <para>
-Symbols exported by the loader (on behalf of the core X server) to
-modules are determined at compile time. Only those symbols explicitly
-exported are available to modules. All external symbols of loaded
-modules are exported to other modules, and to the core X server. The
-loader can be requested to check for unresolved symbols at any time,
-and the action to be taken for unresolved symbols can be controlled by
-the caller of the loader. Typically the caller identifies which symbols
-can safely remain unresolved and which cannot.
- </para>
-
- <para>
-NOTE: Now that ISO-C allows pointers to functions and pointers to data to
-have different internal representations, some of the following interfaces
-will need to be revisited.
- </para>
- </sect2>
-
- <sect2>
- <title>Semi-private Loader Interface</title>
-
- <para>
-The following is the semi-private loader interface that is available to the
-XFree86 common layer.
- </para>
-
- <blockquote><para>
- <programlisting>
- void LoaderInit(void);
- </programlisting>
- <blockquote><para>
- The <function>LoaderInit()</function> function initialises the loader,
- and it must be called once before calling any other loader functions.
- This function initialises the tables of exported symbols, and anything
- else that might need to be initialised.
- </para>
-
- </blockquote></para></blockquote>
-
- <blockquote><para>
- <programlisting>
- void LoaderSetPath(const char *path);
- </programlisting>
- <blockquote><para>
- The <function>LoaderSetPath()</function> function initialises a default
- module search path. This must be called if calls to other functions
- are to be made without explicitly specifying a module search path.
- The search path <parameter>path</parameter> must be a string of one or more
- comma separated absolute paths. Modules are expected to be located
- below these paths, possibly in subdirectories of these paths.
- </para>
-
- </blockquote></para></blockquote>
-
- <blockquote><para>
- <programlisting>
- pointer LoadModule(const char *module, const char *path,
- const char **subdirlist, const char **patternlist,
- pointer options, const XF86ModReqInfo * modreq,
- int *errmaj, int *errmin);
- </programlisting>
- <blockquote><para>
- The <function>LoadModule()</function> function loads the module called
- <parameter>module</parameter>. The return value is a module handle, and
- may be used in future calls to the loader that require a reference
- to a loaded module. The module name <parameter>module</parameter> is
- normally the module's canonical name, which doesn't contain any
- directory path information, or any object/library file prefixes of
- suffixes. Currently a full pathname and/or filename is also accepted.
- This might change. The other parameters are:
-
- <variablelist>
- <varlistentry>
- <term><parameter>path</parameter></term>
- <listitem><para>
- An optional comma-separated list of module search paths.
- When <constant>NULL</constant>, the default search path is used.
- </para></listitem></varlistentry>
-
-
- <varlistentry>
- <term><parameter>subdirlist</parameter></term>
- <listitem><para>
- An optional <constant>NULL</constant> terminated list of
- subdirectories to search. When <constant>NULL</constant>,
- the default built-in list is used (refer to
- <varname>stdSubdirs</varname> in <filename>loadmod.c</filename>).
- The default list is also substituted for entries in
- <parameter>subdirlist</parameter> with the value
- <constant>DEFAULT_LIST</constant>. This makes is possible
- to augment the default list instead of replacing it.
- Subdir elements must be relative, and must not contain
- <literal remap="tt">".."</literal>. If any violate this requirement,
- the load fails.
- </para></listitem></varlistentry>
-
-
- <varlistentry>
- <term><parameter>patternlist</parameter></term>
- <listitem><para>
- An optional <constant>NULL</constant> terminated list of
- POSIX regular expressions used to connect module
- filenames with canonical module names. Each regex
- should contain exactly one subexpression that corresponds
- to the canonical module name. When <constant>NULL</constant>,
- the default built-in list is used (refer to
- <varname>stdPatterns</varname> in
- <filename>loadmod.c</filename>). The default list is also
- substituted for entries in <parameter>patternlist</parameter>
- with the value <constant>DEFAULT_LIST</constant>. This
- makes it possible to augment the default list instead
- of replacing it.
- </para></listitem></varlistentry>
-
-
- <varlistentry>
- <term><parameter>options</parameter></term>
- <listitem><para>
- An optional parameter that is passed to the newly
- loaded module's <literal remap="tt">SetupProc</literal> function
- (if it has one). This argument is normally a
- <constant>NULL</constant> terminated list of
- <structname>Options</structname>, and must be interpreted that
- way by modules loaded directly by the XFree86 common
- layer. However, it may be used for application-specific
- parameter passing in other situations.
- </para>
-
- <para>
- When loading <quote>external</quote> modules (modules that don't
- have the standard entry point, for example a
- special shared library) the options parameter can be
- set to <constant>EXTERN_MODULE</constant> to tell the
- loader not to reject the module when it doesn't find
- the standard entry point.
- </para></listitem></varlistentry>
-
-
- <varlistentry>
- <term><parameter>modreq</parameter></term>
- <listitem><para>
- An optional <structname>XF86ModReqInfo*</structname> containing
- version/ABI/vendor information to requirements to
- check the newly loaded module against. The main
- purpose of this is to allow the loader to verify that
- a module of the correct type/version before running
- its <function>SetupProc</function> function.
- </para>
-
- <para>
- The <literal remap="tt">XF86ModReqInfo</literal> struct is defined
- as follows:
- <programlisting>
-typedef struct {
- CARD8 majorversion; /* MAJOR_UNSPEC */
- CARD8 minorversion; /* MINOR_UNSPEC */
- CARD16 patchlevel; /* PATCH_UNSPEC */
- const char * abiclass; /* ABI_CLASS_NONE */
- CARD32 abiversion; /* ABI_VERS_UNSPEC */
- const char * moduleclass; /* MOD_CLASS_NONE */
-} XF86ModReqInfo;
- </programlisting>
-
- The information here is compared against the equivalent
- information in the module's
- <structname>XF86ModuleVersionInfo</structname> record (which
- is described below). The values in comments above
- indicate <quote>don't care</quote> settings for each of the fields.
- The comparisons made are as follows:
-
- <variablelist>
- <varlistentry>
- <term><structfield>majorversion</structfield></term>
- <listitem><para>
- Must match the module's majorversion
- exactly.
- </para></listitem></varlistentry>
-
- <varlistentry>
- <term><structfield>minorversion</structfield></term>
- <listitem><para>
- The module's minor version must be
- no less than this value. This
- comparison is only made if
- <structfield>majorversion</structfield> is
- specified and matches.
- </para></listitem></varlistentry>
-
- <varlistentry>
- <term><structfield>patchlevel</structfield></term>
- <listitem><para>
- The module's patchlevel must be no
- less than this value. This comparison
- is only made if
- <structfield>minorversion</structfield> is
- specified and matches.
- </para></listitem></varlistentry>
-
- <varlistentry>
- <term><structfield>abiclass</structfield></term>
- <listitem><para>
- String must match the module's abiclass
- string.
- </para></listitem></varlistentry>
-
- <varlistentry>
- <term><structfield>abiversion</structfield></term>
- <listitem><para>
- Must be consistent with the module's
- abiversion (major equal, minor no
- older).
- </para></listitem></varlistentry>
-
- <varlistentry>
- <term><structfield>moduleclass</structfield></term>
- <listitem><para>
- String must match the module's
- moduleclass string.
- </para></listitem></varlistentry>
-
- </variablelist>
- </para></listitem></varlistentry>
-
- <varlistentry>
- <term><parameter>errmaj</parameter></term>
- <listitem><para>
- An optional pointer to a variable holding the major
- part or the error code. When provided,
- <parameter>*errmaj</parameter> is filled in when
- <function>LoadModule()</function> fails.
- </para></listitem></varlistentry>
-
- <varlistentry>
- <term><parameter>errmin</parameter></term>
- <listitem><para>
- Like <parameter>errmaj</parameter>, but for the minor part
- of the error code.
- </para></listitem></varlistentry>
-
- </variablelist>
-
- </para></blockquote>
- </para></blockquote>
-
- <blockquote><para>
- <programlisting>
- void UnloadModule(pointer mod);
- </programlisting>
- <blockquote><para>
- This function unloads the module referred to by the handle mod.
- All child modules are also unloaded recursively. This function must
- not be used to directly unload modules that are child modules (i.e.,
- those that have been loaded with the <function>LoadSubModule()</function>
- described below).
- </para>
-
- </blockquote></para></blockquote>
- </sect2>
-
- <sect2>
- <title>Module Requirements</title>
-
- <para>
-Modules must provide information about themselves to the loader, and
-may optionally provide entry points for "setup" and "teardown" functions
-(those two functions are referred to here as <function>SetupProc</function>
-and <function>TearDownProc</function>).
- </para>
-
- <para>
-The module information is contained in the
-<structname>XF86ModuleVersionInfo</structname> struct, which is defined as follows:
-
- <programlisting>
-typedef struct {
- const char * modname; /* name of module, e.g. "foo" */
- const char * vendor; /* vendor specific string */
- CARD32 _modinfo1_; /* constant MODINFOSTRING1/2 to find */
- CARD32 _modinfo2_; /* infoarea with a binary editor/sign tool */
- CARD32 xf86version; /* contains XF86_VERSION_CURRENT */
- CARD8 majorversion; /* module-specific major version */
- CARD8 minorversion; /* module-specific minor version */
- CARD16 patchlevel; /* module-specific patch level */
- const char * abiclass; /* ABI class that the module uses */
- CARD32 abiversion; /* ABI version */
- const char * moduleclass; /* module class */
- CARD32 checksum[4]; /* contains a digital signature of the */
- /* version info structure */
-} XF86ModuleVersionInfo;
- </programlisting>
-
-The fields are used as follows:
-
- <variablelist>
- <varlistentry>
- <term><structfield>modname</structfield></term>
- <listitem><para>
- The module's name. This field is currently only for
- informational purposes, but the loader may be modified
- in future to require it to match the module's canonical
- name.
- </para></listitem></varlistentry>
-
-
- <varlistentry>
- <term><structfield>vendor</structfield></term>
- <listitem><para>
- The module vendor. This field is for informational purposes
- only.
- </para></listitem></varlistentry>
-
-
- <varlistentry>
- <term><structfield>_modinfo1_</structfield></term>
- <listitem><para>
- This field holds the first part of a signature that can
- be used to locate this structure in the binary. It should
- always be initialised to <constant>MODINFOSTRING1</constant>.
- </para></listitem></varlistentry>
-
-
- <varlistentry>
- <term><structfield>_modinfo2_</structfield></term>
- <listitem><para>
- This field holds the second part of a signature that can
- be used to locate this structure in the binary. It should
- always be initialised to <constant>MODINFOSTRING2</constant>.
- </para></listitem></varlistentry>
-
-
- <varlistentry>
- <term><structfield>xf86version</structfield></term>
- <listitem><para>
- The XFree86 version against which the module was compiled.
- This is mostly for informational/diagnostic purposes. It
- should be initialised to <constant>XF86_VERSION_CURRENT</constant>, which is
- defined in <filename>xf86Version.h</filename>.
- </para></listitem></varlistentry>
-
-
- <varlistentry>
- <term><structfield>majorversion</structfield></term>
- <listitem><para>
- The module-specific major version. For modules where this
- version is used for more than simply informational
- purposes, the major version should only change (be
- incremented) when ABI incompatibilities are introduced,
- or ABI components are removed.
- </para></listitem></varlistentry>
-
-
- <varlistentry>
- <term><structfield>minorversion</structfield></term>
- <listitem><para>
- The module-specific minor version. For modules where this
- version is used for more than simply informational
- purposes, the minor version should only change (be
- incremented) when ABI additions are made in a backward
- compatible way. It should be reset to zero when the major
- version is increased.
- </para></listitem></varlistentry>
-
-
- <varlistentry>
- <term><structfield>patchlevel</structfield></term>
- <listitem><para>
- The module-specific patch level. The patch level should
- increase with new revisions of the module where there
- are no ABI changes, and it should be reset to zero when
- the minor version is increased.
- </para></listitem></varlistentry>
-
-
- <varlistentry>
- <term><structfield>abiclass</structfield></term>
- <listitem><para>
- The ABI class that the module requires. The class is
- specified as a string for easy extensibility. It should
- indicate which (if any) of the X server's built-in ABI
- classes that the module relies on, or a third-party ABI
- if appropriate. Built-in ABI classes currently defined are:
-
- <variablelist>
- <varlistentry>
- <term><constant>ABI_CLASS_NONE</constant></term>
- <listitem><para>no class
- </para></listitem></varlistentry>
- <varlistentry>
- <term><constant>ABI_CLASS_ANSIC</constant></term>
- <listitem><para>only requires the ANSI C interfaces
- </para></listitem></varlistentry>
- <varlistentry>
- <term><constant>ABI_CLASS_VIDEODRV</constant></term>
- <listitem><para>requires the video driver ABI
- </para></listitem></varlistentry>
- <varlistentry>
- <term><constant>ABI_CLASS_XINPUT</constant></term>
- <listitem><para>requires the XInput driver ABI
- </para></listitem></varlistentry>
- <varlistentry>
- <term><constant>ABI_CLASS_EXTENSION</constant></term>
- <listitem><para>requires the extension module ABI
- </para></listitem></varlistentry>
- <varlistentry>
- <term><constant>ABI_CLASS_FONT</constant></term>
- <listitem><para>requires the font module ABI
- </para></listitem></varlistentry>
- </variablelist>
-
- </para></listitem></varlistentry>
-
- <varlistentry>
- <term><structfield>abiversion</structfield></term>
- <listitem><para>
- The version of abiclass that the module requires. The
- version consists of major and minor components. The
- major version must match and the minor version must be
- no newer than that provided by the server or parent
- module. Version identifiers for the built-in classes
- currently defined are:
-
- <literallayout><constant>
- ABI_ANSIC_VERSION
- ABI_VIDEODRV_VERSION
- ABI_XINPUT_VERSION
- ABI_EXTENSION_VERSION
- ABI_FONT_VERSION
- </constant></literallayout>
-
- </para></listitem></varlistentry>
-
- <varlistentry>
- <term><structfield>moduleclass</structfield></term>
- <listitem><para>
- This is similar to the abiclass field, except that it
- defines the type of module rather than the ABI it
- requires. For example, although all video drivers require
- the video driver ABI, not all modules that require the
- video driver ABI are video drivers. This distinction
- can be made with the moduleclass. Currently pre-defined
- module classes are:
-
- <literallayout><constant>
- MOD_CLASS_NONE
- MOD_CLASS_VIDEODRV
- MOD_CLASS_XINPUT
- MOD_CLASS_FONT
- MOD_CLASS_EXTENSION
- </constant></literallayout>
-
- </para></listitem></varlistentry>
-
- <varlistentry>
- <term><structfield>checksum</structfield></term>
- <listitem><para>
- Not currently used.
- </para></listitem></varlistentry>
-
- </variablelist>
- </para>
-
- <para>
-The module version information, and the optional <function>SetupProc</function>
-and <function>TearDownProc</function> entry points are found by the loader
-by locating a data object in the module called "modnameModuleData",
-where "modname" is the canonical name of the module. Modules must
-contain such a data object, and it must be declared with global scope,
-be compile-time initialised, and is of the following type:
-
- <programlisting>
-typedef struct {
- XF86ModuleVersionInfo * vers;
- ModuleSetupProc setup;
- ModuleTearDownProc teardown;
-} XF86ModuleData;
- </programlisting>
- </para>
-
- <para>
-The vers parameter must be initialised to a pointer to a correctly
-initialised <structname>XF86ModuleVersionInfo</structname> struct. The other
-two parameter are optional, and should be initialised to
-<constant>NULL</constant> when not required. The other parameters are defined
-as
-
- <blockquote><para>
- <programlisting>
- typedef pointer (*ModuleSetupProc)(pointer, pointer, int *, int *);
-
- typedef void (*ModuleTearDownProc)(pointer);
-
- pointer SetupProc(pointer module, pointer options,
- int *errmaj, int *errmin);
- </programlisting>
- <blockquote><para>
- When defined, this function is called by the loader after successfully
- loading a module. module is a handle for the newly loaded module,
- and maybe used by the <function>SetupProc</function> if it calls other
- loader functions that require a reference to it. The remaining
- arguments are those that were passed to the
- <function>LoadModule()</function> (or <function>LoadSubModule()</function>),
- and are described above. When the <function>SetupProc</function> is
- successful it must return a non-<constant>NULL</constant> value. The
- loader checks this, and if it is <constant>NULL</constant> it unloads
- the module and reports the failure to the caller of
- <function>LoadModule()</function>. If the <function>SetupProc</function>
- does things that need to be undone when the module is unloaded,
- it should define a <function>TearDownProc</function>, and return a
- pointer that the <function>TearDownProc</function> can use to undo what
- has been done.
- </para>
-
- <para>
- When a module is loaded multiple times, the <function>SetupProc</function>
- is called once for each time it is loaded.
- </para>
-
- </blockquote></para></blockquote>
-
- <blockquote><para>
- <programlisting>
- void TearDownProc(pointer tearDownData);
- </programlisting>
- <blockquote><para>
- When defined, this function is called when the loader unloads a
- module. The <parameter>tearDownData</parameter> parameter is the return
- value of the <function>SetupProc()</function> that was called when the
- module was loaded. The purpose of this function is to clean up
- before the module is unloaded (for example, by freeing allocated
- resources).
- </para>
-
- </blockquote></para></blockquote>
- </para>
- </sect2>
-
- <sect2>
- <title>Public Loader Interface</title>
-
- <para>
-The following is the Loader interface that is available to any part of
-the server, and may also be used from within modules.
- </para>
-
- <blockquote><para>
- <programlisting>
- pointer LoadSubModule(pointer parent, const char *module,
- const char **subdirlist, const char **patternlist,
- pointer options, const XF86ModReqInfo * modreq,
- int *errmaj, int *errmin);
- </programlisting>
- <blockquote><para>
- This function is like the <function>LoadModule()</function> function
- described above, except that the module loaded is registered as a
- child of the calling module. The <parameter>parent</parameter> parameter
- is the calling module's handle. Modules loaded with this function
- are automatically unloaded when the parent module is unloaded. The
- other difference is that the path parameter may not be specified.
- The module search path used for modules loaded with this function
- is the default search path as initialised with
- <function>LoaderSetPath()</function>.
- </para>
-
- </blockquote></para></blockquote>
-
- <blockquote><para>
- <programlisting>
- void UnloadSubModule(pointer module);
- </programlisting>
- <blockquote><para>
- This function unloads the module with handle <parameter>module</parameter>.
- If that module itself has children, they are also unloaded. It is
- like <function>UnloadModule()</function>, except that it is safe to use
- for unloading child modules.
- </para>
-
- </blockquote></para></blockquote>
-
- <blockquote><para>
- <programlisting>
- pointer LoaderSymbol(const char *symbol);
- </programlisting>
- <blockquote><para>
- This function returns the address of the symbol with name
- <parameter>symbol</parameter>. This may be used to locate a module entry
- point with a known name.
- </para>
-
- </blockquote></para></blockquote>
-
- <blockquote><para>
- <programlisting>
- char **LoaderlistDirs(const char **subdirlist,
- const char **patternlist);
- </programlisting>
- <blockquote><para>
- This function returns a <constant>NULL</constant> terminated list of
- canonical modules names for modules found in the default module
- search path. The <parameter>subdirlist</parameter> and
- <parameter>patternlist</parameter> parameters are as described above, and
- can be used to control the locations and names that are searched.
- If no modules are found, the return value is <constant>NULL</constant>.
- The returned list should be freed by calling
- <function>LoaderFreeDirList()</function> when it is no longer needed.
- </para>
-
- </blockquote></para></blockquote>
-
- <blockquote><para>
- <programlisting>
- void LoaderFreeDirList(char **list);
- </programlisting>
- <blockquote><para>
- This function frees a module list created by
- <function>LoaderlistDirs()</function>.
- </para>
-
- </blockquote></para></blockquote>
-
- <blockquote><para>
- <programlisting>
- void LoaderReqSymLists(const char **list0, ...);
- </programlisting>
- <blockquote><para>
- This function allows the registration of required symbols with the
- loader. It is normally used by a caller of
- <function>LoadSubModule()</function>. If any symbols registered in this
- way are found to be unresolved when
- <function>LoaderCheckUnresolved()</function> is called then
- <function>LoaderCheckUnresolved()</function> will report a failure.
- The function takes one or more <constant>NULL</constant> terminated
- lists of symbols. The end of the argument list is indicated by a
- <constant>NULL</constant> argument.
- </para>
-
- </blockquote></para></blockquote>
-
- <blockquote><para>
- <programlisting>
- void LoaderReqSymbols(const char *sym0, ...);
- </programlisting>
- <blockquote><para>
- This function is like <function>LoaderReqSymLists()</function> except
- that its arguments are symbols rather than lists of symbols. This
- function is more convenient when single functions are to be registered,
- especially when the single function might depend on runtime factors.
- The end of the argument list is indicated by a <constant>NULL</constant>
- argument.
- </para>
-
- </blockquote></para></blockquote>
-
- <blockquote><para>
- <programlisting>
- void LoaderRefSymLists(const char **list0, ...);
- </programlisting>
- <blockquote><para>
- This function allows the registration of possibly unresolved symbols
- with the loader. When <function>LoaderCheckUnresolved()</function> is
- run it won't generate warnings for symbols registered in this way
- unless they were also registered as required symbols.
- The function takes one or more <constant>NULL</constant> terminated
- lists of symbols. The end of the argument list is indicated by a
- <constant>NULL</constant> argument.
- </para>
-
- </blockquote></para></blockquote>
-
- <blockquote><para>
- <programlisting>
- void LoaderRefSymbols(const char *sym0, ...);
- </programlisting>
- <blockquote><para>
- This function is like <function>LoaderRefSymLists()</function> except
- that its arguments are symbols rather than lists of symbols. This
- function is more convenient when single functions are to be registered,
- especially when the single function might depend on runtime factors.
- The end of the argument list is indicated by a <constant>NULL</constant>
- argument.
- </para>
-
- </blockquote></para></blockquote>
-
- <blockquote><para>
- <programlisting>
- int LoaderCheckUnresolved(int delayflag);
- </programlisting>
- <blockquote><para>
- This function checks for unresolved symbols. It generates warnings
- for unresolved symbols that have not been registered with
- <function>LoaderRefSymLists()</function>, and maps them to a dummy
- function. This behaviour may change in future. If unresolved
- symbols are found that have been registered with
- <function>LoaderReqSymLists()</function> or
- <function>LoaderReqSymbols()</function> then this function returns a
- non-zero value. If none of these symbols are unresolved the return
- value is zero, indicating success.
- </para>
-
- <para>
- The <parameter>delayflag</parameter> parameter should normally be set to
- <constant>LD_RESOLV_IFDONE</constant>.
- </para>
-
- </blockquote></para></blockquote>
-
- <blockquote><para>
- <programlisting>
- LoaderErrorMsg(const char *name, const char *modname,
- int errmaj, int errmin);
- </programlisting>
- <blockquote><para>
- This function prints an error message that includes the text <quote>Failed
- to load module</quote>, the module name <parameter>modname</parameter>, a message
- specific to the <parameter>errmaj</parameter> value, and the value if
- <parameter>errmin</parameter>. If <parameter>name</parameter> is
- non-<constant>NULL</constant>, it is printed as an identifying prefix
- to the message (followed by a <quote>:</quote>).
- </para>
-
- </blockquote></para></blockquote>
- </sect2>
-
- <sect2>
- <title>Special Registration Functions</title>
-
- <para>
-The loader contains some functions for registering some classes of modules.
-These may be moved out of the loader at some point.
- </para>
-
- <blockquote><para>
- <programlisting>
- void LoadExtension(ExtensionModule *ext);
- </programlisting>
- <blockquote><para>
- This registers the entry points for the extension identified by
- <parameter>ext</parameter>. The <structname>ExtensionModule</structname> struct is
- defined as:
-
- <programlisting>
-typedef struct {
- InitExtension initFunc;
- char * name;
- Bool *disablePtr;
- InitExtension setupFunc;
-} ExtensionModule;
- </programlisting>
- </para>
-
- </blockquote></para></blockquote>
-
- <blockquote><para>
- <programlisting>
- void LoadFont(FontModule *font);
- </programlisting>
- <blockquote><para>
- This registers the entry points for the font rasteriser module
- identified by <parameter>font</parameter>. The <structname>FontModule</structname>
- struct is defined as:
-
- <programlisting>
- typedef struct {
- InitFont initFunc;
- char * name;
- pointer module;
-} FontModule;
- </programlisting>
- </para>
-
- </blockquote></para></blockquote>
-
- </sect2>
-
- </sect1>
-
- <sect1>
- <title>Helper Functions</title>
-
- <para>
-This section describe <quote>helper</quote> functions that video driver
-might find useful. While video drivers are not required to use any of
-these to be considered <quote>compliant</quote>, the use of appropriate helpers is
-strongly encouraged to improve the consistency of driver behaviour.
- </para>
-
- <sect2>
- <title>Functions for printing messages</title>
-
- <blockquote><para>
- <programlisting>
- ErrorF(const char *format, ...);
- </programlisting>
- <blockquote><para>
- This is the basic function for writing to the error log (typically
- stderr and/or a log file). Video drivers should usually avoid
- using this directly in favour of the more specialised functions
- described below. This function is useful for printing messages
- while debugging a driver.
- </para>
-
- </blockquote></para></blockquote>
-
- <blockquote><para>
- <programlisting>
- FatalError(const char *format, ...);
- </programlisting>
- <blockquote><para>
- This prints a message and causes the Xserver to abort. It should
- rarely be used within a video driver, as most error conditions
- should be flagged by the return values of the driver functions.
- This allows the higher layers to decide how to proceed. In rare
- cases, this can be used within a driver if a fatal unexpected
- condition is found.
- </para>
-
- </blockquote></para></blockquote>
-
- <blockquote><para>
- <programlisting>
- xf86ErrorF(const char *format, ...);
- </programlisting>
- <blockquote><para>
- This is like <function>ErrorF()</function>, except that the message is
- only printed when the Xserver's verbosity level is set to the
- default (<constant>1</constant>) or higher. It means that the messages
- are not printed when the server is started with the
- <option>-quiet</option> flag. Typically this function would only be
- used for continuing messages started with one of the more specialised
- functions described below.
- </para>
-
- </blockquote></para></blockquote>
-
- <blockquote><para>
- <programlisting>
- xf86ErrorFVerb(int verb, const char *format, ...);
- </programlisting>
- <blockquote><para>
- Like <function>xf86ErrorF()</function>, except the minimum verbosity
- level for which the message is to be printed is given explicitly.
- Passing a <parameter>verb</parameter> value of zero means the message
- is always printed. A value higher than <constant>1</constant> can be
- used for information would normally not be needed, but which might
- be useful when diagnosing problems.
- </para>
-
- </blockquote></para></blockquote>
-
-
- <blockquote><para>
- <programlisting>
- xf86Msg(MessageType type, const char *format, ...);
- </programlisting>
- <blockquote><para>
- This is like <function>xf86ErrorF()</function>, except that the message
- is prefixed with a marker determined by the value of
- <parameter>type</parameter>. The marker is used to indicate the type of
- message (warning, error, probed value, config value, etc). Note
- the <varname>xf86Verbose</varname> value is ignored for messages of
- type <constant>X_ERROR</constant>.
- </para>
-
- <para>
- The marker values are:
-
- <variablelist>
- <varlistentry>
- <term><constant>X_PROBED</constant></term>
- <listitem><para>Value was probed.
- </para></listitem></varlistentry>
- <varlistentry>
- <term><constant>X_CONFIG</constant></term>
- <listitem><para>Value was given in the config file.
- </para></listitem></varlistentry>
- <varlistentry>
- <term><constant>X_DEFAULT</constant></term>
- <listitem><para>Value is a default.
- </para></listitem></varlistentry>
- <varlistentry>
- <term><constant>X_CMDLINE</constant></term>
- <listitem><para>Value was given on the command line.
- </para></listitem></varlistentry>
- <varlistentry>
- <term><constant>X_NOTICE</constant></term>
- <listitem><para>Notice.
- </para></listitem></varlistentry>
- <varlistentry>
- <term><constant>X_ERROR</constant></term>
- <listitem><para>Error message.
- </para></listitem></varlistentry>
- <varlistentry>
- <term><constant>X_WARNING</constant></term>
- <listitem><para>Warning message.
- </para></listitem></varlistentry>
- <varlistentry>
- <term><constant>X_INFO</constant></term>
- <listitem><para>Informational message.
- </para></listitem></varlistentry>
- <varlistentry>
- <term><constant>X_NONE</constant></term>
- <listitem><para>No prefix.
- </para></listitem></varlistentry>
- <varlistentry>
- <term><constant>X_NOT_IMPLEMENTED</constant></term>
- <listitem><para>The message relates to functionality
- that is not yetimplemented.
- </para></listitem></varlistentry>
- </variablelist>
-
- </para>
-
- </blockquote></para></blockquote>
-
- <blockquote><para>
- <programlisting>
- xf86MsgVerb(MessageType type, int verb, const char *format, ...);
- </programlisting>
- <blockquote><para>
- Like <function>xf86Msg()</function>, but with the verbosity level given
- explicitly.
- </para>
-
- </blockquote></para></blockquote>
-
- <blockquote><para>
- <programlisting>
- xf86DrvMsg(int scrnIndex, MessageType type, const char *format, ...);
- </programlisting>
- <blockquote><para>
- This is like <function>xf86Msg()</function> except that the driver's
- name (the <structfield>name</structfield> field of the
- <structname>ScrnInfoRec</structname>) followed by the
- <parameter>scrnIndex</parameter> in parentheses is printed following the
- prefix. This should be used by video drivers in most cases as it
- clearly indicates which driver/screen the message is for. If
- <parameter>scrnIndex</parameter> is negative, this function behaves
- exactly like <function>xf86Msg()</function>.
- </para>
-
- <para>
- NOTE: This function can only be used after the
- <structname>ScrnInfoRec</structname> and its <structfield>name</structfield> field
- have been allocated. Normally, this means that it can not be
- used before the END of the <function>ChipProbe()</function> function.
- Prior to that, use <function>xf86Msg()</function>, providing the
- driver's name explicitly. No screen number can be supplied at
- that point.
- </para>
-
- </blockquote></para></blockquote>
-
- <blockquote><para>
- <programlisting>
- xf86DrvMsgVerb(int scrnIndex, MessageType type, int verb,
- const char *format, ...);
- </programlisting>
- <blockquote><para>
- Like <function>xf86DrvMsg()</function>, but with the verbosity level
- given explicitly.
- </para>
-
- </blockquote></para></blockquote>
- </sect2>
-
-
- <sect2>
- <title>Functions for setting values based on command line and config file</title>
-
- <blockquote><para>
- <programlisting>
- Bool xf86SetDepthBpp(ScrnInfoPtr scrp, int depth, int bpp,
-
- int fbbpp, int depth24flags);
- </programlisting>
- <blockquote><para>
- This function sets the <structfield>depth</structfield>, <structfield>pixmapBPP</structfield> and <structfield>bitsPerPixel</structfield> fields
- of the <structname>ScrnInfoRec</structname>. It also determines the defaults for display-wide
- attributes and pixmap formats the screen will support, and finds
- the Display subsection that matches the depth/bpp. This function
- should normally be called very early from the
- <function>ChipPreInit()</function> function.
- </para>
-
- <para>
- It requires that the <structfield>confScreen</structfield> field of the <structname>ScrnInfoRec</structname> be
- initialised prior to calling it. This is done by the XFree86
- common layer prior to calling <function>ChipPreInit()</function>.
- </para>
-
- <para>
- The parameters passed are:
-
- <variablelist>
- <varlistentry>
- <term><parameter>depth</parameter></term>
- <listitem><para>
- driver's preferred default depth if no other is given.
- If zero, use the overall server default.
- </para></listitem></varlistentry>
-
- <varlistentry>
- <term><parameter>bpp</parameter></term>
- <listitem><para>
- Same, but for the pixmap bpp.
- </para></listitem></varlistentry>
-
- <varlistentry>
- <term><parameter>fbbpp</parameter></term>
- <listitem><para>
- Same, but for the framebuffer bpp.
- </para></listitem></varlistentry>
-
- <varlistentry>
- <term><parameter>depth24flags</parameter></term>
- <listitem><para>
- Flags that indicate the level of 24/32bpp support
- and whether conversion between different framebuffer
- and pixmap formats is supported. The flags for this
- argument are defined as follows, and multiple flags
- may be ORed together:
-
- <variablelist>
- <varlistentry>
- <term><constant>NoDepth24Support</constant></term>
- <listitem><para>No depth 24 formats supported
- </para></listitem></varlistentry>
- <varlistentry>
- <term><constant>Support24bppFb</constant></term>
- <listitem><para>24bpp framebuffer supported
- </para></listitem></varlistentry>
- <varlistentry>
- <term><constant>Support32bppFb</constant></term>
- <listitem><para>32bpp framebuffer supported
- </para></listitem></varlistentry>
- <varlistentry>
- <term><constant>SupportConvert24to32</constant></term>
- <listitem><para>Can convert 24bpp pixmap to 32bpp fb
- </para></listitem></varlistentry>
- <varlistentry>
- <term><constant>SupportConvert32to24</constant></term>
- <listitem><para>Can convert 32bpp pixmap to 24bpp fb
- </para></listitem></varlistentry>
- <varlistentry>
- <term><constant>ForceConvert24to32</constant></term>
- <listitem><para>Force 24bpp pixmap to 32bpp fb conversion
- </para></listitem></varlistentry>
- <varlistentry>
- <term><constant>ForceConvert32to24</constant></term>
- <listitem><para>Force 32bpp pixmap to 24bpp fb conversion
- </para></listitem></varlistentry>
- </variablelist>
- </para></listitem></varlistentry>
-
- </variablelist>
- </para>
-
- <para>
- It uses the command line, config file, and default values in the
- correct order of precedence to determine the depth and bpp values.
- It is up to the driver to check the results to see that it supports
- them. If not the <function>ChipPreInit()</function> function should
- return <constant>FALSE</constant>.
- </para>
-
- <para>
- If only one of depth/bpp is given, the other is set to a reasonable
- (and consistent) default.
- </para>
-
- <para>
- If a driver finds that the initial <parameter>depth24flags</parameter>
- it uses later results in a fb format that requires more video
- memory than is available it may call this function a second time
- with a different <parameter>depth24flags</parameter> setting.
- </para>
-
- <para>
- On success, the return value is <constant>TRUE</constant>. On failure
- it prints an error message and returns <constant>FALSE</constant>.
- </para>
-
- <para>
- The following fields of the <structname>ScrnInfoRec</structname> are
- initialised by this function:
-
- <blockquote><para>
-<structfield>depth</structfield>, <structfield>bitsPerPixel</structfield>,
-<structfield>display</structfield>, <structfield>imageByteOrder</structfield>,
-<structfield>bitmapScanlinePad</structfield>,
-<structfield>bitmapScanlineUnit</structfield>, <structfield>bitmapBitOrder</structfield>,
-<structfield>numFormats</structfield>, <structfield>formats</structfield>,
-<structfield>fbFormat</structfield>.
- </para></blockquote>
- </para>
-
- </blockquote></para></blockquote>
-
- <blockquote><para>
- <programlisting>
- void xf86PrintDepthBpp(scrnInfoPtr scrp);
- </programlisting>
- <blockquote><para>
- This function can be used to print out the depth and bpp settings.
- It should be called after the final call to
- <function>xf86SetDepthBpp()</function>.
- </para>
-
- </blockquote></para></blockquote>
-
- <blockquote><para>
- <programlisting>
- Bool xf86SetWeight(ScrnInfoPtr scrp, rgb weight, rgb mask);
- </programlisting>
- <blockquote><para>
- This function sets the <structfield>weight</structfield>, <structfield>mask</structfield>,
- <structfield>offset</structfield> and <structfield>rgbBits</structfield> fields of the
- <structname>ScrnInfoRec</structname>. It would normally be called fairly
- early in the <function>ChipPreInit()</function> function for
- depths&nbsp;&gt;&nbsp;8bpp.
- </para>
-
- <para>
- It requires that the <structfield>depth</structfield> and
- <structfield>display</structfield> fields of the <structname>ScrnInfoRec</structname>
- be initialised prior to calling it.
- </para>
-
- <para>
- The parameters passed are:
-
- <variablelist>
- <varlistentry>
- <term><parameter>weight</parameter></term>
- <listitem><para>
- driver's preferred default weight if no other is given.
- If zero, use the overall server default.
-
- </para></listitem></varlistentry>
-
- <varlistentry>
- <term><parameter>mask</parameter></term>
- <listitem><para>
- Same, but for mask.
-
- </para></listitem></varlistentry>
- </variablelist>
- </para>
-
- <para>
- It uses the command line, config file, and default values in the
- correct order of precedence to determine the weight value. It
- derives the mask and offset values from the weight and the defaults.
- It is up to the driver to check the results to see that it supports
- them. If not the <function>ChipPreInit()</function> function should
- return <constant>FALSE</constant>.
- </para>
-
- <para>
- On success, this function prints a message showing the weight
- values selected, and returns <constant>TRUE</constant>.
- </para>
-
- <para>
- On failure it prints an error message and returns <constant>FALSE</constant>.
- </para>
-
- <para>
- The following fields of the <structname>ScrnInfoRec</structname> are
- initialised by this function:
-
- <blockquote><para>
- <structfield>weight</structfield>,
- <structfield>mask</structfield>,
- <structfield>offset</structfield>.
- </para></blockquote>
- </para>
-
- </blockquote></para></blockquote>
-
- <blockquote><para>
- <programlisting>
- Bool xf86SetDefaultVisual(ScrnInfoPtr scrp, int visual);
- </programlisting>
- <blockquote><para>
- This function sets the <structfield>defaultVisual</structfield> field of the
- <structname>ScrnInfoRec</structname>. It would normally be called fairly
- early from the <function>ChipPreInit()</function> function.
- </para>
-
- <para>
- It requires that the <structfield>depth</structfield> and
- <structfield>display</structfield> fields of the <structname>ScrnInfoRec</structname>
- be initialised prior to calling it.
- </para>
-
- <para>
- The parameters passed are:
-
- <variablelist>
- <varlistentry>
- <term><parameter>visual</parameter></term>
- <listitem><para>
- driver's preferred default visual if no other is given.
- If <constant>-1</constant>, use the overall server default.
- </para></listitem></varlistentry>
-
- </variablelist>
- </para>
-
- <para>
- It uses the command line, config file, and default values in the
- correct order of precedence to determine the default visual value.
- It is up to the driver to check the result to see that it supports
- it. If not the <function>ChipPreInit()</function> function should
- return <constant>FALSE</constant>.
- </para>
-
- <para>
- On success, this function prints a message showing the default visual
- selected, and returns <constant>TRUE</constant>.
- </para>
-
- <para>
- On failure it prints an error message and returns <constant>FALSE</constant>.
- </para>
-
- </blockquote></para></blockquote>
-
- <blockquote><para>
- <programlisting>
- Bool xf86SetGamma(ScrnInfoPtr scrp, Gamma gamma);
- </programlisting>
- <blockquote><para>
- This function sets the <structfield>gamma</structfield> field of the
- <structname>ScrnInfoRec</structname>. It would normally be called fairly
- early from the <function>ChipPreInit()</function> function in cases
- where the driver supports gamma correction.
- </para>
-
- <para>
- It requires that the <structfield>monitor</structfield> field of the
- <structname>ScrnInfoRec</structname> be initialised prior to calling it.
- </para>
-
- <para>
- The parameters passed are:
-
- <variablelist>
- <varlistentry>
- <term><parameter>gamma</parameter></term>
- <listitem><para>
- driver's preferred default gamma if no other is given.
- If zero (<code>&lt; 0.01</code>), use the overall server
- default.
- </para></listitem></varlistentry>
-
- </variablelist>
- </para>
-
- <para>
- It uses the command line, config file, and default values in the
- correct order of precedence to determine the gamma value. It is
- up to the driver to check the results to see that it supports
- them. If not the <function>ChipPreInit()</function> function should
- return <constant>FALSE</constant>.
- </para>
-
- <para>
- On success, this function prints a message showing the gamma
- value selected, and returns <constant>TRUE</constant>.
- </para>
-
- <para>
- On failure it prints an error message and returns <constant>FALSE</constant>.
- </para>
-
- </blockquote></para></blockquote>
-
-
- <blockquote><para>
- <programlisting>
- void xf86SetDpi(ScrnInfoPtr pScrn, int x, int y);
- </programlisting>
- <blockquote><para>
- This function sets the <structfield>xDpi</structfield> and <structfield>yDpi</structfield>
- fields of the <structname>ScrnInfoRec</structname>. The driver can specify
- preferred defaults by setting <parameter>x</parameter> and <parameter>y</parameter>
- to non-zero values. The <option>-dpi</option> command line option
- overrides all other settings. Otherwise, if the
- <emphasis>DisplaySize</emphasis> entry is present in the screen's &k.monitor;
- config file section, it is used together with the virtual size to
- calculate the dpi values. This function should be called after
- all the mode resolution has been done.
- </para>
-
- </blockquote></para></blockquote>
-
- <blockquote><para>
- <programlisting>
- void xf86SetBlackWhitePixels(ScrnInfoPtr pScrn);
- </programlisting>
- <blockquote><para>
- This functions sets the <structfield>blackPixel</structfield> and
- <structfield>whitePixel</structfield> fields of the <structname>ScrnInfoRec</structname>
- according to whether or not the <option>-flipPixels</option> command
- line options is present.
- </para>
-
- </blockquote></para></blockquote>
-
- <blockquote><para>
- <programlisting>
- const char *xf86GetVisualName(int visual);
- </programlisting>
- <blockquote><para>
- Returns a printable string with the visual name matching the
- numerical visual class provided. If the value is outside the
- range of valid visual classes, <constant>NULL</constant> is returned.
- </para>
-
- </blockquote></para></blockquote>
-
- </sect2>
-
- <sect2>
- <title>Primary Mode functions</title>
-
- <para>
-The primary mode helper functions are those which would normally be
-used by a driver, unless it has unusual requirements which cannot
-be catered for the by the helpers.
- </para>
-
- <blockquote><para>
- <programlisting>
- int xf86ValidateModes(ScrnInfoPtr scrp, DisplayModePtr availModes,
- char **modeNames, ClockRangePtr clockRanges,
- int *linePitches, int minPitch, int maxPitch,
- int pitchInc, int minHeight, int maxHeight,
- int virtualX, int virtualY,
- unsigned long apertureSize,
- LookupModeFlags strategy);
- </programlisting>
- <blockquote><para>
- This function basically selects the set of modes to use based on
- those available and the various constraints. It also sets some
- other related parameters. It is normally called near the end of
- the <function>ChipPreInit()</function> function.
- </para>
-
- <para>
- The parameters passed to the function are:
-
- <variablelist>
- <varlistentry>
- <term><parameter>availModes</parameter></term>
- <listitem><para>
- List of modes available for the monitor.
- </para></listitem></varlistentry>
-
- <varlistentry>
- <term><parameter>modeNames</parameter></term>
- <listitem><para>
- List of mode names that the screen is requesting.
- </para></listitem></varlistentry>
-
- <varlistentry>
- <term><parameter>clockRanges</parameter></term>
- <listitem><para>
- A list of clock ranges allowed by the driver. Each
- range includes whether interlaced or multiscan modes
- are supported for that range. See below for more on
- <parameter>clockRanges</parameter>.
- </para></listitem></varlistentry>
-
- <varlistentry>
- <term><parameter>linePitches</parameter></term>
- <listitem><para>
- List of line pitches supported by the driver.
- This is optional and should be <constant>NULL</constant> when
- not used.
- </para></listitem></varlistentry>
-
- <varlistentry>
- <term><parameter>minPitch</parameter></term>
- <listitem><para>
- Minimum line pitch supported by the driver. This must
- be supplied when <parameter>linePitches</parameter> is
- <constant>NULL</constant>, and is ignored otherwise.
- </para></listitem></varlistentry>
-
- <varlistentry>
- <term><parameter>maxPitch</parameter></term>
- <listitem><para>
- Maximum line pitch supported by the driver. This is
- required when <parameter>minPitch</parameter> is required.
- </para></listitem></varlistentry>
-
- <varlistentry>
- <term><parameter>pitchInc</parameter></term>
- <listitem><para>
- Granularity of horizontal pitch values as supported by
- the chipset. This is expressed in bits. This must be
- supplied.
- </para></listitem></varlistentry>
-
- <varlistentry>
- <term><parameter>minHeight</parameter></term>
- <listitem><para>
- minimum virtual height allowed. If zero, no limit is
- imposed.
- </para></listitem></varlistentry>
-
- <varlistentry>
- <term><parameter>maxHeight</parameter></term>
- <listitem><para>
- maximum virtual height allowed. If zero, no limit is
- imposed.
- </para></listitem></varlistentry>
-
- <varlistentry>
- <term><parameter>virtualX</parameter></term>
- <listitem><para>
- If greater than zero, this is the virtual width value
- that will be used. Otherwise, the virtual width is
- chosen to be the smallest that can accommodate the modes
- selected.
- </para></listitem></varlistentry>
-
- <varlistentry>
- <term><parameter>virtualY</parameter></term>
- <listitem><para>
- If greater than zero, this is the virtual height value
- that will be used. Otherwise, the virtual height is
- chosen to be the smallest that can accommodate the modes
- selected.
- </para></listitem></varlistentry>
-
- <varlistentry>
- <term><parameter>apertureSize</parameter></term>
- <listitem><para>
- The size (in bytes) of the aperture used to access video
- memory.
- </para></listitem></varlistentry>
-
- <varlistentry>
- <term><parameter>strategy</parameter></term>
- <listitem><para>
- The strategy to use when choosing from multiple modes
- with the same name. The options are:
-
- <variablelist>
- <varlistentry>
- <term><constant>LOOKUP_DEFAULT</constant></term>
- <listitem><para>???
- </para></listitem></varlistentry>
- <varlistentry>
- <term><constant>LOOKUP_BEST_REFRESH</constant></term>
- <listitem><para>mode with best refresh rate
- </para></listitem></varlistentry>
- <varlistentry>
- <term><constant>LOOKUP_CLOSEST_CLOCK</constant></term>
- <listitem><para>mode with closest matching clock
- </para></listitem></varlistentry>
- <varlistentry>
- <term><constant>LOOKUP_LIST_ORDER</constant></term>
- <listitem><para>first usable mode in list
- </para></listitem></varlistentry>
- </variablelist>
-
- The following options can also be combined (OR'ed) with
- one of the above:
-
- <variablelist>
- <varlistentry>
- <term><constant>LOOKUP_CLKDIV2</constant></term>
- <listitem><para>Allow halved clocks
- </para></listitem></varlistentry>
- <varlistentry>
- <term><constant>LOOKUP_OPTIONAL_TOLERANCES</constant></term>
- <listitem><para>
- Allow missing horizontal sync and/or vertical refresh
- ranges in the xorg.conf Monitor section
- </para></listitem></varlistentry>
- </variablelist>
-
- <constant>LOOKUP_OPTIONAL_TOLERANCES</constant> should only be
- specified when the driver can ensure all modes it generates
- can sync on, or at least not damage, the monitor or digital
- flat panel. Horizontal sync and/or vertical refresh ranges
- specified by the user will still be honoured (and acted upon).
-
- </para></listitem></varlistentry>
- </variablelist>
- </para>
-
- <para>
- This function requires that the following fields of the
- <structname>ScrnInfoRec</structname> are initialised prior to calling it:
-
- <variablelist>
- <varlistentry>
- <term><structfield>clock[]</structfield></term>
- <listitem><para>
- List of discrete clocks (when non-programmable)
- </para></listitem></varlistentry>
- <varlistentry>
- <term><structfield>numClocks</structfield></term>
- <listitem><para>
- Number of discrete clocks (when non-programmable)
- </para></listitem></varlistentry>
- <varlistentry>
- <term><structfield>progClock</structfield></term>
- <listitem><para>
- Whether the clock is programmable or not
- </para></listitem></varlistentry>
- <varlistentry>
- <term><structfield>monitor</structfield></term>
- <listitem><para>
- Pointer to the applicable xorg.conf monitor section
- </para></listitem></varlistentry>
- <varlistentry>
- <term><structfield>fdFormat</structfield></term>
- <listitem><para>
- Format of the screen buffer
- </para></listitem></varlistentry>
- <varlistentry>
- <term><structfield>videoRam</structfield></term>
- <listitem><para>
- total video memory size (in bytes)
- </para></listitem></varlistentry>
- <varlistentry>
- <term><structfield>maxHValue</structfield></term>
- <listitem><para>
- Maximum horizontal timing value allowed
- </para></listitem></varlistentry>
- <varlistentry>
- <term><structfield>maxVValue</structfield></term>
- <listitem><para>
- Maximum vertical timing value allowed
- </para></listitem></varlistentry>
- <varlistentry>
- <term><structfield>xInc</structfield></term>
- <listitem><para>
- Horizontal timing increment in pixels (defaults to 8)
- </para></listitem></varlistentry>
- </variablelist>
- </para>
-
- <para>
- This function fills in the following <structname>ScrnInfoRec</structname>
- fields:
-
- <variablelist>
- <varlistentry>
- <term><structfield>modePool</structfield></term>
- <listitem><para>
- A subset of the modes available to the monitor which
- are compatible with the driver.
- </para></listitem></varlistentry>
-
- <varlistentry>
- <term><structfield>modes</structfield></term>
- <listitem><para>
- One mode entry for each of the requested modes, with
- the status field of each filled in to indicate if
- the mode has been accepted or not. This list of
- modes is a circular list.
- </para></listitem></varlistentry>
-
- <varlistentry>
- <term><structfield>virtualX</structfield></term>
- <listitem><para>
- The resulting virtual width.
- </para></listitem></varlistentry>
-
- <varlistentry>
- <term><structfield>virtualY</structfield></term>
- <listitem><para>
- The resulting virtual height.
- </para></listitem></varlistentry>
-
- <varlistentry>
- <term><structfield>displayWidth</structfield></term>
- <listitem><para>
- The resulting line pitch.
- </para></listitem></varlistentry>
-
- <varlistentry>
- <term><structfield>virtualFrom</structfield></term>
- <listitem><para>
- Where the virtual size was determined from.
- </para></listitem></varlistentry>
-
- </variablelist>
- </para>
-
- <para>
- The first stage of this function checks that the
- <parameter>virtualX</parameter> and <parameter>virtualY</parameter> values
- supplied (if greater than zero) are consistent with the line pitch
- and <parameter>maxHeight</parameter> limitations. If not, an error
- message is printed, and the return value is <constant>-1</constant>.
- </para>
-
- <para>
- The second stage sets up the mode pool, eliminating immediately
- any modes that exceed the driver's line pitch limits, and also
- the virtual width and height limits (if greater than zero). For
- each mode removed an informational message is printed at verbosity
- level <constant>2</constant>. If the mode pool ends up being empty,
- a warning message is printed, and the return value is
- <constant>0</constant>.
- </para>
-
- <para>
- The final stage is to lookup each mode name, and fill in the remaining
- parameters. If an error condition is encountered, a message is
- printed, and the return value is <constant>-1</constant>. Otherwise,
- the return value is the number of valid modes found
- (<constant>0</constant> if none are found).
- </para>
-
- <para>
- Even if the supplied mode names include duplicates, no two names will
- ever match the same mode. Furthermore, if the supplied mode names do not
- yield a valid mode (including the case where no names are passed at all),
- the function will continue looking through the mode pool until it finds
- a mode that survives all checks, or until the mode pool is exhausted.
- </para>
-
- <para>
- A message is only printed by this function when a fundamental
- problem is found. It is intended that this function may be called
- more than once if there is more than one set of constraints that
- the driver can work within.
- </para>
-
- <para>
- If this function returns <constant>-1</constant>, the
- <function>ChipPreInit()</function> function should return
- <constant>FALSE</constant>.
- </para>
-
- <para>
- <parameter>clockRanges</parameter> is a linked list of clock ranges
- allowed by the driver. If a mode doesn't fit in any of the defined
- <parameter>clockRanges</parameter>, it is rejected. The first
- <literal remap="tt">clockRange</literal> that matches all requirements is used.
- This structure needs to be initialized to NULL when allocated.
- </para>
-
- <para>
- <parameter>clockRanges</parameter> contains the following fields:
-
- <variablelist>
- <varlistentry>
- <term><structfield>minClock</structfield></term>
- <term><structfield>maxClock</structfield></term>
- <listitem><para>
- The lower and upper mode clock bounds for which the rest
- of the <structname>clockRange</structname> parameters apply.
- Since these are the mode clocks, they are not scaled
- with the <structfield>ClockMulFactor</structfield> and
- <structfield>ClockDivFactor</structfield>. It is up to the driver
- to adjust these values if they depend on the clock
- scaling factors.
- </para></listitem></varlistentry>
-
- <varlistentry>
- <term><structfield>clockIndex</structfield></term>
- <listitem><para>
- (not used yet) <constant>-1</constant> for programmable clocks
- </para></listitem></varlistentry>
-
- <varlistentry>
- <term><structfield>interlaceAllowed</structfield></term>
- <listitem><para>
- <constant>TRUE</constant> if interlacing is allowed for this
- range
- </para></listitem></varlistentry>
-
- <varlistentry>
- <term><structfield>doubleScanAllowed</structfield></term>
- <listitem><para>
- <constant>TRUE</constant> if doublescan or multiscan is allowed
- for this range
- </para></listitem></varlistentry>
-
- <varlistentry>
- <term><structfield>ClockMulFactor</structfield></term>
- <term><structfield>ClockDivFactor</structfield></term>
- <listitem><para>
- Scaling factors that are applied to the mode clocks ONLY
- before selecting a clock index (when there is no
- programmable clock) or a <structfield>SynthClock</structfield>
- value. This is useful for drivers that support pixel
- multiplexing or that need to scale the clocks because
- of hardware restrictions (like sending 24bpp data to an
- 8 bit RAMDAC using a tripled clock).
- </para>
-
- <para>
- Note that these parameters describe what must be done
- to the mode clock to achieve the data transport clock
- between graphics controller and RAMDAC. For example
- for <literal remap="tt">2:1</literal> pixel multiplexing, two pixels
- are sent to the RAMDAC on each clock. This allows the
- RAMDAC clock to be half of the actual pixel clock.
- Hence, <code>ClockMulFactor=1</code> and
- <code>ClockDivFactor=2</code>. This means that the
- clock used for clock selection (ie, determining the
- correct clock index from the list of discrete clocks)
- or for the <structfield>SynthClock</structfield> field in case of
- a programmable clock is: (<code>mode-&gt;Clock *
- ClockMulFactor) / ClockDivFactor</code>.
- </para></listitem></varlistentry>
-
- <varlistentry>
- <term><structfield>PrivFlags</structfield></term>
- <listitem><para>
- This field is copied into the
- <literal remap="tt">mode-&gt;PrivFlags</literal> field when this
- <literal remap="tt">clockRange</literal> is selected by
- <function>xf86ValidateModes()</function>. It allows the
- driver to find out what clock range was selected, so it
- knows it needs to set up pixel multiplexing or any other
- range-dependent feature. This field is purely
- driver-defined: it may contain flag bits, an index or
- anything else (as long as it is an <literal remap="tt">INT</literal>).
- </para></listitem></varlistentry>
- </variablelist>
- </para>
-
- <para>
- Note that the <structfield>mode-&gt;SynthClock</structfield> field is always
- filled in by <function>xf86ValidateModes()</function>: it will contain
- the <quote>data transport clock</quote>, which is the clock that will have
- to be programmed in the chip when it has a programmable clock, or
- the clock that will be picked from the clocks list when it is not
- a programmable one. Thus:
-
- <programlisting>
- mode-&gt;SynthClock = (mode-&gt;Clock * ClockMulFactor) / ClockDivFactor
- </programlisting>
- </para>
-
- </blockquote></para></blockquote>
-
- <blockquote><para>
- <programlisting>
- void xf86PruneDriverModes(ScrnInfoPtr scrp);
- </programlisting>
- <blockquote><para>
- This function deletes modes in the modes field of the
- <structname>ScrnInfoRec</structname> that have been marked as invalid.
- This is normally run after having run
- <function>xf86ValidateModes()</function> for the last time. For each
- mode that is deleted, a warning message is printed out indicating
- the reason for it being deleted.
- </para>
-
- </blockquote></para></blockquote>
-
- <blockquote><para>
- <programlisting>
- void xf86SetCrtcForModes(ScrnInfoPtr scrp, int adjustFlags);
- </programlisting>
- <blockquote><para>
- This function fills in the <structname>Crtc*</structname> fields for all
- the modes in the <structfield>modes</structfield> field of the
- <structname>ScrnInfoRec</structname>. The <parameter>adjustFlags</parameter>
- parameter determines how the vertical CRTC values are scaled for
- interlaced modes. They are halved if it is
- <constant>INTERLACE_HALVE_V</constant>. The vertical CRTC values are
- doubled for doublescan modes, and are further multiplied by the
- <literal remap="tt">VScan</literal> value.
- </para>
-
- <para>
- This function is normally called after calling
- <function>xf86PruneDriverModes()</function>.
- </para>
-
- </blockquote></para></blockquote>
-
- <blockquote><para>
- <programlisting>
- void xf86PrintModes(ScrnInfoPtr scrp);
- </programlisting>
- <blockquote><para>
- This function prints out the virtual size setting, and the line
- pitch being used. It also prints out two lines for each mode being
- used. The first line includes the mode's pixel clock, horizontal sync
- rate, refresh rate, and whether it is interlaced, doublescanned and/or
- multi-scanned. The second line is the mode's Modeline.
- </para>
-
- <para>
- This function is normally called after calling
- <function>xf86SetCrtcForModes()</function>.
- </para>
-
- </blockquote></para></blockquote>
-
- </sect2>
-
- <sect2>
- <title>Secondary Mode functions</title>
-
- <para>
-The secondary mode helper functions are functions which are normally
-used by the primary mode helper functions, and which are not normally
-called directly by a driver. If a driver has unusual requirements
-and needs to do its own mode validation, it might be able to make
-use of some of these secondary mode helper functions.
- </para>
-
- <blockquote><para>
- <programlisting>
- int xf86GetNearestClock(ScrnInfoPtr scrp, int freq, Bool allowDiv2,
- int *divider);
- </programlisting>
- <blockquote><para>
- This function returns the index of the closest clock to the
- frequency <parameter>freq</parameter> given (in kHz). It assumes that
- the number of clocks is greater than zero. It requires that the
- <structfield>numClocks</structfield> and <structfield>clock</structfield> fields of the
- <structname>ScrnInfoRec</structname> are initialised. The
- <structfield>allowDiv2</structfield> field determines if the clocks can be
- halved. The <parameter>*divider</parameter> return value indicates
- whether clock division is used when determining the clock returned.
- </para>
-
- <para>
- This function is only for non-programmable clocks.
- </para>
-
- </blockquote></para></blockquote>
-
- <blockquote><para>
- <programlisting>
- const char *xf86ModeStatusToString(ModeStatus status);
- </programlisting>
- <blockquote><para>
- This function converts the <parameter>status</parameter> value to a
- descriptive printable string.
- </para>
-
- </blockquote></para></blockquote>
-
- <blockquote><para>
- <programlisting>
- ModeStatus xf86LookupMode(ScrnInfoPtr scrp, DisplayModePtr modep,
- ClockRangePtr clockRanges, LookupModeFlags strategy);
- </programlisting>
- <blockquote><para>
- This function takes a pointer to a mode with the name filled in,
- and looks for a mode in the <structfield>modePool</structfield> list which
- matches. The parameters of the matching mode are filled in to
- <parameter>*modep</parameter>. The <parameter>clockRanges</parameter> and
- <parameter>strategy</parameter> parameters are as for the
- <function>xf86ValidateModes()</function> function above.
- </para>
-
- <para>
- This function requires the <structfield>modePool</structfield>,
- <structfield>clock[]</structfield>, <structfield>numClocks</structfield> and
- <structfield>progClock</structfield> fields of the <structname>ScrnInfoRec</structname>
- to be initialised before being called.
- </para>
-
- <para>
- The return value is <constant>MODE_OK</constant> if a mode was found.
- Otherwise it indicates why a matching mode could not be found.
- </para>
-
- </blockquote></para></blockquote>
-
- <blockquote><para>
- <programlisting>
- ModeStatus xf86InitialCheckModeForDriver(ScrnInfoPtr scrp,
- DisplayModePtr mode, ClockRangePtr clockRanges,
- LookupModeFlags strategy, int maxPitch,
- int virtualX, int virtualY);
- </programlisting>
- <blockquote><para>
- This function checks the passed mode against some basic driver
- constraints. Apart from the ones passed explicitly, the
- <structfield>maxHValue</structfield> and <structfield>maxVValue</structfield> fields of
- the <structname>ScrnInfoRec</structname> are also used. If the
- <structfield>ValidMode</structfield> field of the <structname>ScrnInfoRec</structname>
- is set, that function is also called to check the mode. Next, the
- mode is checked against the monitor's constraints.
- </para>
-
- <para>
- If the mode is consistent with all constraints, the return value
- is <constant>MODE_OK</constant>. Otherwise the return value indicates
- which constraint wasn't met.
- </para>
-
- </blockquote></para></blockquote>
-
- <blockquote><para>
- <programlisting>
- void xf86DeleteMode(DisplayModePtr *modeList, DisplayModePtr mode);
- </programlisting>
- <blockquote><para>
- This function deletes the <parameter>mode</parameter> given from the
- <parameter>modeList</parameter>. It never prints any messages, so it is
- up to the caller to print a message if required.
- </para>
-
- </blockquote></para></blockquote>
- </sect2>
-
- <sect2>
- <title>Functions for handling strings and tokens</title>
-
- <para>
- Tables associating strings and numerical tokens combined with the
- following functions provide a compact way of handling strings from
- the config file, and for converting tokens into printable strings.
- The table data structure is:
-
- <programlisting>
-typedef struct {
- int token;
- const char * name;
-} SymTabRec, *SymTabPtr;
- </programlisting>
- </para>
-
- <para>
- A table is an initialised array of <structname>SymTabRec</structname>. The
- tokens must be non-negative integers. Multiple names may be mapped
- to a single token. The table is terminated with an element with a
- <structfield>token</structfield> value of <constant>-1</constant> and
- <constant>NULL</constant> for the <structfield>name</structfield>.
- </para>
-
- <blockquote><para>
- <programlisting>
- const char *xf86TokenToString(SymTabPtr table, int token);
- </programlisting>
- <blockquote><para>
- This function returns the first string in <parameter>table</parameter>
- that matches <parameter>token</parameter>. If no match is found,
- <constant>NULL</constant> is returned (NOTE, older versions of this
- function would return the string "unknown" when no match is found).
- </para>
-
- </blockquote></para></blockquote>
-
- <blockquote><para>
- <programlisting>
- int xf86StringToToken(SymTabPtr table, const char *string);
- </programlisting>
- <blockquote><para>
- This function returns the first token in <parameter>table</parameter>
- that matches <parameter>string</parameter>. The
- <function>xf86NameCmp()</function> function is used to determine the
- match. If no match is found, <constant>-1</constant> is returned.
- </para>
-
- </blockquote></para></blockquote>
-
- </sect2>
-
- <sect2>
- <title>Functions for finding which config file entries to use</title>
-
- <para>
- These functions can be used to select the appropriate config file
- entries that match the detected hardware. They are described above
- in the <link linkend="probe">Probe</link> and
- <link linkend="avail">Available Functions</link> sections.
- </para>
-
- </sect2>
-
- <sect2>
- <title>Probing discrete clocks on old hardware</title>
-
- <para>
- The <function>xf86GetClocks()</function> function may be used to assist
- in finding the discrete pixel clock values on older hardware.
- </para>
-
- <blockquote><para>
- <programlisting>
- void xf86GetClocks(ScrnInfoPtr pScrn, int num,
- Bool (*ClockFunc)(ScrnInfoPtr, int),
- void (*ProtectRegs)(ScrnInfoPtr, Bool),
- void (*BlankScreen)(ScrnInfoPtr, Bool),
- int vertsyncreg, int maskval, int knownclkindex,
- int knownclkvalue);
- </programlisting>
- <blockquote><para>
- This function uses a comparative sampling method to measure the
- discrete pixel clock values. The number of discrete clocks to
- measure is given by <parameter>num</parameter>. <parameter>clockFunc</parameter>
- is a function that selects the <parameter>n</parameter>'th clock. It
- should also save or restore any state affected by programming the
- clocks when the index passed is <constant>CLK_REG_SAVE</constant> or
- <constant>CLK_REG_RESTORE</constant>. <parameter>ProtectRegs</parameter> is
- a function that does whatever is required to protect the hardware
- state while selecting a new clock. <parameter>BlankScreen</parameter>
- is a function that blanks the screen. <parameter>vertsyncreg</parameter>
- and <parameter>maskval</parameter> are the register and bitmask to
- check for the presence of vertical sync pulses.
- <parameter>knownclkindex</parameter> and <parameter>knownclkvalue</parameter>
- are the index and value of a known clock. These are the known
- references on which the comparative measurements are based. The
- number of clocks probed is set in <structfield>pScrn-&gt;numClocks</structfield>,
- and the probed clocks are set in the <structfield>pScrn-&gt;clock[]</structfield>
- array. All of the clock values are in units of kHz.
- </para>
-
- </blockquote></para></blockquote>
-
- <blockquote><para>
- <programlisting>
- void xf86ShowClocks(ScrnInfoPtr scrp, MessageType from);
- </programlisting>
- <blockquote><para>
- Print out the pixel clocks <parameter>scrp-&gt;clock[]</parameter>.
- <parameter>from</parameter> indicates whether the clocks were probed
- or from the config file.
- </para>
-
- </blockquote></para></blockquote>
- </sect2>
-
- <sect2>
- <title>Other helper functions</title>
-
- <blockquote><para>
- <programlisting>
- Bool xf86IsUnblank(int mode);
- </programlisting>
- <blockquote><para>
- Returns <constant>TRUE</constant> when the screen saver mode specified
- by <parameter>mode</parameter> requires the screen be unblanked,
- and <constant>FALSE</constant> otherwise. The screen saver modes that
- require blanking are <constant>SCREEN_SAVER_ON</constant> and
- <constant>SCREEN_SAVER_CYCLE</constant>, and the screen saver modes that
- require unblanking are <constant>SCREEN_SAVER_OFF</constant> and
- <constant>SCREEN_SAVER_FORCER</constant>. Drivers may call this helper
- from their <function>SaveScreen()</function> function to interpret the
- screen saver modes.
- </para>
-
- </blockquote></para></blockquote>
- </sect2>
- </sect1>
-
- <sect1>
- <title>The vgahw module</title>
-
- <para>
-The vgahw modules provides an interface for saving, restoring and
-programming the standard VGA registers, and for handling VGA colourmaps.
- </para>
-
- <sect2>
- <title>Data Structures</title>
-
- <para>
- The public data structures used by the vgahw module are
- <structname>vgaRegRec</structname> and <structname>vgaHWRec</structname>. They are
- defined in <filename>vgaHW.h.</filename>
- </para>
-
- </sect2>
-
- <sect2>
- <title>General vgahw Functions</title>
-
- <blockquote><para>
- <programlisting>
- Bool vgaHWGetHWRec(ScrnInfoPtr pScrn);
- </programlisting>
- <blockquote><para>
- This function allocates a <structname>vgaHWRec</structname> structure, and
- hooks it into the <structname>ScrnInfoRec</structname>'s
- <structfield>privates</structfield>. Like all information hooked into the
- <structfield>privates</structfield>, it is persistent, and only needs to be
- allocated once per screen. This function should normally be called
- from the driver's <function>ChipPreInit()</function> function. The
- <structname>vgaHWRec</structname> is zero-allocated, and the following
- fields are explicitly initialised:
-
- <variablelist>
- <varlistentry>
- <term><structfield>ModeReg.DAC[]</structfield></term>
- <listitem><para>initialised with a default colourmap
- </para></listitem></varlistentry>
- <varlistentry>
- <term><structfield>ModeReg.Attribute[0x11]</structfield></term>
- <listitem><para>initialised with the default overscan index
- </para></listitem></varlistentry>
- <varlistentry>
- <term><structfield>ShowOverscan</structfield></term>
- <listitem><para>initialised according to the "ShowOverscan" option
- </para></listitem></varlistentry>
- <varlistentry>
- <term><structfield>paletteEnabled</structfield></term>
- <listitem><para>initialised to FALSE
- </para></listitem></varlistentry>
- <varlistentry>
- <term><structfield>cmapSaved</structfield></term>
- <listitem><para>initialised to FALSE
- </para></listitem></varlistentry>
- <varlistentry>
- <term><structfield>pScrn</structfield></term>
- <listitem><para>initialised to pScrn
- </para></listitem></varlistentry>
- </variablelist>
- </para>
-
- <para>
- In addition to the above, <function>vgaHWSetStdFuncs()</function> is
- called to initialise the register access function fields with the
- standard VGA set of functions.
- </para>
-
- <para>
- Once allocated, a pointer to the <structname>vgaHWRec</structname> can be
- obtained from the <literal remap="tt">ScrnInfoPtr</literal> with the
- <literal remap="tt">VGAHWPTR(pScrn)</literal> macro.
- </para>
-
- </blockquote></para></blockquote>
-
- <blockquote><para>
- <programlisting>
- void vgaHWFreeHWRec(ScrnInfoPtr pScrn);
- </programlisting>
- <blockquote><para>
- This function frees a <structname>vgaHWRec</structname> structure. It
- should be called from a driver's <function>ChipFreeScreen()</function>
- function.
- </para>
-
- </blockquote></para></blockquote>
-
- <blockquote><para>
- <programlisting>
- Bool vgaHWSetRegCounts(ScrnInfoPtr pScrn, int numCRTC,
- int numSequencer, int numGraphics, int numAttribute);
- </programlisting>
- <blockquote><para>
- This function allows the number of CRTC, Sequencer, Graphics and
- Attribute registers to be changed. This makes it possible for
- extended registers to be saved and restored with
- <function>vgaHWSave()</function> and <function>vgaHWRestore()</function>.
- This function should be called after a <structname>vgaHWRec</structname>
- has been allocated with <function>vgaHWGetHWRec()</function>. The
- default values are defined in <filename>vgaHW.h</filename> as follows:
-
- <programlisting>
-#define VGA_NUM_CRTC 25
-#define VGA_NUM_SEQ 5
-#define VGA_NUM_GFX 9
-#define VGA_NUM_ATTR 21
- </programlisting>
- </para>
-
- </blockquote></para></blockquote>
-
- <blockquote><para>
- <programlisting>
- Bool vgaHWCopyReg(vgaRegPtr dst, vgaRegPtr src);
- </programlisting>
- <blockquote><para>
- This function copies the contents of the VGA saved registers in
- <parameter>src</parameter> to <parameter>dst</parameter>. Note that it isn't
- possible to simply do this with <function>memcpy()</function> (or
- similar). This function returns <constant>TRUE</constant> unless there
- is a problem allocating space for the <structfield>CRTC</structfield> and
- related fields in <parameter>dst</parameter>.
- </para>
-
- </blockquote></para></blockquote>
-
- <blockquote><para>
- <programlisting>
- void vgaHWSetStdFuncs(vgaHWPtr hwp);
- </programlisting>
- <blockquote><para>
- This function initialises the register access function fields of
- <parameter>hwp</parameter> with the standard VGA set of functions. This
- is called by <function>vgaHWGetHWRec()</function>, so there is usually
- no need to call this explicitly. The register access functions
- are described below. If the registers are shadowed in some other
- port I/O space (for example a PCI I/O region), these functions
- can be used to access the shadowed registers if
- <structfield>hwp-&gt;PIOOffset</structfield> is initialised with
- <literal remap="tt">offset</literal>, calculated in such a way that when the
- standard VGA I/O port value is added to it the correct offset into
- the PIO area results. This value is initialised to zero in
- <function>vgaHWGetHWRec()</function>. (Note: the PIOOffset functionality
- is present in XFree86 4.1.0 and later.)
- </para>
-
- </blockquote></para></blockquote>
-
- <blockquote><para>
- <programlisting>
- void vgaHWSetMmioFuncs(vgaHWPtr hwp, CARD8 *base, int offset);
- </programlisting>
- <blockquote><para>
- This function initialised the register access function fields of
- hwp with a generic MMIO set of functions.
- <structfield>hwp-&gt;MMIOBase</structfield> is initialised with
- <parameter>base</parameter>, which must be the virtual address that the
- start of MMIO area is mapped to. <structfield>hwp-&gt;MMIOOffset</structfield>
- is initialised with <parameter>offset</parameter>, which must be calculated
- in such a way that when the standard VGA I/O port value is added
- to it the correct offset into the MMIO area results. That means
- that these functions are only suitable when the VGA I/O ports are
- made available in a direct mapping to the MMIO space. If that is
- not the case, the driver will need to provide its own register
- access functions. The register access functions are described
- below.
- </para>
-
- </blockquote></para></blockquote>
-
- <blockquote><para>
- <programlisting>
- Bool vgaHWMapMem(ScrnInfoPtr pScrn);
- </programlisting>
- <blockquote><para>
- This function maps the VGA memory window. It requires that the
- <structname>vgaHWRec</structname> be allocated. If a driver requires
- non-default <structfield>MapPhys</structfield> or <structfield>MapSize</structfield>
- settings (the physical location and size of the VGA memory window)
- then those fields of the <structname>vgaHWRec</structname> must be initialised
- before calling this function. Otherwise, this function initialiases
- the default values of <constant>0xA0000</constant> for
- <structfield>MapPhys</structfield> and <code>(64&nbsp;*&nbsp;1024)</code> for
- <structfield>MapSize</structfield>. This function must be called before
- attempting to save or restore the VGA state. If the driver doesn't
- call it explicitly, the <function>vgaHWSave()</function> and
- <function>vgaHWRestore()</function> functions may call it if they need
- to access the VGA memory (in which case they will also call
- <function>vgaHWUnmapMem()</function> to unmap the VGA memory before
- exiting).
- </para>
-
- </blockquote></para></blockquote>
-
- <blockquote><para>
- <programlisting>
- void vgaHWUnmapMem(ScrnInfoPtr pScrn);
- </programlisting>
- <blockquote><para>
- This function unmaps the VGA memory window. It must only be called
- after the memory has been mapped. The <structfield>Base</structfield> field
- of the <structname>vgaHWRec</structname> field is set to <constant>NULL</constant>
- to indicate that the memory is no longer mapped.
- </para>
-
- </blockquote></para></blockquote>
-
- <blockquote><para>
- <programlisting>
- void vgaHWGetIOBase(vgaHWPtr hwp);
- </programlisting>
- <blockquote><para>
- This function initialises the <structfield>IOBase</structfield> field of the
- <structname>vgaHWRec</structname>. This function must be called before
- using any other functions that access the video hardware.
- </para>
-
- <para>
- A macro <function>VGAHW_GET_IOBASE()</function> is also available in
- <filename>vgaHW.h</filename> that returns the I/O base, and this may
- be used when the vgahw module is not loaded (for example, in the
- <function>ChipProbe()</function> function).
- </para>
-
- </blockquote></para></blockquote>
-
- <blockquote><para>
- <programlisting>
- void vgaHWUnlock(vgaHWPtr hwp);
- </programlisting>
- <blockquote><para>
- This function unlocks the VGA <literal remap="tt">CRTC[0-7]</literal> registers,
- and must be called before attempting to write to those registers.
- </para>
-
- </blockquote></para></blockquote>
-
- <blockquote><para>
- <programlisting>
- void vgaHWLock(vgaHWPtr hwp);
- </programlisting>
- <blockquote><para>
- This function locks the VGA <literal remap="tt">CRTC[0-7]</literal> registers.
- </para>
-
- </blockquote></para></blockquote>
-
- <blockquote><para>
- <programlisting>
- void vgaHWEnable(vgaHWPtr hwp);
- </programlisting>
- <blockquote><para>
- This function enables the VGA subsystem. (Note, this function is
- present in XFree86 4.1.0 and later.).
- </para>
-
- </blockquote></para></blockquote>
-
- <blockquote><para>
- <programlisting>
- void vgaHWDisable(vgaHWPtr hwp);
- </programlisting>
- <blockquote><para>
- This function disables the VGA subsystem. (Note, this function is
- present in XFree86 4.1.0 and later.).
- </para>
-
- </blockquote></para></blockquote>
-
- <blockquote><para>
- <programlisting>
- void vgaHWSave(ScrnInfoPtr pScrn, vgaRegPtr save, int flags);
- </programlisting>
- <blockquote><para>
- This function saves the VGA state. The state is written to the
- <structname>vgaRegRec</structname> pointed to by <parameter>save</parameter>.
- <parameter>flags</parameter> is set to one or more of the following flags
- ORed together:
-
- <variablelist>
- <varlistentry>
- <term><constant>VGA_SR_MODE</constant></term>
- <listitem><para>the mode setting registers are saved
- </para></listitem></varlistentry>
- <varlistentry>
- <term><constant>VGA_SR_FONTS</constant></term>
- <listitem><para>the text mode font/text data is saved
- </para></listitem></varlistentry>
- <varlistentry>
- <term><constant>VGA_SR_CMAP</constant></term>
- <listitem><para>the colourmap (LUT) is saved
- </para></listitem></varlistentry>
- <varlistentry>
- <term><constant>VGA_SR_ALL</constant></term>
- <listitem><para>all of the above are saved
- </para></listitem></varlistentry>
- </variablelist>
- </para>
-
- <para>
- The <structname>vgaHWRec</structname> and its <structfield>IOBase</structfield> fields
- must be initialised before this function is called. If
- <constant>VGA_SR_FONTS</constant> is set in <parameter>flags</parameter>, the
- VGA memory window must be mapped. If it isn't then
- <function>vgaHWMapMem()</function> will be called to map it, and
- <function>vgaHWUnmapMem()</function> will be called to unmap it
- afterwards. <function>vgaHWSave()</function> uses the three functions
- below in the order <function>vgaHWSaveColormap()</function>,
- <function>vgaHWSaveMode()</function>, <function>vgaHWSaveFonts()</function> to
- carry out the different save phases. It is undecided at this
- stage whether they will remain part of the vgahw module's public
- interface or not.
- </para>
-
- </blockquote></para></blockquote>
-
- <blockquote><para>
- <programlisting>
- void vgaHWSaveMode(ScrnInfoPtr pScrn, vgaRegPtr save);
- </programlisting>
- <blockquote><para>
- This function saves the VGA mode registers. They are saved to
- the <structname>vgaRegRec</structname> pointed to by <parameter>save</parameter>.
- The registers saved are:
-
- <literallayout>
- MiscOut
- CRTC[0-0x18]
- Attribute[0-0x14]
- Graphics[0-8]
- Sequencer[0-4]
- </literallayout>
- </para>
-
- <para>
- The number of registers actually saved may be modified by a prior call
- to <function>vgaHWSetRegCounts()</function>.
- </para>
-
- </blockquote></para></blockquote>
-
- <blockquote><para>
- <programlisting>
- void vgaHWSaveFonts(ScrnInfoPtr pScrn, vgaRegPtr save);
- </programlisting>
- <blockquote><para>
- This function saves the text mode font and text data held in the
- video memory. If called while in a graphics mode, no save is
- done. The VGA memory window must be mapped with
- <function>vgaHWMapMem()</function> before to calling this function.
- </para>
-
- <para>
- On some platforms, one or more of the font/text plane saves may be
- no-ops. This is the case when the platform's VC driver already
- takes care of this.
- </para>
-
- </blockquote></para></blockquote>
-
- <blockquote><para>
- <programlisting>
- void vgaHWSaveColormap(ScrnInfoPtr pScrn, vgaRegPtr save);
- </programlisting>
- <blockquote><para>
- This function saves the VGA colourmap (LUT). Before saving it, it
- attempts to verify that the colourmap is readable. In rare cases
- where it isn't readable, a default colourmap is saved instead.
- </para>
-
- </blockquote></para></blockquote>
-
- <blockquote><para>
- <programlisting>
- void vgaHWRestore(ScrnInfoPtr pScrn, vgaRegPtr restore, int flags);
- </programlisting>
- <blockquote><para>
- This function programs the VGA state. The state programmed is
- that contained in the <structname>vgaRegRec</structname> pointed to by
- <parameter>restore</parameter>. <parameter>flags</parameter> is the same
- as described above for the <function>vgaHWSave()</function> function.
- </para>
-
- <para>
- The <structname>vgaHWRec</structname> and its <structfield>IOBase</structfield> fields
- must be initialised before this function is called. If
- <constant>VGA_SR_FONTS</constant> is set in <parameter>flags</parameter>, the
- VGA memory window must be mapped. If it isn't then
- <function>vgaHWMapMem()</function> will be called to map it, and
- <function>vgaHWUnmapMem()</function> will be called to unmap it
- afterwards. <function>vgaHWRestore()</function> uses the three functions
- below in the order <function>vgaHWRestoreFonts()</function>,
- <function>vgaHWRestoreMode()</function>,
- <function>vgaHWRestoreColormap()</function> to carry out the different
- restore phases. It is undecided at this stage whether they will
- remain part of the vgahw module's public interface or not.
- </para>
-
- </blockquote></para></blockquote>
-
- <blockquote><para>
- <programlisting>
- void vgaHWRestoreMode(ScrnInfoPtr pScrn, vgaRegPtr restore);
- </programlisting>
- <blockquote><para>
- This function restores the VGA mode registers. They are restored
- from the data in the <structname>vgaRegRec</structname> pointed to by
- <parameter>restore</parameter>. The registers restored are:
-
- <literallayout>
- MiscOut
- CRTC[0-0x18]
- Attribute[0-0x14]
- Graphics[0-8]
- Sequencer[0-4]
- </literallayout>
- </para>
-
- <para>
- The number of registers actually restored may be modified by a prior call
- to <function>vgaHWSetRegCounts()</function>.
- </para>
-
- </blockquote></para></blockquote>
-
- <blockquote><para>
- <programlisting>
- void vgaHWRestoreFonts(ScrnInfoPtr pScrn, vgaRegPtr restore);
- </programlisting>
- <blockquote><para>
- This function restores the text mode font and text data to the
- video memory. The VGA memory window must be mapped with
- <function>vgaHWMapMem()</function> before to calling this function.
- </para>
-
- <para>
- On some platforms, one or more of the font/text plane restores
- may be no-ops. This is the case when the platform's VC driver
- already takes care of this.
- </para>
-
- </blockquote></para></blockquote>
-
- <blockquote><para>
- <programlisting>
- void vgaHWRestoreColormap(ScrnInfoPtr pScrn, vgaRegPtr restore);
- </programlisting>
- <blockquote><para>
- This function restores the VGA colourmap (LUT).
- </para>
-
- </blockquote></para></blockquote>
-
- <blockquote><para>
- <programlisting>
- void vgaHWInit(ScrnInfoPtr pScrn, DisplayModePtr mode);
- </programlisting>
- <blockquote><para>
- This function fills in the <structname>vgaHWRec</structname>'s
- <structfield>ModeReg</structfield> field with the values appropriate for
- programming the given video mode. It requires that the
- <structname>ScrnInfoRec</structname>'s <structfield>depth</structfield> field is
- initialised, which determines how the registers are programmed.
- </para>
-
- </blockquote></para></blockquote>
-
- <blockquote><para>
- <programlisting>
- void vgaHWSeqReset(vgaHWPtr hwp, Bool start);
- </programlisting>
- <blockquote><para>
- Do a VGA sequencer reset. If start is <constant>TRUE</constant>, the
- reset is started. If start is <constant>FALSE</constant>, the reset
- is ended.
- </para>
-
- </blockquote></para></blockquote>
-
- <blockquote><para>
- <programlisting>
- void vgaHWProtect(ScrnInfoPtr pScrn, Bool on);
- </programlisting>
- <blockquote><para>
- This function protects VGA registers and memory from corruption
- during loads. It is typically called with on set to
- <constant>TRUE</constant> before programming, and with on set to
- <constant>FALSE</constant> after programming.
- </para>
-
- </blockquote></para></blockquote>
-
- <blockquote><para>
- <programlisting>
- Bool vgaHWSaveScreen(ScreenPtr pScreen, int mode);
- </programlisting>
- <blockquote><para>
- This function blanks and unblanks the screen. It is blanked when
- <parameter>mode</parameter> is <constant>SCREEN_SAVER_ON</constant> or
- <constant>SCREEN_SAVER_CYCLE</constant>, and unblanked when
- <parameter>mode</parameter> is <constant>SCREEN_SAVER_OFF</constant> or
- <constant>SCREEN_SAVER_FORCER</constant>.
- </para>
-
- </blockquote></para></blockquote>
-
- <blockquote><para>
- <programlisting>
- void vgaHWBlankScreen(ScrnInfoPtr pScrn, Bool on);
- </programlisting>
- <blockquote><para>
- This function blanks and unblanks the screen. It is blanked when
- <parameter>on</parameter> is <constant>FALSE</constant>, and unblanked when
- <parameter>on</parameter> is <constant>TRUE</constant>. This function is
- provided for use in cases where the <structname>ScrnInfoRec</structname>
- can't be derived from the <structname>ScreenRec</structname> (while probing
- for clocks, for example).
- </para>
-
- </blockquote></para></blockquote>
-
- </sect2>
-
- <sect2>
- <title>VGA Colormap Functions</title>
-
- <para>
- The vgahw module uses the standard colormap support (see the
- <link linkend="cmap">Colormap Handling</link> section. This is initialised
- with the following function:
-
- <blockquote><para>
- <programlisting>
- Bool vgaHWHandleColormaps(ScreenPtr pScreen);
- </programlisting>
- </para></blockquote>
- </para>
-
- </sect2>
-
- <sect2>
- <title>VGA Register Access Functions</title>
-
- <para>
- The vgahw module abstracts access to the standard VGA registers by
- using a set of functions held in the <structname>vgaHWRec</structname>. When
- the <structname>vgaHWRec</structname> is created these function pointers are
- initialised with the set of standard VGA I/O register access functions.
- In addition to these, the vgahw module includes a basic set of MMIO
- register access functions, and the <structname>vgaHWRec</structname> function
- pointers can be initialised to these by calling the
- <function>vgaHWSetMmioFuncs()</function> function described above. Some
- drivers/platforms may require a different set of functions for VGA
- access. The access functions are described here.
- </para>
-
-
- <blockquote><para>
- <programlisting>
- void writeCrtc(vgaHWPtr hwp, CARD8 index, CARD8 value);
- </programlisting>
- <blockquote><para>
- Write <parameter>value</parameter> to CRTC register <parameter>index</parameter>.
- </para>
-
- </blockquote></para></blockquote>
-
- <blockquote><para>
- <programlisting>
- CARD8 readCrtc(vgaHWPtr hwp, CARD8 index);
- </programlisting>
- <blockquote><para>
- Return the value read from CRTC register <parameter>index</parameter>.
- </para>
-
- </blockquote></para></blockquote>
-
- <blockquote><para>
- <programlisting>
- void writeGr(vgaHWPtr hwp, CARD8 index, CARD8 value);
- </programlisting>
- <blockquote><para>
- Write <parameter>value</parameter> to Graphics Controller register
- <parameter>index</parameter>.
- </para>
-
- </blockquote></para></blockquote>
-
- <blockquote><para>
- <programlisting>
- CARD8 readGR(vgaHWPtr hwp, CARD8 index);
- </programlisting>
- <blockquote><para>
- Return the value read from Graphics Controller register
- <parameter>index</parameter>.
- </para>
-
- </blockquote></para></blockquote>
-
- <blockquote><para>
- <programlisting>
- void writeSeq(vgaHWPtr hwp, CARD8 index, CARD8, value);
- </programlisting>
- <blockquote><para>
- Write <parameter>value</parameter> to Sequencer register
- <parameter>index</parameter>.
- </para>
-
- </blockquote></para></blockquote>
-
- <blockquote><para>
- <programlisting>
- CARD8 readSeq(vgaHWPtr hwp, CARD8 index);
- </programlisting>
- <blockquote><para>
- Return the value read from Sequencer register <parameter>index</parameter>.
- </para>
-
- </blockquote></para></blockquote>
-
- <blockquote><para>
- <programlisting>
- void writeAttr(vgaHWPtr hwp, CARD8 index, CARD8, value);
- </programlisting>
- <blockquote><para>
- Write <parameter>value</parameter> to Attribute Controller register
- <parameter>index</parameter>. When writing out the index value this
- function should set bit 5 (<constant>0x20</constant>) according to the
- setting of <structfield>hwp-&gt;paletteEnabled</structfield> in order to
- preserve the palette access state. It should be cleared when
- <structfield>hwp-&gt;paletteEnabled</structfield> is <constant>TRUE</constant>
- and set when it is <constant>FALSE</constant>.
- </para>
-
- </blockquote></para></blockquote>
-
- <blockquote><para>
- <programlisting>
- CARD8 readAttr(vgaHWPtr hwp, CARD8 index);
- </programlisting>
- <blockquote><para>
- Return the value read from Attribute Controller register
- <parameter>index</parameter>. When writing out the index value this
- function should set bit 5 (<constant>0x20</constant>) according to the
- setting of <structfield>hwp-&gt;paletteEnabled</structfield> in order to
- preserve the palette access state. It should be cleared when
- <structfield>hwp-&gt;paletteEnabled</structfield> is <constant>TRUE</constant>
- and set when it is <constant>FALSE</constant>.
- </para>
-
- </blockquote></para></blockquote>
-
- <blockquote><para>
- <programlisting>
- void writeMiscOut(vgaHWPtr hwp, CARD8 value);
- </programlisting>
- <blockquote><para>
- Write <quote><parameter>value</parameter></quote> to the Miscellaneous Output register.
- </para>
-
- </blockquote></para></blockquote>
-
- <blockquote><para>
- <programlisting>
- CARD8 readMiscOut(vgwHWPtr hwp);
- </programlisting>
- <blockquote><para>
- Return the value read from the Miscellaneous Output register.
- </para>
-
- </blockquote></para></blockquote>
-
- <blockquote><para>
- <programlisting>
- void enablePalette(vgaHWPtr hwp);
- </programlisting>
- <blockquote><para>
- Clear the palette address source bit in the Attribute Controller
- index register and set <literal remap="tt">hwp-&gt;paletteEnabled</literal> to
- <constant>TRUE</constant>.
- </para>
-
- </blockquote></para></blockquote>
-
- <blockquote><para>
- <programlisting>
- void disablePalette(vgaHWPtr hwp);
- </programlisting>
- <blockquote><para>
- Set the palette address source bit in the Attribute Controller
- index register and set <literal remap="tt">hwp-&gt;paletteEnabled</literal> to
- <constant>FALSE</constant>.
- </para>
-
- </blockquote></para></blockquote>
-
- <blockquote><para>
- <programlisting>
- void writeDacMask(vgaHWPtr hwp, CARD8 value);
- </programlisting>
- <blockquote><para>
- Write <parameter>value</parameter> to the DAC Mask register.
- </para>
-
- </blockquote></para></blockquote>
-
- <blockquote><para>
- <programlisting>
- CARD8 readDacMask(vgaHWptr hwp);
- </programlisting>
- <blockquote><para>
- Return the value read from the DAC Mask register.
- </para>
-
- </blockquote></para></blockquote>
-
- <blockquote><para>
- <programlisting>
- void writeDacReadAddress(vgaHWPtr hwp, CARD8 value);
- </programlisting>
- <blockquote><para>
- Write <parameter>value</parameter> to the DAC Read Address register.
- </para>
-
- </blockquote></para></blockquote>
-
- <blockquote><para>
- <programlisting>
- void writeDacWriteAddress(vgaHWPtr hwp, CARD8 value);
- </programlisting>
- <blockquote><para>
- Write <parameter>value</parameter> to the DAC Write Address register.
- </para>
-
- </blockquote></para></blockquote>
-
- <blockquote><para>
- <programlisting>
- void writeDacData(vgaHWPtr hwp, CARD8 value);
- </programlisting>
- <blockquote><para>
- Write <parameter>value</parameter> to the DAC Data register.
- </para>
-
- </blockquote></para></blockquote>
-
- <blockquote><para>
- <programlisting>
- CARD8 readDacData(vgaHWptr hwp);
- </programlisting>
- <blockquote><para>
- Return the value read from the DAC Data register.
- </para>
-
- </blockquote></para></blockquote>
-
- <blockquote><para>
- <programlisting>
- CARD8 readEnable(vgaHWptr hwp);
- </programlisting>
- <blockquote><para>
- Return the value read from the VGA Enable register. (Note: This
- function is present in XFree86 4.1.0 and later.)
- </para>
-
- </blockquote></para></blockquote>
-
- <blockquote><para>
- <programlisting>
- void writeEnable(vgaHWPtr hwp, CARD8 value);
- </programlisting>
- <blockquote><para>
- Write <parameter>value</parameter> to the VGA Enable register. (Note: This
- function is present in XFree86 4.1.0 and later.)
- </para>
-
- </blockquote></para></blockquote>
- </sect2>
- </sect1>
-
- <sect1 id="sample">
- <title>Some notes about writing a driver</title>
-
- <note><para>NOTE: some parts of this are not up to date</para></note>
-
- <para>
-The following is an outline for writing a basic unaccelerated driver
-for a PCI video card with a linear mapped framebuffer, and which has a
-VGA core. It is includes some general information that is relevant to
-most drivers (even those which don't fit that basic description).
- </para>
-
- <para>
-The information here is based on the initial conversion of the Matrox
-Millennium driver to the <quote>new design</quote>. For a fleshing out and sample
-implementation of some of the bits outlined here, refer to that driver.
-Note that this is an example only. The approach used here will not be
-appropriate for all drivers.
- </para>
-
- <para>
-Each driver must reserve a unique driver name, and a string that is used
-to prefix all of its externally visible symbols. This is to avoid name
-space clashes when loading multiple drivers. The examples here are for
-the <quote>ZZZ</quote> driver, which uses the <quote>ZZZ</quote> or <quote>zzz</quote> prefix for its externally
-visible symbols.
- </para>
-
- <sect2>
- <title>Include files</title>
-
- <para>
- All drivers normally include the following headers:
- <literallayout><filename>
- "xf86.h"
- "xf86_OSproc.h"
- "xf86_ansic.h"
- "xf86Resources.h"
- </filename></literallayout>
- Wherever inb/outb (and related things) are used the following should be
- included:
- <literallayout><filename>
- "compiler.h"
- </filename></literallayout>
- Note: in drivers, this must be included after <filename>"xf86_ansic.h"</filename>.
- </para>
-
- <para>
- Drivers that need to access PCI vendor/device definitions need this:
- <literallayout><filename>
- "xf86PciInfo.h"
- </filename></literallayout>
- </para>
-
- <para>
- Drivers that need to access the PCI config space need this:
- <literallayout><filename>
- "xf86Pci.h"
- </filename></literallayout>
- </para>
-
- <para>
- Drivers using the mi banking wrapper need:
-
- <literallayout><filename>
- "mibank.h"
- </filename></literallayout>
- </para>
-
- <para>
- Drivers that initialise a SW cursor need this:
- <literallayout><filename>
- "mipointer.h"
- </filename></literallayout>
- </para>
-
- <para>
- All drivers implementing backing store need this:
- <literallayout><filename>
- "mibstore.h"
- </filename></literallayout>
- </para>
-
- <para>
- All drivers using the mi colourmap code need this:
- <literallayout><filename>
- "micmap.h"
- </filename></literallayout>
- </para>
-
- <para>
- If a driver uses the vgahw module, it needs this:
- <literallayout><filename>
- "vgaHW.h"
- </filename></literallayout>
- </para>
-
- <para>
- Drivers supporting VGA or Hercules monochrome screens need:
- <literallayout><filename>
- "xf1bpp.h"
- </filename></literallayout>
- </para>
-
- <para>
- Drivers supporting VGA or EGC 16-colour screens need:
- <literallayout><filename>
- "xf4bpp.h"
- </filename></literallayout>
- </para>
-
- <para>
- Drivers using cfb need:
- <programlisting>
- #define PSZ 8
- #include "cfb.h"
- #undef PSZ
- </programlisting>
- </para>
-
- <para>
- Drivers supporting bpp 16, 24 or 32 with cfb need one or more of:
- <literallayout><filename>
- "cfb16.h"
- "cfb24.h"
- "cfb32.h"
- </filename></literallayout>
- </para>
-
- <para>
- The driver's own header file:
- <literallayout><filename>
- "zzz.h"
- </filename></literallayout>
- </para>
-
- <para>
- Drivers must NOT include the following:
-
- <literallayout><filename>
- "xf86Priv.h"
- "xf86Privstr.h"
- "xf86_libc.h"
- "xf86_OSlib.h"
- "Xos.h"</filename>
- any OS header
- </literallayout>
- </para>
-
- </sect2>
-
- <sect2>
- <title>Data structures and initialisation</title>
-
- <itemizedlist>
- <listitem>
- <para>The following macros should be defined:
- <programlisting>
-#define VERSION &lt;version-as-an-int&gt;
-#define ZZZ_NAME "ZZZ" /* the name used to prefix messages */
-#define ZZZ_DRIVER_NAME "zzz" /* the driver name as used in config file */
-#define ZZZ_MAJOR_VERSION &lt;int&gt;
-#define ZZZ_MINOR_VERSION &lt;int&gt;
-#define ZZZ_PATCHLEVEL &lt;int&gt;
- </programlisting>
- </para>
- <para>
- NOTE: <constant>ZZZ_DRIVER_NAME</constant> should match the name of the
- driver module without things like the "lib" prefix, the "_drv" suffix
- or filename extensions.
- </para>
- </listitem>
-
- <listitem>
- <para>
- A DriverRec must be defined, which includes the functions required
- at the pre-probe phase. The name of this DriverRec must be an
- upper-case version of ZZZ_DRIVER_NAME (for the purposes of static
- linking).
- <programlisting>
-DriverRec ZZZ = {
- VERSION,
- ZZZ_DRIVER_NAME,
- ZZZIdentify,
- ZZZProbe,
- ZZZAvailableOptions,
- NULL,
- 0
-};
- </programlisting>
- </para>
- </listitem>
-
- <listitem>
- <para>Define list of supported chips and their matching ID:
- <programlisting>
-static SymTabRec ZZZChipsets[] = {
- { PCI_CHIP_ZZZ1234, "zzz1234a" },
- { PCI_CHIP_ZZZ5678, "zzz5678a" },
- { -1, NULL }
-};
- </programlisting>
- </para>
- <para>
- The token field may be any integer value that the driver may use to
- uniquely identify the supported chipsets. For drivers that support
- only PCI devices using the PCI device IDs might be a natural choice,
- but this isn't mandatory. For drivers that support both PCI and other
- devices (like ISA), some other ID should probably used. When other
- IDs are used as the tokens it is recommended that the names be
- defined as an <type>enum</type> type.
- </para>
- </listitem>
-
- <listitem>
- <para>
- If the driver uses the <function>xf86MatchPciInstances()</function>
- helper (recommended for drivers that support PCI cards) a list that
- maps PCI IDs to chip IDs and fixed resources must be defined:
- <programlisting>
-static PciChipsets ZZZPciChipsets[] = {
- { PCI_CHIP_ZZZ1234, PCI_CHIP_ZZZ1234, RES_SHARED_VGA },
- { PCI_CHIP_ZZZ5678, PCI_CHIP_ZZZ5678, RES_SHARED_VGA },
- { -1, -1, RES_UNDEFINED }
-}
- </programlisting>
- </para>
- </listitem>
-
- <listitem>
- <para>
- Define the <structname>XF86ModuleVersionInfo</structname> struct for the
- driver. This is required for the dynamically loaded version:
- <programlisting>
-static XF86ModuleVersionInfo zzzVersRec =
-{
- "zzz",
- MODULEVENDORSTRING,
- MODINFOSTRING1,
- MODINFOSTRING2,
- XF86_VERSION_CURRENT,
- ZZZ_MAJOR_VERSION, ZZZ_MINOR_VERSION, ZZZ_PATCHLEVEL,
- ABI_CLASS_VIDEODRV,
- ABI_VIDEODRV_VERSION,
- MOD_CLASS_VIDEODRV,
- {0,0,0,0}
-};
- </programlisting>
- </para>
- </listitem>
-
- <listitem>
- <para>
- Define a data structure to hold the driver's screen-specific data.
- This must be used instead of global variables. This would be defined
- in the <filename>"zzz.h"</filename> file, something like:
- <programlisting>
-typedef struct {
- type1 field1;
- type2 field2;
- int fooHack;
- Bool pciRetry;
- Bool noAccel;
- Bool hwCursor;
- CloseScreenProcPtr CloseScreen;
- OptionInfoPtr Options;
- ...
-} ZZZRec, *ZZZPtr;
- </programlisting>
- </para>
- </listitem>
-
- <listitem>
- <para>
- Define the list of config file Options that the driver accepts. For
- consistency between drivers those in the list of <quote>standard</quote> options
- should be used where appropriate before inventing new options.
-
- <programlisting>
-typedef enum {
- OPTION_FOO_HACK,
- OPTION_PCI_RETRY,
- OPTION_HW_CURSOR,
- OPTION_NOACCEL
-} ZZZOpts;
-
-static const OptionInfoRec ZZZOptions[] = {
- { OPTION_FOO_HACK, "FooHack", OPTV_INTEGER, {0}, FALSE },
- { OPTION_PCI_RETRY, "PciRetry", OPTV_BOOLEAN, {0}, FALSE },
- { OPTION_HW_CURSOR, "HWcursor", OPTV_BOOLEAN, {0}, FALSE },
- { OPTION_NOACCEL, "NoAccel", OPTV_BOOLEAN, {0}, FALSE },
- { -1, NULL, OPTV_NONE, {0}, FALSE }
-};
- </programlisting>
- </para>
- </listitem>
- </itemizedlist>
- </sect2>
-
- <sect2>
- <title>Functions</title>
-
-
- <sect3>
- <title>SetupProc</title>
-
- <para>
- For dynamically loaded modules, a <varname>ModuleData</varname>
- variable is required. It is should be the name of the driver
- prepended to "ModuleData". A <function>Setup()</function> function is
- also required, which calls <function>xf86AddDriver()</function> to add
- the driver to the main list of drivers.
- </para>
-
- <programlisting>
-static MODULESETUPPROTO(zzzSetup);
-
-XF86ModuleData zzzModuleData = { &amp;zzzVersRec, zzzSetup, NULL };
-
-static pointer
-zzzSetup(pointer module, pointer opts, int *errmaj, int *errmin)
-{
- static Bool setupDone = FALSE;
-
- /* This module should be loaded only once, but check to be sure. */
-
- if (!setupDone) {
- /*
- * Modules that this driver always requires may be loaded
- * here by calling LoadSubModule().
- */
-
- setupDone = TRUE;
- xf86AddDriver(&amp;MGA, module, 0);
-
- /*
- * The return value must be non-NULL on success even though
- * there is no TearDownProc.
- */
- return (pointer)1;
- } else {
- if (errmaj) *errmaj = LDR_ONCEONLY;
- return NULL;
- }
-}
- </programlisting>
- </sect3>
-
- <sect3>
- <title>GetRec, FreeRec</title>
-
- <para>
- A function is usually required to allocate the driver's
- screen-specific data structure and hook it into the
- <structname>ScrnInfoRec</structname>'s <structfield>driverPrivate</structfield> field.
- The <structname>ScrnInfoRec</structname>'s <structfield>driverPrivate</structfield> is
- initialised to <constant>NULL</constant>, so it is easy to check if the
- initialisation has already been done. After allocating it, initialise
- the fields. By using <function>xnfcalloc()</function> to do the allocation
- it is zeroed, and if the allocation fails the server exits.
- </para>
-
- <para>
- NOTE:
- When allocating structures from inside the driver which are defined
- on the common level it is important to initialize the structure to
- zero.
- Only this guarantees that the server remains source compatible to
- future changes in common level structures.
- </para>
-
- <programlisting>
-static Bool
-ZZZGetRec(ScrnInfoPtr pScrn)
-{
- if (pScrn-&gt;driverPrivate != NULL)
- return TRUE;
- pScrn-&gt;driverPrivate = xnfcalloc(sizeof(ZZZRec), 1);
- /* Initialise as required */
- ...
- return TRUE;
-}
- </programlisting>
-
- <para>
- Define a macro in <filename>"zzz.h"</filename> which gets a pointer to
- the <structname>ZZZRec</structname> when given <parameter>pScrn</parameter>:
-
- <programlisting>
-#define ZZZPTR(p) ((ZZZPtr)((p)-&gt;driverPrivate))
- </programlisting>
- </para>
-
- <para>
- Define a function to free the above, setting it to <constant>NULL</constant>
- once it has been freed:
-
- <programlisting>
-static void
-ZZZFreeRec(ScrnInfoPtr pScrn)
-{
- if (pScrn-&gt;driverPrivate == NULL)
- return;
- xfree(pScrn-&gt;driverPrivate);
- pScrn-&gt;driverPrivate = NULL;
-}
- </programlisting>
- </para>
- </sect3>
-
- <sect3>
- <title>Identify</title>
-
- <para>
- Define the <function>Identify()</function> function. It is run before
- the Probe, and typically prints out an identifying message, which
- might include the chipsets it supports. This function is mandatory:
-
- <programlisting>
-static void
-ZZZIdentify(int flags)
-{
- xf86PrintChipsets(ZZZ_NAME, "driver for ZZZ Tech chipsets",
- ZZZChipsets);
-}
- </programlisting>
- </para>
- </sect3>
-
- <sect3>
- <title>Probe</title>
-
- <para>
- Define the <function>Probe()</function> function. The purpose of this
- is to find all instances of the hardware that the driver supports,
- and for the ones not already claimed by another driver, claim the
- slot, and allocate a <structname>ScrnInfoRec</structname>. This should be
- a minimal probe, and it should under no circumstances leave the
- state of the hardware changed. Because a device is found, don't
- assume that it will be used. Don't do any initialisations other
- than the required <structname>ScrnInfoRec</structname> initialisations.
- Don't allocate any new data structures.
- </para>
-
- <para>
- This function is mandatory.
- </para>
-
- <para>
- NOTE: The <function>xf86DrvMsg()</function> functions cannot be used from
- the Probe.
- </para>
-
- <programlisting>
-static Bool
-ZZZProbe(DriverPtr drv, int flags)
-{
- Bool foundScreen = FALSE;
- int numDevSections, numUsed;
- GDevPtr *devSections;
- int *usedChips;
- int i;
-
- /*
- * Find the config file Device sections that match this
- * driver, and return if there are none.
- */
- if ((numDevSections = xf86MatchDevice(ZZZ_DRIVER_NAME,
- &amp;devSections)) &lt;= 0) {
- return FALSE;
- }
-
- /*
- * Since this is a PCI card, "probing" just amounts to checking
- * the PCI data that the server has already collected. If there
- * is none, return.
- *
- * Although the config file is allowed to override things, it
- * is reasonable to not allow it to override the detection
- * of no PCI video cards.
- *
- * The provided xf86MatchPciInstances() helper takes care of
- * the details.
- */
- /* test if PCI bus present */
- if (xf86GetPciVideoInfo()) {
-
- numUsed = xf86MatchPciInstances(ZZZ_NAME, PCI_VENDOR_ZZZ,
- ZZZChipsets, ZZZPciChipsets, devSections,
- numDevSections, drv, &amp;usedChips);
-
- for (i = 0; i &lt; numUsed; i++) {
- ScrnInfoPtr pScrn = NULL;
- if ((pScrn = xf86ConfigPciEntity(pScrn, flags, usedChips[i],
- ZZZPciChipsets, NULL, NULL,
- NULL, NULL, NULL))) {
- /* Allocate a ScrnInfoRec */
- pScrn-&gt;driverVersion = VERSION;
- pScrn-&gt;driverName = ZZZ_DRIVER_NAME;
- pScrn-&gt;name = ZZZ_NAME;
- pScrn-&gt;Probe = ZZZProbe;
- pScrn-&gt;PreInit = ZZZPreInit;
- pScrn-&gt;ScreenInit = ZZZScreenInit;
- pScrn-&gt;SwitchMode = ZZZSwitchMode;
- pScrn-&gt;AdjustFrame = ZZZAdjustFrame;
- pScrn-&gt;EnterVT = ZZZEnterVT;
- pScrn-&gt;LeaveVT = ZZZLeaveVT;
- pScrn-&gt;FreeScreen = ZZZFreeScreen;
- pScrn-&gt;ValidMode = ZZZValidMode;
- foundScreen = TRUE;
- /* add screen to entity */
- }
- }
- xfree(usedChips);
- }
-
-#ifdef HAS_ISA_DEVS
- /*
- * If the driver supports ISA hardware, the following block
- * can be included too.
- */
- numUsed = xf86MatchIsaInstances(ZZZ_NAME, ZZZChipsets,
- ZZZIsaChipsets, drv, ZZZFindIsaDevice,
- devSections, numDevSections, &amp;usedChips);
- for (i = 0; i &lt; numUsed; i++) {
- ScrnInfoPtr pScrn = NULL;
- if ((pScrn = xf86ConfigIsaEntity(pScrn, flags, usedChips[i],
- ZZZIsaChipsets, NULL, NULL, NULL,
- NULL, NULL))) {
- pScrn-&gt;driverVersion = VERSION;
- pScrn-&gt;driverName = ZZZ_DRIVER_NAME;
- pScrn-&gt;name = ZZZ_NAME;
- pScrn-&gt;Probe = ZZZProbe;
- pScrn-&gt;PreInit = ZZZPreInit;
- pScrn-&gt;ScreenInit = ZZZScreenInit;
- pScrn-&gt;SwitchMode = ZZZSwitchMode;
- pScrn-&gt;AdjustFrame = ZZZAdjustFrame;
- pScrn-&gt;EnterVT = ZZZEnterVT;
- pScrn-&gt;LeaveVT = ZZZLeaveVT;
- pScrn-&gt;FreeScreen = ZZZFreeScreen;
- pScrn-&gt;ValidMode = ZZZValidMode;
- foundScreen = TRUE;
- }
- }
- xfree(usedChips);
-#endif /* HAS_ISA_DEVS */
-
- xfree(devSections);
- return foundScreen;
- </programlisting>
- </sect3>
-
- <sect3>
- <title>AvailableOptions</title>
-
- <para>
- Define the <function>AvailableOptions()</function> function. The purpose
- of this is to return the available driver options back to the
- -configure option, so that an xorg.conf file can be built and the
- user can see which options are available for them to use.
- </para>
- </sect3>
-
- <sect3>
- <title>PreInit</title>
-
- <para>
- Define the <function>PreInit()</function> function. The purpose of
- this is to find all the information required to determine if the
- configuration is usable, and to initialise those parts of the
- <structname>ScrnInfoRec</structname> that can be set once at the beginning
- of the first server generation. The information should be found in
- the least intrusive way possible.
- </para>
-
- <para>
- This function is mandatory.
- </para>
-
- <para>
- NOTES:
- <orderedlist>
- <listitem><para>
- The <function>PreInit()</function> function is only called once
- during the life of the X server (at the start of the first
- generation).
- </para></listitem>
-
- <listitem><para>
- Data allocated here must be of the type that persists for
- the life of the X server. This means that data that hooks into
- the <structname>ScrnInfoRec</structname>'s <structfield>privates</structfield>
- field should be allocated here, but data that hooks into the
- <structname>ScreenRec</structname>'s <structfield>devPrivates</structfield> field
- should not be allocated here. The <structfield>driverPrivate</structfield>
- field should also be allocated here.
- </para></listitem>
-
- <listitem><para>
- Although the <structname>ScrnInfoRec</structname> has been allocated
- before this function is called, the <structname>ScreenRec</structname>
- has not been allocated. That means that things requiring it
- cannot be used in this function.
- </para></listitem>
-
- <listitem><para>
- Very little of the <structname>ScrnInfoRec</structname> has been
- initialised when this function is called. It is important to
- get the order of doing things right in this function.
- </para></listitem>
-
- </orderedlist>
- </para>
-
- <programlisting>
-static Bool
-ZZZPreInit(ScrnInfoPtr pScrn, int flags)
-{
- /* Fill in the monitor field */
- pScrn-&gt;monitor = pScrn-&gt;confScreen-&gt;monitor;
-
- /*
- * If using the vgahw module, it will typically be loaded
- * here by calling xf86LoadSubModule(pScrn, "vgahw");
- */
-
- /*
- * Set the depth/bpp. Use the globally preferred depth/bpp. If the
- * driver has special default depth/bpp requirements, the defaults should
- * be specified here explicitly.
- * We support both 24bpp and 32bpp framebuffer layouts.
- * This sets pScrn-&gt;display also.
- */
- if (!xf86SetDepthBpp(pScrn, 0, 0, 0,
- Support24bppFb | Support32bppFb)) {
- return FALSE;
- } else {
- if (depth/bpp isn't one we support) {
- print error message;
- return FALSE;
- }
- }
- /* Print out the depth/bpp that was set */
- xf86PrintDepthBpp(pScrn);
-
- /* Set bits per RGB for 8bpp */
- if (pScrn-&gt;depth &lt;= 8) {
- /* Take into account a dac_6_bit option here */
- pScrn-&gt;rgbBits = 6 or 8;
- }
-
- /*
- * xf86SetWeight() and xf86SetDefaultVisual() must be called
- * after pScrn-&gt;display is initialised.
- */
-
- /* Set weight/mask/offset for depth &gt; 8 */
- if (pScrn-&gt;depth &gt; 8) {
- if (!xf86SetWeight(pScrn, defaultWeight, defaultMask)) {
- return FALSE;
- } else {
- if (weight isn't one we support) {
- print error message;
- return FALSE;
- }
- }
- }
-
- /* Set the default visual. */
- if (!xf86SetDefaultVisual(pScrn, -1)) {
- return FALSE;
- } else {
- if (visual isn't one we support) {
- print error message;
- return FALSE;
- }
- }
-
- /* If the driver supports gamma correction, set the gamma. */
- if (!xf86SetGamma(pScrn, default_gamma)) {
- return FALSE;
- }
-
- /* This driver uses a programmable clock */
- pScrn-&gt;progClock = TRUE;
-
- /* Allocate the ZZZRec driverPrivate */
- if (!ZZZGetRec(pScrn)) {
- return FALSE;
- }
-
- pZzz = ZZZPTR(pScrn);
-
- /* Collect all of the option flags (fill in pScrn-&gt;options) */
- xf86CollectOptions(pScrn, NULL);
-
- /*
- * Process the options based on the information in ZZZOptions.
- * The results are written to pZzz-&gt;Options. If all of the options
- * processing is done within this function a local variable "options"
- * can be used instead of pZzz-&gt;Options.
- */
- if (!(pZzz-&gt;Options = xalloc(sizeof(ZZZOptions))))
- return FALSE;
- (void)memcpy(pZzz-&gt;Options, ZZZOptions, sizeof(ZZZOptions));
- xf86ProcessOptions(pScrn-&gt;scrnIndex, pScrn-&gt;options, pZzz-&gt;Options);
-
- /*
- * Set various fields of ScrnInfoRec and/or ZZZRec based on
- * the options found.
- */
- from = X_DEFAULT;
- pZzz-&gt;hwCursor = FALSE;
- if (xf86IsOptionSet(pZzz-&gt;Options, OPTION_HW_CURSOR)) {
- from = X_CONFIG;
- pZzz-&gt;hwCursor = TRUE;
- }
- xf86DrvMsg(pScrn-&gt;scrnIndex, from, "Using %s cursor\n",
- pZzz-&gt;hwCursor ? "HW" : "SW");
- if (xf86IsOptionSet(pZzz-&gt;Options, OPTION_NOACCEL)) {
- pZzz-&gt;noAccel = TRUE;
- xf86DrvMsg(pScrn-&gt;scrnIndex, X_CONFIG,
- "Acceleration disabled\n");
- } else {
- pZzz-&gt;noAccel = FALSE;
- }
- if (xf86IsOptionSet(pZzz-&gt;Options, OPTION_PCI_RETRY)) {
- pZzz-&gt;UsePCIRetry = TRUE;
- xf86DrvMsg(pScrn-&gt;scrnIndex, X_CONFIG, "PCI retry enabled\n");
- }
- pZzz-&gt;fooHack = 0;
- if (xf86GetOptValInteger(pZzz-&gt;Options, OPTION_FOO_HACK,
- &amp;pZzz-&gt;fooHack)) {
- xf86DrvMsg(pScrn-&gt;scrnIndex, X_CONFIG, "Foo Hack set to %d\n",
- pZzz-&gt;fooHack);
- }
-
- /*
- * Find the PCI slot(s) that this screen claimed in the probe.
- * In this case, exactly one is expected, so complain otherwise.
- * Note in this case we're not interested in the card types so
- * that parameter is set to NULL.
- */
- if ((i = xf86GetPciInfoForScreen(pScrn-&gt;scrnIndex, &amp;pciList, NULL))
- != 1) {
- print error message;
- ZZZFreeRec(pScrn);
- if (i &gt; 0)
- xfree(pciList);
- return FALSE;
- }
- /* Note that pciList should be freed below when no longer needed */
-
- /*
- * Determine the chipset, allowing config file chipset and
- * chipid values to override the probed information. The config
- * chipset value has precedence over its chipid value if both
- * are present.
- *
- * It isn't necessary to fill in pScrn-&gt;chipset if the driver
- * keeps track of the chipset in its ZZZRec.
- */
-
- ...
-
- /*
- * Determine video memory, fb base address, I/O addresses, etc,
- * allowing the config file to override probed values.
- *
- * Set the appropriate pScrn fields (videoRam is probably the
- * most important one that other code might require), and
- * print out the settings.
- */
-
- ...
-
- /* Initialise a clockRanges list. */
-
- ...
-
- /* Set any other chipset specific things in the ZZZRec */
-
- ...
-
- /* Select valid modes from those available */
-
- i = xf86ValidateModes(pScrn, pScrn-&gt;monitor-&gt;Modes,
- pScrn-&gt;display-&gt;modes, clockRanges,
- NULL, minPitch, maxPitch, rounding,
- minHeight, maxHeight,
- pScrn-&gt;display-&gt;virtualX,
- pScrn-&gt;display-&gt;virtualY,
- pScrn-&gt;videoRam * 1024,
- LOOKUP_BEST_REFRESH);
- if (i == -1) {
- ZZZFreeRec(pScrn);
- return FALSE;
- }
-
- /* Prune the modes marked as invalid */
-
- xf86PruneDriverModes(pScrn);
-
- /* If no valid modes, return */
-
- if (i == 0 || pScrn-&gt;modes == NULL) {
- print error message;
- ZZZFreeRec(pScrn);
- return FALSE;
- }
-
- /*
- * Initialise the CRTC fields for the modes. This driver expects
- * vertical values to be halved for interlaced modes.
- */
- xf86SetCrtcForModes(pScrn, INTERLACE_HALVE_V);
-
- /* Set the current mode to the first in the list. */
- pScrn-&gt;currentMode = pScrn-&gt;modes;
-
- /* Print the list of modes being used. */
- xf86PrintModes(pScrn);
-
- /* Set the DPI */
- xf86SetDpi(pScrn, 0, 0);
-
- /* Load bpp-specific modules */
- switch (pScrn-&gt;bitsPerPixel) {
- case 1:
- mod = "xf1bpp";
- break;
- case 4:
- mod = "xf4bpp";
- break;
- case 8:
- mod = "cfb";
- break;
- case 16:
- mod = "cfb16";
- break;
- case 24:
- mod = "cfb24";
- break;
- case 32:
- mod = "cfb32";
- break;
- }
- if (mod &amp;&amp; !xf86LoadSubModule(pScrn, mod))
- ZZZFreeRec(pScrn);
- return FALSE;
-
- /* Load XAA if needed */
- if (!pZzz-&gt;noAccel || pZzz-&gt;hwCursor)
- if (!xf86LoadSubModule(pScrn, "xaa")) {
- ZZZFreeRec(pScrn);
- return FALSE;
- }
-
- /* Done */
- return TRUE;
-}
- </programlisting>
- </sect3>
-
- <sect3>
- <title>MapMem, UnmapMem</title>
-
- <para>
- Define functions to map and unmap the video memory and any other
- memory apertures required. These functions are not mandatory, but
- it is often useful to have such functions.
- </para>
-
- <programlisting>
-static Bool
-ZZZMapMem(ScrnInfoPtr pScrn)
-{
- /* Call xf86MapPciMem() to map each PCI memory area */
- ...
- return TRUE or FALSE;
-}
-
-static Bool
-ZZZUnmapMem(ScrnInfoPtr pScrn)
-{
- /* Call xf86UnMapVidMem() to unmap each memory area */
- ...
- return TRUE or FALSE;
-}
- </programlisting>
- </sect3>
-
- <sect3>
- <title>Save, Restore</title>
-
- <para>
- Define functions to save and restore the original video state. These
- functions are not mandatory, but are often useful.
- </para>
-
- <programlisting>
-static void
-ZZZSave(ScrnInfoPtr pScrn)
-{
- /*
- * Save state into per-screen data structures.
- * If using the vgahw module, vgaHWSave will typically be
- * called here.
- */
- ...
-}
-
-static void
-ZZZRestore(ScrnInfoPtr pScrn)
-{
- /*
- * Restore state from per-screen data structures.
- * If using the vgahw module, vgaHWRestore will typically be
- * called here.
- */
- ...
-}
- </programlisting>
- </sect3>
-
- <sect3>
- <title>ModeInit</title>
-
- <para>
- Define a function to initialise a new video mode. This function isn't
- mandatory, but is often useful.
- </para>
-
- <programlisting>
-static Bool
-ZZZModeInit(ScrnInfoPtr pScrn, DisplayModePtr mode)
-{
- /*
- * Program a video mode. If using the vgahw module,
- * vgaHWInit and vgaRestore will typically be called here.
- * Once up to the point where there can't be a failure
- * set pScrn-&gt;vtSema to TRUE.
- */
- ...
-}
- </programlisting>
- </sect3>
-
- <sect3>
- <title>ScreenInit</title>
-
- <para>
- Define the <function>ScreenInit()</function> function. This is called
- at the start of each server generation, and should fill in as much
- of the <structname>ScreenRec</structname> as possible as well as any other
- data that is initialised once per generation. It should initialise
- the framebuffer layers it is using, and initialise the initial video
- mode.
- </para>
-
- <para>
- This function is mandatory.
- </para>
-
- <para>
- NOTE: The <structname>ScreenRec</structname> (<parameter>pScreen</parameter>) is
- passed to this driver, but it and the
- <varname>ScrnInfoRecs</varname> are not yet hooked into each
- other. This means that in this function, and functions it
- calls, one cannot be found from the other.
- </para>
-
- <programlisting>
-static Bool
-ZZZScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv)
-{
- /* Get the ScrnInfoRec */
- pScrn = xf86Screens[pScreen-&gt;myNum];
-
- /*
- * If using the vgahw module, its data structures and related
- * things are typically initialised/mapped here.
- */
-
- /* Save the current video state */
- ZZZSave(pScrn);
-
- /* Initialise the first mode */
- ZZZModeInit(pScrn, pScrn-&gt;currentMode);
-
- /* Set the viewport if supported */
-
- ZZZAdjustFrame(scrnIndex, pScrn-&gt;frameX0, pScrn-&gt;frameY0, 0);
-
- /*
- * Setup the screen's visuals, and initialise the framebuffer
- * code.
- */
-
- /* Reset the visual list */
- miClearVisualTypes();
-
- /*
- * Setup the visuals supported. This driver only supports
- * TrueColor for bpp &gt; 8, so the default set of visuals isn't
- * acceptable. To deal with this, call miSetVisualTypes with
- * the appropriate visual mask.
- */
-
- if (pScrn-&gt;bitsPerPixel &gt; 8) {
- if (!miSetVisualTypes(pScrn-&gt;depth, TrueColorMask,
- pScrn-&gt;rgbBits, pScrn-&gt;defaultVisual))
- return FALSE;
- } else {
- if (!miSetVisualTypes(pScrn-&gt;depth,
- miGetDefaultVisualMask(pScrn-&gt;depth),
- pScrn-&gt;rgbBits, pScrn-&gt;defaultVisual))
- return FALSE;
- }
-
- /*
- * Initialise the framebuffer.
- */
-
- switch (pScrn-&gt;bitsPerPixel) {
- case 1:
- ret = xf1bppScreenInit(pScreen, FbBase,
- pScrn-&gt;virtualX, pScrn-&gt;virtualY,
- pScrn-&gt;xDpi, pScrn-&gt;yDpi,
- pScrn-&gt;displayWidth);
- break;
- case 4:
- ret = xf4bppScreenInit(pScreen, FbBase,
- pScrn-&gt;virtualX, pScrn-&gt;virtualY,
- pScrn-&gt;xDpi, pScrn-&gt;yDpi,
- pScrn-&gt;displayWidth);
- break;
- case 8:
- ret = cfbScreenInit(pScreen, FbBase,
- pScrn-&gt;virtualX, pScrn-&gt;virtualY,
- pScrn-&gt;xDpi, pScrn-&gt;yDpi,
- pScrn-&gt;displayWidth);
- break;
- case 16:
- ret = cfb16ScreenInit(pScreen, FbBase,
- pScrn-&gt;virtualX, pScrn-&gt;virtualY,
- pScrn-&gt;xDpi, pScrn-&gt;yDpi,
- pScrn-&gt;displayWidth);
- break;
- case 24:
- ret = cfb24ScreenInit(pScreen, FbBase,
- pScrn-&gt;virtualX, pScrn-&gt;virtualY,
- pScrn-&gt;xDpi, pScrn-&gt;yDpi,
- pScrn-&gt;displayWidth);
- break;
- case 32:
- ret = cfb32ScreenInit(pScreen, FbBase,
- pScrn-&gt;virtualX, pScrn-&gt;virtualY,
- pScrn-&gt;xDpi, pScrn-&gt;yDpi,
- pScrn-&gt;displayWidth);
- break;
- default:
- print a message about an internal error;
- ret = FALSE;
- break;
- }
-
- if (!ret)
- return FALSE;
-
- /* Override the default mask/offset settings */
- if (pScrn-&gt;bitsPerPixel &gt; 8) {
- for (i = 0, visual = pScreen-&gt;visuals;
- i &lt; pScreen-&gt;numVisuals; i++, visual++) {
- if ((visual-&gt;class | DynamicClass) == DirectColor) {
- visual-&gt;offsetRed = pScrn-&gt;offset.red;
- visual-&gt;offsetGreen = pScrn-&gt;offset.green;
- visual-&gt;offsetBlue = pScrn-&gt;offset.blue;
- visual-&gt;redMask = pScrn-&gt;mask.red;
- visual-&gt;greenMask = pScrn-&gt;mask.green;
- visual-&gt;blueMask = pScrn-&gt;mask.blue;
- }
- }
- }
-
- /*
- * If banking is needed, initialise an miBankInfoRec (defined in
- * "mibank.h"), and call miInitializeBanking().
- */
- if (!miInitializeBanking(pScreen, pScrn-&gt;virtualX, pScrn-&gt;virtualY,
- pScrn-&gt;displayWidth, pBankInfo))
- return FALSE;
-
- /*
- * If backing store is to be supported (as is usually the case),
- * initialise it.
- */
- miInitializeBackingStore(pScreen);
-
- /*
- * Set initial black &amp; white colourmap indices.
- */
- xf86SetBlackWhitePixels(pScreen);
-
- /*
- * Install colourmap functions. If using the vgahw module,
- * vgaHandleColormaps would usually be called here.
- */
-
- ...
-
- /*
- * Initialise cursor functions. This example is for the mi
- * software cursor.
- */
- miDCInitialize(pScreen, xf86GetPointerScreenFuncs());
-
- /* Initialise the default colourmap */
- switch (pScrn-&gt;depth) {
- case 1:
- if (!xf1bppCreateDefColormap(pScreen))
- return FALSE;
- break;
- case 4:
- if (!xf4bppCreateDefColormap(pScreen))
- return FALSE;
- break;
- default:
- if (!cfbCreateDefColormap(pScreen))
- return FALSE;
- break;
- }
-
- /*
- * Wrap the CloseScreen vector and set SaveScreen.
- */
- ZZZPTR(pScrn)-&gt;CloseScreen = pScreen-&gt;CloseScreen;
- pScreen-&gt;CloseScreen = ZZZCloseScreen;
- pScreen-&gt;SaveScreen = ZZZSaveScreen;
-
- /* Report any unused options (only for the first generation) */
- if (serverGeneration == 1) {
- xf86ShowUnusedOptions(pScrn-&gt;scrnIndex, pScrn-&gt;options);
- }
-
- /* Done */
- return TRUE;
-}
- </programlisting>
- </sect3>
-
- <sect3>
- <title>SwitchMode</title>
-
- <para>
- Define the <function>SwitchMode()</function> function if mode switching
- is supported by the driver.
- </para>
-
- <programlisting>
-static Bool
-ZZZSwitchMode(int scrnIndex, DisplayModePtr mode, int flags)
-{
- return ZZZModeInit(xf86Screens[scrnIndex], mode);
-}
- </programlisting>
- </sect3>
-
- <sect3>
- <title>AdjustFrame</title>
-
- <para>
- Define the <function>AdjustFrame()</function> function if the driver
- supports this.
- </para>
-
- <programlisting>
-static void
-ZZZAdjustFrame(int scrnIndex, int x, int y, int flags)
-{
- /* Adjust the viewport */
-}
- </programlisting>
- </sect3>
-
- <sect3>
- <title>EnterVT, LeaveVT</title>
-
- <para>
- Define the <function>EnterVT()</function> and <function>LeaveVT()</function>
- functions.
- </para>
-
- <para>
- These functions are mandatory.
- </para>
-
- <programlisting>
-static Bool
-ZZZEnterVT(int scrnIndex, int flags)
-{
- ScrnInfoPtr pScrn = xf86Screens[scrnIndex];
- return ZZZModeInit(pScrn, pScrn-&gt;currentMode);
-}
-
-static void
-ZZZLeaveVT(int scrnIndex, int flags)
-{
- ScrnInfoPtr pScrn = xf86Screens[scrnIndex];
- ZZZRestore(pScrn);
-}
- </programlisting>
- </sect3>
-
- <sect3>
- <title>CloseScreen</title>
-
- <para>
- Define the <function>CloseScreen()</function> function:
- </para>
-
- <para>
- This function is mandatory. Note that it unwraps the previously
- wrapped <structfield>pScreen-&gt;CloseScreen</structfield>, and finishes by
- calling it.
- </para>
-
- <programlisting>
-static Bool
-ZZZCloseScreen(int scrnIndex, ScreenPtr pScreen)
-{
- ScrnInfoPtr pScrn = xf86Screens[scrnIndex];
- if (pScrn-&gt;vtSema) {
- ZZZRestore(pScrn);
- ZZZUnmapMem(pScrn);
- }
- pScrn-&gt;vtSema = FALSE;
- pScreen-&gt;CloseScreen = ZZZPTR(pScrn)-&gt;CloseScreen;
- return (*pScreen-&gt;CloseScreen)(scrnIndex, pScreen);
-}
- </programlisting>
- </sect3>
-
- <sect3>
- <title>SaveScreen</title>
-
- <para>
- Define the <function>SaveScreen()</function> function (the screen
- blanking function). When using the vgahw module, this will typically
- be:
-
- <programlisting>
-static Bool
-ZZZSaveScreen(ScreenPtr pScreen, int mode)
-{
- return vgaHWSaveScreen(pScreen, mode);
-}
- </programlisting>
- </para>
-
- <para>
- This function is mandatory. Before modifying any hardware register
- directly this function needs to make sure that the Xserver is active
- by checking if <parameter>pScrn</parameter> is non-NULL and for
- <literal remap="tt">pScrn-&gt;vtSema == TRUE</literal>.
- </para>
- </sect3>
-
- <sect3>
- <title>FreeScreen</title>
-
- <para>
- Define the <function>FreeScreen()</function> function. This function
- is optional. It should be defined if the <structname>ScrnInfoRec</structname>
- <structfield>driverPrivate</structfield> field is used so that it can be freed
- when a screen is deleted by the common layer for reasons possibly
- beyond the driver's control. This function is not used in during
- normal (error free) operation. The per-generation data is freed by
- the <function>CloseScreen()</function> function.
- </para>
-
- <programlisting>
-static void
-ZZZFreeScreen(int scrnIndex, int flags)
-{
- /*
- * If the vgahw module is used vgaHWFreeHWRec() would be called
- * here.
- */
- ZZZFreeRec(xf86Screens[scrnIndex]);
-}
-
- </programlisting>
-
- </sect3>
-
- </sect2>
-
- </sect1>
-
-</article>
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<!DOCTYPE article PUBLIC "-//OASIS//DTD DocBook XML V4.3//EN"
+ "http://www.oasis-open.org/docbook/xml/4.3/docbookx.dtd" [
+ <!ENTITY % defs SYSTEM "/xserver/doc/xml/xserver.ent"> %defs;
+ <!-- config file keyword markup -->
+ <!-- specific config file keywords -->
+ <!ENTITY k.device "<emphasis>Device</emphasis>">
+ <!ENTITY k.monitor "<emphasis>Monitor</emphasis>">
+ <!ENTITY k.display "<emphasis>Display</emphasis>">
+ <!ENTITY k.inputdevice "<emphasis>InputDevice</emphasis>">
+ <!ENTITY k.screen "<emphasis>Screen</emphasis>">
+ <!ENTITY k.serverlayout "<emphasis>ServerLayout</emphasis>">
+ <!ENTITY k.driver "<emphasis>Driver</emphasis>">
+ <!ENTITY k.module "<emphasis>Module</emphasis>">
+ <!ENTITY k.identifier "<emphasis>Identifier</emphasis>">
+ <!ENTITY k.serverflags "<emphasis>ServerFlags</emphasis>">
+] >
+
+<article id="ddxDesign">
+ <articleinfo>
+
+ <title>XFree86 DDX Design (Xorg server version &xserver.version;)</title>
+
+ <authorgroup>
+ <corpauthor><ulink url="http://www.xfree86.org/">
+ The XFree86 Project, Inc.</ulink></corpauthor>
+ <corpauthor><ulink url="http://www.x.org/">
+ The X.Org Foundation, Inc.</ulink></corpauthor>
+
+ <othercredit>
+ <firstname>Jim</firstname><surname>Gettys</surname>
+ <contrib>Updates for X11R6.7</contrib>
+ </othercredit>
+ </authorgroup>
+
+ <pubdate>&xserver.reldate;</pubdate>
+ <releaseinfo>Xorg server version &xserver.version;</releaseinfo>
+
+ </articleinfo>
+
+ <note><para>
+This document describes software undergoing continual evolution, and
+the interfaces described here are subject to change without notice.
+This document is intended to cover the interfaces as found in the
+xorg-server-&xserver.version; release, but is probably not completely
+in sync with the code base.
+ </para></note>
+
+
+ <sect1>
+ <title>Preface</title>
+
+ <para>
+This document was originally the design spec for the DDX layer of the
+XFree86 4.0 X server. The X.Org Foundation adopted the XFree86 4.4rc2
+version of that server as the basis of the Xorg server project, and has
+evolved the XFree86 DDX layer greatly since forking. This document thus
+covers only the current implementation of the XFree86 DDX as found in the
+Xorg server &xserver.version; release, and no longer matches the XFree86
+server itself.
+ </para>
+
+ <para>
+The XFree86 Project's broad design principles for XFree86 4.0 were:
+ <itemizedlist>
+ <listitem><para>keep it reasonable
+ <itemizedlist>
+ <listitem><para>We cannot rewrite the complete server
+ </para></listitem>
+ <listitem><para>We don't want to re-invent the wheel
+ </para></listitem>
+ </itemizedlist></para></listitem>
+ <listitem><para>keep it modular
+ <itemizedlist>
+ <listitem><para>As many things as possible should go into modules
+ </para></listitem>
+ <listitem><para>The basic loader binary should be minimal
+ </para></listitem>
+ <listitem><para>A clean design with well defined layering is
+ important</para></listitem>
+ <listitem><para>DDX specific global variables are a nono
+ </para></listitem>
+ <listitem><para>The structure should be flexible enough to allow
+ future extensions</para></listitem>
+ <listitem><para>The structure should minimize duplication of
+ common code</para></listitem>
+ </itemizedlist></para></listitem>
+ <listitem><para>keep important features in mind
+ <itemizedlist>
+ <listitem><para>multiple screens, including multiple instances
+ of drivers</para></listitem>
+ <listitem><para>mixing different color depths and visuals on
+ different and ideally even on the same screen
+ </para></listitem>
+ <listitem><para>better control of the PCI device used
+ </para></listitem>
+ <listitem><para>better config file parser</para></listitem>
+ <listitem><para>get rid of all VGA compatibility assumptions
+ </para></listitem>
+ </itemizedlist></para></listitem>
+ </itemizedlist>
+ </para>
+
+ <para>
+While the XFree86 project had a goal of avoiding changes to the DIX
+layer unless they found major deficiencies there, to avoid divergence from
+the X.Org sample implementation they were integrating changes from, the
+X.Org developers now maintain both sides, and make changes where they are
+most appropriate. This document concentrates on the XFree86 DDX layer used
+in the Xorg server itself (the code found in <filename>hw/xfree86</filename>
+in the source tree), and developers will also want to refer to the
+<filename>Xserver-spec</filename> documentation that covers the DIX layer
+routines common to all the X servers in the sample implementation.
+ </para>
+ </sect1>
+
+ <sect1>
+ <title>The xorg.conf File</title>
+
+ <para>
+The xorg.conf file format is based on the XF86Config format from XFree86 4.4,
+which is in turn similar to the old XFree86 3.x XF86Config format, with the
+following changes:
+ </para>
+
+ <sect2>
+ <title>&k.device; section</title>
+
+ <para>
+ The &k.device; sections are similar to what they used to be, and
+ describe hardware-specific information for a single video card.
+ &k.device;
+ Some new keywords are added:
+
+
+ <variablelist>
+ <varlistentry><term>Driver "drivername"</term>
+ <listitem><para>
+ Specifies the name of the driver to be used for the card. This
+ is mandatory.
+ </para></listitem></varlistentry>
+ <varlistentry><term>BusID "busslot"</term>
+ <listitem><para>
+ Specifies uniquely the location of the card on the bus. The
+ purpose is to identify particular cards in a multi-headed
+ configuration. The format of the argument is intentionally
+ vague, and may be architecture dependent. For a PCI bus, it
+ is something like "bus:slot:func".
+ </para></listitem></varlistentry>
+ </variablelist>
+ </para>
+
+ <para>
+ A &k.device; section is considered <quote>active</quote> if there is a reference
+ to it in an active &k.screen; section.
+ </para>
+ </sect2>
+
+ <sect2>
+ <title>&k.screen; section</title>
+
+ <para>
+ The &k.screen; sections are similar to what they used to be. They
+ no longer have a &k.driver; keyword, but an &k.identifier; keyword
+ is added. (The &k.driver; keyword may be accepted in place of the
+ &k.identifier; keyword for compatibility purposes.) The identifier
+ can be used to identify which screen is to be active when multiple
+ &k.screen; sections are present. It is possible to specify the active
+ screen from the command line. A default is chosen in the absence
+ of one being specified. A &k.screen; section is considered <quote>active</quote>
+ if there is a reference to it either from the command line, or from
+ an active &k.serverlayout; section.
+ </para>
+ </sect2>
+
+ <sect2>
+ <title>&k.inputdevice; section</title>
+
+ <para>
+ The &k.inputdevice; section is a new section that describes
+ configuration information for input devices. It replaces the old
+ <emphasis>Keyboard</emphasis>, <emphasis>Pointer</emphasis> and <emphasis>XInput</emphasis>
+ sections. Like the &k.device; section, it has two mandatory keywords:
+ &k.identifier; and &k.driver;. For compatibility purposes the old
+ <emphasis>Keyboard</emphasis> and <emphasis>Pointer</emphasis> sections are
+ converted by the parser into &k.inputdevice; sections as follows:
+
+ <variablelist>
+ <varlistentry><term><emphasis>Keyboard</emphasis></term>
+ <listitem><literallayout>
+ &k.identifier; "Implicit Core Keyboard"
+ &k.driver; "keyboard"
+ </literallayout></listitem></varlistentry>
+ <varlistentry><term><emphasis>Pointer</emphasis></term>
+ <listitem><literallayout>
+ &k.identifier; "Implicit Core Pointer"
+ &k.driver; "mouse"
+ </literallayout></listitem></varlistentry>
+ </variablelist>
+ </para>
+
+ <para>
+ An &k.inputdevice; section is considered active if there is a
+ reference to it in an active &k.serverlayout; section. An
+ &k.inputdevice; section may also be referenced implicitly if there
+ is no &k.serverlayout; section, if the <option>-screen</option> command
+ line options is used, or if the &k.serverlayout; section doesn't
+ reference any &k.inputdevice; sections. In this case, the first
+ sections with drivers "keyboard" and "mouse" are used as the core
+ keyboard and pointer respectively.
+ </para>
+ </sect2>
+
+ <sect2>
+ <title>&k.serverlayout; section</title>
+
+ <para>
+ The &k.serverlayout; section is a new section that is used to identify
+ which &k.screen; sections are to be used in a multi-headed configuration,
+ and the relative layout of those screens. It also identifies which
+ &k.inputdevice; sections are to be used. Each &k.serverlayout; section
+ has an identifier, a list of &k.screen; section identifiers, and a list of
+ &k.inputdevice; section identifiers. &k.serverflags; options may also be
+ included in a &k.serverlayout; section, making it possible to override
+ the global values in the &k.serverflags; section.
+ </para>
+
+ <para>
+ A &k.serverlayout; section can be made active by being referenced on
+ the command line. In the absence of this, a default will be chosen
+ (the first one found). The screen names may optionally be followed
+ by a number specifying the preferred screen number, and optionally
+ by information specifying the physical positioning of the screen,
+ either in absolute terms or relative to another screen (or screens).
+ When no screen number is specified, they are numbered according to
+ the order in which they are listed. The old (now obsolete) method
+ of providing the positioning information is to give the names of
+ the four adjacent screens. The order of these is top, bottom, left,
+ right. Here is an example of a &k.serverlayout; section for two
+ screens using the old method, with the second located to the right
+ of the first:
+
+ <programlisting>
+ Section "ServerLayout"
+ Identifier "Main Layout"
+ Screen 0 "Screen 1" "" "" "" "Screen 2"
+ Screen 1 "Screen 2"
+ Screen "Screen 3"
+ EndSection
+ </programlisting>
+ </para>
+
+ <para>
+ The preferred way of specifying the layout is to explicitly specify
+ the screen's location in absolute terms or relative to another
+ screen.
+ </para>
+
+ <para>
+ In the absolute case, the upper left corner's coordinates are given
+ after the <emphasis>Absolute</emphasis> keyword. If the coordinates are
+ omitted, a value of <code>(0,0)</code> is assumed. An example
+ of absolute positioning follows:
+
+ <programlisting>
+ Section "ServerLayout"
+ Identifier "Main Layout"
+ Screen 0 "Screen 1" Absolute 0 0
+ Screen 1 "Screen 2" Absolute 1024 0
+ Screen "Screen 3" Absolute 2048 0
+ EndSection
+ </programlisting>
+ </para>
+
+ <para>
+ In the relative case, the position is specified by either using one of
+ the following keywords followed by the name of the reference screen:
+
+ <simplelist type='vert' columns='1'>
+ <member><emphasis>RightOf</emphasis></member>
+ <member><emphasis>LeftOf</emphasis></member>
+ <member><emphasis>Above</emphasis></member>
+ <member><emphasis>Below</emphasis></member>
+ <member><emphasis>Relative</emphasis></member>
+ </simplelist>
+ </para>
+
+ <para>
+ When the <emphasis>Relative</emphasis> keyword is used, the reference screen
+ name is followed by the coordinates of the new screen's origin
+ relative to reference screen. The following example shows how to use
+ some of the relative positioning options.
+
+ <programlisting>
+ Section "ServerLayout"
+ Identifier "Main Layout"
+ Screen 0 "Screen 1"
+ Screen 1 "Screen 2" RightOf "Screen 1"
+ Screen "Screen 3" Relative "Screen 1" 2048 0
+ EndSection
+ </programlisting>
+ </para>
+ </sect2>
+
+ <sect2>
+ <title>Options</title>
+
+ <para>
+ Options are used more extensively. They may appear in most sections
+ now. Options related to drivers can be present in the &k.screen;,
+ &k.device; and &k.monitor; sections and the &k.display; subsections.
+ The order of precedence is &k.display;, &k.screen;, &k.monitor;,
+ &k.device;. Options have been extended to allow an optional value
+ to be specified in addition to the option name. For more details
+ about options, see the <link linkend="options">Options</link> section
+ for details.
+ </para>
+ </sect2>
+ </sect1>
+
+ <sect1>
+ <title>Driver Interface</title>
+
+ <para>
+The driver interface consists of a minimal set of entry points that are
+required based on the external events that the driver must react to.
+No non-essential structure is imposed on the way they are used beyond
+that. This is a significant difference compared with the old design.
+ </para>
+
+ <para>
+The entry points for drawing operations are already taken care of by
+the framebuffer code (including, XAA). Extensions and enhancements to
+framebuffer code are outside the scope of this document.
+ </para>
+
+ <para>
+This approach to the driver interface provides good flexibility, but does
+increase the complexity of drivers. To help address this, the XFree86
+common layer provides a set of <quote>helper</quote> functions to take care of things
+that most drivers need. These helpers help minimise the amount of code
+duplication between drivers. The use of helper functions by drivers is
+however optional, though encouraged. The basic philosophy behind the
+helper functions is that they should be useful to many drivers, that
+they should balance this against the complexity of their interface. It
+is inevitable that some drivers may find some helpers unsuitable and
+need to provide their own code.
+ </para>
+
+ <para>
+Events that a driver needs to react to are:
+
+ <variablelist>
+ <varlistentry><term>ScreenInit</term>
+
+ <listitem><para>
+ An initialisation function is called from the DIX layer for each
+ screen at the start of each server generation.
+ </para></listitem></varlistentry>
+
+ <varlistentry><term>Enter VT</term>
+
+ <listitem><para>
+ The server takes control of the console.
+ </para></listitem></varlistentry>
+
+ <varlistentry><term>Leave VT</term>
+
+ <listitem><para>
+ The server releases control of the console.
+ </para></listitem></varlistentry>
+
+ <varlistentry><term>Mode Switch</term>
+
+ <listitem><para>
+ Change video mode.
+ </para></listitem></varlistentry>
+
+ <varlistentry><term>ViewPort change</term>
+
+ <listitem><para>
+ Change the origin of the physical view port.
+ </para></listitem></varlistentry>
+
+ <varlistentry><term>ScreenSaver state change</term>
+
+ <listitem><para>
+ Screen saver activation/deactivation.
+ </para></listitem></varlistentry>
+
+ <varlistentry><term>CloseScreen</term>
+
+ <listitem><para>
+ A close screen function is called from the DIX layer for each screen
+ at the end of each server generation.
+ </para></listitem></varlistentry>
+ </variablelist>
+ </para>
+
+
+ <para>
+In addition to these events, the following functions are required by
+the XFree86 common layer:
+
+ <variablelist>
+ <varlistentry><term>Identify</term>
+
+ <listitem><para>
+ Print a driver identifying message.
+ </para></listitem></varlistentry>
+
+ <varlistentry><term>Probe</term>
+
+ <listitem><para>
+ This is how a driver identifies if there is any hardware present that
+ it knows how to drive.
+ </para></listitem></varlistentry>
+
+ <varlistentry><term>PreInit</term>
+
+ <listitem><para>
+ Process information from the xorg.conf file, determine the
+ full characteristics of the hardware, and determine if a valid
+ configuration is present.
+ </para></listitem></varlistentry>
+ </variablelist>
+ </para>
+
+ <para>
+The VidMode extension also requires:
+
+ <variablelist>
+ <varlistentry><term>ValidMode</term>
+
+ <listitem><para>
+ Identify if a new mode is usable with the current configuration.
+ The PreInit function (and/or helpers it calls) may also make use
+ of the ValidMode function or something similar.
+ </para></listitem></varlistentry>
+ </variablelist>
+ </para>
+
+
+ <para>
+Other extensions may require other entry points. The drivers will
+inform the common layer of these in such cases.
+ </para>
+ </sect1>
+
+ <sect1>
+ <title>Resource Access Control Introduction</title>
+
+ <para>
+Graphics devices are accessed through ranges in I/O or memory space.
+While most modern graphics devices allow relocation of such ranges many
+of them still require the use of well established interfaces such as
+VGA memory and IO ranges or 8514/A IO ranges. With modern buses (like
+PCI) it is possible for multiple video devices to share access to these
+resources. The RAC (Resource Access Control) subsystem provides a
+mechanism for this.
+ </para>
+
+ <sect2>
+ <title>Terms and Definitions</title>
+
+ <sect3>
+ <title>Bus</title>
+
+ <para>
+ <quote>Bus</quote> is ambiguous as it is used for different things: it may refer
+ to physical incompatible extension connectors in a computer system.
+ The RAC system knows two such systems: The ISA bus and the PCI bus.
+ (On the software level EISA, MCA and VL buses are currently treated
+ like ISA buses). <quote>Bus</quote> may also refer to logically different
+ entities on a single bus system which are connected via bridges. A
+ PCI system may have several distinct PCI buses connecting each other
+ by PCI-PCI bridges or to the host CPU by HOST-PCI bridges.
+ </para>
+
+ <para>
+ Systems that host more than one bus system link these together using
+ bridges. Bridges are a concern to RAC as they might block or pass
+ specific resources. PCI-PCI bridges may be set up to pass VGA
+ resources to the secondary bus. PCI-ISA buses pass any resources not
+ decoded on the primary PCI bus to the ISA bus. This way VGA resources
+ (although exclusive on the ISA bus) can be shared by ISA and PCI
+ cards. Currently HOST-PCI bridges are not yet handled by RAC as they
+ require specific drivers.
+ </para>
+ </sect3>
+
+ <sect3>
+ <title>Entity</title>
+
+ <para>
+ The smallest independently addressable unit on a system bus is
+ referred to as an entity. So far we know ISA and PCI entities. PCI
+ entities can be located on the PCI bus by an unique ID consisting of
+ the bus, card and function number.
+ </para>
+ </sect3>
+
+ <sect3>
+ <title>Resource</title>
+
+ <para>
+ <quote>Resource</quote> refers to a range of memory or I/O addresses an entity
+ can decode.
+ </para>
+
+ <para>
+ If a device is capable of disabling this decoding the resource is
+ called sharable. For PCI devices a generic method is provided to
+ control resource decoding. Other devices will have to provide a
+ device specific function to control decoding.
+ </para>
+
+ <para>
+ If the entity is capable of decoding this range at a different
+ location this resource is considered relocatable.
+ </para>
+
+ <para>
+ Resources which start at a specific address and occupy a single
+ continuous range are called block resources.
+ </para>
+
+ <para>
+ Alternatively resource addresses can be decoded in a way that they
+ satisfy the conditions:
+ <programlisting>
+ address &amp; mask == base
+ </programlisting>
+ and
+ <programlisting>
+ base &amp; mask == base
+ </programlisting>
+ Resources addressed in such a way are called sparse resources.
+ </para>
+
+ </sect3>
+
+ <sect3>
+ <title>Server States</title>
+
+ <para>
+ The resource access control system knows two server states: the
+ SETUP and the OPERATING state. The SETUP state is entered whenever
+ a mode change takes place or the server exits or does VT switching.
+ During this state all entity resources are under resource access
+ control. During OPERATING state only those entities are controlled
+ which actually have shared resources that conflict with others.
+ </para>
+ </sect3>
+ </sect2>
+ </sect1>
+
+ <sect1>
+ <title>Control Flow in the Server and Mandatory Driver Functions</title>
+
+ <para>
+At the start of each server generation, <function>main()</function>
+(<filename>dix/main.c</filename>) calls the DDX function
+<function>InitOutput()</function>. This is the first place that the DDX gets
+control. <function>InitOutput()</function> is expected to fill in the global
+<structname>screenInfo</structname> struct, and one
+<structfield>screenInfo.screen[]</structfield> entry for each screen present.
+Here is what <function>InitOutput()</function> does:
+ </para>
+
+ <sect2>
+ <title>Parse the xorg.conf file</title>
+
+ <para>
+ This is done at the start of the first server generation only.
+ </para>
+
+ <para>
+ The xorg.conf file is read in full, and the resulting information
+ stored in data structures. None of the parsed information is
+ processed at this point. The parser data structures are opaque to
+ the video drivers and to most of the common layer code.
+ </para>
+
+ <para>
+ The entire file is parsed first to remove any section ordering
+ requirements.
+ </para>
+ </sect2>
+
+
+ <sect2>
+ <title>Initial processing of parsed information and command line options
+ </title>
+
+ <para>
+ This is done at the start of the first server generation only.
+ </para>
+
+ <para>
+ The initial processing is to determine paths like the
+ <emphasis>ModulePath</emphasis>, etc, and to determine which &k.serverlayout;,
+ &k.screen; and &k.device; sections are active.
+ </para>
+ </sect2>
+
+
+ <sect2>
+ <title>Enable port I/O access</title>
+
+ <para>
+ Port I/O access is controlled from the XFree86 common layer, and is
+ <quote>all or nothing</quote>. It is enabled prior to calling driver probes, at
+ the start of subsequent server generations, and when VT switching
+ back to the Xserver. It is disabled at the end of server generations,
+ and when VT switching away from the Xserver.
+ </para>
+
+ <para>
+ The implementation details of this may vary on different platforms.
+ </para>
+ </sect2>
+
+
+ <sect2>
+ <title>General bus probe</title>
+
+ <para>
+ This is done at the start of the first server generation only.
+ </para>
+
+ <para>
+ In the case of ix86 machines, this will be a general PCI probe.
+ The full information obtained here will be available to the drivers.
+ This information persists for the life of the Xserver. In the PCI
+ case, the PCI information for all video cards found is available by
+ calling <function>xf86GetPciVideoInfo()</function>.
+ </para>
+
+ <blockquote><para>
+ <programlisting>
+ pciVideoPtr *xf86GetPciVideoInfo(void);
+ </programlisting>
+ <blockquote><para>
+ returns a pointer to a list of pointers to
+ <structname>pciVideoRec</structname> entries, of which there is one for
+ each detected PCI video card. The list is terminated with a
+ <constant>NULL</constant> pointer. If no PCI video cards were
+ detected, the return value is <constant>NULL</constant>.
+
+ </para></blockquote>
+ </para></blockquote>
+
+ <para>
+ After the bus probe, the resource broker is initialised.
+ </para>
+ </sect2>
+
+
+ <sect2>
+ <title>Load initial set of modules</title>
+
+ <para>
+ This is done at the start of the first server generation only.
+ </para>
+
+ <para>
+ The core server contains a list of mandatory modules. These are loaded
+ first. Currently the only module on this list is the bitmap font module.
+ </para>
+
+ <para>
+ The next set of modules loaded are those specified explicitly in the
+ &k.module; section of the config file.
+ </para>
+
+ <para>
+ The final set of initial modules are the driver modules referenced
+ by the active &k.device; and &k.inputdevice; sections in the config
+ file. Each of these modules is loaded exactly once.
+ </para>
+ </sect2>
+
+
+ <sect2>
+ <title>Register Video and Input Drivers</title>
+
+ <para>
+ This is done at the start of the first server generation only.
+ </para>
+
+ <para>
+ When a driver module is loaded, the loader calls its
+ <function>Setup</function> function. For video drivers, this function
+ calls <function>xf86AddDriver()</function> to register the driver's
+ <structname>DriverRec</structname>, which contains a small set of essential
+ details and driver entry points required during the early phase of
+ <function>InitOutput()</function>. <function>xf86AddDriver()</function>
+ adds it to the global <varname>xf86DriverList[]</varname> array.
+ </para>
+
+ <para>
+ The <structname>DriverRec</structname> contains the driver canonical name,
+ the <function>Identify()</function>,
+ <function>Probe()</function> and <function>AvailableOptions()</function>
+ function entry points as well as a pointer
+ to the driver's module (as returned from the loader when the driver
+ was loaded) and a reference count which keeps track of how many
+ screens are using the driver. The entry driver entry points are
+ those required prior to the driver allocating and filling in its
+ <structname>ScrnInfoRec</structname>.
+ </para>
+
+ <para>
+ For a static server, the <varname>xf86DriverList[]</varname> array is
+ initialised at build time, and the loading of modules is not done.
+ </para>
+
+ <para>
+ A similar procedure is used for input drivers. The input driver's
+ <function>Setup</function> function calls
+ <function>xf86AddInputDriver()</function> to register the driver's
+ <structname>InputDriverRec</structname>, which contains a small set of
+ essential details and driver entry points required during the early
+ phase of <function>InitInput()</function>.
+ <function>xf86AddInputDriver()</function> adds it to the global
+ <varname>xf86InputDriverList[]</varname> array. For a static server,
+ the <varname>xf86InputDriverList[]</varname> array is initialised at
+ build time.
+ </para>
+
+ <para>
+ Both the <varname>xf86DriverList[]</varname> and
+ <varname>xf86InputDriverList[]</varname> arrays have been initialised
+ by the end of this stage.
+ </para>
+
+ <para>
+ Once all the drivers are registered, their
+ <function>ChipIdentify()</function> functions are called.
+ </para>
+
+ <blockquote><para>
+ <programlisting>
+ void ChipIdentify(int flags);
+ </programlisting>
+ <blockquote><para>
+ This is expected to print a message indicating the driver name,
+ a short summary of what it supports, and a list of the chipset
+ names that it supports. It may use the xf86PrintChipsets() helper
+ to do this.
+ </para></blockquote>
+ </para></blockquote>
+
+ <blockquote><para>
+ <programlisting>
+ void xf86PrintChipsets(const char *drvname, const char *drvmsg,
+ SymTabPtr chips);
+ </programlisting>
+ <blockquote><para>
+ This function provides an easy way for a driver's ChipIdentify
+ function to format the identification message.
+ </para></blockquote>
+ </para></blockquote>
+ </sect2>
+
+ <sect2>
+ <title>Initialise Access Control</title>
+
+ <para>
+ This is done at the start of the first server generation only.
+ </para>
+
+ <para>
+ The Resource Access Control (RAC) subsystem is initialised before
+ calling any driver functions that may access hardware. All generic
+ bus information is probed and saved (for restoration later). All
+ (shared resource) video devices are disabled at the generic bus
+ level, and a probe is done to find the <quote>primary</quote> video device. These
+ devices remain disabled for the next step.
+ </para>
+ </sect2>
+
+
+ <sect2 id="probe">
+ <title>Video Driver Probe</title>
+
+ <para>
+ This is done at the start of the first server generation only. The
+ <function>ChipProbe()</function> function of each registered video driver
+ is called.
+ </para>
+
+ <blockquote><para>
+ <programlisting>
+ Bool ChipProbe(DriverPtr drv, int flags);
+ </programlisting>
+ <blockquote><para>
+ The purpose of this is to identify all instances of hardware
+ supported by the driver. The flags value is currently either 0,
+ <constant>PROBE_DEFAULT</constant> or <constant>PROBE_DETECT</constant>.
+ <constant>PROBE_DETECT</constant> is used if "-configure" or "-probe"
+ command line arguments are given and indicates to the
+ <function>Probe()</function> function that it should not configure the
+ bus entities and that no xorg.conf information is available.
+ </para>
+
+ <para>
+ The probe must find the active device sections that match the
+ driver by calling <function>xf86MatchDevice()</function>. The number
+ of matches found limits the maximum number of instances for this
+ driver. If no matches are found, the function should return
+ <constant>FALSE</constant> immediately.
+ </para>
+
+ <para>
+ Devices that cannot be identified by using device-independent
+ methods should be probed at this stage (keeping in mind that access
+ to all resources that can be disabled in a device-independent way
+ are disabled during this phase). The probe must be a minimal
+ probe. It should just determine if there is a card present that
+ the driver can drive. It should use the least intrusive probe
+ methods possible. It must not do anything that is not essential,
+ like probing for other details such as the amount of memory
+ installed, etc. It is recommended that the
+ <function>xf86MatchPciInstances()</function> helper function be used
+ for identifying matching PCI devices, and similarly the
+ <function>xf86MatchIsaInstances()</function> for ISA (non-PCI) devices
+ (see the <link linkend="rac">RAC</link> section). These helpers also
+ checks and claims the appropriate entity. When not using the
+ helper, that should be done with <function>xf86CheckPciSlot()</function>
+ and <function>xf86ClaimPciSlot()</function> for PCI devices and
+ <function>xf86ClaimIsaSlot()</function> for ISA devices (see the
+ <link linkend="rac">RAC</link> section).
+ </para>
+
+ <para>
+ The probe must register all non-relocatable resources at this
+ stage. If a resource conflict is found between exclusive resources
+ the driver will fail immediately. This is usually best done with
+ the <function>xf86ConfigPciEntity()</function> helper function
+ for PCI and <function>xf86ConfigIsaEntity()</function> for ISA
+ (see the <link linkend="rac">RAC</link> section). It is possible to
+ register some entity specific functions with those helpers. When
+ not using the helpers, the <function>xf86AddEntityToScreen()</function>
+ <function>xf86ClaimFixedResources()</function> and
+ <function>xf86SetEntityFuncs()</function> should be used instead (see
+ the <link linkend="rac">RAC</link> section).
+ </para>
+
+ <para>
+ If a chipset is specified in an active device section which the
+ driver considers relevant (ie it has no driver specified, or the
+ driver specified matches the driver doing the probe), the Probe
+ must return <constant>FALSE</constant> if the chipset doesn't match
+ one supported by the driver.
+ </para>
+
+ <para>
+ If there are no active device sections that the driver considers
+ relevant, it must return <constant>FALSE</constant>.
+ </para>
+
+ <para>
+ Allocate a <structname>ScrnInfoRec</structname> for each active instance of the
+ hardware found, and fill in the basic information, including the
+ other driver entry points. This is best done with the
+ <function>xf86ConfigIsaEntity()</function> helper function for ISA
+ instances or <function>xf86ConfigPciEntity()</function> for PCI instances.
+ These functions allocate a <structname>ScrnInfoRec</structname> for active
+ entities. Optionally <function>xf86AllocateScreen()</function>
+ function may also be used to allocate the <structname>ScrnInfoRec</structname>.
+ Any of these functions take care of initialising fields to defined
+ <quote>unused</quote> values.
+ </para>
+
+ <para>
+ Claim the entities for each instance of the hardware found. This
+ prevents other drivers from claiming the same hardware.
+ </para>
+
+ <para>
+ Must leave hardware in the same state it found it in, and must not
+ do any hardware initialisation.
+ </para>
+
+ <para>
+ All detection can be overridden via the config file, and that
+ parsed information is available to the driver at this stage.
+ </para>
+
+ <para>
+ Returns <constant>TRUE</constant> if one or more instances are found,
+ and <constant>FALSE</constant> otherwise.
+ </para>
+
+ </blockquote></para></blockquote>
+
+ <blockquote><para>
+ <programlisting>
+ int xf86MatchDevice(const char *drivername,
+ GDevPtr **driversectlist)
+ </programlisting>
+ <blockquote><para>
+ This function takes the name of the driver and returns via
+ <parameter>driversectlist</parameter> a list of device sections that
+ match the driver name. The function return value is the number
+ of matches found. If a fatal error is encountered the return
+ value is <literal>-1</literal>.
+ </para>
+
+ <para>
+ The caller should use <function>xfree()</function> to free
+ <parameter>*driversectlist</parameter> when it is no longer needed.
+ </para>
+
+ </blockquote></para></blockquote>
+
+ <blockquote><para>
+ <programlisting>
+ ScrnInfoPtr xf86AllocateScreen(DriverPtr drv, int flags)
+ </programlisting>
+ <blockquote><para>
+ This function allocates a new <structname>ScrnInfoRec</structname> in the
+ <varname>xf86Screens[]</varname> array. This function is normally
+ called by the video driver <function>ChipProbe()</function> functions.
+ The return value is a pointer to the newly allocated
+ <structname>ScrnInfoRec</structname>. The <structfield>scrnIndex</structfield>,
+ <structfield>origIndex</structfield>, <structfield>module</structfield> and
+ <structfield>drv</structfield> fields are initialised. The reference count
+ in <parameter>drv</parameter> is incremented. The storage for any
+ currently allocated <quote>privates</quote> pointers is also allocated and
+ the <structfield>privates</structfield> field initialised (the privates data
+ is of course not allocated or initialised). This function never
+ returns on failure. If the allocation fails, the server exits
+ with a fatal error. The flags value is not currently used, and
+ should be set to zero.
+ </para></blockquote>
+ </para></blockquote>
+
+ <para>
+ At the completion of this, a list of <structname>ScrnInfoRecs</structname>
+ have been allocated in the <varname>xf86Screens[]</varname> array, and
+ the associated entities and fixed resources have been claimed. The
+ following <structname>ScrnInfoRec</structname> fields must be initialised at
+ this point:
+
+ <literallayout>
+ driverVersion
+ driverName
+ scrnIndex(*)
+ origIndex(*)
+ drv(*)
+ module(*)
+ name
+ Probe
+ PreInit
+ ScreenInit
+ EnterVT
+ LeaveVT
+ numEntities
+ entityList
+ access
+ </literallayout>
+
+ <literal>(*)</literal> These are initialised when the <structname>ScrnInfoRec</structname>
+ is allocated, and not explicitly by the driver.
+ </para>
+
+ <para>
+ The following <structname>ScrnInfoRec</structname> fields must be initialised
+ if the driver is going to use them:
+
+ <literallayout>
+ SwitchMode
+ AdjustFrame
+ FreeScreen
+ ValidMode
+ </literallayout>
+ </para>
+ </sect2>
+
+ <sect2>
+ <title>Matching Screens</title>
+
+ <para>
+ This is done at the start of the first server generation only.
+ </para>
+
+ <para>
+ After the Probe phase is finished, there will be some number of
+ <structname>ScrnInfoRec</structname>s. These are then matched with the active
+ &k.screen; sections in the xorg.conf, and those not having an active
+ &k.screen; section are deleted. If the number of remaining screens
+ is 0, <function>InitOutput()</function> sets
+ <structfield>screenInfo.numScreens</structfield> to <constant>0</constant> and
+ returns.
+ </para>
+
+ <para>
+ At this point the following fields of the <structname>ScrnInfoRec</structname>s
+ must be initialised:
+
+ <literallayout>
+ confScreen
+ </literallayout>
+ </para>
+
+ </sect2>
+
+ <sect2>
+ <title>Allocate non-conflicting resources</title>
+
+ <para>
+ This is done at the start of the first server generation only.
+ </para>
+
+ <para>
+ Before calling the drivers again, the resource information collected
+ from the Probe phase is processed. This includes checking the extent
+ of PCI resources for the probed devices, and resolving any conflicts
+ in the relocatable PCI resources. It also reports conflicts, checks
+ bus routing issues, and anything else that is needed to enable the
+ entities for the next phase.
+ </para>
+
+ <para>
+ If any drivers registered an <function>EntityInit()</function> function
+ during the Probe phase, then they are called here.
+ </para>
+
+ </sect2>
+
+ <sect2>
+ <title>Sort the Screens and pre-check Monitor Information</title>
+
+ <para>
+ This is done at the start of the first server generation only.
+ </para>
+
+ <para>
+ The list of screens is sorted to match the ordering requested in the
+ config file.
+ </para>
+
+ <para>
+ The list of modes for each active monitor is checked against the
+ monitor's parameters. Invalid modes are pruned.
+ </para>
+
+ </sect2>
+
+ <sect2>
+ <title>PreInit</title>
+
+ <para>
+ This is done at the start of the first server generation only.
+ </para>
+
+ <para>
+ For each <structname>ScrnInfoRec</structname>, enable access to the screens entities and call
+ the <function>ChipPreInit()</function> function.
+ </para>
+
+ <blockquote><para>
+ <programlisting>
+ Bool ChipPreInit(ScrnInfoRec screen, int flags);
+ </programlisting>
+ <blockquote><para>
+ The purpose of this function is to find out all the information
+ required to determine if the configuration is usable, and to
+ initialise those parts of the <structname>ScrnInfoRec</structname> that
+ can be set once at the beginning of the first server generation.
+ </para>
+
+ <para>
+ The number of entities registered for the screen should be checked
+ against the expected number (most drivers expect only one). The
+ entity information for each of them should be retrieved (with
+ <function>xf86GetEntityInfo()</function>) and checked for the correct
+ bus type and that none of the sharable resources registered during
+ the Probe phase was rejected.
+ </para>
+
+ <para>
+ Access to resources for the entities that can be controlled in a
+ device-independent way are enabled before this function is called.
+ If the driver needs to access any resources that it has disabled
+ in an <function>EntityInit()</function> function that it registered,
+ then it may enable them here providing that it disables them before
+ this function returns.
+ </para>
+
+ <para>
+ This includes probing for video memory, clocks, ramdac, and all
+ other HW info that is needed. It includes determining the
+ depth/bpp/visual and related info. It includes validating and
+ determining the set of video modes that will be used (and anything
+ that is required to determine that).
+ </para>
+
+ <para>
+ This information should be determined in the least intrusive way
+ possible. The state of the HW must remain unchanged by this
+ function. Although video memory (including MMIO) may be mapped
+ within this function, it must be unmapped before returning. Driver
+ specific information should be stored in a structure hooked into
+ the <structname>ScrnInfoRec</structname>'s <structfield>driverPrivate</structfield>
+ field. Any other modules which require persistent data (ie data
+ that persists across server generations) should be initialised in
+ this function, and they should allocate a <quote>privates</quote> index to
+ hook their data into by calling
+ <function>xf86AllocateScrnInfoPrivateIndex()</function>. The <quote>privates</quote>
+ data is persistent.
+ </para>
+
+ <para>
+ Helper functions for some of these things are provided at the
+ XFree86 common level, and the driver can choose to make use of
+ them.
+ </para>
+
+ <para>
+ All additional resources that the screen needs must be registered
+ here. This should be done with
+ <function>xf86RegisterResources()</function>. If some of the fixed
+ resources registered in the Probe phase are not needed or not
+ decoded by the hardware when in the OPERATING server state, their
+ status should be updated with
+ <function>xf86SetOperatingState()</function>.
+ </para>
+
+ <para>
+ Modules may be loaded at any point in this function, and all
+ modules that the driver will need must be loaded before the end
+ of this function. Either the <function>xf86LoadSubModule()</function>
+ or the <function>xf86LoadDrvSubModule()</function> function should be
+ used to load modules depending on whether a
+ <structname>ScrnInfoRec</structname> has been set up. A driver may unload
+ a module within this function if it was only needed temporarily,
+ and the <function>xf86UnloadSubModule()</function> function should be used
+ to do that. Otherwise there is no need to explicitly unload modules
+ because the loader takes care of module dependencies and will
+ unload submodules automatically if/when the driver module is
+ unloaded.
+ </para>
+
+ <para>
+ The bulk of the <structname>ScrnInfoRec</structname> fields should be filled
+ out in this function.
+ </para>
+
+ <para>
+ <function>ChipPreInit()</function> returns <constant>FALSE</constant> when
+ the configuration is unusable in some way (unsupported depth, no
+ valid modes, not enough video memory, etc), and <constant>TRUE</constant>
+ if it is usable.
+ </para>
+
+ <para>
+ It is expected that if the <function>ChipPreInit()</function> function
+ returns <constant>TRUE</constant>, then the only reasons that subsequent
+ stages in the driver might fail are lack or resources (like xalloc
+ failures). All other possible reasons for failure should be
+ determined by the <function>ChipPreInit()</function> function.
+ </para></blockquote>
+ </para></blockquote>
+
+ <para>
+ The <structname>ScrnInfoRec</structname>s for screens where the <function>ChipPreInit()</function> fails are removed.
+ If none remain, <function>InitOutput()</function> sets <structfield>screenInfo.numScreens</structfield> to <constant>0</constant> and returns.
+ </para>
+
+ <para>
+ At this point, further fields of the <structname>ScrnInfoRec</structname>s would normally be
+ filled in. Most are not strictly mandatory, but many are required
+ by other layers and/or helper functions that the driver may choose
+ to use. The documentation for those layers and helper functions
+ indicates which they require.
+ </para>
+
+ <para>
+ The following fields of the <structname>ScrnInfoRec</structname>s should be filled in if the
+ driver is going to use them:
+
+ <literallayout>
+ monitor
+ display
+ depth
+ pixmapBPP
+ bitsPerPixel
+ weight (&gt;8bpp only)
+ mask (&gt;8bpp only)
+ offset (&gt;8bpp only)
+ rgbBits (8bpp only)
+ gamma
+ defaultVisual
+ maxHValue
+ maxVValue
+ virtualX
+ virtualY
+ displayWidth
+ frameX0
+ frameY0
+ frameX1
+ frameY1
+ zoomLocked
+ modePool
+ modes
+ currentMode
+ progClock (TRUE if clock is programmable)
+ chipset
+ ramdac
+ clockchip
+ numClocks (if not programmable)
+ clock[] (if not programmable)
+ videoRam
+ biosBase
+ memBase
+ memClk
+ driverPrivate
+ chipID
+ chipRev
+ </literallayout>
+ </para>
+
+ <blockquote><para>
+ <programlisting>
+ pointer xf86LoadSubModule(ScrnInfoPtr pScrn, const char *name);
+ and
+ pointer xf86LoadDrvSubModule(DriverPtr drv, const char *name);
+ </programlisting>
+ <blockquote><para>
+ Load a module that a driver depends on. This function loads the
+ module <parameter>name</parameter> as a sub module of the driver. The
+ return value is a handle identifying the new module. If the load
+ fails, the return value will be <constant>NULL</constant>. If a driver
+ needs to explicitly unload a module it has loaded in this way,
+ the return value must be saved and passed to
+ <function>xf86UnloadSubModule()</function> when unloading.
+
+ </para></blockquote>
+ </para></blockquote>
+
+ <blockquote><para>
+ <programlisting>
+ void xf86UnloadSubModule(pointer module);
+ </programlisting>
+ <blockquote><para>
+ Unloads the module referenced by <parameter>module</parameter>.
+ <parameter>module</parameter> should be a pointer returned previously
+ by <function>xf86LoadSubModule()</function> or
+ <function>xf86LoadDrvSubModule()</function> .
+
+ </para></blockquote>
+ </para></blockquote>
+ </sect2>
+
+ <sect2>
+ <title>Cleaning up Unused Drivers</title>
+
+ <para>
+ At this point it is known which screens will be in use, and which
+ drivers are being used. Unreferenced drivers (and modules they
+ may have loaded) are unloaded here.
+ </para>
+
+ </sect2>
+
+ <sect2>
+ <title>Consistency Checks</title>
+
+ <para>
+ The parameters that must be global to the server, like pixmap formats,
+ bitmap bit order, bitmap scanline unit and image byte order are
+ compared for each of the screens. If a mismatch is found, the server
+ exits with an appropriate message.
+ </para>
+
+ </sect2>
+
+ <sect2>
+ <title>Check if Resource Control is Needed</title>
+
+ <para>
+ Determine if resource access control is needed. This is the case
+ if more than one screen is used. If necessary the RAC wrapper module
+ is loaded.
+ </para>
+ </sect2>
+
+ <sect2>
+ <title>AddScreen (ScreenInit)</title>
+
+ <para>
+ At this point, the valid screens are known.
+ <function>AddScreen()</function> is called for each of them, passing
+ <function>ChipScreenInit()</function> as the argument.
+ <function>AddScreen()</function> is a DIX function that allocates a new
+ <structfield>screenInfo.screen[]</structfield> entry (aka
+ <varname>pScreen</varname>), and does some basic initialisation of it.
+ It then calls the <function>ChipScreenInit()</function> function, with
+ <parameter>pScreen</parameter> as one of its arguments. If
+ <function>ChipScreenInit()</function> returns <constant>FALSE</constant>,
+ <function>AddScreen()</function> returns <constant>-1</constant>. Otherwise
+ it returns the index of the screen. <function>AddScreen()</function>
+ should only fail because of programming errors or failure to allocate
+ resources (like memory). All configuration problems should be
+ detected BEFORE this point.
+ </para>
+
+ <blockquote><para>
+ <programlisting>
+ Bool ChipScreenInit(int index, ScreenPtr pScreen,
+ int argc, char **argv);
+ </programlisting>
+ <blockquote><para>
+ This is called at the start of each server generation.
+ </para>
+
+ <para>
+ Fill in all of <parameter>pScreen</parameter>, possibly doing some of
+ this by calling ScreenInit functions from other layers like mi,
+ framebuffers (cfb, etc), and extensions.
+ </para>
+
+ <para>
+ Decide which operations need to be placed under resource access
+ control. The classes of operations are the frame buffer operations
+ (<constant>RAC_FB</constant>), the pointer operations
+ (<constant>RAC_CURSOR</constant>), the viewport change operations
+ (<constant>RAC_VIEWPORT</constant>) and the colormap operations
+ (<constant>RAC_COLORMAP</constant>). Any operation that requires
+ resources which might be disabled during OPERATING state should
+ be set to use RAC. This can be specified separately for memory
+ and IO resources (the <structfield>racMemFlags</structfield> and
+ <structfield>racIoFlags</structfield> fields of the <structname>ScrnInfoRec</structname>
+ respectively).
+ </para>
+
+ <para>
+ Map any video memory or other memory regions.
+ </para>
+
+ <para>
+ Save the video card state. Enough state must be saved so that
+ the original state can later be restored.
+ </para>
+
+ <para>
+ Initialise the initial video mode. The <structname>ScrnInfoRec</structname>'s
+ <structfield>vtSema</structfield> field should be set to <constant>TRUE</constant>
+ just prior to changing the video hardware's state.
+
+ </para></blockquote>
+ </para></blockquote>
+
+
+ <para>
+ The <function>ChipScreenInit()</function> function (or functions from other
+ layers that it calls) should allocate entries in the
+ <structname>ScreenRec</structname>'s <structfield>devPrivates</structfield> area by
+ calling <function>AllocateScreenPrivateIndex()</function> if it needs
+ per-generation storage. Since the <structname>ScreenRec</structname>'s
+ <structfield>devPrivates</structfield> information is cleared for each server
+ generation, this is the correct place to initialise it.
+ </para>
+
+ <para>
+ After <function>AddScreen()</function> has successfully returned, the
+ following <structname>ScrnInfoRec</structname> fields are initialised:
+
+ <literallayout>
+ pScreen
+ racMemFlags
+ racIoFlags
+ </literallayout>
+ </para>
+
+ <para>
+ The <function>ChipScreenInit()</function> function should initialise the
+ <structfield>CloseScreen</structfield> and <structfield>SaveScreen</structfield> fields
+ of <parameter>pScreen</parameter>. The old value of
+ <structfield>pScreen-&gt;CloseScreen</structfield> should be saved as part of
+ the driver's per-screen private data, allowing it to be called from
+ <function>ChipCloseScreen()</function>. This means that the existing
+ <function>CloseScreen()</function> function is wrapped.
+ </para>
+ </sect2>
+
+ <sect2>
+ <title>Finalising RAC Initialisation</title>
+
+ <para>
+ After all the <function>ChipScreenInit()</function> functions have been
+ called, each screen has registered its RAC requirements. This
+ information is used to determine which shared resources are requested
+ by more than one driver and set the access functions accordingly.
+ This is done following these rules:
+
+ <orderedlist>
+ <listitem><para>
+ The sharable resources registered by each entity are compared.
+ If a resource is registered by more than one entity the entity
+ will be marked to indicate that it needs to share this resources
+ type (IO or MEM).
+ </para></listitem>
+
+ <listitem><para>
+ A resource marked <quote>disabled</quote> during OPERATING state will be
+ ignored entirely.
+ </para></listitem>
+
+ <listitem><para>
+ A resource marked <quote>unused</quote> will only conflict with an overlapping
+ resource of an other entity if the second is actually in use
+ during OPERATING state.
+ </para></listitem>
+
+ <listitem><para>
+ If an <quote>unused</quote> resource was found to conflict but the entity
+ does not use any other resource of this type the entire resource
+ type will be disabled for that entity.
+ </para></listitem>
+ </orderedlist>
+ </para>
+
+ </sect2>
+
+ <sect2>
+ <title>Finishing InitOutput()</title>
+
+ <para>
+ At this point <function>InitOutput()</function> is finished, and all the
+ screens have been setup in their initial video mode.
+ </para>
+
+ </sect2>
+
+ <sect2>
+ <title>Mode Switching</title>
+
+ <para>
+ When a SwitchMode event is received, <function>ChipSwitchMode()</function>
+ is called (when it exists):
+ </para>
+
+ <blockquote><para>
+ <programlisting>
+ Bool ChipSwitchMode(int index, DisplayModePtr mode, int flags);
+ </programlisting>
+ <blockquote><para>
+ Initialises the new mode for the screen identified by
+ <parameter>index;</parameter>. The viewport may need to be adjusted
+ also.
+
+ </para></blockquote>
+ </para></blockquote>
+
+ </sect2>
+
+ <sect2>
+ <title>Changing Viewport</title>
+
+ <para>
+ When a Change Viewport event is received,
+ <function>ChipAdjustFrame()</function> is called (when it exists):
+ </para>
+
+ <blockquote><para>
+ <programlisting>
+ void ChipAdjustFrame(int index, int x, int y, int flags);
+ </programlisting>
+ <blockquote><para>
+ Changes the viewport for the screen identified by
+ <parameter>index;</parameter>.
+ </para>
+
+ <para>
+ It should be noted that many chipsets impose restrictions on where the
+ viewport may be placed in the virtual resolution, either for alignment
+ reasons, or to prevent the start of the viewport from being positioned
+ within a pixel (as can happen in a 24bpp mode). After calculating the
+ value the chipset's panning registers need to be set to for non-DGA
+ modes, this function should recalculate the ScrnInfoRec's
+ <structfield>frameX0</structfield>, <structfield>frameY0</structfield>, <structfield>frameX1</structfield>
+ and <structfield>frameY1</structfield> fields to correspond to that value. If
+ this is not done, switching to another mode might cause the position
+ of a hardware cursor to change.
+
+ </para></blockquote>
+ </para></blockquote>
+
+ </sect2>
+
+ <sect2>
+ <title>VT Switching</title>
+
+ <para>
+ When a VT switch event is received, <function>xf86VTSwitch()</function>
+ is called. <function>xf86VTSwitch()</function> does the following:
+
+ <variablelist>
+ <varlistentry><term>On ENTER:</term>
+ <listitem>
+ <itemizedlist>
+ <listitem><para>
+ enable port I/O access
+ </para></listitem>
+
+ <listitem><para>
+ save and initialise the bus/resource state
+ </para></listitem>
+
+ <listitem><para>
+ enter the SETUP server state
+ </para></listitem>
+
+ <listitem><para>
+ calls <function>ChipEnterVT()</function> for each screen
+ </para></listitem>
+
+ <listitem><para>
+ enter the OPERATING server state
+ </para></listitem>
+
+ <listitem><para>
+ validate GCs
+ </para></listitem>
+
+ <listitem><para>
+ Restore fb from saved pixmap for each screen
+ </para></listitem>
+
+ <listitem><para>
+ Enable all input devices
+ </para></listitem>
+ </itemizedlist>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term>On LEAVE:</term>
+ <listitem>
+ <itemizedlist>
+ <listitem><para>
+ Save fb to pixmap for each screen
+ </para></listitem>
+
+ <listitem><para>
+ validate GCs
+ </para></listitem>
+
+ <listitem><para>
+ enter the SETUP server state
+ </para></listitem>
+
+ <listitem><para>
+ calls <function>ChipLeaveVT()</function> for each screen
+ </para></listitem>
+
+ <listitem><para>
+ disable all input devices
+ </para></listitem>
+
+ <listitem><para>
+ restore bus/resource state
+ </para></listitem>
+
+ <listitem><para>
+ disables port I/O access
+ </para></listitem>
+ </itemizedlist>
+ </listitem>
+ </varlistentry>
+ </variablelist>
+ </para>
+
+ <blockquote><para>
+ <programlisting>
+ Bool ChipEnterVT(int index, int flags);
+ </programlisting>
+ <blockquote><para>
+ This function should initialise the current video mode and
+ initialise the viewport, turn on the HW cursor if appropriate,
+ etc.
+ </para>
+
+ <para>
+ Should it re-save the video state before initialising the video
+ mode?
+ </para>
+
+ </blockquote></para></blockquote>
+
+ <blockquote><para>
+ <programlisting>
+ void ChipLeaveVT(int index, int flags);
+ </programlisting>
+ <blockquote><para>
+ This function should restore the saved video state. If
+ appropriate it should also turn off the HW cursor, and invalidate
+ any pixmap/font caches.
+ </para>
+
+ </blockquote></para></blockquote>
+
+ <para>
+ Optionally, <function>ChipLeaveVT()</function> may also unmap memory
+ regions. If so, <function>ChipEnterVT()</function> will need to remap
+ them. Additionally, if an aperture used to access video memory is
+ unmapped and remapped in this fashion, <function>ChipEnterVT()</function>
+ will also need to notify the framebuffer layers of the aperture's new
+ location in virtual memory. This is done with a call to the screen's
+ <function>ModifyPixmapHeader()</function> function, as follows
+ </para>
+
+ <blockquote><para>
+ <programlisting>
+ (*pScreen-&gt;ModifyPixmapHeader)(pScrn-&gt;ppix,
+ -1, -1, -1, -1, -1, NewApertureAddress);
+ </programlisting>
+ <blockquote><para>
+ where the <structfield>ppix</structfield> field in a ScrnInfoRec
+ points to the pixmap used by the screen's
+ <function>SaveRestoreImage()</function> function to hold the screen's
+ contents while switched out.
+ </para>
+
+ </blockquote></para></blockquote>
+
+ <para>
+ Other layers may wrap the <function>ChipEnterVT()</function> and
+ <function>ChipLeaveVT()</function> functions if they need to take some
+ action when these events are received.
+ </para>
+ </sect2>
+
+ <sect2>
+ <title>End of server generation</title>
+
+ <para>
+ At the end of each server generation, the DIX layer calls
+ <function>ChipCloseScreen()</function> for each screen:
+ </para>
+
+ <blockquote><para>
+ <programlisting>
+ Bool ChipCloseScreen(int index, ScreenPtr pScreen);
+ </programlisting>
+ <blockquote><para>
+ This function should restore the saved video state and unmap the
+ memory regions.
+ </para>
+
+ <para>
+ It should also free per-screen data structures allocated by the
+ driver. Note that the persistent data held in the
+ <structname>ScrnInfoRec</structname>'s <structfield>driverPrivate</structfield> field
+ should not be freed here because it is needed by subsequent server
+ generations.
+ </para>
+
+ <para>
+ The <structname>ScrnInfoRec</structname>'s <structfield>vtSema</structfield> field
+ should be set to <constant>FALSE</constant> once the video HW state
+ has been restored.
+ </para>
+
+ <para>
+ Before freeing the per-screen driver data the saved
+ <structfield>CloseScreen</structfield> value should be restored to
+ <structfield>pScreen-&gt;CloseScreen</structfield>, and that function should
+ be called after freeing the data.
+
+ </para></blockquote>
+ </para></blockquote>
+ </sect2>
+ </sect1>
+
+ <sect1>
+ <title>Optional Driver Functions</title>
+
+ <para>
+The functions outlined here can be called from the XFree86 common layer,
+but their presence is optional.
+ </para>
+
+ <sect2>
+ <title>Mode Validation</title>
+
+ <para>
+ When a mode validation helper supplied by the XFree86-common layer is
+ being used, it can be useful to provide a function to check for hw
+ specific mode constraints:
+ </para>
+
+ <blockquote><para>
+ <programlisting>
+ ModeStatus ChipValidMode(int index, DisplayModePtr mode,
+ Bool verbose, int flags);
+ </programlisting>
+ <blockquote><para>
+ Check the passed mode for hw-specific constraints, and return the
+ appropriate status value.
+
+ </para></blockquote>
+ </para></blockquote>
+
+ <para>
+This function may also modify the effective timings and clock of the passed
+mode. These have been stored in the mode's <structfield>Crtc*</structfield> and
+<structfield>SynthClock</structfield> elements, and have already been adjusted for
+interlacing, doublescanning, multiscanning and clock multipliers and dividers.
+The function should not modify any other mode field, unless it wants to modify
+the mode timings reported to the user by <function>xf86PrintModes()</function>.
+ </para>
+
+ <para>
+The function is called once for every mode in the xorg.conf Monitor section
+assigned to the screen, with <parameter>flags</parameter> set to
+<constant>MODECHECK_INITIAL</constant>. It is subsequently called for every mode
+in the xorg.conf Display subsection assigned to the screen, with
+<parameter>flags</parameter> set to <constant>MODECHECK_FINAL</constant>. In the second
+case, the mode will have successfully passed all other tests. In addition,
+the <structname>ScrnInfoRec</structname>'s <structfield>virtualX</structfield>,
+<structfield>virtualY</structfield> and <structfield>displayWidth</structfield> fields will have been
+set as if the mode to be validated were to be the last mode accepted.
+ </para>
+
+ <para>
+In effect, calls with MODECHECK_INITIAL are intended for checks that do not
+depend on any mode other than the one being validated, while calls with
+MODECHECK_FINAL are intended for checks that may involve more than one mode.
+ </para>
+ </sect2>
+
+ <sect2>
+ <title>Free screen data</title>
+
+ <para>
+ When a screen is deleted prior to the completion of the ScreenInit
+ phase the <function>ChipFreeScreen()</function> function is called when defined.
+ </para>
+
+ <blockquote><para>
+ <programlisting>
+ void ChipFreeScreen(int scrnindex, int flags);
+ </programlisting>
+ <blockquote><para>
+ Free any driver-allocated data that may have been allocated up to
+ and including an unsuccessful <function>ChipScreenInit()</function>
+ call. This would predominantly be data allocated by
+ <function>ChipPreInit()</function> that persists across server
+ generations. It would include the <structfield>driverPrivate</structfield>,
+ and any <quote>privates</quote> entries that modules may have allocated.
+
+ </para></blockquote>
+ </para></blockquote>
+
+ </sect2>
+</sect1>
+
+ <sect1>
+ <title>Recommended driver functions</title>
+
+ <para>
+The functions outlined here are for internal use by the driver only.
+They are entirely optional, and are never accessed directly from higher
+layers. The sample function declarations shown here are just examples.
+The interface (if any) used is up to the driver.
+ </para>
+
+ <sect2>
+ <title>Save</title>
+
+ <para>
+ Save the video state. This could be called from <function>ChipScreenInit()</function> and
+ (possibly) <function>ChipEnterVT()</function>.
+ </para>
+
+ <blockquote><para>
+ <programlisting>
+ void ChipSave(ScrnInfoPtr pScrn);
+ </programlisting>
+ <blockquote><para>
+ Saves the current state. This will only be saving pre-server
+ states or states before returning to the server. There is only
+ one current saved state per screen and it is stored in private
+ storage in the screen.
+
+ </para></blockquote>
+ </para></blockquote>
+ </sect2>
+
+ <sect2>
+ <title>Restore</title>
+
+ <para>
+ Restore the original video state. This could be called from the
+ <function>ChipLeaveVT()</function> and <function>ChipCloseScreen()</function>
+ functions.
+ </para>
+
+ <blockquote><para>
+ <programlisting>
+ void ChipRestore(ScrnInfoPtr pScrn);
+ </programlisting>
+ <blockquote><para>
+ Restores the saved state from the private storage. Usually only
+ used for restoring text modes.
+
+ </para></blockquote>
+ </para></blockquote>
+
+ </sect2>
+
+ <sect2>
+ <title>Initialise Mode</title>
+
+ <para>
+ Initialise a video mode. This could be called from the
+ <function>ChipScreenInit()</function>, <function>ChipSwitchMode()</function>
+ and <function>ChipEnterVT()</function> functions.
+ </para>
+
+ <blockquote><para>
+ <programlisting>
+ Bool ChipModeInit(ScrnInfoPtr pScrn, DisplayModePtr mode);
+ </programlisting>
+ <blockquote><para>
+ Programs the hardware for the given video mode.
+
+ </para></blockquote>
+ </para></blockquote>
+
+ </sect2>
+ </sect1>
+
+ <sect1>
+ <title>Data and Data Structures</title>
+
+ <sect2>
+ <title>Command line data</title>
+
+ <para>
+Command line options are typically global, and are stored in global
+variables. These variables are read-only and are available to drivers
+via a function call interface. Most of these command line values are
+processed via helper functions to ensure that they are treated consistently
+by all drivers. The other means of access is provided for cases where
+the supplied helper functions might not be appropriate.
+ </para>
+
+ <para>
+Some of them are:
+
+ <literallayout>
+ xf86Verbose verbosity level
+ xf86Bpp -bpp from the command line
+ xf86Depth -depth from the command line
+ xf86Weight -weight from the command line
+ xf86Gamma -{r,g,b,}gamma from the command line
+ xf86FlipPixels -flippixels from the command line
+ xf86ProbeOnly -probeonly from the command line
+ defaultColorVisualClass -cc from the command line
+ </literallayout>
+ </para>
+
+ <para>
+If we ever do allow for screen-specific command line options, we may
+need to rethink this.
+ </para>
+
+ <para>
+These can be accessed in a read-only manner by drivers with the following
+functions:
+ </para>
+
+ <blockquote><para>
+ <programlisting>
+ int xf86GetVerbosity();
+ </programlisting>
+ <blockquote><para>
+ Returns the value of <varname>xf86Verbose</varname>.
+ </para></blockquote>
+
+ </para></blockquote>
+
+ <blockquote><para>
+ <programlisting>
+ int xf86GetDepth();
+ </programlisting>
+ <blockquote><para>
+ Returns the <option>-depth</option> command line setting. If not
+ set on the command line, <constant>-1</constant> is returned.
+ </para></blockquote>
+
+ </para></blockquote>
+
+ <blockquote><para>
+ <programlisting>
+ rgb xf86GetWeight();
+ </programlisting>
+ <blockquote><para>
+ Returns the <option>-weight</option> command line setting. If not
+ set on the command line, <literal remap="tt">{0, 0, 0}</literal> is returned.
+ </para></blockquote>
+
+ </para></blockquote>
+
+ <blockquote><para>
+ <programlisting>
+ Gamma xf86GetGamma();
+ </programlisting>
+ <blockquote><para>
+ Returns the <option>-gamma</option> or <option>-rgamma</option>,
+ <option>-ggamma</option>, <option>-bgamma</option> command line settings.
+ If not set on the command line, <literal remap="tt">{0.0, 0.0, 0.0}</literal>
+ is returned.
+ </para></blockquote>
+
+ </para></blockquote>
+
+ <blockquote><para>
+ <programlisting>
+ Bool xf86GetFlipPixels();
+ </programlisting>
+ <blockquote><para>
+ Returns <constant>TRUE</constant> if <option>-flippixels</option> is
+ present on the command line, and <constant>FALSE</constant> otherwise.
+ </para></blockquote>
+
+ </para></blockquote>
+
+ <blockquote><para>
+ <programlisting>
+ const char *xf86GetServerName();
+ </programlisting>
+ <blockquote><para>
+ Returns the name of the X server from the command line.
+ </para></blockquote>
+
+ </para></blockquote>
+ </sect2>
+
+ <sect2>
+ <title>Data handling</title>
+
+ <para>
+Config file data contains parts that are global, and parts that are
+Screen specific. All of it is parsed into data structures that neither
+the drivers or most other parts of the server need to know about.
+ </para>
+
+ <para>
+The global data is typically not required by drivers, and as such, most
+of it is stored in the private <structname>xf86InfoRec</structname>.
+ </para>
+
+ <para>
+The screen-specific data collected from the config file is stored in
+screen, device, display, monitor-specific data structures that are separate
+from the <varname>ScrnInfoRecs</varname>, with the appropriate elements/fields
+hooked into the <varname>ScrnInfoRecs</varname> as required. The screen
+config data is held in <structname>confScreenRec</structname>, device data in
+the <structname>GDevRec</structname>, monitor data in the <structname>MonRec</structname>,
+and display data in the <structname>DispRec</structname>.
+ </para>
+
+ <para>
+The XFree86 common layer's screen specific data (the actual data in use
+for each screen) is held in the <varname>ScrnInfoRecs</varname>. As has
+been outlined above, the <varname>ScrnInfoRecs</varname> are allocated at probe
+time, and it is the responsibility of the Drivers' <function>Probe()</function>
+and <function>PreInit()</function> functions to finish filling them in based
+on both data provided on the command line and data provided from the
+Config file. The precedence for this is:
+
+ <blockquote><para>
+ command line -&gt; config file -&gt; probed/default data
+ </para></blockquote>
+ </para>
+
+ <para>
+For most things in this category there are helper functions that the
+drivers can use to ensure that the above precedence is consistently
+used.
+ </para>
+
+ <para>
+As well as containing screen-specific data that the XFree86 common layer
+(including essential parts of the server infrastructure as well as helper
+functions) needs to access, it also contains some data that drivers use
+internally. When considering whether to add a new field to the
+<structname>ScrnInfoRec</structname>, consider the balance between the convenience
+of things that lots of drivers need and the size/obscurity of the
+<structname>ScrnInfoRec</structname>.
+ </para>
+
+ <para>
+Per-screen driver specific data that cannot be accommodated with the
+static <structname>ScrnInfoRec</structname> fields is held in a driver-defined
+data structure, a pointer to which is assigned to the
+<structname>ScrnInfoRec</structname>'s <structfield>driverPrivate</structfield> field. This
+is per-screen data that persists across server generations (as does the
+bulk of the static <structname>ScrnInfoRec</structname> data). It would typically
+also include the video card's saved state.
+ </para>
+
+ <para>
+Per-screen data for other modules that the driver uses (for example,
+the XAA module) that is reset for each server generation is hooked into
+the <structname>ScrnInfoRec</structname> through it's <structfield>privates</structfield>
+field.
+ </para>
+
+ <para>
+Once it has stabilised, the data structures and variables accessible to
+video drivers will be documented here. In the meantime, those things
+defined in the <filename>xf86.h</filename> and <filename>xf86str.h</filename>
+files are visible to video drivers. Things defined in
+<filename>xf86Priv.h</filename> and <filename>xf86Privstr.h</filename> are NOT
+intended to be visible to video drivers, and it is an error for a driver
+to include those files.
+ </para>
+
+ </sect2>
+
+ <sect2>
+ <title>Accessing global data</title>
+
+ <para>
+Some other global state information that the drivers may access via
+functions is as follows:
+ </para>
+
+ <blockquote><para>
+ <programlisting>
+ Bool xf86ServerIsExiting();
+ </programlisting>
+ <blockquote><para>
+ Returns <constant>TRUE</constant> if the server is at the end of a
+ generation and is in the process of exiting, and
+ <constant>FALSE</constant> otherwise.
+ </para></blockquote>
+
+ </para></blockquote>
+
+ <blockquote><para>
+ <programlisting>
+ Bool xf86ServerIsResetting();
+ </programlisting>
+ <blockquote><para>
+ Returns <constant>TRUE</constant> if the server is at the end of a
+ generation and is in the process of resetting, and
+ <constant>FALSE</constant> otherwise.
+ </para></blockquote>
+
+ </para></blockquote>
+
+ <blockquote><para>
+ <programlisting>
+ Bool xf86ServerIsInitialising();
+ </programlisting>
+ <blockquote><para>
+ Returns <constant>TRUE</constant> if the server is at the beginning of
+ a generation and is in the process of initialising, and
+ <constant>FALSE</constant> otherwise.
+ </para></blockquote>
+
+ </para></blockquote>
+
+ <blockquote><para>
+ <programlisting>
+ Bool xf86ServerIsOnlyProbing();
+ </programlisting>
+ <blockquote><para>
+ Returns <constant>TRUE</constant> if the -probeonly command line flag
+ was specified, and <constant>FALSE</constant> otherwise.
+ </para></blockquote>
+
+ </para></blockquote>
+
+ <blockquote><para>
+ <programlisting>
+ Bool xf86CaughtSignal();
+ </programlisting>
+ <blockquote><para>
+ Returns <constant>TRUE</constant> if the server has caught a signal,
+ and <constant>FALSE</constant> otherwise.
+ </para></blockquote>
+
+ </para></blockquote>
+ </sect2>
+
+ <sect2>
+ <title>Allocating private data</title>
+
+ <para>
+A driver and any module it uses may allocate per-screen private storage
+in either the <structname>ScreenRec</structname> (DIX level) or
+<structname>ScrnInfoRec</structname> (XFree86 common layer level).
+<structname>ScreenRec</structname> storage persists only for a single server
+generation, and <structname>ScrnInfoRec</structname> storage persists across
+generations for the lifetime of the server.
+ </para>
+
+ <para>
+The <structname>ScreenRec</structname> <structfield>devPrivates</structfield> data must be
+reallocated/initialised at the start of each new generation. This is
+normally done from the <function>ChipScreenInit()</function> function, and
+Init functions for other modules that it calls. Data allocated in this
+way should be freed by the driver's <function>ChipCloseScreen()</function>
+functions, and Close functions for other modules that it calls. A new
+<structfield>devPrivates</structfield> entry is allocated by calling the
+<function>AllocateScreenPrivateIndex()</function> function.
+ </para>
+
+ <blockquote><para>
+ <programlisting>
+ int AllocateScreenPrivateIndex();
+ </programlisting>
+ <blockquote><para>
+ This function allocates a new element in the
+ <structfield>devPrivates</structfield> field of all currently existing
+ <literal remap="tt">ScreenRecs</literal>. The return value is the index of this
+ new element in the <structfield>devPrivates</structfield> array. The
+ <structfield>devPrivates</structfield> field is of type
+ <structname>DevUnion</structname>:
+
+ <programlisting>
+ typedef union _DevUnion {
+ pointer ptr;
+ long val;
+ unsigned long uval;
+ pointer (*fptr)(void);
+ } DevUnion;
+ </programlisting>
+
+ which allows the element to be used for any of the above types.
+ It is commonly used as a pointer to data that the caller allocates
+ after the new index has been allocated.
+ </para>
+
+ <para>
+ This function will return <constant>-1</constant> when there is an
+ error allocating the new index.
+ </para>
+
+ </blockquote>
+ </para></blockquote>
+
+ <para>
+The <structname>ScrnInfoRec</structname> <structfield>privates</structfield> data persists
+for the life of the server, so only needs to be allocated once. This
+should be done from the <function>ChipPreInit()</function> function, and Init
+functions for other modules that it calls. Data allocated in this way
+should be freed by the driver's <function>ChipFreeScreen()</function> functions,
+and Free functions for other modules that it calls. A new
+<structfield>privates</structfield> entry is allocated by calling the
+<function>xf86AllocateScrnInfoPrivateIndex()</function> function.
+ </para>
+
+ <blockquote><para>
+ <programlisting>
+ int xf86AllocateScrnInfoPrivateIndex();
+ </programlisting>
+ <blockquote><para>
+ This function allocates a new element in the <structfield>privates</structfield>
+ field of all currently existing <varname>ScrnInfoRecs</varname>.
+ The return value is the index of this new element in the
+ <structfield>privates</structfield> array. The <structfield>privates</structfield>
+ field is of type <structfield>DevUnion</structfield>:
+
+ <programlisting>
+ typedef union _DevUnion {
+ pointer ptr;
+ long val;
+ unsigned long uval;
+ pointer (*fptr)(void);
+ } DevUnion;
+ </programlisting>
+
+ which allows the element to be used for any of the above types.
+ It is commonly used as a pointer to data that the caller allocates
+ after the new index has been allocated.
+ </para>
+
+ <para>
+ This function will not return when there is an error allocating
+ the new index. When there is an error it will cause the server
+ to exit with a fatal error. The similar function for allocation
+ privates in the <structname>ScreenRec</structname>
+ (<function>AllocateScreenPrivateIndex()</function>) differs in this
+ respect by returning <constant>-1</constant> when the allocation fails.
+ </para>
+
+ </blockquote>
+ </para></blockquote>
+ </sect2>
+ </sect1>
+
+ <sect1 id="rac">
+ <title>Keeping Track of Bus Resources</title>
+
+ <sect2>
+ <title>Theory of Operation</title>
+
+ <para>
+The XFree86 common layer has knowledge of generic access control mechanisms
+for devices on certain bus systems (currently the PCI bus) as well as
+of methods to enable or disable access to the buses itself. Furthermore
+it can access information on resources decoded by these devices and if
+necessary modify it.
+ </para>
+
+ <para>
+When first starting the Xserver collects all this information, saves it
+for restoration, checks it for consistency, and if necessary, corrects
+it. Finally it disables all resources on a generic level prior to
+calling any driver function.
+ </para>
+
+ <para>
+When the <function>Probe()</function> function of each driver is called the
+device sections are matched against the devices found in the system.
+The driver may probe devices at this stage that cannot be identified by
+using device independent methods. Access to all resources that can be
+controlled in a device independent way is disabled. The
+<function>Probe()</function> function should register all non-relocatable
+resources at this stage. If a resource conflict is found between
+exclusive resources the driver will fail immediately. Optionally the
+driver might specify an <function>EntityInit()</function>,
+<function>EntityLeave()</function> and <function>EntityEnter()</function> function.
+ </para>
+
+ <para>
+<function>EntityInit()</function> can be used to disable any shared resources
+that are not controlled by the generic access control functions. It is
+called prior to the PreInit phase regardless if an entity is active or
+not. When calling the <function>EntityInit()</function>,
+<function>EntityEnter()</function> and <function>EntityLeave()</function> functions
+the common level will disable access to all other entities on a generic
+level. Since the common level has no knowledge of device specific
+methods to disable access to resources it cannot be guaranteed that
+certain resources are not decoded by any other entity until the
+<function>EntityInit()</function> or <function>EntityEnter()</function> phase is
+finished. Device drivers should therefore register all those resources
+which they are going to disable. If these resources are never to be
+used by any driver function they may be flagged <constant>ResInit</constant>
+so that they can be removed from the resource list after processing all
+<function>EntityInit()</function> functions. <function>EntityEnter()</function>
+should disable decoding of all resources which are not registered as
+exclusive and which are not handled by the generic access control in
+the common level. The difference to <function>EntityInit()</function> is
+that the latter one is only called once during lifetime of the server.
+It can therefore be used to set up variables prior to disabling resources.
+<function>EntityLeave()</function> should restore the original state when
+exiting the server or switching to a different VT. It also needs to
+disable device specific access functions if they need to be disabled on
+server exit or VT switch. The default state is to enable them before
+giving up the VT.
+ </para>
+
+ <para>
+In <function>PreInit()</function> phase each driver should check if any
+sharable resources it has registered during <function>Probe()</function> has
+been denied and take appropriate action which could simply be to fail.
+If it needs to access resources it has disabled during
+<function>EntitySetup()</function> it can do so provided it has registered
+these and will disable them before returning from
+<function>PreInit()</function>. This also applies to all other driver
+functions. Several functions are provided to request resource ranges,
+register these, correct PCI config space and add replacements for the
+generic access functions. Resources may be marked <quote>disabled</quote> or
+<quote>unused</quote> during OPERATING stage. Although these steps could also be
+performed in <function>ScreenInit()</function>, this is not desirable.
+ </para>
+
+ <para>
+Following <function>PreInit()</function> phase the common level determines
+if resource access control is needed. This is the case if more than
+one screen is used. If necessary the RAC wrapper module is loaded. In
+<function>ScreenInit()</function> the drivers can decide which operations
+need to be placed under RAC. Available are the frame buffer operations,
+the pointer operations and the colormap operations. Any operation that
+requires resources which might be disabled during OPERATING state should
+be set to use RAC. This can be specified separately for memory and IO
+resources.
+ </para>
+
+ <para>
+When <function>ScreenInit()</function> phase is done the common level will
+determine which shared resources are requested by more than one driver
+and set the access functions accordingly. This is done following these
+rules:
+
+ <orderedlist>
+ <listitem><para>
+ The sharable resources registered by each entity are compared. If
+ a resource is registered by more than one entity the entity will be
+ marked to need to share this resources type (<constant>IO</constant> or
+ <constant>MEM</constant>).
+ </para></listitem>
+
+ <listitem><para>
+ A resource marked <quote>disabled</quote> during OPERATING state will be ignored
+ entirely.
+ </para></listitem>
+
+ <listitem><para>
+ A resource marked <quote>unused</quote> will only conflicts with an overlapping
+ resource of an other entity if the second is actually in use during
+ OPERATING state.
+ </para></listitem>
+
+ <listitem><para>
+ If an <quote>unused</quote> resource was found to conflict however the entity
+ does not use any other resource of this type the entire resource type
+ will be disabled for that entity.
+ </para></listitem>
+ </orderedlist>
+ </para>
+
+ <para>
+The driver has the choice among different ways to control access to
+certain resources:
+
+ <orderedlist>
+ <listitem><para>
+ It can rely on the generic access functions. This is probably the
+ most common case. Here the driver only needs to register any resource
+ it is going to use.
+ </para></listitem>
+
+ <listitem><para>
+ It can replace the generic access functions by driver specific
+ ones. This will mostly be used in cases where no generic access
+ functions are available. In this case the driver has to make sure
+ these resources are disabled when entering the <function>PreInit()</function>
+ stage. Since the replacement functions are registered in
+ <function>PreInit()</function> the driver will have to enable these
+ resources itself if it needs to access them during this state. The
+ driver can specify if the replacement functions can control memory
+ and/or I/O resources separately.
+ </para></listitem>
+
+ <listitem><para>
+ The driver can enable resources itself when it needs them. Each
+ driver function enabling them needs to disable them before it will
+ return. This should be used if a resource which can be controlled
+ in a device dependent way is only required during SETUP state. This
+ way it can be marked <quote>unused</quote> during OPERATING state.
+ </para></listitem>
+ </orderedlist>
+ </para>
+
+ <para>
+A resource which is decoded during OPERATING state however never accessed
+by the driver should be marked unused.
+ </para>
+
+ <para>
+Since access switching latencies are an issue during Xserver operation,
+the common level attempts to minimize the number of entities that need
+to be placed under RAC control. When a wrapped operation is called,
+the <function>EnableAccess()</function> function is called before control is
+passed on. <function>EnableAccess()</function> checks if a screen is under
+access control. If not it just establishes bus routing and returns.
+If the screen needs to be under access control,
+<function>EnableAccess()</function> determines which resource types
+(<literal remap="tt">MEM</literal>, <literal remap="tt">IO</literal>) are required. Then it tests
+if this access is already established. If so it simply returns. If
+not it disables the currently established access, fixes bus routing and
+enables access to all entities registered for this screen.
+ </para>
+
+ <para>
+Whenever a mode switch or a VT-switch is performed the common level will
+return to SETUP state.
+ </para>
+ </sect2>
+
+ <sect2>
+ <title>Resource Types</title>
+
+ <para>
+Resource have certain properties. When registering resources each range
+is accompanied by a flag consisting of the ORed flags of the different
+properties the resource has. Each resource range may be classified
+according to
+
+ <itemizedlist>
+ <listitem><para>
+ its physical properties i.e., if it addresses
+ memory (<constant>ResMem</constant>) or
+ I/O space (<constant>ResIo</constant>),
+ </para></listitem>
+ <listitem><para>
+ if it addresses a
+ block (<constant>ResBlock</constant>) or
+ sparse (<constant>ResSparse</constant>)
+ range,
+ </para></listitem>
+ <listitem><para>
+ its access properties.
+ </para></listitem>
+ </itemizedlist>
+ </para>
+
+ <para>
+There are two known access properties:
+
+ <itemizedlist>
+ <listitem><para>
+ <constant>ResExclusive</constant>
+ for resources which may not be shared with any other device and
+ </para></listitem>
+ <listitem><para>
+ <constant>ResShared</constant>
+ for resources which can be disabled and therefore can be shared.
+ </para></listitem>
+ </itemizedlist>
+ </para>
+
+ <para>
+If it is necessary to test a resource against any type a generic access
+type <constant>ResAny</constant> is provided. If this is set the resource
+will conflict with any resource of a different entity intersecting its
+range. Further it can be specified that a resource is decoded however
+never used during any stage (<constant>ResUnused</constant>) or during
+OPERATING state (<constant>ResUnusedOpr</constant>). A resource only visible
+during the init functions (ie. <function>EntityInit()</function>,
+<function>EntityEnter()</function> and <function>EntityLeave()</function> should
+be registered with the flag <constant>ResInit</constant>. A resource that
+might conflict with background resource ranges may be flagged with
+<constant>ResBios</constant>. This might be useful when registering resources
+ranges that were assigned by the system Bios.
+ </para>
+
+ <para>
+Several predefined resource lists are available for VGA and 8514/A
+resources in <filename>common/xf86Resources.h</filename>.
+ </para>
+ </sect2>
+
+ <sect2 id="avail">
+ <title>Available Functions</title>
+
+ <para>
+The functions provided for resource management are listed in their order
+of use in the driver.
+ </para>
+
+ <sect3>
+ <title>Probe Phase</title>
+
+ <para>
+In this phase each driver detects those resources it is able to drive,
+creates an entity record for each of them, registers non-relocatable
+resources and allocates screens and adds the resources to screens.
+ </para>
+
+ <para>
+Two helper functions are provided for matching device sections in the
+xorg.conf file to the devices:
+ </para>
+
+ <blockquote><para>
+ <programlisting>
+ int xf86MatchPciInstances(const char *driverName, int vendorID,
+ SymTabPtr chipsets, PciChipsets *PCIchipsets,
+ GDevPtr *devList, int numDevs, DriverPtr drvp,
+ int **foundEntities);
+ </programlisting>
+ <blockquote><para>
+ This function finds matches between PCI cards that a driver supports
+ and config file device sections. It is intended for use in the
+ <function>ChipProbe()</function> function of drivers for PCI cards.
+ Only probed PCI devices with a vendor ID matching
+ <parameter>vendorID</parameter> are considered. <parameter>devList</parameter>
+ and <parameter>numDevs</parameter> are typically those found from
+ calling <function>xf86MatchDevice()</function>, and represent the active
+ config file device sections relevant to the driver.
+ <parameter>PCIchipsets</parameter> is a table that provides a mapping
+ between the PCI device IDs, the driver's internal chipset tokens
+ and a list of fixed resources.
+ </para>
+
+ <para>
+ When a device section doesn't have a <emphasis>BusID</emphasis> entry it
+ can only match the primary video device. Secondary devices are
+ only matched with device sections that have a matching
+ <emphasis>BusID</emphasis> entry.
+ </para>
+
+ <para>
+ Once the preliminary matches have been found, a final match is
+ confirmed by checking if the chipset override, ChipID override or
+ probed PCI chipset type match one of those given in the
+ <parameter>chipsets</parameter> and <parameter>PCIchipsets</parameter> lists.
+ The <parameter>PCIchipsets</parameter> list includes a list of the PCI
+ device IDs supported by the driver. The list should be terminated
+ with an entry with PCI ID <constant>-1</constant>". The
+ <parameter>chipsets</parameter> list is a table mapping the driver's
+ internal chipset tokens to names, and should be terminated with
+ a <constant>NULL</constant> entry. Only those entries with a
+ corresponding entry in the <parameter>PCIchipsets</parameter> list are
+ considered. The order of precedence is: config file chipset,
+ config file ChipID, probed PCI device ID.
+ </para>
+
+ <para>
+ In cases where a driver handles PCI chipsets with more than one
+ vendor ID, it may set <parameter>vendorID</parameter> to
+ <constant>0</constant>, and OR each devID in the list with (the
+ vendor&nbsp;ID&nbsp;&lt;&lt;&nbsp;16).
+ </para>
+
+ <para>
+ Entity index numbers for confirmed matches are returned as an
+ array via <parameter>foundEntities</parameter>. The PCI information,
+ chipset token and device section for each match are found in the
+ <structname>EntityInfoRec</structname> referenced by the indices.
+ </para>
+
+ <para>
+ The function return value is the number of confirmed matches. A
+ return value of <constant>-1</constant> indicates an internal error.
+ The returned <parameter>foundEntities</parameter> array should be freed
+ by the driver with <function>xfree()</function> when it is no longer
+ needed in cases where the return value is greater than zero.
+ </para>
+
+ </blockquote></para></blockquote>
+
+ <blockquote><para>
+ <programlisting>
+ int xf86MatchIsaInstances(const char *driverName,
+ SymTabPtr chipsets, IsaChipsets *ISAchipsets,
+ DriverPtr drvp, FindIsaDevProc FindIsaDevice,
+ GDevPtr *devList, int numDevs,
+ int **foundEntities);
+ </programlisting>
+ <blockquote><para>
+ This function finds matches between ISA cards that a driver supports
+ and config file device sections. It is intended for use in the
+ <function>ChipProbe()</function> function of drivers for ISA cards.
+ <parameter>devList</parameter> and <parameter>numDevs</parameter> are
+ typically those found from calling <function>xf86MatchDevice()</function>,
+ and represent the active config file device sections relevant to
+ the driver. <parameter>ISAchipsets</parameter> is a table that provides
+ a mapping between the driver's internal chipset tokens and the
+ resource classes. <parameter>FindIsaDevice</parameter> is a
+ driver-provided function that probes the hardware and returns the
+ chipset token corresponding to what was detected, and
+ <constant>-1</constant> if nothing was detected.
+ </para>
+
+ <para>
+ If the config file device section contains a chipset entry, then
+ it is checked against the <parameter>chipsets</parameter> list. When
+ no chipset entry is present, the <parameter>FindIsaDevice</parameter>
+ function is called instead.
+ </para>
+
+ <para>
+ Entity index numbers for confirmed matches are returned as an
+ array via <parameter>foundEntities</parameter>. The chipset token and
+ device section for each match are found in the
+ <structname>EntityInfoRec</structname> referenced by the indices.
+ </para>
+
+ <para>
+ The function return value is the number of confirmed matches. A
+ return value of <constant>-1</constant> indicates an internal error.
+ The returned <parameter>foundEntities</parameter> array should be freed
+ by the driver with <function>xfree()</function> when it is no longer
+ needed in cases where the return value is greater than zero.
+ </para>
+
+ </blockquote></para></blockquote>
+
+ <para>
+These two helper functions make use of several core functions that are
+available at the driver level:
+ </para>
+
+ <blockquote><para>
+ <programlisting>
+ Bool xf86ParsePciBusString(const char *busID, int *bus,
+ int *device, int *func);
+ </programlisting>
+ <blockquote><para>
+ Takes a <parameter>BusID</parameter> string, and if it is in the correct
+ format, returns the PCI <parameter>bus</parameter>, <parameter>device</parameter>,
+ <parameter>func</parameter> values that it indicates. The format of the
+ string is expected to be "PCI:bus:device:func" where each of <quote>bus</quote>,
+ <quote>device</quote> and <quote>func</quote> are decimal integers. The ":func" part may
+ be omitted, and the func value assumed to be zero, but this isn't
+ encouraged. The "PCI" prefix may also be omitted. The prefix
+ "AGP" is currently equivalent to the "PCI" prefix. If the string
+ isn't a valid PCI BusID, the return value is <constant>FALSE</constant>.
+ </para>
+
+ </blockquote></para></blockquote>
+
+ <blockquote><para>
+ <programlisting>
+ Bool xf86ComparePciBusString(const char *busID, int bus,
+ int device, int func);
+ </programlisting>
+ <blockquote><para>
+ Compares a <parameter>BusID</parameter> string with PCI <parameter>bus</parameter>,
+ <parameter>device</parameter>, <parameter>func</parameter> values. If they
+ match <constant>TRUE</constant> is returned, and <constant>FALSE</constant>
+ if they don't.
+ </para>
+
+ </blockquote></para></blockquote>
+
+ <blockquote><para>
+ <programlisting>
+ Bool xf86ParseIsaBusString(const char *busID);
+ </programlisting>
+ <blockquote><para>
+ Compares a <parameter>BusID</parameter> string with the ISA bus ID string
+ ("ISA" or "ISA:"). If they match <constant>TRUE</constant> is returned,
+ and <constant>FALSE</constant> if they don't.
+ </para>
+
+ </blockquote></para></blockquote>
+
+ <blockquote><para>
+ <programlisting>
+ Bool xf86CheckPciSlot(int bus, int device, int func);
+ </programlisting>
+ <blockquote><para>
+ Checks if the PCI slot <literal remap="tt">bus:device:func</literal> has been
+ claimed. If so, it returns <constant>FALSE</constant>, and otherwise
+ <constant>TRUE</constant>.
+ </para>
+
+ </blockquote></para></blockquote>
+
+ <blockquote><para>
+ <programlisting>
+ int xf86ClaimPciSlot(int bus, int device, int func, DriverPtr drvp,
+ int chipset, GDevPtr dev, Bool active);
+ </programlisting>
+ <blockquote><para>
+ This function is used to claim a PCI slot, allocate the associated
+ entity record and initialise their data structures. The return
+ value is the index of the newly allocated entity record, or
+ <constant>-1</constant> if the claim fails. This function should always
+ succeed if <function>xf86CheckPciSlot()</function> returned
+ <constant>TRUE</constant> for the same PCI slot.
+ </para>
+
+ </blockquote></para></blockquote>
+
+ <blockquote><para>
+ <programlisting>
+ Bool xf86IsPrimaryPci(void);
+ </programlisting>
+ <blockquote><para>
+ This function returns <constant>TRUE</constant> if the primary card is
+ a PCI device, and <constant>FALSE</constant> otherwise.
+ </para>
+
+ </blockquote></para></blockquote>
+
+ <blockquote><para>
+ <programlisting>
+ int xf86ClaimIsaSlot(DriverPtr drvp, int chipset,
+ GDevPtr dev, Bool active);
+ </programlisting>
+ <blockquote><para>
+ This allocates an entity record entity and initialise the data
+ structures. The return value is the index of the newly allocated
+ entity record.
+ </para>
+
+ </blockquote></para></blockquote>
+
+ <blockquote><para>
+ <programlisting>
+ Bool xf86IsPrimaryIsa(void);
+ </programlisting>
+ <blockquote><para>
+ This function returns <constant>TRUE</constant> if the primary card is
+ an ISA (non-PCI) device, and <constant>FALSE</constant> otherwise.
+ </para>
+
+ </blockquote></para></blockquote>
+
+ <para>
+Two helper functions are provided to aid configuring entities:
+ </para>
+
+ <blockquote><para>
+ <programlisting>
+ ScrnInfoPtr xf86ConfigPciEntity(ScrnInfoPtr pScrn,
+ int scrnFlag, int entityIndex,
+ PciChipsets *p_chip,
+ resList res, EntityProc init,
+ EntityProc enter, EntityProc leave,
+ pointer private);
+
+ ScrnInfoPtr xf86ConfigIsaEntity(ScrnInfoPtr pScrn,
+ int scrnFlag, int entityIndex,
+ IsaChipsets *i_chip,
+ resList res, EntityProc init,
+ EntityProc enter, EntityProc leave,
+ pointer private);
+ </programlisting>
+ <blockquote><para>
+ These functions are used to register the non-relocatable resources
+ for an entity, and the optional entity-specific <parameter>Init</parameter>, <parameter>Enter</parameter> and
+ <parameter>Leave</parameter> functions. Usually the list of fixed resources is obtained
+ from the Isa/PciChipsets lists. However an additional list of
+ resources may be passed. Generally this is not required.
+ For active entities a <structname>ScrnInfoRec</structname> is allocated
+ if the <parameter>pScrn</parameter> argument is <constant>NULL</constant>.
+The
+ return value is <constant>TRUE</constant> when successful. The init, enter, leave
+ functions are defined as follows:
+
+ <blockquote><para>
+ <programlisting>
+ typedef void (*EntityProc)(int entityIndex,
+ pointer private);
+ </programlisting>
+ </para></blockquote>
+
+ They are passed the entity index and a pointer to a private scratch
+ area. This can be set up during <function>Probe()</function> and
+ its address can be passed to
+ <function>xf86ConfigIsaEntity()</function> and
+ <function>xf86ConfigPciEntity()</function> as the last argument.
+ </para>
+
+ </blockquote></para></blockquote>
+
+ <para>
+These two helper functions make use of several core functions that are
+available at the driver level:
+
+ <blockquote><para>
+ <programlisting>
+ void xf86ClaimFixedResources(resList list, int entityIndex);
+ </programlisting>
+ <blockquote><para>
+ This function registers the non-relocatable resources which cannot
+ be disabled and which therefore would cause the server to fail
+ immediately if they were found to conflict. It also records
+ non-relocatable but sharable resources for processing after the
+ <function>Probe()</function> phase.
+ </para>
+
+ </blockquote></para></blockquote>
+
+ <blockquote><para>
+ <programlisting>
+ Bool xf86SetEntityFuncs(int entityIndex, EntityProc init,
+ EntityProc enter, EntityProc leave, pointer);
+ </programlisting>
+ <blockquote><para>
+ This function registers with an entity the <parameter>init</parameter>,
+ <parameter>enter</parameter>, <parameter>leave</parameter> functions along
+ with the pointer to their private area.
+ </para>
+
+ </blockquote></para></blockquote>
+
+ <blockquote><para>
+ <programlisting>
+ void xf86AddEntityToScreen(ScrnInfoPtr pScrn, int entityIndex);
+ </programlisting>
+ <blockquote><para>
+ This function associates the entity referenced by
+ <parameter>entityIndex</parameter> with the screen.
+ </para>
+
+ </blockquote></para></blockquote>
+ </para>
+ </sect3>
+
+ <sect3>
+ <title>PreInit Phase</title>
+
+ <para>
+During this phase the remaining resources should be registered.
+<function>PreInit()</function> should call <function>xf86GetEntityInfo()</function>
+to obtain a pointer to an <structname>EntityInfoRec</structname> for each entity
+it is able to drive and check if any resource are listed in its
+<structfield>resources</structfield> field. If resources registered in the Probe
+phase have been rejected in the post-Probe phase
+(<structfield>resources</structfield> is non-<constant>NULL</constant>), then the driver should
+decide if it can continue without using these or if it should fail.
+ </para>
+
+ <blockquote><para>
+ <programlisting>
+ EntityInfoPtr xf86GetEntityInfo(int entityIndex);
+ </programlisting>
+ <blockquote><para>
+ This function returns a pointer to the <structname>EntityInfoRec</structname>
+ referenced by <parameter>entityIndex</parameter>. The returned
+ <structname>EntityInfoRec</structname> should be freed with
+ <function>xfree()</function> when no longer needed.
+ </para>
+
+ </blockquote></para></blockquote>
+
+ <para>
+Several functions are provided to simplify resource registration:
+ <blockquote><para>
+ <programlisting>
+ Bool xf86IsEntityPrimary(int entityIndex);
+ </programlisting>
+ <blockquote><para>
+ This function returns <constant>TRUE</constant> if the entity referenced
+ by <parameter>entityIndex</parameter> is the primary display device (i.e.,
+ the one initialised at boot time and used in text mode).
+ </para>
+
+ </blockquote></para></blockquote>
+
+ <blockquote><para>
+ <programlisting>
+ Bool xf86IsScreenPrimary(int scrnIndex);
+ </programlisting>
+ <blockquote><para>
+ This function returns <constant>TRUE</constant> if the primary entity
+ is registered with the screen referenced by
+ <parameter>scrnIndex</parameter>.
+ </para>
+
+ </blockquote></para></blockquote>
+
+ <blockquote><para>
+ <programlisting>
+ pciVideoPtr xf86GetPciInfoForEntity(int entityIndex);
+ </programlisting>
+ <blockquote><para>
+ This function returns a pointer to the <structname>pciVideoRec</structname>
+ for the specified entity. If the entity is not a PCI device,
+ <constant>NULL</constant> is returned.
+ </para>
+
+ </blockquote></para></blockquote>
+ </para>
+
+ <para>
+The primary function for registration of resources is:
+ <blockquote><para>
+ <programlisting>
+ resPtr xf86RegisterResources(int entityIndex, resList list,
+ int access);
+ </programlisting>
+ <blockquote><para>
+ This function tries to register the resources in
+ <parameter>list</parameter>. If list is <constant>NULL</constant> it tries
+ to determine the resources automatically. This only works for
+ entities that provide a generic way to read out the resource ranges
+ they decode. So far this is only the case for PCI devices. By
+ default the PCI resources are registered as shared
+ (<constant>ResShared</constant>) if the driver wants to set a different
+ access type it can do so by specifying the access flags in the
+ third argument. A value of <constant>0</constant> means to use the
+ default settings. If for any reason the resource broker is not
+ able to register some of the requested resources the function will
+ return a pointer to a list of the failed ones. In this case the
+ driver may be able to move the resource to different locations.
+ In case of PCI bus entities this is done by passing the list of
+ failed resources to <function>xf86ReallocatePciResources()</function>.
+ When the registration succeeds, the return value is
+ <constant>NULL</constant>.
+ </para>
+
+ </blockquote></para></blockquote>
+ </para>
+
+ <blockquote><para>
+ <programlisting>
+ resPtr xf86ReallocatePciResources(int entityIndex, resPtr pRes);
+ </programlisting>
+ <blockquote><para>
+ This function takes a list of PCI resources that need to be
+ reallocated and returns <constant>NULL</constant> when all relocations are
+ successful.
+ <function>xf86RegisterResources()</function> should be called again to
+ register the relocated resources with the broker.
+ If the reallocation fails, a list of the resources that could not be
+ relocated is returned.
+ </para>
+
+ </blockquote></para></blockquote>
+
+<para>
+Two functions are provided to obtain a resource range of a given type:
+ <blockquote><para>
+ <programlisting>
+ resRange xf86GetBlock(long type, memType size,
+ memType window_start, memType window_end,
+ memType align_mask, resPtr avoid);
+ </programlisting>
+ <blockquote><para>
+ This function tries to find a block range of size
+ <parameter>size</parameter> and type <parameter>type</parameter> in a window
+ bound by <parameter>window_start</parameter> and <parameter>window_end</parameter>
+ with the alignment specified in <parameter>align_mask</parameter>.
+ Optionally a list of resource ranges which should be avoided within
+ the window can be supplied. On failure a zero-length range of
+ type <constant>ResEnd</constant> will be returned.
+ </para>
+ </blockquote></para></blockquote>
+
+ <blockquote><para>
+ <programlisting>
+ resRange xf86GetSparse(long type, memType fixed_bits,
+ memType decode_mask, memType address_mask,
+ resPtr avoid);
+ </programlisting>
+ <blockquote><para>
+ This function is like the previous one, but attempts to find a
+ sparse range instead of a block range. Here three values have to
+ be specified: the <parameter>address_mask</parameter> which marks all
+ bits of the mask part of the address, the <parameter>decode_mask</parameter>
+ which masks out the bits which are hardcoded and are therefore
+ not available for relocation and the values of the fixed bits.
+ The function tries to find a base that satisfies the given condition.
+ If the function fails it will return a zero range of type
+ <constant>ResEnd</constant>. Optionally it might be passed a list of
+ resource ranges to avoid.
+ </para>
+
+ </blockquote></para></blockquote>
+ </para>
+
+ <para>
+Some PCI devices are broken in the sense that they return invalid size
+information for a certain resource. In this case the driver can supply
+the correct size and make sure that the resource range allocated for
+the card is large enough to hold the address range decoded by the card.
+The function <function>xf86FixPciResource()</function> can be used to do this:
+ <blockquote><para>
+ <programlisting>
+ Bool xf86FixPciResource(int entityIndex, unsigned int prt,
+ CARD32 alignment, long type);
+ </programlisting>
+ <blockquote><para>
+ This function fixes a PCI resource allocation. The
+ <parameter>prt</parameter> parameter contains the number of the PCI base
+ register that needs to be fixed (<constant>0-5</constant>, and
+ <constant>6</constant> for the BIOS base register). The size is
+ specified by the alignment. Since PCI resources need to span an
+ integral range of size <literal remap="tt">2&circ;n</literal>, the alignm ent also
+ specifies the number of addresses that will be decoded. If the
+ driver specifies a type mask it can override the default type for
+ PCI resources which is <constant>ResShared</constant>. The resource
+ broker needs to know that to find a matching resource range. This
+ function should be called before calling
+ <function>xf86RegisterResources()</function>. The return value is
+ <constant>TRUE</constant> when the function succeeds.
+ </para>
+
+ </blockquote></para></blockquote>
+
+ <blockquote><para>
+ <programlisting>
+ Bool xf86CheckPciMemBase(pciVideoPtr pPci, memType base);
+ </programlisting>
+ <blockquote><para>
+ This function checks that the memory base address specified matches
+ one of the PCI base address register values for the given PCI
+ device. This is mostly used to check that an externally provided
+ base address (e.g., from a config file) matches an actual value
+ allocated to a device.
+ </para>
+
+ </blockquote></para></blockquote>
+ </para>
+
+ <para>
+The driver may replace the generic access control functions for an entity.
+This is done with the <function>xf86SetAccessFuncs()</function>:
+ <blockquote><para>
+ <programlisting>
+ void xf86SetAccessFuncs(EntityInfoPtr pEnt,
+ xf86SetAccessFuncPtr funcs,
+ xf86SetAccessFuncPtr oldFuncs);
+ </programlisting>
+ with:
+ <programlisting>
+ typedef struct {
+ xf86AccessPtr mem;
+ xf86AccessPtr io;
+ xf86AccessPtr io_mem;
+ } xf86SetAccessFuncRec, *xf86SetAccessFuncPtr;
+ </programlisting>
+ <blockquote><para>
+ The driver can pass three functions: one for I/O access, one for
+ memory access and one for combined memory and I/O access. If the
+ memory access and combined access functions are identical the
+ common level assumes that the memory access cannot be controlled
+ independently of I/O access, if the I/O access function and the
+ combined access functions are the same it is assumed that I/O can
+ not be controlled independently. If memory and I/O have to be
+ controlled together all three values should be the same. If a
+ non <constant>NULL</constant> value is passed as third argument it is
+ interpreted as an address where to store the old access record.
+ If the third argument is <constant>NULL</constant> it will be assumed
+ that the generic access should be enabled before replacing the
+ access functions. Otherwise it will be disabled. The driver may
+ enable them itself using the returned values. It should do this
+ from its replacement access functions as the generic access may
+ be disabled by the common level on certain occasions. If replacement
+ functions are specified they must control all resources of the
+ specific type registered for the entity.
+ </para>
+
+ </blockquote></para></blockquote>
+ </para>
+
+ <para>
+To find out if a specific resource range conflicts with another
+resource the <function>xf86ChkConflict()</function> function may be used:
+ <blockquote><para>
+ <programlisting>
+ memType xf86ChkConflict(resRange *rgp, int entityIndex);
+ </programlisting>
+ <blockquote><para>
+ This function checks if the resource range <parameter>rgp</parameter> of
+ for the specified entity conflicts with with another resource.
+ If a conflict is found, the address of the start of the conflict
+ is returned. The return value is zero when there is no conflict.
+ </para>
+
+ </blockquote></para></blockquote>
+ </para>
+
+ <para>
+The OPERATING state properties of previously registered fixed resources
+can be set with the <function>xf86SetOperatingState()</function> function:
+ <blockquote><para>
+ <programlisting>
+ resPtr xf86SetOperatingState(resList list, int entityIndex,
+ int mask);
+ </programlisting>
+ <blockquote><para>
+ This function is used to set the status of a resource during
+ OPERATING state. <parameter>list</parameter> holds a list to which
+ <parameter>mask</parameter> is to be applied. The parameter
+ <parameter>mask</parameter> may have the value <constant>ResUnusedOpr</constant>
+ and <constant>ResDisableOpr</constant>. The first one should be used
+ if a resource isn't used by the driver during OPERATING state
+ although it is decoded by the device, while the latter one indicates
+ that the resource is not decoded during OPERATING state. Note
+ that the resource ranges have to match those specified during
+ registration. If a range has been specified starting at
+ <literal remap="tt">A</literal> and ending at <literal remap="tt">B</literal> and suppose
+ <literal remap="tt">C</literal> us a value satisfying
+ <literal remap="tt">A&nbsp;&lt;&nbsp;C&nbsp;&lt;&nbsp;B</literal> one may not
+ specify the resource range <literal remap="tt">(A,B)</literal> by splitting it
+ into two ranges <literal remap="tt">(A,C)</literal> and <literal remap="tt">(C,B)</literal>.
+ </para>
+
+ </blockquote></para></blockquote>
+ </para>
+
+ <para>
+The following two functions are provided for special cases:
+ <blockquote><para>
+ <programlisting>
+ void xf86RemoveEntityFromScreen(ScrnInfoPtr pScrn, int entityIndex);
+ </programlisting>
+ <blockquote><para>
+ This function may be used to remove an entity from a screen. This
+ only makes sense if a screen has more than one entity assigned or
+ the screen is to be deleted. No test is made if the screen has
+ any entities left.
+ </para>
+
+ </blockquote></para></blockquote>
+
+ <blockquote><para>
+ <programlisting>
+ void xf86DeallocateResourcesForEntity(int entityIndex, long type);
+ </programlisting>
+ <blockquote><para>
+ This function deallocates all resources of a given type registered
+ for a certain entity from the resource broker list.
+ </para>
+
+ </blockquote></para></blockquote>
+ </para>
+
+ </sect3>
+
+ <sect3>
+ <title>ScreenInit Phase</title>
+
+ <para>
+All that is required in this phase is to setup the RAC flags. Note that
+it is also permissible to set these flags up in the PreInit phase. The
+RAC flags are held in the <structfield>racIoFlags</structfield> and <structfield>racMemFlags</structfield> fields of the
+<structname>ScrnInfoRec</structname> for each screen. They specify which graphics operations
+might require the use of shared resources. This can be specified
+separately for memory and I/O resources. The available flags are defined
+in <filename>rac/xf86RAC.h</filename>. They are:
+
+ <variablelist>
+ <varlistentry><term><constant>RAC_FB</constant></term>
+ <listitem><para>
+ for framebuffer operations (including hw acceleration)
+ </para></listitem></varlistentry>
+ <varlistentry><term><constant>RAC_CURSOR</constant></term>
+ <listitem><para>
+ for Cursor operations
+ (??? I'm not sure if we need this for SW cursor it depends
+ on which level the sw cursor is drawn)
+ </para></listitem></varlistentry>
+ <varlistentry><term><constant>RAC_COLORMAP</constant></term>
+ <listitem><para>
+ for colormap operations
+ </para></listitem></varlistentry>
+ <varlistentry><term><constant>RAC_VIEWPORT</constant></term>
+ <listitem><para>
+ for the call to <function>ChipAdjustFrame()</function>
+ </para></listitem></varlistentry>
+ </variablelist>
+
+
+The flags are ORed together.
+ </para>
+ </sect3>
+ </sect2>
+ </sect1>
+
+ <sect1 id="options">
+ <title>Config file <quote>Option</quote> entries</title>
+
+ <para>
+Option entries are permitted in most sections and subsections of the
+config file. There are two forms of option entries:
+
+ <variablelist>
+ <varlistentry><term>Option "option-name"</term>
+ <listitem><para>
+ A boolean option.
+ </para></listitem></varlistentry>
+ <varlistentry><term>Option "option-name" "option-value"</term>
+ <listitem><para>
+ An option with an arbitrary value.
+ </para></listitem></varlistentry>
+ </variablelist>
+ </para>
+
+ <para>
+The option entries are handled by the parser, and a list of the parsed
+options is included with each of the appropriate data structures that
+the drivers have access to. The data structures used to hold the option
+information are opaque to the driver, and a driver must not access the
+option data directly. Instead, the common layer provides a set of
+functions that may be used to access, check and manipulate the option
+data.
+ </para>
+
+ <para>
+First, the low level option handling functions. In most cases drivers
+would not need to use these directly.
+ </para>
+
+ <blockquote><para>
+ <programlisting>
+ pointer xf86FindOption(pointer options, const char *name);
+ </programlisting>
+ <blockquote><para>
+ Takes a list of options and an option name, and returns a handle
+ for the first option entry in the list matching the name. Returns
+ <constant>NULL</constant> if no match is found.
+ </para>
+
+ </blockquote></para></blockquote>
+
+ <blockquote><para>
+ <programlisting>
+ char *xf86FindOptionValue(pointer options, const char *name);
+ </programlisting>
+ <blockquote><para>
+ Takes a list of options and an option name, and returns the value
+ associated with the first option entry in the list matching the
+ name. If the matching option has no value, an empty string
+ (<constant>""</constant>) is returned. Returns <constant>NULL</constant>
+ if no match is found.
+ </para>
+
+ </blockquote></para></blockquote>
+
+ <blockquote><para>
+ <programlisting>
+ void xf86MarkOptionUsed(pointer option);
+ </programlisting>
+ <blockquote><para>
+ Takes a handle for an option, and marks that option as used.
+ </para>
+
+ </blockquote></para></blockquote>
+
+ <blockquote><para>
+ <programlisting>
+ void xf86MarkOptionUsedByName(pointer options, const char *name);
+ </programlisting>
+ <blockquote><para>
+ Takes a list of options and an option name and marks the first
+ option entry in the list matching the name as used.
+ </para>
+
+ </blockquote></para></blockquote>
+
+ <para>
+Next, the higher level functions that most drivers would use.
+ </para>
+ <blockquote><para>
+ <programlisting>
+ void xf86CollectOptions(ScrnInfoPtr pScrn, pointer extraOpts);
+ </programlisting>
+ <blockquote><para>
+ Collect the options from each of the config file sections used by
+ the screen (<parameter>pScrn</parameter>) and return the merged list as
+ <structfield>pScrn-&gt;options</structfield>. This function requires that
+ <structfield>pScrn-&gt;confScreen</structfield>, <structfield>pScrn-&gt;display</structfield>,
+ <structfield>pScrn-&gt;monitor</structfield>,
+ <structfield>pScrn-&gt;numEntities</structfield>, and
+ <structfield>pScrn-&gt;entityList</structfield> are initialised.
+ <parameter>extraOpts</parameter> may optionally be set to an additional
+ list of options to be combined with the others. The order of
+ precedence for options is <parameter>extraOpts</parameter>, display,
+ confScreen, monitor, device.
+ </para>
+
+ </blockquote></para></blockquote>
+
+ <blockquote><para>
+ <programlisting>
+ void xf86ProcessOptions(int scrnIndex, pointer options,
+ OptionInfoPtr optinfo);
+ </programlisting>
+ <blockquote><para>
+ Processes a list of options according to the information in the
+ array of <structname>OptionInfoRecs</structname> (<parameter>optinfo</parameter>).
+ The resulting information is stored in the <structfield>value</structfield>
+ fields of the appropriate <parameter>optinfo</parameter> entries. The
+ <structfield>found</structfield> fields are set to <constant>TRUE</constant>
+ when an option with a value of the correct type if found, and
+ <constant>FALSE</constant> otherwise. The <structfield>type</structfield> field
+ is used to determine the expected value type for each option.
+ Each option in the list of options for which there is a name match
+ (but not necessarily a value type match) is marked as used.
+ Warning messages are printed when option values don't match the
+ types specified in the optinfo data.
+ </para>
+
+ <para>
+ NOTE: If this function is called before a driver's screen number
+ is known (e.g., from the <function>ChipProbe()</function> function) a
+ <parameter>scrnIndex</parameter> value of <constant>-1</constant> should be
+ used.
+ </para>
+
+ <para>
+ NOTE 2: Given that this function stores into the
+ <literal remap="tt">OptionInfoRecs</literal> pointed to by <parameter>optinfo</parameter>,
+ the caller should ensure the <literal remap="tt">OptionInfoRecs</literal> are
+ (re-)initialised before the call, especially if the caller expects
+ to use the predefined option values as defaults.
+ </para>
+
+ <para>
+ The <structname>OptionInfoRec</structname> is defined as follows:
+
+ <programlisting>
+ typedef struct {
+ double freq;
+ int units;
+ } OptFrequency;
+
+ typedef union {
+ unsigned long num;
+ char * str;
+ double realnum;
+ Bool bool;
+ OptFrequency freq;
+ } ValueUnion;
+
+ typedef enum {
+ OPTV_NONE = 0,
+ OPTV_INTEGER,
+ OPTV_STRING, /* a non-empty string */
+ OPTV_ANYSTR, /* Any string, including an empty one */
+ OPTV_REAL,
+ OPTV_BOOLEAN,
+ OPTV_PERCENT,
+ OPTV_FREQ
+ } OptionValueType;
+
+ typedef enum {
+ OPTUNITS_HZ = 1,
+ OPTUNITS_KHZ,
+ OPTUNITS_MHZ
+ } OptFreqUnits;
+
+ typedef struct {
+ int token;
+ const char* name;
+ OptionValueType type;
+ ValueUnion value;
+ Bool found;
+ } OptionInfoRec, *OptionInfoPtr;
+ </programlisting>
+ </para>
+ <para>
+ <constant>OPTV_FREQ</constant> can be used for options values that are
+ frequencies. These values are a floating point number with an
+ optional unit name appended. The unit name can be one of "Hz",
+ "kHz", "k", "MHz", "M". The multiplier associated with the unit
+ is stored in <structfield>freq.units</structfield>, and the scaled frequency
+ is stored in <structfield>freq.freq</structfield>. When no unit is specified,
+ <structfield>freq.units</structfield> is set to <constant>0</constant>, and
+ <structfield>freq.freq</structfield> is unscaled.
+ </para>
+
+ <para>
+ <constant>OPTV_PERCENT</constant> can be used for option values that are
+ specified in percent (e.g. "20%"). These values are a floating point
+ number with a percent sign appended. If the percent sign is missing,
+ the parser will fail to match the value.
+ </para>
+
+ <para>
+ Typical usage is to setup an array of
+ <structname>OptionInfoRec</structname>s with all fields initialised.
+ The <structfield>value</structfield> and <structfield>found</structfield> fields get
+ set by <function>xf86ProcessOptions()</function>. For cases where the
+ value parsing is more complex, the driver should specify
+ <constant>OPTV_STRING</constant>, and parse the string itself. An
+ example of using this option handling is included in the
+ <link linkend="sample">Sample Driver</link> section.
+ </para>
+
+ </blockquote></para></blockquote>
+
+ <blockquote><para>
+ <programlisting>
+ void xf86ShowUnusedOptions(int scrnIndex, pointer options);
+ </programlisting>
+ <blockquote><para>
+ Prints out warning messages for each option in the list of options
+ that isn't marked as used. This is intended to show options that
+ the driver hasn't recognised. It would normally be called near
+ the end of the <function>ChipScreenInit()</function> function, but only
+ when <code>serverGeneration&nbsp;==&nbsp;1</code>
+ </para>
+ </blockquote></para></blockquote>
+
+ <blockquote><para>
+ <programlisting>
+ OptionInfoPtr xf86TokenToOptinfo(const OptionInfoRec *table,
+ int token);
+ </programlisting>
+ <blockquote><para>
+ Returns a pointer to the <structname>OptionInfoRec</structname> in
+ <parameter>table</parameter> with a token field matching
+ <parameter>token</parameter>. Returns <constant>NULL</constant> if no match
+ is found.
+ </para>
+
+ </blockquote></para></blockquote>
+
+ <blockquote><para>
+ <programlisting>
+ Bool xf86IsOptionSet(const OptionInfoRec *table, int token);
+ </programlisting>
+ <blockquote><para>
+ Returns the <literal remap="tt">found</literal> field of the
+ <structname>OptionInfoRec</structname> in <parameter>table</parameter> with a
+ <structfield>token</structfield> field matching <parameter>token</parameter>. This
+ can be used for options of all types. Note that for options of
+ type <constant>OPTV_BOOLEAN</constant>, it isn't sufficient to check
+ this to determine the value of the option. Returns
+ <constant>FALSE</constant> if no match is found.
+ </para>
+
+ </blockquote></para></blockquote>
+
+ <blockquote><para>
+ <programlisting>
+ char *xf86GetOptValString(const OptionInfoRec *table, int token);
+ </programlisting>
+ <blockquote><para>
+ Returns the <structfield>value.str</structfield> field of the
+ <structname>OptionInfoRec</structname> in <parameter>table</parameter> with a
+ token field matching <parameter>token</parameter>. Returns
+ <constant>NULL</constant> if no match is found.
+ </para>
+
+ </blockquote></para></blockquote>
+
+ <blockquote><para>
+ <programlisting>
+ Bool xf86GetOptValInteger(const OptionInfoRec *table, int token,
+
+ int *value);
+ </programlisting>
+ <blockquote><para>
+ Returns via <parameter>*value</parameter> the <structfield>value.num</structfield>
+ field of the <structname>OptionInfoRec</structname> in <parameter>table</parameter>
+ with a <structfield>token</structfield> field matching <parameter>token</parameter>.
+ <parameter>*value</parameter> is only changed when a match is found so
+ it can be safely initialised with a default prior to calling this
+ function. The function return value is as for
+ <function>xf86IsOptionSet()</function>.
+ </para>
+
+ </blockquote></para></blockquote>
+
+ <blockquote><para>
+ <programlisting>
+ Bool xf86GetOptValULong(const OptionInfoRec *table, int token,
+ unsigned long *value);
+ </programlisting>
+ <blockquote><para>
+ Like <function>xf86GetOptValInteger()</function>, except the value is
+ treated as an <type>unsigned long</type>.
+ </para>
+
+ </blockquote></para></blockquote>
+
+ <blockquote><para>
+ <programlisting>
+ Bool xf86GetOptValReal(const OptionInfoRec *table, int token,
+ double *value);
+ </programlisting>
+ <blockquote><para>
+ Like <function>xf86GetOptValInteger()</function>, except that
+ <structfield>value.realnum</structfield> is used.
+ </para>
+
+ </blockquote></para></blockquote>
+
+ <blockquote><para>
+ <programlisting>
+ Bool xf86GetOptValFreq(const OptionInfoRec *table, int token,
+ OptFreqUnits expectedUnits, double *value);
+ </programlisting>
+ <blockquote><para>
+ Like <function>xf86GetOptValInteger()</function>, except that the
+ <structfield>value.freq</structfield> data is returned. The frequency value
+ is scaled to the units indicated by <parameter>expectedUnits</parameter>.
+ The scaling is exact when the units were specified explicitly in
+ the option's value. Otherwise, the <parameter>expectedUnits</parameter>
+ field is used as a hint when doing the scaling. In this case,
+ values larger than <constant>1000</constant> are assumed to have be
+ specified in the next smallest units. For example, if the Option
+ value is "10000" and expectedUnits is <constant>OPTUNITS_MHZ</constant>,
+ the value returned is <constant>10</constant>.
+ </para>
+
+ </blockquote></para></blockquote>
+
+ <blockquote><para>
+ <programlisting>
+ Bool xf86GetOptValBool(const OptionInfoRec *table, int token, Bool *value);
+ </programlisting>
+ <blockquote><para>
+ This function is used to check boolean options
+ (<constant>OPTV_BOOLEAN</constant>). If the function return value is
+ <constant>FALSE</constant>, it means the option wasn't set. Otherwise
+ <parameter>*value</parameter> is set to the boolean value indicated by
+ the option's value. No option <parameter>value</parameter> is interpreted
+ as <constant>TRUE</constant>. Option values meaning <constant>TRUE</constant>
+ are "1", "yes", "on", "true", and option values meaning
+ <constant>FALSE</constant> are "0", "no", "off", "false". Option names
+ both with the "no" prefix in their names, and with that prefix
+ removed are also checked and handled in the obvious way.
+ <parameter>*value</parameter> is not changed when the option isn't present.
+ It should normally be set to a default value before calling this
+ function.
+ </para>
+
+ </blockquote></para></blockquote>
+
+ <blockquote><para>
+ <programlisting>
+ Bool xf86ReturnOptValBool(const OptionInfoRec *table, int token, Bool def);
+ </programlisting>
+ <blockquote><para>
+ This function is used to check boolean options
+ (<constant>OPTV_BOOLEAN</constant>). If the option is set, its value
+ is returned. If the options is not set, the default value specified
+ by <parameter>def</parameter> is returned. The option interpretation is
+ the same as for <function>xf86GetOptValBool()</function>.
+ </para>
+
+ </blockquote></para></blockquote>
+
+ <blockquote><para>
+ <programlisting>
+ int xf86NameCmp(const char *s1, const char *s2);
+ </programlisting>
+ <blockquote><para>
+ This function should be used when comparing strings from the config
+ file with expected values. It works like <function>strcmp()</function>,
+ but is not case sensitive and space, tab, and <quote><literal>_</literal></quote> characters
+ are ignored in the comparison. The use of this function isn't
+ restricted to parsing option values. It may be used anywhere
+ where this functionality required.
+ </para>
+
+ </blockquote></para></blockquote>
+ </sect1>
+
+ <sect1>
+ <title>Modules, Drivers, Include Files and Interface Issues</title>
+
+ <para>
+NOTE: this section is incomplete.
+ </para>
+
+
+ <sect2>
+ <title>Include files</title>
+
+ <para>
+The following include files are typically required by video drivers:
+
+ <blockquote><para>
+ All drivers should include these:
+ <literallayout><filename>
+ "xf86.h"
+ "xf86_OSproc.h"
+ "xf86_ansic.h"
+ "xf86Resources.h"
+ </filename></literallayout>
+ Wherever inb/outb (and related things) are used the following should be
+ included:
+ <literallayout><filename>
+ "compiler.h"
+ </filename></literallayout>
+ Note: in drivers, this must be included after <filename>"xf86_ansic.h"</filename>.
+ </para>
+
+ <para>
+ Drivers that need to access PCI vendor/device definitions need this:
+ <literallayout><filename>
+ "xf86PciInfo.h"
+ </filename></literallayout>
+ </para>
+
+ <para>
+ Drivers that need to access the PCI config space need this:
+ <literallayout><filename>
+ "xf86Pci.h"
+ </filename></literallayout>
+ </para>
+
+ <para>
+ Drivers that initialise a SW cursor need this:
+ <literallayout><filename>
+ "mipointer.h"
+ </filename></literallayout>
+ </para>
+
+ <para>
+ All drivers implementing backing store need this:
+ <literallayout><filename>
+ "mibstore.h"
+ </filename></literallayout>
+ </para>
+
+ <para>
+ All drivers using the mi colourmap code need this:
+ <literallayout><filename>
+ "micmap.h"
+ </filename></literallayout>
+ </para>
+
+ <para>
+ If a driver uses the vgahw module, it needs this:
+ <literallayout><filename>
+ "vgaHW.h"
+ </filename></literallayout>
+ </para>
+
+ <para>
+ Drivers supporting VGA or Hercules monochrome screens need:
+ <literallayout><filename>
+ "xf1bpp.h"
+ </filename></literallayout>
+ </para>
+
+ <para>
+ Drivers supporting VGA or EGC 16-colour screens need:
+ <literallayout><filename>
+ "xf4bpp.h"
+ </filename></literallayout>
+ </para>
+
+ <para>
+ Drivers using cfb need:
+ <programlisting>
+ #define PSZ 8
+ #include "cfb.h"
+ #undef PSZ
+ </programlisting>
+ </para>
+
+ <para>
+ Drivers supporting bpp 16, 24 or 32 with cfb need one or more of:
+ <literallayout><filename>
+ "cfb16.h"
+ "cfb24.h"
+ "cfb32.h"
+ </filename></literallayout>
+ </para>
+
+ <para>
+ If a driver uses XAA, it needs these:
+ <literallayout><filename>
+ "xaa.h"
+ "xaalocal.h"
+ </filename></literallayout>
+ </para>
+
+ <para>
+ If a driver uses the fb manager, it needs this:
+ <literallayout><filename>
+ "xf86fbman.h"
+ </filename></literallayout>
+ </para>
+ </blockquote>
+ </para>
+
+ <para>
+Non-driver modules should include <filename>"xf86_ansic.h"</filename> to get the correct
+wrapping of ANSI C/libc functions.
+ </para>
+
+ <para>
+All modules must NOT include any system include files, or the following:
+
+ <literallayout><filename>
+ "xf86Priv.h"
+ "xf86Privstr.h"
+ "xf86_OSlib.h"
+ "Xos.h"
+ </filename></literallayout>
+ </para>
+
+ <para>
+In addition, "xf86_libc.h" must not be included explicitly. It is
+included implicitly by "xf86_ansic.h".
+ </para>
+
+ </sect2>
+ </sect1>
+
+ <sect1>
+ <title>Offscreen Memory Manager</title>
+
+ <para>
+Management of offscreen video memory may be handled by the XFree86
+framebuffer manager. Once the offscreen memory manager is running,
+drivers or extensions may allocate, free or resize areas of offscreen
+video memory using the following functions (definitions taken from
+<filename>xf86fbman.h</filename>):
+
+ <programlisting>
+ typedef struct _FBArea {
+ ScreenPtr pScreen;
+ BoxRec box;
+ int granularity;
+ void (*MoveAreaCallback)(struct _FBArea*, struct _FBArea*)
+ void (*RemoveAreaCallback)(struct _FBArea*)
+ DevUnion devPrivate;
+ } FBArea, *FBAreaPtr;
+
+ typedef void (*MoveAreaCallbackProcPtr)(FBAreaPtr from, FBAreaPtr to)
+ typedef void (*RemoveAreaCallbackProcPtr)(FBAreaPtr)
+
+ FBAreaPtr xf86AllocateOffscreenArea (
+ ScreenPtr pScreen,
+ int width, int height,
+ int granularity,
+ MoveAreaCallbackProcPtr MoveAreaCallback,
+ RemoveAreaCallbackProcPtr RemoveAreaCallback,
+ pointer privData
+ )
+
+ void xf86FreeOffscreenArea (FBAreaPtr area)
+
+ Bool xf86ResizeOffscreenArea (
+ FBAreaPtr area
+ int w, int h
+ )
+ </programlisting>
+ </para>
+
+ <para>
+The function:
+ <programlisting>
+ Bool xf86FBManagerRunning(ScreenPtr pScreen);
+ </programlisting>
+
+can be used by an extension to check if the driver has initialized
+the memory manager. The manager is not available if this returns
+<constant>FALSE</constant> and the functions above will all fail.
+ </para>
+
+
+ <para>
+<function>xf86AllocateOffscreenArea()</function> can be used to request a
+rectangle of dimensions <parameter>width</parameter>&nbsp;&times;&nbsp;<parameter>height</parameter>
+(in pixels) from unused offscreen memory. <parameter>granularity</parameter>
+specifies that the leftmost edge of the rectangle must lie on some
+multiple of <parameter>granularity</parameter> pixels. A granularity of zero
+means the same thing as a granularity of one - no alignment preference.
+A <parameter>MoveAreaCallback</parameter> can be provided to notify the requester
+when the offscreen area is moved. If no <parameter>MoveAreaCallback</parameter>
+is supplied then the area is considered to be immovable. The
+<parameter>privData</parameter> field will be stored in the manager's internal
+structure for that allocated area and will be returned to the requester
+in the <parameter>FBArea</parameter> passed via the
+<parameter>MoveAreaCallback</parameter>. An optional
+<parameter>RemoveAreaCallback</parameter> is provided. If the driver provides
+this it indicates that the area should be allocated with a lower priority.
+Such an area may be removed when a higher priority request (one that
+doesn't have a <parameter>RemoveAreaCallback</parameter>) is made. When this
+function is called, the driver will have an opportunity to do whatever
+cleanup it needs to do to deal with the loss of the area, but it must
+finish its cleanup before the function exits since the offscreen memory
+manager will free the area immediately after.
+ </para>
+
+ <para>
+<function>xf86AllocateOffscreenArea()</function> returns <constant>NULL</constant>
+if it was unable to allocate the requested area. When no longer needed,
+areas should be freed with <function>xf86FreeOffscreenArea()</function>.
+ </para>
+
+ <para>
+<function>xf86ResizeOffscreenArea()</function> resizes an existing
+<literal remap="tt">FBArea</literal>. <function>xf86ResizeOffscreenArea()</function>
+returns <constant>TRUE</constant> if the resize was successful. If
+<function>xf86ResizeOffscreenArea()</function> returns <constant>FALSE</constant>,
+the original <literal remap="tt">FBArea</literal> is left unmodified. Resizing an
+area maintains the area's original <literal remap="tt">granularity</literal>,
+<literal remap="tt">devPrivate</literal>, and <literal remap="tt">MoveAreaCallback</literal>.
+<function>xf86ResizeOffscreenArea()</function> has considerably less overhead
+than freeing the old area then reallocating the new size, so it should
+be used whenever possible.
+ </para>
+
+ <para>
+The function:
+ <programlisting>
+ Bool xf86QueryLargestOffscreenArea(
+ ScreenPtr pScreen,
+ int *width, int *height,
+ int granularity,
+ int preferences,
+ int priority
+ );
+ </programlisting>
+
+is provided to query the width and height of the largest single
+<structname>FBArea</structname> allocatable given a particular priority.
+<parameter>preferences</parameter> can be one of the following to indicate
+whether width, height or area should be considered when determining
+which is the largest single <structname>FBArea</structname> available.
+
+ <programlisting>
+ FAVOR_AREA_THEN_WIDTH
+ FAVOR_AREA_THEN_HEIGHT
+ FAVOR_WIDTH_THEN_AREA
+ FAVOR_HEIGHT_THEN_AREA
+ </programlisting>
+ </para>
+
+ <para>
+<parameter>priority</parameter> is one of the following:
+
+ <blockquote>
+ <para>
+ <constant>PRIORITY_LOW</constant>
+ <blockquote><para>
+ Return the largest block available without stealing anyone else's
+ space. This corresponds to the priority of allocating a
+ <structname>FBArea</structname> when a <function>RemoveAreaCallback</function>
+ is provided.
+ </para></blockquote>
+ </para>
+
+ <para>
+ <constant>PRIORITY_NORMAL</constant>
+ <blockquote><para>
+ Return the largest block available if it is acceptable to steal a
+ lower priority area from someone. This corresponds to the priority
+ of allocating a <structname>FBArea</structname> without providing a
+ <function>RemoveAreaCallback</function>.
+ </para></blockquote>
+ </para>
+
+ <para>
+ <constant>PRIORITY_EXTREME</constant>
+ <blockquote><para>
+ Return the largest block available if all <structname>FBArea</structname>s
+ that aren't locked down were expunged from memory first. This
+ corresponds to any allocation made directly after a call to
+ <function>xf86PurgeUnlockedOffscreenAreas()</function>.
+ </para></blockquote>
+ </para>
+
+ </blockquote>
+ </para>
+
+
+ <para>
+The function:
+
+ <programlisting>
+ Bool xf86PurgeUnlockedOffscreenAreas(ScreenPtr pScreen);
+ </programlisting>
+
+is provided as an extreme method to free up offscreen memory. This
+will remove all removable <structname>FBArea</structname> allocations.
+ </para>
+
+
+ <para>
+Initialization of the XFree86 framebuffer manager is done via
+
+ <programlisting>
+ Bool xf86InitFBManager(ScreenPtr pScreen, BoxPtr FullBox);
+ </programlisting>
+
+<parameter>FullBox</parameter> represents the area of the framebuffer that the
+manager is allowed to manage. This is typically a box with a width of
+<structfield>pScrn-&gt;displayWidth</structfield> and a height of as many lines as
+can be fit within the total video memory, however, the driver can reserve
+areas at the extremities by passing a smaller area to the manager.
+ </para>
+
+ <para>
+<function>xf86InitFBManager()</function> must be called before XAA is
+initialized since XAA uses the manager for it's pixmap cache.
+ </para>
+
+ <para>
+An alternative function is provided to allow the driver to initialize
+the framebuffer manager with a Region rather than a box.
+
+ <programlisting>
+ Bool xf86InitFBManagerRegion(ScreenPtr pScreen,
+ RegionPtr FullRegion);
+ </programlisting>
+
+<function>xf86InitFBManagerRegion()</function>, unlike
+<function>xf86InitFBManager()</function>, does not remove the area used for
+the visible screen so that area should not be included in the region
+passed to the function. <function>xf86InitFBManagerRegion()</function> is
+useful when non-contiguous areas are available to be managed, and is
+required when multiple framebuffers are stored in video memory (as in
+the case where an overlay of a different depth is stored as a second
+framebuffer in offscreen memory).
+ </para>
+
+ </sect1>
+
+ <sect1 id="cmap">
+ <title>Colormap Handling</title>
+
+ <para>
+A generic colormap handling layer is provided within the XFree86 common
+layer. This layer takes care of most of the details, and only requires
+a function from the driver that loads the hardware palette when required.
+To use the colormap layer, a driver calls the
+<function>xf86HandleColormaps()</function> function.
+
+ <blockquote><para>
+ <programlisting>
+ Bool xf86HandleColormaps(ScreenPtr pScreen, int maxColors,
+ int sigRGBbits, LoadPaletteFuncPtr loadPalette,
+ SetOverscanFuncPtr setOverscan,
+ unsigned int flags);
+ </programlisting>
+ <blockquote><para>
+ This function must be called after the default colormap has been
+ initialised. The <structfield>pScrn-&gt;gamma</structfield> field must also
+ be initialised, preferably by calling <function>xf86SetGamma()</function>.
+ <parameter>maxColors</parameter> is the number of entries in the palette.
+ <parameter>sigRGBbits</parameter> is the size in bits of each color
+ component in the DAC's palette. <parameter>loadPalette</parameter>
+ is a driver-provided function for loading a colormap into the
+ hardware, and is described below. <parameter>setOverscan</parameter> is
+ an optional function that may be provided when the overscan color
+ is an index from the standard LUT and when it needs to be adjusted
+ to keep it as close to black as possible. The
+ <parameter>setOverscan</parameter> function programs the overscan index.
+ It shouldn't normally be used for depths other than 8.
+ <parameter>setOverscan</parameter> should be set to <constant>NULL</constant>
+ when it isn't needed. <parameter>flags</parameter> may be set to the
+ following (which may be ORed together):
+
+ <variablelist>
+ <varlistentry>
+ <term><constant>CMAP_PALETTED_TRUECOLOR</constant></term>
+ <listitem><para>
+ the TrueColor visual is paletted and is
+ just a special case of DirectColor.
+ This flag is only valid for
+ <code>bpp&nbsp;&gt;&nbsp;8</code>.
+
+ </para></listitem></varlistentry>
+ <varlistentry>
+ <term><constant>CMAP_RELOAD_ON_MODE_SWITCH</constant></term>
+ <listitem><para>
+ reload the colormap automatically
+ after mode switches. This is useful
+ for when the driver is resetting the
+ hardware during mode switches and
+ corrupting or erasing the hardware
+ palette.
+
+ </para></listitem></varlistentry>
+ <varlistentry>
+ <term><constant>CMAP_LOAD_EVEN_IF_OFFSCREEN</constant></term>
+ <listitem><para>
+ reload the colormap even if the screen
+ is switched out of the server's VC.
+ The palette is <emphasis>not</emphasis> reloaded when
+ the screen is switched back in, nor after
+ mode switches. This is useful when the
+ driver needs to keep track of palette
+ changes.
+
+ </para></listitem></varlistentry>
+ </variablelist>
+ </para>
+
+ <para>
+ The colormap layer normally reloads the palette after VT enters so it
+ is not necessary for the driver to save and restore the palette
+ when switching VTs. The driver must, however, still save the
+ initial palette during server start up and restore it during
+ server exit.
+ </para>
+
+ </blockquote></para></blockquote>
+
+ <blockquote><para>
+ <programlisting>
+ void LoadPalette(ScrnInfoPtr pScrn, int numColors, int *indices,
+ LOCO *colors, VisualPtr pVisual);
+ </programlisting>
+ <blockquote><para>
+ <function>LoadPalette()</function> is a driver-provided function for
+ loading a colormap into hardware. <parameter>colors</parameter> is the
+ array of RGB values that represent the full colormap.
+ <parameter>indices</parameter> is a list of index values into the colors
+ array. These indices indicate the entries that need to be updated.
+ <parameter>numColors</parameter> is the number of the indices to be
+ updated.
+ </para>
+
+ </blockquote></para></blockquote>
+
+ <blockquote><para>
+ <programlisting>
+ void SetOverscan(ScrnInfoPtr pScrn, int overscan);
+ </programlisting>
+ <blockquote><para>
+ <function>SetOverscan()</function> is a driver-provided function for
+ programming the <parameter>overscan</parameter> index. As described
+ above, it is normally only appropriate for LUT modes where all
+ colormap entries are available for the display, but where one of
+ them is also used for the overscan (typically 8bpp for VGA compatible
+ LUTs). It isn't required in cases where the overscan area is
+ never visible.
+ </para>
+
+ </blockquote></para>
+ </blockquote></para>
+
+ </sect1>
+
+ <sect1>
+ <title>DPMS Extension</title>
+
+ <para>
+Support code for the DPMS extension is included in the XFree86 common layer.
+This code provides an interface between the main extension code, and a means
+for drivers to initialise DPMS when they support it. One function is
+available to drivers to do this initialisation, and it is always available,
+even when the DPMS extension is not supported by the core server (in
+which case it returns a failure result).
+ </para>
+
+ <blockquote><para>
+ <programlisting>
+ Bool xf86DPMSInit(ScreenPtr pScreen, DPMSSetProcPtr set, int flags);
+ </programlisting>
+ <blockquote><para>
+ This function registers a driver's DPMS level programming function
+ <parameter>set</parameter>. It also checks
+ <structfield>pScrn-&gt;options</structfield> for the "dpms" option, and when
+ present marks DPMS as being enabled for that screen. The
+ <parameter>set</parameter> function is called whenever the DPMS level
+ changes, and is used to program the requested level.
+ <parameter>flags</parameter> is currently not used, and should be
+ <constant>0</constant>. If the initialisation fails for any reason,
+ including when there is no DPMS support in the core server, the
+ function returns <constant>FALSE</constant>.
+ </para>
+
+ </blockquote></para></blockquote>
+
+
+ <para>
+Drivers that implement DPMS support must provide the following function,
+that gets called when the DPMS level is changed:
+
+
+ <blockquote><para>
+ <programlisting>
+ void ChipDPMSSet(ScrnInfoPtr pScrn, int level, int flags);
+ </programlisting>
+ <blockquote><para>
+ Program the DPMS level specified by <parameter>level</parameter>. Valid
+ values of <parameter>level</parameter> are <constant>DPMSModeOn</constant>,
+ <constant>DPMSModeStandby</constant>, <constant>DPMSModeSuspend</constant>,
+ <constant>DPMSModeOff</constant>. These values are defined in
+ <filename>"extensions/dpms.h"</filename>.
+ </para>
+
+ </blockquote></para></blockquote>
+ </para>
+
+ </sect1>
+
+ <sect1>
+ <title>DGA Extension</title>
+
+ <para>
+Drivers can support the XFree86 Direct Graphics Architecture (DGA) by
+filling out a structure of function pointers and a list of modes and
+passing them to DGAInit.
+ </para>
+
+ <blockquote><para>
+ <programlisting>
+ Bool DGAInit(ScreenPtr pScreen, DGAFunctionPtr funcs,
+ DGAModePtr modes, int num);
+
+/** The DGAModeRec **/
+
+typedef struct {
+ int num;
+ DisplayModePtr mode;
+ int flags;
+ int imageWidth;
+ int imageHeight;
+ int pixmapWidth;
+ int pixmapHeight;
+ int bytesPerScanline;
+ int byteOrder;
+ int depth;
+ int bitsPerPixel;
+ unsigned long red_mask;
+ unsigned long green_mask;
+ unsigned long blue_mask;
+ int viewportWidth;
+ int viewportHeight;
+ int xViewportStep;
+ int yViewportStep;
+ int maxViewportX;
+ int maxViewportY;
+ int viewportFlags;
+ int offset;
+ unsigned char *address;
+ int reserved1;
+ int reserved2;
+} DGAModeRec, *DGAModePtr;
+ </programlisting>
+
+ <variablelist>
+ <varlistentry>
+ <term><structfield>num</structfield></term>
+ <listitem><para>
+ Can be ignored. The DGA DDX will assign these numbers.
+ </para></listitem></varlistentry>
+
+ <varlistentry>
+ <term><structfield>mode</structfield></term>
+ <listitem><para>
+ A pointer to the <structname>DisplayModeRec</structname> for this mode.
+ </para></listitem></varlistentry>
+
+ <varlistentry>
+ <term><structfield>flags</structfield></term>
+ <listitem><para>
+ The following flags are defined and may be OR'd together:
+
+ <variablelist>
+ <varlistentry>
+ <term><constant>DGA_CONCURRENT_ACCESS</constant></term>
+ <listitem><para>
+ Indicates that the driver supports concurrent graphics
+ accelerator and linear framebuffer access.
+
+ </para></listitem></varlistentry>
+
+ <varlistentry>
+ <term><constant>DGA_FILL_RECT
+ DGA_BLIT_RECT
+ DGA_BLIT_RECT_TRANS</constant></term>
+ <listitem><para>
+ Indicates that the driver supports the FillRect, BlitRect
+ or BlitTransRect functions in this mode.
+
+ </para></listitem></varlistentry>
+
+ <varlistentry>
+ <term><constant>DGA_PIXMAP_AVAILABLE</constant></term>
+ <listitem><para>
+ Indicates that Xlib may be used on the framebuffer.
+ This flag will usually be set unless the driver wishes
+ to prohibit this for some reason.
+
+ </para></listitem></varlistentry>
+
+ <varlistentry>
+ <term><constant>DGA_INTERLACED
+ DGA_DOUBLESCAN</constant></term>
+ <listitem><para>
+ Indicates that these are interlaced or double scan modes.
+
+ </para></listitem></varlistentry>
+ </variablelist>
+ </para></listitem></varlistentry>
+
+ <varlistentry>
+ <term><structfield>imageWidth
+ imageHeight</structfield></term>
+ <listitem><para>
+ These are the dimensions of the linear framebuffer
+ accessible by the client.
+
+ </para></listitem></varlistentry>
+
+ <varlistentry>
+ <term><structfield>pixmapWidth
+ pixmapHeight</structfield></term>
+ <listitem><para>
+ These are the dimensions of the area of the
+ framebuffer accessible by the graphics accelerator.
+
+ </para></listitem></varlistentry>
+
+ <varlistentry>
+ <term><structfield>bytesPerScanline</structfield></term>
+ <listitem><para>
+ Pitch of the framebuffer in bytes.
+
+ </para></listitem></varlistentry>
+
+ <varlistentry>
+ <term><structfield>byteOrder</structfield></term>
+ <listitem><para>
+ Usually the same as
+ <structfield>pScrn-&gt;imageByteOrder</structfield>.
+
+ </para></listitem></varlistentry>
+
+ <varlistentry>
+ <term><structfield>depth</structfield></term>
+ <listitem><para>
+ The depth of the framebuffer in this mode.
+
+ </para></listitem></varlistentry>
+
+ <varlistentry>
+ <term><structfield>bitsPerPixel</structfield></term>
+ <listitem><para>
+ The number of bits per pixel in this mode.
+
+ </para></listitem></varlistentry>
+
+ <varlistentry>
+ <term><structfield>red_mask</structfield></term>
+ <term><structfield>green_mask</structfield></term>
+ <term><structfield>blue_mask</structfield></term>
+ <listitem><para>
+ The RGB masks for this mode, if applicable.
+
+ </para></listitem></varlistentry>
+
+ <varlistentry>
+ <term><structfield>viewportWidth</structfield></term>
+ <term><structfield>viewportHeight</structfield></term>
+ <listitem><para>
+ Dimensions of the visible part of the framebuffer.
+ Usually <structfield>mode-&gt;HDisplay</structfield> and
+ <structfield>mode-&gt;VDisplay</structfield>.
+
+ </para></listitem></varlistentry>
+
+ <varlistentry>
+ <term><structfield>xViewportStep
+ yViewportStep</structfield></term>
+ <listitem><para>
+ The granularity of x and y viewport positions that
+ the driver supports in this mode.
+
+ </para></listitem></varlistentry>
+
+ <varlistentry>
+ <term><structfield>maxViewportX
+ maxViewportY</structfield></term>
+ <listitem><para>
+ The maximum viewport position supported by the
+ driver in this mode.
+ </para></listitem></varlistentry>
+
+ <varlistentry>
+ <term><structfield>viewportFlags</structfield></term>
+ <listitem><para>
+ The following may be OR'd together:
+
+ <variablelist>
+ <varlistentry>
+ <term><constant>DGA_FLIP_IMMEDIATE</constant></term>
+ <listitem><para>
+ The driver supports immediate viewport changes.
+ </para></listitem></varlistentry>
+
+ <varlistentry>
+ <term><constant>DGA_FLIP_RETRACE</constant></term>
+
+ <listitem><para>
+ The driver supports viewport changes at retrace.
+ </para></listitem></varlistentry>
+ </variablelist>
+ </para></listitem></varlistentry>
+
+ <varlistentry>
+ <term><structfield>offset</structfield></term>
+ <listitem><para>
+ The offset into the linear framebuffer that corresponds to
+ pixel (0,0) for this mode.
+ </para></listitem></varlistentry>
+
+ <varlistentry>
+ <term><structfield>address</structfield></term>
+ <listitem><para>
+ The virtual address of the framebuffer as mapped by the driver.
+ This is needed when DGA_PIXMAP_AVAILABLE is set.
+ </para></listitem></varlistentry>
+
+ </variablelist>
+
+ <programlisting>
+/** The DGAFunctionRec **/
+
+typedef struct {
+ Bool (*OpenFramebuffer)(
+ ScrnInfoPtr pScrn,
+ char **name,
+ unsigned char **mem,
+ int *size,
+ int *offset,
+ int *extra
+ );
+ void (*CloseFramebuffer)(ScrnInfoPtr pScrn);
+ Bool (*SetMode)(ScrnInfoPtr pScrn, DGAModePtr pMode);
+ void (*SetViewport)(ScrnInfoPtr pScrn, int x, int y, int flags);
+ int (*GetViewport)(ScrnInfoPtr pScrn);
+ void (*Sync)(ScrnInfoPtr);
+ void (*FillRect)(
+ ScrnInfoPtr pScrn,
+ int x, int y, int w, int h,
+ unsigned long color
+ );
+ void (*BlitRect)(
+ ScrnInfoPtr pScrn,
+ int srcx, int srcy,
+ int w, int h,
+ int dstx, int dsty
+ );
+ void (*BlitTransRect)(
+ ScrnInfoPtr pScrn,
+ int srcx, int srcy,
+ int w, int h,
+ int dstx, int dsty,
+ unsigned long color
+ );
+} DGAFunctionRec, *DGAFunctionPtr;
+ </programlisting>
+
+
+ <blockquote><para>
+ <programlisting>
+ Bool OpenFramebuffer (pScrn, name, mem, size, offset, extra);
+ </programlisting>
+ <blockquote><para>
+ <function>OpenFramebuffer()</function> should pass the client everything
+ it needs to know to be able to open the framebuffer. These
+ parameters are OS specific and their meanings are to be interpreted
+ by an OS specific client library.
+
+ <variablelist>
+ <varlistentry>
+ <term><parameter>name</parameter></term>
+ <listitem><para>
+ The name of the device to open or <constant>NULL</constant> if
+ there is no special device to open. A <constant>NULL</constant>
+ name tells the client that it should open whatever device
+ one would usually open to access physical memory.
+ </para></listitem></varlistentry>
+
+ <varlistentry>
+ <term><parameter>mem</parameter></term>
+ <listitem><para>
+ The physical address of the start of the framebuffer.
+ </para></listitem></varlistentry>
+
+ <varlistentry>
+ <term><parameter>size</parameter></term>
+ <listitem><para>
+ The size of the framebuffer in bytes.
+ </para></listitem></varlistentry>
+
+ <varlistentry>
+ <term><parameter>offset</parameter></term>
+ <listitem><para>
+ Any offset into the device, if applicable.
+ </para></listitem></varlistentry>
+
+ <varlistentry>
+ <term><parameter>flags</parameter></term>
+ <listitem><para>
+ Any additional information that the client may need.
+ Currently, only the <constant>DGA_NEED_ROOT</constant> flag is
+ defined.
+ </para></listitem></varlistentry>
+
+ </variablelist>
+ </para></blockquote>
+ </para></blockquote>
+
+ <blockquote><para>
+ <programlisting>
+ void CloseFramebuffer (pScrn);
+ </programlisting>
+ <blockquote><para>
+ <function>CloseFramebuffer()</function> merely informs the driver (if it
+ even cares) that client no longer needs to access the framebuffer
+ directly. This function is optional.
+ </para>
+
+ </blockquote></para></blockquote>
+
+ <blockquote><para>
+ <programlisting>
+ Bool SetMode (pScrn, pMode);
+ </programlisting>
+ <blockquote><para>
+ <function>SetMode()</function> tells the driver to initialize the mode
+ passed to it. If <parameter>pMode</parameter> is <constant>NULL</constant>,
+ then the driver should restore the original pre-DGA mode.
+ </para>
+
+ </blockquote></para></blockquote>
+
+ <blockquote><para>
+ <programlisting>
+ void SetViewport (pScrn, x, y, flags);
+ </programlisting>
+ <blockquote><para>
+ <function>SetViewport()</function> tells the driver to make the upper
+ left-hand corner of the visible screen correspond to coordinate
+ <literal remap="tt">(x,y)</literal> on the framebuffer. <parameter>flags</parameter>
+ currently defined are:
+
+ <variablelist>
+ <varlistentry>
+ <term><constant>DGA_FLIP_IMMEDIATE</constant></term>
+ <listitem><para>
+ The viewport change should occur immediately.
+ </para></listitem></varlistentry>
+
+ <varlistentry>
+ <term><constant>DGA_FLIP_RETRACE</constant></term>
+ <listitem><para>
+ The viewport change should occur at the
+ vertical retrace, but this function should
+ return sooner if possible.
+ </para></listitem></varlistentry>
+ </variablelist>
+ </para>
+
+ <para>
+ The <literal remap="tt">(x,y)</literal> locations will be passed as the client
+ specified them, however, the driver is expected to round these
+ locations down to the next supported location as specified by the
+ <structfield>xViewportStep</structfield> and <structfield>yViewportStep</structfield>
+ for the current mode.
+ </para>
+ </blockquote></para></blockquote>
+
+ <blockquote><para>
+ <programlisting>
+ int GetViewport (pScrn);
+ </programlisting>
+ <blockquote><para>
+ <function>GetViewport()</function> gets the current page flip status.
+ Set bits in the returned int correspond to viewport change requests
+ still pending. For instance, set bit zero if the last SetViewport
+ request is still pending, bit one if the one before that is still
+ pending, etc.
+ </para>
+
+ </blockquote></para></blockquote>
+
+ <blockquote><para>
+ <programlisting>
+ void Sync (pScrn);
+ </programlisting>
+ <blockquote><para>
+ This function should ensure that any graphics accelerator operations
+ have finished. This function should not return until the graphics
+ accelerator is idle.
+ </para>
+
+ </blockquote></para></blockquote>
+
+ <blockquote><para>
+ <programlisting>
+ void FillRect (pScrn, x, y, w, h, color);
+ </programlisting>
+ <blockquote><para>
+ This optional function should fill a rectangle
+ <parameter>w&nbsp;&times;&nbsp;h</parameter> located at
+ <parameter>(x,y)</parameter> in the given color.
+ </para>
+
+ </blockquote></para></blockquote>
+
+ <blockquote><para>
+ <programlisting>
+ void BlitRect (pScrn, srcx, srcy, w, h, dstx, dsty);
+ </programlisting>
+ <blockquote><para>
+ This optional function should copy an area
+ <parameter>w&nbsp;&times;&nbsp;h</parameter> located at
+ <parameter>(srcx,srcy)</parameter> to location <parameter>(dstx,dsty)</parameter>.
+ This function will need to handle copy directions as appropriate.
+ </para>
+
+ </blockquote></para></blockquote>
+
+ <blockquote><para>
+ <programlisting>
+ void BlitTransRect (pScrn, srcx, srcy, w, h, dstx, dsty, color);
+ </programlisting>
+ <blockquote><para>
+ This optional function is the same as BlitRect except that pixels
+ in the source corresponding to the color key <parameter>color</parameter>
+ should be skipped.
+ </para>
+
+ </blockquote></para></blockquote>
+ </para></blockquote>
+
+ </sect1>
+
+ <sect1>
+ <title>The XFree86 X Video Extension (Xv) Device Dependent Layer</title>
+
+ <para>
+XFree86 offers the X Video Extension which allows clients to treat video
+as any another primitive and <quote>Put</quote> video into drawables. By default,
+the extension reports no video adaptors as being available since the
+DDX layer has not been initialized. The driver can initialize the DDX
+layer by filling out one or more <literal remap="tt">XF86VideoAdaptorRecs</literal>
+as described later in this document and passing a list of
+<literal remap="tt">XF86VideoAdaptorPtr</literal> pointers to the following function:
+
+ <programlisting>
+ Bool xf86XVScreenInit(ScreenPtr pScreen,
+ XF86VideoAdaptorPtr *adaptPtrs,
+ int num);
+ </programlisting>
+ </para>
+
+ <para>
+After doing this, the extension will report video adaptors as being
+available, providing the data in their respective
+<literal remap="tt">XF86VideoAdaptorRecs</literal> was valid.
+<function>xf86XVScreenInit()</function> <emphasis>copies</emphasis> data from the structure
+passed to it so the driver may free it after the initialization. At
+the moment, the DDX only supports rendering into Window drawables.
+Pixmap rendering will be supported after a sufficient survey of suitable
+hardware is completed.
+ </para>
+
+ <para>
+The <structname>XF86VideoAdaptorRec</structname>:
+
+ <programlisting>
+typedef struct {
+ unsigned int type;
+ int flags;
+ char *name;
+ int nEncodings;
+ XF86VideoEncodingPtr pEncodings;
+ int nFormats;
+ XF86VideoFormatPtr pFormats;
+ int nPorts;
+ DevUnion *pPortPrivates;
+ int nAttributes;
+ XF86AttributePtr pAttributes;
+ int nImages;
+ XF86ImagePtr pImages;
+ PutVideoFuncPtr PutVideo;
+ PutStillFuncPtr PutStill;
+ GetVideoFuncPtr GetVideo;
+ GetStillFuncPtr GetStill;
+ StopVideoFuncPtr StopVideo;
+ SetPortAttributeFuncPtr SetPortAttribute;
+ GetPortAttributeFuncPtr GetPortAttribute;
+ QueryBestSizeFuncPtr QueryBestSize;
+ PutImageFuncPtr PutImage;
+ QueryImageAttributesFuncPtr QueryImageAttributes;
+} XF86VideoAdaptorRec, *XF86VideoAdaptorPtr;
+ </programlisting></para>
+
+ <para>
+Each adaptor will have its own XF86VideoAdaptorRec. The fields are
+as follows:
+
+ <variablelist>
+ <varlistentry>
+ <term><structfield>type</structfield></term>
+ <listitem><para>
+ This can be any of the following flags OR'd together.
+
+ <variablelist>
+ <varlistentry>
+ <term><constant>XvInputMask</constant>
+ <constant>XvOutputMask</constant></term>
+ <listitem><para>
+ These refer to the target drawable and are similar to a Window's
+ class. <literal remap="tt">XvInputMask</literal> indicates that the adaptor
+ can put video into a drawable. <literal remap="tt">XvOutputMask</literal>
+ indicates that the adaptor can get video from a drawable.
+ </para></listitem></varlistentry>
+
+ <varlistentry>
+ <term><constant>XvVideoMask</constant>
+ <constant>XvStillMask</constant>
+ <constant>XvImageMask</constant></term>
+ <listitem><para>
+ These indicate that the adaptor supports video, still or
+ image primitives respectively.
+ </para></listitem></varlistentry>
+
+ <varlistentry>
+ <term><constant>XvWindowMask</constant>
+ <constant>XvPixmapMask</constant></term>
+ <listitem><para>
+ These indicate the types of drawables the adaptor is capable
+ of rendering into. At the moment, Pixmap rendering is not
+ supported and the <constant>XvPixmapMask</constant> flag is ignored.
+ </para></listitem></varlistentry>
+ </variablelist>
+
+ </para></listitem></varlistentry>
+
+ <varlistentry>
+ <term><structfield>flags</structfield></term>
+ <listitem><para>
+ Currently, the following flags are defined:
+
+ <variablelist>
+ <varlistentry>
+ <term><constant>VIDEO_NO_CLIPPING</constant></term>
+ <listitem><para>
+ This indicates that the video adaptor does not support
+ clipping. The driver will never receive <quote>Put</quote> requests
+ where less than the entire area determined by
+ <parameter>drw_x</parameter>, <parameter>drw_y</parameter>,
+ <parameter>drw_w</parameter> and <parameter>drw_h</parameter> is visible.
+ This flag does not apply to <quote>Get</quote> requests. Hardware
+ that is incapable of clipping <quote>Gets</quote> may punt or get
+ the extents of the clipping region passed to it.
+ </para></listitem>
+
+ </varlistentry>
+
+ <varlistentry>
+ <term><constant>VIDEO_INVERT_CLIPLIST</constant></term>
+ <listitem><para>
+ This indicates that the video driver requires the clip
+ list to contain the regions which are obscured rather
+ than the regions which are are visible.
+ </para></listitem>
+
+ </varlistentry>
+
+ <varlistentry>
+ <term><constant>VIDEO_OVERLAID_STILLS</constant></term>
+ <listitem><para>
+ Implementing PutStill for hardware that does video as an
+ overlay can be awkward since it's unclear how long to leave
+ the video up for. When this flag is set, StopVideo will be
+ called whenever the destination gets clipped or moved so that
+ the still can be left up until then.
+ </para></listitem>
+
+ </varlistentry>
+
+ <varlistentry>
+ <term><constant>VIDEO_OVERLAID_IMAGES</constant></term>
+ <listitem><para>
+ Same as <constant>VIDEO_OVERLAID_STILLS</constant> but for images.
+ </para></listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term><constant>VIDEO_CLIP_TO_VIEWPORT</constant></term>
+ <listitem><para>
+ Indicates that the clip region passed to the driver functions
+ should be clipped to the visible portion of the screen in the
+ case where the viewport is smaller than the virtual desktop.
+ </para></listitem></varlistentry>
+
+ </variablelist>
+ </para></listitem></varlistentry>
+
+ <varlistentry>
+ <term><structfield>name</structfield></term>
+ <listitem><para>
+ The name of the adaptor.
+ </para></listitem></varlistentry>
+
+
+ <varlistentry>
+ <term><structfield>nEncodings</structfield>
+ <structfield>pEncodings</structfield></term>
+ <listitem><para>
+ The number of encodings the adaptor is capable of and pointer
+ to the <structname>XF86VideoEncodingRec</structname> array. The
+ <structname>XF86VideoEncodingRec</structname> is described later on.
+ For drivers that only support XvImages there should be an encoding
+ named "XV_IMAGE" and the width and height should specify
+ the maximum size source image supported.
+ </para></listitem></varlistentry>
+
+
+ <varlistentry>
+ <term><structfield>nFormats</structfield>
+ <structfield>pFormats</structfield></term>
+ <listitem><para>
+ The number of formats the adaptor is capable of and pointer to
+ the <structname>XF86VideoFormatRec</structname> array. The
+ <structname>XF86VideoFormatRec</structname> is described later on.
+ </para></listitem></varlistentry>
+
+
+ <varlistentry>
+ <term><structfield>nPorts</structfield>
+ <structfield>pPortPrivates</structfield></term>
+ <listitem><para>
+ The number of ports is the number of separate data streams which
+ the adaptor can handle simultaneously. If you have more than
+ one port, the adaptor is expected to be able to render into more
+ than one window at a time. <structfield>pPortPrivates</structfield> is
+ an array of pointers or ints - one for each port. A port's
+ private data will be passed to the driver any time the port is
+ requested to do something like put the video or stop the video.
+ In the case where there may be many ports, this enables the
+ driver to know which port the request is intended for. Most
+ commonly, this will contain a pointer to the data structure
+ containing information about the port. In Xv, all ports on
+ a particular adaptor are expected to be identical in their
+ functionality.
+ </para></listitem></varlistentry>
+
+
+ <varlistentry>
+ <term><structfield>nAttributes</structfield>
+ <structfield>pAttributes</structfield></term>
+ <listitem><para>
+ The number of attributes recognized by the adaptor and a pointer to
+ the array of <structname>XF86AttributeRecs</structname>. The
+ <structname>XF86AttributeRec</structname> is described later on.
+ </para></listitem></varlistentry>
+
+
+ <varlistentry>
+ <term><structfield>nImages</structfield>
+ <structfield>pImages</structfield></term>
+ <listitem><para>
+ The number of <structname>XF86ImageRecs</structname> supported by the adaptor
+ and a pointer to the array of <structname>XF86ImageRecs</structname>. The
+ <structname>XF86ImageRec</structname> is described later on.
+ </para></listitem></varlistentry>
+
+
+ <varlistentry>
+ <term><structfield>
+ PutVideo PutStill GetVideo GetStill StopVideo
+ SetPortAttribute GetPortAttribute QueryBestSize PutImage
+ QueryImageAttributes
+ </structfield></term>
+ <listitem><para>
+ These functions define the DDX-&gt;driver interface. In each
+ case, the pointer <parameter>data</parameter> is passed to the driver.
+ This is the port private for that port as described above. All
+ fields are required except under the following conditions:
+
+ <orderedlist>
+ <listitem><para>
+ <structfield>PutVideo</structfield>, <structfield>PutStill</structfield> and
+ the image routines <structfield>PutImage</structfield> and
+ <structfield>QueryImageAttributes</structfield> are not required when the
+ adaptor type does not contain <constant>XvInputMask</constant>.
+ </para></listitem>
+
+ <listitem><para>
+ <structfield>GetVideo</structfield> and <structfield>GetStill</structfield>
+ are not required when the adaptor type does not contain
+ <constant>XvOutputMask</constant>.
+ </para></listitem>
+
+ <listitem><para>
+ <structfield>GetVideo</structfield> and <structfield>PutVideo</structfield>
+ are not required when the adaptor type does not contain
+ <constant>XvVideoMask</constant>.
+ </para></listitem>
+
+ <listitem><para>
+ <structfield>GetStill</structfield> and <structfield>PutStill</structfield>
+ are not required when the adaptor type does not contain
+ <constant>XvStillMask</constant>.
+ </para></listitem>
+
+ <listitem><para>
+ <structfield>PutImage</structfield> and <structfield>QueryImageAttributes</structfield>
+ are not required when the adaptor type does not contain
+ <constant>XvImageMask</constant>.
+ </para></listitem>
+
+ </orderedlist>
+
+ </para>
+
+ <para>
+ With the exception of <structfield>QueryImageAttributes</structfield>, these
+ functions should return <constant>Success</constant> if the operation was
+ completed successfully. They can return <constant>XvBadAlloc</constant>
+ otherwise. <structfield>QueryImageAttributes</structfield> returns the size
+ of the XvImage queried.
+ </para>
+
+ <para>
+ If the <constant>VIDEO_NO_CLIPPING</constant>
+ flag is set, the <literal remap="tt">clipBoxes</literal> may be ignored by
+ the driver. <literal remap="tt">ClipBoxes</literal> is an <literal remap="tt">X-Y</literal>
+ banded region identical to those used throughout the server.
+ The clipBoxes represent the visible portions of the area determined
+ by <literal remap="tt">drw_x</literal>, <literal remap="tt">drw_y</literal>,
+ <literal remap="tt">drw_w</literal> and <literal remap="tt">drw_h</literal> in the Get/Put
+ function. The boxes are in screen coordinates, are guaranteed
+ not to overlap and an empty region will never be passed.
+ If the driver has specified <constant>VIDEO_INVERT_CLIPLIST</constant>,
+ <literal remap="tt">clipBoxes</literal> will indicate the areas of the primitive
+ which are obscured rather than the areas visible.
+
+ </para></listitem></varlistentry>
+ </variablelist>
+
+ <blockquote><para>
+ <programlisting>
+ typedef int (* PutVideoFuncPtr)( ScrnInfoPtr pScrn,
+ short vid_x, short vid_y, short drw_x, short drw_y,
+ short vid_w, short vid_h, short drw_w, short drw_h,
+ RegionPtr clipBoxes, pointer data );
+ </programlisting>
+ <blockquote><para>
+ This indicates that the driver should take a subsection
+ <parameter>vid_w</parameter> by <parameter>vid_h</parameter> at location
+ <parameter>(vid_x,vid_y)</parameter> from the video stream and direct
+ it into the rectangle <parameter>drw_w</parameter> by <parameter>drw_h</parameter>
+ at location <parameter>(drw_x,drw_y)</parameter> on the screen, scaling as
+ necessary. Due to the large variations in capabilities of
+ the various hardware expected to be used with this extension,
+ it is not expected that all hardware will be able to do this
+ exactly as described. In that case the driver should just do
+ <quote>the best it can,</quote> scaling as closely to the target rectangle
+ as it can without rendering outside of it. In the worst case,
+ the driver can opt to just not turn on the video.
+ </para>
+
+ </blockquote></para></blockquote>
+
+ <blockquote><para>
+ <programlisting>
+ typedef int (* PutStillFuncPtr)( ScrnInfoPtr pScrn,
+ short vid_x, short vid_y, short drw_x, short drw_y,
+ short vid_w, short vid_h, short drw_w, short drw_h,
+ RegionPtr clipBoxes, pointer data );
+ </programlisting>
+ <blockquote><para>
+ This is same as <structfield>PutVideo</structfield> except that the driver
+ should place only one frame from the stream on the screen.
+ </para>
+
+ </blockquote></para></blockquote>
+
+ <blockquote><para>
+ <programlisting>
+ typedef int (* GetVideoFuncPtr)( ScrnInfoPtr pScrn,
+ short vid_x, short vid_y, short drw_x, short drw_y,
+ short vid_w, short vid_h, short drw_w, short drw_h,
+ RegionPtr clipBoxes, pointer data );
+ </programlisting>
+ <blockquote><para>
+ This is same as <structfield>PutVideo</structfield> except that the driver
+ gets video from the screen and outputs it. The driver should
+ do the best it can to get the requested dimensions correct
+ without reading from an area larger than requested.
+ </para>
+
+ </blockquote></para></blockquote>
+
+ <blockquote><para>
+ <programlisting>
+ typedef int (* GetStillFuncPtr)( ScrnInfoPtr pScrn,
+ short vid_x, short vid_y, short drw_x, short drw_y,
+ short vid_w, short vid_h, short drw_w, short drw_h,
+ RegionPtr clipBoxes, pointer data );
+ </programlisting>
+ <blockquote><para>
+ This is the same as <literal remap="tt">GetVideo</literal> except that the
+ driver should place only one frame from the screen into the
+ output stream.
+ </para>
+
+ </blockquote></para></blockquote>
+
+ <blockquote><para>
+ <programlisting>
+ typedef void (* StopVideoFuncPtr)(ScrnInfoPtr pScrn,
+ pointer data, Bool cleanup);
+ </programlisting>
+ <blockquote><para>
+ This indicates the driver should stop displaying the video.
+ This is used to stop both input and output video. The
+ <parameter>cleanup</parameter> field indicates that the video is
+ being stopped because the client requested it to stop or
+ because the server is exiting the current VT. In that case
+ the driver should deallocate any offscreen memory areas (if
+ there are any) being used to put the video to the screen. If
+ <parameter>cleanup</parameter> is not set, the video is being stopped
+ temporarily due to clipping or moving of the window, etc...
+ and video will likely be restarted soon so the driver should
+ not deallocate any offscreen areas associated with that port.
+ </para>
+
+ </blockquote></para></blockquote>
+ <blockquote><para>
+ <programlisting>
+ typedef int (* SetPortAttributeFuncPtr)(ScrnInfoPtr pScrn,
+ Atom attribute,INT32 value, pointer data);
+ </programlisting>
+
+ <programlisting>
+ typedef int (* GetPortAttributeFuncPtr)(ScrnInfoPtr pScrn,
+ Atom attribute,INT32 *value, pointer data);
+ </programlisting>
+ <blockquote><para>
+ A port may have particular attributes such as hue,
+ saturation, brightness or contrast. Xv clients set and
+ get these attribute values by sending attribute strings
+ (Atoms) to the server. Such requests end up at these
+ driver functions. It is recommended that the driver provide
+ at least the following attributes mentioned in the Xv client
+ library docs:
+ <literallayout><constant>
+ XV_ENCODING
+ XV_HUE
+ XV_SATURATION
+ XV_BRIGHTNESS
+ XV_CONTRAST
+ </constant></literallayout>
+ but the driver may recognize as many atoms as it wishes. If
+ a requested attribute is unknown by the driver it should return
+ <constant>BadMatch</constant>. <constant>XV_ENCODING</constant> is the
+ attribute intended to let the client specify which video
+ encoding the particular port should be using (see the description
+ of <structname>XF86VideoEncodingRec</structname> below). If the
+ requested encoding is unsupported, the driver should return
+ <constant>XvBadEncoding</constant>. If the value lies outside the
+ advertised range <constant>BadValue</constant> may be returned.
+ <constant>Success</constant> should be returned otherwise.
+ </para>
+
+ </blockquote></para></blockquote>
+
+ <blockquote><para>
+ <programlisting>
+ typedef void (* QueryBestSizeFuncPtr)(ScrnInfoPtr pScrn,
+ Bool motion, short vid_w, short vid_h,
+ short drw_w, short drw_h,
+ unsigned int *p_w, unsigned int *p_h, pointer data);
+ </programlisting>
+ <blockquote><para>
+ <function>QueryBestSize</function> provides the client with a way
+ to query what the destination dimensions would end up being
+ if they were to request that an area
+ <parameter>vid_w</parameter> by <parameter>vid_h</parameter> from the video
+ stream be scaled to rectangle of
+ <parameter>drw_w</parameter> by <parameter>drw_h</parameter> on the screen.
+ Since it is not expected that all hardware will be able to
+ get the target dimensions exactly, it is important that the
+ driver provide this function.
+ </para>
+
+ </blockquote></para></blockquote>
+
+ <blockquote><para>
+ <programlisting>
+ typedef int (* PutImageFuncPtr)( ScrnInfoPtr pScrn,
+ short src_x, short src_y, short drw_x, short drw_y,
+ short src_w, short src_h, short drw_w, short drw_h,
+ int image, char *buf, short width, short height,
+ Bool sync, RegionPtr clipBoxes, pointer data );
+ </programlisting>
+ <blockquote><para>
+ This is similar to <structfield>PutStill</structfield> except that the
+ source of the video is not a port but the data stored in a system
+ memory buffer at <parameter>buf</parameter>. The data is in the format
+ indicated by the <parameter>image</parameter> descriptor and represents a
+ source of size <parameter>width</parameter> by <parameter>height</parameter>.
+ If <parameter>sync</parameter> is TRUE the driver should not return
+ from this function until it is through reading the data
+ from <parameter>buf</parameter>. Returning when <parameter>sync</parameter>
+ is TRUE indicates that it is safe for the data at <parameter>buf</parameter>
+ to be replaced, freed, or modified.
+ </para>
+
+ </blockquote></para></blockquote>
+
+ <blockquote><para>
+ <programlisting>
+ typedef int (* QueryImageAttributesFuncPtr)( ScrnInfoPtr pScrn,
+ int image, short *width, short *height,
+ int *pitches, int *offsets);
+ </programlisting>
+ <blockquote><para>
+ This function is called to let the driver specify how data for
+ a particular <parameter>image</parameter> of size <parameter>width</parameter>
+ by <parameter>height</parameter> should be stored. Sometimes only
+ the size and corrected width and height are needed. In that
+ case <parameter>pitches</parameter> and <parameter>offsets</parameter> are
+ NULL. The size of the memory required for the image is returned
+ by this function. The <parameter>width</parameter> and
+ <parameter>height</parameter> of the requested image can be altered by
+ the driver to reflect format limitations (such as component
+ sampling periods that are larger than one). If
+ <parameter>pitches</parameter> and <parameter>offsets</parameter> are not NULL,
+ these will be arrays with as many elements in them as there
+ are planes in the <parameter>image</parameter> format. The driver
+ should specify the pitch (in bytes) of each scanline in the
+ particular plane as well as the offset to that plane (in bytes)
+ from the beginning of the image.
+ </para>
+
+ </blockquote></para></blockquote>
+ </para>
+
+ <para>
+The XF86VideoEncodingRec:
+
+ <blockquote><para>
+ <programlisting>
+typedef struct {
+ int id;
+ char *name;
+ unsigned short width, height;
+ XvRationalRec rate;
+} XF86VideoEncodingRec, *XF86VideoEncodingPtr;
+
+ </programlisting>
+ <blockquote><para>
+ The <structname>XF86VideoEncodingRec</structname> specifies what encodings
+ the adaptor can support. Most of this data is just informational
+ and for the client's benefit, and is what will be reported by
+ <function>XvQueryEncodings</function>. The <parameter>id</parameter> field is
+ expected to be a unique identifier to allow the client to request a
+ certain encoding via the <constant>XV_ENCODING</constant> attribute string.
+
+ </para>
+ </blockquote></para></blockquote>
+ </para>
+
+ <para>
+The XF86VideoFormatRec:
+
+ <blockquote><para>
+ <programlisting>
+typedef struct {
+ char depth;
+ short class;
+} XF86VideoFormatRec, *XF86VideoFormatPtr;
+
+ </programlisting>
+ <blockquote><para>
+ This specifies what visuals the video is viewable in.
+ <parameter>depth</parameter> is the depth of the visual (not bpp).
+ <parameter>class</parameter> is the visual class such as
+ <constant>TrueColor</constant>, <constant>DirectColor</constant> or
+ <constant>PseudoColor</constant>. Initialization of an adaptor will fail
+ if none of the visuals on that screen are supported.
+ </para>
+
+ </blockquote></para></blockquote>
+ </para>
+
+ <para>
+The XF86AttributeRec:
+
+ <blockquote><para>
+ <programlisting>
+typedef struct {
+ int flags;
+ int min_value;
+ int max_value;
+ char *name;
+} XF86AttributeListRec, *XF86AttributeListPtr;
+
+ </programlisting>
+ <blockquote><para>
+ Each adaptor may have an array of these advertising the attributes
+ for its ports. Currently defined flags are <literal remap="tt">XvGettable</literal>
+ and <literal remap="tt">XvSettable</literal> which may be OR'd together indicating that
+ attribute is <quote>gettable</quote> or <quote>settable</quote> by the client. The
+ <literal remap="tt">min</literal> and <literal remap="tt">max</literal> field specify the valid range
+ for the value. <literal remap="tt">Name</literal> is a text string describing the
+ attribute by name.
+ </para>
+
+ </blockquote></para></blockquote>
+
+ </para>
+
+ <para>
+The XF86ImageRec:
+
+ <blockquote><para>
+ <programlisting>
+typedef struct {
+ int id;
+ int type;
+ int byte_order;
+ char guid[16];
+ int bits_per_pixel;
+ int format;
+ int num_planes;
+
+ /* for RGB formats */
+ int depth;
+ unsigned int red_mask;
+ unsigned int green_mask;
+ unsigned int blue_mask;
+
+ /* for YUV formats */
+ unsigned int y_sample_bits;
+ unsigned int u_sample_bits;
+ unsigned int v_sample_bits;
+ unsigned int horz_y_period;
+ unsigned int horz_u_period;
+ unsigned int horz_v_period;
+ unsigned int vert_y_period;
+ unsigned int vert_u_period;
+ unsigned int vert_v_period;
+ char component_order[32];
+ int scanline_order;
+} XF86ImageRec, *XF86ImagePtr;
+
+ </programlisting>
+ <blockquote><para>
+ XF86ImageRec describes how video source data is laid out in memory.
+ The fields are as follows:
+
+ <variablelist>
+ <varlistentry>
+ <term><structfield>id</structfield></term>
+ <listitem><para>
+ This is a unique descriptor for the format. It is often good to
+ set this value to the FOURCC for the format when applicable.
+ </para></listitem></varlistentry>
+
+ <varlistentry>
+ <term><structfield>type</structfield></term>
+ <listitem><para>
+ This is <constant>XvRGB</constant> or <constant>XvYUV</constant>.
+ </para></listitem></varlistentry>
+
+ <varlistentry>
+ <term><structfield>byte_order</structfield></term>
+ <listitem><para>
+ This is <constant>LSBFirst</constant> or <constant>MSBFirst</constant>.
+ </para></listitem></varlistentry>
+
+ <varlistentry>
+ <term><structfield>guid</structfield></term>
+ <listitem><para>
+ This is the Globally Unique IDentifier for the format. When
+ not applicable, all characters should be NULL.
+ </para></listitem></varlistentry>
+
+ <varlistentry>
+ <term><structfield>bits_per_pixel</structfield></term>
+ <listitem><para>
+ The number of bits taken up (but not necessarily used) by each
+ pixel. Note that for some planar formats which have fractional
+ bits per pixel (such as IF09) this number may be rounded _down_.
+ </para></listitem></varlistentry>
+
+ <varlistentry>
+ <term><structfield>format</structfield></term>
+ <listitem><para>
+ This is <constant>XvPlanar</constant> or <constant>XvPacked</constant>.
+ </para></listitem></varlistentry>
+
+ <varlistentry>
+ <term><structfield>num_planes</structfield></term>
+ <listitem><para>
+ The number of planes in planar formats. This should be set to
+ one for packed formats.
+ </para></listitem></varlistentry>
+
+ <varlistentry>
+ <term><structfield>depth</structfield></term>
+ <listitem><para>
+ The significant bits per pixel in RGB formats (analgous to the
+ depth of a pixmap format).
+ </para></listitem></varlistentry>
+
+ <varlistentry>
+ <term><structfield>red_mask</structfield></term>
+ <term><structfield>green_mask</structfield></term>
+ <term><structfield>blue_mask</structfield></term>
+ <listitem><para>
+ The red, green and blue bitmasks for packed RGB formats.
+ </para></listitem></varlistentry>
+
+ <varlistentry>
+ <term><structfield>y_sample_bits</structfield></term>
+ <term><structfield>u_sample_bits</structfield></term>
+ <term><structfield>v_sample_bits</structfield></term>
+ <listitem><para>
+ The y, u and v sample sizes (in bits).
+ </para></listitem></varlistentry>
+
+ <varlistentry>
+ <term><structfield>horz_y_period</structfield></term>
+ <term><structfield>horz_u_period</structfield></term>
+ <term><structfield>horz_v_period</structfield></term>
+ <listitem><para>
+ The y, u and v sampling periods in the horizontal direction.
+ </para></listitem></varlistentry>
+
+ <varlistentry>
+ <term><structfield>vert_y_period</structfield></term>
+ <term><structfield>vert_u_period</structfield></term>
+ <term><structfield>vert_v_period</structfield></term>
+ <listitem><para>
+ The y, u and v sampling periods in the vertical direction.
+ </para></listitem></varlistentry>
+
+ <varlistentry>
+ <term><structfield>component_order</structfield></term>
+ <listitem><para>
+ Uppercase ascii characters representing the order that
+ samples are stored within packed formats. For planar formats
+ this represents the ordering of the planes. Unused characters
+ in the 32 byte string should be set to NULL.
+ </para></listitem></varlistentry>
+
+ <varlistentry>
+ <term><structfield>scanline_order</structfield></term>
+ <listitem><para>
+ This is <constant>XvTopToBottom</constant> or <constant>XvBottomToTop</constant>.
+ </para></listitem></varlistentry>
+
+ </variablelist>
+ </para>
+
+ <para>
+ Since some formats (particular some planar YUV formats) may not
+be completely defined by the parameters above, the guid, when
+available, should provide the most accurate description of the
+format.
+ </para>
+
+ </blockquote></para></blockquote>
+ </para>
+ </sect1>
+
+ <sect1>
+ <title>The Loader</title>
+
+ <para>
+This section describes the interfaces to the module loader. The loader
+interfaces can be divided into two groups: those that are only available to
+the XFree86 common layer, and those that are also available to modules.
+ </para>
+
+ <sect2>
+ <title>Loader Overview</title>
+
+ <para>
+The loader is capable of loading modules in a range of object formats,
+and knowledge of these formats is built in to the loader. Knowledge of
+new object formats can be added to the loader in a straightforward
+manner. This makes it possible to provide OS-independent modules (for
+a given CPU architecture type). In addition to this, the loader can
+load modules via the OS-provided <function>dlopen(3)</function> service where
+available. Such modules are not platform independent, and the semantics
+of <function>dlopen()</function> on most systems results in significant
+limitations in the use of modules of this type. Support for
+<function>dlopen()</function> modules in the loader is primarily for
+experimental and development purposes.
+ </para>
+
+ <para>
+Symbols exported by the loader (on behalf of the core X server) to
+modules are determined at compile time. Only those symbols explicitly
+exported are available to modules. All external symbols of loaded
+modules are exported to other modules, and to the core X server. The
+loader can be requested to check for unresolved symbols at any time,
+and the action to be taken for unresolved symbols can be controlled by
+the caller of the loader. Typically the caller identifies which symbols
+can safely remain unresolved and which cannot.
+ </para>
+
+ <para>
+NOTE: Now that ISO-C allows pointers to functions and pointers to data to
+have different internal representations, some of the following interfaces
+will need to be revisited.
+ </para>
+ </sect2>
+
+ <sect2>
+ <title>Semi-private Loader Interface</title>
+
+ <para>
+The following is the semi-private loader interface that is available to the
+XFree86 common layer.
+ </para>
+
+ <blockquote><para>
+ <programlisting>
+ void LoaderInit(void);
+ </programlisting>
+ <blockquote><para>
+ The <function>LoaderInit()</function> function initialises the loader,
+ and it must be called once before calling any other loader functions.
+ This function initialises the tables of exported symbols, and anything
+ else that might need to be initialised.
+ </para>
+
+ </blockquote></para></blockquote>
+
+ <blockquote><para>
+ <programlisting>
+ void LoaderSetPath(const char *path);
+ </programlisting>
+ <blockquote><para>
+ The <function>LoaderSetPath()</function> function initialises a default
+ module search path. This must be called if calls to other functions
+ are to be made without explicitly specifying a module search path.
+ The search path <parameter>path</parameter> must be a string of one or more
+ comma separated absolute paths. Modules are expected to be located
+ below these paths, possibly in subdirectories of these paths.
+ </para>
+
+ </blockquote></para></blockquote>
+
+ <blockquote><para>
+ <programlisting>
+ pointer LoadModule(const char *module, const char *path,
+ const char **subdirlist, const char **patternlist,
+ pointer options, const XF86ModReqInfo * modreq,
+ int *errmaj, int *errmin);
+ </programlisting>
+ <blockquote><para>
+ The <function>LoadModule()</function> function loads the module called
+ <parameter>module</parameter>. The return value is a module handle, and
+ may be used in future calls to the loader that require a reference
+ to a loaded module. The module name <parameter>module</parameter> is
+ normally the module's canonical name, which doesn't contain any
+ directory path information, or any object/library file prefixes of
+ suffixes. Currently a full pathname and/or filename is also accepted.
+ This might change. The other parameters are:
+
+ <variablelist>
+ <varlistentry>
+ <term><parameter>path</parameter></term>
+ <listitem><para>
+ An optional comma-separated list of module search paths.
+ When <constant>NULL</constant>, the default search path is used.
+ </para></listitem></varlistentry>
+
+
+ <varlistentry>
+ <term><parameter>subdirlist</parameter></term>
+ <listitem><para>
+ An optional <constant>NULL</constant> terminated list of
+ subdirectories to search. When <constant>NULL</constant>,
+ the default built-in list is used (refer to
+ <varname>stdSubdirs</varname> in <filename>loadmod.c</filename>).
+ The default list is also substituted for entries in
+ <parameter>subdirlist</parameter> with the value
+ <constant>DEFAULT_LIST</constant>. This makes is possible
+ to augment the default list instead of replacing it.
+ Subdir elements must be relative, and must not contain
+ <literal remap="tt">".."</literal>. If any violate this requirement,
+ the load fails.
+ </para></listitem></varlistentry>
+
+
+ <varlistentry>
+ <term><parameter>patternlist</parameter></term>
+ <listitem><para>
+ An optional <constant>NULL</constant> terminated list of
+ POSIX regular expressions used to connect module
+ filenames with canonical module names. Each regex
+ should contain exactly one subexpression that corresponds
+ to the canonical module name. When <constant>NULL</constant>,
+ the default built-in list is used (refer to
+ <varname>stdPatterns</varname> in
+ <filename>loadmod.c</filename>). The default list is also
+ substituted for entries in <parameter>patternlist</parameter>
+ with the value <constant>DEFAULT_LIST</constant>. This
+ makes it possible to augment the default list instead
+ of replacing it.
+ </para></listitem></varlistentry>
+
+
+ <varlistentry>
+ <term><parameter>options</parameter></term>
+ <listitem><para>
+ An optional parameter that is passed to the newly
+ loaded module's <literal remap="tt">SetupProc</literal> function
+ (if it has one). This argument is normally a
+ <constant>NULL</constant> terminated list of
+ <structname>Options</structname>, and must be interpreted that
+ way by modules loaded directly by the XFree86 common
+ layer. However, it may be used for application-specific
+ parameter passing in other situations.
+ </para>
+
+ <para>
+ When loading <quote>external</quote> modules (modules that don't
+ have the standard entry point, for example a
+ special shared library) the options parameter can be
+ set to <constant>EXTERN_MODULE</constant> to tell the
+ loader not to reject the module when it doesn't find
+ the standard entry point.
+ </para></listitem></varlistentry>
+
+
+ <varlistentry>
+ <term><parameter>modreq</parameter></term>
+ <listitem><para>
+ An optional <structname>XF86ModReqInfo*</structname> containing
+ version/ABI/vendor information to requirements to
+ check the newly loaded module against. The main
+ purpose of this is to allow the loader to verify that
+ a module of the correct type/version before running
+ its <function>SetupProc</function> function.
+ </para>
+
+ <para>
+ The <literal remap="tt">XF86ModReqInfo</literal> struct is defined
+ as follows:
+ <programlisting>
+typedef struct {
+ CARD8 majorversion; /* MAJOR_UNSPEC */
+ CARD8 minorversion; /* MINOR_UNSPEC */
+ CARD16 patchlevel; /* PATCH_UNSPEC */
+ const char * abiclass; /* ABI_CLASS_NONE */
+ CARD32 abiversion; /* ABI_VERS_UNSPEC */
+ const char * moduleclass; /* MOD_CLASS_NONE */
+} XF86ModReqInfo;
+ </programlisting>
+
+ The information here is compared against the equivalent
+ information in the module's
+ <structname>XF86ModuleVersionInfo</structname> record (which
+ is described below). The values in comments above
+ indicate <quote>don't care</quote> settings for each of the fields.
+ The comparisons made are as follows:
+
+ <variablelist>
+ <varlistentry>
+ <term><structfield>majorversion</structfield></term>
+ <listitem><para>
+ Must match the module's majorversion
+ exactly.
+ </para></listitem></varlistentry>
+
+ <varlistentry>
+ <term><structfield>minorversion</structfield></term>
+ <listitem><para>
+ The module's minor version must be
+ no less than this value. This
+ comparison is only made if
+ <structfield>majorversion</structfield> is
+ specified and matches.
+ </para></listitem></varlistentry>
+
+ <varlistentry>
+ <term><structfield>patchlevel</structfield></term>
+ <listitem><para>
+ The module's patchlevel must be no
+ less than this value. This comparison
+ is only made if
+ <structfield>minorversion</structfield> is
+ specified and matches.
+ </para></listitem></varlistentry>
+
+ <varlistentry>
+ <term><structfield>abiclass</structfield></term>
+ <listitem><para>
+ String must match the module's abiclass
+ string.
+ </para></listitem></varlistentry>
+
+ <varlistentry>
+ <term><structfield>abiversion</structfield></term>
+ <listitem><para>
+ Must be consistent with the module's
+ abiversion (major equal, minor no
+ older).
+ </para></listitem></varlistentry>
+
+ <varlistentry>
+ <term><structfield>moduleclass</structfield></term>
+ <listitem><para>
+ String must match the module's
+ moduleclass string.
+ </para></listitem></varlistentry>
+
+ </variablelist>
+ </para></listitem></varlistentry>
+
+ <varlistentry>
+ <term><parameter>errmaj</parameter></term>
+ <listitem><para>
+ An optional pointer to a variable holding the major
+ part or the error code. When provided,
+ <parameter>*errmaj</parameter> is filled in when
+ <function>LoadModule()</function> fails.
+ </para></listitem></varlistentry>
+
+ <varlistentry>
+ <term><parameter>errmin</parameter></term>
+ <listitem><para>
+ Like <parameter>errmaj</parameter>, but for the minor part
+ of the error code.
+ </para></listitem></varlistentry>
+
+ </variablelist>
+
+ </para></blockquote>
+ </para></blockquote>
+
+ <blockquote><para>
+ <programlisting>
+ void UnloadModule(pointer mod);
+ </programlisting>
+ <blockquote><para>
+ This function unloads the module referred to by the handle mod.
+ All child modules are also unloaded recursively. This function must
+ not be used to directly unload modules that are child modules (i.e.,
+ those that have been loaded with the <function>LoadSubModule()</function>
+ described below).
+ </para>
+
+ </blockquote></para></blockquote>
+ </sect2>
+
+ <sect2>
+ <title>Module Requirements</title>
+
+ <para>
+Modules must provide information about themselves to the loader, and
+may optionally provide entry points for "setup" and "teardown" functions
+(those two functions are referred to here as <function>SetupProc</function>
+and <function>TearDownProc</function>).
+ </para>
+
+ <para>
+The module information is contained in the
+<structname>XF86ModuleVersionInfo</structname> struct, which is defined as follows:
+
+ <programlisting>
+typedef struct {
+ const char * modname; /* name of module, e.g. "foo" */
+ const char * vendor; /* vendor specific string */
+ CARD32 _modinfo1_; /* constant MODINFOSTRING1/2 to find */
+ CARD32 _modinfo2_; /* infoarea with a binary editor/sign tool */
+ CARD32 xf86version; /* contains XF86_VERSION_CURRENT */
+ CARD8 majorversion; /* module-specific major version */
+ CARD8 minorversion; /* module-specific minor version */
+ CARD16 patchlevel; /* module-specific patch level */
+ const char * abiclass; /* ABI class that the module uses */
+ CARD32 abiversion; /* ABI version */
+ const char * moduleclass; /* module class */
+ CARD32 checksum[4]; /* contains a digital signature of the */
+ /* version info structure */
+} XF86ModuleVersionInfo;
+ </programlisting>
+
+The fields are used as follows:
+
+ <variablelist>
+ <varlistentry>
+ <term><structfield>modname</structfield></term>
+ <listitem><para>
+ The module's name. This field is currently only for
+ informational purposes, but the loader may be modified
+ in future to require it to match the module's canonical
+ name.
+ </para></listitem></varlistentry>
+
+
+ <varlistentry>
+ <term><structfield>vendor</structfield></term>
+ <listitem><para>
+ The module vendor. This field is for informational purposes
+ only.
+ </para></listitem></varlistentry>
+
+
+ <varlistentry>
+ <term><structfield>_modinfo1_</structfield></term>
+ <listitem><para>
+ This field holds the first part of a signature that can
+ be used to locate this structure in the binary. It should
+ always be initialised to <constant>MODINFOSTRING1</constant>.
+ </para></listitem></varlistentry>
+
+
+ <varlistentry>
+ <term><structfield>_modinfo2_</structfield></term>
+ <listitem><para>
+ This field holds the second part of a signature that can
+ be used to locate this structure in the binary. It should
+ always be initialised to <constant>MODINFOSTRING2</constant>.
+ </para></listitem></varlistentry>
+
+
+ <varlistentry>
+ <term><structfield>xf86version</structfield></term>
+ <listitem><para>
+ The XFree86 version against which the module was compiled.
+ This is mostly for informational/diagnostic purposes. It
+ should be initialised to <constant>XF86_VERSION_CURRENT</constant>, which is
+ defined in <filename>xf86Version.h</filename>.
+ </para></listitem></varlistentry>
+
+
+ <varlistentry>
+ <term><structfield>majorversion</structfield></term>
+ <listitem><para>
+ The module-specific major version. For modules where this
+ version is used for more than simply informational
+ purposes, the major version should only change (be
+ incremented) when ABI incompatibilities are introduced,
+ or ABI components are removed.
+ </para></listitem></varlistentry>
+
+
+ <varlistentry>
+ <term><structfield>minorversion</structfield></term>
+ <listitem><para>
+ The module-specific minor version. For modules where this
+ version is used for more than simply informational
+ purposes, the minor version should only change (be
+ incremented) when ABI additions are made in a backward
+ compatible way. It should be reset to zero when the major
+ version is increased.
+ </para></listitem></varlistentry>
+
+
+ <varlistentry>
+ <term><structfield>patchlevel</structfield></term>
+ <listitem><para>
+ The module-specific patch level. The patch level should
+ increase with new revisions of the module where there
+ are no ABI changes, and it should be reset to zero when
+ the minor version is increased.
+ </para></listitem></varlistentry>
+
+
+ <varlistentry>
+ <term><structfield>abiclass</structfield></term>
+ <listitem><para>
+ The ABI class that the module requires. The class is
+ specified as a string for easy extensibility. It should
+ indicate which (if any) of the X server's built-in ABI
+ classes that the module relies on, or a third-party ABI
+ if appropriate. Built-in ABI classes currently defined are:
+
+ <variablelist>
+ <varlistentry>
+ <term><constant>ABI_CLASS_NONE</constant></term>
+ <listitem><para>no class
+ </para></listitem></varlistentry>
+ <varlistentry>
+ <term><constant>ABI_CLASS_ANSIC</constant></term>
+ <listitem><para>only requires the ANSI C interfaces
+ </para></listitem></varlistentry>
+ <varlistentry>
+ <term><constant>ABI_CLASS_VIDEODRV</constant></term>
+ <listitem><para>requires the video driver ABI
+ </para></listitem></varlistentry>
+ <varlistentry>
+ <term><constant>ABI_CLASS_XINPUT</constant></term>
+ <listitem><para>requires the XInput driver ABI
+ </para></listitem></varlistentry>
+ <varlistentry>
+ <term><constant>ABI_CLASS_EXTENSION</constant></term>
+ <listitem><para>requires the extension module ABI
+ </para></listitem></varlistentry>
+ <varlistentry>
+ <term><constant>ABI_CLASS_FONT</constant></term>
+ <listitem><para>requires the font module ABI
+ </para></listitem></varlistentry>
+ </variablelist>
+
+ </para></listitem></varlistentry>
+
+ <varlistentry>
+ <term><structfield>abiversion</structfield></term>
+ <listitem><para>
+ The version of abiclass that the module requires. The
+ version consists of major and minor components. The
+ major version must match and the minor version must be
+ no newer than that provided by the server or parent
+ module. Version identifiers for the built-in classes
+ currently defined are:
+
+ <literallayout><constant>
+ ABI_ANSIC_VERSION
+ ABI_VIDEODRV_VERSION
+ ABI_XINPUT_VERSION
+ ABI_EXTENSION_VERSION
+ ABI_FONT_VERSION
+ </constant></literallayout>
+
+ </para></listitem></varlistentry>
+
+ <varlistentry>
+ <term><structfield>moduleclass</structfield></term>
+ <listitem><para>
+ This is similar to the abiclass field, except that it
+ defines the type of module rather than the ABI it
+ requires. For example, although all video drivers require
+ the video driver ABI, not all modules that require the
+ video driver ABI are video drivers. This distinction
+ can be made with the moduleclass. Currently pre-defined
+ module classes are:
+
+ <literallayout><constant>
+ MOD_CLASS_NONE
+ MOD_CLASS_VIDEODRV
+ MOD_CLASS_XINPUT
+ MOD_CLASS_FONT
+ MOD_CLASS_EXTENSION
+ </constant></literallayout>
+
+ </para></listitem></varlistentry>
+
+ <varlistentry>
+ <term><structfield>checksum</structfield></term>
+ <listitem><para>
+ Not currently used.
+ </para></listitem></varlistentry>
+
+ </variablelist>
+ </para>
+
+ <para>
+The module version information, and the optional <function>SetupProc</function>
+and <function>TearDownProc</function> entry points are found by the loader
+by locating a data object in the module called "modnameModuleData",
+where "modname" is the canonical name of the module. Modules must
+contain such a data object, and it must be declared with global scope,
+be compile-time initialised, and is of the following type:
+
+ <programlisting>
+typedef struct {
+ XF86ModuleVersionInfo * vers;
+ ModuleSetupProc setup;
+ ModuleTearDownProc teardown;
+} XF86ModuleData;
+ </programlisting>
+ </para>
+
+ <para>
+The vers parameter must be initialised to a pointer to a correctly
+initialised <structname>XF86ModuleVersionInfo</structname> struct. The other
+two parameter are optional, and should be initialised to
+<constant>NULL</constant> when not required. The other parameters are defined
+as
+
+ <blockquote><para>
+ <programlisting>
+ typedef pointer (*ModuleSetupProc)(pointer, pointer, int *, int *);
+
+ typedef void (*ModuleTearDownProc)(pointer);
+
+ pointer SetupProc(pointer module, pointer options,
+ int *errmaj, int *errmin);
+ </programlisting>
+ <blockquote><para>
+ When defined, this function is called by the loader after successfully
+ loading a module. module is a handle for the newly loaded module,
+ and maybe used by the <function>SetupProc</function> if it calls other
+ loader functions that require a reference to it. The remaining
+ arguments are those that were passed to the
+ <function>LoadModule()</function> (or <function>LoadSubModule()</function>),
+ and are described above. When the <function>SetupProc</function> is
+ successful it must return a non-<constant>NULL</constant> value. The
+ loader checks this, and if it is <constant>NULL</constant> it unloads
+ the module and reports the failure to the caller of
+ <function>LoadModule()</function>. If the <function>SetupProc</function>
+ does things that need to be undone when the module is unloaded,
+ it should define a <function>TearDownProc</function>, and return a
+ pointer that the <function>TearDownProc</function> can use to undo what
+ has been done.
+ </para>
+
+ <para>
+ When a module is loaded multiple times, the <function>SetupProc</function>
+ is called once for each time it is loaded.
+ </para>
+
+ </blockquote></para></blockquote>
+
+ <blockquote><para>
+ <programlisting>
+ void TearDownProc(pointer tearDownData);
+ </programlisting>
+ <blockquote><para>
+ When defined, this function is called when the loader unloads a
+ module. The <parameter>tearDownData</parameter> parameter is the return
+ value of the <function>SetupProc()</function> that was called when the
+ module was loaded. The purpose of this function is to clean up
+ before the module is unloaded (for example, by freeing allocated
+ resources).
+ </para>
+
+ </blockquote></para></blockquote>
+ </para>
+ </sect2>
+
+ <sect2>
+ <title>Public Loader Interface</title>
+
+ <para>
+The following is the Loader interface that is available to any part of
+the server, and may also be used from within modules.
+ </para>
+
+ <blockquote><para>
+ <programlisting>
+ pointer LoadSubModule(pointer parent, const char *module,
+ const char **subdirlist, const char **patternlist,
+ pointer options, const XF86ModReqInfo * modreq,
+ int *errmaj, int *errmin);
+ </programlisting>
+ <blockquote><para>
+ This function is like the <function>LoadModule()</function> function
+ described above, except that the module loaded is registered as a
+ child of the calling module. The <parameter>parent</parameter> parameter
+ is the calling module's handle. Modules loaded with this function
+ are automatically unloaded when the parent module is unloaded. The
+ other difference is that the path parameter may not be specified.
+ The module search path used for modules loaded with this function
+ is the default search path as initialised with
+ <function>LoaderSetPath()</function>.
+ </para>
+
+ </blockquote></para></blockquote>
+
+ <blockquote><para>
+ <programlisting>
+ void UnloadSubModule(pointer module);
+ </programlisting>
+ <blockquote><para>
+ This function unloads the module with handle <parameter>module</parameter>.
+ If that module itself has children, they are also unloaded. It is
+ like <function>UnloadModule()</function>, except that it is safe to use
+ for unloading child modules.
+ </para>
+
+ </blockquote></para></blockquote>
+
+ <blockquote><para>
+ <programlisting>
+ pointer LoaderSymbol(const char *symbol);
+ </programlisting>
+ <blockquote><para>
+ This function returns the address of the symbol with name
+ <parameter>symbol</parameter>. This may be used to locate a module entry
+ point with a known name.
+ </para>
+
+ </blockquote></para></blockquote>
+
+ <blockquote><para>
+ <programlisting>
+ char **LoaderlistDirs(const char **subdirlist,
+ const char **patternlist);
+ </programlisting>
+ <blockquote><para>
+ This function returns a <constant>NULL</constant> terminated list of
+ canonical modules names for modules found in the default module
+ search path. The <parameter>subdirlist</parameter> and
+ <parameter>patternlist</parameter> parameters are as described above, and
+ can be used to control the locations and names that are searched.
+ If no modules are found, the return value is <constant>NULL</constant>.
+ The returned list should be freed by calling
+ <function>LoaderFreeDirList()</function> when it is no longer needed.
+ </para>
+
+ </blockquote></para></blockquote>
+
+ <blockquote><para>
+ <programlisting>
+ void LoaderFreeDirList(char **list);
+ </programlisting>
+ <blockquote><para>
+ This function frees a module list created by
+ <function>LoaderlistDirs()</function>.
+ </para>
+
+ </blockquote></para></blockquote>
+
+ <blockquote><para>
+ <programlisting>
+ void LoaderReqSymLists(const char **list0, ...);
+ </programlisting>
+ <blockquote><para>
+ This function allows the registration of required symbols with the
+ loader. It is normally used by a caller of
+ <function>LoadSubModule()</function>. If any symbols registered in this
+ way are found to be unresolved when
+ <function>LoaderCheckUnresolved()</function> is called then
+ <function>LoaderCheckUnresolved()</function> will report a failure.
+ The function takes one or more <constant>NULL</constant> terminated
+ lists of symbols. The end of the argument list is indicated by a
+ <constant>NULL</constant> argument.
+ </para>
+
+ </blockquote></para></blockquote>
+
+ <blockquote><para>
+ <programlisting>
+ void LoaderReqSymbols(const char *sym0, ...);
+ </programlisting>
+ <blockquote><para>
+ This function is like <function>LoaderReqSymLists()</function> except
+ that its arguments are symbols rather than lists of symbols. This
+ function is more convenient when single functions are to be registered,
+ especially when the single function might depend on runtime factors.
+ The end of the argument list is indicated by a <constant>NULL</constant>
+ argument.
+ </para>
+
+ </blockquote></para></blockquote>
+
+ <blockquote><para>
+ <programlisting>
+ void LoaderRefSymLists(const char **list0, ...);
+ </programlisting>
+ <blockquote><para>
+ This function allows the registration of possibly unresolved symbols
+ with the loader. When <function>LoaderCheckUnresolved()</function> is
+ run it won't generate warnings for symbols registered in this way
+ unless they were also registered as required symbols.
+ The function takes one or more <constant>NULL</constant> terminated
+ lists of symbols. The end of the argument list is indicated by a
+ <constant>NULL</constant> argument.
+ </para>
+
+ </blockquote></para></blockquote>
+
+ <blockquote><para>
+ <programlisting>
+ void LoaderRefSymbols(const char *sym0, ...);
+ </programlisting>
+ <blockquote><para>
+ This function is like <function>LoaderRefSymLists()</function> except
+ that its arguments are symbols rather than lists of symbols. This
+ function is more convenient when single functions are to be registered,
+ especially when the single function might depend on runtime factors.
+ The end of the argument list is indicated by a <constant>NULL</constant>
+ argument.
+ </para>
+
+ </blockquote></para></blockquote>
+
+ <blockquote><para>
+ <programlisting>
+ int LoaderCheckUnresolved(int delayflag);
+ </programlisting>
+ <blockquote><para>
+ This function checks for unresolved symbols. It generates warnings
+ for unresolved symbols that have not been registered with
+ <function>LoaderRefSymLists()</function>, and maps them to a dummy
+ function. This behaviour may change in future. If unresolved
+ symbols are found that have been registered with
+ <function>LoaderReqSymLists()</function> or
+ <function>LoaderReqSymbols()</function> then this function returns a
+ non-zero value. If none of these symbols are unresolved the return
+ value is zero, indicating success.
+ </para>
+
+ <para>
+ The <parameter>delayflag</parameter> parameter should normally be set to
+ <constant>LD_RESOLV_IFDONE</constant>.
+ </para>
+
+ </blockquote></para></blockquote>
+
+ <blockquote><para>
+ <programlisting>
+ LoaderErrorMsg(const char *name, const char *modname,
+ int errmaj, int errmin);
+ </programlisting>
+ <blockquote><para>
+ This function prints an error message that includes the text <quote>Failed
+ to load module</quote>, the module name <parameter>modname</parameter>, a message
+ specific to the <parameter>errmaj</parameter> value, and the value if
+ <parameter>errmin</parameter>. If <parameter>name</parameter> is
+ non-<constant>NULL</constant>, it is printed as an identifying prefix
+ to the message (followed by a <quote>:</quote>).
+ </para>
+
+ </blockquote></para></blockquote>
+ </sect2>
+
+ <sect2>
+ <title>Special Registration Functions</title>
+
+ <para>
+The loader contains some functions for registering some classes of modules.
+These may be moved out of the loader at some point.
+ </para>
+
+ <blockquote><para>
+ <programlisting>
+ void LoadExtension(ExtensionModule *ext);
+ </programlisting>
+ <blockquote><para>
+ This registers the entry points for the extension identified by
+ <parameter>ext</parameter>. The <structname>ExtensionModule</structname> struct is
+ defined as:
+
+ <programlisting>
+typedef struct {
+ InitExtension initFunc;
+ char * name;
+ Bool *disablePtr;
+ InitExtension setupFunc;
+} ExtensionModule;
+ </programlisting>
+ </para>
+
+ </blockquote></para></blockquote>
+
+ <blockquote><para>
+ <programlisting>
+ void LoadFont(FontModule *font);
+ </programlisting>
+ <blockquote><para>
+ This registers the entry points for the font rasteriser module
+ identified by <parameter>font</parameter>. The <structname>FontModule</structname>
+ struct is defined as:
+
+ <programlisting>
+ typedef struct {
+ InitFont initFunc;
+ char * name;
+ pointer module;
+} FontModule;
+ </programlisting>
+ </para>
+
+ </blockquote></para></blockquote>
+
+ </sect2>
+
+ </sect1>
+
+ <sect1>
+ <title>Helper Functions</title>
+
+ <para>
+This section describe <quote>helper</quote> functions that video driver
+might find useful. While video drivers are not required to use any of
+these to be considered <quote>compliant</quote>, the use of appropriate helpers is
+strongly encouraged to improve the consistency of driver behaviour.
+ </para>
+
+ <sect2>
+ <title>Functions for printing messages</title>
+
+ <blockquote><para>
+ <programlisting>
+ ErrorF(const char *format, ...);
+ </programlisting>
+ <blockquote><para>
+ This is the basic function for writing to the error log (typically
+ stderr and/or a log file). Video drivers should usually avoid
+ using this directly in favour of the more specialised functions
+ described below. This function is useful for printing messages
+ while debugging a driver.
+ </para>
+
+ </blockquote></para></blockquote>
+
+ <blockquote><para>
+ <programlisting>
+ FatalError(const char *format, ...);
+ </programlisting>
+ <blockquote><para>
+ This prints a message and causes the Xserver to abort. It should
+ rarely be used within a video driver, as most error conditions
+ should be flagged by the return values of the driver functions.
+ This allows the higher layers to decide how to proceed. In rare
+ cases, this can be used within a driver if a fatal unexpected
+ condition is found.
+ </para>
+
+ </blockquote></para></blockquote>
+
+ <blockquote><para>
+ <programlisting>
+ xf86ErrorF(const char *format, ...);
+ </programlisting>
+ <blockquote><para>
+ This is like <function>ErrorF()</function>, except that the message is
+ only printed when the Xserver's verbosity level is set to the
+ default (<constant>1</constant>) or higher. It means that the messages
+ are not printed when the server is started with the
+ <option>-quiet</option> flag. Typically this function would only be
+ used for continuing messages started with one of the more specialised
+ functions described below.
+ </para>
+
+ </blockquote></para></blockquote>
+
+ <blockquote><para>
+ <programlisting>
+ xf86ErrorFVerb(int verb, const char *format, ...);
+ </programlisting>
+ <blockquote><para>
+ Like <function>xf86ErrorF()</function>, except the minimum verbosity
+ level for which the message is to be printed is given explicitly.
+ Passing a <parameter>verb</parameter> value of zero means the message
+ is always printed. A value higher than <constant>1</constant> can be
+ used for information would normally not be needed, but which might
+ be useful when diagnosing problems.
+ </para>
+
+ </blockquote></para></blockquote>
+
+
+ <blockquote><para>
+ <programlisting>
+ xf86Msg(MessageType type, const char *format, ...);
+ </programlisting>
+ <blockquote><para>
+ This is like <function>xf86ErrorF()</function>, except that the message
+ is prefixed with a marker determined by the value of
+ <parameter>type</parameter>. The marker is used to indicate the type of
+ message (warning, error, probed value, config value, etc). Note
+ the <varname>xf86Verbose</varname> value is ignored for messages of
+ type <constant>X_ERROR</constant>.
+ </para>
+
+ <para>
+ The marker values are:
+
+ <variablelist>
+ <varlistentry>
+ <term><constant>X_PROBED</constant></term>
+ <listitem><para>Value was probed.
+ </para></listitem></varlistentry>
+ <varlistentry>
+ <term><constant>X_CONFIG</constant></term>
+ <listitem><para>Value was given in the config file.
+ </para></listitem></varlistentry>
+ <varlistentry>
+ <term><constant>X_DEFAULT</constant></term>
+ <listitem><para>Value is a default.
+ </para></listitem></varlistentry>
+ <varlistentry>
+ <term><constant>X_CMDLINE</constant></term>
+ <listitem><para>Value was given on the command line.
+ </para></listitem></varlistentry>
+ <varlistentry>
+ <term><constant>X_NOTICE</constant></term>
+ <listitem><para>Notice.
+ </para></listitem></varlistentry>
+ <varlistentry>
+ <term><constant>X_ERROR</constant></term>
+ <listitem><para>Error message.
+ </para></listitem></varlistentry>
+ <varlistentry>
+ <term><constant>X_WARNING</constant></term>
+ <listitem><para>Warning message.
+ </para></listitem></varlistentry>
+ <varlistentry>
+ <term><constant>X_INFO</constant></term>
+ <listitem><para>Informational message.
+ </para></listitem></varlistentry>
+ <varlistentry>
+ <term><constant>X_NONE</constant></term>
+ <listitem><para>No prefix.
+ </para></listitem></varlistentry>
+ <varlistentry>
+ <term><constant>X_NOT_IMPLEMENTED</constant></term>
+ <listitem><para>The message relates to functionality
+ that is not yetimplemented.
+ </para></listitem></varlistentry>
+ </variablelist>
+
+ </para>
+
+ </blockquote></para></blockquote>
+
+ <blockquote><para>
+ <programlisting>
+ xf86MsgVerb(MessageType type, int verb, const char *format, ...);
+ </programlisting>
+ <blockquote><para>
+ Like <function>xf86Msg()</function>, but with the verbosity level given
+ explicitly.
+ </para>
+
+ </blockquote></para></blockquote>
+
+ <blockquote><para>
+ <programlisting>
+ xf86DrvMsg(int scrnIndex, MessageType type, const char *format, ...);
+ </programlisting>
+ <blockquote><para>
+ This is like <function>xf86Msg()</function> except that the driver's
+ name (the <structfield>name</structfield> field of the
+ <structname>ScrnInfoRec</structname>) followed by the
+ <parameter>scrnIndex</parameter> in parentheses is printed following the
+ prefix. This should be used by video drivers in most cases as it
+ clearly indicates which driver/screen the message is for. If
+ <parameter>scrnIndex</parameter> is negative, this function behaves
+ exactly like <function>xf86Msg()</function>.
+ </para>
+
+ <para>
+ NOTE: This function can only be used after the
+ <structname>ScrnInfoRec</structname> and its <structfield>name</structfield> field
+ have been allocated. Normally, this means that it can not be
+ used before the END of the <function>ChipProbe()</function> function.
+ Prior to that, use <function>xf86Msg()</function>, providing the
+ driver's name explicitly. No screen number can be supplied at
+ that point.
+ </para>
+
+ </blockquote></para></blockquote>
+
+ <blockquote><para>
+ <programlisting>
+ xf86DrvMsgVerb(int scrnIndex, MessageType type, int verb,
+ const char *format, ...);
+ </programlisting>
+ <blockquote><para>
+ Like <function>xf86DrvMsg()</function>, but with the verbosity level
+ given explicitly.
+ </para>
+
+ </blockquote></para></blockquote>
+ </sect2>
+
+
+ <sect2>
+ <title>Functions for setting values based on command line and config file</title>
+
+ <blockquote><para>
+ <programlisting>
+ Bool xf86SetDepthBpp(ScrnInfoPtr scrp, int depth, int bpp,
+
+ int fbbpp, int depth24flags);
+ </programlisting>
+ <blockquote><para>
+ This function sets the <structfield>depth</structfield>, <structfield>pixmapBPP</structfield> and <structfield>bitsPerPixel</structfield> fields
+ of the <structname>ScrnInfoRec</structname>. It also determines the defaults for display-wide
+ attributes and pixmap formats the screen will support, and finds
+ the Display subsection that matches the depth/bpp. This function
+ should normally be called very early from the
+ <function>ChipPreInit()</function> function.
+ </para>
+
+ <para>
+ It requires that the <structfield>confScreen</structfield> field of the <structname>ScrnInfoRec</structname> be
+ initialised prior to calling it. This is done by the XFree86
+ common layer prior to calling <function>ChipPreInit()</function>.
+ </para>
+
+ <para>
+ The parameters passed are:
+
+ <variablelist>
+ <varlistentry>
+ <term><parameter>depth</parameter></term>
+ <listitem><para>
+ driver's preferred default depth if no other is given.
+ If zero, use the overall server default.
+ </para></listitem></varlistentry>
+
+ <varlistentry>
+ <term><parameter>bpp</parameter></term>
+ <listitem><para>
+ Same, but for the pixmap bpp.
+ </para></listitem></varlistentry>
+
+ <varlistentry>
+ <term><parameter>fbbpp</parameter></term>
+ <listitem><para>
+ Same, but for the framebuffer bpp.
+ </para></listitem></varlistentry>
+
+ <varlistentry>
+ <term><parameter>depth24flags</parameter></term>
+ <listitem><para>
+ Flags that indicate the level of 24/32bpp support
+ and whether conversion between different framebuffer
+ and pixmap formats is supported. The flags for this
+ argument are defined as follows, and multiple flags
+ may be ORed together:
+
+ <variablelist>
+ <varlistentry>
+ <term><constant>NoDepth24Support</constant></term>
+ <listitem><para>No depth 24 formats supported
+ </para></listitem></varlistentry>
+ <varlistentry>
+ <term><constant>Support24bppFb</constant></term>
+ <listitem><para>24bpp framebuffer supported
+ </para></listitem></varlistentry>
+ <varlistentry>
+ <term><constant>Support32bppFb</constant></term>
+ <listitem><para>32bpp framebuffer supported
+ </para></listitem></varlistentry>
+ <varlistentry>
+ <term><constant>SupportConvert24to32</constant></term>
+ <listitem><para>Can convert 24bpp pixmap to 32bpp fb
+ </para></listitem></varlistentry>
+ <varlistentry>
+ <term><constant>SupportConvert32to24</constant></term>
+ <listitem><para>Can convert 32bpp pixmap to 24bpp fb
+ </para></listitem></varlistentry>
+ <varlistentry>
+ <term><constant>ForceConvert24to32</constant></term>
+ <listitem><para>Force 24bpp pixmap to 32bpp fb conversion
+ </para></listitem></varlistentry>
+ <varlistentry>
+ <term><constant>ForceConvert32to24</constant></term>
+ <listitem><para>Force 32bpp pixmap to 24bpp fb conversion
+ </para></listitem></varlistentry>
+ </variablelist>
+ </para></listitem></varlistentry>
+
+ </variablelist>
+ </para>
+
+ <para>
+ It uses the command line, config file, and default values in the
+ correct order of precedence to determine the depth and bpp values.
+ It is up to the driver to check the results to see that it supports
+ them. If not the <function>ChipPreInit()</function> function should
+ return <constant>FALSE</constant>.
+ </para>
+
+ <para>
+ If only one of depth/bpp is given, the other is set to a reasonable
+ (and consistent) default.
+ </para>
+
+ <para>
+ If a driver finds that the initial <parameter>depth24flags</parameter>
+ it uses later results in a fb format that requires more video
+ memory than is available it may call this function a second time
+ with a different <parameter>depth24flags</parameter> setting.
+ </para>
+
+ <para>
+ On success, the return value is <constant>TRUE</constant>. On failure
+ it prints an error message and returns <constant>FALSE</constant>.
+ </para>
+
+ <para>
+ The following fields of the <structname>ScrnInfoRec</structname> are
+ initialised by this function:
+
+ <blockquote><para>
+<structfield>depth</structfield>, <structfield>bitsPerPixel</structfield>,
+<structfield>display</structfield>, <structfield>imageByteOrder</structfield>,
+<structfield>bitmapScanlinePad</structfield>,
+<structfield>bitmapScanlineUnit</structfield>, <structfield>bitmapBitOrder</structfield>,
+<structfield>numFormats</structfield>, <structfield>formats</structfield>,
+<structfield>fbFormat</structfield>.
+ </para></blockquote>
+ </para>
+
+ </blockquote></para></blockquote>
+
+ <blockquote><para>
+ <programlisting>
+ void xf86PrintDepthBpp(scrnInfoPtr scrp);
+ </programlisting>
+ <blockquote><para>
+ This function can be used to print out the depth and bpp settings.
+ It should be called after the final call to
+ <function>xf86SetDepthBpp()</function>.
+ </para>
+
+ </blockquote></para></blockquote>
+
+ <blockquote><para>
+ <programlisting>
+ Bool xf86SetWeight(ScrnInfoPtr scrp, rgb weight, rgb mask);
+ </programlisting>
+ <blockquote><para>
+ This function sets the <structfield>weight</structfield>, <structfield>mask</structfield>,
+ <structfield>offset</structfield> and <structfield>rgbBits</structfield> fields of the
+ <structname>ScrnInfoRec</structname>. It would normally be called fairly
+ early in the <function>ChipPreInit()</function> function for
+ depths&nbsp;&gt;&nbsp;8bpp.
+ </para>
+
+ <para>
+ It requires that the <structfield>depth</structfield> and
+ <structfield>display</structfield> fields of the <structname>ScrnInfoRec</structname>
+ be initialised prior to calling it.
+ </para>
+
+ <para>
+ The parameters passed are:
+
+ <variablelist>
+ <varlistentry>
+ <term><parameter>weight</parameter></term>
+ <listitem><para>
+ driver's preferred default weight if no other is given.
+ If zero, use the overall server default.
+
+ </para></listitem></varlistentry>
+
+ <varlistentry>
+ <term><parameter>mask</parameter></term>
+ <listitem><para>
+ Same, but for mask.
+
+ </para></listitem></varlistentry>
+ </variablelist>
+ </para>
+
+ <para>
+ It uses the command line, config file, and default values in the
+ correct order of precedence to determine the weight value. It
+ derives the mask and offset values from the weight and the defaults.
+ It is up to the driver to check the results to see that it supports
+ them. If not the <function>ChipPreInit()</function> function should
+ return <constant>FALSE</constant>.
+ </para>
+
+ <para>
+ On success, this function prints a message showing the weight
+ values selected, and returns <constant>TRUE</constant>.
+ </para>
+
+ <para>
+ On failure it prints an error message and returns <constant>FALSE</constant>.
+ </para>
+
+ <para>
+ The following fields of the <structname>ScrnInfoRec</structname> are
+ initialised by this function:
+
+ <blockquote><para>
+ <structfield>weight</structfield>,
+ <structfield>mask</structfield>,
+ <structfield>offset</structfield>.
+ </para></blockquote>
+ </para>
+
+ </blockquote></para></blockquote>
+
+ <blockquote><para>
+ <programlisting>
+ Bool xf86SetDefaultVisual(ScrnInfoPtr scrp, int visual);
+ </programlisting>
+ <blockquote><para>
+ This function sets the <structfield>defaultVisual</structfield> field of the
+ <structname>ScrnInfoRec</structname>. It would normally be called fairly
+ early from the <function>ChipPreInit()</function> function.
+ </para>
+
+ <para>
+ It requires that the <structfield>depth</structfield> and
+ <structfield>display</structfield> fields of the <structname>ScrnInfoRec</structname>
+ be initialised prior to calling it.
+ </para>
+
+ <para>
+ The parameters passed are:
+
+ <variablelist>
+ <varlistentry>
+ <term><parameter>visual</parameter></term>
+ <listitem><para>
+ driver's preferred default visual if no other is given.
+ If <constant>-1</constant>, use the overall server default.
+ </para></listitem></varlistentry>
+
+ </variablelist>
+ </para>
+
+ <para>
+ It uses the command line, config file, and default values in the
+ correct order of precedence to determine the default visual value.
+ It is up to the driver to check the result to see that it supports
+ it. If not the <function>ChipPreInit()</function> function should
+ return <constant>FALSE</constant>.
+ </para>
+
+ <para>
+ On success, this function prints a message showing the default visual
+ selected, and returns <constant>TRUE</constant>.
+ </para>
+
+ <para>
+ On failure it prints an error message and returns <constant>FALSE</constant>.
+ </para>
+
+ </blockquote></para></blockquote>
+
+ <blockquote><para>
+ <programlisting>
+ Bool xf86SetGamma(ScrnInfoPtr scrp, Gamma gamma);
+ </programlisting>
+ <blockquote><para>
+ This function sets the <structfield>gamma</structfield> field of the
+ <structname>ScrnInfoRec</structname>. It would normally be called fairly
+ early from the <function>ChipPreInit()</function> function in cases
+ where the driver supports gamma correction.
+ </para>
+
+ <para>
+ It requires that the <structfield>monitor</structfield> field of the
+ <structname>ScrnInfoRec</structname> be initialised prior to calling it.
+ </para>
+
+ <para>
+ The parameters passed are:
+
+ <variablelist>
+ <varlistentry>
+ <term><parameter>gamma</parameter></term>
+ <listitem><para>
+ driver's preferred default gamma if no other is given.
+ If zero (<code>&lt; 0.01</code>), use the overall server
+ default.
+ </para></listitem></varlistentry>
+
+ </variablelist>
+ </para>
+
+ <para>
+ It uses the command line, config file, and default values in the
+ correct order of precedence to determine the gamma value. It is
+ up to the driver to check the results to see that it supports
+ them. If not the <function>ChipPreInit()</function> function should
+ return <constant>FALSE</constant>.
+ </para>
+
+ <para>
+ On success, this function prints a message showing the gamma
+ value selected, and returns <constant>TRUE</constant>.
+ </para>
+
+ <para>
+ On failure it prints an error message and returns <constant>FALSE</constant>.
+ </para>
+
+ </blockquote></para></blockquote>
+
+
+ <blockquote><para>
+ <programlisting>
+ void xf86SetDpi(ScrnInfoPtr pScrn, int x, int y);
+ </programlisting>
+ <blockquote><para>
+ This function sets the <structfield>xDpi</structfield> and <structfield>yDpi</structfield>
+ fields of the <structname>ScrnInfoRec</structname>. The driver can specify
+ preferred defaults by setting <parameter>x</parameter> and <parameter>y</parameter>
+ to non-zero values. The <option>-dpi</option> command line option
+ overrides all other settings. Otherwise, if the
+ <emphasis>DisplaySize</emphasis> entry is present in the screen's &k.monitor;
+ config file section, it is used together with the virtual size to
+ calculate the dpi values. This function should be called after
+ all the mode resolution has been done.
+ </para>
+
+ </blockquote></para></blockquote>
+
+ <blockquote><para>
+ <programlisting>
+ void xf86SetBlackWhitePixels(ScrnInfoPtr pScrn);
+ </programlisting>
+ <blockquote><para>
+ This functions sets the <structfield>blackPixel</structfield> and
+ <structfield>whitePixel</structfield> fields of the <structname>ScrnInfoRec</structname>
+ according to whether or not the <option>-flipPixels</option> command
+ line options is present.
+ </para>
+
+ </blockquote></para></blockquote>
+
+ <blockquote><para>
+ <programlisting>
+ const char *xf86GetVisualName(int visual);
+ </programlisting>
+ <blockquote><para>
+ Returns a printable string with the visual name matching the
+ numerical visual class provided. If the value is outside the
+ range of valid visual classes, <constant>NULL</constant> is returned.
+ </para>
+
+ </blockquote></para></blockquote>
+
+ </sect2>
+
+ <sect2>
+ <title>Primary Mode functions</title>
+
+ <para>
+The primary mode helper functions are those which would normally be
+used by a driver, unless it has unusual requirements which cannot
+be catered for the by the helpers.
+ </para>
+
+ <blockquote><para>
+ <programlisting>
+ int xf86ValidateModes(ScrnInfoPtr scrp, DisplayModePtr availModes,
+ char **modeNames, ClockRangePtr clockRanges,
+ int *linePitches, int minPitch, int maxPitch,
+ int pitchInc, int minHeight, int maxHeight,
+ int virtualX, int virtualY,
+ unsigned long apertureSize,
+ LookupModeFlags strategy);
+ </programlisting>
+ <blockquote><para>
+ This function basically selects the set of modes to use based on
+ those available and the various constraints. It also sets some
+ other related parameters. It is normally called near the end of
+ the <function>ChipPreInit()</function> function.
+ </para>
+
+ <para>
+ The parameters passed to the function are:
+
+ <variablelist>
+ <varlistentry>
+ <term><parameter>availModes</parameter></term>
+ <listitem><para>
+ List of modes available for the monitor.
+ </para></listitem></varlistentry>
+
+ <varlistentry>
+ <term><parameter>modeNames</parameter></term>
+ <listitem><para>
+ List of mode names that the screen is requesting.
+ </para></listitem></varlistentry>
+
+ <varlistentry>
+ <term><parameter>clockRanges</parameter></term>
+ <listitem><para>
+ A list of clock ranges allowed by the driver. Each
+ range includes whether interlaced or multiscan modes
+ are supported for that range. See below for more on
+ <parameter>clockRanges</parameter>.
+ </para></listitem></varlistentry>
+
+ <varlistentry>
+ <term><parameter>linePitches</parameter></term>
+ <listitem><para>
+ List of line pitches supported by the driver.
+ This is optional and should be <constant>NULL</constant> when
+ not used.
+ </para></listitem></varlistentry>
+
+ <varlistentry>
+ <term><parameter>minPitch</parameter></term>
+ <listitem><para>
+ Minimum line pitch supported by the driver. This must
+ be supplied when <parameter>linePitches</parameter> is
+ <constant>NULL</constant>, and is ignored otherwise.
+ </para></listitem></varlistentry>
+
+ <varlistentry>
+ <term><parameter>maxPitch</parameter></term>
+ <listitem><para>
+ Maximum line pitch supported by the driver. This is
+ required when <parameter>minPitch</parameter> is required.
+ </para></listitem></varlistentry>
+
+ <varlistentry>
+ <term><parameter>pitchInc</parameter></term>
+ <listitem><para>
+ Granularity of horizontal pitch values as supported by
+ the chipset. This is expressed in bits. This must be
+ supplied.
+ </para></listitem></varlistentry>
+
+ <varlistentry>
+ <term><parameter>minHeight</parameter></term>
+ <listitem><para>
+ minimum virtual height allowed. If zero, no limit is
+ imposed.
+ </para></listitem></varlistentry>
+
+ <varlistentry>
+ <term><parameter>maxHeight</parameter></term>
+ <listitem><para>
+ maximum virtual height allowed. If zero, no limit is
+ imposed.
+ </para></listitem></varlistentry>
+
+ <varlistentry>
+ <term><parameter>virtualX</parameter></term>
+ <listitem><para>
+ If greater than zero, this is the virtual width value
+ that will be used. Otherwise, the virtual width is
+ chosen to be the smallest that can accommodate the modes
+ selected.
+ </para></listitem></varlistentry>
+
+ <varlistentry>
+ <term><parameter>virtualY</parameter></term>
+ <listitem><para>
+ If greater than zero, this is the virtual height value
+ that will be used. Otherwise, the virtual height is
+ chosen to be the smallest that can accommodate the modes
+ selected.
+ </para></listitem></varlistentry>
+
+ <varlistentry>
+ <term><parameter>apertureSize</parameter></term>
+ <listitem><para>
+ The size (in bytes) of the aperture used to access video
+ memory.
+ </para></listitem></varlistentry>
+
+ <varlistentry>
+ <term><parameter>strategy</parameter></term>
+ <listitem><para>
+ The strategy to use when choosing from multiple modes
+ with the same name. The options are:
+
+ <variablelist>
+ <varlistentry>
+ <term><constant>LOOKUP_DEFAULT</constant></term>
+ <listitem><para>???
+ </para></listitem></varlistentry>
+ <varlistentry>
+ <term><constant>LOOKUP_BEST_REFRESH</constant></term>
+ <listitem><para>mode with best refresh rate
+ </para></listitem></varlistentry>
+ <varlistentry>
+ <term><constant>LOOKUP_CLOSEST_CLOCK</constant></term>
+ <listitem><para>mode with closest matching clock
+ </para></listitem></varlistentry>
+ <varlistentry>
+ <term><constant>LOOKUP_LIST_ORDER</constant></term>
+ <listitem><para>first usable mode in list
+ </para></listitem></varlistentry>
+ </variablelist>
+
+ The following options can also be combined (OR'ed) with
+ one of the above:
+
+ <variablelist>
+ <varlistentry>
+ <term><constant>LOOKUP_CLKDIV2</constant></term>
+ <listitem><para>Allow halved clocks
+ </para></listitem></varlistentry>
+ <varlistentry>
+ <term><constant>LOOKUP_OPTIONAL_TOLERANCES</constant></term>
+ <listitem><para>
+ Allow missing horizontal sync and/or vertical refresh
+ ranges in the xorg.conf Monitor section
+ </para></listitem></varlistentry>
+ </variablelist>
+
+ <constant>LOOKUP_OPTIONAL_TOLERANCES</constant> should only be
+ specified when the driver can ensure all modes it generates
+ can sync on, or at least not damage, the monitor or digital
+ flat panel. Horizontal sync and/or vertical refresh ranges
+ specified by the user will still be honoured (and acted upon).
+
+ </para></listitem></varlistentry>
+ </variablelist>
+ </para>
+
+ <para>
+ This function requires that the following fields of the
+ <structname>ScrnInfoRec</structname> are initialised prior to calling it:
+
+ <variablelist>
+ <varlistentry>
+ <term><structfield>clock[]</structfield></term>
+ <listitem><para>
+ List of discrete clocks (when non-programmable)
+ </para></listitem></varlistentry>
+ <varlistentry>
+ <term><structfield>numClocks</structfield></term>
+ <listitem><para>
+ Number of discrete clocks (when non-programmable)
+ </para></listitem></varlistentry>
+ <varlistentry>
+ <term><structfield>progClock</structfield></term>
+ <listitem><para>
+ Whether the clock is programmable or not
+ </para></listitem></varlistentry>
+ <varlistentry>
+ <term><structfield>monitor</structfield></term>
+ <listitem><para>
+ Pointer to the applicable xorg.conf monitor section
+ </para></listitem></varlistentry>
+ <varlistentry>
+ <term><structfield>fdFormat</structfield></term>
+ <listitem><para>
+ Format of the screen buffer
+ </para></listitem></varlistentry>
+ <varlistentry>
+ <term><structfield>videoRam</structfield></term>
+ <listitem><para>
+ total video memory size (in bytes)
+ </para></listitem></varlistentry>
+ <varlistentry>
+ <term><structfield>maxHValue</structfield></term>
+ <listitem><para>
+ Maximum horizontal timing value allowed
+ </para></listitem></varlistentry>
+ <varlistentry>
+ <term><structfield>maxVValue</structfield></term>
+ <listitem><para>
+ Maximum vertical timing value allowed
+ </para></listitem></varlistentry>
+ <varlistentry>
+ <term><structfield>xInc</structfield></term>
+ <listitem><para>
+ Horizontal timing increment in pixels (defaults to 8)
+ </para></listitem></varlistentry>
+ </variablelist>
+ </para>
+
+ <para>
+ This function fills in the following <structname>ScrnInfoRec</structname>
+ fields:
+
+ <variablelist>
+ <varlistentry>
+ <term><structfield>modePool</structfield></term>
+ <listitem><para>
+ A subset of the modes available to the monitor which
+ are compatible with the driver.
+ </para></listitem></varlistentry>
+
+ <varlistentry>
+ <term><structfield>modes</structfield></term>
+ <listitem><para>
+ One mode entry for each of the requested modes, with
+ the status field of each filled in to indicate if
+ the mode has been accepted or not. This list of
+ modes is a circular list.
+ </para></listitem></varlistentry>
+
+ <varlistentry>
+ <term><structfield>virtualX</structfield></term>
+ <listitem><para>
+ The resulting virtual width.
+ </para></listitem></varlistentry>
+
+ <varlistentry>
+ <term><structfield>virtualY</structfield></term>
+ <listitem><para>
+ The resulting virtual height.
+ </para></listitem></varlistentry>
+
+ <varlistentry>
+ <term><structfield>displayWidth</structfield></term>
+ <listitem><para>
+ The resulting line pitch.
+ </para></listitem></varlistentry>
+
+ <varlistentry>
+ <term><structfield>virtualFrom</structfield></term>
+ <listitem><para>
+ Where the virtual size was determined from.
+ </para></listitem></varlistentry>
+
+ </variablelist>
+ </para>
+
+ <para>
+ The first stage of this function checks that the
+ <parameter>virtualX</parameter> and <parameter>virtualY</parameter> values
+ supplied (if greater than zero) are consistent with the line pitch
+ and <parameter>maxHeight</parameter> limitations. If not, an error
+ message is printed, and the return value is <constant>-1</constant>.
+ </para>
+
+ <para>
+ The second stage sets up the mode pool, eliminating immediately
+ any modes that exceed the driver's line pitch limits, and also
+ the virtual width and height limits (if greater than zero). For
+ each mode removed an informational message is printed at verbosity
+ level <constant>2</constant>. If the mode pool ends up being empty,
+ a warning message is printed, and the return value is
+ <constant>0</constant>.
+ </para>
+
+ <para>
+ The final stage is to lookup each mode name, and fill in the remaining
+ parameters. If an error condition is encountered, a message is
+ printed, and the return value is <constant>-1</constant>. Otherwise,
+ the return value is the number of valid modes found
+ (<constant>0</constant> if none are found).
+ </para>
+
+ <para>
+ Even if the supplied mode names include duplicates, no two names will
+ ever match the same mode. Furthermore, if the supplied mode names do not
+ yield a valid mode (including the case where no names are passed at all),
+ the function will continue looking through the mode pool until it finds
+ a mode that survives all checks, or until the mode pool is exhausted.
+ </para>
+
+ <para>
+ A message is only printed by this function when a fundamental
+ problem is found. It is intended that this function may be called
+ more than once if there is more than one set of constraints that
+ the driver can work within.
+ </para>
+
+ <para>
+ If this function returns <constant>-1</constant>, the
+ <function>ChipPreInit()</function> function should return
+ <constant>FALSE</constant>.
+ </para>
+
+ <para>
+ <parameter>clockRanges</parameter> is a linked list of clock ranges
+ allowed by the driver. If a mode doesn't fit in any of the defined
+ <parameter>clockRanges</parameter>, it is rejected. The first
+ <literal remap="tt">clockRange</literal> that matches all requirements is used.
+ This structure needs to be initialized to NULL when allocated.
+ </para>
+
+ <para>
+ <parameter>clockRanges</parameter> contains the following fields:
+
+ <variablelist>
+ <varlistentry>
+ <term><structfield>minClock</structfield></term>
+ <term><structfield>maxClock</structfield></term>
+ <listitem><para>
+ The lower and upper mode clock bounds for which the rest
+ of the <structname>clockRange</structname> parameters apply.
+ Since these are the mode clocks, they are not scaled
+ with the <structfield>ClockMulFactor</structfield> and
+ <structfield>ClockDivFactor</structfield>. It is up to the driver
+ to adjust these values if they depend on the clock
+ scaling factors.
+ </para></listitem></varlistentry>
+
+ <varlistentry>
+ <term><structfield>clockIndex</structfield></term>
+ <listitem><para>
+ (not used yet) <constant>-1</constant> for programmable clocks
+ </para></listitem></varlistentry>
+
+ <varlistentry>
+ <term><structfield>interlaceAllowed</structfield></term>
+ <listitem><para>
+ <constant>TRUE</constant> if interlacing is allowed for this
+ range
+ </para></listitem></varlistentry>
+
+ <varlistentry>
+ <term><structfield>doubleScanAllowed</structfield></term>
+ <listitem><para>
+ <constant>TRUE</constant> if doublescan or multiscan is allowed
+ for this range
+ </para></listitem></varlistentry>
+
+ <varlistentry>
+ <term><structfield>ClockMulFactor</structfield></term>
+ <term><structfield>ClockDivFactor</structfield></term>
+ <listitem><para>
+ Scaling factors that are applied to the mode clocks ONLY
+ before selecting a clock index (when there is no
+ programmable clock) or a <structfield>SynthClock</structfield>
+ value. This is useful for drivers that support pixel
+ multiplexing or that need to scale the clocks because
+ of hardware restrictions (like sending 24bpp data to an
+ 8 bit RAMDAC using a tripled clock).
+ </para>
+
+ <para>
+ Note that these parameters describe what must be done
+ to the mode clock to achieve the data transport clock
+ between graphics controller and RAMDAC. For example
+ for <literal remap="tt">2:1</literal> pixel multiplexing, two pixels
+ are sent to the RAMDAC on each clock. This allows the
+ RAMDAC clock to be half of the actual pixel clock.
+ Hence, <code>ClockMulFactor=1</code> and
+ <code>ClockDivFactor=2</code>. This means that the
+ clock used for clock selection (ie, determining the
+ correct clock index from the list of discrete clocks)
+ or for the <structfield>SynthClock</structfield> field in case of
+ a programmable clock is: (<code>mode-&gt;Clock *
+ ClockMulFactor) / ClockDivFactor</code>.
+ </para></listitem></varlistentry>
+
+ <varlistentry>
+ <term><structfield>PrivFlags</structfield></term>
+ <listitem><para>
+ This field is copied into the
+ <literal remap="tt">mode-&gt;PrivFlags</literal> field when this
+ <literal remap="tt">clockRange</literal> is selected by
+ <function>xf86ValidateModes()</function>. It allows the
+ driver to find out what clock range was selected, so it
+ knows it needs to set up pixel multiplexing or any other
+ range-dependent feature. This field is purely
+ driver-defined: it may contain flag bits, an index or
+ anything else (as long as it is an <literal remap="tt">INT</literal>).
+ </para></listitem></varlistentry>
+ </variablelist>
+ </para>
+
+ <para>
+ Note that the <structfield>mode-&gt;SynthClock</structfield> field is always
+ filled in by <function>xf86ValidateModes()</function>: it will contain
+ the <quote>data transport clock</quote>, which is the clock that will have
+ to be programmed in the chip when it has a programmable clock, or
+ the clock that will be picked from the clocks list when it is not
+ a programmable one. Thus:
+
+ <programlisting>
+ mode-&gt;SynthClock = (mode-&gt;Clock * ClockMulFactor) / ClockDivFactor
+ </programlisting>
+ </para>
+
+ </blockquote></para></blockquote>
+
+ <blockquote><para>
+ <programlisting>
+ void xf86PruneDriverModes(ScrnInfoPtr scrp);
+ </programlisting>
+ <blockquote><para>
+ This function deletes modes in the modes field of the
+ <structname>ScrnInfoRec</structname> that have been marked as invalid.
+ This is normally run after having run
+ <function>xf86ValidateModes()</function> for the last time. For each
+ mode that is deleted, a warning message is printed out indicating
+ the reason for it being deleted.
+ </para>
+
+ </blockquote></para></blockquote>
+
+ <blockquote><para>
+ <programlisting>
+ void xf86SetCrtcForModes(ScrnInfoPtr scrp, int adjustFlags);
+ </programlisting>
+ <blockquote><para>
+ This function fills in the <structname>Crtc*</structname> fields for all
+ the modes in the <structfield>modes</structfield> field of the
+ <structname>ScrnInfoRec</structname>. The <parameter>adjustFlags</parameter>
+ parameter determines how the vertical CRTC values are scaled for
+ interlaced modes. They are halved if it is
+ <constant>INTERLACE_HALVE_V</constant>. The vertical CRTC values are
+ doubled for doublescan modes, and are further multiplied by the
+ <literal remap="tt">VScan</literal> value.
+ </para>
+
+ <para>
+ This function is normally called after calling
+ <function>xf86PruneDriverModes()</function>.
+ </para>
+
+ </blockquote></para></blockquote>
+
+ <blockquote><para>
+ <programlisting>
+ void xf86PrintModes(ScrnInfoPtr scrp);
+ </programlisting>
+ <blockquote><para>
+ This function prints out the virtual size setting, and the line
+ pitch being used. It also prints out two lines for each mode being
+ used. The first line includes the mode's pixel clock, horizontal sync
+ rate, refresh rate, and whether it is interlaced, doublescanned and/or
+ multi-scanned. The second line is the mode's Modeline.
+ </para>
+
+ <para>
+ This function is normally called after calling
+ <function>xf86SetCrtcForModes()</function>.
+ </para>
+
+ </blockquote></para></blockquote>
+
+ </sect2>
+
+ <sect2>
+ <title>Secondary Mode functions</title>
+
+ <para>
+The secondary mode helper functions are functions which are normally
+used by the primary mode helper functions, and which are not normally
+called directly by a driver. If a driver has unusual requirements
+and needs to do its own mode validation, it might be able to make
+use of some of these secondary mode helper functions.
+ </para>
+
+ <blockquote><para>
+ <programlisting>
+ int xf86GetNearestClock(ScrnInfoPtr scrp, int freq, Bool allowDiv2,
+ int *divider);
+ </programlisting>
+ <blockquote><para>
+ This function returns the index of the closest clock to the
+ frequency <parameter>freq</parameter> given (in kHz). It assumes that
+ the number of clocks is greater than zero. It requires that the
+ <structfield>numClocks</structfield> and <structfield>clock</structfield> fields of the
+ <structname>ScrnInfoRec</structname> are initialised. The
+ <structfield>allowDiv2</structfield> field determines if the clocks can be
+ halved. The <parameter>*divider</parameter> return value indicates
+ whether clock division is used when determining the clock returned.
+ </para>
+
+ <para>
+ This function is only for non-programmable clocks.
+ </para>
+
+ </blockquote></para></blockquote>
+
+ <blockquote><para>
+ <programlisting>
+ const char *xf86ModeStatusToString(ModeStatus status);
+ </programlisting>
+ <blockquote><para>
+ This function converts the <parameter>status</parameter> value to a
+ descriptive printable string.
+ </para>
+
+ </blockquote></para></blockquote>
+
+ <blockquote><para>
+ <programlisting>
+ ModeStatus xf86LookupMode(ScrnInfoPtr scrp, DisplayModePtr modep,
+ ClockRangePtr clockRanges, LookupModeFlags strategy);
+ </programlisting>
+ <blockquote><para>
+ This function takes a pointer to a mode with the name filled in,
+ and looks for a mode in the <structfield>modePool</structfield> list which
+ matches. The parameters of the matching mode are filled in to
+ <parameter>*modep</parameter>. The <parameter>clockRanges</parameter> and
+ <parameter>strategy</parameter> parameters are as for the
+ <function>xf86ValidateModes()</function> function above.
+ </para>
+
+ <para>
+ This function requires the <structfield>modePool</structfield>,
+ <structfield>clock[]</structfield>, <structfield>numClocks</structfield> and
+ <structfield>progClock</structfield> fields of the <structname>ScrnInfoRec</structname>
+ to be initialised before being called.
+ </para>
+
+ <para>
+ The return value is <constant>MODE_OK</constant> if a mode was found.
+ Otherwise it indicates why a matching mode could not be found.
+ </para>
+
+ </blockquote></para></blockquote>
+
+ <blockquote><para>
+ <programlisting>
+ ModeStatus xf86InitialCheckModeForDriver(ScrnInfoPtr scrp,
+ DisplayModePtr mode, ClockRangePtr clockRanges,
+ LookupModeFlags strategy, int maxPitch,
+ int virtualX, int virtualY);
+ </programlisting>
+ <blockquote><para>
+ This function checks the passed mode against some basic driver
+ constraints. Apart from the ones passed explicitly, the
+ <structfield>maxHValue</structfield> and <structfield>maxVValue</structfield> fields of
+ the <structname>ScrnInfoRec</structname> are also used. If the
+ <structfield>ValidMode</structfield> field of the <structname>ScrnInfoRec</structname>
+ is set, that function is also called to check the mode. Next, the
+ mode is checked against the monitor's constraints.
+ </para>
+
+ <para>
+ If the mode is consistent with all constraints, the return value
+ is <constant>MODE_OK</constant>. Otherwise the return value indicates
+ which constraint wasn't met.
+ </para>
+
+ </blockquote></para></blockquote>
+
+ <blockquote><para>
+ <programlisting>
+ void xf86DeleteMode(DisplayModePtr *modeList, DisplayModePtr mode);
+ </programlisting>
+ <blockquote><para>
+ This function deletes the <parameter>mode</parameter> given from the
+ <parameter>modeList</parameter>. It never prints any messages, so it is
+ up to the caller to print a message if required.
+ </para>
+
+ </blockquote></para></blockquote>
+ </sect2>
+
+ <sect2>
+ <title>Functions for handling strings and tokens</title>
+
+ <para>
+ Tables associating strings and numerical tokens combined with the
+ following functions provide a compact way of handling strings from
+ the config file, and for converting tokens into printable strings.
+ The table data structure is:
+
+ <programlisting>
+typedef struct {
+ int token;
+ const char * name;
+} SymTabRec, *SymTabPtr;
+ </programlisting>
+ </para>
+
+ <para>
+ A table is an initialised array of <structname>SymTabRec</structname>. The
+ tokens must be non-negative integers. Multiple names may be mapped
+ to a single token. The table is terminated with an element with a
+ <structfield>token</structfield> value of <constant>-1</constant> and
+ <constant>NULL</constant> for the <structfield>name</structfield>.
+ </para>
+
+ <blockquote><para>
+ <programlisting>
+ const char *xf86TokenToString(SymTabPtr table, int token);
+ </programlisting>
+ <blockquote><para>
+ This function returns the first string in <parameter>table</parameter>
+ that matches <parameter>token</parameter>. If no match is found,
+ <constant>NULL</constant> is returned (NOTE, older versions of this
+ function would return the string "unknown" when no match is found).
+ </para>
+
+ </blockquote></para></blockquote>
+
+ <blockquote><para>
+ <programlisting>
+ int xf86StringToToken(SymTabPtr table, const char *string);
+ </programlisting>
+ <blockquote><para>
+ This function returns the first token in <parameter>table</parameter>
+ that matches <parameter>string</parameter>. The
+ <function>xf86NameCmp()</function> function is used to determine the
+ match. If no match is found, <constant>-1</constant> is returned.
+ </para>
+
+ </blockquote></para></blockquote>
+
+ </sect2>
+
+ <sect2>
+ <title>Functions for finding which config file entries to use</title>
+
+ <para>
+ These functions can be used to select the appropriate config file
+ entries that match the detected hardware. They are described above
+ in the <link linkend="probe">Probe</link> and
+ <link linkend="avail">Available Functions</link> sections.
+ </para>
+
+ </sect2>
+
+ <sect2>
+ <title>Probing discrete clocks on old hardware</title>
+
+ <para>
+ The <function>xf86GetClocks()</function> function may be used to assist
+ in finding the discrete pixel clock values on older hardware.
+ </para>
+
+ <blockquote><para>
+ <programlisting>
+ void xf86GetClocks(ScrnInfoPtr pScrn, int num,
+ Bool (*ClockFunc)(ScrnInfoPtr, int),
+ void (*ProtectRegs)(ScrnInfoPtr, Bool),
+ void (*BlankScreen)(ScrnInfoPtr, Bool),
+ int vertsyncreg, int maskval, int knownclkindex,
+ int knownclkvalue);
+ </programlisting>
+ <blockquote><para>
+ This function uses a comparative sampling method to measure the
+ discrete pixel clock values. The number of discrete clocks to
+ measure is given by <parameter>num</parameter>. <parameter>clockFunc</parameter>
+ is a function that selects the <parameter>n</parameter>'th clock. It
+ should also save or restore any state affected by programming the
+ clocks when the index passed is <constant>CLK_REG_SAVE</constant> or
+ <constant>CLK_REG_RESTORE</constant>. <parameter>ProtectRegs</parameter> is
+ a function that does whatever is required to protect the hardware
+ state while selecting a new clock. <parameter>BlankScreen</parameter>
+ is a function that blanks the screen. <parameter>vertsyncreg</parameter>
+ and <parameter>maskval</parameter> are the register and bitmask to
+ check for the presence of vertical sync pulses.
+ <parameter>knownclkindex</parameter> and <parameter>knownclkvalue</parameter>
+ are the index and value of a known clock. These are the known
+ references on which the comparative measurements are based. The
+ number of clocks probed is set in <structfield>pScrn-&gt;numClocks</structfield>,
+ and the probed clocks are set in the <structfield>pScrn-&gt;clock[]</structfield>
+ array. All of the clock values are in units of kHz.
+ </para>
+
+ </blockquote></para></blockquote>
+
+ <blockquote><para>
+ <programlisting>
+ void xf86ShowClocks(ScrnInfoPtr scrp, MessageType from);
+ </programlisting>
+ <blockquote><para>
+ Print out the pixel clocks <parameter>scrp-&gt;clock[]</parameter>.
+ <parameter>from</parameter> indicates whether the clocks were probed
+ or from the config file.
+ </para>
+
+ </blockquote></para></blockquote>
+ </sect2>
+
+ <sect2>
+ <title>Other helper functions</title>
+
+ <blockquote><para>
+ <programlisting>
+ Bool xf86IsUnblank(int mode);
+ </programlisting>
+ <blockquote><para>
+ Returns <constant>TRUE</constant> when the screen saver mode specified
+ by <parameter>mode</parameter> requires the screen be unblanked,
+ and <constant>FALSE</constant> otherwise. The screen saver modes that
+ require blanking are <constant>SCREEN_SAVER_ON</constant> and
+ <constant>SCREEN_SAVER_CYCLE</constant>, and the screen saver modes that
+ require unblanking are <constant>SCREEN_SAVER_OFF</constant> and
+ <constant>SCREEN_SAVER_FORCER</constant>. Drivers may call this helper
+ from their <function>SaveScreen()</function> function to interpret the
+ screen saver modes.
+ </para>
+
+ </blockquote></para></blockquote>
+ </sect2>
+ </sect1>
+
+ <sect1>
+ <title>The vgahw module</title>
+
+ <para>
+The vgahw modules provides an interface for saving, restoring and
+programming the standard VGA registers, and for handling VGA colourmaps.
+ </para>
+
+ <sect2>
+ <title>Data Structures</title>
+
+ <para>
+ The public data structures used by the vgahw module are
+ <structname>vgaRegRec</structname> and <structname>vgaHWRec</structname>. They are
+ defined in <filename>vgaHW.h.</filename>
+ </para>
+
+ </sect2>
+
+ <sect2>
+ <title>General vgahw Functions</title>
+
+ <blockquote><para>
+ <programlisting>
+ Bool vgaHWGetHWRec(ScrnInfoPtr pScrn);
+ </programlisting>
+ <blockquote><para>
+ This function allocates a <structname>vgaHWRec</structname> structure, and
+ hooks it into the <structname>ScrnInfoRec</structname>'s
+ <structfield>privates</structfield>. Like all information hooked into the
+ <structfield>privates</structfield>, it is persistent, and only needs to be
+ allocated once per screen. This function should normally be called
+ from the driver's <function>ChipPreInit()</function> function. The
+ <structname>vgaHWRec</structname> is zero-allocated, and the following
+ fields are explicitly initialised:
+
+ <variablelist>
+ <varlistentry>
+ <term><structfield>ModeReg.DAC[]</structfield></term>
+ <listitem><para>initialised with a default colourmap
+ </para></listitem></varlistentry>
+ <varlistentry>
+ <term><structfield>ModeReg.Attribute[0x11]</structfield></term>
+ <listitem><para>initialised with the default overscan index
+ </para></listitem></varlistentry>
+ <varlistentry>
+ <term><structfield>ShowOverscan</structfield></term>
+ <listitem><para>initialised according to the "ShowOverscan" option
+ </para></listitem></varlistentry>
+ <varlistentry>
+ <term><structfield>paletteEnabled</structfield></term>
+ <listitem><para>initialised to FALSE
+ </para></listitem></varlistentry>
+ <varlistentry>
+ <term><structfield>cmapSaved</structfield></term>
+ <listitem><para>initialised to FALSE
+ </para></listitem></varlistentry>
+ <varlistentry>
+ <term><structfield>pScrn</structfield></term>
+ <listitem><para>initialised to pScrn
+ </para></listitem></varlistentry>
+ </variablelist>
+ </para>
+
+ <para>
+ In addition to the above, <function>vgaHWSetStdFuncs()</function> is
+ called to initialise the register access function fields with the
+ standard VGA set of functions.
+ </para>
+
+ <para>
+ Once allocated, a pointer to the <structname>vgaHWRec</structname> can be
+ obtained from the <literal remap="tt">ScrnInfoPtr</literal> with the
+ <literal remap="tt">VGAHWPTR(pScrn)</literal> macro.
+ </para>
+
+ </blockquote></para></blockquote>
+
+ <blockquote><para>
+ <programlisting>
+ void vgaHWFreeHWRec(ScrnInfoPtr pScrn);
+ </programlisting>
+ <blockquote><para>
+ This function frees a <structname>vgaHWRec</structname> structure. It
+ should be called from a driver's <function>ChipFreeScreen()</function>
+ function.
+ </para>
+
+ </blockquote></para></blockquote>
+
+ <blockquote><para>
+ <programlisting>
+ Bool vgaHWSetRegCounts(ScrnInfoPtr pScrn, int numCRTC,
+ int numSequencer, int numGraphics, int numAttribute);
+ </programlisting>
+ <blockquote><para>
+ This function allows the number of CRTC, Sequencer, Graphics and
+ Attribute registers to be changed. This makes it possible for
+ extended registers to be saved and restored with
+ <function>vgaHWSave()</function> and <function>vgaHWRestore()</function>.
+ This function should be called after a <structname>vgaHWRec</structname>
+ has been allocated with <function>vgaHWGetHWRec()</function>. The
+ default values are defined in <filename>vgaHW.h</filename> as follows:
+
+ <programlisting>
+#define VGA_NUM_CRTC 25
+#define VGA_NUM_SEQ 5
+#define VGA_NUM_GFX 9
+#define VGA_NUM_ATTR 21
+ </programlisting>
+ </para>
+
+ </blockquote></para></blockquote>
+
+ <blockquote><para>
+ <programlisting>
+ Bool vgaHWCopyReg(vgaRegPtr dst, vgaRegPtr src);
+ </programlisting>
+ <blockquote><para>
+ This function copies the contents of the VGA saved registers in
+ <parameter>src</parameter> to <parameter>dst</parameter>. Note that it isn't
+ possible to simply do this with <function>memcpy()</function> (or
+ similar). This function returns <constant>TRUE</constant> unless there
+ is a problem allocating space for the <structfield>CRTC</structfield> and
+ related fields in <parameter>dst</parameter>.
+ </para>
+
+ </blockquote></para></blockquote>
+
+ <blockquote><para>
+ <programlisting>
+ void vgaHWSetStdFuncs(vgaHWPtr hwp);
+ </programlisting>
+ <blockquote><para>
+ This function initialises the register access function fields of
+ <parameter>hwp</parameter> with the standard VGA set of functions. This
+ is called by <function>vgaHWGetHWRec()</function>, so there is usually
+ no need to call this explicitly. The register access functions
+ are described below. If the registers are shadowed in some other
+ port I/O space (for example a PCI I/O region), these functions
+ can be used to access the shadowed registers if
+ <structfield>hwp-&gt;PIOOffset</structfield> is initialised with
+ <literal remap="tt">offset</literal>, calculated in such a way that when the
+ standard VGA I/O port value is added to it the correct offset into
+ the PIO area results. This value is initialised to zero in
+ <function>vgaHWGetHWRec()</function>. (Note: the PIOOffset functionality
+ is present in XFree86 4.1.0 and later.)
+ </para>
+
+ </blockquote></para></blockquote>
+
+ <blockquote><para>
+ <programlisting>
+ void vgaHWSetMmioFuncs(vgaHWPtr hwp, CARD8 *base, int offset);
+ </programlisting>
+ <blockquote><para>
+ This function initialised the register access function fields of
+ hwp with a generic MMIO set of functions.
+ <structfield>hwp-&gt;MMIOBase</structfield> is initialised with
+ <parameter>base</parameter>, which must be the virtual address that the
+ start of MMIO area is mapped to. <structfield>hwp-&gt;MMIOOffset</structfield>
+ is initialised with <parameter>offset</parameter>, which must be calculated
+ in such a way that when the standard VGA I/O port value is added
+ to it the correct offset into the MMIO area results. That means
+ that these functions are only suitable when the VGA I/O ports are
+ made available in a direct mapping to the MMIO space. If that is
+ not the case, the driver will need to provide its own register
+ access functions. The register access functions are described
+ below.
+ </para>
+
+ </blockquote></para></blockquote>
+
+ <blockquote><para>
+ <programlisting>
+ Bool vgaHWMapMem(ScrnInfoPtr pScrn);
+ </programlisting>
+ <blockquote><para>
+ This function maps the VGA memory window. It requires that the
+ <structname>vgaHWRec</structname> be allocated. If a driver requires
+ non-default <structfield>MapPhys</structfield> or <structfield>MapSize</structfield>
+ settings (the physical location and size of the VGA memory window)
+ then those fields of the <structname>vgaHWRec</structname> must be initialised
+ before calling this function. Otherwise, this function initialiases
+ the default values of <constant>0xA0000</constant> for
+ <structfield>MapPhys</structfield> and <code>(64&nbsp;*&nbsp;1024)</code> for
+ <structfield>MapSize</structfield>. This function must be called before
+ attempting to save or restore the VGA state. If the driver doesn't
+ call it explicitly, the <function>vgaHWSave()</function> and
+ <function>vgaHWRestore()</function> functions may call it if they need
+ to access the VGA memory (in which case they will also call
+ <function>vgaHWUnmapMem()</function> to unmap the VGA memory before
+ exiting).
+ </para>
+
+ </blockquote></para></blockquote>
+
+ <blockquote><para>
+ <programlisting>
+ void vgaHWUnmapMem(ScrnInfoPtr pScrn);
+ </programlisting>
+ <blockquote><para>
+ This function unmaps the VGA memory window. It must only be called
+ after the memory has been mapped. The <structfield>Base</structfield> field
+ of the <structname>vgaHWRec</structname> field is set to <constant>NULL</constant>
+ to indicate that the memory is no longer mapped.
+ </para>
+
+ </blockquote></para></blockquote>
+
+ <blockquote><para>
+ <programlisting>
+ void vgaHWGetIOBase(vgaHWPtr hwp);
+ </programlisting>
+ <blockquote><para>
+ This function initialises the <structfield>IOBase</structfield> field of the
+ <structname>vgaHWRec</structname>. This function must be called before
+ using any other functions that access the video hardware.
+ </para>
+
+ <para>
+ A macro <function>VGAHW_GET_IOBASE()</function> is also available in
+ <filename>vgaHW.h</filename> that returns the I/O base, and this may
+ be used when the vgahw module is not loaded (for example, in the
+ <function>ChipProbe()</function> function).
+ </para>
+
+ </blockquote></para></blockquote>
+
+ <blockquote><para>
+ <programlisting>
+ void vgaHWUnlock(vgaHWPtr hwp);
+ </programlisting>
+ <blockquote><para>
+ This function unlocks the VGA <literal remap="tt">CRTC[0-7]</literal> registers,
+ and must be called before attempting to write to those registers.
+ </para>
+
+ </blockquote></para></blockquote>
+
+ <blockquote><para>
+ <programlisting>
+ void vgaHWLock(vgaHWPtr hwp);
+ </programlisting>
+ <blockquote><para>
+ This function locks the VGA <literal remap="tt">CRTC[0-7]</literal> registers.
+ </para>
+
+ </blockquote></para></blockquote>
+
+ <blockquote><para>
+ <programlisting>
+ void vgaHWEnable(vgaHWPtr hwp);
+ </programlisting>
+ <blockquote><para>
+ This function enables the VGA subsystem. (Note, this function is
+ present in XFree86 4.1.0 and later.).
+ </para>
+
+ </blockquote></para></blockquote>
+
+ <blockquote><para>
+ <programlisting>
+ void vgaHWDisable(vgaHWPtr hwp);
+ </programlisting>
+ <blockquote><para>
+ This function disables the VGA subsystem. (Note, this function is
+ present in XFree86 4.1.0 and later.).
+ </para>
+
+ </blockquote></para></blockquote>
+
+ <blockquote><para>
+ <programlisting>
+ void vgaHWSave(ScrnInfoPtr pScrn, vgaRegPtr save, int flags);
+ </programlisting>
+ <blockquote><para>
+ This function saves the VGA state. The state is written to the
+ <structname>vgaRegRec</structname> pointed to by <parameter>save</parameter>.
+ <parameter>flags</parameter> is set to one or more of the following flags
+ ORed together:
+
+ <variablelist>
+ <varlistentry>
+ <term><constant>VGA_SR_MODE</constant></term>
+ <listitem><para>the mode setting registers are saved
+ </para></listitem></varlistentry>
+ <varlistentry>
+ <term><constant>VGA_SR_FONTS</constant></term>
+ <listitem><para>the text mode font/text data is saved
+ </para></listitem></varlistentry>
+ <varlistentry>
+ <term><constant>VGA_SR_CMAP</constant></term>
+ <listitem><para>the colourmap (LUT) is saved
+ </para></listitem></varlistentry>
+ <varlistentry>
+ <term><constant>VGA_SR_ALL</constant></term>
+ <listitem><para>all of the above are saved
+ </para></listitem></varlistentry>
+ </variablelist>
+ </para>
+
+ <para>
+ The <structname>vgaHWRec</structname> and its <structfield>IOBase</structfield> fields
+ must be initialised before this function is called. If
+ <constant>VGA_SR_FONTS</constant> is set in <parameter>flags</parameter>, the
+ VGA memory window must be mapped. If it isn't then
+ <function>vgaHWMapMem()</function> will be called to map it, and
+ <function>vgaHWUnmapMem()</function> will be called to unmap it
+ afterwards. <function>vgaHWSave()</function> uses the three functions
+ below in the order <function>vgaHWSaveColormap()</function>,
+ <function>vgaHWSaveMode()</function>, <function>vgaHWSaveFonts()</function> to
+ carry out the different save phases. It is undecided at this
+ stage whether they will remain part of the vgahw module's public
+ interface or not.
+ </para>
+
+ </blockquote></para></blockquote>
+
+ <blockquote><para>
+ <programlisting>
+ void vgaHWSaveMode(ScrnInfoPtr pScrn, vgaRegPtr save);
+ </programlisting>
+ <blockquote><para>
+ This function saves the VGA mode registers. They are saved to
+ the <structname>vgaRegRec</structname> pointed to by <parameter>save</parameter>.
+ The registers saved are:
+
+ <literallayout>
+ MiscOut
+ CRTC[0-0x18]
+ Attribute[0-0x14]
+ Graphics[0-8]
+ Sequencer[0-4]
+ </literallayout>
+ </para>
+
+ <para>
+ The number of registers actually saved may be modified by a prior call
+ to <function>vgaHWSetRegCounts()</function>.
+ </para>
+
+ </blockquote></para></blockquote>
+
+ <blockquote><para>
+ <programlisting>
+ void vgaHWSaveFonts(ScrnInfoPtr pScrn, vgaRegPtr save);
+ </programlisting>
+ <blockquote><para>
+ This function saves the text mode font and text data held in the
+ video memory. If called while in a graphics mode, no save is
+ done. The VGA memory window must be mapped with
+ <function>vgaHWMapMem()</function> before to calling this function.
+ </para>
+
+ <para>
+ On some platforms, one or more of the font/text plane saves may be
+ no-ops. This is the case when the platform's VC driver already
+ takes care of this.
+ </para>
+
+ </blockquote></para></blockquote>
+
+ <blockquote><para>
+ <programlisting>
+ void vgaHWSaveColormap(ScrnInfoPtr pScrn, vgaRegPtr save);
+ </programlisting>
+ <blockquote><para>
+ This function saves the VGA colourmap (LUT). Before saving it, it
+ attempts to verify that the colourmap is readable. In rare cases
+ where it isn't readable, a default colourmap is saved instead.
+ </para>
+
+ </blockquote></para></blockquote>
+
+ <blockquote><para>
+ <programlisting>
+ void vgaHWRestore(ScrnInfoPtr pScrn, vgaRegPtr restore, int flags);
+ </programlisting>
+ <blockquote><para>
+ This function programs the VGA state. The state programmed is
+ that contained in the <structname>vgaRegRec</structname> pointed to by
+ <parameter>restore</parameter>. <parameter>flags</parameter> is the same
+ as described above for the <function>vgaHWSave()</function> function.
+ </para>
+
+ <para>
+ The <structname>vgaHWRec</structname> and its <structfield>IOBase</structfield> fields
+ must be initialised before this function is called. If
+ <constant>VGA_SR_FONTS</constant> is set in <parameter>flags</parameter>, the
+ VGA memory window must be mapped. If it isn't then
+ <function>vgaHWMapMem()</function> will be called to map it, and
+ <function>vgaHWUnmapMem()</function> will be called to unmap it
+ afterwards. <function>vgaHWRestore()</function> uses the three functions
+ below in the order <function>vgaHWRestoreFonts()</function>,
+ <function>vgaHWRestoreMode()</function>,
+ <function>vgaHWRestoreColormap()</function> to carry out the different
+ restore phases. It is undecided at this stage whether they will
+ remain part of the vgahw module's public interface or not.
+ </para>
+
+ </blockquote></para></blockquote>
+
+ <blockquote><para>
+ <programlisting>
+ void vgaHWRestoreMode(ScrnInfoPtr pScrn, vgaRegPtr restore);
+ </programlisting>
+ <blockquote><para>
+ This function restores the VGA mode registers. They are restored
+ from the data in the <structname>vgaRegRec</structname> pointed to by
+ <parameter>restore</parameter>. The registers restored are:
+
+ <literallayout>
+ MiscOut
+ CRTC[0-0x18]
+ Attribute[0-0x14]
+ Graphics[0-8]
+ Sequencer[0-4]
+ </literallayout>
+ </para>
+
+ <para>
+ The number of registers actually restored may be modified by a prior call
+ to <function>vgaHWSetRegCounts()</function>.
+ </para>
+
+ </blockquote></para></blockquote>
+
+ <blockquote><para>
+ <programlisting>
+ void vgaHWRestoreFonts(ScrnInfoPtr pScrn, vgaRegPtr restore);
+ </programlisting>
+ <blockquote><para>
+ This function restores the text mode font and text data to the
+ video memory. The VGA memory window must be mapped with
+ <function>vgaHWMapMem()</function> before to calling this function.
+ </para>
+
+ <para>
+ On some platforms, one or more of the font/text plane restores
+ may be no-ops. This is the case when the platform's VC driver
+ already takes care of this.
+ </para>
+
+ </blockquote></para></blockquote>
+
+ <blockquote><para>
+ <programlisting>
+ void vgaHWRestoreColormap(ScrnInfoPtr pScrn, vgaRegPtr restore);
+ </programlisting>
+ <blockquote><para>
+ This function restores the VGA colourmap (LUT).
+ </para>
+
+ </blockquote></para></blockquote>
+
+ <blockquote><para>
+ <programlisting>
+ void vgaHWInit(ScrnInfoPtr pScrn, DisplayModePtr mode);
+ </programlisting>
+ <blockquote><para>
+ This function fills in the <structname>vgaHWRec</structname>'s
+ <structfield>ModeReg</structfield> field with the values appropriate for
+ programming the given video mode. It requires that the
+ <structname>ScrnInfoRec</structname>'s <structfield>depth</structfield> field is
+ initialised, which determines how the registers are programmed.
+ </para>
+
+ </blockquote></para></blockquote>
+
+ <blockquote><para>
+ <programlisting>
+ void vgaHWSeqReset(vgaHWPtr hwp, Bool start);
+ </programlisting>
+ <blockquote><para>
+ Do a VGA sequencer reset. If start is <constant>TRUE</constant>, the
+ reset is started. If start is <constant>FALSE</constant>, the reset
+ is ended.
+ </para>
+
+ </blockquote></para></blockquote>
+
+ <blockquote><para>
+ <programlisting>
+ void vgaHWProtect(ScrnInfoPtr pScrn, Bool on);
+ </programlisting>
+ <blockquote><para>
+ This function protects VGA registers and memory from corruption
+ during loads. It is typically called with on set to
+ <constant>TRUE</constant> before programming, and with on set to
+ <constant>FALSE</constant> after programming.
+ </para>
+
+ </blockquote></para></blockquote>
+
+ <blockquote><para>
+ <programlisting>
+ Bool vgaHWSaveScreen(ScreenPtr pScreen, int mode);
+ </programlisting>
+ <blockquote><para>
+ This function blanks and unblanks the screen. It is blanked when
+ <parameter>mode</parameter> is <constant>SCREEN_SAVER_ON</constant> or
+ <constant>SCREEN_SAVER_CYCLE</constant>, and unblanked when
+ <parameter>mode</parameter> is <constant>SCREEN_SAVER_OFF</constant> or
+ <constant>SCREEN_SAVER_FORCER</constant>.
+ </para>
+
+ </blockquote></para></blockquote>
+
+ <blockquote><para>
+ <programlisting>
+ void vgaHWBlankScreen(ScrnInfoPtr pScrn, Bool on);
+ </programlisting>
+ <blockquote><para>
+ This function blanks and unblanks the screen. It is blanked when
+ <parameter>on</parameter> is <constant>FALSE</constant>, and unblanked when
+ <parameter>on</parameter> is <constant>TRUE</constant>. This function is
+ provided for use in cases where the <structname>ScrnInfoRec</structname>
+ can't be derived from the <structname>ScreenRec</structname> (while probing
+ for clocks, for example).
+ </para>
+
+ </blockquote></para></blockquote>
+
+ </sect2>
+
+ <sect2>
+ <title>VGA Colormap Functions</title>
+
+ <para>
+ The vgahw module uses the standard colormap support (see the
+ <link linkend="cmap">Colormap Handling</link> section. This is initialised
+ with the following function:
+
+ <blockquote><para>
+ <programlisting>
+ Bool vgaHWHandleColormaps(ScreenPtr pScreen);
+ </programlisting>
+ </para></blockquote>
+ </para>
+
+ </sect2>
+
+ <sect2>
+ <title>VGA Register Access Functions</title>
+
+ <para>
+ The vgahw module abstracts access to the standard VGA registers by
+ using a set of functions held in the <structname>vgaHWRec</structname>. When
+ the <structname>vgaHWRec</structname> is created these function pointers are
+ initialised with the set of standard VGA I/O register access functions.
+ In addition to these, the vgahw module includes a basic set of MMIO
+ register access functions, and the <structname>vgaHWRec</structname> function
+ pointers can be initialised to these by calling the
+ <function>vgaHWSetMmioFuncs()</function> function described above. Some
+ drivers/platforms may require a different set of functions for VGA
+ access. The access functions are described here.
+ </para>
+
+
+ <blockquote><para>
+ <programlisting>
+ void writeCrtc(vgaHWPtr hwp, CARD8 index, CARD8 value);
+ </programlisting>
+ <blockquote><para>
+ Write <parameter>value</parameter> to CRTC register <parameter>index</parameter>.
+ </para>
+
+ </blockquote></para></blockquote>
+
+ <blockquote><para>
+ <programlisting>
+ CARD8 readCrtc(vgaHWPtr hwp, CARD8 index);
+ </programlisting>
+ <blockquote><para>
+ Return the value read from CRTC register <parameter>index</parameter>.
+ </para>
+
+ </blockquote></para></blockquote>
+
+ <blockquote><para>
+ <programlisting>
+ void writeGr(vgaHWPtr hwp, CARD8 index, CARD8 value);
+ </programlisting>
+ <blockquote><para>
+ Write <parameter>value</parameter> to Graphics Controller register
+ <parameter>index</parameter>.
+ </para>
+
+ </blockquote></para></blockquote>
+
+ <blockquote><para>
+ <programlisting>
+ CARD8 readGR(vgaHWPtr hwp, CARD8 index);
+ </programlisting>
+ <blockquote><para>
+ Return the value read from Graphics Controller register
+ <parameter>index</parameter>.
+ </para>
+
+ </blockquote></para></blockquote>
+
+ <blockquote><para>
+ <programlisting>
+ void writeSeq(vgaHWPtr hwp, CARD8 index, CARD8, value);
+ </programlisting>
+ <blockquote><para>
+ Write <parameter>value</parameter> to Sequencer register
+ <parameter>index</parameter>.
+ </para>
+
+ </blockquote></para></blockquote>
+
+ <blockquote><para>
+ <programlisting>
+ CARD8 readSeq(vgaHWPtr hwp, CARD8 index);
+ </programlisting>
+ <blockquote><para>
+ Return the value read from Sequencer register <parameter>index</parameter>.
+ </para>
+
+ </blockquote></para></blockquote>
+
+ <blockquote><para>
+ <programlisting>
+ void writeAttr(vgaHWPtr hwp, CARD8 index, CARD8, value);
+ </programlisting>
+ <blockquote><para>
+ Write <parameter>value</parameter> to Attribute Controller register
+ <parameter>index</parameter>. When writing out the index value this
+ function should set bit 5 (<constant>0x20</constant>) according to the
+ setting of <structfield>hwp-&gt;paletteEnabled</structfield> in order to
+ preserve the palette access state. It should be cleared when
+ <structfield>hwp-&gt;paletteEnabled</structfield> is <constant>TRUE</constant>
+ and set when it is <constant>FALSE</constant>.
+ </para>
+
+ </blockquote></para></blockquote>
+
+ <blockquote><para>
+ <programlisting>
+ CARD8 readAttr(vgaHWPtr hwp, CARD8 index);
+ </programlisting>
+ <blockquote><para>
+ Return the value read from Attribute Controller register
+ <parameter>index</parameter>. When writing out the index value this
+ function should set bit 5 (<constant>0x20</constant>) according to the
+ setting of <structfield>hwp-&gt;paletteEnabled</structfield> in order to
+ preserve the palette access state. It should be cleared when
+ <structfield>hwp-&gt;paletteEnabled</structfield> is <constant>TRUE</constant>
+ and set when it is <constant>FALSE</constant>.
+ </para>
+
+ </blockquote></para></blockquote>
+
+ <blockquote><para>
+ <programlisting>
+ void writeMiscOut(vgaHWPtr hwp, CARD8 value);
+ </programlisting>
+ <blockquote><para>
+ Write <quote><parameter>value</parameter></quote> to the Miscellaneous Output register.
+ </para>
+
+ </blockquote></para></blockquote>
+
+ <blockquote><para>
+ <programlisting>
+ CARD8 readMiscOut(vgwHWPtr hwp);
+ </programlisting>
+ <blockquote><para>
+ Return the value read from the Miscellaneous Output register.
+ </para>
+
+ </blockquote></para></blockquote>
+
+ <blockquote><para>
+ <programlisting>
+ void enablePalette(vgaHWPtr hwp);
+ </programlisting>
+ <blockquote><para>
+ Clear the palette address source bit in the Attribute Controller
+ index register and set <literal remap="tt">hwp-&gt;paletteEnabled</literal> to
+ <constant>TRUE</constant>.
+ </para>
+
+ </blockquote></para></blockquote>
+
+ <blockquote><para>
+ <programlisting>
+ void disablePalette(vgaHWPtr hwp);
+ </programlisting>
+ <blockquote><para>
+ Set the palette address source bit in the Attribute Controller
+ index register and set <literal remap="tt">hwp-&gt;paletteEnabled</literal> to
+ <constant>FALSE</constant>.
+ </para>
+
+ </blockquote></para></blockquote>
+
+ <blockquote><para>
+ <programlisting>
+ void writeDacMask(vgaHWPtr hwp, CARD8 value);
+ </programlisting>
+ <blockquote><para>
+ Write <parameter>value</parameter> to the DAC Mask register.
+ </para>
+
+ </blockquote></para></blockquote>
+
+ <blockquote><para>
+ <programlisting>
+ CARD8 readDacMask(vgaHWptr hwp);
+ </programlisting>
+ <blockquote><para>
+ Return the value read from the DAC Mask register.
+ </para>
+
+ </blockquote></para></blockquote>
+
+ <blockquote><para>
+ <programlisting>
+ void writeDacReadAddress(vgaHWPtr hwp, CARD8 value);
+ </programlisting>
+ <blockquote><para>
+ Write <parameter>value</parameter> to the DAC Read Address register.
+ </para>
+
+ </blockquote></para></blockquote>
+
+ <blockquote><para>
+ <programlisting>
+ void writeDacWriteAddress(vgaHWPtr hwp, CARD8 value);
+ </programlisting>
+ <blockquote><para>
+ Write <parameter>value</parameter> to the DAC Write Address register.
+ </para>
+
+ </blockquote></para></blockquote>
+
+ <blockquote><para>
+ <programlisting>
+ void writeDacData(vgaHWPtr hwp, CARD8 value);
+ </programlisting>
+ <blockquote><para>
+ Write <parameter>value</parameter> to the DAC Data register.
+ </para>
+
+ </blockquote></para></blockquote>
+
+ <blockquote><para>
+ <programlisting>
+ CARD8 readDacData(vgaHWptr hwp);
+ </programlisting>
+ <blockquote><para>
+ Return the value read from the DAC Data register.
+ </para>
+
+ </blockquote></para></blockquote>
+
+ <blockquote><para>
+ <programlisting>
+ CARD8 readEnable(vgaHWptr hwp);
+ </programlisting>
+ <blockquote><para>
+ Return the value read from the VGA Enable register. (Note: This
+ function is present in XFree86 4.1.0 and later.)
+ </para>
+
+ </blockquote></para></blockquote>
+
+ <blockquote><para>
+ <programlisting>
+ void writeEnable(vgaHWPtr hwp, CARD8 value);
+ </programlisting>
+ <blockquote><para>
+ Write <parameter>value</parameter> to the VGA Enable register. (Note: This
+ function is present in XFree86 4.1.0 and later.)
+ </para>
+
+ </blockquote></para></blockquote>
+ </sect2>
+ </sect1>
+
+ <sect1 id="sample">
+ <title>Some notes about writing a driver</title>
+
+ <note><para>NOTE: some parts of this are not up to date</para></note>
+
+ <para>
+The following is an outline for writing a basic unaccelerated driver
+for a PCI video card with a linear mapped framebuffer, and which has a
+VGA core. It is includes some general information that is relevant to
+most drivers (even those which don't fit that basic description).
+ </para>
+
+ <para>
+The information here is based on the initial conversion of the Matrox
+Millennium driver to the <quote>new design</quote>. For a fleshing out and sample
+implementation of some of the bits outlined here, refer to that driver.
+Note that this is an example only. The approach used here will not be
+appropriate for all drivers.
+ </para>
+
+ <para>
+Each driver must reserve a unique driver name, and a string that is used
+to prefix all of its externally visible symbols. This is to avoid name
+space clashes when loading multiple drivers. The examples here are for
+the <quote>ZZZ</quote> driver, which uses the <quote>ZZZ</quote> or <quote>zzz</quote> prefix for its externally
+visible symbols.
+ </para>
+
+ <sect2>
+ <title>Include files</title>
+
+ <para>
+ All drivers normally include the following headers:
+ <literallayout><filename>
+ "xf86.h"
+ "xf86_OSproc.h"
+ "xf86_ansic.h"
+ "xf86Resources.h"
+ </filename></literallayout>
+ Wherever inb/outb (and related things) are used the following should be
+ included:
+ <literallayout><filename>
+ "compiler.h"
+ </filename></literallayout>
+ Note: in drivers, this must be included after <filename>"xf86_ansic.h"</filename>.
+ </para>
+
+ <para>
+ Drivers that need to access PCI vendor/device definitions need this:
+ <literallayout><filename>
+ "xf86PciInfo.h"
+ </filename></literallayout>
+ </para>
+
+ <para>
+ Drivers that need to access the PCI config space need this:
+ <literallayout><filename>
+ "xf86Pci.h"
+ </filename></literallayout>
+ </para>
+
+ <para>
+ Drivers using the mi banking wrapper need:
+
+ <literallayout><filename>
+ "mibank.h"
+ </filename></literallayout>
+ </para>
+
+ <para>
+ Drivers that initialise a SW cursor need this:
+ <literallayout><filename>
+ "mipointer.h"
+ </filename></literallayout>
+ </para>
+
+ <para>
+ All drivers implementing backing store need this:
+ <literallayout><filename>
+ "mibstore.h"
+ </filename></literallayout>
+ </para>
+
+ <para>
+ All drivers using the mi colourmap code need this:
+ <literallayout><filename>
+ "micmap.h"
+ </filename></literallayout>
+ </para>
+
+ <para>
+ If a driver uses the vgahw module, it needs this:
+ <literallayout><filename>
+ "vgaHW.h"
+ </filename></literallayout>
+ </para>
+
+ <para>
+ Drivers supporting VGA or Hercules monochrome screens need:
+ <literallayout><filename>
+ "xf1bpp.h"
+ </filename></literallayout>
+ </para>
+
+ <para>
+ Drivers supporting VGA or EGC 16-colour screens need:
+ <literallayout><filename>
+ "xf4bpp.h"
+ </filename></literallayout>
+ </para>
+
+ <para>
+ Drivers using cfb need:
+ <programlisting>
+ #define PSZ 8
+ #include "cfb.h"
+ #undef PSZ
+ </programlisting>
+ </para>
+
+ <para>
+ Drivers supporting bpp 16, 24 or 32 with cfb need one or more of:
+ <literallayout><filename>
+ "cfb16.h"
+ "cfb24.h"
+ "cfb32.h"
+ </filename></literallayout>
+ </para>
+
+ <para>
+ The driver's own header file:
+ <literallayout><filename>
+ "zzz.h"
+ </filename></literallayout>
+ </para>
+
+ <para>
+ Drivers must NOT include the following:
+
+ <literallayout><filename>
+ "xf86Priv.h"
+ "xf86Privstr.h"
+ "xf86_libc.h"
+ "xf86_OSlib.h"
+ "Xos.h"</filename>
+ any OS header
+ </literallayout>
+ </para>
+
+ </sect2>
+
+ <sect2>
+ <title>Data structures and initialisation</title>
+
+ <itemizedlist>
+ <listitem>
+ <para>The following macros should be defined:
+ <programlisting>
+#define VERSION &lt;version-as-an-int&gt;
+#define ZZZ_NAME "ZZZ" /* the name used to prefix messages */
+#define ZZZ_DRIVER_NAME "zzz" /* the driver name as used in config file */
+#define ZZZ_MAJOR_VERSION &lt;int&gt;
+#define ZZZ_MINOR_VERSION &lt;int&gt;
+#define ZZZ_PATCHLEVEL &lt;int&gt;
+ </programlisting>
+ </para>
+ <para>
+ NOTE: <constant>ZZZ_DRIVER_NAME</constant> should match the name of the
+ driver module without things like the "lib" prefix, the "_drv" suffix
+ or filename extensions.
+ </para>
+ </listitem>
+
+ <listitem>
+ <para>
+ A DriverRec must be defined, which includes the functions required
+ at the pre-probe phase. The name of this DriverRec must be an
+ upper-case version of ZZZ_DRIVER_NAME (for the purposes of static
+ linking).
+ <programlisting>
+DriverRec ZZZ = {
+ VERSION,
+ ZZZ_DRIVER_NAME,
+ ZZZIdentify,
+ ZZZProbe,
+ ZZZAvailableOptions,
+ NULL,
+ 0
+};
+ </programlisting>
+ </para>
+ </listitem>
+
+ <listitem>
+ <para>Define list of supported chips and their matching ID:
+ <programlisting>
+static SymTabRec ZZZChipsets[] = {
+ { PCI_CHIP_ZZZ1234, "zzz1234a" },
+ { PCI_CHIP_ZZZ5678, "zzz5678a" },
+ { -1, NULL }
+};
+ </programlisting>
+ </para>
+ <para>
+ The token field may be any integer value that the driver may use to
+ uniquely identify the supported chipsets. For drivers that support
+ only PCI devices using the PCI device IDs might be a natural choice,
+ but this isn't mandatory. For drivers that support both PCI and other
+ devices (like ISA), some other ID should probably used. When other
+ IDs are used as the tokens it is recommended that the names be
+ defined as an <type>enum</type> type.
+ </para>
+ </listitem>
+
+ <listitem>
+ <para>
+ If the driver uses the <function>xf86MatchPciInstances()</function>
+ helper (recommended for drivers that support PCI cards) a list that
+ maps PCI IDs to chip IDs and fixed resources must be defined:
+ <programlisting>
+static PciChipsets ZZZPciChipsets[] = {
+ { PCI_CHIP_ZZZ1234, PCI_CHIP_ZZZ1234, RES_SHARED_VGA },
+ { PCI_CHIP_ZZZ5678, PCI_CHIP_ZZZ5678, RES_SHARED_VGA },
+ { -1, -1, RES_UNDEFINED }
+}
+ </programlisting>
+ </para>
+ </listitem>
+
+ <listitem>
+ <para>
+ Define the <structname>XF86ModuleVersionInfo</structname> struct for the
+ driver. This is required for the dynamically loaded version:
+ <programlisting>
+static XF86ModuleVersionInfo zzzVersRec =
+{
+ "zzz",
+ MODULEVENDORSTRING,
+ MODINFOSTRING1,
+ MODINFOSTRING2,
+ XF86_VERSION_CURRENT,
+ ZZZ_MAJOR_VERSION, ZZZ_MINOR_VERSION, ZZZ_PATCHLEVEL,
+ ABI_CLASS_VIDEODRV,
+ ABI_VIDEODRV_VERSION,
+ MOD_CLASS_VIDEODRV,
+ {0,0,0,0}
+};
+ </programlisting>
+ </para>
+ </listitem>
+
+ <listitem>
+ <para>
+ Define a data structure to hold the driver's screen-specific data.
+ This must be used instead of global variables. This would be defined
+ in the <filename>"zzz.h"</filename> file, something like:
+ <programlisting>
+typedef struct {
+ type1 field1;
+ type2 field2;
+ int fooHack;
+ Bool pciRetry;
+ Bool noAccel;
+ Bool hwCursor;
+ CloseScreenProcPtr CloseScreen;
+ OptionInfoPtr Options;
+ ...
+} ZZZRec, *ZZZPtr;
+ </programlisting>
+ </para>
+ </listitem>
+
+ <listitem>
+ <para>
+ Define the list of config file Options that the driver accepts. For
+ consistency between drivers those in the list of <quote>standard</quote> options
+ should be used where appropriate before inventing new options.
+
+ <programlisting>
+typedef enum {
+ OPTION_FOO_HACK,
+ OPTION_PCI_RETRY,
+ OPTION_HW_CURSOR,
+ OPTION_NOACCEL
+} ZZZOpts;
+
+static const OptionInfoRec ZZZOptions[] = {
+ { OPTION_FOO_HACK, "FooHack", OPTV_INTEGER, {0}, FALSE },
+ { OPTION_PCI_RETRY, "PciRetry", OPTV_BOOLEAN, {0}, FALSE },
+ { OPTION_HW_CURSOR, "HWcursor", OPTV_BOOLEAN, {0}, FALSE },
+ { OPTION_NOACCEL, "NoAccel", OPTV_BOOLEAN, {0}, FALSE },
+ { -1, NULL, OPTV_NONE, {0}, FALSE }
+};
+ </programlisting>
+ </para>
+ </listitem>
+ </itemizedlist>
+ </sect2>
+
+ <sect2>
+ <title>Functions</title>
+
+
+ <sect3>
+ <title>SetupProc</title>
+
+ <para>
+ For dynamically loaded modules, a <varname>ModuleData</varname>
+ variable is required. It is should be the name of the driver
+ prepended to "ModuleData". A <function>Setup()</function> function is
+ also required, which calls <function>xf86AddDriver()</function> to add
+ the driver to the main list of drivers.
+ </para>
+
+ <programlisting>
+static MODULESETUPPROTO(zzzSetup);
+
+XF86ModuleData zzzModuleData = { &amp;zzzVersRec, zzzSetup, NULL };
+
+static pointer
+zzzSetup(pointer module, pointer opts, int *errmaj, int *errmin)
+{
+ static Bool setupDone = FALSE;
+
+ /* This module should be loaded only once, but check to be sure. */
+
+ if (!setupDone) {
+ /*
+ * Modules that this driver always requires may be loaded
+ * here by calling LoadSubModule().
+ */
+
+ setupDone = TRUE;
+ xf86AddDriver(&amp;MGA, module, 0);
+
+ /*
+ * The return value must be non-NULL on success even though
+ * there is no TearDownProc.
+ */
+ return (pointer)1;
+ } else {
+ if (errmaj) *errmaj = LDR_ONCEONLY;
+ return NULL;
+ }
+}
+ </programlisting>
+ </sect3>
+
+ <sect3>
+ <title>GetRec, FreeRec</title>
+
+ <para>
+ A function is usually required to allocate the driver's
+ screen-specific data structure and hook it into the
+ <structname>ScrnInfoRec</structname>'s <structfield>driverPrivate</structfield> field.
+ The <structname>ScrnInfoRec</structname>'s <structfield>driverPrivate</structfield> is
+ initialised to <constant>NULL</constant>, so it is easy to check if the
+ initialisation has already been done. After allocating it, initialise
+ the fields. By using <function>xnfcalloc()</function> to do the allocation
+ it is zeroed, and if the allocation fails the server exits.
+ </para>
+
+ <para>
+ NOTE:
+ When allocating structures from inside the driver which are defined
+ on the common level it is important to initialize the structure to
+ zero.
+ Only this guarantees that the server remains source compatible to
+ future changes in common level structures.
+ </para>
+
+ <programlisting>
+static Bool
+ZZZGetRec(ScrnInfoPtr pScrn)
+{
+ if (pScrn-&gt;driverPrivate != NULL)
+ return TRUE;
+ pScrn-&gt;driverPrivate = xnfcalloc(sizeof(ZZZRec), 1);
+ /* Initialise as required */
+ ...
+ return TRUE;
+}
+ </programlisting>
+
+ <para>
+ Define a macro in <filename>"zzz.h"</filename> which gets a pointer to
+ the <structname>ZZZRec</structname> when given <parameter>pScrn</parameter>:
+
+ <programlisting>
+#define ZZZPTR(p) ((ZZZPtr)((p)-&gt;driverPrivate))
+ </programlisting>
+ </para>
+
+ <para>
+ Define a function to free the above, setting it to <constant>NULL</constant>
+ once it has been freed:
+
+ <programlisting>
+static void
+ZZZFreeRec(ScrnInfoPtr pScrn)
+{
+ if (pScrn-&gt;driverPrivate == NULL)
+ return;
+ xfree(pScrn-&gt;driverPrivate);
+ pScrn-&gt;driverPrivate = NULL;
+}
+ </programlisting>
+ </para>
+ </sect3>
+
+ <sect3>
+ <title>Identify</title>
+
+ <para>
+ Define the <function>Identify()</function> function. It is run before
+ the Probe, and typically prints out an identifying message, which
+ might include the chipsets it supports. This function is mandatory:
+
+ <programlisting>
+static void
+ZZZIdentify(int flags)
+{
+ xf86PrintChipsets(ZZZ_NAME, "driver for ZZZ Tech chipsets",
+ ZZZChipsets);
+}
+ </programlisting>
+ </para>
+ </sect3>
+
+ <sect3>
+ <title>Probe</title>
+
+ <para>
+ Define the <function>Probe()</function> function. The purpose of this
+ is to find all instances of the hardware that the driver supports,
+ and for the ones not already claimed by another driver, claim the
+ slot, and allocate a <structname>ScrnInfoRec</structname>. This should be
+ a minimal probe, and it should under no circumstances leave the
+ state of the hardware changed. Because a device is found, don't
+ assume that it will be used. Don't do any initialisations other
+ than the required <structname>ScrnInfoRec</structname> initialisations.
+ Don't allocate any new data structures.
+ </para>
+
+ <para>
+ This function is mandatory.
+ </para>
+
+ <para>
+ NOTE: The <function>xf86DrvMsg()</function> functions cannot be used from
+ the Probe.
+ </para>
+
+ <programlisting>
+static Bool
+ZZZProbe(DriverPtr drv, int flags)
+{
+ Bool foundScreen = FALSE;
+ int numDevSections, numUsed;
+ GDevPtr *devSections;
+ int *usedChips;
+ int i;
+
+ /*
+ * Find the config file Device sections that match this
+ * driver, and return if there are none.
+ */
+ if ((numDevSections = xf86MatchDevice(ZZZ_DRIVER_NAME,
+ &amp;devSections)) &lt;= 0) {
+ return FALSE;
+ }
+
+ /*
+ * Since this is a PCI card, "probing" just amounts to checking
+ * the PCI data that the server has already collected. If there
+ * is none, return.
+ *
+ * Although the config file is allowed to override things, it
+ * is reasonable to not allow it to override the detection
+ * of no PCI video cards.
+ *
+ * The provided xf86MatchPciInstances() helper takes care of
+ * the details.
+ */
+ /* test if PCI bus present */
+ if (xf86GetPciVideoInfo()) {
+
+ numUsed = xf86MatchPciInstances(ZZZ_NAME, PCI_VENDOR_ZZZ,
+ ZZZChipsets, ZZZPciChipsets, devSections,
+ numDevSections, drv, &amp;usedChips);
+
+ for (i = 0; i &lt; numUsed; i++) {
+ ScrnInfoPtr pScrn = NULL;
+ if ((pScrn = xf86ConfigPciEntity(pScrn, flags, usedChips[i],
+ ZZZPciChipsets, NULL, NULL,
+ NULL, NULL, NULL))) {
+ /* Allocate a ScrnInfoRec */
+ pScrn-&gt;driverVersion = VERSION;
+ pScrn-&gt;driverName = ZZZ_DRIVER_NAME;
+ pScrn-&gt;name = ZZZ_NAME;
+ pScrn-&gt;Probe = ZZZProbe;
+ pScrn-&gt;PreInit = ZZZPreInit;
+ pScrn-&gt;ScreenInit = ZZZScreenInit;
+ pScrn-&gt;SwitchMode = ZZZSwitchMode;
+ pScrn-&gt;AdjustFrame = ZZZAdjustFrame;
+ pScrn-&gt;EnterVT = ZZZEnterVT;
+ pScrn-&gt;LeaveVT = ZZZLeaveVT;
+ pScrn-&gt;FreeScreen = ZZZFreeScreen;
+ pScrn-&gt;ValidMode = ZZZValidMode;
+ foundScreen = TRUE;
+ /* add screen to entity */
+ }
+ }
+ xfree(usedChips);
+ }
+
+#ifdef HAS_ISA_DEVS
+ /*
+ * If the driver supports ISA hardware, the following block
+ * can be included too.
+ */
+ numUsed = xf86MatchIsaInstances(ZZZ_NAME, ZZZChipsets,
+ ZZZIsaChipsets, drv, ZZZFindIsaDevice,
+ devSections, numDevSections, &amp;usedChips);
+ for (i = 0; i &lt; numUsed; i++) {
+ ScrnInfoPtr pScrn = NULL;
+ if ((pScrn = xf86ConfigIsaEntity(pScrn, flags, usedChips[i],
+ ZZZIsaChipsets, NULL, NULL, NULL,
+ NULL, NULL))) {
+ pScrn-&gt;driverVersion = VERSION;
+ pScrn-&gt;driverName = ZZZ_DRIVER_NAME;
+ pScrn-&gt;name = ZZZ_NAME;
+ pScrn-&gt;Probe = ZZZProbe;
+ pScrn-&gt;PreInit = ZZZPreInit;
+ pScrn-&gt;ScreenInit = ZZZScreenInit;
+ pScrn-&gt;SwitchMode = ZZZSwitchMode;
+ pScrn-&gt;AdjustFrame = ZZZAdjustFrame;
+ pScrn-&gt;EnterVT = ZZZEnterVT;
+ pScrn-&gt;LeaveVT = ZZZLeaveVT;
+ pScrn-&gt;FreeScreen = ZZZFreeScreen;
+ pScrn-&gt;ValidMode = ZZZValidMode;
+ foundScreen = TRUE;
+ }
+ }
+ xfree(usedChips);
+#endif /* HAS_ISA_DEVS */
+
+ xfree(devSections);
+ return foundScreen;
+ </programlisting>
+ </sect3>
+
+ <sect3>
+ <title>AvailableOptions</title>
+
+ <para>
+ Define the <function>AvailableOptions()</function> function. The purpose
+ of this is to return the available driver options back to the
+ -configure option, so that an xorg.conf file can be built and the
+ user can see which options are available for them to use.
+ </para>
+ </sect3>
+
+ <sect3>
+ <title>PreInit</title>
+
+ <para>
+ Define the <function>PreInit()</function> function. The purpose of
+ this is to find all the information required to determine if the
+ configuration is usable, and to initialise those parts of the
+ <structname>ScrnInfoRec</structname> that can be set once at the beginning
+ of the first server generation. The information should be found in
+ the least intrusive way possible.
+ </para>
+
+ <para>
+ This function is mandatory.
+ </para>
+
+ <para>
+ NOTES:
+ <orderedlist>
+ <listitem><para>
+ The <function>PreInit()</function> function is only called once
+ during the life of the X server (at the start of the first
+ generation).
+ </para></listitem>
+
+ <listitem><para>
+ Data allocated here must be of the type that persists for
+ the life of the X server. This means that data that hooks into
+ the <structname>ScrnInfoRec</structname>'s <structfield>privates</structfield>
+ field should be allocated here, but data that hooks into the
+ <structname>ScreenRec</structname>'s <structfield>devPrivates</structfield> field
+ should not be allocated here. The <structfield>driverPrivate</structfield>
+ field should also be allocated here.
+ </para></listitem>
+
+ <listitem><para>
+ Although the <structname>ScrnInfoRec</structname> has been allocated
+ before this function is called, the <structname>ScreenRec</structname>
+ has not been allocated. That means that things requiring it
+ cannot be used in this function.
+ </para></listitem>
+
+ <listitem><para>
+ Very little of the <structname>ScrnInfoRec</structname> has been
+ initialised when this function is called. It is important to
+ get the order of doing things right in this function.
+ </para></listitem>
+
+ </orderedlist>
+ </para>
+
+ <programlisting>
+static Bool
+ZZZPreInit(ScrnInfoPtr pScrn, int flags)
+{
+ /* Fill in the monitor field */
+ pScrn-&gt;monitor = pScrn-&gt;confScreen-&gt;monitor;
+
+ /*
+ * If using the vgahw module, it will typically be loaded
+ * here by calling xf86LoadSubModule(pScrn, "vgahw");
+ */
+
+ /*
+ * Set the depth/bpp. Use the globally preferred depth/bpp. If the
+ * driver has special default depth/bpp requirements, the defaults should
+ * be specified here explicitly.
+ * We support both 24bpp and 32bpp framebuffer layouts.
+ * This sets pScrn-&gt;display also.
+ */
+ if (!xf86SetDepthBpp(pScrn, 0, 0, 0,
+ Support24bppFb | Support32bppFb)) {
+ return FALSE;
+ } else {
+ if (depth/bpp isn't one we support) {
+ print error message;
+ return FALSE;
+ }
+ }
+ /* Print out the depth/bpp that was set */
+ xf86PrintDepthBpp(pScrn);
+
+ /* Set bits per RGB for 8bpp */
+ if (pScrn-&gt;depth &lt;= 8) {
+ /* Take into account a dac_6_bit option here */
+ pScrn-&gt;rgbBits = 6 or 8;
+ }
+
+ /*
+ * xf86SetWeight() and xf86SetDefaultVisual() must be called
+ * after pScrn-&gt;display is initialised.
+ */
+
+ /* Set weight/mask/offset for depth &gt; 8 */
+ if (pScrn-&gt;depth &gt; 8) {
+ if (!xf86SetWeight(pScrn, defaultWeight, defaultMask)) {
+ return FALSE;
+ } else {
+ if (weight isn't one we support) {
+ print error message;
+ return FALSE;
+ }
+ }
+ }
+
+ /* Set the default visual. */
+ if (!xf86SetDefaultVisual(pScrn, -1)) {
+ return FALSE;
+ } else {
+ if (visual isn't one we support) {
+ print error message;
+ return FALSE;
+ }
+ }
+
+ /* If the driver supports gamma correction, set the gamma. */
+ if (!xf86SetGamma(pScrn, default_gamma)) {
+ return FALSE;
+ }
+
+ /* This driver uses a programmable clock */
+ pScrn-&gt;progClock = TRUE;
+
+ /* Allocate the ZZZRec driverPrivate */
+ if (!ZZZGetRec(pScrn)) {
+ return FALSE;
+ }
+
+ pZzz = ZZZPTR(pScrn);
+
+ /* Collect all of the option flags (fill in pScrn-&gt;options) */
+ xf86CollectOptions(pScrn, NULL);
+
+ /*
+ * Process the options based on the information in ZZZOptions.
+ * The results are written to pZzz-&gt;Options. If all of the options
+ * processing is done within this function a local variable "options"
+ * can be used instead of pZzz-&gt;Options.
+ */
+ if (!(pZzz-&gt;Options = xalloc(sizeof(ZZZOptions))))
+ return FALSE;
+ (void)memcpy(pZzz-&gt;Options, ZZZOptions, sizeof(ZZZOptions));
+ xf86ProcessOptions(pScrn-&gt;scrnIndex, pScrn-&gt;options, pZzz-&gt;Options);
+
+ /*
+ * Set various fields of ScrnInfoRec and/or ZZZRec based on
+ * the options found.
+ */
+ from = X_DEFAULT;
+ pZzz-&gt;hwCursor = FALSE;
+ if (xf86IsOptionSet(pZzz-&gt;Options, OPTION_HW_CURSOR)) {
+ from = X_CONFIG;
+ pZzz-&gt;hwCursor = TRUE;
+ }
+ xf86DrvMsg(pScrn-&gt;scrnIndex, from, "Using %s cursor\n",
+ pZzz-&gt;hwCursor ? "HW" : "SW");
+ if (xf86IsOptionSet(pZzz-&gt;Options, OPTION_NOACCEL)) {
+ pZzz-&gt;noAccel = TRUE;
+ xf86DrvMsg(pScrn-&gt;scrnIndex, X_CONFIG,
+ "Acceleration disabled\n");
+ } else {
+ pZzz-&gt;noAccel = FALSE;
+ }
+ if (xf86IsOptionSet(pZzz-&gt;Options, OPTION_PCI_RETRY)) {
+ pZzz-&gt;UsePCIRetry = TRUE;
+ xf86DrvMsg(pScrn-&gt;scrnIndex, X_CONFIG, "PCI retry enabled\n");
+ }
+ pZzz-&gt;fooHack = 0;
+ if (xf86GetOptValInteger(pZzz-&gt;Options, OPTION_FOO_HACK,
+ &amp;pZzz-&gt;fooHack)) {
+ xf86DrvMsg(pScrn-&gt;scrnIndex, X_CONFIG, "Foo Hack set to %d\n",
+ pZzz-&gt;fooHack);
+ }
+
+ /*
+ * Find the PCI slot(s) that this screen claimed in the probe.
+ * In this case, exactly one is expected, so complain otherwise.
+ * Note in this case we're not interested in the card types so
+ * that parameter is set to NULL.
+ */
+ if ((i = xf86GetPciInfoForScreen(pScrn-&gt;scrnIndex, &amp;pciList, NULL))
+ != 1) {
+ print error message;
+ ZZZFreeRec(pScrn);
+ if (i &gt; 0)
+ xfree(pciList);
+ return FALSE;
+ }
+ /* Note that pciList should be freed below when no longer needed */
+
+ /*
+ * Determine the chipset, allowing config file chipset and
+ * chipid values to override the probed information. The config
+ * chipset value has precedence over its chipid value if both
+ * are present.
+ *
+ * It isn't necessary to fill in pScrn-&gt;chipset if the driver
+ * keeps track of the chipset in its ZZZRec.
+ */
+
+ ...
+
+ /*
+ * Determine video memory, fb base address, I/O addresses, etc,
+ * allowing the config file to override probed values.
+ *
+ * Set the appropriate pScrn fields (videoRam is probably the
+ * most important one that other code might require), and
+ * print out the settings.
+ */
+
+ ...
+
+ /* Initialise a clockRanges list. */
+
+ ...
+
+ /* Set any other chipset specific things in the ZZZRec */
+
+ ...
+
+ /* Select valid modes from those available */
+
+ i = xf86ValidateModes(pScrn, pScrn-&gt;monitor-&gt;Modes,
+ pScrn-&gt;display-&gt;modes, clockRanges,
+ NULL, minPitch, maxPitch, rounding,
+ minHeight, maxHeight,
+ pScrn-&gt;display-&gt;virtualX,
+ pScrn-&gt;display-&gt;virtualY,
+ pScrn-&gt;videoRam * 1024,
+ LOOKUP_BEST_REFRESH);
+ if (i == -1) {
+ ZZZFreeRec(pScrn);
+ return FALSE;
+ }
+
+ /* Prune the modes marked as invalid */
+
+ xf86PruneDriverModes(pScrn);
+
+ /* If no valid modes, return */
+
+ if (i == 0 || pScrn-&gt;modes == NULL) {
+ print error message;
+ ZZZFreeRec(pScrn);
+ return FALSE;
+ }
+
+ /*
+ * Initialise the CRTC fields for the modes. This driver expects
+ * vertical values to be halved for interlaced modes.
+ */
+ xf86SetCrtcForModes(pScrn, INTERLACE_HALVE_V);
+
+ /* Set the current mode to the first in the list. */
+ pScrn-&gt;currentMode = pScrn-&gt;modes;
+
+ /* Print the list of modes being used. */
+ xf86PrintModes(pScrn);
+
+ /* Set the DPI */
+ xf86SetDpi(pScrn, 0, 0);
+
+ /* Load bpp-specific modules */
+ switch (pScrn-&gt;bitsPerPixel) {
+ case 1:
+ mod = "xf1bpp";
+ break;
+ case 4:
+ mod = "xf4bpp";
+ break;
+ case 8:
+ mod = "cfb";
+ break;
+ case 16:
+ mod = "cfb16";
+ break;
+ case 24:
+ mod = "cfb24";
+ break;
+ case 32:
+ mod = "cfb32";
+ break;
+ }
+ if (mod &amp;&amp; !xf86LoadSubModule(pScrn, mod))
+ ZZZFreeRec(pScrn);
+ return FALSE;
+
+ /* Load XAA if needed */
+ if (!pZzz-&gt;noAccel || pZzz-&gt;hwCursor)
+ if (!xf86LoadSubModule(pScrn, "xaa")) {
+ ZZZFreeRec(pScrn);
+ return FALSE;
+ }
+
+ /* Done */
+ return TRUE;
+}
+ </programlisting>
+ </sect3>
+
+ <sect3>
+ <title>MapMem, UnmapMem</title>
+
+ <para>
+ Define functions to map and unmap the video memory and any other
+ memory apertures required. These functions are not mandatory, but
+ it is often useful to have such functions.
+ </para>
+
+ <programlisting>
+static Bool
+ZZZMapMem(ScrnInfoPtr pScrn)
+{
+ /* Call xf86MapPciMem() to map each PCI memory area */
+ ...
+ return TRUE or FALSE;
+}
+
+static Bool
+ZZZUnmapMem(ScrnInfoPtr pScrn)
+{
+ /* Call xf86UnMapVidMem() to unmap each memory area */
+ ...
+ return TRUE or FALSE;
+}
+ </programlisting>
+ </sect3>
+
+ <sect3>
+ <title>Save, Restore</title>
+
+ <para>
+ Define functions to save and restore the original video state. These
+ functions are not mandatory, but are often useful.
+ </para>
+
+ <programlisting>
+static void
+ZZZSave(ScrnInfoPtr pScrn)
+{
+ /*
+ * Save state into per-screen data structures.
+ * If using the vgahw module, vgaHWSave will typically be
+ * called here.
+ */
+ ...
+}
+
+static void
+ZZZRestore(ScrnInfoPtr pScrn)
+{
+ /*
+ * Restore state from per-screen data structures.
+ * If using the vgahw module, vgaHWRestore will typically be
+ * called here.
+ */
+ ...
+}
+ </programlisting>
+ </sect3>
+
+ <sect3>
+ <title>ModeInit</title>
+
+ <para>
+ Define a function to initialise a new video mode. This function isn't
+ mandatory, but is often useful.
+ </para>
+
+ <programlisting>
+static Bool
+ZZZModeInit(ScrnInfoPtr pScrn, DisplayModePtr mode)
+{
+ /*
+ * Program a video mode. If using the vgahw module,
+ * vgaHWInit and vgaRestore will typically be called here.
+ * Once up to the point where there can't be a failure
+ * set pScrn-&gt;vtSema to TRUE.
+ */
+ ...
+}
+ </programlisting>
+ </sect3>
+
+ <sect3>
+ <title>ScreenInit</title>
+
+ <para>
+ Define the <function>ScreenInit()</function> function. This is called
+ at the start of each server generation, and should fill in as much
+ of the <structname>ScreenRec</structname> as possible as well as any other
+ data that is initialised once per generation. It should initialise
+ the framebuffer layers it is using, and initialise the initial video
+ mode.
+ </para>
+
+ <para>
+ This function is mandatory.
+ </para>
+
+ <para>
+ NOTE: The <structname>ScreenRec</structname> (<parameter>pScreen</parameter>) is
+ passed to this driver, but it and the
+ <varname>ScrnInfoRecs</varname> are not yet hooked into each
+ other. This means that in this function, and functions it
+ calls, one cannot be found from the other.
+ </para>
+
+ <programlisting>
+static Bool
+ZZZScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv)
+{
+ /* Get the ScrnInfoRec */
+ pScrn = xf86Screens[pScreen-&gt;myNum];
+
+ /*
+ * If using the vgahw module, its data structures and related
+ * things are typically initialised/mapped here.
+ */
+
+ /* Save the current video state */
+ ZZZSave(pScrn);
+
+ /* Initialise the first mode */
+ ZZZModeInit(pScrn, pScrn-&gt;currentMode);
+
+ /* Set the viewport if supported */
+
+ ZZZAdjustFrame(scrnIndex, pScrn-&gt;frameX0, pScrn-&gt;frameY0, 0);
+
+ /*
+ * Setup the screen's visuals, and initialise the framebuffer
+ * code.
+ */
+
+ /* Reset the visual list */
+ miClearVisualTypes();
+
+ /*
+ * Setup the visuals supported. This driver only supports
+ * TrueColor for bpp &gt; 8, so the default set of visuals isn't
+ * acceptable. To deal with this, call miSetVisualTypes with
+ * the appropriate visual mask.
+ */
+
+ if (pScrn-&gt;bitsPerPixel &gt; 8) {
+ if (!miSetVisualTypes(pScrn-&gt;depth, TrueColorMask,
+ pScrn-&gt;rgbBits, pScrn-&gt;defaultVisual))
+ return FALSE;
+ } else {
+ if (!miSetVisualTypes(pScrn-&gt;depth,
+ miGetDefaultVisualMask(pScrn-&gt;depth),
+ pScrn-&gt;rgbBits, pScrn-&gt;defaultVisual))
+ return FALSE;
+ }
+
+ /*
+ * Initialise the framebuffer.
+ */
+
+ switch (pScrn-&gt;bitsPerPixel) {
+ case 1:
+ ret = xf1bppScreenInit(pScreen, FbBase,
+ pScrn-&gt;virtualX, pScrn-&gt;virtualY,
+ pScrn-&gt;xDpi, pScrn-&gt;yDpi,
+ pScrn-&gt;displayWidth);
+ break;
+ case 4:
+ ret = xf4bppScreenInit(pScreen, FbBase,
+ pScrn-&gt;virtualX, pScrn-&gt;virtualY,
+ pScrn-&gt;xDpi, pScrn-&gt;yDpi,
+ pScrn-&gt;displayWidth);
+ break;
+ case 8:
+ ret = cfbScreenInit(pScreen, FbBase,
+ pScrn-&gt;virtualX, pScrn-&gt;virtualY,
+ pScrn-&gt;xDpi, pScrn-&gt;yDpi,
+ pScrn-&gt;displayWidth);
+ break;
+ case 16:
+ ret = cfb16ScreenInit(pScreen, FbBase,
+ pScrn-&gt;virtualX, pScrn-&gt;virtualY,
+ pScrn-&gt;xDpi, pScrn-&gt;yDpi,
+ pScrn-&gt;displayWidth);
+ break;
+ case 24:
+ ret = cfb24ScreenInit(pScreen, FbBase,
+ pScrn-&gt;virtualX, pScrn-&gt;virtualY,
+ pScrn-&gt;xDpi, pScrn-&gt;yDpi,
+ pScrn-&gt;displayWidth);
+ break;
+ case 32:
+ ret = cfb32ScreenInit(pScreen, FbBase,
+ pScrn-&gt;virtualX, pScrn-&gt;virtualY,
+ pScrn-&gt;xDpi, pScrn-&gt;yDpi,
+ pScrn-&gt;displayWidth);
+ break;
+ default:
+ print a message about an internal error;
+ ret = FALSE;
+ break;
+ }
+
+ if (!ret)
+ return FALSE;
+
+ /* Override the default mask/offset settings */
+ if (pScrn-&gt;bitsPerPixel &gt; 8) {
+ for (i = 0, visual = pScreen-&gt;visuals;
+ i &lt; pScreen-&gt;numVisuals; i++, visual++) {
+ if ((visual-&gt;class | DynamicClass) == DirectColor) {
+ visual-&gt;offsetRed = pScrn-&gt;offset.red;
+ visual-&gt;offsetGreen = pScrn-&gt;offset.green;
+ visual-&gt;offsetBlue = pScrn-&gt;offset.blue;
+ visual-&gt;redMask = pScrn-&gt;mask.red;
+ visual-&gt;greenMask = pScrn-&gt;mask.green;
+ visual-&gt;blueMask = pScrn-&gt;mask.blue;
+ }
+ }
+ }
+
+ /*
+ * If banking is needed, initialise an miBankInfoRec (defined in
+ * "mibank.h"), and call miInitializeBanking().
+ */
+ if (!miInitializeBanking(pScreen, pScrn-&gt;virtualX, pScrn-&gt;virtualY,
+ pScrn-&gt;displayWidth, pBankInfo))
+ return FALSE;
+
+ /*
+ * If backing store is to be supported (as is usually the case),
+ * initialise it.
+ */
+ miInitializeBackingStore(pScreen);
+
+ /*
+ * Set initial black &amp; white colourmap indices.
+ */
+ xf86SetBlackWhitePixels(pScreen);
+
+ /*
+ * Install colourmap functions. If using the vgahw module,
+ * vgaHandleColormaps would usually be called here.
+ */
+
+ ...
+
+ /*
+ * Initialise cursor functions. This example is for the mi
+ * software cursor.
+ */
+ miDCInitialize(pScreen, xf86GetPointerScreenFuncs());
+
+ /* Initialise the default colourmap */
+ switch (pScrn-&gt;depth) {
+ case 1:
+ if (!xf1bppCreateDefColormap(pScreen))
+ return FALSE;
+ break;
+ case 4:
+ if (!xf4bppCreateDefColormap(pScreen))
+ return FALSE;
+ break;
+ default:
+ if (!cfbCreateDefColormap(pScreen))
+ return FALSE;
+ break;
+ }
+
+ /*
+ * Wrap the CloseScreen vector and set SaveScreen.
+ */
+ ZZZPTR(pScrn)-&gt;CloseScreen = pScreen-&gt;CloseScreen;
+ pScreen-&gt;CloseScreen = ZZZCloseScreen;
+ pScreen-&gt;SaveScreen = ZZZSaveScreen;
+
+ /* Report any unused options (only for the first generation) */
+ if (serverGeneration == 1) {
+ xf86ShowUnusedOptions(pScrn-&gt;scrnIndex, pScrn-&gt;options);
+ }
+
+ /* Done */
+ return TRUE;
+}
+ </programlisting>
+ </sect3>
+
+ <sect3>
+ <title>SwitchMode</title>
+
+ <para>
+ Define the <function>SwitchMode()</function> function if mode switching
+ is supported by the driver.
+ </para>
+
+ <programlisting>
+static Bool
+ZZZSwitchMode(int scrnIndex, DisplayModePtr mode, int flags)
+{
+ return ZZZModeInit(xf86Screens[scrnIndex], mode);
+}
+ </programlisting>
+ </sect3>
+
+ <sect3>
+ <title>AdjustFrame</title>
+
+ <para>
+ Define the <function>AdjustFrame()</function> function if the driver
+ supports this.
+ </para>
+
+ <programlisting>
+static void
+ZZZAdjustFrame(int scrnIndex, int x, int y, int flags)
+{
+ /* Adjust the viewport */
+}
+ </programlisting>
+ </sect3>
+
+ <sect3>
+ <title>EnterVT, LeaveVT</title>
+
+ <para>
+ Define the <function>EnterVT()</function> and <function>LeaveVT()</function>
+ functions.
+ </para>
+
+ <para>
+ These functions are mandatory.
+ </para>
+
+ <programlisting>
+static Bool
+ZZZEnterVT(int scrnIndex, int flags)
+{
+ ScrnInfoPtr pScrn = xf86Screens[scrnIndex];
+ return ZZZModeInit(pScrn, pScrn-&gt;currentMode);
+}
+
+static void
+ZZZLeaveVT(int scrnIndex, int flags)
+{
+ ScrnInfoPtr pScrn = xf86Screens[scrnIndex];
+ ZZZRestore(pScrn);
+}
+ </programlisting>
+ </sect3>
+
+ <sect3>
+ <title>CloseScreen</title>
+
+ <para>
+ Define the <function>CloseScreen()</function> function:
+ </para>
+
+ <para>
+ This function is mandatory. Note that it unwraps the previously
+ wrapped <structfield>pScreen-&gt;CloseScreen</structfield>, and finishes by
+ calling it.
+ </para>
+
+ <programlisting>
+static Bool
+ZZZCloseScreen(int scrnIndex, ScreenPtr pScreen)
+{
+ ScrnInfoPtr pScrn = xf86Screens[scrnIndex];
+ if (pScrn-&gt;vtSema) {
+ ZZZRestore(pScrn);
+ ZZZUnmapMem(pScrn);
+ }
+ pScrn-&gt;vtSema = FALSE;
+ pScreen-&gt;CloseScreen = ZZZPTR(pScrn)-&gt;CloseScreen;
+ return (*pScreen-&gt;CloseScreen)(scrnIndex, pScreen);
+}
+ </programlisting>
+ </sect3>
+
+ <sect3>
+ <title>SaveScreen</title>
+
+ <para>
+ Define the <function>SaveScreen()</function> function (the screen
+ blanking function). When using the vgahw module, this will typically
+ be:
+
+ <programlisting>
+static Bool
+ZZZSaveScreen(ScreenPtr pScreen, int mode)
+{
+ return vgaHWSaveScreen(pScreen, mode);
+}
+ </programlisting>
+ </para>
+
+ <para>
+ This function is mandatory. Before modifying any hardware register
+ directly this function needs to make sure that the Xserver is active
+ by checking if <parameter>pScrn</parameter> is non-NULL and for
+ <literal remap="tt">pScrn-&gt;vtSema == TRUE</literal>.
+ </para>
+ </sect3>
+
+ <sect3>
+ <title>FreeScreen</title>
+
+ <para>
+ Define the <function>FreeScreen()</function> function. This function
+ is optional. It should be defined if the <structname>ScrnInfoRec</structname>
+ <structfield>driverPrivate</structfield> field is used so that it can be freed
+ when a screen is deleted by the common layer for reasons possibly
+ beyond the driver's control. This function is not used in during
+ normal (error free) operation. The per-generation data is freed by
+ the <function>CloseScreen()</function> function.
+ </para>
+
+ <programlisting>
+static void
+ZZZFreeScreen(int scrnIndex, int flags)
+{
+ /*
+ * If the vgahw module is used vgaHWFreeHWRec() would be called
+ * here.
+ */
+ ZZZFreeRec(xf86Screens[scrnIndex]);
+}
+
+ </programlisting>
+
+ </sect3>
+
+ </sect2>
+
+ </sect1>
+
+</article>
diff --git a/xorg-server/hw/xfree86/doc/devel/Makefile.am b/xorg-server/hw/xfree86/doc/devel/Makefile.am
deleted file mode 100644
index c9eca5eb3..000000000
--- a/xorg-server/hw/xfree86/doc/devel/Makefile.am
+++ /dev/null
@@ -1,7 +0,0 @@
-# Documentation for developers that is distributed with the source but
-# not installed on the system for end-users
-
-EXTRA_DIST = \
- Registry \
- exa-driver.txt \
- README.DRIcomp
diff --git a/xorg-server/hw/xfree86/doc/devel/exa-driver.txt b/xorg-server/hw/xfree86/doc/exa-driver.txt
index 048307ee7..048307ee7 100644
--- a/xorg-server/hw/xfree86/doc/devel/exa-driver.txt
+++ b/xorg-server/hw/xfree86/doc/exa-driver.txt
diff --git a/xorg-server/hw/xfree86/dri2/dri2.c b/xorg-server/hw/xfree86/dri2/dri2.c
index 5c42a51df..bf7ebb9f8 100644
--- a/xorg-server/hw/xfree86/dri2/dri2.c
+++ b/xorg-server/hw/xfree86/dri2/dri2.c
@@ -83,6 +83,7 @@ typedef struct _DRI2Drawable {
CARD64 last_swap_ust; /* ust at completion of most recent swap */
int swap_limit; /* for N-buffering */
unsigned long serialNumber;
+ Bool needInvalidate;
} DRI2DrawableRec, *DRI2DrawablePtr;
typedef struct _DRI2Screen {
@@ -497,6 +498,8 @@ do_get_buffers(DrawablePtr pDraw, int *width, int *height,
DRI2BufferFrontLeft);
}
+ pPriv->needInvalidate = TRUE;
+
return pPriv->buffers;
err_out:
@@ -540,9 +543,11 @@ DRI2InvalidateDrawable(DrawablePtr pDraw)
DRI2DrawablePtr pPriv = DRI2GetDrawable(pDraw);
DRI2DrawableRefPtr ref;
- if (!pPriv)
+ if (!pPriv || !pPriv->needInvalidate)
return;
+ pPriv->needInvalidate = FALSE;
+
list_for_each_entry(ref, &pPriv->reference_list, link)
ref->invalidate(pDraw, ref->priv);
}
diff --git a/xorg-server/hw/xnest/Events.c b/xorg-server/hw/xnest/Events.c
index 5c800860a..619427ded 100644
--- a/xorg-server/hw/xnest/Events.c
+++ b/xorg-server/hw/xnest/Events.c
@@ -43,8 +43,6 @@ is" without express or implied warranty.
CARD32 lastEventTime = 0;
-extern EventList *xnestEvents;
-
void
ProcessInputEvents(void)
{
@@ -104,23 +102,17 @@ xnestCollectExposures(void)
void
xnestQueueKeyEvent(int type, unsigned int keycode)
{
- int i, n;
-
- GetEventList(&xnestEvents);
lastEventTime = GetTimeInMillis();
- n = GetKeyboardEvents(xnestEvents, xnestKeyboardDevice, type, keycode, NULL);
- for (i = 0; i < n; i++)
- mieqEnqueue(xnestKeyboardDevice, (InternalEvent*)(xnestEvents + i)->event);
+ QueueKeyboardEvents(xnestKeyboardDevice, type, keycode, NULL);
}
void
xnestCollectEvents(void)
{
XEvent X;
- int i, n, valuators[2];
+ int valuators[2];
ValuatorMask mask;
ScreenPtr pScreen;
- GetEventList(&xnestEvents);
while (XCheckIfEvent(xnestDisplay, &X, xnestNotExposurePredicate, NULL)) {
switch (X.type) {
@@ -138,20 +130,16 @@ xnestCollectEvents(void)
valuator_mask_set_range(&mask, 0, 0, NULL);
xnestUpdateModifierState(X.xkey.state);
lastEventTime = GetTimeInMillis();
- n = GetPointerEvents(xnestEvents, xnestPointerDevice, ButtonPress,
- X.xbutton.button, POINTER_RELATIVE, &mask);
- for (i = 0; i < n; i++)
- mieqEnqueue(xnestPointerDevice, (InternalEvent*)(xnestEvents + i)->event);
+ QueuePointerEvents(xnestPointerDevice, ButtonPress,
+ X.xbutton.button, POINTER_RELATIVE, &mask);
break;
case ButtonRelease:
valuator_mask_set_range(&mask, 0, 0, NULL);
xnestUpdateModifierState(X.xkey.state);
lastEventTime = GetTimeInMillis();
- n = GetPointerEvents(xnestEvents, xnestPointerDevice, ButtonRelease,
- X.xbutton.button, POINTER_RELATIVE, &mask);
- for (i = 0; i < n; i++)
- mieqEnqueue(xnestPointerDevice, (InternalEvent*)(xnestEvents + i)->event);
+ QueuePointerEvents(xnestPointerDevice, ButtonRelease,
+ X.xbutton.button, POINTER_RELATIVE, &mask);
break;
case MotionNotify:
@@ -159,10 +147,8 @@ xnestCollectEvents(void)
valuators[1] = X.xmotion.y;
valuator_mask_set_range(&mask, 0, 2, valuators);
lastEventTime = GetTimeInMillis();
- n = GetPointerEvents(xnestEvents, xnestPointerDevice, MotionNotify,
- 0, POINTER_ABSOLUTE, &mask);
- for (i = 0; i < n; i++)
- mieqEnqueue(xnestPointerDevice, (InternalEvent*)(xnestEvents + i)->event);
+ QueuePointerEvents(xnestPointerDevice, MotionNotify,
+ 0, POINTER_ABSOLUTE, &mask);
break;
case FocusIn:
@@ -193,10 +179,8 @@ xnestCollectEvents(void)
valuators[1] = X.xcrossing.y;
valuator_mask_set_range(&mask, 0, 2, valuators);
lastEventTime = GetTimeInMillis();
- n = GetPointerEvents(xnestEvents, xnestPointerDevice, MotionNotify,
- 0, POINTER_ABSOLUTE, &mask);
- for (i = 0; i < n; i++)
- mieqEnqueue(xnestPointerDevice, (InternalEvent*)(xnestEvents + i)->event);
+ QueuePointerEvents(xnestPointerDevice, MotionNotify,
+ 0, POINTER_ABSOLUTE, &mask);
xnestDirectInstallColormaps(pScreen);
}
}
diff --git a/xorg-server/hw/xnest/Init.c b/xorg-server/hw/xnest/Init.c
index 8a90cc65e..ee74101d2 100644
--- a/xorg-server/hw/xnest/Init.c
+++ b/xorg-server/hw/xnest/Init.c
@@ -45,8 +45,6 @@ is" without express or implied warranty.
Bool xnestDoFullGeneration = True;
-EventList *xnestEvents = NULL;
-
void
InitOutput(ScreenInfo *screenInfo, int argc, char *argv[])
{
@@ -100,8 +98,6 @@ InitInput(int argc, char *argv[])
if (rc != Success)
FatalError("Failed to init Xnest default devices.\n");
- GetEventList(&xnestEvents);
-
mieqInit();
AddEnabledDevice(XConnectionNumber(xnestDisplay));
diff --git a/xorg-server/hw/xquartz/Makefile.am b/xorg-server/hw/xquartz/Makefile.am
index 76f624d78..a7cc012d9 100644
--- a/xorg-server/hw/xquartz/Makefile.am
+++ b/xorg-server/hw/xquartz/Makefile.am
@@ -33,7 +33,8 @@ libXquartz_la_SOURCES = \
quartzCocoa.m \
quartzKeyboard.c \
quartzStartup.c \
- quartzRandR.c
+ quartzRandR.c \
+ console_redirect.c
EXTRA_DIST = \
X11Application.h \
@@ -49,4 +50,5 @@ EXTRA_DIST = \
quartzKeyboard.h \
quartzRandR.h \
sanitizedCarbon.h \
- sanitizedCocoa.h
+ sanitizedCocoa.h \
+ console_redirect.h
diff --git a/xorg-server/hw/xquartz/X11Application.h b/xorg-server/hw/xquartz/X11Application.h
index 256ff187a..619f32f7a 100644
--- a/xorg-server/hw/xquartz/X11Application.h
+++ b/xorg-server/hw/xquartz/X11Application.h
@@ -43,11 +43,12 @@
- (void) set_controller:controller;
- (void) set_window_menu:(NSArray *)list;
+- (CFPropertyListRef) prefs_get_copy:(NSString *)key CF_RETURNS_RETAINED;
- (int) prefs_get_integer:(NSString *)key default:(int)def;
- (const char *) prefs_get_string:(NSString *)key default:(const char *)def;
- (float) prefs_get_float:(NSString *)key default:(float)def;
- (int) prefs_get_boolean:(NSString *)key default:(int)def;
-- (NSURL *) prefs_copy_url:(NSString *)key default:(NSURL *)def;
+- (NSURL *) prefs_copy_url:(NSString *)key default:(NSURL *)def NS_RETURNS_RETAINED;
- (NSArray *) prefs_get_array:(NSString *)key;
- (void) prefs_set_integer:(NSString *)key value:(int)value;
- (void) prefs_set_float:(NSString *)key value:(float)value;
diff --git a/xorg-server/hw/xquartz/applewmExt.h b/xorg-server/hw/xquartz/applewmExt.h
index 35c8f8f6d..c46a7bde4 100644
--- a/xorg-server/hw/xquartz/applewmExt.h
+++ b/xorg-server/hw/xquartz/applewmExt.h
@@ -35,9 +35,9 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#include <Xplugin.h>
#if XPLUGIN_VERSION < 4
-typedef xp_frame_attr int;
-typedef xp_frame_class int;
-typedef xp_frame_rect int;
+typedef int xp_frame_attr;
+typedef int xp_frame_class;
+typedef int xp_frame_rect;
#endif
typedef int (*DisableUpdateProc)(void);
diff --git a/xorg-server/hw/xquartz/console_redirect.c b/xorg-server/hw/xquartz/console_redirect.c
new file mode 100644
index 000000000..cdd2b8960
--- /dev/null
+++ b/xorg-server/hw/xquartz/console_redirect.c
@@ -0,0 +1,418 @@
+/* Copyright (c) 2011 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>
+#else
+#define DEBUG_CONSOLE_REDIRECT 1
+#define HAVE_LIBDISPATCH 1
+#endif
+
+#include <assert.h>
+#include <unistd.h>
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include <sys/types.h>
+#include <sys/event.h>
+#include <asl.h>
+#include <errno.h>
+#include <fcntl.h>
+
+#include "console_redirect.h"
+
+#define BUF_SIZE 512
+
+#ifdef HAVE_LIBDISPATCH
+#include <dispatch/dispatch.h>
+
+static dispatch_queue_t redirect_serial_q;
+static dispatch_group_t read_source_group;
+#else
+#include <pthread.h>
+
+static pthread_t redirect_pthread;
+static pthread_mutex_t redirect_fds_lock = PTHREAD_MUTEX_INITIALIZER;
+
+static int kq;
+
+/* Notifications to our reader thread */
+#define ASL_REDIRECT_TERMINATE ((void *)(uintptr_t)1)
+#endif
+
+typedef struct {
+ int level;
+ aslclient asl;
+ aslmsg msg;
+
+ /* Buffered reading */
+ char *buf;
+ char *w;
+
+#ifdef HAVE_LIBDISPATCH
+ dispatch_source_t read_source;
+#endif
+} asl_redirect;
+
+static asl_redirect *redirect_fds = NULL;
+static int n_redirect_fds = 0;
+
+/* Read from the FD until there is no more to read and redirect to ASL.
+ * Preconditions:
+ * 1: pthread_mutex_lock lock is held (pthreads) or called
+ * from the appropriate serial queue for operating on
+ * redirect_fds
+ * 2: fd corresponds to a valid entry in redirect_fds
+ *
+ * Return values:
+ * If the pipe is closed, EOF is returned regardless of how many bytes
+ * were processed. If the pipe is still open, the number of read bytes
+ * is returned.
+ */
+static inline int _read_redirect(int fd, int flush) {
+ int total_read = 0;
+ int nbytes;
+ asl_redirect *aslr = &redirect_fds[fd];
+
+ while((nbytes = read(fd, aslr->w, BUF_SIZE - (aslr->w - aslr->buf) - 1)) > 0) {
+ char *s, *p;
+
+ /* Increment our returned number read */
+ total_read += nbytes;
+
+ nbytes += (aslr->w - aslr->buf);
+ aslr->buf[nbytes] = '\0';
+
+ /* One line at a time */
+ for(p=aslr->buf; *p && (p - aslr->buf) < nbytes; p = s + 1) {
+ // Find null or \n
+ for(s=p; *s && *s != '\n'; s++);
+ if(*s == '\n') {
+ *s='\0';
+ asl_log(aslr->asl, aslr->msg, aslr->level, "%s", p);
+ } else if(aslr->buf != p) {
+ memmove(aslr->buf, p, BUF_SIZE);
+ aslr->w = aslr->buf + (s - p);
+ break;
+ } else if(nbytes == BUF_SIZE - 1) {
+ asl_log(aslr->asl, aslr->msg, aslr->level, "%s", p);
+ aslr->w = aslr->buf;
+ break;
+ }
+ }
+ }
+
+ /* Flush if requested or we're at EOF */
+ if(flush || nbytes == 0) {
+ if(aslr->w > aslr->buf) {
+ *aslr->w = '\0';
+ asl_log(aslr->asl, aslr->msg, aslr->level, "%s", aslr->buf);
+ }
+ }
+
+ if(nbytes == 0)
+ return EOF;
+ return total_read;
+}
+
+#ifdef HAVE_LIBDISPATCH
+static void read_from_source(void *_source) {
+ dispatch_source_t source = (dispatch_source_t)_source;
+ int fd = dispatch_source_get_handle(source);
+ if(_read_redirect(fd, 0) == EOF) {
+ dispatch_source_cancel(source);
+ }
+}
+
+static void cancel_source(void *_source) {
+ dispatch_source_t source = (dispatch_source_t)_source;
+ int fd = dispatch_source_get_handle(source);
+ asl_redirect *aslr = &redirect_fds[fd];
+
+ /* Flush the buffer */
+ _read_redirect(fd, 1);
+
+ close(fd);
+ free(aslr->buf);
+ memset(aslr, 0, sizeof(*aslr));
+ dispatch_release(source);
+ dispatch_group_leave(read_source_group);
+}
+
+#else /* !HAVE_LIBDISPATCH */
+static void *redirect_thread(void *ctx __unused) {
+ struct kevent ev;
+ int n;
+
+ while(1) {
+ n = kevent(kq, NULL, 0, &ev, 1, NULL);
+
+ /* Bail on errors */
+ if(n < 0) {
+ asl_log(NULL, NULL, ASL_LEVEL_ERR, "kevent failure: %s", strerror(errno));
+ break;
+ }
+
+ /* This should not happen */
+ if(n == 0)
+ continue;
+
+ switch(ev.filter) {
+ case EVFILT_READ:
+ pthread_mutex_lock(&redirect_fds_lock);
+ {
+ int fd = ev.ident;
+ int close_fd = 0;
+ asl_redirect *aslr = &redirect_fds[fd];
+
+ if(fd < 0 || fd >= n_redirect_fds || aslr->buf == NULL) {
+ asl_log(NULL, NULL, ASL_LEVEL_ERR, "Unexpected file descriptor: %d", fd);
+ goto next;
+ }
+
+ if(ev.flags & EV_EOF) {
+ close_fd = 1;
+ if(EOF != _read_redirect(fd, 1)) {
+ asl_log(NULL, NULL, ASL_LEVEL_ERR, "kevent reported EOF on %d, but read doesn't concur.", fd);
+ }
+ } else {
+ close_fd = (EOF == _read_redirect(fd, 0));
+ }
+
+ if(close_fd) {
+ EV_SET(&ev, fd, EVFILT_READ, EV_DELETE, 0, 0, 0);
+ kevent(kq, &ev, 1, NULL, 0, NULL);
+ close(fd);
+ free(aslr->buf);
+ memset(aslr, 0, sizeof(*aslr));
+ }
+ }
+ next:
+ pthread_mutex_unlock(&redirect_fds_lock);
+
+ case EVFILT_TIMER:
+ if(ev.udata == ASL_REDIRECT_TERMINATE)
+ return NULL;
+
+ default:
+ ;;
+ }
+ }
+
+ return NULL;
+}
+#endif
+
+static void redirect_atexit(void) {
+ /* stdout is linebuffered, so flush the buffer */
+ if(redirect_fds[STDOUT_FILENO].buf)
+ fflush(stdout);
+
+#ifdef HAVE_LIBDISPATCH
+ {
+ int i;
+
+ /* Cancel all of our dispatch sources, so they flush to ASL */
+ for(i=0; i < n_redirect_fds; i++)
+ if(redirect_fds[i].read_source)
+ dispatch_source_cancel(redirect_fds[i].read_source);
+
+ /* Wait at least three seconds for our sources to flush to ASL */
+ dispatch_group_wait(read_source_group, dispatch_time(DISPATCH_TIME_NOW, 3LL * NSEC_PER_SEC));
+ }
+#else
+ {
+ struct kevent ev;
+
+ /* Tell our reader thread it is time to pack up and go home */
+ EV_SET(&ev, 0, EVFILT_TIMER, EV_ADD | EV_ONESHOT, 0, 0, ASL_REDIRECT_TERMINATE);
+ kevent(kq, &ev, 1, NULL, 0, NULL);
+
+ pthread_join(redirect_pthread, NULL);
+ }
+#endif
+}
+
+#ifdef HAVE_LIBDISPATCH
+static void xq_asl_init(void *ctx __unused)
+#else
+static void xq_asl_init(void)
+#endif
+{
+ assert((redirect_fds = calloc(16, sizeof(*redirect_fds))) != NULL);
+ n_redirect_fds = 16;
+
+#ifdef HAVE_LIBDISPATCH
+ redirect_serial_q = dispatch_queue_create("com.apple.asl-redirect", NULL);
+ assert(redirect_serial_q != NULL);
+
+ read_source_group = dispatch_group_create();
+ assert(read_source_group != NULL);
+#else
+ assert((kq = kqueue()) != -1);
+ assert(pthread_create(&redirect_pthread, NULL, redirect_thread, NULL) == 0);
+#endif
+
+ atexit(redirect_atexit);
+}
+
+int xq_asl_log_fd(aslclient asl, aslmsg msg, int level, int fd) {
+#ifdef HAVE_LIBDISPATCH
+ int err __block = 0;
+ static dispatch_once_t once_control;
+ dispatch_once_f(&once_control, NULL, xq_asl_init);
+#else
+ int err = 0;
+ static pthread_once_t once_control = PTHREAD_ONCE_INIT;
+ assert(pthread_once(&once_control, xq_asl_init) == 0);
+#endif
+
+ if(fd < 0)
+ return EBADF;
+
+#ifdef HAVE_LIBDISPATCH
+#define BLOCK_DONE return
+ dispatch_sync(redirect_serial_q, ^
+#else
+#define BLOCK_DONE goto done
+ assert(pthread_mutex_lock(&redirect_fds_lock) == 0);
+#endif
+ {
+ /* Reallocate if we need more space */
+ if(fd >= n_redirect_fds) {
+ size_t new_n = 1 << (ffs(fd) + 1);
+ asl_redirect *new_array = realloc(redirect_fds, new_n * sizeof(*redirect_fds));
+ if(!new_array) {
+ err = errno;
+ BLOCK_DONE;
+ }
+ redirect_fds = new_array;
+ memset(redirect_fds + n_redirect_fds, 0, new_n - n_redirect_fds);
+ n_redirect_fds = new_n;
+ }
+
+ /* If we're already listening on it, return error. */
+ if(redirect_fds[fd].buf != NULL) {
+ err = EBADF;
+ BLOCK_DONE;
+ }
+
+ /* Initialize our buffer */
+ redirect_fds[fd].buf = (char *)malloc(BUF_SIZE);
+ if(redirect_fds[fd].buf == NULL) {
+ err = errno;
+ BLOCK_DONE;
+ }
+ redirect_fds[fd].w = redirect_fds[fd].buf;
+
+ /* Store our ASL settings */
+ redirect_fds[fd].level = level;
+ redirect_fds[fd].asl = asl;
+ redirect_fds[fd].msg = msg;
+
+ /* Don't block on reads from this fd */
+ fcntl(fd, F_SETFL, O_NONBLOCK);
+
+ /* Start listening */
+#ifdef HAVE_LIBDISPATCH
+ {
+ dispatch_source_t read_source = dispatch_source_create(DISPATCH_SOURCE_TYPE_READ, fd, 0, redirect_serial_q);
+ redirect_fds[fd].read_source = read_source;
+ dispatch_set_context(read_source, read_source);
+ dispatch_source_set_event_handler_f(read_source, read_from_source);
+ dispatch_source_set_cancel_handler_f(read_source, cancel_source);
+ dispatch_group_enter(read_source_group);
+ dispatch_resume(read_source);
+ }
+#else
+ {
+ struct kevent ev;
+ EV_SET(&ev, fd, EVFILT_READ, EV_ADD, 0, 0, 0);
+ kevent(kq, &ev, 1, NULL, 0, NULL);
+ }
+#endif
+ }
+#ifdef HAVE_LIBDISPATCH
+ );
+#else
+done:
+ assert(pthread_mutex_unlock(&redirect_fds_lock) == 0);
+#endif
+#undef BLOCK_DONE
+
+ return err;
+}
+
+int xq_asl_capture_fd(aslclient asl, aslmsg msg, int level, int fd) {
+ int pipepair[2];
+
+ /* Create pipe */
+ if(pipe(pipepair) == -1)
+ return errno;
+
+ /* Close the read fd but not the write fd on exec */
+ if(fcntl(pipepair[0], F_SETFD, FD_CLOEXEC) == -1)
+ return errno;
+
+ /* Replace the existing fd */
+ if(dup2(pipepair[1], fd) == -1) {
+ close(pipepair[0]);
+ close(pipepair[1]);
+ return errno;
+ }
+
+ /* If we capture STDOUT_FILENO, make sure we linebuffer stdout */
+ if(fd == STDOUT_FILENO)
+ setlinebuf(stdout);
+
+ /* Close the duplicate fds since they've been reassigned */
+ close(pipepair[1]);
+
+ /* Hand off the read end of our pipe to xq_asl_log_fd */
+ return xq_asl_log_fd(asl, msg, level, pipepair[0]);
+}
+
+#ifdef DEBUG_CONSOLE_REDIRECT
+int main(int argc __unused, char **argv __unused) {
+ xq_asl_capture_fd(NULL, NULL, ASL_LEVEL_NOTICE, STDOUT_FILENO);
+ xq_asl_capture_fd(NULL, NULL, ASL_LEVEL_ERR, STDERR_FILENO);
+
+ fprintf(stderr, "TEST ERR1\n");
+ fprintf(stdout, "TEST OUT1\n");
+ fprintf(stderr, "TEST ERR2\n");
+ fprintf(stdout, "TEST OUT2\n");
+ system("/bin/echo SYST OUT");
+ system("/bin/echo SYST ERR >&2");
+ fprintf(stdout, "TEST OUT3\n");
+ fprintf(stdout, "TEST OUT4\n");
+ fprintf(stderr, "TEST ERR3\n");
+ fprintf(stderr, "TEST ERR4\n");
+
+ exit(0);
+}
+#endif
diff --git a/xorg-server/hw/xquartz/console_redirect.h b/xorg-server/hw/xquartz/console_redirect.h
new file mode 100644
index 000000000..94520a35c
--- /dev/null
+++ b/xorg-server/hw/xquartz/console_redirect.h
@@ -0,0 +1,44 @@
+/* Copyright (c) 2011 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 _XQUARTZ_CONSOLE_REDIRECT_H_
+#define _XQUARTZ_CONSOLE_REDIRECT_H_
+
+#include <asl.h>
+
+/* The given fd is replaced with a pipe. Anything written to it will will be
+ * logged to ASL.
+ */
+int xq_asl_capture_fd(aslclient asl, aslmsg msg, int level, int fd);
+
+/* The given fd is read from and passed along to ASL until all write ends of the
+ * pipe are closed. Once the last writer has closed the pipe, we close our end.
+ */
+int xq_asl_log_fd(aslclient asl, aslmsg msg, int level, int fd);
+
+#endif
diff --git a/xorg-server/hw/xquartz/darwinEvents.c b/xorg-server/hw/xquartz/darwinEvents.c
index f3e12250e..fe744b741 100644
--- a/xorg-server/hw/xquartz/darwinEvents.c
+++ b/xorg-server/hw/xquartz/darwinEvents.c
@@ -88,7 +88,7 @@ static pthread_mutex_t fd_add_lock = PTHREAD_MUTEX_INITIALIZER;
static pthread_cond_t fd_add_ready_cond = PTHREAD_COND_INITIALIZER;
static pthread_t fd_add_tid = NULL;
-static EventListPtr darwinEvents = NULL;
+static InternalEvent* darwinEvents = NULL;
static pthread_mutex_t mieq_lock = PTHREAD_MUTEX_INITIALIZER;
static pthread_cond_t mieq_ready_cond = PTHREAD_COND_INITIALIZER;
@@ -433,7 +433,6 @@ static void DarwinPrepareValuators(DeviceIntPtr pDev, int *valuators, ScreenPtr
void DarwinSendPointerEvents(DeviceIntPtr pDev, int ev_type, int ev_button, float pointer_x, float pointer_y,
float pressure, float tilt_x, float tilt_y) {
static int darwinFakeMouseButtonDown = 0;
- int i, num_events;
ScreenPtr screen;
int valuators[5];
@@ -486,15 +485,12 @@ void DarwinSendPointerEvents(DeviceIntPtr pDev, int ev_type, int ev_button, floa
darwinEvents_lock(); {
ValuatorMask mask;
valuator_mask_set_range(&mask, 0, (pDev == darwinPointer) ? 2 : 5, valuators);
- num_events = GetPointerEvents(darwinEvents, pDev, ev_type, ev_button,
- POINTER_ABSOLUTE, &mask);
- for(i=0; i<num_events; i++) mieqEnqueue (pDev, (InternalEvent*)darwinEvents[i].event);
- if(num_events > 0) DarwinPokeEQ();
+ QueuePointerEvents(pDev, ev_type, ev_button, POINTER_ABSOLUTE, &mask);
+ DarwinPokeEQ();
} darwinEvents_unlock();
}
void DarwinSendKeyboardEvents(int ev_type, int keycode) {
- int i, num_events;
if(!darwinEvents) {
DEBUG_LOG("DarwinSendKeyboardEvents called before darwinEvents was initialized\n");
@@ -502,15 +498,13 @@ void DarwinSendKeyboardEvents(int ev_type, int keycode) {
}
darwinEvents_lock(); {
- num_events = GetKeyboardEvents(darwinEvents, darwinKeyboard, ev_type, keycode + MIN_KEYCODE, NULL);
- for(i=0; i<num_events; i++) mieqEnqueue(darwinKeyboard, (InternalEvent*)darwinEvents[i].event);
- if(num_events > 0) DarwinPokeEQ();
+ QueueKeyboardEvents(darwinKeyboard, ev_type, keycode + MIN_KEYCODE, NULL);
+ DarwinPokeEQ();
} darwinEvents_unlock();
}
void DarwinSendProximityEvents(DeviceIntPtr pDev, int ev_type, float pointer_x, float pointer_y,
float pressure, float tilt_x, float tilt_y) {
- int i, num_events;
ScreenPtr screen;
int valuators[5];
@@ -531,9 +525,8 @@ void DarwinSendProximityEvents(DeviceIntPtr pDev, int ev_type, float pointer_x,
darwinEvents_lock(); {
ValuatorMask mask;
valuator_mask_set_range(&mask, 0, 5, valuators);
- num_events = GetProximityEvents(darwinEvents, pDev, ev_type, &mask);
- for(i=0; i<num_events; i++) mieqEnqueue (pDev, (InternalEvent*)darwinEvents[i].event);
- if(num_events > 0) DarwinPokeEQ();
+ QueueProximityEvents(pDev, ev_type, &mask);
+ DarwinPokeEQ();
} darwinEvents_unlock();
}
diff --git a/xorg-server/hw/xquartz/mach-startup/Makefile.am b/xorg-server/hw/xquartz/mach-startup/Makefile.am
index 4dff45aa8..1ce54ad86 100644
--- a/xorg-server/hw/xquartz/mach-startup/Makefile.am
+++ b/xorg-server/hw/xquartz/mach-startup/Makefile.am
@@ -1,4 +1,5 @@
AM_CPPFLAGS = \
+ -I$(srcdir)/.. \
-DBUILD_DATE=\"$(BUILD_DATE)\" \
-DXSERVER_VERSION=\"$(VERSION)\" \
-DX11BINDIR=\"$(bindir)\"
diff --git a/xorg-server/hw/xquartz/mach-startup/bundle-main.c b/xorg-server/hw/xquartz/mach-startup/bundle-main.c
index 846025b44..8e3437644 100644
--- a/xorg-server/hw/xquartz/mach-startup/bundle-main.c
+++ b/xorg-server/hw/xquartz/mach-startup/bundle-main.c
@@ -36,6 +36,7 @@
#endif
#include <X11/Xlib.h>
+#include <assert.h>
#include <unistd.h>
#include <stdio.h>
#include <string.h>
@@ -60,12 +61,14 @@
#include "mach_startup.h"
#include "mach_startupServer.h"
-#include "launchd_fd.h"
+#include "console_redirect.h"
+
/* From darwinEvents.c ... but don't want to pull in all the server cruft */
void DarwinListenOnOpenFD(int fd);
/* Ditto, from os/log.c */
extern void ErrorF(const char *f, ...) _X_ATTRIBUTE_PRINTF(1,2);
+extern void FatalError(const char *f, ...) _X_ATTRIBUTE_PRINTF(1,2) _X_NORETURN;
extern int noPanoramiXExtension;
@@ -102,6 +105,10 @@ int server_main(int argc, char **argv, char **envp);
static int execute(const char *command);
static char *command_from_prefs(const char *key, const char *default_value);
+static char *pref_app_to_run;
+static char *pref_login_shell;
+static char *pref_startx_script;
+
#ifndef HAVE_LIBDISPATCH
/*** Pthread Magics ***/
static pthread_t create_thread(void *(*func)(void *), void *arg) {
@@ -446,7 +453,7 @@ static int startup_trigger(int argc, char **argv, char **envp) {
/* Could open the display, start the launcher */
XCloseDisplay(display);
- return execute(command_from_prefs("app_to_run", DEFAULT_CLIENT));
+ return execute(pref_app_to_run);
}
}
@@ -457,7 +464,7 @@ static int startup_trigger(int argc, char **argv, char **envp) {
} else {
ErrorF("X11.app: Could not connect to server (DISPLAY is not set). Starting X server.\n");
}
- return execute(command_from_prefs("startx_script", DEFAULT_STARTX));
+ return execute(pref_startx_script);
}
/** Setup the environment we want our child processes to inherit */
@@ -475,6 +482,28 @@ static void ensure_path(const char *dir) {
}
}
+static void setup_console_redirect(const char *bundle_id) {
+ char *asl_sender;
+ char *asl_facility;
+ aslclient aslc;
+
+ asprintf(&asl_sender, "%s.server", bundle_id);
+ assert(asl_sender);
+
+ asl_facility = strdup(bundle_id);
+ assert(asl_facility);
+ if(strcmp(asl_facility + strlen(asl_facility) - 4, ".X11") == 0)
+ asl_facility[strlen(asl_facility) - 4] = '\0';
+
+ assert(aslc = asl_open(asl_sender, asl_facility, ASL_OPT_NO_DELAY));
+ free(asl_sender);
+ free(asl_facility);
+
+ asl_set_filter(aslc, ASL_FILTER_MASK_UPTO(ASL_LEVEL_WARNING));
+ xq_asl_capture_fd(aslc, NULL, ASL_LEVEL_INFO, STDOUT_FILENO);
+ xq_asl_capture_fd(aslc, NULL, ASL_LEVEL_NOTICE, STDERR_FILENO);
+}
+
static void setup_env(void) {
char *temp;
const char *pds = NULL;
@@ -497,6 +526,8 @@ static void setup_env(void) {
pds = BUNDLE_ID_PREFIX".X11";
}
+ setup_console_redirect(pds);
+
server_bootstrap_name = strdup(pds);
if(!server_bootstrap_name) {
ErrorF("X11.app: Memory allocation error.\n");
@@ -594,11 +625,20 @@ int main(int argc, char **argv, char **envp) {
pid_t child1, child2;
int status;
+ pref_app_to_run = command_from_prefs("app_to_run", DEFAULT_CLIENT);
+ assert(pref_app_to_run);
+
+ pref_login_shell = command_from_prefs("login_shell", DEFAULT_SHELL);
+ assert(pref_login_shell);
+
+ pref_startx_script = command_from_prefs("startx_script", DEFAULT_STARTX);
+ assert(pref_startx_script);
+
/* Do the fork-twice trick to avoid having to reap zombies */
child1 = fork();
switch (child1) {
case -1: /* error */
- break;
+ FatalError("fork() failed: %s\n", strerror(errno));
case 0: /* child1 */
child2 = fork();
@@ -607,7 +647,7 @@ int main(int argc, char **argv, char **envp) {
int max_files, i;
case -1: /* error */
- break;
+ FatalError("fork() failed: %s\n", strerror(errno));
case 0: /* child2 */
/* close all open files except for standard streams */
@@ -629,6 +669,10 @@ int main(int argc, char **argv, char **envp) {
default: /* parent */
waitpid(child1, &status, 0);
}
+
+ free(pref_app_to_run);
+ free(pref_login_shell);
+ free(pref_startx_script);
}
/* Main event loop */
@@ -646,7 +690,7 @@ static int execute(const char *command) {
const char *newargv[4];
const char **p;
- newargv[0] = command_from_prefs("login_shell", DEFAULT_SHELL);
+ newargv[0] = pref_login_shell;
newargv[1] = "-c";
newargv[2] = command;
newargv[3] = NULL;
diff --git a/xorg-server/hw/xquartz/mach-startup/launchd_fd.c b/xorg-server/hw/xquartz/mach-startup/launchd_fd.c
index 5c7e03cf3..8003dd177 100644
--- a/xorg-server/hw/xquartz/mach-startup/launchd_fd.c
+++ b/xorg-server/hw/xquartz/mach-startup/launchd_fd.c
@@ -31,41 +31,43 @@
#endif
#include <launch.h>
-#include <stdio.h>
+#include <asl.h>
#include <errno.h>
#include "launchd_fd.h"
+extern aslclient aslc;
+
int launchd_display_fd(void) {
launch_data_t sockets_dict, checkin_request, checkin_response;
launch_data_t listening_fd_array, listening_fd;
/* Get launchd fd */
if ((checkin_request = launch_data_new_string(LAUNCH_KEY_CHECKIN)) == NULL) {
- fprintf(stderr,"launch_data_new_string(\"" LAUNCH_KEY_CHECKIN "\") Unable to create string.\n");
+ asl_log(aslc, NULL, ASL_LEVEL_ERR, "launch_data_new_string(\"" LAUNCH_KEY_CHECKIN "\") Unable to create string.\n");
return ERROR_FD;
}
if ((checkin_response = launch_msg(checkin_request)) == NULL) {
- fprintf(stderr,"launch_msg(\"" LAUNCH_KEY_CHECKIN "\") IPC failure: %s\n",strerror(errno));
+ asl_log(aslc, NULL, ASL_LEVEL_WARNING, "launch_msg(\"" LAUNCH_KEY_CHECKIN "\") IPC failure: %s\n",strerror(errno));
return ERROR_FD;
}
if (LAUNCH_DATA_ERRNO == launch_data_get_type(checkin_response)) {
// ignore EACCES, which is common if we weren't started by launchd
if (launch_data_get_errno(checkin_response) != EACCES)
- fprintf(stderr,"launchd check-in failed: %s\n", strerror(launch_data_get_errno(checkin_response)));
+ asl_log(aslc, NULL, ASL_LEVEL_ERR, "launchd check-in failed: %s\n", strerror(launch_data_get_errno(checkin_response)));
return ERROR_FD;
}
sockets_dict = launch_data_dict_lookup(checkin_response, LAUNCH_JOBKEY_SOCKETS);
if (NULL == sockets_dict) {
- fprintf(stderr,"launchd check-in: no sockets found to answer requests on!\n");
+ asl_log(aslc, NULL, ASL_LEVEL_ERR, "launchd check-in: no sockets found to answer requests on!\n");
return ERROR_FD;
}
if (launch_data_dict_get_count(sockets_dict) > 1) {
- fprintf(stderr,"launchd check-in: some sockets will be ignored!\n");
+ asl_log(aslc, NULL, ASL_LEVEL_ERR, "launchd check-in: some sockets will be ignored!\n");
return ERROR_FD;
}
@@ -73,13 +75,13 @@ int launchd_display_fd(void) {
if (NULL == listening_fd_array) {
listening_fd_array = launch_data_dict_lookup(sockets_dict, ":0");
if (NULL == listening_fd_array) {
- fprintf(stderr,"launchd check-in: No known sockets found to answer requests on! \"%s:0\" and \":0\" failed.\n", BUNDLE_ID_PREFIX);
+ asl_log(aslc, NULL, ASL_LEVEL_ERR, "launchd check-in: No known sockets found to answer requests on! \"%s:0\" and \":0\" failed.\n", BUNDLE_ID_PREFIX);
return ERROR_FD;
}
}
if (launch_data_array_get_count(listening_fd_array)!=1) {
- fprintf(stderr,"launchd check-in: Expected 1 socket from launchd, got %u)\n",
+ asl_log(aslc, NULL, ASL_LEVEL_ERR, "launchd check-in: Expected 1 socket from launchd, got %u)\n",
(unsigned)launch_data_array_get_count(listening_fd_array));
return ERROR_FD;
}
diff --git a/xorg-server/hw/xquartz/mach-startup/stub.c b/xorg-server/hw/xquartz/mach-startup/stub.c
index c8a628311..8319dd06e 100644
--- a/xorg-server/hw/xquartz/mach-startup/stub.c
+++ b/xorg-server/hw/xquartz/mach-startup/stub.c
@@ -33,9 +33,9 @@
#endif
#include <string.h>
-#include <stdio.h>
#include <unistd.h>
#include <errno.h>
+#include <asl.h>
#include <sys/socket.h>
#include <sys/un.h>
@@ -43,8 +43,6 @@
#define kX11AppBundleId BUNDLE_ID_PREFIX".X11"
#define kX11AppBundlePath "/Contents/MacOS/X11"
-static char *server_bootstrap_name = kX11AppBundleId;
-
#include <mach/mach.h>
#include <mach/mach_error.h>
#include <servers/bootstrap.h>
@@ -57,8 +55,8 @@ static char *server_bootstrap_name = kX11AppBundleId;
#include "launchd_fd.h"
static char x11_path[PATH_MAX + 1];
-
static pid_t x11app_pid = 0;
+aslclient aslc;
static void set_x11_path(void) {
#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1050
@@ -69,26 +67,24 @@ static void set_x11_path(void) {
switch (osstatus) {
case noErr:
if (appURL == NULL) {
- fprintf(stderr, "Xquartz: Invalid response from LSFindApplicationForInfo(%s)\n",
+ asl_log(aslc, NULL, ASL_LEVEL_ERR, "Xquartz: Invalid response from LSFindApplicationForInfo(%s)",
kX11AppBundleId);
exit(1);
}
if (!CFURLGetFileSystemRepresentation(appURL, true, (unsigned char *)x11_path, sizeof(x11_path))) {
- fprintf(stderr, "Xquartz: Error resolving URL for %s\n", kX11AppBundleId);
+ asl_log(aslc, NULL, ASL_LEVEL_ERR, "Xquartz: Error resolving URL for %s", kX11AppBundleId);
exit(3);
}
strlcat(x11_path, kX11AppBundlePath, sizeof(x11_path));
-#ifdef DEBUG
- fprintf(stderr, "Xquartz: X11.app = %s\n", x11_path);
-#endif
+ asl_log(aslc, NULL, ASL_LEVEL_INFO, "Xquartz: X11.app = %s", x11_path);
break;
case kLSApplicationNotFoundErr:
- fprintf(stderr, "Xquartz: Unable to find application for %s\n", kX11AppBundleId);
+ asl_log(aslc, NULL, ASL_LEVEL_ERR, "Xquartz: Unable to find application for %s", kX11AppBundleId);
exit(10);
default:
- fprintf(stderr, "Xquartz: Unable to find application for %s, error code = %d\n",
+ asl_log(aslc, NULL, ASL_LEVEL_ERR, "Xquartz: Unable to find application for %s, error code = %d",
kX11AppBundleId, (int)osstatus);
exit(11);
}
@@ -114,12 +110,12 @@ static int connect_to_socket(const char *filename) {
ret_fd = socket(PF_UNIX, SOCK_STREAM, 0);
if(ret_fd == -1) {
- fprintf(stderr, "Xquartz: Failed to create socket: %s - %s\n", filename, strerror(errno));
+ asl_log(aslc, NULL, ASL_LEVEL_ERR, "Xquartz: Failed to create socket: %s - %s", filename, strerror(errno));
return -1;
}
if(connect(ret_fd, servaddr, servaddr_len) < 0) {
- fprintf(stderr, "Xquartz: Failed to connect to socket: %s - %d - %s\n", filename, errno, strerror(errno));
+ asl_log(aslc, NULL, ASL_LEVEL_ERR, "Xquartz: Failed to connect to socket: %s - %d - %s", filename, errno, strerror(errno));
close(ret_fd);
return -1;
}
@@ -160,14 +156,11 @@ static void send_fd_handoff(int connected_fd, int launchd_fd) {
*((int*)CMSG_DATA(cmsg)) = launchd_fd;
if(sendmsg(connected_fd, &msg, 0) < 0) {
- fprintf(stderr, "Xquartz: Error sending $DISPLAY file descriptor over fd %d: %d -- %s\n", connected_fd, errno, strerror(errno));
+ asl_log(aslc, NULL, ASL_LEVEL_ERR, "Xquartz: Error sending $DISPLAY file descriptor over fd %d: %d -- %s", connected_fd, errno, strerror(errno));
return;
}
-#ifdef DEBUG
- fprintf(stderr, "Xquartz: Message sent. Closing handoff fd.\n");
-#endif
-
+ asl_log(aslc, NULL, ASL_LEVEL_DEBUG, "Xquartz: Message sent. Closing handoff fd.");
close(connected_fd);
}
@@ -187,10 +180,25 @@ int main(int argc, char **argv, char **envp) {
int launchd_fd;
string_t handoff_socket_filename;
sig_t handler;
+ char *asl_sender;
+ char *asl_facility;
+ char *server_bootstrap_name = kX11AppBundleId;
if(getenv("X11_PREFS_DOMAIN"))
server_bootstrap_name = getenv("X11_PREFS_DOMAIN");
-
+
+ asprintf(&asl_sender, "%s.stub", server_bootstrap_name);
+ assert(asl_sender);
+
+ asl_facility = strdup(server_bootstrap_name);
+ assert(asl_facility);
+ if(strcmp(asl_facility + strlen(asl_facility) - 4, ".X11") == 0)
+ asl_facility[strlen(asl_facility) - 4] = '\0';
+
+ assert(aslc = asl_open(asl_sender, asl_facility, ASL_OPT_NO_DELAY));
+ free(asl_sender);
+ free(asl_facility);
+
/* We don't have a mechanism in place to handle this interrupt driven
* server-start notification, so just send the signal now, so xinit doesn't
* time out waiting for it and will just poll for the server.
@@ -211,13 +219,13 @@ int main(int argc, char **argv, char **envp) {
if(kr != KERN_SUCCESS) {
pid_t child;
- fprintf(stderr, "Xquartz: Unable to locate waiting server: %s\n", server_bootstrap_name);
+ asl_log(aslc, NULL, ASL_LEVEL_WARNING, "Xquartz: Unable to locate waiting server: %s", server_bootstrap_name);
set_x11_path();
/* This forking is ugly and will be cleaned up later */
child = fork();
if(child == -1) {
- fprintf(stderr, "Xquartz: Could not fork: %s\n", strerror(errno));
+ asl_log(aslc, NULL, ASL_LEVEL_ERR, "Xquartz: Could not fork: %s", strerror(errno));
return EXIT_FAILURE;
}
@@ -226,7 +234,7 @@ int main(int argc, char **argv, char **envp) {
_argv[0] = x11_path;
_argv[1] = "--listenonly";
_argv[2] = NULL;
- fprintf(stderr, "Xquartz: Starting X server: %s --listenonly\n", x11_path);
+ asl_log(aslc, NULL, ASL_LEVEL_NOTICE, "Xquartz: Starting X server: %s --listenonly", x11_path);
return execvp(x11_path, _argv);
}
@@ -240,9 +248,9 @@ int main(int argc, char **argv, char **envp) {
if(kr != KERN_SUCCESS) {
#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1050
- fprintf(stderr, "Xquartz: bootstrap_look_up(): %s\n", bootstrap_strerror(kr));
+ asl_log(aslc, NULL, ASL_LEVEL_ERR, "Xquartz: bootstrap_look_up(): %s", bootstrap_strerror(kr));
#else
- fprintf(stderr, "Xquartz: bootstrap_look_up(): %ul\n", (unsigned long)kr);
+ asl_log(aslc, NULL, ASL_LEVEL_ERR, "Xquartz: bootstrap_look_up(): %ul", (unsigned long)kr);
#endif
return EXIT_FAILURE;
}
@@ -258,20 +266,17 @@ int main(int argc, char **argv, char **envp) {
for(try=0, try_max=5; try < try_max; try++) {
if(request_fd_handoff_socket(mp, handoff_socket_filename) != KERN_SUCCESS) {
- fprintf(stderr, "Xquartz: Failed to request a socket from the server to send the $DISPLAY fd over (try %d of %d)\n", (int)try+1, (int)try_max);
+ asl_log(aslc, NULL, ASL_LEVEL_INFO, "Xquartz: Failed to request a socket from the server to send the $DISPLAY fd over (try %d of %d)", (int)try+1, (int)try_max);
continue;
}
handoff_fd = connect_to_socket(handoff_socket_filename);
if(handoff_fd == -1) {
- fprintf(stderr, "Xquartz: Failed to connect to socket (try %d of %d)\n", (int)try+1, (int)try_max);
+ asl_log(aslc, NULL, ASL_LEVEL_ERR, "Xquartz: Failed to connect to socket (try %d of %d)", (int)try+1, (int)try_max);
continue;
}
-#ifdef DEBUG
- fprintf(stderr, "Xquartz: Handoff connection established (try %d of %d) on fd %d, \"%s\". Sending message.\n", (int)try+1, (int)try_max, handoff_fd, handoff_socket_filename);
-#endif
-
+ asl_log(aslc, NULL, ASL_LEVEL_INFO, "Xquartz: Handoff connection established (try %d of %d) on fd %d, \"%s\". Sending message.", (int)try+1, (int)try_max, handoff_fd, handoff_socket_filename);
send_fd_handoff(handoff_fd, launchd_fd);
close(handoff_fd);
break;
@@ -288,7 +293,7 @@ int main(int argc, char **argv, char **envp) {
newenvp = (string_array_t)calloc((1 + envpc), sizeof(string_t));
if(!newargv || !newenvp) {
- fprintf(stderr, "Xquartz: Memory allocation failure\n");
+ asl_log(aslc, NULL, ASL_LEVEL_ERR, "Xquartz: Memory allocation failure");
return EXIT_FAILURE;
}
@@ -305,7 +310,7 @@ int main(int argc, char **argv, char **envp) {
free(newenvp);
if (kr != KERN_SUCCESS) {
- fprintf(stderr, "Xquartz: start_x11_server: %s\n", mach_error_string(kr));
+ asl_log(aslc, NULL, ASL_LEVEL_ERR, "Xquartz: start_x11_server: %s", mach_error_string(kr));
return EXIT_FAILURE;
}
return EXIT_SUCCESS;
diff --git a/xorg-server/hw/xquartz/man/Xquartz.man b/xorg-server/hw/xquartz/man/Xquartz.man
index 447194740..19e8efbad 100644
--- a/xorg-server/hw/xquartz/man/Xquartz.man
+++ b/xorg-server/hw/xquartz/man/Xquartz.man
@@ -16,72 +16,72 @@ OS X handles the desktop background.
.SH CUSTOMIZATION
\fIXquartz\fP can be customized using the defaults(1) command. The available options are:
.TP 8
-.B defaults write __laucnd_id_prefix__.X11 enable_fake_buttons -boolean true
+.B defaults write __bundle_id_prefix__.X11 enable_fake_buttons -boolean true
Emulates a 3 button mouse using modifier keys. By default, the Command modifier
is used to emulate button 2 and Option is used for button 3. Thus, clicking the
first mouse button while holding down Command will act like clicking
button 2. Holding down Option will simulate button 3.
.TP 8
-.B defaults write __laucnd_id_prefix__.X11 fake_button2 \fImodifiers\fP
+.B defaults write __bundle_id_prefix__.X11 fake_button2 \fImodifiers\fP
Change the modifier keys used to emulate the second mouse button. By default,
Command is used to emulate the second button. Any combination of the following
modifier names may be used: {l,r,}shift, {l,r,}option, {l,r,}control, {l,r,}command, fn
.TP 8
-.B defaults write __laucnd_id_prefix__.X11 fake_button3 \fImodifiers\fP
+.B defaults write __bundle_id_prefix__.X11 fake_button3 \fImodifiers\fP
Change the modifier keys used to emulate the second mouse button. By default,
Command is used to emulate the second button. Any combination of the following
modifier names may be used: {l,r,}shift, {l,r,}option, {l,r,}control, {l,r,}command, fn
.TP 8
-.B defaults write __laucnd_id_prefix__.X11 fullscreen_hotkeys -boolean true
+.B defaults write __bundle_id_prefix__.X11 fullscreen_hotkeys -boolean true
Enable OSX hotkeys while in fullscreen
.TP 8
-.B defaults write __laucnd_id_prefix__.X11 fullscreen_menu -boolean true
+.B defaults write __bundle_id_prefix__.X11 fullscreen_menu -boolean true
Show the OSX menu while in fullscreen
.TP 8
-.B defaults write __laucnd_id_prefix__.X11 no_quit_alert -boolean true
+.B defaults write __bundle_id_prefix__.X11 no_quit_alert -boolean true
Disables the alert dialog displayed when attempting to quit X11.
.TP 8
-.B defaults write __laucnd_id_prefix__.X11 no_auth -boolean true
+.B defaults write __bundle_id_prefix__.X11 no_auth -boolean true
Stops the X server requiring that clients authenticate themselves when
connecting. See Xsecurity(__miscmansuffix__).
.TP 8
-.B defaults write __laucnd_id_prefix__.X11 nolisten_tcp -boolean false
+.B defaults write __bundle_id_prefix__.X11 nolisten_tcp -boolean false
This will tell the server to listen and accept TCP connections. Doing this without enabling
xauth is a possible security concern. See Xsecurity(__miscmansuffix__).
.TP 8
-.B defaults write __laucnd_id_prefix__.X11 enable_system_beep -boolean false
+.B defaults write __bundle_id_prefix__.X11 enable_system_beep -boolean false
Don't use the standard system beep effect for X11 alerts.
.TP 8
-.B defaults write __laucnd_id_prefix__.X11 enable_key_equivalents -boolean false
+.B defaults write __bundle_id_prefix__.X11 enable_key_equivalents -boolean false
Disable menu keyboard equivalents while X11 windows are focused.
.TP 8
-.B defaults write __laucnd_id_prefix__.X11 depth \fIdepth\fP
+.B defaults write __bundle_id_prefix__.X11 depth \fIdepth\fP
Specifies the color bit depth to use. Currently only 15, and 24 color
bits per pixel are supported. If not specified, or a value of -1 is specified,
defaults to the depth of the main display.
.TP 8
-.B defaults write __laucnd_id_prefix__.X11 sync_keymap -boolean true
+.B defaults write __bundle_id_prefix__.X11 sync_keymap -boolean true
Keep the X11 keymap up to date with the OSX system keymap.
.TP 8
-.B defaults write __laucnd_id_prefix__.X11 option_sends_alt -boolean true
+.B defaults write __bundle_id_prefix__.X11 option_sends_alt -boolean true
The Option key will send Alt_L and Alt_R instead of Mode_switch.
.TP 8
-.B defaults write __laucnd_id_prefix__.X11 sync_pasteboard -boolean true
+.B defaults write __bundle_id_prefix__.X11 sync_pasteboard -boolean true
Enable syncing between the OSX pasteboard and clipboard/primary selection buffers in X11. This option needs to be true for any of the other pasteboard sync options to have an effect.
.TP 8
-.B defaults write __laucnd_id_prefix__.X11 sync_pasteboard_to_clipboard -boolean true
+.B defaults write __bundle_id_prefix__.X11 sync_pasteboard_to_clipboard -boolean true
Update the X11 CLIPBOARD when the OSX NSPasteboard is updated.
.TP 8
-.B defaults write __laucnd_id_prefix__.X11 sync_pasteboard_to_primary -boolean true
+.B defaults write __bundle_id_prefix__.X11 sync_pasteboard_to_primary -boolean true
Update the the X11 PRIMARY buffer when the OSX NSPasteboard is updated.
.TP 8
-.B defaults write __laucnd_id_prefix__.X11 sync_clipboard_to_pasteboard -boolean true
+.B defaults write __bundle_id_prefix__.X11 sync_clipboard_to_pasteboard -boolean true
Update the the OSX NSPasteboard when the X11 CLIPBOARD is updated. Note that enabling this option causes the clipboard synchronization to act as a clipboard manager in X11. This makes it impossible to use xclipboard, klipper, or any other such clipboard managers. If you want to use any of these programs, you must disable this option.
.TP 8
-.B defaults write __laucnd_id_prefix__.X11 sync_primary_on_select -boolean true
+.B defaults write __bundle_id_prefix__.X11 sync_primary_on_select -boolean true
This option defaults to false and is provided only "for experts." It updates the NSPasteboard whenever a new X11 selection is made (rather than requiring you to hit cmd-c to copy the selection to the NSPasteboard). Since the X11 protocol does not require applications to send notification when they change selection, this might not work in all cases (if you run into this problem, try selecting text in another application first, then selecting the text you want).
.TP 8
-.B defaults write __laucnd_id_prefix__.X11 enable_test_extensions -boolean true
+.B defaults write __bundle_id_prefix__.X11 enable_test_extensions -boolean true
This option defaults to false and is only accessible through the command line. Enable this option to turn on the DEC-XTRAP, RECORD, and XTEST extensions in the server.
.SH OPTIONS
.PP
@@ -102,9 +102,32 @@ Same as fake_button3 above.
.TP 8
.B "\-depth \fIdepth\fP"
Same as depth above.
+.SH LOGGING
+XQuartz stores a server log at ~/Library/Logs/X11.__bundle_id_prefix__.log which
+is analogous to /var/log/Xorg.#.log on systems that use the XFree86 DDX such as
+Linux, BSD, and Solaris.
+.PP
+In addition to this server log, XQuartz sends messages to syslogd(8) using
+asl(3). These logs are sent to the __bundle_id_prefix__ facility, and you can
+watch these logs using the following syslog(1) command:
+.TP 8
+.B $ syslog -w -k Facility __bundle_id_prefix__
+.PP
+By default, XQaurtz sets an ASL mask which prevents it from logging messages
+below the ASL_LEVEL_WARNING level (meaning almost all logging is done strictly
+to the file referenced above). To force XQuartz to send all log messages to
+syslogd(8), you can adjust this mask using the following syslog(1) command:
+.TP 8
+.B $ syslog -c X11.bin -d
+.PP
+The stdout and stderr messages printed by any process launched by XQuartz will
+be redirected to this syslog facility with a priority level of ASL_LEVEL_INFO
+and ASL_LEVEL_NOTICE respectively. In order to see these messages in syslog,
+you will need to adjust XQuartz's asl mask as above but using -i or -n
+instead of -d.
.SH "SEE ALSO"
.PP
-X(__miscmansuffix__), Xserver(1), xdm(1), xinit(1)
+X(__miscmansuffix__), Xserver(1), xdm(1), xinit(1), syslog(1), syslogd(8)
.PP
http://xquartz.macosforge.org
.PP
diff --git a/xorg-server/hw/xquartz/quartzKeyboard.c b/xorg-server/hw/xquartz/quartzKeyboard.c
index c54011488..e682f08b6 100644
--- a/xorg-server/hw/xquartz/quartzKeyboard.c
+++ b/xorg-server/hw/xquartz/quartzKeyboard.c
@@ -56,13 +56,7 @@
#include "X11Application.h"
-#ifdef NDEBUG
-#undef NDEBUG
#include <assert.h>
-#define NDEBUG 1
-#else
-#include <assert.h>
-#endif
#include <pthread.h>
#include "xkbsrv.h"
diff --git a/xorg-server/hw/xquartz/sanitizedCocoa.h b/xorg-server/hw/xquartz/sanitizedCocoa.h
index 58de64c1c..5a2a282d1 100644
--- a/xorg-server/hw/xquartz/sanitizedCocoa.h
+++ b/xorg-server/hw/xquartz/sanitizedCocoa.h
@@ -16,7 +16,8 @@
#define BOOL OSX_BOOL
#define EventType HIT_EventType
-#include <Cocoa/Cocoa.h>
+#import <Cocoa/Cocoa.h>
+#import <Foundation/Foundation.h>
#undef Cursor
#undef WindowPtr
@@ -24,4 +25,40 @@
#undef BOOL
#undef EventType
+#ifndef __has_feature
+#define __has_feature(x) 0 // Compatibility with non-clang compilers.
+#endif
+
+#ifndef NS_RETURNS_RETAINED
+#if __has_feature(attribute_ns_returns_retained)
+#define NS_RETURNS_RETAINED __attribute__((ns_returns_retained))
+#else
+#define NS_RETURNS_RETAINED
+#endif
+#endif
+
+#ifndef NS_RETURNS_NOT_RETAINED
+#if __has_feature(attribute_ns_returns_not_retained)
+#define NS_RETURNS_NOT_RETAINED __attribute__((ns_returns_not_retained))
+#else
+#define NS_RETURNS_NOT_RETAINED
+#endif
+#endif
+
+#ifndef CF_RETURNS_RETAINED
+#if __has_feature(attribute_cf_returns_retained)
+#define CF_RETURNS_RETAINED __attribute__((cf_returns_retained))
+#else
+#define CF_RETURNS_RETAINED
+#endif
+#endif
+
+#ifndef CF_RETURNS_NOT_RETAINED
+#if __has_feature(attribute_cf_returns_not_retained)
+#define CF_RETURNS_NOT_RETAINED __attribute__((cf_returns_not_retained))
+#else
+#define CF_RETURNS_NOT_RETAINED
+#endif
+#endif
+
#endif /* _XQ_SANITIZED_COCOA_H_ */
diff --git a/xorg-server/hw/xquartz/xpr/xprFrame.c b/xorg-server/hw/xquartz/xpr/xprFrame.c
index 5f6b1cb7b..4818653f6 100644
--- a/xorg-server/hw/xquartz/xpr/xprFrame.c
+++ b/xorg-server/hw/xquartz/xpr/xprFrame.c
@@ -69,7 +69,7 @@ static x_hash_table *window_hash;
#ifdef HAVE_LIBDISPATCH
static dispatch_queue_t window_hash_serial_q;
#else
-static pthread_mutex_t window_hash_mutex;
+static pthread_rwlock_t window_hash_rwlock;
#endif
/* Prototypes for static functions */
@@ -192,9 +192,9 @@ xprCreateFrame(RootlessWindowPtr pFrame, ScreenPtr pScreen,
x_hash_table_insert(window_hash, pFrame->wid, pFrame);
});
#else
- pthread_mutex_lock(&window_hash_mutex);
+ pthread_rwlock_wrlock(&window_hash_rwlock);
x_hash_table_insert(window_hash, pFrame->wid, pFrame);
- pthread_mutex_unlock(&window_hash_mutex);
+ pthread_rwlock_wrlock(&window_hash_rwlock);
#endif
xprSetNativeProperty(pFrame);
@@ -216,9 +216,9 @@ xprDestroyFrame(RootlessFrameID wid)
x_hash_table_remove(window_hash, wid);
});
#else
- pthread_mutex_lock(&window_hash_mutex);
+ pthread_rwlock_wrlock(&window_hash_rwlock);
x_hash_table_remove(window_hash, wid);
- pthread_mutex_unlock(&window_hash_mutex);
+ pthread_rwlock_unlock(&window_hash_rwlock);
#endif
err = xp_destroy_window(x_cvt_vptr_to_uint(wid));
@@ -292,9 +292,9 @@ static void xprRestackFrame(RootlessFrameID wid, RootlessFrameID nextWid) {
winRec = x_hash_table_lookup(window_hash, wid, NULL);
});
#else
- pthread_mutex_lock(&window_hash_mutex);
+ pthread_rwlock_rdlock(&window_hash_rwlock);
winRec = x_hash_table_lookup(window_hash, wid, NULL);
- pthread_mutex_unlock(&window_hash_mutex);
+ pthread_rwlock_unlock(&window_hash_rwlock);
#endif
if(winRec) {
@@ -479,7 +479,7 @@ xprInit(ScreenPtr pScreen)
#ifdef HAVE_LIBDISPATCH
assert((window_hash_serial_q = dispatch_queue_create(BUNDLE_ID_PREFIX".X11.xpr_window_hash", NULL)));
#else
- assert(0 == pthread_mutex_init(&window_hash_mutex, NULL));
+ assert(0 == pthread_rwlock_init(&window_hash_rwlock, NULL));
#endif
return TRUE;
@@ -500,9 +500,9 @@ xprGetXWindow(xp_window_id wid)
});
#else
RootlessWindowRec *winRec;
- pthread_mutex_lock(&window_hash_mutex);
+ pthread_rwlock_rdlock(&window_hash_rwlock);
winRec = x_hash_table_lookup(window_hash, x_cvt_uint_to_vptr(wid), NULL);
- pthread_mutex_unlock(&window_hash_mutex);
+ pthread_rwlock_unlock(&window_hash_rwlock);
#endif
return winRec != NULL ? winRec->win : NULL;
diff --git a/xorg-server/hw/xwin/winkeybd.c b/xorg-server/hw/xwin/winkeybd.c
index 912e2de1c..2fa6b3f6e 100644
--- a/xorg-server/hw/xwin/winkeybd.c
+++ b/xorg-server/hw/xwin/winkeybd.c
@@ -472,8 +472,7 @@ winKeybdReleaseKeys (void)
void
winSendKeyEvent (DWORD dwKey, Bool fDown)
{
- EventListPtr events;
- int i, nevents;
+ InternalEvent* events;
/*
* When alt-tabing between screens we can get phantom key up messages
@@ -484,11 +483,7 @@ winSendKeyEvent (DWORD dwKey, Bool fDown)
/* Update the keyState map */
g_winKeyState[dwKey] = fDown;
- GetEventList(&events);
- nevents = GetKeyboardEvents(events, g_pwinKeyboard, fDown ? KeyPress : KeyRelease, dwKey + MIN_KEYCODE, NULL);
-
- for (i = 0; i < nevents; i++)
- mieqEnqueue(g_pwinKeyboard, (InternalEvent*)events[i].event);
+ QueueKeyboardEvents(g_pwinKeyboard, fDown ? KeyPress : KeyRelease, dwKey + MIN_KEYCODE, NULL);
winDebug("winSendKeyEvent: dwKey: %d, fDown: %d, nEvents %d\n",
dwKey, fDown, nevents);
diff --git a/xorg-server/hw/xwin/winmouse.c b/xorg-server/hw/xwin/winmouse.c
index 48b426f79..b1b0657cf 100644
--- a/xorg-server/hw/xwin/winmouse.c
+++ b/xorg-server/hw/xwin/winmouse.c
@@ -1,386 +1,375 @@
-/*
- *Copyright (C) 1994-2000 The XFree86 Project, Inc. All Rights Reserved.
- *
- *Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files (the
- *"Software"), to deal in the Software without restriction, including
- *without limitation the rights to use, copy, modify, merge, publish,
- *distribute, sublicense, and/or sell copies of the Software, and to
- *permit persons to whom the Software is furnished to do so, subject to
- *the following conditions:
- *
- *The above copyright notice and this permission notice shall be
- *included in all copies or substantial portions of the Software.
- *
- *THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- *EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- *MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- *NONINFRINGEMENT. IN NO EVENT SHALL THE XFREE86 PROJECT BE LIABLE FOR
- *ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
- *CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
- *WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- *Except as contained in this notice, the name of the XFree86 Project
- *shall not be used in advertising or otherwise to promote the sale, use
- *or other dealings in this Software without prior written authorization
- *from the XFree86 Project.
- *
- * Authors: Dakshinamurthy Karra
- * Suhaib M Siddiqi
- * Peter Busch
- * Harold L Hunt II
- */
-
-#ifdef HAVE_XWIN_CONFIG_H
-#include <xwin-config.h>
-#endif
-#include "win.h"
-
-#include "inputstr.h"
-#include "exevents.h" /* for button/axes labels */
-#include "xserver-properties.h"
-#include "inpututils.h"
-
-/* Peek the internal button mapping */
-static CARD8 const *g_winMouseButtonMap = NULL;
-
-
-/*
- * Local prototypes
- */
-
-static void
-winMouseCtrl (DeviceIntPtr pDevice, PtrCtrl *pCtrl);
-
-
-static void
-winMouseCtrl (DeviceIntPtr pDevice, PtrCtrl *pCtrl)
-{
-}
-
-
-/*
- * See Porting Layer Definition - p. 18
- * This is known as a DeviceProc
- */
-
-int
-winMouseProc (DeviceIntPtr pDeviceInt, int iState)
-{
- int lngMouseButtons, i;
- int lngWheelEvents = 2;
- CARD8 *map;
- DevicePtr pDevice = (DevicePtr) pDeviceInt;
- Atom *btn_labels;
- Atom axes_labels[2];
-
- switch (iState)
- {
- case DEVICE_INIT:
- /* Get number of mouse buttons */
- lngMouseButtons = GetSystemMetrics(SM_CMOUSEBUTTONS);
-
- /* Mapping of windows events to X events:
- * LEFT:1 MIDDLE:2 RIGHT:3
- * SCROLL_UP:4 SCROLL_DOWN:5
- * XBUTTON 1:6 XBUTTON 2:7 ...
- *
- * To map scroll wheel correctly we need at least the 3 normal buttons
- */
- if (lngMouseButtons < 3)
- lngMouseButtons = 3;
- winMsg(X_PROBED, "%d mouse buttons found\n", lngMouseButtons);
-
- /* allocate memory:
- * number of buttons + 2x mouse wheel event + 1 extra (offset for map)
- */
- map = malloc(sizeof(CARD8) * (lngMouseButtons + lngWheelEvents + 1));
-
- /* initalize button map */
- map[0] = 0;
- for (i=1; i <= lngMouseButtons + lngWheelEvents; i++)
- map[i] = i;
-
- btn_labels = calloc((lngMouseButtons + lngWheelEvents), sizeof(Atom));
- btn_labels[0] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_LEFT);
- btn_labels[1] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_MIDDLE);
- btn_labels[2] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_RIGHT);
- btn_labels[3] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_WHEEL_UP);
- btn_labels[4] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_WHEEL_DOWN);
-
- axes_labels[0] = XIGetKnownProperty(AXIS_LABEL_PROP_REL_X);
- axes_labels[1] = XIGetKnownProperty(AXIS_LABEL_PROP_REL_Y);
-
- InitPointerDeviceStruct (pDevice,
- map,
- lngMouseButtons + lngWheelEvents,
- btn_labels,
- winMouseCtrl,
- GetMotionHistorySize(),
- 2,
- axes_labels);
- free(map);
- free(btn_labels);
-
- g_winMouseButtonMap = pDeviceInt->button->map;
- break;
-
- case DEVICE_ON:
- pDevice->on = TRUE;
- break;
-
- case DEVICE_CLOSE:
- g_winMouseButtonMap = NULL;
-
- case DEVICE_OFF:
- pDevice->on = FALSE;
- break;
- }
- return Success;
-}
-
-
-/* Handle the mouse wheel */
-int
-winMouseWheel (ScreenPtr pScreen, int iDeltaZ)
-{
- winScreenPriv(pScreen);
- int button; /* Button4 or Button5 */
-
- /* Button4 = WheelUp */
- /* Button5 = WheelDown */
-
- /* Do we have any previous delta stored? */
- if ((pScreenPriv->iDeltaZ > 0
- && iDeltaZ > 0)
- || (pScreenPriv->iDeltaZ < 0
- && iDeltaZ < 0))
- {
- /* Previous delta and of same sign as current delta */
- iDeltaZ += pScreenPriv->iDeltaZ;
- pScreenPriv->iDeltaZ = 0;
- }
- else
- {
- /*
- * Previous delta of different sign, or zero.
- * We will set it to zero for either case,
- * as blindly setting takes just as much time
- * as checking, then setting if necessary :)
- */
- pScreenPriv->iDeltaZ = 0;
- }
-
- /*
- * Only process this message if the wheel has moved further than
- * WHEEL_DELTA
- */
- if (iDeltaZ >= WHEEL_DELTA || (-1 * iDeltaZ) >= WHEEL_DELTA)
- {
- pScreenPriv->iDeltaZ = 0;
-
- /* Figure out how many whole deltas of the wheel we have */
- iDeltaZ /= WHEEL_DELTA;
- }
- else
- {
- /*
- * Wheel has not moved past WHEEL_DELTA threshold;
- * we will store the wheel delta until the threshold
- * has been reached.
- */
- pScreenPriv->iDeltaZ = iDeltaZ;
- return 0;
- }
-
- /* Set the button to indicate up or down wheel delta */
- if (iDeltaZ > 0)
- {
- button = Button4;
- }
- else
- {
- button = Button5;
- }
-
- /*
- * Flip iDeltaZ to positive, if negative,
- * because always need to generate a *positive* number of
- * button clicks for the Z axis.
- */
- if (iDeltaZ < 0)
- {
- iDeltaZ *= -1;
- }
-
- /* Generate X input messages for each wheel delta we have seen */
- while (iDeltaZ--)
- {
- /* Push the wheel button */
- winMouseButtonsSendEvent (ButtonPress, button);
-
- /* Release the wheel button */
- winMouseButtonsSendEvent (ButtonRelease, button);
- }
-
- return 0;
-}
-
-
-/*
- * Enqueue a mouse button event
- */
-
-void
-winMouseButtonsSendEvent (int iEventType, int iButton)
-{
- EventListPtr events;
- int i, nevents;
- ValuatorMask mask;
-
- if (g_winMouseButtonMap)
- iButton = g_winMouseButtonMap[iButton];
-
- valuator_mask_zero(&mask);
- GetEventList(&events);
- nevents = GetPointerEvents(events, g_pwinPointer, iEventType, iButton,
- POINTER_RELATIVE, &mask);
-
- for (i = 0; i < nevents; i++)
- mieqEnqueue(g_pwinPointer, (InternalEvent*)events[i].event);
-
-#if CYGDEBUG
- ErrorF("winMouseButtonsSendEvent: iEventType: %d, iButton: %d, nEvents %d\n",
- iEventType, iButton, nevents);
-#endif
-}
-
-
-/*
- * Decide what to do with a Windows mouse message
- */
-
-int
-winMouseButtonsHandle (ScreenPtr pScreen,
- int iEventType, int iButton,
- WPARAM wParam)
-{
- winScreenPriv(pScreen);
- winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo;
-
- /* Send button events right away if emulate 3 buttons is off */
- if (pScreenInfo->iE3BTimeout == WIN_E3B_OFF)
- {
- /* Emulate 3 buttons is off, send the button event */
- winMouseButtonsSendEvent (iEventType, iButton);
- return 0;
- }
-
- /* Emulate 3 buttons is on, let the fun begin */
- if (iEventType == ButtonPress
- && pScreenPriv->iE3BCachedPress == 0
- && !pScreenPriv->fE3BFakeButton2Sent)
- {
- /*
- * Button was pressed, no press is cached,
- * and there is no fake button 2 release pending.
- */
-
- /* Store button press type */
- pScreenPriv->iE3BCachedPress = iButton;
-
- /*
- * Set a timer to send this button press if the other button
- * is not pressed within the timeout time.
- */
- SetTimer (pScreenPriv->hwndScreen,
- WIN_E3B_TIMER_ID,
- pScreenInfo->iE3BTimeout,
- NULL);
- }
- else if (iEventType == ButtonPress
- && pScreenPriv->iE3BCachedPress != 0
- && pScreenPriv->iE3BCachedPress != iButton
- && !pScreenPriv->fE3BFakeButton2Sent)
- {
- /*
- * Button press is cached, other button was pressed,
- * and there is no fake button 2 release pending.
- */
-
- /* Mouse button was cached and other button was pressed */
- KillTimer (pScreenPriv->hwndScreen, WIN_E3B_TIMER_ID);
- pScreenPriv->iE3BCachedPress = 0;
-
- /* Send fake middle button */
- winMouseButtonsSendEvent (ButtonPress, Button2);
-
- /* Indicate that a fake middle button event was sent */
- pScreenPriv->fE3BFakeButton2Sent = TRUE;
- }
- else if (iEventType == ButtonRelease
- && pScreenPriv->iE3BCachedPress == iButton)
- {
- /*
- * Cached button was released before timer ran out,
- * and before the other mouse button was pressed.
- */
- KillTimer (pScreenPriv->hwndScreen, WIN_E3B_TIMER_ID);
- pScreenPriv->iE3BCachedPress = 0;
-
- /* Send cached press, then send release */
- winMouseButtonsSendEvent (ButtonPress, iButton);
- winMouseButtonsSendEvent (ButtonRelease, iButton);
- }
- else if (iEventType == ButtonRelease
- && pScreenPriv->fE3BFakeButton2Sent
- && !(wParam & MK_LBUTTON)
- && !(wParam & MK_RBUTTON))
- {
- /*
- * Fake button 2 was sent and both mouse buttons have now been released
- */
- pScreenPriv->fE3BFakeButton2Sent = FALSE;
-
- /* Send middle mouse button release */
- winMouseButtonsSendEvent (ButtonRelease, Button2);
- }
- else if (iEventType == ButtonRelease
- && pScreenPriv->iE3BCachedPress == 0
- && !pScreenPriv->fE3BFakeButton2Sent)
- {
- /*
- * Button was release, no button is cached,
- * and there is no fake button 2 release is pending.
- */
- winMouseButtonsSendEvent (ButtonRelease, iButton);
- }
-
- return 0;
-}
-
-/**
- * Enqueue a motion event.
- *
- * XXX: miPointerMove does exactly this, but is static :-( (and uses a static buffer)
- *
- */
-void winEnqueueMotion(int x, int y)
-{
- int i, nevents;
- int valuators[2];
- ValuatorMask mask;
- EventListPtr events;
-
- miPointerSetPosition(g_pwinPointer, POINTER_RELATIVE, &x, &y);
- valuators[0] = x;
- valuators[1] = y;
-
- valuator_mask_set_range(&mask, 0, 2, valuators);
- GetEventList(&events);
- nevents = GetPointerEvents(events, g_pwinPointer, MotionNotify, 0,
- POINTER_ABSOLUTE | POINTER_SCREEN, &mask);
-
- for (i = 0; i < nevents; i++)
- mieqEnqueue(g_pwinPointer, (InternalEvent*)events[i].event);
-}
+/*
+ *Copyright (C) 1994-2000 The XFree86 Project, Inc. All Rights Reserved.
+ *
+ *Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ *"Software"), to deal in the Software without restriction, including
+ *without limitation the rights to use, copy, modify, merge, publish,
+ *distribute, sublicense, and/or sell copies of the Software, and to
+ *permit persons to whom the Software is furnished to do so, subject to
+ *the following conditions:
+ *
+ *The above copyright notice and this permission notice shall be
+ *included in all copies or substantial portions of the Software.
+ *
+ *THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ *EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ *MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ *NONINFRINGEMENT. IN NO EVENT SHALL THE XFREE86 PROJECT BE LIABLE FOR
+ *ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
+ *CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ *WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *Except as contained in this notice, the name of the XFree86 Project
+ *shall not be used in advertising or otherwise to promote the sale, use
+ *or other dealings in this Software without prior written authorization
+ *from the XFree86 Project.
+ *
+ * Authors: Dakshinamurthy Karra
+ * Suhaib M Siddiqi
+ * Peter Busch
+ * Harold L Hunt II
+ */
+
+#ifdef HAVE_XWIN_CONFIG_H
+#include <xwin-config.h>
+#endif
+#include "win.h"
+
+#include "inputstr.h"
+#include "exevents.h" /* for button/axes labels */
+#include "xserver-properties.h"
+#include "inpututils.h"
+
+/* Peek the internal button mapping */
+static CARD8 const *g_winMouseButtonMap = NULL;
+
+
+/*
+ * Local prototypes
+ */
+
+static void
+winMouseCtrl (DeviceIntPtr pDevice, PtrCtrl *pCtrl);
+
+
+static void
+winMouseCtrl (DeviceIntPtr pDevice, PtrCtrl *pCtrl)
+{
+}
+
+
+/*
+ * See Porting Layer Definition - p. 18
+ * This is known as a DeviceProc
+ */
+
+int
+winMouseProc (DeviceIntPtr pDeviceInt, int iState)
+{
+ int lngMouseButtons, i;
+ int lngWheelEvents = 2;
+ CARD8 *map;
+ DevicePtr pDevice = (DevicePtr) pDeviceInt;
+ Atom *btn_labels;
+ Atom axes_labels[2];
+
+ switch (iState)
+ {
+ case DEVICE_INIT:
+ /* Get number of mouse buttons */
+ lngMouseButtons = GetSystemMetrics(SM_CMOUSEBUTTONS);
+
+ /* Mapping of windows events to X events:
+ * LEFT:1 MIDDLE:2 RIGHT:3
+ * SCROLL_UP:4 SCROLL_DOWN:5
+ * XBUTTON 1:6 XBUTTON 2:7 ...
+ *
+ * To map scroll wheel correctly we need at least the 3 normal buttons
+ */
+ if (lngMouseButtons < 3)
+ lngMouseButtons = 3;
+ winMsg(X_PROBED, "%d mouse buttons found\n", lngMouseButtons);
+
+ /* allocate memory:
+ * number of buttons + 2x mouse wheel event + 1 extra (offset for map)
+ */
+ map = malloc(sizeof(CARD8) * (lngMouseButtons + lngWheelEvents + 1));
+
+ /* initalize button map */
+ map[0] = 0;
+ for (i=1; i <= lngMouseButtons + lngWheelEvents; i++)
+ map[i] = i;
+
+ btn_labels = calloc((lngMouseButtons + lngWheelEvents), sizeof(Atom));
+ btn_labels[0] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_LEFT);
+ btn_labels[1] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_MIDDLE);
+ btn_labels[2] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_RIGHT);
+ btn_labels[3] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_WHEEL_UP);
+ btn_labels[4] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_WHEEL_DOWN);
+
+ axes_labels[0] = XIGetKnownProperty(AXIS_LABEL_PROP_REL_X);
+ axes_labels[1] = XIGetKnownProperty(AXIS_LABEL_PROP_REL_Y);
+
+ InitPointerDeviceStruct (pDevice,
+ map,
+ lngMouseButtons + lngWheelEvents,
+ btn_labels,
+ winMouseCtrl,
+ GetMotionHistorySize(),
+ 2,
+ axes_labels);
+ free(map);
+ free(btn_labels);
+
+ g_winMouseButtonMap = pDeviceInt->button->map;
+ break;
+
+ case DEVICE_ON:
+ pDevice->on = TRUE;
+ break;
+
+ case DEVICE_CLOSE:
+ g_winMouseButtonMap = NULL;
+
+ case DEVICE_OFF:
+ pDevice->on = FALSE;
+ break;
+ }
+ return Success;
+}
+
+
+/* Handle the mouse wheel */
+int
+winMouseWheel (ScreenPtr pScreen, int iDeltaZ)
+{
+ winScreenPriv(pScreen);
+ int button; /* Button4 or Button5 */
+
+ /* Button4 = WheelUp */
+ /* Button5 = WheelDown */
+
+ /* Do we have any previous delta stored? */
+ if ((pScreenPriv->iDeltaZ > 0
+ && iDeltaZ > 0)
+ || (pScreenPriv->iDeltaZ < 0
+ && iDeltaZ < 0))
+ {
+ /* Previous delta and of same sign as current delta */
+ iDeltaZ += pScreenPriv->iDeltaZ;
+ pScreenPriv->iDeltaZ = 0;
+ }
+ else
+ {
+ /*
+ * Previous delta of different sign, or zero.
+ * We will set it to zero for either case,
+ * as blindly setting takes just as much time
+ * as checking, then setting if necessary :)
+ */
+ pScreenPriv->iDeltaZ = 0;
+ }
+
+ /*
+ * Only process this message if the wheel has moved further than
+ * WHEEL_DELTA
+ */
+ if (iDeltaZ >= WHEEL_DELTA || (-1 * iDeltaZ) >= WHEEL_DELTA)
+ {
+ pScreenPriv->iDeltaZ = 0;
+
+ /* Figure out how many whole deltas of the wheel we have */
+ iDeltaZ /= WHEEL_DELTA;
+ }
+ else
+ {
+ /*
+ * Wheel has not moved past WHEEL_DELTA threshold;
+ * we will store the wheel delta until the threshold
+ * has been reached.
+ */
+ pScreenPriv->iDeltaZ = iDeltaZ;
+ return 0;
+ }
+
+ /* Set the button to indicate up or down wheel delta */
+ if (iDeltaZ > 0)
+ {
+ button = Button4;
+ }
+ else
+ {
+ button = Button5;
+ }
+
+ /*
+ * Flip iDeltaZ to positive, if negative,
+ * because always need to generate a *positive* number of
+ * button clicks for the Z axis.
+ */
+ if (iDeltaZ < 0)
+ {
+ iDeltaZ *= -1;
+ }
+
+ /* Generate X input messages for each wheel delta we have seen */
+ while (iDeltaZ--)
+ {
+ /* Push the wheel button */
+ winMouseButtonsSendEvent (ButtonPress, button);
+
+ /* Release the wheel button */
+ winMouseButtonsSendEvent (ButtonRelease, button);
+ }
+
+ return 0;
+}
+
+
+/*
+ * Enqueue a mouse button event
+ */
+
+void
+winMouseButtonsSendEvent (int iEventType, int iButton)
+{
+ ValuatorMask mask;
+
+ if (g_winMouseButtonMap)
+ iButton = g_winMouseButtonMap[iButton];
+
+ valuator_mask_zero(&mask);
+ QueuePointerEvents(g_pwinPointer, iEventType, iButton,
+ POINTER_RELATIVE, &mask);
+
+#if CYGDEBUG
+ ErrorF("winMouseButtonsSendEvent: iEventType: %d, iButton: %d, nEvents %d\n",
+ iEventType, iButton, nevents);
+#endif
+}
+
+
+/*
+ * Decide what to do with a Windows mouse message
+ */
+
+int
+winMouseButtonsHandle (ScreenPtr pScreen,
+ int iEventType, int iButton,
+ WPARAM wParam)
+{
+ winScreenPriv(pScreen);
+ winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo;
+
+ /* Send button events right away if emulate 3 buttons is off */
+ if (pScreenInfo->iE3BTimeout == WIN_E3B_OFF)
+ {
+ /* Emulate 3 buttons is off, send the button event */
+ winMouseButtonsSendEvent (iEventType, iButton);
+ return 0;
+ }
+
+ /* Emulate 3 buttons is on, let the fun begin */
+ if (iEventType == ButtonPress
+ && pScreenPriv->iE3BCachedPress == 0
+ && !pScreenPriv->fE3BFakeButton2Sent)
+ {
+ /*
+ * Button was pressed, no press is cached,
+ * and there is no fake button 2 release pending.
+ */
+
+ /* Store button press type */
+ pScreenPriv->iE3BCachedPress = iButton;
+
+ /*
+ * Set a timer to send this button press if the other button
+ * is not pressed within the timeout time.
+ */
+ SetTimer (pScreenPriv->hwndScreen,
+ WIN_E3B_TIMER_ID,
+ pScreenInfo->iE3BTimeout,
+ NULL);
+ }
+ else if (iEventType == ButtonPress
+ && pScreenPriv->iE3BCachedPress != 0
+ && pScreenPriv->iE3BCachedPress != iButton
+ && !pScreenPriv->fE3BFakeButton2Sent)
+ {
+ /*
+ * Button press is cached, other button was pressed,
+ * and there is no fake button 2 release pending.
+ */
+
+ /* Mouse button was cached and other button was pressed */
+ KillTimer (pScreenPriv->hwndScreen, WIN_E3B_TIMER_ID);
+ pScreenPriv->iE3BCachedPress = 0;
+
+ /* Send fake middle button */
+ winMouseButtonsSendEvent (ButtonPress, Button2);
+
+ /* Indicate that a fake middle button event was sent */
+ pScreenPriv->fE3BFakeButton2Sent = TRUE;
+ }
+ else if (iEventType == ButtonRelease
+ && pScreenPriv->iE3BCachedPress == iButton)
+ {
+ /*
+ * Cached button was released before timer ran out,
+ * and before the other mouse button was pressed.
+ */
+ KillTimer (pScreenPriv->hwndScreen, WIN_E3B_TIMER_ID);
+ pScreenPriv->iE3BCachedPress = 0;
+
+ /* Send cached press, then send release */
+ winMouseButtonsSendEvent (ButtonPress, iButton);
+ winMouseButtonsSendEvent (ButtonRelease, iButton);
+ }
+ else if (iEventType == ButtonRelease
+ && pScreenPriv->fE3BFakeButton2Sent
+ && !(wParam & MK_LBUTTON)
+ && !(wParam & MK_RBUTTON))
+ {
+ /*
+ * Fake button 2 was sent and both mouse buttons have now been released
+ */
+ pScreenPriv->fE3BFakeButton2Sent = FALSE;
+
+ /* Send middle mouse button release */
+ winMouseButtonsSendEvent (ButtonRelease, Button2);
+ }
+ else if (iEventType == ButtonRelease
+ && pScreenPriv->iE3BCachedPress == 0
+ && !pScreenPriv->fE3BFakeButton2Sent)
+ {
+ /*
+ * Button was release, no button is cached,
+ * and there is no fake button 2 release is pending.
+ */
+ winMouseButtonsSendEvent (ButtonRelease, iButton);
+ }
+
+ return 0;
+}
+
+/**
+ * Enqueue a motion event.
+ *
+ * XXX: miPointerMove does exactly this, but is static :-( (and uses a static buffer)
+ *
+ */
+void winEnqueueMotion(int x, int y)
+{
+ int valuators[2];
+ ValuatorMask mask;
+
+ miPointerSetPosition(g_pwinPointer, POINTER_RELATIVE, &x, &y);
+ valuators[0] = x;
+ valuators[1] = y;
+
+ valuator_mask_set_range(&mask, 0, 2, valuators);
+ QueuePointerEvents(g_pwinPointer, MotionNotify, 0,
+ POINTER_ABSOLUTE | POINTER_SCREEN, &mask);
+
+}
diff --git a/xorg-server/include/dix.h b/xorg-server/include/dix.h
index c201e3ac1..9a111e8a7 100644
--- a/xorg-server/include/dix.h
+++ b/xorg-server/include/dix.h
@@ -375,7 +375,7 @@ extern void ReleaseActiveGrabs(
extern GrabPtr CheckPassiveGrabsOnWindow(
WindowPtr /* pWin */,
DeviceIntPtr /* device */,
- DeviceEvent * /* event */,
+ InternalEvent * /* event */,
BOOL /* checkCore */,
BOOL /* activate */);
@@ -415,7 +415,7 @@ extern void DeliverFocusedEvent(
InternalEvent* /* event */,
WindowPtr /* window */);
-extern void DeliverGrabbedEvent(
+extern int DeliverGrabbedEvent(
InternalEvent* /* event */,
DeviceIntPtr /* thisDev */,
Bool /* deactivateGrab */);
diff --git a/xorg-server/include/eventstr.h b/xorg-server/include/eventstr.h
index 673207ce3..049688ca0 100644
--- a/xorg-server/include/eventstr.h
+++ b/xorg-server/include/eventstr.h
@@ -68,10 +68,6 @@ enum EventType {
ET_Internal = 0xFF /* First byte */
};
-#define CHECKEVENT(ev) if (ev && ((InternalEvent*)(ev))->any.header != 0xFF) \
- FatalError("Wrong event type %d.\n", \
- ((InternalEvent*)(ev))->any.header);
-
/**
* Used for ALL input device events internal in the server until
* copied into the matching protocol event.
diff --git a/xorg-server/include/input.h b/xorg-server/include/input.h
index 86078daee..4de4ff52c 100644
--- a/xorg-server/include/input.h
+++ b/xorg-server/include/input.h
@@ -109,19 +109,8 @@ typedef union _GrabMask GrabMask;
typedef struct _ValuatorMask ValuatorMask;
-typedef struct _EventList {
- xEvent* event;
- int evlen; /* length of allocated memory for event in bytes. This is not
- the actual length of the event. The event's actual length is
- 32 for standard events or 32 +
- ((xGenericEvent*)event)->length * 4 for GenericEvents.
- For events in the EQ, the length is
- ((InternalEvent*)event)->u.any.length */
-} EventList, *EventListPtr;
-
/* The DIX stores incoming input events in this list */
-extern EventListPtr InputEventList;
-extern int InputEventListLen;
+extern InternalEvent* InputEventList;
typedef int (*DeviceProc)(
DeviceIntPtr /*device*/,
@@ -439,22 +428,28 @@ extern _X_EXPORT void CloseInput(void);
extern _X_EXPORT int GetMaximumEventsNum(void);
-extern _X_EXPORT int GetEventList(EventListPtr* list);
-extern _X_EXPORT EventListPtr InitEventList(int num_events);
-extern _X_EXPORT void FreeEventList(EventListPtr list, int num_events);
+extern _X_EXPORT InternalEvent *InitEventList(int num_events);
+extern _X_EXPORT void FreeEventList(InternalEvent *list, int num_events);
-extern void CreateClassesChangedEvent(EventListPtr event,
+extern void CreateClassesChangedEvent(InternalEvent *event,
DeviceIntPtr master,
DeviceIntPtr slave,
int type);
-extern EventListPtr UpdateFromMaster(
- EventListPtr events,
+extern InternalEvent * UpdateFromMaster(
+ InternalEvent *events,
DeviceIntPtr pDev,
int type,
int *num_events);
extern _X_EXPORT int GetPointerEvents(
- EventListPtr events,
+ InternalEvent *events,
+ DeviceIntPtr pDev,
+ int type,
+ int buttons,
+ int flags,
+ const ValuatorMask *mask);
+
+extern _X_EXPORT void QueuePointerEvents(
DeviceIntPtr pDev,
int type,
int buttons,
@@ -462,14 +457,25 @@ extern _X_EXPORT int GetPointerEvents(
const ValuatorMask *mask);
extern _X_EXPORT int GetKeyboardEvents(
- EventListPtr events,
+ InternalEvent *events,
+ DeviceIntPtr pDev,
+ int type,
+ int key_code,
+ const ValuatorMask *mask);
+
+extern _X_EXPORT void QueueKeyboardEvents(
DeviceIntPtr pDev,
int type,
int key_code,
const ValuatorMask *mask);
extern int GetProximityEvents(
- EventListPtr events,
+ InternalEvent *events,
+ DeviceIntPtr pDev,
+ int type,
+ const ValuatorMask *mask);
+
+extern void QueueProximityEvents(
DeviceIntPtr pDev,
int type,
const ValuatorMask *mask);
@@ -495,6 +501,8 @@ extern _X_EXPORT int GetMotionHistory(
ScreenPtr pScreen,
BOOL core);
+extern void ReleaseButtonsAndKeys(DeviceIntPtr dev);
+
extern int AttachDevice(ClientPtr client,
DeviceIntPtr slave,
DeviceIntPtr master);
diff --git a/xorg-server/include/inputstr.h b/xorg-server/include/inputstr.h
index bd7c78dec..bc0accc87 100644
--- a/xorg-server/include/inputstr.h
+++ b/xorg-server/include/inputstr.h
@@ -591,4 +591,14 @@ typedef struct _EventSyncInfo {
extern EventSyncInfoRec syncEvents;
+/**
+ * Given a sprite, returns the window at the bottom of the trace (i.e. the
+ * furthest window from the root).
+ */
+static inline WindowPtr DeepestSpriteWin(SpritePtr sprite)
+{
+ assert(sprite->spriteTraceGood > 0);
+ return sprite->spriteTrace[sprite->spriteTraceGood - 1];
+}
+
#endif /* INPUTSTRUCT_H */
diff --git a/xorg-server/include/inpututils.h b/xorg-server/include/inpututils.h
index af07afeb0..92a754327 100644
--- a/xorg-server/include/inpututils.h
+++ b/xorg-server/include/inpututils.h
@@ -1,40 +1,42 @@
-/*
- * Copyright © 2010 Red Hat, 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 (including the next
- * paragraph) shall be included in all copies or substantial portions of the
- * Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
- * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
- * DEALINGS IN THE SOFTWARE.
- *
- */
-
-#ifdef HAVE_DIX_CONFIG_H
-#include "dix-config.h"
-#endif
-
-#ifndef INPUTUTILS_H
-#define INPUTUTILS_H
-
-#include "input.h"
-
-struct _ValuatorMask {
- int8_t last_bit; /* highest bit set in mask */
- uint8_t mask[(MAX_VALUATORS + 7)/8];
- int valuators[MAX_VALUATORS]; /* valuator data */
-};
-
-#endif
+/*
+ * Copyright © 2010 Red Hat, 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 (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ *
+ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include "dix-config.h"
+#endif
+
+#ifndef INPUTUTILS_H
+#define INPUTUTILS_H
+
+#include "input.h"
+
+struct _ValuatorMask {
+ int8_t last_bit; /* highest bit set in mask */
+ uint8_t mask[(MAX_VALUATORS + 7)/8];
+ int valuators[MAX_VALUATORS]; /* valuator data */
+};
+
+extern void verify_internal_event(const InternalEvent *ev);
+
+#endif
diff --git a/xorg-server/include/misc.h b/xorg-server/include/misc.h
index 42f225b17..bdcc8cc1e 100644
--- a/xorg-server/include/misc.h
+++ b/xorg-server/include/misc.h
@@ -1,302 +1,320 @@
-/***********************************************************
-
-Copyright 1987, 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.
-
-
-Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
-
- All Rights Reserved
-
-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 Digital not be
-used in advertising or publicity pertaining to distribution of the
-software without specific, written prior permission.
-
-DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
-ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
-DIGITAL 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 1992, 1993 Data General Corporation;
-Copyright 1992, 1993 OMRON Corporation
-
-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
-neither the name OMRON or DATA GENERAL be used in advertising or publicity
-pertaining to distribution of the software without specific, written prior
-permission of the party whose name is to be used. Neither OMRON or
-DATA GENERAL make any representation about the suitability of this software
-for any purpose. It is provided "as is" without express or implied warranty.
-
-OMRON AND DATA GENERAL EACH DISCLAIM ALL WARRANTIES WITH REGARD TO THIS
-SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS,
-IN NO EVENT SHALL OMRON OR DATA GENERAL BE LIABLE FOR ANY SPECIAL, INDIRECT
-OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
-DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
-TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
-OF THIS SOFTWARE.
-
-******************************************************************/
-#ifndef MISC_H
-#define MISC_H 1
-/*
- * X internal definitions
- *
- */
-
-#include <X11/Xosdefs.h>
-#include <X11/Xfuncproto.h>
-#include <X11/Xmd.h>
-#include <X11/X.h>
-#include <X11/Xdefs.h>
-
-#include <stddef.h>
-#include <stdint.h>
-
-#ifndef MAXSCREENS
-#define MAXSCREENS 16
-#endif
-#define MAXCLIENTS 256
-#define MAXEXTENSIONS 128
-#define MAXFORMATS 8
-#define MAXDEVICES 40 /* input devices */
-
-#define EXTENSION_EVENT_BASE 64
-#define EXTENSION_BASE 128
-
-typedef uint32_t ATOM;
-
-#ifndef TRUE
-#define TRUE 1
-#define FALSE 0
-#endif
-
-#ifndef _XTYPEDEF_CALLBACKLISTPTR
-typedef struct _CallbackList *CallbackListPtr; /* also in dix.h */
-#define _XTYPEDEF_CALLBACKLISTPTR
-#endif
-
-typedef struct _xReq *xReqPtr;
-
-#include "os.h" /* for ALLOCATE_LOCAL and DEALLOCATE_LOCAL */
-#include <X11/Xfuncs.h> /* for bcopy, bzero, and bcmp */
-
-#define NullBox ((BoxPtr)0)
-#define MILLI_PER_MIN (1000 * 60)
-#define MILLI_PER_SECOND (1000)
-
- /* this next is used with None and ParentRelative to tell
- PaintWin() what to use to paint the background. Also used
- in the macro IS_VALID_PIXMAP */
-
-#define USE_BACKGROUND_PIXEL 3
-#define USE_BORDER_PIXEL 3
-
-
-/* byte swap a 32-bit literal */
-#define lswapl(x) ((((x) & 0xff) << 24) |\
- (((x) & 0xff00) << 8) |\
- (((x) & 0xff0000) >> 8) |\
- (((x) >> 24) & 0xff))
-
-/* byte swap a short literal */
-#define lswaps(x) ((((x) & 0xff) << 8) | (((x) >> 8) & 0xff))
-
-#undef min
-#undef max
-
-#define min(a, b) (((a) < (b)) ? (a) : (b))
-#define max(a, b) (((a) > (b)) ? (a) : (b))
-/* abs() is a function, not a macro; include the file declaring
- * it in case we haven't done that yet.
- */
-#include <stdlib.h>
-#ifndef Fabs
-#define Fabs(a) ((a) > 0.0 ? (a) : -(a)) /* floating absolute value */
-#endif
-#define sign(x) ((x) < 0 ? -1 : ((x) > 0 ? 1 : 0))
-/* this assumes b > 0 */
-#define modulus(a, b, d) if (((d) = (a) % (b)) < 0) (d) += (b)
-/*
- * return the least significant bit in x which is set
- *
- * This works on 1's complement and 2's complement machines.
- * If you care about the extra instruction on 2's complement
- * machines, change to ((x) & (-(x)))
- */
-#define lowbit(x) ((x) & (~(x) + 1))
-
-/* XXX Not for modules */
-#include <limits.h>
-#if !defined(MAXSHORT) || !defined(MINSHORT) || \
- !defined(MAXINT) || !defined(MININT)
-/*
- * Some implementations #define these through <math.h>, so preclude
- * #include'ing it later.
- */
-
-#include <math.h>
-#undef MAXSHORT
-#define MAXSHORT SHRT_MAX
-#undef MINSHORT
-#define MINSHORT SHRT_MIN
-#undef MAXINT
-#define MAXINT INT_MAX
-#undef MININT
-#define MININT INT_MIN
-
-#include <assert.h>
-#include <ctype.h>
-#include <stdio.h> /* for fopen, etc... */
-
-#endif
-
-#ifndef PATH_MAX
-#include <sys/param.h>
-#ifndef PATH_MAX
-#ifdef MAXPATHLEN
-#define PATH_MAX MAXPATHLEN
-#else
-#define PATH_MAX 1024
-#endif
-#endif
-#endif
-
-/**
- * Calculate the number of bytes needed to hold bits.
- * @param bits The minimum number of bits needed.
- * @return The number of bytes needed to hold bits.
- */
-static inline int
-bits_to_bytes(const int bits) {
- return ((bits + 7) >> 3);
-}
-/**
- * Calculate the number of 4-byte units needed to hold the given number of
- * bytes.
- * @param bytes The minimum number of bytes needed.
- * @return The number of 4-byte units needed to hold bytes.
- */
-static inline int
-bytes_to_int32(const int bytes) {
- return (((bytes) + 3) >> 2);
-}
-
-/**
- * Calculate the number of bytes (in multiples of 4) needed to hold bytes.
- * @param bytes The minimum number of bytes needed.
- * @return The closest multiple of 4 that is equal or higher than bytes.
- */
-static inline int
-pad_to_int32(const int bytes) {
- return (((bytes) + 3) & ~3);
-}
-
-extern char**
-xstrtokenize(const char *str, const char* separators);
-
-/* some macros to help swap requests, replies, and events */
-
-#define LengthRestB(stuff) \
- ((client->req_len << 2) - sizeof(*stuff))
-
-#define LengthRestS(stuff) \
- ((client->req_len << 1) - (sizeof(*stuff) >> 1))
-
-#define LengthRestL(stuff) \
- (client->req_len - (sizeof(*stuff) >> 2))
-
-#define SwapRestS(stuff) \
- SwapShorts((short *)(stuff + 1), LengthRestS(stuff))
-
-#define SwapRestL(stuff) \
- SwapLongs((CARD32 *)(stuff + 1), LengthRestL(stuff))
-
-/* byte swap a 32-bit value */
-#define swapl(x, n) { \
- n = ((char *) (x))[0];\
- ((char *) (x))[0] = ((char *) (x))[3];\
- ((char *) (x))[3] = n;\
- n = ((char *) (x))[1];\
- ((char *) (x))[1] = ((char *) (x))[2];\
- ((char *) (x))[2] = n; }
-
-/* byte swap a short */
-#define swaps(x, n) { \
- n = ((char *) (x))[0];\
- ((char *) (x))[0] = ((char *) (x))[1];\
- ((char *) (x))[1] = n; }
-
-/* copy 32-bit value from src to dst byteswapping on the way */
-#define cpswapl(src, dst) { \
- ((char *)&(dst))[0] = ((char *) &(src))[3];\
- ((char *)&(dst))[1] = ((char *) &(src))[2];\
- ((char *)&(dst))[2] = ((char *) &(src))[1];\
- ((char *)&(dst))[3] = ((char *) &(src))[0]; }
-
-/* copy short from src to dst byteswapping on the way */
-#define cpswaps(src, dst) { \
- ((char *) &(dst))[0] = ((char *) &(src))[1];\
- ((char *) &(dst))[1] = ((char *) &(src))[0]; }
-
-extern _X_EXPORT void SwapLongs(
- CARD32 *list,
- unsigned long count);
-
-extern _X_EXPORT void SwapShorts(
- short *list,
- unsigned long count);
-
-extern _X_EXPORT void MakePredeclaredAtoms(void);
-
-extern _X_EXPORT int Ones(
- unsigned long /*mask*/);
-
-typedef struct _xPoint *DDXPointPtr;
-typedef struct pixman_box16 *BoxPtr;
-typedef struct _xEvent *xEventPtr;
-typedef struct _xRectangle *xRectanglePtr;
-typedef struct _GrabRec *GrabPtr;
-
-/* typedefs from other places - duplicated here to minimize the amount
- * of unnecessary junk that one would normally have to include to get
- * these symbols defined
- */
-
-#ifndef _XTYPEDEF_CHARINFOPTR
-typedef struct _CharInfo *CharInfoPtr; /* also in fonts/include/font.h */
-#define _XTYPEDEF_CHARINFOPTR
-#endif
-
-extern _X_EXPORT unsigned long globalSerialNumber;
-extern _X_EXPORT unsigned long serverGeneration;
-
-#endif /* MISC_H */
+/***********************************************************
+
+Copyright 1987, 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.
+
+
+Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
+
+ All Rights Reserved
+
+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 Digital not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+DIGITAL 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 1992, 1993 Data General Corporation;
+Copyright 1992, 1993 OMRON Corporation
+
+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
+neither the name OMRON or DATA GENERAL be used in advertising or publicity
+pertaining to distribution of the software without specific, written prior
+permission of the party whose name is to be used. Neither OMRON or
+DATA GENERAL make any representation about the suitability of this software
+for any purpose. It is provided "as is" without express or implied warranty.
+
+OMRON AND DATA GENERAL EACH DISCLAIM ALL WARRANTIES WITH REGARD TO THIS
+SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS,
+IN NO EVENT SHALL OMRON OR DATA GENERAL BE LIABLE FOR ANY SPECIAL, INDIRECT
+OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
+OF THIS SOFTWARE.
+
+******************************************************************/
+#ifndef MISC_H
+#define MISC_H 1
+/*
+ * X internal definitions
+ *
+ */
+
+#include <X11/Xosdefs.h>
+#include <X11/Xfuncproto.h>
+#include <X11/Xmd.h>
+#include <X11/X.h>
+#include <X11/Xdefs.h>
+
+#include <stddef.h>
+#include <stdint.h>
+
+#ifndef MAXSCREENS
+#define MAXSCREENS 16
+#endif
+#define MAXCLIENTS 256
+#define MAXEXTENSIONS 128
+#define MAXFORMATS 8
+#define MAXDEVICES 40 /* input devices */
+
+#define EXTENSION_EVENT_BASE 64
+#define EXTENSION_BASE 128
+
+typedef uint32_t ATOM;
+
+#ifndef TRUE
+#define TRUE 1
+#define FALSE 0
+#endif
+
+#ifndef _XTYPEDEF_CALLBACKLISTPTR
+typedef struct _CallbackList *CallbackListPtr; /* also in dix.h */
+#define _XTYPEDEF_CALLBACKLISTPTR
+#endif
+
+typedef struct _xReq *xReqPtr;
+
+#include "os.h" /* for ALLOCATE_LOCAL and DEALLOCATE_LOCAL */
+#include <X11/Xfuncs.h> /* for bcopy, bzero, and bcmp */
+
+#define NullBox ((BoxPtr)0)
+#define MILLI_PER_MIN (1000 * 60)
+#define MILLI_PER_SECOND (1000)
+
+ /* this next is used with None and ParentRelative to tell
+ PaintWin() what to use to paint the background. Also used
+ in the macro IS_VALID_PIXMAP */
+
+#define USE_BACKGROUND_PIXEL 3
+#define USE_BORDER_PIXEL 3
+
+
+/* byte swap a 32-bit literal */
+#define lswapl(x) ((((x) & 0xff) << 24) |\
+ (((x) & 0xff00) << 8) |\
+ (((x) & 0xff0000) >> 8) |\
+ (((x) >> 24) & 0xff))
+
+/* byte swap a short literal */
+#define lswaps(x) ((((x) & 0xff) << 8) | (((x) >> 8) & 0xff))
+
+#undef min
+#undef max
+
+#define min(a, b) (((a) < (b)) ? (a) : (b))
+#define max(a, b) (((a) > (b)) ? (a) : (b))
+/* abs() is a function, not a macro; include the file declaring
+ * it in case we haven't done that yet.
+ */
+#include <stdlib.h>
+#ifndef Fabs
+#define Fabs(a) ((a) > 0.0 ? (a) : -(a)) /* floating absolute value */
+#endif
+#define sign(x) ((x) < 0 ? -1 : ((x) > 0 ? 1 : 0))
+/* this assumes b > 0 */
+#define modulus(a, b, d) if (((d) = (a) % (b)) < 0) (d) += (b)
+/*
+ * return the least significant bit in x which is set
+ *
+ * This works on 1's complement and 2's complement machines.
+ * If you care about the extra instruction on 2's complement
+ * machines, change to ((x) & (-(x)))
+ */
+#define lowbit(x) ((x) & (~(x) + 1))
+
+/* XXX Not for modules */
+#include <limits.h>
+#if !defined(MAXSHORT) || !defined(MINSHORT) || \
+ !defined(MAXINT) || !defined(MININT)
+/*
+ * Some implementations #define these through <math.h>, so preclude
+ * #include'ing it later.
+ */
+
+#include <math.h>
+#undef MAXSHORT
+#define MAXSHORT SHRT_MAX
+#undef MINSHORT
+#define MINSHORT SHRT_MIN
+#undef MAXINT
+#define MAXINT INT_MAX
+#undef MININT
+#define MININT INT_MIN
+
+#include <assert.h>
+#include <ctype.h>
+#include <stdio.h> /* for fopen, etc... */
+
+#endif
+
+#ifndef PATH_MAX
+#include <sys/param.h>
+#ifndef PATH_MAX
+#ifdef MAXPATHLEN
+#define PATH_MAX MAXPATHLEN
+#else
+#define PATH_MAX 1024
+#endif
+#endif
+#endif
+
+/**
+ * Calculate the number of bytes needed to hold bits.
+ * @param bits The minimum number of bits needed.
+ * @return The number of bytes needed to hold bits.
+ */
+static inline int
+bits_to_bytes(const int bits) {
+ return ((bits + 7) >> 3);
+}
+/**
+ * Calculate the number of 4-byte units needed to hold the given number of
+ * bytes.
+ * @param bytes The minimum number of bytes needed.
+ * @return The number of 4-byte units needed to hold bytes.
+ */
+static inline int
+bytes_to_int32(const int bytes) {
+ return (((bytes) + 3) >> 2);
+}
+
+/**
+ * Calculate the number of bytes (in multiples of 4) needed to hold bytes.
+ * @param bytes The minimum number of bytes needed.
+ * @return The closest multiple of 4 that is equal or higher than bytes.
+ */
+static inline int
+pad_to_int32(const int bytes) {
+ return (((bytes) + 3) & ~3);
+}
+
+extern char**
+xstrtokenize(const char *str, const char* separators);
+
+/**
+ * Compare the two version numbers comprising of major.minor.
+ *
+ * @return A value less than 0 if a is less than b, 0 if a is equal to b,
+ * or a value greater than 0
+ */
+static inline int
+version_compare(uint16_t a_major, uint16_t a_minor,
+ uint16_t b_major, uint16_t b_minor)
+{
+ int a, b;
+
+ a = a_major << 16 | a_minor;
+ b = b_major << 16 | b_minor;
+
+ return (a - b);
+}
+
+/* some macros to help swap requests, replies, and events */
+
+#define LengthRestB(stuff) \
+ ((client->req_len << 2) - sizeof(*stuff))
+
+#define LengthRestS(stuff) \
+ ((client->req_len << 1) - (sizeof(*stuff) >> 1))
+
+#define LengthRestL(stuff) \
+ (client->req_len - (sizeof(*stuff) >> 2))
+
+#define SwapRestS(stuff) \
+ SwapShorts((short *)(stuff + 1), LengthRestS(stuff))
+
+#define SwapRestL(stuff) \
+ SwapLongs((CARD32 *)(stuff + 1), LengthRestL(stuff))
+
+/* byte swap a 32-bit value */
+#define swapl(x, n) { \
+ n = ((char *) (x))[0];\
+ ((char *) (x))[0] = ((char *) (x))[3];\
+ ((char *) (x))[3] = n;\
+ n = ((char *) (x))[1];\
+ ((char *) (x))[1] = ((char *) (x))[2];\
+ ((char *) (x))[2] = n; }
+
+/* byte swap a short */
+#define swaps(x, n) { \
+ n = ((char *) (x))[0];\
+ ((char *) (x))[0] = ((char *) (x))[1];\
+ ((char *) (x))[1] = n; }
+
+/* copy 32-bit value from src to dst byteswapping on the way */
+#define cpswapl(src, dst) { \
+ ((char *)&(dst))[0] = ((char *) &(src))[3];\
+ ((char *)&(dst))[1] = ((char *) &(src))[2];\
+ ((char *)&(dst))[2] = ((char *) &(src))[1];\
+ ((char *)&(dst))[3] = ((char *) &(src))[0]; }
+
+/* copy short from src to dst byteswapping on the way */
+#define cpswaps(src, dst) { \
+ ((char *) &(dst))[0] = ((char *) &(src))[1];\
+ ((char *) &(dst))[1] = ((char *) &(src))[0]; }
+
+extern _X_EXPORT void SwapLongs(
+ CARD32 *list,
+ unsigned long count);
+
+extern _X_EXPORT void SwapShorts(
+ short *list,
+ unsigned long count);
+
+extern _X_EXPORT void MakePredeclaredAtoms(void);
+
+extern _X_EXPORT int Ones(
+ unsigned long /*mask*/);
+
+typedef struct _xPoint *DDXPointPtr;
+typedef struct pixman_box16 *BoxPtr;
+typedef struct _xEvent *xEventPtr;
+typedef struct _xRectangle *xRectanglePtr;
+typedef struct _GrabRec *GrabPtr;
+
+/* typedefs from other places - duplicated here to minimize the amount
+ * of unnecessary junk that one would normally have to include to get
+ * these symbols defined
+ */
+
+#ifndef _XTYPEDEF_CHARINFOPTR
+typedef struct _CharInfo *CharInfoPtr; /* also in fonts/include/font.h */
+#define _XTYPEDEF_CHARINFOPTR
+#endif
+
+extern _X_EXPORT unsigned long globalSerialNumber;
+extern _X_EXPORT unsigned long serverGeneration;
+
+#endif /* MISC_H */
diff --git a/xorg-server/doc/man/Makefile.am b/xorg-server/man/Makefile.am
index 71d704917..71d704917 100644
--- a/xorg-server/doc/man/Makefile.am
+++ b/xorg-server/man/Makefile.am
diff --git a/xorg-server/doc/man/Xserver.man b/xorg-server/man/Xserver.man
index d3a16e2b7..d3a16e2b7 100644
--- a/xorg-server/doc/man/Xserver.man
+++ b/xorg-server/man/Xserver.man
diff --git a/xorg-server/manpages.am b/xorg-server/manpages.am
index 03089e38b..ea969cc5f 100644
--- a/xorg-server/manpages.am
+++ b/xorg-server/manpages.am
@@ -24,7 +24,7 @@ MAN_SUBSTS += -e 's|__logdir__|$(logdir)|g' \
-e 's|__sysconfdir__|$(sysconfdir)|g' \
-e 's|__xconfigdir__|$(__XCONFIGDIR__)|g' \
-e 's|__xkbdir__|$(XKB_BASE_DIRECTORY)|g' \
- -e 's|__laucnd_id_prefix__|$(BUNDLE_ID_PREFIX)|g' \
+ -e 's|__bundle_id_prefix__|$(BUNDLE_ID_PREFIX)|g' \
-e 's|__modulepath__|$(DEFAULT_MODULE_PATH)|g' \
-e 's|__default_font_path__|$(COMPILEDDEFAULTFONTPATH)|g' \
-e '\|$(COMPILEDDEFAULTFONTPATH)| s|/,|/, |g'
diff --git a/xorg-server/mi/mieq.c b/xorg-server/mi/mieq.c
index 08a0c8758..236ffcc3b 100644
--- a/xorg-server/mi/mieq.c
+++ b/xorg-server/mi/mieq.c
@@ -64,7 +64,7 @@ in this Software without prior written authorization from The Open Group.
#define DequeueScreen(dev) dev->spriteInfo->sprite->pDequeueScreen
typedef struct _Event {
- EventListPtr events;
+ InternalEvent* events;
ScreenPtr pScreen;
DeviceIntPtr pDev; /* device this event _originated_ from */
} EventRec, *EventPtr;
@@ -111,7 +111,7 @@ mieqInit(void)
for (i = 0; i < QUEUE_SIZE; i++)
{
if (miEventQueue.events[i].events == NULL) {
- EventListPtr evlist = InitEventList(1);
+ InternalEvent* evlist = InitEventList(1);
if (!evlist)
FatalError("Could not allocate event queue.\n");
miEventQueue.events[i].events = evlist;
@@ -146,7 +146,7 @@ void
mieqEnqueue(DeviceIntPtr pDev, InternalEvent *e)
{
unsigned int oldtail = miEventQueue.tail;
- EventListPtr evt;
+ InternalEvent* evt;
int isMotion = 0;
int evlen;
Time time;
@@ -156,7 +156,7 @@ mieqEnqueue(DeviceIntPtr pDev, InternalEvent *e)
pthread_mutex_lock(&miEventQueueMutex);
#endif
- CHECKEVENT(e);
+ verify_internal_event(e);
/* avoid merging events from different devices */
if (e->any.type == ET_Motion)
@@ -188,21 +188,7 @@ mieqEnqueue(DeviceIntPtr pDev, InternalEvent *e)
evlen = e->any.length;
evt = miEventQueue.events[oldtail].events;
- if (evt->evlen < evlen)
- {
- evt->evlen = evlen;
- evt->event = realloc(evt->event, evt->evlen);
- if (!evt->event)
- {
- ErrorF("[mi] Running out of memory. Tossing event.\n");
-#ifdef XQUARTZ
- pthread_mutex_unlock(&miEventQueueMutex);
-#endif
- return;
- }
- }
-
- memcpy(evt->event, e, evlen);
+ memcpy(evt, e, evlen);
time = e->any.time;
/* Make sure that event times don't go backwards - this
@@ -211,7 +197,7 @@ mieqEnqueue(DeviceIntPtr pDev, InternalEvent *e)
miEventQueue.lastEventTime - time < 10000)
e->any.time = miEventQueue.lastEventTime;
- miEventQueue.lastEventTime = ((InternalEvent*)evt->event)->any.time;
+ miEventQueue.lastEventTime = evt->any.time;
miEventQueue.events[oldtail].pScreen = pDev ? EnqueueScreen(pDev) : NULL;
miEventQueue.events[oldtail].pDev = pDev;
@@ -292,8 +278,8 @@ static void
FixUpEventForMaster(DeviceIntPtr mdev, DeviceIntPtr sdev,
InternalEvent* original, InternalEvent *master)
{
- CHECKEVENT(original);
- CHECKEVENT(master);
+ verify_internal_event(original);
+ verify_internal_event(master);
/* Ensure chained button mappings, i.e. that the detail field is the
* value of the mapped button on the SD, not the physical button */
if (original->any.type == ET_ButtonPress ||
@@ -323,7 +309,7 @@ CopyGetMasterEvent(DeviceIntPtr sdev,
int type = original->any.type;
int mtype; /* which master type? */
- CHECKEVENT(original);
+ verify_internal_event(original);
/* ET_XQuartz has sdev == NULL */
if (!sdev || IsMaster(sdev) || IsFloating(sdev))
@@ -376,7 +362,7 @@ mieqProcessDeviceEvent(DeviceIntPtr dev,
DeviceIntPtr master;
InternalEvent mevent; /* master event */
- CHECKEVENT(event);
+ verify_internal_event(event);
/* Custom event handler */
handler = miEventQueue.handlers[event->any.type];
@@ -431,10 +417,8 @@ void
mieqProcessInputEvents(void)
{
EventRec *e = NULL;
- int evlen;
ScreenPtr screen;
- static InternalEvent *event = NULL;
- static size_t event_size = 0;
+ static InternalEvent event;
DeviceIntPtr dev = NULL,
master = NULL;
@@ -445,20 +429,7 @@ mieqProcessInputEvents(void)
while (miEventQueue.head != miEventQueue.tail) {
e = &miEventQueue.events[miEventQueue.head];
- evlen = e->events->evlen;
- if(evlen > event_size)
- {
- event = realloc(event, evlen);
- event_size = evlen;
- }
-
-
- if (!event)
- FatalError("[mi] No memory left for event processing.\n");
-
- memcpy(event, e->events->event, evlen);
-
-
+ event = *e->events;
dev = e->pDev;
screen = e->pScreen;
@@ -480,10 +451,10 @@ mieqProcessInputEvents(void)
DPMSSet(serverClient, DPMSModeOn);
#endif
- mieqProcessDeviceEvent(dev, event, screen);
+ mieqProcessDeviceEvent(dev, &event, screen);
/* Update the sprite now. Next event may be from different device. */
- if (event->any.type == ET_Motion && master)
+ if (event.any.type == ET_Motion && master)
miPointerUpdateSprite(dev);
#ifdef XQUARTZ
diff --git a/xorg-server/mi/mipointer.c b/xorg-server/mi/mipointer.c
index db243810c..322be9e44 100644
--- a/xorg-server/mi/mipointer.c
+++ b/xorg-server/mi/mipointer.c
@@ -63,6 +63,7 @@ in this Software without prior written authorization from The Open Group.
# include "dixstruct.h"
# include "inputstr.h"
# include "inpututils.h"
+# include "eventstr.h"
DevPrivateKeyRec miPointerScreenKeyRec;
@@ -99,7 +100,7 @@ static void miPointerDeviceCleanup(DeviceIntPtr pDev,
ScreenPtr pScreen);
static void miPointerMoveNoEvent (DeviceIntPtr pDev, ScreenPtr pScreen, int x, int y);
-static EventList* events; /* for WarpPointer MotionNotifies */
+static InternalEvent* events; /* for WarpPointer MotionNotifies */
Bool
miPointerInitialize (ScreenPtr pScreen,
@@ -689,7 +690,7 @@ miPointerMove (DeviceIntPtr pDev, ScreenPtr pScreen, int x, int y)
darwinEvents_lock();
#endif
for (i = 0; i < nevents; i++)
- mieqEnqueue(pDev, (InternalEvent*)events[i].event);
+ mieqEnqueue(pDev, &events[i]);
#ifdef XQUARTZ
darwinEvents_unlock();
#endif
diff --git a/xorg-server/os/log.c b/xorg-server/os/log.c
index 9579e58d8..4a310e64d 100644
--- a/xorg-server/os/log.c
+++ b/xorg-server/os/log.c
@@ -528,7 +528,12 @@ FatalError(const char *f, ...)
va_start(args, f);
#ifdef __APPLE__
- (void)vsnprintf(__crashreporter_info_buff__, sizeof(__crashreporter_info_buff__), f, args);
+ {
+ va_list args2;
+ va_copy(args2, args);
+ (void)vsnprintf(__crashreporter_info_buff__, sizeof(__crashreporter_info_buff__), f, args2);
+ va_end(args2);
+ }
#endif
VErrorF(f, args);
va_end(args);
diff --git a/xorg-server/randr/rrdispatch.c b/xorg-server/randr/rrdispatch.c
index 213550475..d1c99c288 100644
--- a/xorg-server/randr/rrdispatch.c
+++ b/xorg-server/randr/rrdispatch.c
@@ -28,8 +28,8 @@ RRClientKnowsRates (ClientPtr pClient)
{
rrClientPriv(pClient);
- return (pRRClient->major_version > 1 ||
- (pRRClient->major_version == 1 && pRRClient->minor_version >= 1));
+ return version_compare(pRRClient->major_version, pRRClient->minor_version,
+ 1, 1) >= 0;
}
static int
@@ -47,8 +47,8 @@ ProcRRQueryVersion (ClientPtr client)
rep.length = 0;
rep.sequenceNumber = client->sequence;
- if ((stuff->majorVersion * 1000 + stuff->minorVersion) <
- (SERVER_RANDR_MAJOR_VERSION * 1000 + SERVER_RANDR_MINOR_VERSION))
+ if (version_compare(stuff->majorVersion, stuff->minorVersion,
+ SERVER_RANDR_MAJOR_VERSION, SERVER_RANDR_MINOR_VERSION) < 0)
{
rep.majorVersion = stuff->majorVersion;
rep.minorVersion = stuff->minorVersion;
diff --git a/xorg-server/record/record.c b/xorg-server/record/record.c
index cafe02168..69fca727e 100644
--- a/xorg-server/record/record.c
+++ b/xorg-server/record/record.c
@@ -1,2936 +1,2936 @@
-
-/*
-
-Copyright 1995, 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.
-
-Author: David P. Wiggins, The Open Group
-
-This work benefited from earlier work done by Martha Zimet of NCD
-and Jim Haggerty of Metheus.
-
-*/
-
-#ifdef HAVE_DIX_CONFIG_H
-#include <dix-config.h>
-#endif
-
-#include "dixstruct.h"
-#include "extnsionst.h"
-#include <X11/extensions/recordproto.h>
-#include "set.h"
-#include "swaprep.h"
-#include "inputstr.h"
-#include "eventconvert.h"
-#include "scrnintstr.h"
-
-
-#include <stdio.h>
-#include <assert.h>
-
-#ifdef PANORAMIX
-#include "globals.h"
-#include "panoramiX.h"
-#include "panoramiXsrv.h"
-#include "cursor.h"
-#endif
-
-#include "protocol-versions.h"
-
-static RESTYPE RTContext; /* internal resource type for Record contexts */
-
-/* How many bytes of protocol data to buffer in a context. Don't set to less
- * than 32.
- */
-#define REPLY_BUF_SIZE 1024
-
-/* Record Context structure */
-
-typedef struct {
- XID id; /* resource id of context */
- ClientPtr pRecordingClient; /* client that has context enabled */
- struct _RecordClientsAndProtocolRec *pListOfRCAP; /* all registered info */
- ClientPtr pBufClient; /* client whose protocol is in replyBuffer*/
- unsigned int continuedReply:1; /* recording a reply that is split up? */
- char elemHeaders; /* element header flags (time/seq no.) */
- char bufCategory; /* category of protocol in replyBuffer */
- int numBufBytes; /* number of bytes in replyBuffer */
- char replyBuffer[REPLY_BUF_SIZE]; /* buffered recorded protocol */
- int inFlush; /* are we inside RecordFlushReplyBuffer */
-} RecordContextRec, *RecordContextPtr;
-
-/* RecordMinorOpRec - to hold minor opcode selections for extension requests
- * and replies
- */
-
-typedef union {
- int count; /* first element of array: how many "major" structs to follow */
- struct { /* rest of array elements are this */
- short first; /* first major opcode */
- short last; /* last major opcode */
- RecordSetPtr pMinOpSet; /* minor opcode set for above major range */
- } major;
-} RecordMinorOpRec, *RecordMinorOpPtr;
-
-
-/* RecordClientsAndProtocolRec, nicknamed RCAP - holds all the client and
- * protocol selections passed in a single CreateContext or RegisterClients.
- * Generally, a context will have one of these from the create and an
- * additional one for each RegisterClients. RCAPs are freed when all their
- * clients are unregistered.
- */
-
-typedef struct _RecordClientsAndProtocolRec {
- RecordContextPtr pContext; /* context that owns this RCAP */
- struct _RecordClientsAndProtocolRec *pNextRCAP; /* next RCAP on context */
- RecordSetPtr pRequestMajorOpSet; /* requests to record */
- RecordMinorOpPtr pRequestMinOpInfo; /* extension requests to record */
- RecordSetPtr pReplyMajorOpSet; /* replies to record */
- RecordMinorOpPtr pReplyMinOpInfo; /* extension replies to record */
- RecordSetPtr pDeviceEventSet; /* device events to record */
- RecordSetPtr pDeliveredEventSet; /* delivered events to record */
- RecordSetPtr pErrorSet; /* errors to record */
- XID * pClientIDs; /* array of clients to record */
- short numClients; /* number of clients in pClientIDs */
- short sizeClients; /* size of pClientIDs array */
- unsigned int clientStarted:1; /* record new client connections? */
- unsigned int clientDied:1; /* record client disconnections? */
- unsigned int clientIDsSeparatelyAllocated:1; /* pClientIDs malloced? */
-} RecordClientsAndProtocolRec, *RecordClientsAndProtocolPtr;
-
-/* how much bigger to make pRCAP->pClientIDs when reallocing */
-#define CLIENT_ARRAY_GROWTH_INCREMENT 4
-
-/* counts the total number of RCAPs belonging to enabled contexts. */
-static int numEnabledRCAPs;
-
-/* void VERIFY_CONTEXT(RecordContextPtr, XID, ClientPtr)
- * In the spirit of the VERIFY_* macros in dix.h, this macro fills in
- * the context pointer if the given ID is a valid Record Context, else it
- * returns an error.
- */
-#define VERIFY_CONTEXT(_pContext, _contextid, _client) { \
- int rc = dixLookupResourceByType((pointer *)&(_pContext), _contextid, \
- RTContext, _client, DixUseAccess); \
- if (rc != Success) \
- return rc; \
-}
-
-static int RecordDeleteContext(
- pointer /*value*/,
- XID /*id*/
-);
-
-void RecordExtensionInit(void);
-
-/***************************************************************************/
-
-/* client private stuff */
-
-/* To make declarations less obfuscated, have a typedef for a pointer to a
- * Proc function.
- */
-typedef int (*ProcFunctionPtr)(
- ClientPtr /*pClient*/
-);
-
-/* Record client private. Generally a client only has one of these if
- * any of its requests are being recorded.
- */
-typedef struct {
-/* ptr to client's proc vector before Record stuck its nose in */
- ProcFunctionPtr *originalVector;
-
-/* proc vector with pointers for recorded requests redirected to the
- * function RecordARequest
- */
- ProcFunctionPtr recordVector[256];
-} RecordClientPrivateRec, *RecordClientPrivatePtr;
-
-static DevPrivateKeyRec RecordClientPrivateKeyRec;
-#define RecordClientPrivateKey (&RecordClientPrivateKeyRec)
-
-/* RecordClientPrivatePtr RecordClientPrivate(ClientPtr)
- * gets the client private of the given client. Syntactic sugar.
- */
-#define RecordClientPrivate(_pClient) (RecordClientPrivatePtr) \
- dixLookupPrivate(&(_pClient)->devPrivates, RecordClientPrivateKey)
-
-
-/***************************************************************************/
-
-/* global list of all contexts */
-
-static RecordContextPtr *ppAllContexts;
-
-static int numContexts;/* number of contexts in ppAllContexts */
-
-/* number of currently enabled contexts. All enabled contexts are bunched
- * up at the front of the ppAllContexts array, from ppAllContexts[0] to
- * ppAllContexts[numEnabledContexts-1], to eliminate time spent skipping
- * past disabled contexts.
- */
-static int numEnabledContexts;
-
-/* RecordFindContextOnAllContexts
- *
- * Arguments:
- * pContext is the context to search for.
- *
- * Returns:
- * The index into the array ppAllContexts at which pContext is stored.
- * If pContext is not found in ppAllContexts, returns -1.
- *
- * Side Effects: none.
- */
-static int
-RecordFindContextOnAllContexts(RecordContextPtr pContext)
-{
- int i;
-
- assert(numContexts >= numEnabledContexts);
- for (i = 0; i < numContexts; i++)
- {
- if (ppAllContexts[i] == pContext)
- return i;
- }
- return -1;
-} /* RecordFindContextOnAllContexts */
-
-
-/***************************************************************************/
-
-/* RecordFlushReplyBuffer
- *
- * Arguments:
- * pContext is the context to flush.
- * data1 is a pointer to additional data, and len1 is its length in bytes.
- * data2 is a pointer to additional data, and len2 is its length in bytes.
- *
- * Returns: nothing.
- *
- * Side Effects:
- * If the context is enabled, any buffered (recorded) protocol is written
- * to the recording client, and the number of buffered bytes is set to
- * zero. If len1 is not zero, data1/len1 are then written to the
- * recording client, and similarly for data2/len2 (written after
- * data1/len1).
- */
-static void
-RecordFlushReplyBuffer(
- RecordContextPtr pContext,
- pointer data1,
- int len1,
- pointer data2,
- int len2
-)
-{
- if (!pContext->pRecordingClient || pContext->pRecordingClient->clientGone || pContext->inFlush)
- return;
- ++pContext->inFlush;
- if (pContext->numBufBytes)
- WriteToClient(pContext->pRecordingClient, pContext->numBufBytes,
- (char *)pContext->replyBuffer);
- pContext->numBufBytes = 0;
- if (len1)
- WriteToClient(pContext->pRecordingClient, len1, (char *)data1);
- if (len2)
- WriteToClient(pContext->pRecordingClient, len2, (char *)data2);
- --pContext->inFlush;
-} /* RecordFlushReplyBuffer */
-
-
-/* RecordAProtocolElement
- *
- * Arguments:
- * pContext is the context that is recording a protocol element.
- * pClient is the client whose protocol is being recorded. For
- * device events and EndOfData, pClient is NULL.
- * category is the category of the protocol element, as defined
- * by the RECORD spec.
- * data is a pointer to the protocol data, and datalen is its length
- * in bytes.
- * futurelen is the number of bytes that will be sent in subsequent
- * calls to this function to complete this protocol element.
- * In those subsequent calls, futurelen will be -1 to indicate
- * that the current data is a continuation of the same protocol
- * element.
- *
- * Returns: nothing.
- *
- * Side Effects:
- * The context may be flushed. The new protocol element will be
- * added to the context's protocol buffer with appropriate element
- * headers prepended (sequence number and timestamp). If the data
- * is continuation data (futurelen == -1), element headers won't
- * be added. If the protocol element and headers won't fit in
- * the context's buffer, it is sent directly to the recording
- * client (after any buffered data).
- */
-static void
-RecordAProtocolElement(RecordContextPtr pContext, ClientPtr pClient,
- int category, pointer data, int datalen, int futurelen)
-{
- CARD32 elemHeaderData[2];
- int numElemHeaders = 0;
- Bool recordingClientSwapped = pContext->pRecordingClient->swapped;
- int n;
- CARD32 serverTime = 0;
- Bool gotServerTime = FALSE;
- int replylen;
-
- if (futurelen >= 0)
- { /* start of new protocol element */
- xRecordEnableContextReply *pRep = (xRecordEnableContextReply *)
- pContext->replyBuffer;
- if (pContext->pBufClient != pClient ||
- pContext->bufCategory != category)
- {
- RecordFlushReplyBuffer(pContext, NULL, 0, NULL, 0);
- pContext->pBufClient = pClient;
- pContext->bufCategory = category;
- }
-
- if (!pContext->numBufBytes)
- {
- serverTime = GetTimeInMillis();
- gotServerTime = TRUE;
- pRep->type = X_Reply;
- pRep->category = category;
- pRep->sequenceNumber = pContext->pRecordingClient->sequence;
- pRep->length = 0;
- pRep->elementHeader = pContext->elemHeaders;
- pRep->serverTime = serverTime;
- if (pClient)
- {
- pRep->clientSwapped =
- (pClient->swapped != recordingClientSwapped);
- pRep->idBase = pClient->clientAsMask;
- pRep->recordedSequenceNumber = pClient->sequence;
- }
- else /* it's a device event, StartOfData, or EndOfData */
- {
- pRep->clientSwapped = (category != XRecordFromServer) &&
- recordingClientSwapped;
- pRep->idBase = 0;
- pRep->recordedSequenceNumber = 0;
- }
-
- if (recordingClientSwapped)
- {
- swaps(&pRep->sequenceNumber, n);
- swapl(&pRep->length, n);
- swapl(&pRep->idBase, n);
- swapl(&pRep->serverTime, n);
- swapl(&pRep->recordedSequenceNumber, n);
- }
- pContext->numBufBytes = SIZEOF(xRecordEnableContextReply);
- }
-
- /* generate element headers if needed */
-
- if ( ( (pContext->elemHeaders & XRecordFromClientTime)
- && category == XRecordFromClient)
- ||
- ( (pContext->elemHeaders & XRecordFromServerTime)
- && category == XRecordFromServer))
- {
- if (gotServerTime)
- elemHeaderData[numElemHeaders] = serverTime;
- else
- elemHeaderData[numElemHeaders] = GetTimeInMillis();
- if (recordingClientSwapped)
- swapl(&elemHeaderData[numElemHeaders], n);
- numElemHeaders++;
- }
-
- if ( (pContext->elemHeaders & XRecordFromClientSequence)
- &&
- (category == XRecordFromClient || category == XRecordClientDied))
- {
- elemHeaderData[numElemHeaders] = pClient->sequence;
- if (recordingClientSwapped)
- swapl(&elemHeaderData[numElemHeaders], n);
- numElemHeaders++;
- }
-
- /* adjust reply length */
-
- replylen = pRep->length;
- if (recordingClientSwapped) swapl(&replylen, n);
- replylen += numElemHeaders + bytes_to_int32(datalen) +
- bytes_to_int32(futurelen);
- if (recordingClientSwapped) swapl(&replylen, n);
- pRep->length = replylen;
- } /* end if not continued reply */
-
- numElemHeaders *= 4;
-
- /* if space available >= space needed, buffer the data */
-
- if (REPLY_BUF_SIZE - pContext->numBufBytes >= datalen + numElemHeaders)
- {
- if (numElemHeaders)
- {
- memcpy(pContext->replyBuffer + pContext->numBufBytes,
- elemHeaderData, numElemHeaders);
- pContext->numBufBytes += numElemHeaders;
- }
- if (datalen)
- {
- memcpy(pContext->replyBuffer + pContext->numBufBytes,
- data, datalen);
- pContext->numBufBytes += datalen;
- }
- }
- else
- RecordFlushReplyBuffer(pContext, (pointer)elemHeaderData,
- numElemHeaders, (pointer)data, datalen);
-
-} /* RecordAProtocolElement */
-
-
-/* RecordFindClientOnContext
- *
- * Arguments:
- * pContext is the context to search.
- * clientspec is the resource ID mask identifying the client to search
- * for, or XRecordFutureClients.
- * pposition is a pointer to an int, or NULL. See Returns.
- *
- * Returns:
- * The RCAP on which clientspec was found, or NULL if not found on
- * any RCAP on the given context.
- * If pposition was not NULL and the returned RCAP is not NULL,
- * *pposition will be set to the index into the returned the RCAP's
- * pClientIDs array that holds clientspec.
- *
- * Side Effects: none.
- */
-static RecordClientsAndProtocolPtr
-RecordFindClientOnContext(
- RecordContextPtr pContext,
- XID clientspec,
- int *pposition
-)
-{
- RecordClientsAndProtocolPtr pRCAP;
-
- for (pRCAP = pContext->pListOfRCAP; pRCAP; pRCAP = pRCAP->pNextRCAP)
- {
- int i;
- for (i = 0; i < pRCAP->numClients; i++)
- {
- if (pRCAP->pClientIDs[i] == clientspec)
- {
- if (pposition)
- *pposition = i;
- return pRCAP;
- }
- }
- }
- return NULL;
-} /* RecordFindClientOnContext */
-
-
-/* RecordABigRequest
- *
- * Arguments:
- * pContext is the recording context.
- * client is the client being recorded.
- * stuff is a pointer to the big request of client (see the Big Requests
- * extension for details.)
- *
- * Returns: nothing.
- *
- * Side Effects:
- * The big request is recorded with the correct length field re-inserted.
- *
- * Note: this function exists mainly to make RecordARequest smaller.
- */
-static void
-RecordABigRequest(RecordContextPtr pContext, ClientPtr client, xReq *stuff)
-{
- CARD32 bigLength;
- char n;
- int bytesLeft;
-
- /* note: client->req_len has been frobbed by ReadRequestFromClient
- * (os/io.c) to discount the extra 4 bytes taken by the extended length
- * field in a big request. The actual request length to record is
- * client->req_len + 1 (measured in CARD32s).
- */
-
- /* record the request header */
- bytesLeft = client->req_len << 2;
- RecordAProtocolElement(pContext, client, XRecordFromClient,
- (pointer)stuff, SIZEOF(xReq), bytesLeft);
-
- /* reinsert the extended length field that was squished out */
- bigLength = client->req_len + bytes_to_int32(sizeof(bigLength));
- if (client->swapped)
- swapl(&bigLength, n);
- RecordAProtocolElement(pContext, client, XRecordFromClient,
- (pointer)&bigLength, sizeof(bigLength), /* continuation */ -1);
- bytesLeft -= sizeof(bigLength);
-
- /* record the rest of the request after the length */
- RecordAProtocolElement(pContext, client, XRecordFromClient,
- (pointer)(stuff + 1), bytesLeft, /* continuation */ -1);
-} /* RecordABigRequest */
-
-
-/* RecordARequest
- *
- * Arguments:
- * client is a client that the server has dispatched a request to by
- * calling client->requestVector[request opcode] .
- * The request is in client->requestBuffer.
- *
- * Returns:
- * Whatever is returned by the "real" Proc function for this request.
- * The "real" Proc function is the function that was in
- * client->requestVector[request opcode] before it was replaced by
- * RecordARequest. (See the function RecordInstallHooks.)
- *
- * Side Effects:
- * The request is recorded by all contexts that have registered this
- * request for this client. The real Proc function is called.
- */
-static int
-RecordARequest(ClientPtr client)
-{
- RecordContextPtr pContext;
- RecordClientsAndProtocolPtr pRCAP;
- int i;
- RecordClientPrivatePtr pClientPriv;
- REQUEST(xReq);
- int majorop;
-
- majorop = stuff->reqType;
- for (i = 0; i < numEnabledContexts; i++)
- {
- pContext = ppAllContexts[i];
- pRCAP = RecordFindClientOnContext(pContext, client->clientAsMask,
- NULL);
- if (pRCAP && pRCAP->pRequestMajorOpSet &&
- RecordIsMemberOfSet(pRCAP->pRequestMajorOpSet, majorop))
- {
- if (majorop <= 127)
- { /* core request */
-
- if (stuff->length == 0)
- RecordABigRequest(pContext, client, stuff);
- else
- RecordAProtocolElement(pContext, client, XRecordFromClient,
- (pointer)stuff, client->req_len << 2, 0);
- }
- else /* extension, check minor opcode */
- {
- int minorop = MinorOpcodeOfRequest(client);
- int numMinOpInfo;
- RecordMinorOpPtr pMinorOpInfo = pRCAP->pRequestMinOpInfo;
-
- assert (pMinorOpInfo);
- numMinOpInfo = pMinorOpInfo->count;
- pMinorOpInfo++;
- assert (numMinOpInfo);
- for ( ; numMinOpInfo; numMinOpInfo--, pMinorOpInfo++)
- {
- if (majorop >= pMinorOpInfo->major.first &&
- majorop <= pMinorOpInfo->major.last &&
- RecordIsMemberOfSet(pMinorOpInfo->major.pMinOpSet,
- minorop))
- {
- if (stuff->length == 0)
- RecordABigRequest(pContext, client, stuff);
- else
- RecordAProtocolElement(pContext, client,
- XRecordFromClient, (pointer)stuff,
- client->req_len << 2, 0);
- break;
- }
- } /* end for each minor op info */
- } /* end extension request */
- } /* end this RCAP wants this major opcode */
- } /* end for each context */
- pClientPriv = RecordClientPrivate(client);
- assert(pClientPriv);
- return (* pClientPriv->originalVector[majorop])(client);
-} /* RecordARequest */
-
-/* RecordAReply
- *
- * Arguments:
- * pcbl is &ReplyCallback.
- * nulldata is NULL.
- * calldata is a pointer to a ReplyInfoRec (include/os.h)
- * which provides information about replies that are being sent
- * to clients.
- *
- * Returns: nothing.
- *
- * Side Effects:
- * The reply is recorded by all contexts that have registered this
- * reply type for this client. If more data belonging to the same
- * reply is expected, and if the reply is being recorded by any
- * context, pContext->continuedReply is set to 1.
- * If pContext->continuedReply was already 1 and this is the last
- * chunk of data belonging to this reply, it is set to 0.
- */
-static void
-RecordAReply(CallbackListPtr *pcbl, pointer nulldata, pointer calldata)
-{
- RecordContextPtr pContext;
- RecordClientsAndProtocolPtr pRCAP;
- int eci;
- int majorop;
- ReplyInfoRec *pri = (ReplyInfoRec *)calldata;
- ClientPtr client = pri->client;
- REQUEST(xReq);
-
- majorop = stuff->reqType;
- for (eci = 0; eci < numEnabledContexts; eci++)
- {
- pContext = ppAllContexts[eci];
- pRCAP = RecordFindClientOnContext(pContext, client->clientAsMask,
- NULL);
- if (pRCAP)
- {
- if (pContext->continuedReply)
- {
- RecordAProtocolElement(pContext, client, XRecordFromServer,
- (pointer)pri->replyData, pri->dataLenBytes, /* continuation */ -1);
- if (!pri->bytesRemaining)
- pContext->continuedReply = 0;
- }
- else if (pri->startOfReply && pRCAP->pReplyMajorOpSet &&
- RecordIsMemberOfSet(pRCAP->pReplyMajorOpSet, majorop))
- {
- if (majorop <= 127)
- { /* core reply */
- RecordAProtocolElement(pContext, client, XRecordFromServer,
- (pointer)pri->replyData, pri->dataLenBytes, pri->bytesRemaining);
- if (pri->bytesRemaining)
- pContext->continuedReply = 1;
- }
- else /* extension, check minor opcode */
- {
- int minorop = MinorOpcodeOfRequest(client);
- int numMinOpInfo;
- RecordMinorOpPtr pMinorOpInfo = pRCAP->pReplyMinOpInfo;
- assert (pMinorOpInfo);
- numMinOpInfo = pMinorOpInfo->count;
- pMinorOpInfo++;
- assert (numMinOpInfo);
- for ( ; numMinOpInfo; numMinOpInfo--, pMinorOpInfo++)
- {
- if (majorop >= pMinorOpInfo->major.first &&
- majorop <= pMinorOpInfo->major.last &&
- RecordIsMemberOfSet(pMinorOpInfo->major.pMinOpSet,
- minorop))
- {
- RecordAProtocolElement(pContext, client,
- XRecordFromServer, (pointer)pri->replyData,
- pri->dataLenBytes, pri->bytesRemaining);
- if (pri->bytesRemaining)
- pContext->continuedReply = 1;
- break;
- }
- } /* end for each minor op info */
- } /* end extension reply */
- } /* end continued reply vs. start of reply */
- } /* end client is registered on this context */
- } /* end for each context */
-} /* RecordAReply */
-
-
-/* RecordADeliveredEventOrError
- *
- * Arguments:
- * pcbl is &EventCallback.
- * nulldata is NULL.
- * calldata is a pointer to a EventInfoRec (include/dix.h)
- * which provides information about events that are being sent
- * to clients.
- *
- * Returns: nothing.
- *
- * Side Effects:
- * The event or error is recorded by all contexts that have registered
- * it for this client.
- */
-static void
-RecordADeliveredEventOrError(CallbackListPtr *pcbl, pointer nulldata, pointer calldata)
-{
- EventInfoRec *pei = (EventInfoRec *)calldata;
- RecordContextPtr pContext;
- RecordClientsAndProtocolPtr pRCAP;
- int eci; /* enabled context index */
- ClientPtr pClient = pei->client;
-
- for (eci = 0; eci < numEnabledContexts; eci++)
- {
- pContext = ppAllContexts[eci];
- pRCAP = RecordFindClientOnContext(pContext, pClient->clientAsMask,
- NULL);
- if (pRCAP && (pRCAP->pDeliveredEventSet || pRCAP->pErrorSet))
- {
- int ev; /* event index */
- xEvent *pev = pei->events;
- for (ev = 0; ev < pei->count; ev++, pev++)
- {
- int recordit = 0;
- if (pRCAP->pErrorSet)
- {
- recordit = RecordIsMemberOfSet(pRCAP->pErrorSet,
- ((xError *)(pev))->errorCode);
- }
- else if (pRCAP->pDeliveredEventSet)
- {
- recordit = RecordIsMemberOfSet(pRCAP->pDeliveredEventSet,
- pev->u.u.type & 0177);
- }
- if (recordit)
- {
- xEvent swappedEvent;
- xEvent *pEvToRecord = pev;
-
- if (pClient->swapped)
- {
- (*EventSwapVector[pev->u.u.type & 0177])
- (pev, &swappedEvent);
- pEvToRecord = &swappedEvent;
-
- }
- RecordAProtocolElement(pContext, pClient,
- XRecordFromServer, pEvToRecord, SIZEOF(xEvent), 0);
- }
- } /* end for each event */
- } /* end this client is on this context */
- } /* end for each enabled context */
-} /* RecordADeliveredEventOrError */
-
-
-static void
-RecordSendProtocolEvents(RecordClientsAndProtocolPtr pRCAP,
- RecordContextPtr pContext,
- xEvent* pev, int count)
-{
- int ev; /* event index */
-
- for (ev = 0; ev < count; ev++, pev++)
- {
- if (RecordIsMemberOfSet(pRCAP->pDeviceEventSet,
- pev->u.u.type & 0177))
- {
- xEvent swappedEvent;
- xEvent *pEvToRecord = pev;
-#ifdef PANORAMIX
- xEvent shiftedEvent;
-
- if (!noPanoramiXExtension &&
- (pev->u.u.type == MotionNotify ||
- pev->u.u.type == ButtonPress ||
- pev->u.u.type == ButtonRelease ||
- pev->u.u.type == KeyPress ||
- pev->u.u.type == KeyRelease)) {
- int scr = XineramaGetCursorScreen(inputInfo.pointer);
- memcpy(&shiftedEvent, pev, sizeof(xEvent));
- shiftedEvent.u.keyButtonPointer.rootX +=
- screenInfo.screens[scr]->x -
- screenInfo.screens[0]->x;
- shiftedEvent.u.keyButtonPointer.rootY +=
- screenInfo.screens[scr]->y -
- screenInfo.screens[0]->y;
- pEvToRecord = &shiftedEvent;
- }
-#endif /* PANORAMIX */
-
- if (pContext->pRecordingClient->swapped)
- {
- (*EventSwapVector[pEvToRecord->u.u.type & 0177])
- (pEvToRecord, &swappedEvent);
- pEvToRecord = &swappedEvent;
- }
-
- RecordAProtocolElement(pContext, NULL,
- XRecordFromServer, pEvToRecord, SIZEOF(xEvent), 0);
- /* make sure device events get flushed in the absence
- * of other client activity
- */
- SetCriticalOutputPending();
- }
- } /* end for each event */
-
-} /* RecordADeviceEvent */
-
-/* RecordADeviceEvent
- *
- * Arguments:
- * pcbl is &DeviceEventCallback.
- * nulldata is NULL.
- * calldata is a pointer to a DeviceEventInfoRec (include/dix.h)
- * which provides information about device events that occur.
- *
- * Returns: nothing.
- *
- * Side Effects:
- * The device event is recorded by all contexts that have registered
- * it for this client.
- */
-static void
-RecordADeviceEvent(CallbackListPtr *pcbl, pointer nulldata, pointer calldata)
-{
- DeviceEventInfoRec *pei = (DeviceEventInfoRec *)calldata;
- RecordContextPtr pContext;
- RecordClientsAndProtocolPtr pRCAP;
- int eci; /* enabled context index */
-
- for (eci = 0; eci < numEnabledContexts; eci++)
- {
- pContext = ppAllContexts[eci];
- for (pRCAP = pContext->pListOfRCAP; pRCAP; pRCAP = pRCAP->pNextRCAP)
- {
- if (pRCAP->pDeviceEventSet)
- {
- int count;
- xEvent *xi_events = NULL;
-
- /* TODO check return values */
- if (IsMaster(pei->device))
- {
- xEvent *core_events;
- EventToCore(pei->event, &core_events, &count);
- RecordSendProtocolEvents(pRCAP, pContext, core_events,
- count);
- free(core_events);
- }
-
- EventToXI(pei->event, &xi_events, &count);
- RecordSendProtocolEvents(pRCAP, pContext, xi_events, count);
- free(xi_events);
- } /* end this RCAP selects device events */
- } /* end for each RCAP on this context */
- } /* end for each enabled context */
-}
-
-
-/* RecordFlushAllContexts
- *
- * Arguments:
- * pcbl is &FlushCallback.
- * nulldata and calldata are NULL.
- *
- * Returns: nothing.
- *
- * Side Effects:
- * All buffered reply data of all enabled contexts is written to
- * the recording clients.
- */
-static void
-RecordFlushAllContexts(
- CallbackListPtr *pcbl,
- pointer nulldata,
- pointer calldata
-)
-{
- int eci; /* enabled context index */
- RecordContextPtr pContext;
-
- for (eci = 0; eci < numEnabledContexts; eci++)
- {
- pContext = ppAllContexts[eci];
-
- /* In most cases we leave it to RecordFlushReplyBuffer to make
- * this check, but this function could be called very often, so we
- * check before calling hoping to save the function call cost
- * most of the time.
- */
- if (pContext->numBufBytes)
- RecordFlushReplyBuffer(ppAllContexts[eci], NULL, 0, NULL, 0);
- }
-} /* RecordFlushAllContexts */
-
-
-/* RecordInstallHooks
- *
- * Arguments:
- * pRCAP is an RCAP on an enabled or being-enabled context.
- * oneclient can be zero or the resource ID mask identifying a client.
- *
- * Returns: BadAlloc if a memory allocation error occurred, else Success.
- *
- * Side Effects:
- * Recording hooks needed by RCAP are installed.
- * If oneclient is zero, recording hooks needed for all clients and
- * protocol on the RCAP are installed. If oneclient is non-zero,
- * only those hooks needed for the specified client are installed.
- *
- * Client requestVectors may be altered. numEnabledRCAPs will be
- * incremented if oneclient == 0. Callbacks may be added to
- * various callback lists.
- */
-static int
-RecordInstallHooks(RecordClientsAndProtocolPtr pRCAP, XID oneclient)
-{
- int i = 0;
- XID client;
-
- if (oneclient)
- client = oneclient;
- else
- client = pRCAP->numClients ? pRCAP->pClientIDs[i++] : 0;
-
- while (client)
- {
- if (client != XRecordFutureClients)
- {
- if (pRCAP->pRequestMajorOpSet)
- {
- RecordSetIteratePtr pIter = NULL;
- RecordSetInterval interval;
- ClientPtr pClient = clients[CLIENT_ID(client)];
-
- if (pClient && !RecordClientPrivate(pClient))
- {
- RecordClientPrivatePtr pClientPriv;
- /* no Record proc vector; allocate one */
- pClientPriv = (RecordClientPrivatePtr)
- malloc(sizeof(RecordClientPrivateRec));
- if (!pClientPriv)
- return BadAlloc;
- /* copy old proc vector to new */
- memcpy(pClientPriv->recordVector, pClient->requestVector,
- sizeof (pClientPriv->recordVector));
- pClientPriv->originalVector = pClient->requestVector;
- dixSetPrivate(&pClient->devPrivates,
- RecordClientPrivateKey, pClientPriv);
- pClient->requestVector = pClientPriv->recordVector;
- }
- while ((pIter = RecordIterateSet(pRCAP->pRequestMajorOpSet,
- pIter, &interval)))
- {
- unsigned int j;
- for (j = interval.first; j <= interval.last; j++)
- pClient->requestVector[j] = RecordARequest;
- }
- }
- }
- if (oneclient)
- client = 0;
- else
- client = (i < pRCAP->numClients) ? pRCAP->pClientIDs[i++] : 0;
- }
-
- assert(numEnabledRCAPs >= 0);
- if (!oneclient && ++numEnabledRCAPs == 1)
- { /* we're enabling the first context */
- if (!AddCallback(&EventCallback, RecordADeliveredEventOrError, NULL))
- return BadAlloc;
- if (!AddCallback(&DeviceEventCallback, RecordADeviceEvent, NULL))
- return BadAlloc;
- if (!AddCallback(&ReplyCallback, RecordAReply, NULL))
- return BadAlloc;
- if (!AddCallback(&FlushCallback, RecordFlushAllContexts, NULL))
- return BadAlloc;
- /* Alternate context flushing scheme: delete the line above
- * and call RegisterBlockAndWakeupHandlers here passing
- * RecordFlushAllContexts. Is this any better?
- */
- }
- return Success;
-} /* RecordInstallHooks */
-
-
-/* RecordUninstallHooks
- *
- * Arguments:
- * pRCAP is an RCAP on an enabled or being-disabled context.
- * oneclient can be zero or the resource ID mask identifying a client.
- *
- * Returns: nothing.
- *
- * Side Effects:
- * Recording hooks needed by RCAP may be uninstalled.
- * If oneclient is zero, recording hooks needed for all clients and
- * protocol on the RCAP may be uninstalled. If oneclient is non-zero,
- * only those hooks needed for the specified client may be uninstalled.
- *
- * Client requestVectors may be altered. numEnabledRCAPs will be
- * decremented if oneclient == 0. Callbacks may be deleted from
- * various callback lists.
- */
-static void
-RecordUninstallHooks(RecordClientsAndProtocolPtr pRCAP, XID oneclient)
-{
- int i = 0;
- XID client;
-
- if (oneclient)
- client = oneclient;
- else
- client = pRCAP->numClients ? pRCAP->pClientIDs[i++] : 0;
-
- while (client)
- {
- if (client != XRecordFutureClients)
- {
- if (pRCAP->pRequestMajorOpSet)
- {
- ClientPtr pClient = clients[CLIENT_ID(client)];
- int c;
- Bool otherRCAPwantsProcVector = FALSE;
- RecordClientPrivatePtr pClientPriv = NULL;
-
- assert (pClient);
- pClientPriv = RecordClientPrivate(pClient);
- assert (pClientPriv);
- memcpy(pClientPriv->recordVector, pClientPriv->originalVector,
- sizeof (pClientPriv->recordVector));
-
- for (c = 0; c < numEnabledContexts; c++)
- {
- RecordClientsAndProtocolPtr pOtherRCAP;
- RecordContextPtr pContext = ppAllContexts[c];
-
- if (pContext == pRCAP->pContext) continue;
- pOtherRCAP = RecordFindClientOnContext(pContext, client,
- NULL);
- if (pOtherRCAP && pOtherRCAP->pRequestMajorOpSet)
- {
- RecordSetIteratePtr pIter = NULL;
- RecordSetInterval interval;
-
- otherRCAPwantsProcVector = TRUE;
- while ((pIter = RecordIterateSet(
- pOtherRCAP->pRequestMajorOpSet,
- pIter, &interval)))
- {
- unsigned int j;
- for (j = interval.first; j <= interval.last; j++)
- pClient->requestVector[j] = RecordARequest;
- }
- }
- }
- if (!otherRCAPwantsProcVector)
- { /* nobody needs it, so free it */
- pClient->requestVector = pClientPriv->originalVector;
- dixSetPrivate(&pClient->devPrivates,
- RecordClientPrivateKey, NULL);
- free(pClientPriv);
- }
- } /* end if this RCAP specifies any requests */
- } /* end if not future clients */
- if (oneclient)
- client = 0;
- else
- client = (i < pRCAP->numClients) ? pRCAP->pClientIDs[i++] : 0;
- }
-
- assert(numEnabledRCAPs >= 1);
- if (!oneclient && --numEnabledRCAPs == 0)
- { /* we're disabling the last context */
- DeleteCallback(&EventCallback, RecordADeliveredEventOrError, NULL);
- DeleteCallback(&DeviceEventCallback, RecordADeviceEvent, NULL);
- DeleteCallback(&ReplyCallback, RecordAReply, NULL);
- DeleteCallback(&FlushCallback, RecordFlushAllContexts, NULL);
- /* Alternate context flushing scheme: delete the line above
- * and call RemoveBlockAndWakeupHandlers here passing
- * RecordFlushAllContexts. Is this any better?
- */
- /* Having deleted the callback, call it one last time. -gildea */
- RecordFlushAllContexts(&FlushCallback, NULL, NULL);
- }
-} /* RecordUninstallHooks */
-
-
-/* RecordDeleteClientFromRCAP
- *
- * Arguments:
- * pRCAP is an RCAP to delete the client from.
- * position is the index into the array pRCAP->pClientIDs of the
- * client to delete.
- *
- * Returns: nothing.
- *
- * Side Effects:
- * Recording hooks needed by client will be uninstalled if the context
- * is enabled. The designated client will be removed from the
- * pRCAP->pClientIDs array. If it was the only client on the RCAP,
- * the RCAP is removed from the context and freed. (Invariant: RCAPs
- * have at least one client.)
- */
-static void
-RecordDeleteClientFromRCAP(RecordClientsAndProtocolPtr pRCAP, int position)
-{
- if (pRCAP->pContext->pRecordingClient)
- RecordUninstallHooks(pRCAP, pRCAP->pClientIDs[position]);
- if (position != pRCAP->numClients - 1)
- pRCAP->pClientIDs[position] = pRCAP->pClientIDs[pRCAP->numClients - 1];
- if (--pRCAP->numClients == 0)
- { /* no more clients; remove RCAP from context's list */
- RecordContextPtr pContext = pRCAP->pContext;
- if (pContext->pRecordingClient)
- RecordUninstallHooks(pRCAP, 0);
- if (pContext->pListOfRCAP == pRCAP)
- pContext->pListOfRCAP = pRCAP->pNextRCAP;
- else
- {
- RecordClientsAndProtocolPtr prevRCAP;
- for (prevRCAP = pContext->pListOfRCAP;
- prevRCAP->pNextRCAP != pRCAP;
- prevRCAP = prevRCAP->pNextRCAP)
- ;
- prevRCAP->pNextRCAP = pRCAP->pNextRCAP;
- }
- /* free the RCAP */
- if (pRCAP->clientIDsSeparatelyAllocated)
- free(pRCAP->pClientIDs);
- free(pRCAP);
- }
-} /* RecordDeleteClientFromRCAP */
-
-
-/* RecordAddClientToRCAP
- *
- * Arguments:
- * pRCAP is an RCAP to add the client to.
- * clientspec is the resource ID mask identifying a client, or
- * XRecordFutureClients.
- *
- * Returns: nothing.
- *
- * Side Effects:
- * Recording hooks needed by client will be installed if the context
- * is enabled. The designated client will be added to the
- * pRCAP->pClientIDs array, which may be realloced.
- * pRCAP->clientIDsSeparatelyAllocated may be set to 1 if there
- * is no more room to hold clients internal to the RCAP.
- */
-static void
-RecordAddClientToRCAP(RecordClientsAndProtocolPtr pRCAP, XID clientspec)
-{
- if (pRCAP->numClients == pRCAP->sizeClients)
- {
- if (pRCAP->clientIDsSeparatelyAllocated)
- {
- XID *pNewIDs = (XID *)realloc(pRCAP->pClientIDs,
- (pRCAP->sizeClients + CLIENT_ARRAY_GROWTH_INCREMENT) *
- sizeof(XID));
- if (!pNewIDs)
- return;
- pRCAP->pClientIDs = pNewIDs;
- pRCAP->sizeClients += CLIENT_ARRAY_GROWTH_INCREMENT;
- }
- else
- {
- XID *pNewIDs = (XID *)malloc((pRCAP->sizeClients +
- CLIENT_ARRAY_GROWTH_INCREMENT) * sizeof(XID));
- if (!pNewIDs)
- return;
- memcpy(pNewIDs, pRCAP->pClientIDs, pRCAP->numClients *sizeof(XID));
- pRCAP->pClientIDs = pNewIDs;
- pRCAP->sizeClients += CLIENT_ARRAY_GROWTH_INCREMENT;
- pRCAP->clientIDsSeparatelyAllocated = 1;
- }
- }
- pRCAP->pClientIDs[pRCAP->numClients++] = clientspec;
- if (pRCAP->pContext->pRecordingClient)
- RecordInstallHooks(pRCAP, clientspec);
-} /* RecordDeleteClientFromRCAP */
-
-
-/* RecordDeleteClientFromContext
- *
- * Arguments:
- * pContext is the context to delete from.
- * clientspec is the resource ID mask identifying a client, or
- * XRecordFutureClients.
- *
- * Returns: nothing.
- *
- * Side Effects:
- * If clientspec is on any RCAP of the context, it is deleted from that
- * RCAP. (A given clientspec can only be on one RCAP of a context.)
- */
-static void
-RecordDeleteClientFromContext(RecordContextPtr pContext, XID clientspec)
-{
- RecordClientsAndProtocolPtr pRCAP;
- int position;
-
- if ((pRCAP = RecordFindClientOnContext(pContext, clientspec, &position)))
- RecordDeleteClientFromRCAP(pRCAP, position);
-} /* RecordDeleteClientFromContext */
-
-
-/* RecordSanityCheckClientSpecifiers
- *
- * Arguments:
- * clientspecs is an array of alleged CLIENTSPECs passed by the client.
- * nspecs is the number of elements in clientspecs.
- * errorspec, if non-zero, is the resource id base of a client that
- * must not appear in clienspecs.
- *
- * Returns: BadMatch if any of the clientspecs are invalid, else Success.
- *
- * Side Effects: none.
- */
-static int
-RecordSanityCheckClientSpecifiers(ClientPtr client, XID *clientspecs, int nspecs, XID errorspec)
-{
- int i;
- int clientIndex;
- int rc;
- pointer value;
-
- for (i = 0; i < nspecs; i++)
- {
- if (clientspecs[i] == XRecordCurrentClients ||
- clientspecs[i] == XRecordFutureClients ||
- clientspecs[i] == XRecordAllClients)
- continue;
- if (errorspec && (CLIENT_BITS(clientspecs[i]) == errorspec) )
- return BadMatch;
- clientIndex = CLIENT_ID(clientspecs[i]);
- if (clientIndex && clients[clientIndex] &&
- clients[clientIndex]->clientState == ClientStateRunning)
- {
- if (clientspecs[i] == clients[clientIndex]->clientAsMask)
- continue;
- rc = dixLookupResourceByClass(&value, clientspecs[i], RC_ANY,
- client, DixGetAttrAccess);
- if (rc != Success)
- return rc;
- }
- else
- return BadMatch;
- }
- return Success;
-} /* RecordSanityCheckClientSpecifiers */
-
-
-/* RecordCanonicalizeClientSpecifiers
- *
- * Arguments:
- * pClientspecs is an array of CLIENTSPECs that have been sanity
- * checked.
- * pNumClientspecs is a pointer to the number of elements in pClientspecs.
- * excludespec, if non-zero, is the resource id base of a client that
- * should not be included in the expansion of XRecordAllClients or
- * XRecordCurrentClients.
- *
- * Returns:
- * A pointer to an array of CLIENTSPECs that is the same as the
- * passed array with the following modifications:
- * - all but the client id bits of resource IDs are stripped off.
- * - duplicates removed.
- * - XRecordAllClients expanded to a list of all currently connected
- * clients + XRecordFutureClients - excludespec (if non-zero)
- * - XRecordCurrentClients expanded to a list of all currently
- * connected clients - excludespec (if non-zero)
- * The returned array may be the passed array modified in place, or
- * it may be an malloc'ed array. The caller should keep a pointer to the
- * original array and free the returned array if it is different.
- *
- * *pNumClientspecs is set to the number of elements in the returned
- * array.
- *
- * Side Effects:
- * pClientspecs may be modified in place.
- */
-static XID *
-RecordCanonicalizeClientSpecifiers(XID *pClientspecs, int *pNumClientspecs, XID excludespec)
-{
- int i;
- int numClients = *pNumClientspecs;
-
- /* first pass strips off the resource index bits, leaving just the
- * client id bits. This makes searching for a particular client simpler
- * (and faster.)
- */
- for (i = 0; i < numClients; i++)
- {
- XID cs = pClientspecs[i];
- if (cs > XRecordAllClients)
- pClientspecs[i] = CLIENT_BITS(cs);
- }
-
- for (i = 0; i < numClients; i++)
- {
- if (pClientspecs[i] == XRecordAllClients ||
- pClientspecs[i] == XRecordCurrentClients)
- { /* expand All/Current */
- int j, nc;
- XID *pCanon = (XID *)malloc(sizeof(XID) * (currentMaxClients + 1));
- if (!pCanon) return NULL;
- for (nc = 0, j = 1; j < currentMaxClients; j++)
- {
- ClientPtr client = clients[j];
- if (client != NullClient &&
- client->clientState == ClientStateRunning &&
- client->clientAsMask != excludespec)
- {
- pCanon[nc++] = client->clientAsMask;
- }
- }
- if (pClientspecs[i] == XRecordAllClients)
- pCanon[nc++] = XRecordFutureClients;
- *pNumClientspecs = nc;
- return pCanon;
- }
- else /* not All or Current */
- {
- int j;
- for (j = i + 1; j < numClients; )
- {
- if (pClientspecs[i] == pClientspecs[j])
- {
- pClientspecs[j] = pClientspecs[--numClients];
- }
- else
- j++;
- }
- }
- } /* end for each clientspec */
- *pNumClientspecs = numClients;
- return pClientspecs;
-} /* RecordCanonicalizeClientSpecifiers */
-
-
-/****************************************************************************/
-
-/* stuff for RegisterClients */
-
-/* RecordPadAlign
- *
- * Arguments:
- * size is the number of bytes taken by an object.
- * align is a byte boundary (e.g. 4, 8)
- *
- * Returns:
- * the number of pad bytes to add at the end of an object of the
- * given size so that an object placed immediately behind it will
- * begin on an <align>-byte boundary.
- *
- * Side Effects: none.
- */
-static int
-RecordPadAlign(int size, int align)
-{
- return (align - (size & (align - 1))) & (align - 1);
-} /* RecordPadAlign */
-
-
-/* RecordSanityCheckRegisterClients
- *
- * Arguments:
- * pContext is the context being registered on.
- * client is the client that issued a RecordCreateContext or
- * RecordRegisterClients request.
- * stuff is a pointer to the request.
- *
- * Returns:
- * Any one of several possible error values if any of the request
- * arguments are invalid. Success if everything is OK.
- *
- * Side Effects: none.
- */
-static int
-RecordSanityCheckRegisterClients(RecordContextPtr pContext, ClientPtr client, xRecordRegisterClientsReq *stuff)
-{
- int err;
- xRecordRange *pRange;
- int i;
- XID recordingClient;
-
- if (((client->req_len << 2) - SIZEOF(xRecordRegisterClientsReq)) !=
- 4 * stuff->nClients + SIZEOF(xRecordRange) * stuff->nRanges)
- return BadLength;
-
- if (stuff->elementHeader &
- ~(XRecordFromClientSequence|XRecordFromClientTime|XRecordFromServerTime))
- {
- client->errorValue = stuff->elementHeader;
- return BadValue;
- }
-
- recordingClient = pContext->pRecordingClient ?
- pContext->pRecordingClient->clientAsMask : 0;
- err = RecordSanityCheckClientSpecifiers(client, (XID *)&stuff[1],
- stuff->nClients, recordingClient);
- if (err != Success) return err;
-
- pRange = (xRecordRange *)(((XID *)&stuff[1]) + stuff->nClients);
- for (i = 0; i < stuff->nRanges; i++, pRange++)
- {
- if (pRange->coreRequestsFirst > pRange->coreRequestsLast)
- {
- client->errorValue = pRange->coreRequestsFirst;
- return BadValue;
- }
- if (pRange->coreRepliesFirst > pRange->coreRepliesLast)
- {
- client->errorValue = pRange->coreRepliesFirst;
- return BadValue;
- }
- if ((pRange->extRequestsMajorFirst || pRange->extRequestsMajorLast) &&
- (pRange->extRequestsMajorFirst < 128 ||
- pRange->extRequestsMajorLast < 128 ||
- pRange->extRequestsMajorFirst > pRange->extRequestsMajorLast))
- {
- client->errorValue = pRange->extRequestsMajorFirst;
- return BadValue;
- }
- if (pRange->extRequestsMinorFirst > pRange->extRequestsMinorLast)
- {
- client->errorValue = pRange->extRequestsMinorFirst;
- return BadValue;
- }
- if ((pRange->extRepliesMajorFirst || pRange->extRepliesMajorLast) &&
- (pRange->extRepliesMajorFirst < 128 ||
- pRange->extRepliesMajorLast < 128 ||
- pRange->extRepliesMajorFirst > pRange->extRepliesMajorLast))
- {
- client->errorValue = pRange->extRepliesMajorFirst;
- return BadValue;
- }
- if (pRange->extRepliesMinorFirst > pRange->extRepliesMinorLast)
- {
- client->errorValue = pRange->extRepliesMinorFirst;
- return BadValue;
- }
- if ((pRange->deliveredEventsFirst || pRange->deliveredEventsLast) &&
- (pRange->deliveredEventsFirst < 2 ||
- pRange->deliveredEventsLast < 2 ||
- pRange->deliveredEventsFirst > pRange->deliveredEventsLast))
- {
- client->errorValue = pRange->deliveredEventsFirst;
- return BadValue;
- }
- if ((pRange->deviceEventsFirst || pRange->deviceEventsLast) &&
- (pRange->deviceEventsFirst < 2 ||
- pRange->deviceEventsLast < 2 ||
- pRange->deviceEventsFirst > pRange->deviceEventsLast))
- {
- client->errorValue = pRange->deviceEventsFirst;
- return BadValue;
- }
- if (pRange->errorsFirst > pRange->errorsLast)
- {
- client->errorValue = pRange->errorsFirst;
- return BadValue;
- }
- if (pRange->clientStarted != xFalse && pRange->clientStarted != xTrue)
- {
- client->errorValue = pRange->clientStarted;
- return BadValue;
- }
- if (pRange->clientDied != xFalse && pRange->clientDied != xTrue)
- {
- client->errorValue = pRange->clientDied;
- return BadValue;
- }
- } /* end for each range */
- return Success;
-} /* end RecordSanityCheckRegisterClients */
-
-/* This is a tactical structure used to gather information about all the sets
- * (RecordSetPtr) that need to be created for an RCAP in the process of
- * digesting a list of RECORDRANGEs (converting it to the internal
- * representation).
- */
-typedef struct
-{
- int nintervals; /* number of intervals in following array */
- RecordSetInterval *intervals; /* array of intervals for this set */
- int size; /* size of intevals array; >= nintervals */
- int align; /* alignment restriction for set */
- int offset; /* where to store set pointer rel. to start of RCAP */
- short first, last; /* if for extension, major opcode interval */
-} SetInfoRec, *SetInfoPtr;
-
-/* These constant are used to index into an array of SetInfoRec. */
-enum {REQ, /* set info for requests */
- REP, /* set info for replies */
- ERR, /* set info for errors */
- DEV, /* set info for device events */
- DLEV, /* set info for delivered events */
- PREDEFSETS}; /* number of predefined array entries */
-
-
-/* RecordAllocIntervals
- *
- * Arguments:
- * psi is a pointer to a SetInfoRec whose intervals pointer is NULL.
- * nIntervals is the desired size of the intervals array.
- *
- * Returns: BadAlloc if a memory allocation error occurred, else Success.
- *
- * Side Effects:
- * If Success is returned, psi->intervals is a pointer to size
- * RecordSetIntervals, all zeroed, and psi->size is set to size.
- */
-static int
-RecordAllocIntervals(SetInfoPtr psi, int nIntervals)
-{
- assert(!psi->intervals);
- psi->intervals = (RecordSetInterval *)
- malloc(nIntervals * sizeof(RecordSetInterval));
- if (!psi->intervals)
- return BadAlloc;
- memset(psi->intervals, 0, nIntervals * sizeof(RecordSetInterval));
- psi->size = nIntervals;
- return Success;
-} /* end RecordAllocIntervals */
-
-
-/* RecordConvertRangesToIntervals
- *
- * Arguments:
- * psi is a pointer to the SetInfoRec we are building.
- * pRanges is an array of xRecordRanges.
- * nRanges is the number of elements in pRanges.
- * byteoffset is the offset from the start of an xRecordRange of the
- * two bytes (1 for first, 1 for last) we are interested in.
- * pExtSetInfo, if non-NULL, indicates that the two bytes mentioned
- * above are followed by four bytes (2 for first, 2 for last)
- * representing a minor opcode range, and this information should be
- * stored in one of the SetInfoRecs starting at pExtSetInfo.
- * pnExtSetInfo is the number of elements in the pExtSetInfo array.
- *
- * Returns: BadAlloc if a memory allocation error occurred, else Success.
- *
- * Side Effects:
- * The slice of pRanges indicated by byteoffset is stored in psi.
- * If pExtSetInfo is non-NULL, minor opcode intervals are stored
- * in an existing SetInfoRec if the major opcode interval matches, else
- * they are stored in a new SetInfoRec, and *pnExtSetInfo is
- * increased accordingly.
- */
-static int
-RecordConvertRangesToIntervals(
- SetInfoPtr psi,
- xRecordRange *pRanges,
- int nRanges,
- int byteoffset,
- SetInfoPtr pExtSetInfo,
- int *pnExtSetInfo
-)
-{
- int i;
- CARD8 *pCARD8;
- int first, last;
- int err;
-
- for (i = 0; i < nRanges; i++, pRanges++)
- {
- pCARD8 = ((CARD8 *)pRanges) + byteoffset;
- first = pCARD8[0];
- last = pCARD8[1];
- if (first || last)
- {
- if (!psi->intervals)
- {
- err = RecordAllocIntervals(psi, 2 * (nRanges - i));
- if (err != Success)
- return err;
- }
- psi->intervals[psi->nintervals].first = first;
- psi->intervals[psi->nintervals].last = last;
- psi->nintervals++;
- assert(psi->nintervals <= psi->size);
- if (pExtSetInfo)
- {
- SetInfoPtr pesi = pExtSetInfo;
- CARD16 *pCARD16 = (CARD16 *)(pCARD8 + 2);
- int j;
-
- for (j = 0; j < *pnExtSetInfo; j++, pesi++)
- {
- if ( (first == pesi->first) && (last == pesi->last) )
- break;
- }
- if (j == *pnExtSetInfo)
- {
- err = RecordAllocIntervals(pesi, 2 * (nRanges - i));
- if (err != Success)
- return err;
- pesi->first = first;
- pesi->last = last;
- (*pnExtSetInfo)++;
- }
- pesi->intervals[pesi->nintervals].first = pCARD16[0];
- pesi->intervals[pesi->nintervals].last = pCARD16[1];
- pesi->nintervals++;
- assert(pesi->nintervals <= pesi->size);
- }
- }
- }
- return Success;
-} /* end RecordConvertRangesToIntervals */
-
-#define offset_of(_structure, _field) \
- ((char *)(& (_structure . _field)) - (char *)(&_structure))
-
-/* RecordRegisterClients
- *
- * Arguments:
- * pContext is the context on which to register the clients.
- * client is the client that issued the RecordCreateContext or
- * RecordRegisterClients request.
- * stuff is a pointer to the request.
- *
- * Returns:
- * Any one of several possible error values defined by the protocol.
- * Success if everything is OK.
- *
- * Side Effects:
- * If different element headers are specified, the context is flushed.
- * If any of the specified clients are already registered on the
- * context, they are first unregistered. A new RCAP is created to
- * hold the specified protocol and clients, and it is linked onto the
- * context. If the context is enabled, appropriate hooks are installed
- * to record the new clients and protocol.
- */
-static int
-RecordRegisterClients(RecordContextPtr pContext, ClientPtr client, xRecordRegisterClientsReq *stuff)
-{
- int err;
- int i;
- SetInfoPtr si;
- int maxSets;
- int nExtReqSets = 0;
- int nExtRepSets = 0;
- int extReqSetsOffset = 0;
- int extRepSetsOffset = 0;
- SetInfoPtr pExtReqSets, pExtRepSets;
- int clientListOffset;
- XID *pCanonClients;
- int clientStarted = 0, clientDied = 0;
- xRecordRange *pRanges, rr;
- int nClients;
- int sizeClients;
- int totRCAPsize;
- RecordClientsAndProtocolPtr pRCAP;
- int pad;
- XID recordingClient;
-
- /* do all sanity checking up front */
-
- err = RecordSanityCheckRegisterClients(pContext, client, stuff);
- if (err != Success)
- return err;
-
- /* if element headers changed, flush buffer */
-
- if (pContext->elemHeaders != stuff->elementHeader)
- {
- RecordFlushReplyBuffer(pContext, NULL, 0, NULL, 0);
- pContext->elemHeaders = stuff->elementHeader;
- }
-
- nClients = stuff->nClients;
- if (!nClients)
- /* if empty clients list, we're done. */
- return Success;
-
- recordingClient = pContext->pRecordingClient ?
- pContext->pRecordingClient->clientAsMask : 0;
- pCanonClients = RecordCanonicalizeClientSpecifiers((XID *)&stuff[1],
- &nClients, recordingClient);
- if (!pCanonClients)
- return BadAlloc;
-
- /* We may have to create as many as one set for each "predefined"
- * protocol types, plus one per range for extension reuests, plus one per
- * range for extension replies.
- */
- maxSets = PREDEFSETS + 2 * stuff->nRanges;
- si = (SetInfoPtr)malloc(sizeof(SetInfoRec) * maxSets);
- if (!si)
- {
- err = BadAlloc;
- goto bailout;
- }
- memset(si, 0, sizeof(SetInfoRec) * maxSets);
-
- /* theoretically you must do this because NULL may not be all-bits-zero */
- for (i = 0; i < maxSets; i++)
- si[i].intervals = NULL;
-
- pExtReqSets = si + PREDEFSETS;
- pExtRepSets = pExtReqSets + stuff->nRanges;
-
- pRanges = (xRecordRange *)(((XID *)&stuff[1]) + stuff->nClients);
-
- err = RecordConvertRangesToIntervals(&si[REQ], pRanges, stuff->nRanges,
- offset_of(rr, coreRequestsFirst), NULL, NULL);
- if (err != Success) goto bailout;
-
- err = RecordConvertRangesToIntervals(&si[REQ], pRanges, stuff->nRanges,
- offset_of(rr, extRequestsMajorFirst), pExtReqSets, &nExtReqSets);
- if (err != Success) goto bailout;
-
- err = RecordConvertRangesToIntervals(&si[REP], pRanges, stuff->nRanges,
- offset_of(rr, coreRepliesFirst), NULL, NULL);
- if (err != Success) goto bailout;
-
- err = RecordConvertRangesToIntervals(&si[REP], pRanges, stuff->nRanges,
- offset_of(rr, extRepliesMajorFirst), pExtRepSets, &nExtRepSets);
- if (err != Success) goto bailout;
-
- err = RecordConvertRangesToIntervals(&si[ERR], pRanges, stuff->nRanges,
- offset_of(rr, errorsFirst), NULL, NULL);
- if (err != Success) goto bailout;
-
- err = RecordConvertRangesToIntervals(&si[DLEV], pRanges, stuff->nRanges,
- offset_of(rr, deliveredEventsFirst), NULL, NULL);
- if (err != Success) goto bailout;
-
- err = RecordConvertRangesToIntervals(&si[DEV], pRanges, stuff->nRanges,
- offset_of(rr, deviceEventsFirst), NULL, NULL);
- if (err != Success) goto bailout;
-
- /* collect client-started and client-died */
-
- for (i = 0; i < stuff->nRanges; i++)
- {
- if (pRanges[i].clientStarted) clientStarted = TRUE;
- if (pRanges[i].clientDied) clientDied = TRUE;
- }
-
- /* We now have all the information collected to create all the sets,
- * and we can compute the total memory required for the RCAP.
- */
-
- totRCAPsize = sizeof(RecordClientsAndProtocolRec);
-
- /* leave a little room to grow before forcing a separate allocation */
- sizeClients = nClients + CLIENT_ARRAY_GROWTH_INCREMENT;
- pad = RecordPadAlign(totRCAPsize, sizeof(XID));
- clientListOffset = totRCAPsize + pad;
- totRCAPsize += pad + sizeClients * sizeof(XID);
-
- if (nExtReqSets)
- {
- pad = RecordPadAlign(totRCAPsize, sizeof(RecordSetPtr));
- extReqSetsOffset = totRCAPsize + pad;
- totRCAPsize += pad + (nExtReqSets + 1) * sizeof(RecordMinorOpRec);
- }
- if (nExtRepSets)
- {
- pad = RecordPadAlign(totRCAPsize, sizeof(RecordSetPtr));
- extRepSetsOffset = totRCAPsize + pad;
- totRCAPsize += pad + (nExtRepSets + 1) * sizeof(RecordMinorOpRec);
- }
-
- for (i = 0; i < maxSets; i++)
- {
- if (si[i].nintervals)
- {
- si[i].size = RecordSetMemoryRequirements(
- si[i].intervals, si[i].nintervals, &si[i].align);
- pad = RecordPadAlign(totRCAPsize, si[i].align);
- si[i].offset = pad + totRCAPsize;
- totRCAPsize += pad + si[i].size;
- }
- }
-
- /* allocate memory for the whole RCAP */
-
- pRCAP = (RecordClientsAndProtocolPtr)malloc(totRCAPsize);
- if (!pRCAP)
- {
- err = BadAlloc;
- goto bailout;
- }
-
- /* fill in the RCAP */
-
- pRCAP->pContext = pContext;
- pRCAP->pClientIDs = (XID *)((char *)pRCAP + clientListOffset);
- pRCAP->numClients = nClients;
- pRCAP->sizeClients = sizeClients;
- pRCAP->clientIDsSeparatelyAllocated = 0;
- for (i = 0; i < nClients; i++)
- {
- RecordDeleteClientFromContext(pContext, pCanonClients[i]);
- pRCAP->pClientIDs[i] = pCanonClients[i];
- }
-
- /* create all the sets */
-
- if (si[REQ].intervals)
- {
- pRCAP->pRequestMajorOpSet =
- RecordCreateSet(si[REQ].intervals, si[REQ].nintervals,
- (RecordSetPtr)((char *)pRCAP + si[REQ].offset), si[REQ].size);
- }
- else pRCAP->pRequestMajorOpSet = NULL;
-
- if (si[REP].intervals)
- {
- pRCAP->pReplyMajorOpSet =
- RecordCreateSet(si[REP].intervals, si[REP].nintervals,
- (RecordSetPtr)((char *)pRCAP + si[REP].offset), si[REP].size);
- }
- else pRCAP->pReplyMajorOpSet = NULL;
-
- if (si[ERR].intervals)
- {
- pRCAP->pErrorSet =
- RecordCreateSet(si[ERR].intervals, si[ERR].nintervals,
- (RecordSetPtr)((char *)pRCAP + si[ERR].offset), si[ERR].size);
- }
- else pRCAP->pErrorSet = NULL;
-
- if (si[DEV].intervals)
- {
- pRCAP->pDeviceEventSet =
- RecordCreateSet(si[DEV].intervals, si[DEV].nintervals,
- (RecordSetPtr)((char *)pRCAP + si[DEV].offset), si[DEV].size);
- }
- else pRCAP->pDeviceEventSet = NULL;
-
- if (si[DLEV].intervals)
- {
- pRCAP->pDeliveredEventSet =
- RecordCreateSet(si[DLEV].intervals, si[DLEV].nintervals,
- (RecordSetPtr)((char *)pRCAP + si[DLEV].offset), si[DLEV].size);
- }
- else pRCAP->pDeliveredEventSet = NULL;
-
- if (nExtReqSets)
- {
- pRCAP->pRequestMinOpInfo = (RecordMinorOpPtr)
- ((char *)pRCAP + extReqSetsOffset);
- pRCAP->pRequestMinOpInfo[0].count = nExtReqSets;
- for (i = 0; i < nExtReqSets; i++, pExtReqSets++)
- {
- pRCAP->pRequestMinOpInfo[i+1].major.first = pExtReqSets->first;
- pRCAP->pRequestMinOpInfo[i+1].major.last = pExtReqSets->last;
- pRCAP->pRequestMinOpInfo[i+1].major.pMinOpSet =
- RecordCreateSet(pExtReqSets->intervals,
- pExtReqSets->nintervals,
- (RecordSetPtr)((char *)pRCAP + pExtReqSets->offset),
- pExtReqSets->size);
- }
- }
- else pRCAP->pRequestMinOpInfo = NULL;
-
- if (nExtRepSets)
- {
- pRCAP->pReplyMinOpInfo = (RecordMinorOpPtr)
- ((char *)pRCAP + extRepSetsOffset);
- pRCAP->pReplyMinOpInfo[0].count = nExtRepSets;
- for (i = 0; i < nExtRepSets; i++, pExtRepSets++)
- {
- pRCAP->pReplyMinOpInfo[i+1].major.first = pExtRepSets->first;
- pRCAP->pReplyMinOpInfo[i+1].major.last = pExtRepSets->last;
- pRCAP->pReplyMinOpInfo[i+1].major.pMinOpSet =
- RecordCreateSet(pExtRepSets->intervals,
- pExtRepSets->nintervals,
- (RecordSetPtr)((char *)pRCAP + pExtRepSets->offset),
- pExtRepSets->size);
- }
- }
- else pRCAP->pReplyMinOpInfo = NULL;
-
- pRCAP->clientStarted = clientStarted;
- pRCAP->clientDied = clientDied;
-
- /* link the RCAP onto the context */
-
- pRCAP->pNextRCAP = pContext->pListOfRCAP;
- pContext->pListOfRCAP = pRCAP;
-
- if (pContext->pRecordingClient) /* context enabled */
- RecordInstallHooks(pRCAP, 0);
-
-bailout:
- if (si)
- {
- for (i = 0; i < maxSets; i++)
- free(si[i].intervals);
- free(si);
- }
- if (pCanonClients && pCanonClients != (XID *)&stuff[1])
- free(pCanonClients);
- return err;
-} /* RecordRegisterClients */
-
-
-/* Proc functions all take a client argument, execute the request in
- * client->requestBuffer, and return a protocol error status.
- */
-
-static int
-ProcRecordQueryVersion(ClientPtr client)
-{
- /* REQUEST(xRecordQueryVersionReq); */
- xRecordQueryVersionReply rep;
- int n;
-
- REQUEST_SIZE_MATCH(xRecordQueryVersionReq);
- rep.type = X_Reply;
- rep.sequenceNumber = client->sequence;
- rep.length = 0;
- rep.majorVersion = SERVER_RECORD_MAJOR_VERSION;
- rep.minorVersion = SERVER_RECORD_MINOR_VERSION;
- if(client->swapped)
- {
- swaps(&rep.sequenceNumber, n);
- swaps(&rep.majorVersion, n);
- swaps(&rep.minorVersion, n);
- }
- (void)WriteToClient(client, sizeof(xRecordQueryVersionReply),
- (char *)&rep);
- return Success;
-} /* ProcRecordQueryVersion */
-
-
-static int
-ProcRecordCreateContext(ClientPtr client)
-{
- REQUEST(xRecordCreateContextReq);
- RecordContextPtr pContext;
- RecordContextPtr *ppNewAllContexts = NULL;
- int err = BadAlloc;
-
- REQUEST_AT_LEAST_SIZE(xRecordCreateContextReq);
- LEGAL_NEW_RESOURCE(stuff->context, client);
-
- pContext = (RecordContextPtr)malloc(sizeof(RecordContextRec));
- if (!pContext)
- goto bailout;
-
- /* make sure there is room in ppAllContexts to store the new context */
-
- ppNewAllContexts = (RecordContextPtr *)
- realloc(ppAllContexts, sizeof(RecordContextPtr) * (numContexts + 1));
- if (!ppNewAllContexts)
- goto bailout;
- ppAllContexts = ppNewAllContexts;
-
- pContext->id = stuff->context;
- pContext->pRecordingClient = NULL;
- pContext->pListOfRCAP = NULL;
- pContext->elemHeaders = 0;
- pContext->bufCategory = 0;
- pContext->numBufBytes = 0;
- pContext->pBufClient = NULL;
- pContext->continuedReply = 0;
- pContext->inFlush = 0;
-
- err = RecordRegisterClients(pContext, client,
- (xRecordRegisterClientsReq *)stuff);
- if (err != Success)
- goto bailout;
-
- if (AddResource(pContext->id, RTContext, pContext))
- {
- ppAllContexts[numContexts++] = pContext;
- return Success;
- }
- else
- {
- RecordDeleteContext((pointer)pContext, pContext->id);
- err = BadAlloc;
- }
-bailout:
- free(pContext);
- return err;
-} /* ProcRecordCreateContext */
-
-
-static int
-ProcRecordRegisterClients(ClientPtr client)
-{
- RecordContextPtr pContext;
- REQUEST(xRecordRegisterClientsReq);
-
- REQUEST_AT_LEAST_SIZE(xRecordRegisterClientsReq);
- VERIFY_CONTEXT(pContext, stuff->context, client);
-
- return RecordRegisterClients(pContext, client, stuff);
-} /* ProcRecordRegisterClients */
-
-
-static int
-ProcRecordUnregisterClients(ClientPtr client)
-{
- RecordContextPtr pContext;
- int err;
- REQUEST(xRecordUnregisterClientsReq);
- XID *pCanonClients;
- int nClients;
- int i;
-
- REQUEST_AT_LEAST_SIZE(xRecordUnregisterClientsReq);
- if ((client->req_len << 2) - SIZEOF(xRecordUnregisterClientsReq) !=
- 4 * stuff->nClients)
- return BadLength;
- VERIFY_CONTEXT(pContext, stuff->context, client);
- err = RecordSanityCheckClientSpecifiers(client, (XID *)&stuff[1],
- stuff->nClients, 0);
- if (err != Success)
- return err;
-
- nClients = stuff->nClients;
- pCanonClients = RecordCanonicalizeClientSpecifiers((XID *)&stuff[1],
- &nClients, 0);
- if (!pCanonClients)
- return BadAlloc;
-
- for (i = 0; i < nClients; i++)
- {
- RecordDeleteClientFromContext(pContext, pCanonClients[i]);
- }
- if (pCanonClients != (XID *)&stuff[1])
- free(pCanonClients);
- return Success;
-} /* ProcRecordUnregisterClients */
-
-
-/****************************************************************************/
-
-/* stuff for GetContext */
-
-/* This is a tactical structure used to hold the xRecordRanges as they are
- * being reconstituted from the sets in the RCAPs.
- */
-
-typedef struct {
- xRecordRange *pRanges; /* array of xRecordRanges for one RCAP */
- int size; /* number of elements in pRanges, >= nRanges */
- int nRanges; /* number of occupied element of pRanges */
-} GetContextRangeInfoRec, *GetContextRangeInfoPtr;
-
-
-/* RecordAllocRanges
- *
- * Arguments:
- * pri is a pointer to a GetContextRangeInfoRec to allocate for.
- * nRanges is the number of xRecordRanges desired for pri.
- *
- * Returns: BadAlloc if a memory allocation error occurred, else Success.
- *
- * Side Effects:
- * If Success is returned, pri->pRanges points to at least nRanges
- * ranges. pri->nRanges is set to nRanges. pri->size is the actual
- * number of ranges. Newly allocated ranges are zeroed.
- */
-static int
-RecordAllocRanges(GetContextRangeInfoPtr pri, int nRanges)
-{
- int newsize;
- xRecordRange *pNewRange;
-#define SZINCR 8
-
- newsize = max(pri->size + SZINCR, nRanges);
- pNewRange = (xRecordRange *)realloc(pri->pRanges,
- newsize * sizeof(xRecordRange));
- if (!pNewRange)
- return BadAlloc;
-
- pri->pRanges = pNewRange;
- pri->size = newsize;
- memset(&pri->pRanges[pri->size - SZINCR], 0, SZINCR * sizeof(xRecordRange));
- if (pri->nRanges < nRanges)
- pri->nRanges = nRanges;
- return Success;
-} /* RecordAllocRanges */
-
-
-/* RecordConvertSetToRanges
- *
- * Arguments:
- * pSet is the set to be converted.
- * pri is where the result should be stored.
- * byteoffset is the offset from the start of an xRecordRange of the
- * two vales (first, last) we are interested in.
- * card8 is TRUE if the vales are one byte each and FALSE if two bytes
- * each.
- * imax is the largest set value to store in pri->pRanges.
- * pStartIndex, if non-NULL, is the index of the first range in
- * pri->pRanges that should be stored to. If NULL,
- * start at index 0.
- *
- * Returns: BadAlloc if a memory allocation error occurred, else Success.
- *
- * Side Effects:
- * If Success is returned, the slice of pri->pRanges indicated by
- * byteoffset and card8 is filled in with the intervals from pSet.
- * if pStartIndex was non-NULL, *pStartIndex is filled in with one
- * more than the index of the last xRecordRange that was touched.
- */
-static int
-RecordConvertSetToRanges(
- RecordSetPtr pSet,
- GetContextRangeInfoPtr pri,
- int byteoffset,
- Bool card8,
- unsigned int imax,
- int *pStartIndex
-)
-{
- int nRanges;
- RecordSetIteratePtr pIter = NULL;
- RecordSetInterval interval;
- CARD8 *pCARD8;
- CARD16 *pCARD16;
- int err;
-
- if (!pSet)
- return Success;
-
- nRanges = pStartIndex ? *pStartIndex : 0;
- while ((pIter = RecordIterateSet(pSet, pIter, &interval)))
- {
- if (interval.first > imax) break;
- if (interval.last > imax) interval.last = imax;
- nRanges++;
- if (nRanges > pri->size)
- {
- err = RecordAllocRanges(pri, nRanges);
- if (err != Success)
- return err;
- }
- else
- pri->nRanges = max(pri->nRanges, nRanges);
- if (card8)
- {
- pCARD8 = ((CARD8 *)&pri->pRanges[nRanges-1]) + byteoffset;
- *pCARD8++ = interval.first;
- *pCARD8 = interval.last;
- }
- else
- {
- pCARD16 = (CARD16 *)
- (((char *)&pri->pRanges[nRanges-1]) + byteoffset);
- *pCARD16++ = interval.first;
- *pCARD16 = interval.last;
- }
- }
- if (pStartIndex)
- *pStartIndex = nRanges;
- return Success;
-} /* RecordConvertSetToRanges */
-
-
-/* RecordConvertMinorOpInfoToRanges
- *
- * Arguments:
- * pMinOpInfo is the minor opcode info to convert to xRecordRanges.
- * pri is where the result should be stored.
- * byteoffset is the offset from the start of an xRecordRange of the
- * four vales (CARD8 major_first, CARD8 major_last,
- * CARD16 minor_first, CARD16 minor_last) we are going to store.
- *
- * Returns: BadAlloc if a memory allocation error occurred, else Success.
- *
- * Side Effects:
- * If Success is returned, the slice of pri->pRanges indicated by
- * byteoffset is filled in with the information from pMinOpInfo.
- */
-static int
-RecordConvertMinorOpInfoToRanges(
- RecordMinorOpPtr pMinOpInfo,
- GetContextRangeInfoPtr pri,
- int byteoffset
-)
-{
- int nsets;
- int start;
- int i;
- int err;
-
- if (!pMinOpInfo)
- return Success;
-
- nsets = pMinOpInfo->count;
- pMinOpInfo++;
- start = 0;
- for (i = 0; i < nsets; i++)
- {
- int j, s;
- s = start;
- err = RecordConvertSetToRanges(pMinOpInfo[i].major.pMinOpSet, pri,
- byteoffset + 2, FALSE, 65535, &start);
- if (err != Success) return err;
- for (j = s; j < start; j++)
- {
- CARD8 *pCARD8 = ((CARD8 *)&pri->pRanges[j]) + byteoffset;
- *pCARD8++ = pMinOpInfo[i].major.first;
- *pCARD8 = pMinOpInfo[i].major.last;
- }
- }
- return Success;
-} /* RecordConvertMinorOpInfoToRanges */
-
-
-/* RecordSwapRanges
- *
- * Arguments:
- * pRanges is an array of xRecordRanges.
- * nRanges is the number of elements in pRanges.
- *
- * Returns: nothing.
- *
- * Side Effects:
- * The 16 bit fields of each xRecordRange are byte swapped.
- */
-static void
-RecordSwapRanges(xRecordRange *pRanges, int nRanges)
-{
- int i;
- register char n;
- for (i = 0; i < nRanges; i++, pRanges++)
- {
- swaps(&pRanges->extRequestsMinorFirst, n);
- swaps(&pRanges->extRequestsMinorLast, n);
- swaps(&pRanges->extRepliesMinorFirst, n);
- swaps(&pRanges->extRepliesMinorLast, n);
- }
-} /* RecordSwapRanges */
-
-
-static int
-ProcRecordGetContext(ClientPtr client)
-{
- RecordContextPtr pContext;
- REQUEST(xRecordGetContextReq);
- xRecordGetContextReply rep;
- int n;
- RecordClientsAndProtocolPtr pRCAP;
- int nRCAPs = 0;
- GetContextRangeInfoPtr pRangeInfo;
- GetContextRangeInfoPtr pri;
- int i;
- int err;
-
- REQUEST_SIZE_MATCH(xRecordGetContextReq);
- VERIFY_CONTEXT(pContext, stuff->context, client);
-
- /* how many RCAPs are there on this context? */
-
- for (pRCAP = pContext->pListOfRCAP; pRCAP; pRCAP = pRCAP->pNextRCAP)
- nRCAPs++;
-
- /* allocate and initialize space for record range info */
-
- pRangeInfo = (GetContextRangeInfoPtr)malloc(
- nRCAPs * sizeof(GetContextRangeInfoRec));
- if (!pRangeInfo && nRCAPs > 0)
- return BadAlloc;
- for (i = 0; i < nRCAPs; i++)
- {
- pRangeInfo[i].pRanges = NULL;
- pRangeInfo[i].size = 0;
- pRangeInfo[i].nRanges = 0;
- }
-
- /* convert the RCAP (internal) representation of the recorded protocol
- * to the wire protocol (external) representation, storing the information
- * for the ith RCAP in pri[i]
- */
-
- for (pRCAP = pContext->pListOfRCAP, pri = pRangeInfo;
- pRCAP;
- pRCAP = pRCAP->pNextRCAP, pri++)
- {
- xRecordRange rr;
-
- err = RecordConvertSetToRanges(pRCAP->pRequestMajorOpSet, pri,
- offset_of(rr, coreRequestsFirst), TRUE, 127, NULL);
- if (err != Success) goto bailout;
-
- err = RecordConvertSetToRanges(pRCAP->pReplyMajorOpSet, pri,
- offset_of(rr, coreRepliesFirst), TRUE, 127, NULL);
- if (err != Success) goto bailout;
-
- err = RecordConvertSetToRanges(pRCAP->pDeliveredEventSet, pri,
- offset_of(rr, deliveredEventsFirst), TRUE, 255, NULL);
- if (err != Success) goto bailout;
-
- err = RecordConvertSetToRanges(pRCAP->pDeviceEventSet, pri,
- offset_of(rr, deviceEventsFirst), TRUE, 255, NULL);
- if (err != Success) goto bailout;
-
- err = RecordConvertSetToRanges(pRCAP->pErrorSet, pri,
- offset_of(rr, errorsFirst), TRUE, 255, NULL);
- if (err != Success) goto bailout;
-
- err = RecordConvertMinorOpInfoToRanges(pRCAP->pRequestMinOpInfo,
- pri, offset_of(rr, extRequestsMajorFirst));
- if (err != Success) goto bailout;
-
- err = RecordConvertMinorOpInfoToRanges(pRCAP->pReplyMinOpInfo,
- pri, offset_of(rr, extRepliesMajorFirst));
- if (err != Success) goto bailout;
-
- if (pRCAP->clientStarted || pRCAP->clientDied)
- {
- if (pri->nRanges == 0)
- RecordAllocRanges(pri, 1);
- pri->pRanges[0].clientStarted = pRCAP->clientStarted;
- pri->pRanges[0].clientDied = pRCAP->clientDied;
- }
- }
-
- /* calculate number of clients and reply length */
-
- rep.nClients = 0;
- rep.length = 0;
- for (pRCAP = pContext->pListOfRCAP, pri = pRangeInfo;
- pRCAP;
- pRCAP = pRCAP->pNextRCAP, pri++)
- {
- rep.nClients += pRCAP->numClients;
- rep.length += pRCAP->numClients *
- ( bytes_to_int32(sizeof(xRecordClientInfo)) +
- pri->nRanges * bytes_to_int32(sizeof(xRecordRange)));
- }
-
- /* write the reply header */
-
- rep.type = X_Reply;
- rep.sequenceNumber = client->sequence;
- rep.enabled = pContext->pRecordingClient != NULL;
- rep.elementHeader = pContext->elemHeaders;
- if(client->swapped)
- {
- swaps(&rep.sequenceNumber, n);
- swapl(&rep.length, n);
- swapl(&rep.nClients, n);
- }
- (void)WriteToClient(client, sizeof(xRecordGetContextReply),
- (char *)&rep);
-
- /* write all the CLIENT_INFOs */
-
- for (pRCAP = pContext->pListOfRCAP, pri = pRangeInfo;
- pRCAP;
- pRCAP = pRCAP->pNextRCAP, pri++)
- {
- xRecordClientInfo rci;
- rci.nRanges = pri->nRanges;
- if (client->swapped)
- {
- swapl(&rci.nRanges, n);
- RecordSwapRanges(pri->pRanges, pri->nRanges);
- }
- for (i = 0; i < pRCAP->numClients; i++)
- {
- rci.clientResource = pRCAP->pClientIDs[i];
- if (client->swapped) swapl(&rci.clientResource, n);
- WriteToClient(client, sizeof(xRecordClientInfo), (char *)&rci);
- WriteToClient(client, sizeof(xRecordRange) * pri->nRanges,
- (char *)pri->pRanges);
- }
- }
- err = Success;
-
-bailout:
- for (i = 0; i < nRCAPs; i++)
- {
- free(pRangeInfo[i].pRanges);
- }
- free(pRangeInfo);
- return err;
-} /* ProcRecordGetContext */
-
-
-static int
-ProcRecordEnableContext(ClientPtr client)
-{
- RecordContextPtr pContext;
- REQUEST(xRecordEnableContextReq);
- int i;
- RecordClientsAndProtocolPtr pRCAP;
-
- REQUEST_SIZE_MATCH(xRecordGetContextReq);
- VERIFY_CONTEXT(pContext, stuff->context, client);
- if (pContext->pRecordingClient)
- return BadMatch; /* already enabled */
-
- /* install record hooks for each RCAP */
-
- for (pRCAP = pContext->pListOfRCAP; pRCAP; pRCAP = pRCAP->pNextRCAP)
- {
- int err = RecordInstallHooks(pRCAP, 0);
- if (err != Success)
- { /* undo the previous installs */
- RecordClientsAndProtocolPtr pUninstallRCAP;
- for (pUninstallRCAP = pContext->pListOfRCAP;
- pUninstallRCAP != pRCAP;
- pUninstallRCAP = pUninstallRCAP->pNextRCAP)
- {
- RecordUninstallHooks(pUninstallRCAP, 0);
- }
- return err;
- }
- }
-
- /* Disallow further request processing on this connection until
- * the context is disabled.
- */
- IgnoreClient(client);
- pContext->pRecordingClient = client;
-
- /* Don't allow the data connection to record itself; unregister it. */
- RecordDeleteClientFromContext(pContext,
- pContext->pRecordingClient->clientAsMask);
-
- /* move the newly enabled context to the front part of ppAllContexts,
- * where all the enabled contexts are
- */
- i = RecordFindContextOnAllContexts(pContext);
- assert(i >= numEnabledContexts);
- if (i != numEnabledContexts)
- {
- ppAllContexts[i] = ppAllContexts[numEnabledContexts];
- ppAllContexts[numEnabledContexts] = pContext;
- }
-
- ++numEnabledContexts;
- assert(numEnabledContexts > 0);
-
- /* send StartOfData */
- RecordAProtocolElement(pContext, NULL, XRecordStartOfData, NULL, 0, 0);
- RecordFlushReplyBuffer(pContext, NULL, 0, NULL, 0);
- return Success;
-} /* ProcRecordEnableContext */
-
-
-/* RecordDisableContext
- *
- * Arguments:
- * pContext is the context to disable.
- * nRanges is the number of elements in pRanges.
- *
- * Returns: nothing.
- *
- * Side Effects:
- * If the context was enabled, it is disabled. An EndOfData
- * message is sent to the recording client. Recording hooks for
- * this context are uninstalled. The context is moved to the
- * rear part of the ppAllContexts array. numEnabledContexts is
- * decremented. Request processing for the formerly recording client
- * is resumed.
- */
-static void
-RecordDisableContext(RecordContextPtr pContext)
-{
- RecordClientsAndProtocolPtr pRCAP;
- int i;
-
- if (!pContext->pRecordingClient) return;
- if (!pContext->pRecordingClient->clientGone)
- {
- RecordAProtocolElement(pContext, NULL, XRecordEndOfData, NULL, 0, 0);
- RecordFlushReplyBuffer(pContext, NULL, 0, NULL, 0);
- /* Re-enable request processing on this connection. */
- AttendClient(pContext->pRecordingClient);
- }
-
- for (pRCAP = pContext->pListOfRCAP; pRCAP; pRCAP = pRCAP->pNextRCAP)
- {
- RecordUninstallHooks(pRCAP, 0);
- }
-
- pContext->pRecordingClient = NULL;
-
- /* move the newly disabled context to the rear part of ppAllContexts,
- * where all the disabled contexts are
- */
- i = RecordFindContextOnAllContexts(pContext);
- assert( (i != -1) && (i < numEnabledContexts) );
- if (i != (numEnabledContexts - 1) )
- {
- ppAllContexts[i] = ppAllContexts[numEnabledContexts-1];
- ppAllContexts[numEnabledContexts-1] = pContext;
- }
- --numEnabledContexts;
- assert(numEnabledContexts >= 0);
-} /* RecordDisableContext */
-
-
-static int
-ProcRecordDisableContext(ClientPtr client)
-{
- RecordContextPtr pContext;
- REQUEST(xRecordDisableContextReq);
-
- REQUEST_SIZE_MATCH(xRecordDisableContextReq);
- VERIFY_CONTEXT(pContext, stuff->context, client);
- RecordDisableContext(pContext);
- return Success;
-} /* ProcRecordDisableContext */
-
-
-/* RecordDeleteContext
- *
- * Arguments:
- * value is the context to delete.
- * id is its resource ID.
- *
- * Returns: Success.
- *
- * Side Effects:
- * Disables the context, frees all associated memory, and removes
- * it from the ppAllContexts array.
- */
-static int
-RecordDeleteContext(pointer value, XID id)
-{
- int i;
- RecordContextPtr pContext = (RecordContextPtr)value;
- RecordClientsAndProtocolPtr pRCAP;
-
- RecordDisableContext(pContext);
-
- /* Remove all the clients from all the RCAPs.
- * As a result, the RCAPs will be freed.
- */
-
- while ((pRCAP = pContext->pListOfRCAP))
- {
- int numClients = pRCAP->numClients;
- /* when the last client is deleted, the RCAP will go away. */
- while(numClients--)
- {
- RecordDeleteClientFromRCAP(pRCAP, numClients);
- }
- }
-
- /* remove context from AllContexts list */
-
- if (-1 != (i = RecordFindContextOnAllContexts(pContext)))
- {
- ppAllContexts[i] = ppAllContexts[numContexts - 1];
- if (--numContexts == 0)
- {
- free(ppAllContexts);
- ppAllContexts = NULL;
- }
- }
- free(pContext);
-
- return Success;
-} /* RecordDeleteContext */
-
-
-static int
-ProcRecordFreeContext(ClientPtr client)
-{
- RecordContextPtr pContext;
- REQUEST(xRecordFreeContextReq);
-
- REQUEST_SIZE_MATCH(xRecordFreeContextReq);
- VERIFY_CONTEXT(pContext, stuff->context, client);
- FreeResource(stuff->context, RT_NONE);
- return Success;
-} /* ProcRecordFreeContext */
-
-
-static int
-ProcRecordDispatch(ClientPtr client)
-{
- REQUEST(xReq);
-
- switch (stuff->data)
- {
- case X_RecordQueryVersion:
- return ProcRecordQueryVersion(client);
- case X_RecordCreateContext:
- return ProcRecordCreateContext(client);
- case X_RecordRegisterClients:
- return ProcRecordRegisterClients(client);
- case X_RecordUnregisterClients:
- return ProcRecordUnregisterClients(client);
- case X_RecordGetContext:
- return ProcRecordGetContext(client);
- case X_RecordEnableContext:
- return ProcRecordEnableContext(client);
- case X_RecordDisableContext:
- return ProcRecordDisableContext(client);
- case X_RecordFreeContext:
- return ProcRecordFreeContext(client);
- default:
- return BadRequest;
- }
-} /* ProcRecordDispatch */
-
-
-static int
-SProcRecordQueryVersion(ClientPtr client)
-{
- REQUEST(xRecordQueryVersionReq);
- register char n;
-
- swaps(&stuff->length, n);
- REQUEST_SIZE_MATCH(xRecordQueryVersionReq);
- swaps(&stuff->majorVersion, n);
- swaps(&stuff->minorVersion,n);
- return ProcRecordQueryVersion(client);
-} /* SProcRecordQueryVersion */
-
-
-static int
-SwapCreateRegister(xRecordRegisterClientsReq *stuff)
-{
- register char n;
- int i;
- XID *pClientID;
-
- swapl(&stuff->context, n);
- swapl(&stuff->nClients, n);
- swapl(&stuff->nRanges, n);
- pClientID = (XID *)&stuff[1];
- if (stuff->nClients > stuff->length - bytes_to_int32(sz_xRecordRegisterClientsReq))
- return BadLength;
- for (i = 0; i < stuff->nClients; i++, pClientID++)
- {
- swapl(pClientID, n);
- }
- if (stuff->nRanges > stuff->length - bytes_to_int32(sz_xRecordRegisterClientsReq)
- - stuff->nClients)
- return BadLength;
- RecordSwapRanges((xRecordRange *)pClientID, stuff->nRanges);
- return Success;
-} /* SwapCreateRegister */
-
-
-static int
-SProcRecordCreateContext(ClientPtr client)
-{
- REQUEST(xRecordCreateContextReq);
- int status;
- register char n;
-
- swaps(&stuff->length, n);
- REQUEST_AT_LEAST_SIZE(xRecordCreateContextReq);
- if ((status = SwapCreateRegister((pointer)stuff)) != Success)
- return status;
- return ProcRecordCreateContext(client);
-} /* SProcRecordCreateContext */
-
-
-static int
-SProcRecordRegisterClients(ClientPtr client)
-{
- REQUEST(xRecordRegisterClientsReq);
- int status;
- register char n;
-
- swaps(&stuff->length, n);
- REQUEST_AT_LEAST_SIZE(xRecordRegisterClientsReq);
- if ((status = SwapCreateRegister((pointer)stuff)) != Success)
- return status;
- return ProcRecordRegisterClients(client);
-} /* SProcRecordRegisterClients */
-
-
-static int
-SProcRecordUnregisterClients(ClientPtr client)
-{
- REQUEST(xRecordUnregisterClientsReq);
- register char n;
-
- swaps(&stuff->length, n);
- REQUEST_AT_LEAST_SIZE(xRecordUnregisterClientsReq);
- swapl(&stuff->context, n);
- swapl(&stuff->nClients, n);
- SwapRestL(stuff);
- return ProcRecordUnregisterClients(client);
-} /* SProcRecordUnregisterClients */
-
-
-static int
-SProcRecordGetContext(ClientPtr client)
-{
- REQUEST(xRecordGetContextReq);
- register char n;
-
- swaps(&stuff->length, n);
- REQUEST_SIZE_MATCH(xRecordGetContextReq);
- swapl(&stuff->context, n);
- return ProcRecordGetContext(client);
-} /* SProcRecordGetContext */
-
-static int
-SProcRecordEnableContext(ClientPtr client)
-{
- REQUEST(xRecordEnableContextReq);
- register char n;
-
- swaps(&stuff->length, n);
- REQUEST_SIZE_MATCH(xRecordEnableContextReq);
- swapl(&stuff->context, n);
- return ProcRecordEnableContext(client);
-} /* SProcRecordEnableContext */
-
-
-static int
-SProcRecordDisableContext(ClientPtr client)
-{
- REQUEST(xRecordDisableContextReq);
- register char n;
-
- swaps(&stuff->length, n);
- REQUEST_SIZE_MATCH(xRecordDisableContextReq);
- swapl(&stuff->context, n);
- return ProcRecordDisableContext(client);
-} /* SProcRecordDisableContext */
-
-
-static int
-SProcRecordFreeContext(ClientPtr client)
-{
- REQUEST(xRecordFreeContextReq);
- register char n;
-
- swaps(&stuff->length, n);
- REQUEST_SIZE_MATCH(xRecordFreeContextReq);
- swapl(&stuff->context, n);
- return ProcRecordFreeContext(client);
-} /* SProcRecordFreeContext */
-
-
-static int
-SProcRecordDispatch(ClientPtr client)
-{
- REQUEST(xReq);
-
- switch (stuff->data)
- {
- case X_RecordQueryVersion:
- return SProcRecordQueryVersion(client);
- case X_RecordCreateContext:
- return SProcRecordCreateContext(client);
- case X_RecordRegisterClients:
- return SProcRecordRegisterClients(client);
- case X_RecordUnregisterClients:
- return SProcRecordUnregisterClients(client);
- case X_RecordGetContext:
- return SProcRecordGetContext(client);
- case X_RecordEnableContext:
- return SProcRecordEnableContext(client);
- case X_RecordDisableContext:
- return SProcRecordDisableContext(client);
- case X_RecordFreeContext:
- return SProcRecordFreeContext(client);
- default:
- return BadRequest;
- }
-} /* SProcRecordDispatch */
-
-/* RecordConnectionSetupInfo
- *
- * Arguments:
- * pContext is an enabled context that specifies recording of
- * connection setup info.
- * pci holds the connection setup info.
- *
- * Returns: nothing.
- *
- * Side Effects:
- * The connection setup info is sent to the recording client.
- */
-static void
-RecordConnectionSetupInfo(RecordContextPtr pContext, NewClientInfoRec *pci)
-{
- int prefixsize = SIZEOF(xConnSetupPrefix);
- int restsize = pci->prefix->length * 4;
-
- if (pci->client->swapped)
- {
- char *pConnSetup = (char *)malloc(prefixsize + restsize);
- if (!pConnSetup)
- return;
- SwapConnSetupPrefix(pci->prefix, (xConnSetupPrefix*)pConnSetup);
- SwapConnSetupInfo((char*)pci->setup, (char*)(pConnSetup + prefixsize));
- RecordAProtocolElement(pContext, pci->client, XRecordClientStarted,
- (pointer)pConnSetup, prefixsize + restsize, 0);
- free(pConnSetup);
- }
- else
- {
- /* don't alloc and copy as in the swapped case; just send the
- * data in two pieces
- */
- RecordAProtocolElement(pContext, pci->client, XRecordClientStarted,
- (pointer)pci->prefix, prefixsize, restsize);
- RecordAProtocolElement(pContext, pci->client, XRecordClientStarted,
- (pointer)pci->setup, restsize, /* continuation */ -1);
- }
-} /* RecordConnectionSetupInfo */
-
-
-/* RecordDeleteContext
- *
- * Arguments:
- * pcbl is &ClientStateCallback.
- * nullata is NULL.
- * calldata is a pointer to a NewClientInfoRec (include/dixstruct.h)
- * which contains information about client state changes.
- *
- * Returns: nothing.
- *
- * Side Effects:
- * If a new client has connected and any contexts have specified
- * XRecordFutureClients, the new client is registered on those contexts.
- * If any of those contexts specify recording of the connection setup
- * info, it is recorded.
- *
- * If an existing client has disconnected, it is deleted from any
- * contexts that it was registered on. If any of those contexts
- * specified XRecordClientDied, they record a ClientDied protocol element.
- * If the disconnectiong client happened to be the data connection of an
- * enabled context, the context is disabled.
- */
-
-static void
-RecordAClientStateChange(CallbackListPtr *pcbl, pointer nulldata, pointer calldata)
-{
- NewClientInfoRec *pci = (NewClientInfoRec *)calldata;
- int i;
- ClientPtr pClient = pci->client;
- RecordContextPtr *ppAllContextsCopy = NULL;
- int numContextsCopy = 0;
-
- switch (pClient->clientState)
- {
- case ClientStateRunning: /* new client */
- for (i = 0; i < numContexts; i++)
- {
- RecordClientsAndProtocolPtr pRCAP;
- RecordContextPtr pContext = ppAllContexts[i];
-
- if ((pRCAP = RecordFindClientOnContext(pContext,
- XRecordFutureClients, NULL)))
- {
- RecordAddClientToRCAP(pRCAP, pClient->clientAsMask);
- if (pContext->pRecordingClient && pRCAP->clientStarted)
- RecordConnectionSetupInfo(pContext, pci);
- }
- }
- break;
-
- case ClientStateGone:
- case ClientStateRetained: /* client disconnected */
-
- /* RecordDisableContext modifies contents of ppAllContexts. */
- numContextsCopy = numContexts;
- ppAllContextsCopy = malloc(numContextsCopy * sizeof(RecordContextPtr));
- assert(ppAllContextsCopy);
- memcpy(ppAllContextsCopy, ppAllContexts, numContextsCopy * sizeof(RecordContextPtr));
-
- for (i = 0; i < numContextsCopy; i++)
- {
- RecordClientsAndProtocolPtr pRCAP;
- RecordContextPtr pContext = ppAllContextsCopy[i];
- int pos;
-
- if (pContext->pRecordingClient == pClient)
- RecordDisableContext(pContext);
- if ((pRCAP = RecordFindClientOnContext(pContext,
- pClient->clientAsMask, &pos)))
- {
- if (pContext->pRecordingClient && pRCAP->clientDied)
- RecordAProtocolElement(pContext, pClient,
- XRecordClientDied, NULL, 0, 0);
- RecordDeleteClientFromRCAP(pRCAP, pos);
- }
- }
-
- free(ppAllContextsCopy);
- break;
-
- default:
- break;
- } /* end switch on client state */
-} /* RecordAClientStateChange */
-
-
-/* RecordCloseDown
- *
- * Arguments:
- * extEntry is the extension information for RECORD.
- *
- * Returns: nothing.
- *
- * Side Effects:
- * Performs any cleanup needed by RECORD at server shutdown time.
- *
- */
-static void
-RecordCloseDown(ExtensionEntry *extEntry)
-{
- DeleteCallback(&ClientStateCallback, RecordAClientStateChange, NULL);
-} /* RecordCloseDown */
-
-
-/* RecordExtensionInit
- *
- * Arguments: none.
- *
- * Returns: nothing.
- *
- * Side Effects:
- * Enables the RECORD extension if possible.
- */
-void
-RecordExtensionInit(void)
-{
- ExtensionEntry *extentry;
-
- RTContext = CreateNewResourceType(RecordDeleteContext, "RecordContext");
- if (!RTContext)
- return;
-
- if (!dixRegisterPrivateKey(RecordClientPrivateKey, PRIVATE_CLIENT, 0))
- return;
-
- ppAllContexts = NULL;
- numContexts = numEnabledContexts = numEnabledRCAPs = 0;
-
- if (!AddCallback(&ClientStateCallback, RecordAClientStateChange, NULL))
- return;
-
- extentry = AddExtension(RECORD_NAME, RecordNumEvents, RecordNumErrors,
- ProcRecordDispatch, SProcRecordDispatch,
- RecordCloseDown, StandardMinorOpcode);
- if (!extentry)
- {
- DeleteCallback(&ClientStateCallback, RecordAClientStateChange, NULL);
- return;
- }
- SetResourceTypeErrorValue(RTContext, extentry->errorBase + XRecordBadContext);
-
-} /* RecordExtensionInit */
-
+
+/*
+
+Copyright 1995, 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.
+
+Author: David P. Wiggins, The Open Group
+
+This work benefited from earlier work done by Martha Zimet of NCD
+and Jim Haggerty of Metheus.
+
+*/
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include "dixstruct.h"
+#include "extnsionst.h"
+#include <X11/extensions/recordproto.h>
+#include "set.h"
+#include "swaprep.h"
+#include "inputstr.h"
+#include "eventconvert.h"
+#include "scrnintstr.h"
+
+
+#include <stdio.h>
+#include <assert.h>
+
+#ifdef PANORAMIX
+#include "globals.h"
+#include "panoramiX.h"
+#include "panoramiXsrv.h"
+#include "cursor.h"
+#endif
+
+#include "protocol-versions.h"
+
+static RESTYPE RTContext; /* internal resource type for Record contexts */
+
+/* How many bytes of protocol data to buffer in a context. Don't set to less
+ * than 32.
+ */
+#define REPLY_BUF_SIZE 1024
+
+/* Record Context structure */
+
+typedef struct {
+ XID id; /* resource id of context */
+ ClientPtr pRecordingClient; /* client that has context enabled */
+ struct _RecordClientsAndProtocolRec *pListOfRCAP; /* all registered info */
+ ClientPtr pBufClient; /* client whose protocol is in replyBuffer*/
+ unsigned int continuedReply:1; /* recording a reply that is split up? */
+ char elemHeaders; /* element header flags (time/seq no.) */
+ char bufCategory; /* category of protocol in replyBuffer */
+ int numBufBytes; /* number of bytes in replyBuffer */
+ char replyBuffer[REPLY_BUF_SIZE]; /* buffered recorded protocol */
+ int inFlush; /* are we inside RecordFlushReplyBuffer */
+} RecordContextRec, *RecordContextPtr;
+
+/* RecordMinorOpRec - to hold minor opcode selections for extension requests
+ * and replies
+ */
+
+typedef union {
+ int count; /* first element of array: how many "major" structs to follow */
+ struct { /* rest of array elements are this */
+ short first; /* first major opcode */
+ short last; /* last major opcode */
+ RecordSetPtr pMinOpSet; /* minor opcode set for above major range */
+ } major;
+} RecordMinorOpRec, *RecordMinorOpPtr;
+
+
+/* RecordClientsAndProtocolRec, nicknamed RCAP - holds all the client and
+ * protocol selections passed in a single CreateContext or RegisterClients.
+ * Generally, a context will have one of these from the create and an
+ * additional one for each RegisterClients. RCAPs are freed when all their
+ * clients are unregistered.
+ */
+
+typedef struct _RecordClientsAndProtocolRec {
+ RecordContextPtr pContext; /* context that owns this RCAP */
+ struct _RecordClientsAndProtocolRec *pNextRCAP; /* next RCAP on context */
+ RecordSetPtr pRequestMajorOpSet; /* requests to record */
+ RecordMinorOpPtr pRequestMinOpInfo; /* extension requests to record */
+ RecordSetPtr pReplyMajorOpSet; /* replies to record */
+ RecordMinorOpPtr pReplyMinOpInfo; /* extension replies to record */
+ RecordSetPtr pDeviceEventSet; /* device events to record */
+ RecordSetPtr pDeliveredEventSet; /* delivered events to record */
+ RecordSetPtr pErrorSet; /* errors to record */
+ XID * pClientIDs; /* array of clients to record */
+ short numClients; /* number of clients in pClientIDs */
+ short sizeClients; /* size of pClientIDs array */
+ unsigned int clientStarted:1; /* record new client connections? */
+ unsigned int clientDied:1; /* record client disconnections? */
+ unsigned int clientIDsSeparatelyAllocated:1; /* pClientIDs malloced? */
+} RecordClientsAndProtocolRec, *RecordClientsAndProtocolPtr;
+
+/* how much bigger to make pRCAP->pClientIDs when reallocing */
+#define CLIENT_ARRAY_GROWTH_INCREMENT 4
+
+/* counts the total number of RCAPs belonging to enabled contexts. */
+static int numEnabledRCAPs;
+
+/* void VERIFY_CONTEXT(RecordContextPtr, XID, ClientPtr)
+ * In the spirit of the VERIFY_* macros in dix.h, this macro fills in
+ * the context pointer if the given ID is a valid Record Context, else it
+ * returns an error.
+ */
+#define VERIFY_CONTEXT(_pContext, _contextid, _client) { \
+ int rc = dixLookupResourceByType((pointer *)&(_pContext), _contextid, \
+ RTContext, _client, DixUseAccess); \
+ if (rc != Success) \
+ return rc; \
+}
+
+static int RecordDeleteContext(
+ pointer /*value*/,
+ XID /*id*/
+);
+
+void RecordExtensionInit(void);
+
+/***************************************************************************/
+
+/* client private stuff */
+
+/* To make declarations less obfuscated, have a typedef for a pointer to a
+ * Proc function.
+ */
+typedef int (*ProcFunctionPtr)(
+ ClientPtr /*pClient*/
+);
+
+/* Record client private. Generally a client only has one of these if
+ * any of its requests are being recorded.
+ */
+typedef struct {
+/* ptr to client's proc vector before Record stuck its nose in */
+ ProcFunctionPtr *originalVector;
+
+/* proc vector with pointers for recorded requests redirected to the
+ * function RecordARequest
+ */
+ ProcFunctionPtr recordVector[256];
+} RecordClientPrivateRec, *RecordClientPrivatePtr;
+
+static DevPrivateKeyRec RecordClientPrivateKeyRec;
+#define RecordClientPrivateKey (&RecordClientPrivateKeyRec)
+
+/* RecordClientPrivatePtr RecordClientPrivate(ClientPtr)
+ * gets the client private of the given client. Syntactic sugar.
+ */
+#define RecordClientPrivate(_pClient) (RecordClientPrivatePtr) \
+ dixLookupPrivate(&(_pClient)->devPrivates, RecordClientPrivateKey)
+
+
+/***************************************************************************/
+
+/* global list of all contexts */
+
+static RecordContextPtr *ppAllContexts;
+
+static int numContexts;/* number of contexts in ppAllContexts */
+
+/* number of currently enabled contexts. All enabled contexts are bunched
+ * up at the front of the ppAllContexts array, from ppAllContexts[0] to
+ * ppAllContexts[numEnabledContexts-1], to eliminate time spent skipping
+ * past disabled contexts.
+ */
+static int numEnabledContexts;
+
+/* RecordFindContextOnAllContexts
+ *
+ * Arguments:
+ * pContext is the context to search for.
+ *
+ * Returns:
+ * The index into the array ppAllContexts at which pContext is stored.
+ * If pContext is not found in ppAllContexts, returns -1.
+ *
+ * Side Effects: none.
+ */
+static int
+RecordFindContextOnAllContexts(RecordContextPtr pContext)
+{
+ int i;
+
+ assert(numContexts >= numEnabledContexts);
+ for (i = 0; i < numContexts; i++)
+ {
+ if (ppAllContexts[i] == pContext)
+ return i;
+ }
+ return -1;
+} /* RecordFindContextOnAllContexts */
+
+
+/***************************************************************************/
+
+/* RecordFlushReplyBuffer
+ *
+ * Arguments:
+ * pContext is the context to flush.
+ * data1 is a pointer to additional data, and len1 is its length in bytes.
+ * data2 is a pointer to additional data, and len2 is its length in bytes.
+ *
+ * Returns: nothing.
+ *
+ * Side Effects:
+ * If the context is enabled, any buffered (recorded) protocol is written
+ * to the recording client, and the number of buffered bytes is set to
+ * zero. If len1 is not zero, data1/len1 are then written to the
+ * recording client, and similarly for data2/len2 (written after
+ * data1/len1).
+ */
+static void
+RecordFlushReplyBuffer(
+ RecordContextPtr pContext,
+ pointer data1,
+ int len1,
+ pointer data2,
+ int len2
+)
+{
+ if (!pContext->pRecordingClient || pContext->pRecordingClient->clientGone || pContext->inFlush)
+ return;
+ ++pContext->inFlush;
+ if (pContext->numBufBytes)
+ WriteToClient(pContext->pRecordingClient, pContext->numBufBytes,
+ (char *)pContext->replyBuffer);
+ pContext->numBufBytes = 0;
+ if (len1)
+ WriteToClient(pContext->pRecordingClient, len1, (char *)data1);
+ if (len2)
+ WriteToClient(pContext->pRecordingClient, len2, (char *)data2);
+ --pContext->inFlush;
+} /* RecordFlushReplyBuffer */
+
+
+/* RecordAProtocolElement
+ *
+ * Arguments:
+ * pContext is the context that is recording a protocol element.
+ * pClient is the client whose protocol is being recorded. For
+ * device events and EndOfData, pClient is NULL.
+ * category is the category of the protocol element, as defined
+ * by the RECORD spec.
+ * data is a pointer to the protocol data, and datalen is its length
+ * in bytes.
+ * futurelen is the number of bytes that will be sent in subsequent
+ * calls to this function to complete this protocol element.
+ * In those subsequent calls, futurelen will be -1 to indicate
+ * that the current data is a continuation of the same protocol
+ * element.
+ *
+ * Returns: nothing.
+ *
+ * Side Effects:
+ * The context may be flushed. The new protocol element will be
+ * added to the context's protocol buffer with appropriate element
+ * headers prepended (sequence number and timestamp). If the data
+ * is continuation data (futurelen == -1), element headers won't
+ * be added. If the protocol element and headers won't fit in
+ * the context's buffer, it is sent directly to the recording
+ * client (after any buffered data).
+ */
+static void
+RecordAProtocolElement(RecordContextPtr pContext, ClientPtr pClient,
+ int category, pointer data, int datalen, int futurelen)
+{
+ CARD32 elemHeaderData[2];
+ int numElemHeaders = 0;
+ Bool recordingClientSwapped = pContext->pRecordingClient->swapped;
+ int n;
+ CARD32 serverTime = 0;
+ Bool gotServerTime = FALSE;
+ int replylen;
+
+ if (futurelen >= 0)
+ { /* start of new protocol element */
+ xRecordEnableContextReply *pRep = (xRecordEnableContextReply *)
+ pContext->replyBuffer;
+ if (pContext->pBufClient != pClient ||
+ pContext->bufCategory != category)
+ {
+ RecordFlushReplyBuffer(pContext, NULL, 0, NULL, 0);
+ pContext->pBufClient = pClient;
+ pContext->bufCategory = category;
+ }
+
+ if (!pContext->numBufBytes)
+ {
+ serverTime = GetTimeInMillis();
+ gotServerTime = TRUE;
+ pRep->type = X_Reply;
+ pRep->category = category;
+ pRep->sequenceNumber = pContext->pRecordingClient->sequence;
+ pRep->length = 0;
+ pRep->elementHeader = pContext->elemHeaders;
+ pRep->serverTime = serverTime;
+ if (pClient)
+ {
+ pRep->clientSwapped =
+ (pClient->swapped != recordingClientSwapped);
+ pRep->idBase = pClient->clientAsMask;
+ pRep->recordedSequenceNumber = pClient->sequence;
+ }
+ else /* it's a device event, StartOfData, or EndOfData */
+ {
+ pRep->clientSwapped = (category != XRecordFromServer) &&
+ recordingClientSwapped;
+ pRep->idBase = 0;
+ pRep->recordedSequenceNumber = 0;
+ }
+
+ if (recordingClientSwapped)
+ {
+ swaps(&pRep->sequenceNumber, n);
+ swapl(&pRep->length, n);
+ swapl(&pRep->idBase, n);
+ swapl(&pRep->serverTime, n);
+ swapl(&pRep->recordedSequenceNumber, n);
+ }
+ pContext->numBufBytes = SIZEOF(xRecordEnableContextReply);
+ }
+
+ /* generate element headers if needed */
+
+ if ( ( (pContext->elemHeaders & XRecordFromClientTime)
+ && category == XRecordFromClient)
+ ||
+ ( (pContext->elemHeaders & XRecordFromServerTime)
+ && category == XRecordFromServer))
+ {
+ if (gotServerTime)
+ elemHeaderData[numElemHeaders] = serverTime;
+ else
+ elemHeaderData[numElemHeaders] = GetTimeInMillis();
+ if (recordingClientSwapped)
+ swapl(&elemHeaderData[numElemHeaders], n);
+ numElemHeaders++;
+ }
+
+ if ( (pContext->elemHeaders & XRecordFromClientSequence)
+ &&
+ (category == XRecordFromClient || category == XRecordClientDied))
+ {
+ elemHeaderData[numElemHeaders] = pClient->sequence;
+ if (recordingClientSwapped)
+ swapl(&elemHeaderData[numElemHeaders], n);
+ numElemHeaders++;
+ }
+
+ /* adjust reply length */
+
+ replylen = pRep->length;
+ if (recordingClientSwapped) swapl(&replylen, n);
+ replylen += numElemHeaders + bytes_to_int32(datalen) +
+ bytes_to_int32(futurelen);
+ if (recordingClientSwapped) swapl(&replylen, n);
+ pRep->length = replylen;
+ } /* end if not continued reply */
+
+ numElemHeaders *= 4;
+
+ /* if space available >= space needed, buffer the data */
+
+ if (REPLY_BUF_SIZE - pContext->numBufBytes >= datalen + numElemHeaders)
+ {
+ if (numElemHeaders)
+ {
+ memcpy(pContext->replyBuffer + pContext->numBufBytes,
+ elemHeaderData, numElemHeaders);
+ pContext->numBufBytes += numElemHeaders;
+ }
+ if (datalen)
+ {
+ memcpy(pContext->replyBuffer + pContext->numBufBytes,
+ data, datalen);
+ pContext->numBufBytes += datalen;
+ }
+ }
+ else
+ RecordFlushReplyBuffer(pContext, (pointer)elemHeaderData,
+ numElemHeaders, (pointer)data, datalen);
+
+} /* RecordAProtocolElement */
+
+
+/* RecordFindClientOnContext
+ *
+ * Arguments:
+ * pContext is the context to search.
+ * clientspec is the resource ID mask identifying the client to search
+ * for, or XRecordFutureClients.
+ * pposition is a pointer to an int, or NULL. See Returns.
+ *
+ * Returns:
+ * The RCAP on which clientspec was found, or NULL if not found on
+ * any RCAP on the given context.
+ * If pposition was not NULL and the returned RCAP is not NULL,
+ * *pposition will be set to the index into the returned the RCAP's
+ * pClientIDs array that holds clientspec.
+ *
+ * Side Effects: none.
+ */
+static RecordClientsAndProtocolPtr
+RecordFindClientOnContext(
+ RecordContextPtr pContext,
+ XID clientspec,
+ int *pposition
+)
+{
+ RecordClientsAndProtocolPtr pRCAP;
+
+ for (pRCAP = pContext->pListOfRCAP; pRCAP; pRCAP = pRCAP->pNextRCAP)
+ {
+ int i;
+ for (i = 0; i < pRCAP->numClients; i++)
+ {
+ if (pRCAP->pClientIDs[i] == clientspec)
+ {
+ if (pposition)
+ *pposition = i;
+ return pRCAP;
+ }
+ }
+ }
+ return NULL;
+} /* RecordFindClientOnContext */
+
+
+/* RecordABigRequest
+ *
+ * Arguments:
+ * pContext is the recording context.
+ * client is the client being recorded.
+ * stuff is a pointer to the big request of client (see the Big Requests
+ * extension for details.)
+ *
+ * Returns: nothing.
+ *
+ * Side Effects:
+ * The big request is recorded with the correct length field re-inserted.
+ *
+ * Note: this function exists mainly to make RecordARequest smaller.
+ */
+static void
+RecordABigRequest(RecordContextPtr pContext, ClientPtr client, xReq *stuff)
+{
+ CARD32 bigLength;
+ char n;
+ int bytesLeft;
+
+ /* note: client->req_len has been frobbed by ReadRequestFromClient
+ * (os/io.c) to discount the extra 4 bytes taken by the extended length
+ * field in a big request. The actual request length to record is
+ * client->req_len + 1 (measured in CARD32s).
+ */
+
+ /* record the request header */
+ bytesLeft = client->req_len << 2;
+ RecordAProtocolElement(pContext, client, XRecordFromClient,
+ (pointer)stuff, SIZEOF(xReq), bytesLeft);
+
+ /* reinsert the extended length field that was squished out */
+ bigLength = client->req_len + bytes_to_int32(sizeof(bigLength));
+ if (client->swapped)
+ swapl(&bigLength, n);
+ RecordAProtocolElement(pContext, client, XRecordFromClient,
+ (pointer)&bigLength, sizeof(bigLength), /* continuation */ -1);
+ bytesLeft -= sizeof(bigLength);
+
+ /* record the rest of the request after the length */
+ RecordAProtocolElement(pContext, client, XRecordFromClient,
+ (pointer)(stuff + 1), bytesLeft, /* continuation */ -1);
+} /* RecordABigRequest */
+
+
+/* RecordARequest
+ *
+ * Arguments:
+ * client is a client that the server has dispatched a request to by
+ * calling client->requestVector[request opcode] .
+ * The request is in client->requestBuffer.
+ *
+ * Returns:
+ * Whatever is returned by the "real" Proc function for this request.
+ * The "real" Proc function is the function that was in
+ * client->requestVector[request opcode] before it was replaced by
+ * RecordARequest. (See the function RecordInstallHooks.)
+ *
+ * Side Effects:
+ * The request is recorded by all contexts that have registered this
+ * request for this client. The real Proc function is called.
+ */
+static int
+RecordARequest(ClientPtr client)
+{
+ RecordContextPtr pContext;
+ RecordClientsAndProtocolPtr pRCAP;
+ int i;
+ RecordClientPrivatePtr pClientPriv;
+ REQUEST(xReq);
+ int majorop;
+
+ majorop = stuff->reqType;
+ for (i = 0; i < numEnabledContexts; i++)
+ {
+ pContext = ppAllContexts[i];
+ pRCAP = RecordFindClientOnContext(pContext, client->clientAsMask,
+ NULL);
+ if (pRCAP && pRCAP->pRequestMajorOpSet &&
+ RecordIsMemberOfSet(pRCAP->pRequestMajorOpSet, majorop))
+ {
+ if (majorop <= 127)
+ { /* core request */
+
+ if (stuff->length == 0)
+ RecordABigRequest(pContext, client, stuff);
+ else
+ RecordAProtocolElement(pContext, client, XRecordFromClient,
+ (pointer)stuff, client->req_len << 2, 0);
+ }
+ else /* extension, check minor opcode */
+ {
+ int minorop = MinorOpcodeOfRequest(client);
+ int numMinOpInfo;
+ RecordMinorOpPtr pMinorOpInfo = pRCAP->pRequestMinOpInfo;
+
+ assert (pMinorOpInfo);
+ numMinOpInfo = pMinorOpInfo->count;
+ pMinorOpInfo++;
+ assert (numMinOpInfo);
+ for ( ; numMinOpInfo; numMinOpInfo--, pMinorOpInfo++)
+ {
+ if (majorop >= pMinorOpInfo->major.first &&
+ majorop <= pMinorOpInfo->major.last &&
+ RecordIsMemberOfSet(pMinorOpInfo->major.pMinOpSet,
+ minorop))
+ {
+ if (stuff->length == 0)
+ RecordABigRequest(pContext, client, stuff);
+ else
+ RecordAProtocolElement(pContext, client,
+ XRecordFromClient, (pointer)stuff,
+ client->req_len << 2, 0);
+ break;
+ }
+ } /* end for each minor op info */
+ } /* end extension request */
+ } /* end this RCAP wants this major opcode */
+ } /* end for each context */
+ pClientPriv = RecordClientPrivate(client);
+ assert(pClientPriv);
+ return (* pClientPriv->originalVector[majorop])(client);
+} /* RecordARequest */
+
+/* RecordAReply
+ *
+ * Arguments:
+ * pcbl is &ReplyCallback.
+ * nulldata is NULL.
+ * calldata is a pointer to a ReplyInfoRec (include/os.h)
+ * which provides information about replies that are being sent
+ * to clients.
+ *
+ * Returns: nothing.
+ *
+ * Side Effects:
+ * The reply is recorded by all contexts that have registered this
+ * reply type for this client. If more data belonging to the same
+ * reply is expected, and if the reply is being recorded by any
+ * context, pContext->continuedReply is set to 1.
+ * If pContext->continuedReply was already 1 and this is the last
+ * chunk of data belonging to this reply, it is set to 0.
+ */
+static void
+RecordAReply(CallbackListPtr *pcbl, pointer nulldata, pointer calldata)
+{
+ RecordContextPtr pContext;
+ RecordClientsAndProtocolPtr pRCAP;
+ int eci;
+ int majorop;
+ ReplyInfoRec *pri = (ReplyInfoRec *)calldata;
+ ClientPtr client = pri->client;
+ REQUEST(xReq);
+
+ majorop = stuff->reqType;
+ for (eci = 0; eci < numEnabledContexts; eci++)
+ {
+ pContext = ppAllContexts[eci];
+ pRCAP = RecordFindClientOnContext(pContext, client->clientAsMask,
+ NULL);
+ if (pRCAP)
+ {
+ if (pContext->continuedReply)
+ {
+ RecordAProtocolElement(pContext, client, XRecordFromServer,
+ (pointer)pri->replyData, pri->dataLenBytes, /* continuation */ -1);
+ if (!pri->bytesRemaining)
+ pContext->continuedReply = 0;
+ }
+ else if (pri->startOfReply && pRCAP->pReplyMajorOpSet &&
+ RecordIsMemberOfSet(pRCAP->pReplyMajorOpSet, majorop))
+ {
+ if (majorop <= 127)
+ { /* core reply */
+ RecordAProtocolElement(pContext, client, XRecordFromServer,
+ (pointer)pri->replyData, pri->dataLenBytes, pri->bytesRemaining);
+ if (pri->bytesRemaining)
+ pContext->continuedReply = 1;
+ }
+ else /* extension, check minor opcode */
+ {
+ int minorop = MinorOpcodeOfRequest(client);
+ int numMinOpInfo;
+ RecordMinorOpPtr pMinorOpInfo = pRCAP->pReplyMinOpInfo;
+ assert (pMinorOpInfo);
+ numMinOpInfo = pMinorOpInfo->count;
+ pMinorOpInfo++;
+ assert (numMinOpInfo);
+ for ( ; numMinOpInfo; numMinOpInfo--, pMinorOpInfo++)
+ {
+ if (majorop >= pMinorOpInfo->major.first &&
+ majorop <= pMinorOpInfo->major.last &&
+ RecordIsMemberOfSet(pMinorOpInfo->major.pMinOpSet,
+ minorop))
+ {
+ RecordAProtocolElement(pContext, client,
+ XRecordFromServer, (pointer)pri->replyData,
+ pri->dataLenBytes, pri->bytesRemaining);
+ if (pri->bytesRemaining)
+ pContext->continuedReply = 1;
+ break;
+ }
+ } /* end for each minor op info */
+ } /* end extension reply */
+ } /* end continued reply vs. start of reply */
+ } /* end client is registered on this context */
+ } /* end for each context */
+} /* RecordAReply */
+
+
+/* RecordADeliveredEventOrError
+ *
+ * Arguments:
+ * pcbl is &EventCallback.
+ * nulldata is NULL.
+ * calldata is a pointer to a EventInfoRec (include/dix.h)
+ * which provides information about events that are being sent
+ * to clients.
+ *
+ * Returns: nothing.
+ *
+ * Side Effects:
+ * The event or error is recorded by all contexts that have registered
+ * it for this client.
+ */
+static void
+RecordADeliveredEventOrError(CallbackListPtr *pcbl, pointer nulldata, pointer calldata)
+{
+ EventInfoRec *pei = (EventInfoRec *)calldata;
+ RecordContextPtr pContext;
+ RecordClientsAndProtocolPtr pRCAP;
+ int eci; /* enabled context index */
+ ClientPtr pClient = pei->client;
+
+ for (eci = 0; eci < numEnabledContexts; eci++)
+ {
+ pContext = ppAllContexts[eci];
+ pRCAP = RecordFindClientOnContext(pContext, pClient->clientAsMask,
+ NULL);
+ if (pRCAP && (pRCAP->pDeliveredEventSet || pRCAP->pErrorSet))
+ {
+ int ev; /* event index */
+ xEvent *pev = pei->events;
+ for (ev = 0; ev < pei->count; ev++, pev++)
+ {
+ int recordit = 0;
+ if (pRCAP->pErrorSet)
+ {
+ recordit = RecordIsMemberOfSet(pRCAP->pErrorSet,
+ ((xError *)(pev))->errorCode);
+ }
+ else if (pRCAP->pDeliveredEventSet)
+ {
+ recordit = RecordIsMemberOfSet(pRCAP->pDeliveredEventSet,
+ pev->u.u.type & 0177);
+ }
+ if (recordit)
+ {
+ xEvent swappedEvent;
+ xEvent *pEvToRecord = pev;
+
+ if (pClient->swapped)
+ {
+ (*EventSwapVector[pev->u.u.type & 0177])
+ (pev, &swappedEvent);
+ pEvToRecord = &swappedEvent;
+
+ }
+ RecordAProtocolElement(pContext, pClient,
+ XRecordFromServer, pEvToRecord, SIZEOF(xEvent), 0);
+ }
+ } /* end for each event */
+ } /* end this client is on this context */
+ } /* end for each enabled context */
+} /* RecordADeliveredEventOrError */
+
+
+static void
+RecordSendProtocolEvents(RecordClientsAndProtocolPtr pRCAP,
+ RecordContextPtr pContext,
+ xEvent* pev, int count)
+{
+ int ev; /* event index */
+
+ for (ev = 0; ev < count; ev++, pev++)
+ {
+ if (RecordIsMemberOfSet(pRCAP->pDeviceEventSet,
+ pev->u.u.type & 0177))
+ {
+ xEvent swappedEvent;
+ xEvent *pEvToRecord = pev;
+#ifdef PANORAMIX
+ xEvent shiftedEvent;
+
+ if (!noPanoramiXExtension &&
+ (pev->u.u.type == MotionNotify ||
+ pev->u.u.type == ButtonPress ||
+ pev->u.u.type == ButtonRelease ||
+ pev->u.u.type == KeyPress ||
+ pev->u.u.type == KeyRelease)) {
+ int scr = XineramaGetCursorScreen(inputInfo.pointer);
+ memcpy(&shiftedEvent, pev, sizeof(xEvent));
+ shiftedEvent.u.keyButtonPointer.rootX +=
+ screenInfo.screens[scr]->x -
+ screenInfo.screens[0]->x;
+ shiftedEvent.u.keyButtonPointer.rootY +=
+ screenInfo.screens[scr]->y -
+ screenInfo.screens[0]->y;
+ pEvToRecord = &shiftedEvent;
+ }
+#endif /* PANORAMIX */
+
+ if (pContext->pRecordingClient->swapped)
+ {
+ (*EventSwapVector[pEvToRecord->u.u.type & 0177])
+ (pEvToRecord, &swappedEvent);
+ pEvToRecord = &swappedEvent;
+ }
+
+ RecordAProtocolElement(pContext, NULL,
+ XRecordFromServer, pEvToRecord, SIZEOF(xEvent), 0);
+ /* make sure device events get flushed in the absence
+ * of other client activity
+ */
+ SetCriticalOutputPending();
+ }
+ } /* end for each event */
+
+} /* RecordADeviceEvent */
+
+/* RecordADeviceEvent
+ *
+ * Arguments:
+ * pcbl is &DeviceEventCallback.
+ * nulldata is NULL.
+ * calldata is a pointer to a DeviceEventInfoRec (include/dix.h)
+ * which provides information about device events that occur.
+ *
+ * Returns: nothing.
+ *
+ * Side Effects:
+ * The device event is recorded by all contexts that have registered
+ * it for this client.
+ */
+static void
+RecordADeviceEvent(CallbackListPtr *pcbl, pointer nulldata, pointer calldata)
+{
+ DeviceEventInfoRec *pei = (DeviceEventInfoRec *)calldata;
+ RecordContextPtr pContext;
+ RecordClientsAndProtocolPtr pRCAP;
+ int eci; /* enabled context index */
+
+ for (eci = 0; eci < numEnabledContexts; eci++)
+ {
+ pContext = ppAllContexts[eci];
+ for (pRCAP = pContext->pListOfRCAP; pRCAP; pRCAP = pRCAP->pNextRCAP)
+ {
+ if (pRCAP->pDeviceEventSet)
+ {
+ int count;
+ xEvent *xi_events = NULL;
+
+ /* TODO check return values */
+ if (IsMaster(pei->device))
+ {
+ xEvent *core_events;
+ EventToCore(pei->event, &core_events, &count);
+ RecordSendProtocolEvents(pRCAP, pContext, core_events,
+ count);
+ free(core_events);
+ }
+
+ EventToXI(pei->event, &xi_events, &count);
+ RecordSendProtocolEvents(pRCAP, pContext, xi_events, count);
+ free(xi_events);
+ } /* end this RCAP selects device events */
+ } /* end for each RCAP on this context */
+ } /* end for each enabled context */
+}
+
+
+/* RecordFlushAllContexts
+ *
+ * Arguments:
+ * pcbl is &FlushCallback.
+ * nulldata and calldata are NULL.
+ *
+ * Returns: nothing.
+ *
+ * Side Effects:
+ * All buffered reply data of all enabled contexts is written to
+ * the recording clients.
+ */
+static void
+RecordFlushAllContexts(
+ CallbackListPtr *pcbl,
+ pointer nulldata,
+ pointer calldata
+)
+{
+ int eci; /* enabled context index */
+ RecordContextPtr pContext;
+
+ for (eci = 0; eci < numEnabledContexts; eci++)
+ {
+ pContext = ppAllContexts[eci];
+
+ /* In most cases we leave it to RecordFlushReplyBuffer to make
+ * this check, but this function could be called very often, so we
+ * check before calling hoping to save the function call cost
+ * most of the time.
+ */
+ if (pContext->numBufBytes)
+ RecordFlushReplyBuffer(ppAllContexts[eci], NULL, 0, NULL, 0);
+ }
+} /* RecordFlushAllContexts */
+
+
+/* RecordInstallHooks
+ *
+ * Arguments:
+ * pRCAP is an RCAP on an enabled or being-enabled context.
+ * oneclient can be zero or the resource ID mask identifying a client.
+ *
+ * Returns: BadAlloc if a memory allocation error occurred, else Success.
+ *
+ * Side Effects:
+ * Recording hooks needed by RCAP are installed.
+ * If oneclient is zero, recording hooks needed for all clients and
+ * protocol on the RCAP are installed. If oneclient is non-zero,
+ * only those hooks needed for the specified client are installed.
+ *
+ * Client requestVectors may be altered. numEnabledRCAPs will be
+ * incremented if oneclient == 0. Callbacks may be added to
+ * various callback lists.
+ */
+static int
+RecordInstallHooks(RecordClientsAndProtocolPtr pRCAP, XID oneclient)
+{
+ int i = 0;
+ XID client;
+
+ if (oneclient)
+ client = oneclient;
+ else
+ client = pRCAP->numClients ? pRCAP->pClientIDs[i++] : 0;
+
+ while (client)
+ {
+ if (client != XRecordFutureClients)
+ {
+ if (pRCAP->pRequestMajorOpSet)
+ {
+ RecordSetIteratePtr pIter = NULL;
+ RecordSetInterval interval;
+ ClientPtr pClient = clients[CLIENT_ID(client)];
+
+ if (pClient && !RecordClientPrivate(pClient))
+ {
+ RecordClientPrivatePtr pClientPriv;
+ /* no Record proc vector; allocate one */
+ pClientPriv = (RecordClientPrivatePtr)
+ malloc(sizeof(RecordClientPrivateRec));
+ if (!pClientPriv)
+ return BadAlloc;
+ /* copy old proc vector to new */
+ memcpy(pClientPriv->recordVector, pClient->requestVector,
+ sizeof (pClientPriv->recordVector));
+ pClientPriv->originalVector = pClient->requestVector;
+ dixSetPrivate(&pClient->devPrivates,
+ RecordClientPrivateKey, pClientPriv);
+ pClient->requestVector = pClientPriv->recordVector;
+ }
+ while ((pIter = RecordIterateSet(pRCAP->pRequestMajorOpSet,
+ pIter, &interval)))
+ {
+ unsigned int j;
+ for (j = interval.first; j <= interval.last; j++)
+ pClient->requestVector[j] = RecordARequest;
+ }
+ }
+ }
+ if (oneclient)
+ client = 0;
+ else
+ client = (i < pRCAP->numClients) ? pRCAP->pClientIDs[i++] : 0;
+ }
+
+ assert(numEnabledRCAPs >= 0);
+ if (!oneclient && ++numEnabledRCAPs == 1)
+ { /* we're enabling the first context */
+ if (!AddCallback(&EventCallback, RecordADeliveredEventOrError, NULL))
+ return BadAlloc;
+ if (!AddCallback(&DeviceEventCallback, RecordADeviceEvent, NULL))
+ return BadAlloc;
+ if (!AddCallback(&ReplyCallback, RecordAReply, NULL))
+ return BadAlloc;
+ if (!AddCallback(&FlushCallback, RecordFlushAllContexts, NULL))
+ return BadAlloc;
+ /* Alternate context flushing scheme: delete the line above
+ * and call RegisterBlockAndWakeupHandlers here passing
+ * RecordFlushAllContexts. Is this any better?
+ */
+ }
+ return Success;
+} /* RecordInstallHooks */
+
+
+/* RecordUninstallHooks
+ *
+ * Arguments:
+ * pRCAP is an RCAP on an enabled or being-disabled context.
+ * oneclient can be zero or the resource ID mask identifying a client.
+ *
+ * Returns: nothing.
+ *
+ * Side Effects:
+ * Recording hooks needed by RCAP may be uninstalled.
+ * If oneclient is zero, recording hooks needed for all clients and
+ * protocol on the RCAP may be uninstalled. If oneclient is non-zero,
+ * only those hooks needed for the specified client may be uninstalled.
+ *
+ * Client requestVectors may be altered. numEnabledRCAPs will be
+ * decremented if oneclient == 0. Callbacks may be deleted from
+ * various callback lists.
+ */
+static void
+RecordUninstallHooks(RecordClientsAndProtocolPtr pRCAP, XID oneclient)
+{
+ int i = 0;
+ XID client;
+
+ if (oneclient)
+ client = oneclient;
+ else
+ client = pRCAP->numClients ? pRCAP->pClientIDs[i++] : 0;
+
+ while (client)
+ {
+ if (client != XRecordFutureClients)
+ {
+ if (pRCAP->pRequestMajorOpSet)
+ {
+ ClientPtr pClient = clients[CLIENT_ID(client)];
+ int c;
+ Bool otherRCAPwantsProcVector = FALSE;
+ RecordClientPrivatePtr pClientPriv = NULL;
+
+ assert (pClient);
+ pClientPriv = RecordClientPrivate(pClient);
+ assert (pClientPriv);
+ memcpy(pClientPriv->recordVector, pClientPriv->originalVector,
+ sizeof (pClientPriv->recordVector));
+
+ for (c = 0; c < numEnabledContexts; c++)
+ {
+ RecordClientsAndProtocolPtr pOtherRCAP;
+ RecordContextPtr pContext = ppAllContexts[c];
+
+ if (pContext == pRCAP->pContext) continue;
+ pOtherRCAP = RecordFindClientOnContext(pContext, client,
+ NULL);
+ if (pOtherRCAP && pOtherRCAP->pRequestMajorOpSet)
+ {
+ RecordSetIteratePtr pIter = NULL;
+ RecordSetInterval interval;
+
+ otherRCAPwantsProcVector = TRUE;
+ while ((pIter = RecordIterateSet(
+ pOtherRCAP->pRequestMajorOpSet,
+ pIter, &interval)))
+ {
+ unsigned int j;
+ for (j = interval.first; j <= interval.last; j++)
+ pClient->requestVector[j] = RecordARequest;
+ }
+ }
+ }
+ if (!otherRCAPwantsProcVector)
+ { /* nobody needs it, so free it */
+ pClient->requestVector = pClientPriv->originalVector;
+ dixSetPrivate(&pClient->devPrivates,
+ RecordClientPrivateKey, NULL);
+ free(pClientPriv);
+ }
+ } /* end if this RCAP specifies any requests */
+ } /* end if not future clients */
+ if (oneclient)
+ client = 0;
+ else
+ client = (i < pRCAP->numClients) ? pRCAP->pClientIDs[i++] : 0;
+ }
+
+ assert(numEnabledRCAPs >= 1);
+ if (!oneclient && --numEnabledRCAPs == 0)
+ { /* we're disabling the last context */
+ DeleteCallback(&EventCallback, RecordADeliveredEventOrError, NULL);
+ DeleteCallback(&DeviceEventCallback, RecordADeviceEvent, NULL);
+ DeleteCallback(&ReplyCallback, RecordAReply, NULL);
+ DeleteCallback(&FlushCallback, RecordFlushAllContexts, NULL);
+ /* Alternate context flushing scheme: delete the line above
+ * and call RemoveBlockAndWakeupHandlers here passing
+ * RecordFlushAllContexts. Is this any better?
+ */
+ /* Having deleted the callback, call it one last time. -gildea */
+ RecordFlushAllContexts(&FlushCallback, NULL, NULL);
+ }
+} /* RecordUninstallHooks */
+
+
+/* RecordDeleteClientFromRCAP
+ *
+ * Arguments:
+ * pRCAP is an RCAP to delete the client from.
+ * position is the index into the array pRCAP->pClientIDs of the
+ * client to delete.
+ *
+ * Returns: nothing.
+ *
+ * Side Effects:
+ * Recording hooks needed by client will be uninstalled if the context
+ * is enabled. The designated client will be removed from the
+ * pRCAP->pClientIDs array. If it was the only client on the RCAP,
+ * the RCAP is removed from the context and freed. (Invariant: RCAPs
+ * have at least one client.)
+ */
+static void
+RecordDeleteClientFromRCAP(RecordClientsAndProtocolPtr pRCAP, int position)
+{
+ if (pRCAP->pContext->pRecordingClient)
+ RecordUninstallHooks(pRCAP, pRCAP->pClientIDs[position]);
+ if (position != pRCAP->numClients - 1)
+ pRCAP->pClientIDs[position] = pRCAP->pClientIDs[pRCAP->numClients - 1];
+ if (--pRCAP->numClients == 0)
+ { /* no more clients; remove RCAP from context's list */
+ RecordContextPtr pContext = pRCAP->pContext;
+ if (pContext->pRecordingClient)
+ RecordUninstallHooks(pRCAP, 0);
+ if (pContext->pListOfRCAP == pRCAP)
+ pContext->pListOfRCAP = pRCAP->pNextRCAP;
+ else
+ {
+ RecordClientsAndProtocolPtr prevRCAP;
+ for (prevRCAP = pContext->pListOfRCAP;
+ prevRCAP->pNextRCAP != pRCAP;
+ prevRCAP = prevRCAP->pNextRCAP)
+ ;
+ prevRCAP->pNextRCAP = pRCAP->pNextRCAP;
+ }
+ /* free the RCAP */
+ if (pRCAP->clientIDsSeparatelyAllocated)
+ free(pRCAP->pClientIDs);
+ free(pRCAP);
+ }
+} /* RecordDeleteClientFromRCAP */
+
+
+/* RecordAddClientToRCAP
+ *
+ * Arguments:
+ * pRCAP is an RCAP to add the client to.
+ * clientspec is the resource ID mask identifying a client, or
+ * XRecordFutureClients.
+ *
+ * Returns: nothing.
+ *
+ * Side Effects:
+ * Recording hooks needed by client will be installed if the context
+ * is enabled. The designated client will be added to the
+ * pRCAP->pClientIDs array, which may be realloced.
+ * pRCAP->clientIDsSeparatelyAllocated may be set to 1 if there
+ * is no more room to hold clients internal to the RCAP.
+ */
+static void
+RecordAddClientToRCAP(RecordClientsAndProtocolPtr pRCAP, XID clientspec)
+{
+ if (pRCAP->numClients == pRCAP->sizeClients)
+ {
+ if (pRCAP->clientIDsSeparatelyAllocated)
+ {
+ XID *pNewIDs = (XID *)realloc(pRCAP->pClientIDs,
+ (pRCAP->sizeClients + CLIENT_ARRAY_GROWTH_INCREMENT) *
+ sizeof(XID));
+ if (!pNewIDs)
+ return;
+ pRCAP->pClientIDs = pNewIDs;
+ pRCAP->sizeClients += CLIENT_ARRAY_GROWTH_INCREMENT;
+ }
+ else
+ {
+ XID *pNewIDs = (XID *)malloc((pRCAP->sizeClients +
+ CLIENT_ARRAY_GROWTH_INCREMENT) * sizeof(XID));
+ if (!pNewIDs)
+ return;
+ memcpy(pNewIDs, pRCAP->pClientIDs, pRCAP->numClients *sizeof(XID));
+ pRCAP->pClientIDs = pNewIDs;
+ pRCAP->sizeClients += CLIENT_ARRAY_GROWTH_INCREMENT;
+ pRCAP->clientIDsSeparatelyAllocated = 1;
+ }
+ }
+ pRCAP->pClientIDs[pRCAP->numClients++] = clientspec;
+ if (pRCAP->pContext->pRecordingClient)
+ RecordInstallHooks(pRCAP, clientspec);
+} /* RecordDeleteClientFromRCAP */
+
+
+/* RecordDeleteClientFromContext
+ *
+ * Arguments:
+ * pContext is the context to delete from.
+ * clientspec is the resource ID mask identifying a client, or
+ * XRecordFutureClients.
+ *
+ * Returns: nothing.
+ *
+ * Side Effects:
+ * If clientspec is on any RCAP of the context, it is deleted from that
+ * RCAP. (A given clientspec can only be on one RCAP of a context.)
+ */
+static void
+RecordDeleteClientFromContext(RecordContextPtr pContext, XID clientspec)
+{
+ RecordClientsAndProtocolPtr pRCAP;
+ int position;
+
+ if ((pRCAP = RecordFindClientOnContext(pContext, clientspec, &position)))
+ RecordDeleteClientFromRCAP(pRCAP, position);
+} /* RecordDeleteClientFromContext */
+
+
+/* RecordSanityCheckClientSpecifiers
+ *
+ * Arguments:
+ * clientspecs is an array of alleged CLIENTSPECs passed by the client.
+ * nspecs is the number of elements in clientspecs.
+ * errorspec, if non-zero, is the resource id base of a client that
+ * must not appear in clienspecs.
+ *
+ * Returns: BadMatch if any of the clientspecs are invalid, else Success.
+ *
+ * Side Effects: none.
+ */
+static int
+RecordSanityCheckClientSpecifiers(ClientPtr client, XID *clientspecs, int nspecs, XID errorspec)
+{
+ int i;
+ int clientIndex;
+ int rc;
+ pointer value;
+
+ for (i = 0; i < nspecs; i++)
+ {
+ if (clientspecs[i] == XRecordCurrentClients ||
+ clientspecs[i] == XRecordFutureClients ||
+ clientspecs[i] == XRecordAllClients)
+ continue;
+ if (errorspec && (CLIENT_BITS(clientspecs[i]) == errorspec) )
+ return BadMatch;
+ clientIndex = CLIENT_ID(clientspecs[i]);
+ if (clientIndex && clients[clientIndex] &&
+ clients[clientIndex]->clientState == ClientStateRunning)
+ {
+ if (clientspecs[i] == clients[clientIndex]->clientAsMask)
+ continue;
+ rc = dixLookupResourceByClass(&value, clientspecs[i], RC_ANY,
+ client, DixGetAttrAccess);
+ if (rc != Success)
+ return rc;
+ }
+ else
+ return BadMatch;
+ }
+ return Success;
+} /* RecordSanityCheckClientSpecifiers */
+
+
+/* RecordCanonicalizeClientSpecifiers
+ *
+ * Arguments:
+ * pClientspecs is an array of CLIENTSPECs that have been sanity
+ * checked.
+ * pNumClientspecs is a pointer to the number of elements in pClientspecs.
+ * excludespec, if non-zero, is the resource id base of a client that
+ * should not be included in the expansion of XRecordAllClients or
+ * XRecordCurrentClients.
+ *
+ * Returns:
+ * A pointer to an array of CLIENTSPECs that is the same as the
+ * passed array with the following modifications:
+ * - all but the client id bits of resource IDs are stripped off.
+ * - duplicates removed.
+ * - XRecordAllClients expanded to a list of all currently connected
+ * clients + XRecordFutureClients - excludespec (if non-zero)
+ * - XRecordCurrentClients expanded to a list of all currently
+ * connected clients - excludespec (if non-zero)
+ * The returned array may be the passed array modified in place, or
+ * it may be an malloc'ed array. The caller should keep a pointer to the
+ * original array and free the returned array if it is different.
+ *
+ * *pNumClientspecs is set to the number of elements in the returned
+ * array.
+ *
+ * Side Effects:
+ * pClientspecs may be modified in place.
+ */
+static XID *
+RecordCanonicalizeClientSpecifiers(XID *pClientspecs, int *pNumClientspecs, XID excludespec)
+{
+ int i;
+ int numClients = *pNumClientspecs;
+
+ /* first pass strips off the resource index bits, leaving just the
+ * client id bits. This makes searching for a particular client simpler
+ * (and faster.)
+ */
+ for (i = 0; i < numClients; i++)
+ {
+ XID cs = pClientspecs[i];
+ if (cs > XRecordAllClients)
+ pClientspecs[i] = CLIENT_BITS(cs);
+ }
+
+ for (i = 0; i < numClients; i++)
+ {
+ if (pClientspecs[i] == XRecordAllClients ||
+ pClientspecs[i] == XRecordCurrentClients)
+ { /* expand All/Current */
+ int j, nc;
+ XID *pCanon = (XID *)malloc(sizeof(XID) * (currentMaxClients + 1));
+ if (!pCanon) return NULL;
+ for (nc = 0, j = 1; j < currentMaxClients; j++)
+ {
+ ClientPtr client = clients[j];
+ if (client != NullClient &&
+ client->clientState == ClientStateRunning &&
+ client->clientAsMask != excludespec)
+ {
+ pCanon[nc++] = client->clientAsMask;
+ }
+ }
+ if (pClientspecs[i] == XRecordAllClients)
+ pCanon[nc++] = XRecordFutureClients;
+ *pNumClientspecs = nc;
+ return pCanon;
+ }
+ else /* not All or Current */
+ {
+ int j;
+ for (j = i + 1; j < numClients; )
+ {
+ if (pClientspecs[i] == pClientspecs[j])
+ {
+ pClientspecs[j] = pClientspecs[--numClients];
+ }
+ else
+ j++;
+ }
+ }
+ } /* end for each clientspec */
+ *pNumClientspecs = numClients;
+ return pClientspecs;
+} /* RecordCanonicalizeClientSpecifiers */
+
+
+/****************************************************************************/
+
+/* stuff for RegisterClients */
+
+/* RecordPadAlign
+ *
+ * Arguments:
+ * size is the number of bytes taken by an object.
+ * align is a byte boundary (e.g. 4, 8)
+ *
+ * Returns:
+ * the number of pad bytes to add at the end of an object of the
+ * given size so that an object placed immediately behind it will
+ * begin on an <align>-byte boundary.
+ *
+ * Side Effects: none.
+ */
+static int
+RecordPadAlign(int size, int align)
+{
+ return (align - (size & (align - 1))) & (align - 1);
+} /* RecordPadAlign */
+
+
+/* RecordSanityCheckRegisterClients
+ *
+ * Arguments:
+ * pContext is the context being registered on.
+ * client is the client that issued a RecordCreateContext or
+ * RecordRegisterClients request.
+ * stuff is a pointer to the request.
+ *
+ * Returns:
+ * Any one of several possible error values if any of the request
+ * arguments are invalid. Success if everything is OK.
+ *
+ * Side Effects: none.
+ */
+static int
+RecordSanityCheckRegisterClients(RecordContextPtr pContext, ClientPtr client, xRecordRegisterClientsReq *stuff)
+{
+ int err;
+ xRecordRange *pRange;
+ int i;
+ XID recordingClient;
+
+ if (((client->req_len << 2) - SIZEOF(xRecordRegisterClientsReq)) !=
+ 4 * stuff->nClients + SIZEOF(xRecordRange) * stuff->nRanges)
+ return BadLength;
+
+ if (stuff->elementHeader &
+ ~(XRecordFromClientSequence|XRecordFromClientTime|XRecordFromServerTime))
+ {
+ client->errorValue = stuff->elementHeader;
+ return BadValue;
+ }
+
+ recordingClient = pContext->pRecordingClient ?
+ pContext->pRecordingClient->clientAsMask : 0;
+ err = RecordSanityCheckClientSpecifiers(client, (XID *)&stuff[1],
+ stuff->nClients, recordingClient);
+ if (err != Success) return err;
+
+ pRange = (xRecordRange *)(((XID *)&stuff[1]) + stuff->nClients);
+ for (i = 0; i < stuff->nRanges; i++, pRange++)
+ {
+ if (pRange->coreRequestsFirst > pRange->coreRequestsLast)
+ {
+ client->errorValue = pRange->coreRequestsFirst;
+ return BadValue;
+ }
+ if (pRange->coreRepliesFirst > pRange->coreRepliesLast)
+ {
+ client->errorValue = pRange->coreRepliesFirst;
+ return BadValue;
+ }
+ if ((pRange->extRequestsMajorFirst || pRange->extRequestsMajorLast) &&
+ (pRange->extRequestsMajorFirst < 128 ||
+ pRange->extRequestsMajorLast < 128 ||
+ pRange->extRequestsMajorFirst > pRange->extRequestsMajorLast))
+ {
+ client->errorValue = pRange->extRequestsMajorFirst;
+ return BadValue;
+ }
+ if (pRange->extRequestsMinorFirst > pRange->extRequestsMinorLast)
+ {
+ client->errorValue = pRange->extRequestsMinorFirst;
+ return BadValue;
+ }
+ if ((pRange->extRepliesMajorFirst || pRange->extRepliesMajorLast) &&
+ (pRange->extRepliesMajorFirst < 128 ||
+ pRange->extRepliesMajorLast < 128 ||
+ pRange->extRepliesMajorFirst > pRange->extRepliesMajorLast))
+ {
+ client->errorValue = pRange->extRepliesMajorFirst;
+ return BadValue;
+ }
+ if (pRange->extRepliesMinorFirst > pRange->extRepliesMinorLast)
+ {
+ client->errorValue = pRange->extRepliesMinorFirst;
+ return BadValue;
+ }
+ if ((pRange->deliveredEventsFirst || pRange->deliveredEventsLast) &&
+ (pRange->deliveredEventsFirst < 2 ||
+ pRange->deliveredEventsLast < 2 ||
+ pRange->deliveredEventsFirst > pRange->deliveredEventsLast))
+ {
+ client->errorValue = pRange->deliveredEventsFirst;
+ return BadValue;
+ }
+ if ((pRange->deviceEventsFirst || pRange->deviceEventsLast) &&
+ (pRange->deviceEventsFirst < 2 ||
+ pRange->deviceEventsLast < 2 ||
+ pRange->deviceEventsFirst > pRange->deviceEventsLast))
+ {
+ client->errorValue = pRange->deviceEventsFirst;
+ return BadValue;
+ }
+ if (pRange->errorsFirst > pRange->errorsLast)
+ {
+ client->errorValue = pRange->errorsFirst;
+ return BadValue;
+ }
+ if (pRange->clientStarted != xFalse && pRange->clientStarted != xTrue)
+ {
+ client->errorValue = pRange->clientStarted;
+ return BadValue;
+ }
+ if (pRange->clientDied != xFalse && pRange->clientDied != xTrue)
+ {
+ client->errorValue = pRange->clientDied;
+ return BadValue;
+ }
+ } /* end for each range */
+ return Success;
+} /* end RecordSanityCheckRegisterClients */
+
+/* This is a tactical structure used to gather information about all the sets
+ * (RecordSetPtr) that need to be created for an RCAP in the process of
+ * digesting a list of RECORDRANGEs (converting it to the internal
+ * representation).
+ */
+typedef struct
+{
+ int nintervals; /* number of intervals in following array */
+ RecordSetInterval *intervals; /* array of intervals for this set */
+ int size; /* size of intevals array; >= nintervals */
+ int align; /* alignment restriction for set */
+ int offset; /* where to store set pointer rel. to start of RCAP */
+ short first, last; /* if for extension, major opcode interval */
+} SetInfoRec, *SetInfoPtr;
+
+/* These constant are used to index into an array of SetInfoRec. */
+enum {REQ, /* set info for requests */
+ REP, /* set info for replies */
+ ERR, /* set info for errors */
+ DEV, /* set info for device events */
+ DLEV, /* set info for delivered events */
+ PREDEFSETS}; /* number of predefined array entries */
+
+
+/* RecordAllocIntervals
+ *
+ * Arguments:
+ * psi is a pointer to a SetInfoRec whose intervals pointer is NULL.
+ * nIntervals is the desired size of the intervals array.
+ *
+ * Returns: BadAlloc if a memory allocation error occurred, else Success.
+ *
+ * Side Effects:
+ * If Success is returned, psi->intervals is a pointer to size
+ * RecordSetIntervals, all zeroed, and psi->size is set to size.
+ */
+static int
+RecordAllocIntervals(SetInfoPtr psi, int nIntervals)
+{
+ assert(!psi->intervals);
+ psi->intervals = (RecordSetInterval *)
+ malloc(nIntervals * sizeof(RecordSetInterval));
+ if (!psi->intervals)
+ return BadAlloc;
+ memset(psi->intervals, 0, nIntervals * sizeof(RecordSetInterval));
+ psi->size = nIntervals;
+ return Success;
+} /* end RecordAllocIntervals */
+
+
+/* RecordConvertRangesToIntervals
+ *
+ * Arguments:
+ * psi is a pointer to the SetInfoRec we are building.
+ * pRanges is an array of xRecordRanges.
+ * nRanges is the number of elements in pRanges.
+ * byteoffset is the offset from the start of an xRecordRange of the
+ * two bytes (1 for first, 1 for last) we are interested in.
+ * pExtSetInfo, if non-NULL, indicates that the two bytes mentioned
+ * above are followed by four bytes (2 for first, 2 for last)
+ * representing a minor opcode range, and this information should be
+ * stored in one of the SetInfoRecs starting at pExtSetInfo.
+ * pnExtSetInfo is the number of elements in the pExtSetInfo array.
+ *
+ * Returns: BadAlloc if a memory allocation error occurred, else Success.
+ *
+ * Side Effects:
+ * The slice of pRanges indicated by byteoffset is stored in psi.
+ * If pExtSetInfo is non-NULL, minor opcode intervals are stored
+ * in an existing SetInfoRec if the major opcode interval matches, else
+ * they are stored in a new SetInfoRec, and *pnExtSetInfo is
+ * increased accordingly.
+ */
+static int
+RecordConvertRangesToIntervals(
+ SetInfoPtr psi,
+ xRecordRange *pRanges,
+ int nRanges,
+ int byteoffset,
+ SetInfoPtr pExtSetInfo,
+ int *pnExtSetInfo
+)
+{
+ int i;
+ CARD8 *pCARD8;
+ int first, last;
+ int err;
+
+ for (i = 0; i < nRanges; i++, pRanges++)
+ {
+ pCARD8 = ((CARD8 *)pRanges) + byteoffset;
+ first = pCARD8[0];
+ last = pCARD8[1];
+ if (first || last)
+ {
+ if (!psi->intervals)
+ {
+ err = RecordAllocIntervals(psi, 2 * (nRanges - i));
+ if (err != Success)
+ return err;
+ }
+ psi->intervals[psi->nintervals].first = first;
+ psi->intervals[psi->nintervals].last = last;
+ psi->nintervals++;
+ assert(psi->nintervals <= psi->size);
+ if (pExtSetInfo)
+ {
+ SetInfoPtr pesi = pExtSetInfo;
+ CARD16 *pCARD16 = (CARD16 *)(pCARD8 + 2);
+ int j;
+
+ for (j = 0; j < *pnExtSetInfo; j++, pesi++)
+ {
+ if ( (first == pesi->first) && (last == pesi->last) )
+ break;
+ }
+ if (j == *pnExtSetInfo)
+ {
+ err = RecordAllocIntervals(pesi, 2 * (nRanges - i));
+ if (err != Success)
+ return err;
+ pesi->first = first;
+ pesi->last = last;
+ (*pnExtSetInfo)++;
+ }
+ pesi->intervals[pesi->nintervals].first = pCARD16[0];
+ pesi->intervals[pesi->nintervals].last = pCARD16[1];
+ pesi->nintervals++;
+ assert(pesi->nintervals <= pesi->size);
+ }
+ }
+ }
+ return Success;
+} /* end RecordConvertRangesToIntervals */
+
+#define offset_of(_structure, _field) \
+ ((char *)(& (_structure . _field)) - (char *)(&_structure))
+
+/* RecordRegisterClients
+ *
+ * Arguments:
+ * pContext is the context on which to register the clients.
+ * client is the client that issued the RecordCreateContext or
+ * RecordRegisterClients request.
+ * stuff is a pointer to the request.
+ *
+ * Returns:
+ * Any one of several possible error values defined by the protocol.
+ * Success if everything is OK.
+ *
+ * Side Effects:
+ * If different element headers are specified, the context is flushed.
+ * If any of the specified clients are already registered on the
+ * context, they are first unregistered. A new RCAP is created to
+ * hold the specified protocol and clients, and it is linked onto the
+ * context. If the context is enabled, appropriate hooks are installed
+ * to record the new clients and protocol.
+ */
+static int
+RecordRegisterClients(RecordContextPtr pContext, ClientPtr client, xRecordRegisterClientsReq *stuff)
+{
+ int err;
+ int i;
+ SetInfoPtr si;
+ int maxSets;
+ int nExtReqSets = 0;
+ int nExtRepSets = 0;
+ int extReqSetsOffset = 0;
+ int extRepSetsOffset = 0;
+ SetInfoPtr pExtReqSets, pExtRepSets;
+ int clientListOffset;
+ XID *pCanonClients;
+ int clientStarted = 0, clientDied = 0;
+ xRecordRange *pRanges, rr;
+ int nClients;
+ int sizeClients;
+ int totRCAPsize;
+ RecordClientsAndProtocolPtr pRCAP;
+ int pad;
+ XID recordingClient;
+
+ /* do all sanity checking up front */
+
+ err = RecordSanityCheckRegisterClients(pContext, client, stuff);
+ if (err != Success)
+ return err;
+
+ /* if element headers changed, flush buffer */
+
+ if (pContext->elemHeaders != stuff->elementHeader)
+ {
+ RecordFlushReplyBuffer(pContext, NULL, 0, NULL, 0);
+ pContext->elemHeaders = stuff->elementHeader;
+ }
+
+ nClients = stuff->nClients;
+ if (!nClients)
+ /* if empty clients list, we're done. */
+ return Success;
+
+ recordingClient = pContext->pRecordingClient ?
+ pContext->pRecordingClient->clientAsMask : 0;
+ pCanonClients = RecordCanonicalizeClientSpecifiers((XID *)&stuff[1],
+ &nClients, recordingClient);
+ if (!pCanonClients)
+ return BadAlloc;
+
+ /* We may have to create as many as one set for each "predefined"
+ * protocol types, plus one per range for extension reuests, plus one per
+ * range for extension replies.
+ */
+ maxSets = PREDEFSETS + 2 * stuff->nRanges;
+ si = (SetInfoPtr)malloc(sizeof(SetInfoRec) * maxSets);
+ if (!si)
+ {
+ err = BadAlloc;
+ goto bailout;
+ }
+ memset(si, 0, sizeof(SetInfoRec) * maxSets);
+
+ /* theoretically you must do this because NULL may not be all-bits-zero */
+ for (i = 0; i < maxSets; i++)
+ si[i].intervals = NULL;
+
+ pExtReqSets = si + PREDEFSETS;
+ pExtRepSets = pExtReqSets + stuff->nRanges;
+
+ pRanges = (xRecordRange *)(((XID *)&stuff[1]) + stuff->nClients);
+
+ err = RecordConvertRangesToIntervals(&si[REQ], pRanges, stuff->nRanges,
+ offset_of(rr, coreRequestsFirst), NULL, NULL);
+ if (err != Success) goto bailout;
+
+ err = RecordConvertRangesToIntervals(&si[REQ], pRanges, stuff->nRanges,
+ offset_of(rr, extRequestsMajorFirst), pExtReqSets, &nExtReqSets);
+ if (err != Success) goto bailout;
+
+ err = RecordConvertRangesToIntervals(&si[REP], pRanges, stuff->nRanges,
+ offset_of(rr, coreRepliesFirst), NULL, NULL);
+ if (err != Success) goto bailout;
+
+ err = RecordConvertRangesToIntervals(&si[REP], pRanges, stuff->nRanges,
+ offset_of(rr, extRepliesMajorFirst), pExtRepSets, &nExtRepSets);
+ if (err != Success) goto bailout;
+
+ err = RecordConvertRangesToIntervals(&si[ERR], pRanges, stuff->nRanges,
+ offset_of(rr, errorsFirst), NULL, NULL);
+ if (err != Success) goto bailout;
+
+ err = RecordConvertRangesToIntervals(&si[DLEV], pRanges, stuff->nRanges,
+ offset_of(rr, deliveredEventsFirst), NULL, NULL);
+ if (err != Success) goto bailout;
+
+ err = RecordConvertRangesToIntervals(&si[DEV], pRanges, stuff->nRanges,
+ offset_of(rr, deviceEventsFirst), NULL, NULL);
+ if (err != Success) goto bailout;
+
+ /* collect client-started and client-died */
+
+ for (i = 0; i < stuff->nRanges; i++)
+ {
+ if (pRanges[i].clientStarted) clientStarted = TRUE;
+ if (pRanges[i].clientDied) clientDied = TRUE;
+ }
+
+ /* We now have all the information collected to create all the sets,
+ * and we can compute the total memory required for the RCAP.
+ */
+
+ totRCAPsize = sizeof(RecordClientsAndProtocolRec);
+
+ /* leave a little room to grow before forcing a separate allocation */
+ sizeClients = nClients + CLIENT_ARRAY_GROWTH_INCREMENT;
+ pad = RecordPadAlign(totRCAPsize, sizeof(XID));
+ clientListOffset = totRCAPsize + pad;
+ totRCAPsize += pad + sizeClients * sizeof(XID);
+
+ if (nExtReqSets)
+ {
+ pad = RecordPadAlign(totRCAPsize, sizeof(RecordSetPtr));
+ extReqSetsOffset = totRCAPsize + pad;
+ totRCAPsize += pad + (nExtReqSets + 1) * sizeof(RecordMinorOpRec);
+ }
+ if (nExtRepSets)
+ {
+ pad = RecordPadAlign(totRCAPsize, sizeof(RecordSetPtr));
+ extRepSetsOffset = totRCAPsize + pad;
+ totRCAPsize += pad + (nExtRepSets + 1) * sizeof(RecordMinorOpRec);
+ }
+
+ for (i = 0; i < maxSets; i++)
+ {
+ if (si[i].nintervals)
+ {
+ si[i].size = RecordSetMemoryRequirements(
+ si[i].intervals, si[i].nintervals, &si[i].align);
+ pad = RecordPadAlign(totRCAPsize, si[i].align);
+ si[i].offset = pad + totRCAPsize;
+ totRCAPsize += pad + si[i].size;
+ }
+ }
+
+ /* allocate memory for the whole RCAP */
+
+ pRCAP = (RecordClientsAndProtocolPtr)malloc(totRCAPsize);
+ if (!pRCAP)
+ {
+ err = BadAlloc;
+ goto bailout;
+ }
+
+ /* fill in the RCAP */
+
+ pRCAP->pContext = pContext;
+ pRCAP->pClientIDs = (XID *)((char *)pRCAP + clientListOffset);
+ pRCAP->numClients = nClients;
+ pRCAP->sizeClients = sizeClients;
+ pRCAP->clientIDsSeparatelyAllocated = 0;
+ for (i = 0; i < nClients; i++)
+ {
+ RecordDeleteClientFromContext(pContext, pCanonClients[i]);
+ pRCAP->pClientIDs[i] = pCanonClients[i];
+ }
+
+ /* create all the sets */
+
+ if (si[REQ].intervals)
+ {
+ pRCAP->pRequestMajorOpSet =
+ RecordCreateSet(si[REQ].intervals, si[REQ].nintervals,
+ (RecordSetPtr)((char *)pRCAP + si[REQ].offset), si[REQ].size);
+ }
+ else pRCAP->pRequestMajorOpSet = NULL;
+
+ if (si[REP].intervals)
+ {
+ pRCAP->pReplyMajorOpSet =
+ RecordCreateSet(si[REP].intervals, si[REP].nintervals,
+ (RecordSetPtr)((char *)pRCAP + si[REP].offset), si[REP].size);
+ }
+ else pRCAP->pReplyMajorOpSet = NULL;
+
+ if (si[ERR].intervals)
+ {
+ pRCAP->pErrorSet =
+ RecordCreateSet(si[ERR].intervals, si[ERR].nintervals,
+ (RecordSetPtr)((char *)pRCAP + si[ERR].offset), si[ERR].size);
+ }
+ else pRCAP->pErrorSet = NULL;
+
+ if (si[DEV].intervals)
+ {
+ pRCAP->pDeviceEventSet =
+ RecordCreateSet(si[DEV].intervals, si[DEV].nintervals,
+ (RecordSetPtr)((char *)pRCAP + si[DEV].offset), si[DEV].size);
+ }
+ else pRCAP->pDeviceEventSet = NULL;
+
+ if (si[DLEV].intervals)
+ {
+ pRCAP->pDeliveredEventSet =
+ RecordCreateSet(si[DLEV].intervals, si[DLEV].nintervals,
+ (RecordSetPtr)((char *)pRCAP + si[DLEV].offset), si[DLEV].size);
+ }
+ else pRCAP->pDeliveredEventSet = NULL;
+
+ if (nExtReqSets)
+ {
+ pRCAP->pRequestMinOpInfo = (RecordMinorOpPtr)
+ ((char *)pRCAP + extReqSetsOffset);
+ pRCAP->pRequestMinOpInfo[0].count = nExtReqSets;
+ for (i = 0; i < nExtReqSets; i++, pExtReqSets++)
+ {
+ pRCAP->pRequestMinOpInfo[i+1].major.first = pExtReqSets->first;
+ pRCAP->pRequestMinOpInfo[i+1].major.last = pExtReqSets->last;
+ pRCAP->pRequestMinOpInfo[i+1].major.pMinOpSet =
+ RecordCreateSet(pExtReqSets->intervals,
+ pExtReqSets->nintervals,
+ (RecordSetPtr)((char *)pRCAP + pExtReqSets->offset),
+ pExtReqSets->size);
+ }
+ }
+ else pRCAP->pRequestMinOpInfo = NULL;
+
+ if (nExtRepSets)
+ {
+ pRCAP->pReplyMinOpInfo = (RecordMinorOpPtr)
+ ((char *)pRCAP + extRepSetsOffset);
+ pRCAP->pReplyMinOpInfo[0].count = nExtRepSets;
+ for (i = 0; i < nExtRepSets; i++, pExtRepSets++)
+ {
+ pRCAP->pReplyMinOpInfo[i+1].major.first = pExtRepSets->first;
+ pRCAP->pReplyMinOpInfo[i+1].major.last = pExtRepSets->last;
+ pRCAP->pReplyMinOpInfo[i+1].major.pMinOpSet =
+ RecordCreateSet(pExtRepSets->intervals,
+ pExtRepSets->nintervals,
+ (RecordSetPtr)((char *)pRCAP + pExtRepSets->offset),
+ pExtRepSets->size);
+ }
+ }
+ else pRCAP->pReplyMinOpInfo = NULL;
+
+ pRCAP->clientStarted = clientStarted;
+ pRCAP->clientDied = clientDied;
+
+ /* link the RCAP onto the context */
+
+ pRCAP->pNextRCAP = pContext->pListOfRCAP;
+ pContext->pListOfRCAP = pRCAP;
+
+ if (pContext->pRecordingClient) /* context enabled */
+ RecordInstallHooks(pRCAP, 0);
+
+bailout:
+ if (si)
+ {
+ for (i = 0; i < maxSets; i++)
+ free(si[i].intervals);
+ free(si);
+ }
+ if (pCanonClients && pCanonClients != (XID *)&stuff[1])
+ free(pCanonClients);
+ return err;
+} /* RecordRegisterClients */
+
+
+/* Proc functions all take a client argument, execute the request in
+ * client->requestBuffer, and return a protocol error status.
+ */
+
+static int
+ProcRecordQueryVersion(ClientPtr client)
+{
+ /* REQUEST(xRecordQueryVersionReq); */
+ xRecordQueryVersionReply rep;
+ int n;
+
+ REQUEST_SIZE_MATCH(xRecordQueryVersionReq);
+ rep.type = X_Reply;
+ rep.sequenceNumber = client->sequence;
+ rep.length = 0;
+ rep.majorVersion = SERVER_RECORD_MAJOR_VERSION;
+ rep.minorVersion = SERVER_RECORD_MINOR_VERSION;
+ if(client->swapped)
+ {
+ swaps(&rep.sequenceNumber, n);
+ swaps(&rep.majorVersion, n);
+ swaps(&rep.minorVersion, n);
+ }
+ (void)WriteToClient(client, sizeof(xRecordQueryVersionReply),
+ (char *)&rep);
+ return Success;
+} /* ProcRecordQueryVersion */
+
+
+static int
+ProcRecordCreateContext(ClientPtr client)
+{
+ REQUEST(xRecordCreateContextReq);
+ RecordContextPtr pContext;
+ RecordContextPtr *ppNewAllContexts = NULL;
+ int err = BadAlloc;
+
+ REQUEST_AT_LEAST_SIZE(xRecordCreateContextReq);
+ LEGAL_NEW_RESOURCE(stuff->context, client);
+
+ pContext = (RecordContextPtr)malloc(sizeof(RecordContextRec));
+ if (!pContext)
+ goto bailout;
+
+ /* make sure there is room in ppAllContexts to store the new context */
+
+ ppNewAllContexts = (RecordContextPtr *)
+ realloc(ppAllContexts, sizeof(RecordContextPtr) * (numContexts + 1));
+ if (!ppNewAllContexts)
+ goto bailout;
+ ppAllContexts = ppNewAllContexts;
+
+ pContext->id = stuff->context;
+ pContext->pRecordingClient = NULL;
+ pContext->pListOfRCAP = NULL;
+ pContext->elemHeaders = 0;
+ pContext->bufCategory = 0;
+ pContext->numBufBytes = 0;
+ pContext->pBufClient = NULL;
+ pContext->continuedReply = 0;
+ pContext->inFlush = 0;
+
+ err = RecordRegisterClients(pContext, client,
+ (xRecordRegisterClientsReq *)stuff);
+ if (err != Success)
+ goto bailout;
+
+ if (AddResource(pContext->id, RTContext, pContext))
+ {
+ ppAllContexts[numContexts++] = pContext;
+ return Success;
+ }
+ else
+ {
+ RecordDeleteContext((pointer)pContext, pContext->id);
+ return BadAlloc;
+ }
+bailout:
+ free(pContext);
+ return err;
+} /* ProcRecordCreateContext */
+
+
+static int
+ProcRecordRegisterClients(ClientPtr client)
+{
+ RecordContextPtr pContext;
+ REQUEST(xRecordRegisterClientsReq);
+
+ REQUEST_AT_LEAST_SIZE(xRecordRegisterClientsReq);
+ VERIFY_CONTEXT(pContext, stuff->context, client);
+
+ return RecordRegisterClients(pContext, client, stuff);
+} /* ProcRecordRegisterClients */
+
+
+static int
+ProcRecordUnregisterClients(ClientPtr client)
+{
+ RecordContextPtr pContext;
+ int err;
+ REQUEST(xRecordUnregisterClientsReq);
+ XID *pCanonClients;
+ int nClients;
+ int i;
+
+ REQUEST_AT_LEAST_SIZE(xRecordUnregisterClientsReq);
+ if ((client->req_len << 2) - SIZEOF(xRecordUnregisterClientsReq) !=
+ 4 * stuff->nClients)
+ return BadLength;
+ VERIFY_CONTEXT(pContext, stuff->context, client);
+ err = RecordSanityCheckClientSpecifiers(client, (XID *)&stuff[1],
+ stuff->nClients, 0);
+ if (err != Success)
+ return err;
+
+ nClients = stuff->nClients;
+ pCanonClients = RecordCanonicalizeClientSpecifiers((XID *)&stuff[1],
+ &nClients, 0);
+ if (!pCanonClients)
+ return BadAlloc;
+
+ for (i = 0; i < nClients; i++)
+ {
+ RecordDeleteClientFromContext(pContext, pCanonClients[i]);
+ }
+ if (pCanonClients != (XID *)&stuff[1])
+ free(pCanonClients);
+ return Success;
+} /* ProcRecordUnregisterClients */
+
+
+/****************************************************************************/
+
+/* stuff for GetContext */
+
+/* This is a tactical structure used to hold the xRecordRanges as they are
+ * being reconstituted from the sets in the RCAPs.
+ */
+
+typedef struct {
+ xRecordRange *pRanges; /* array of xRecordRanges for one RCAP */
+ int size; /* number of elements in pRanges, >= nRanges */
+ int nRanges; /* number of occupied element of pRanges */
+} GetContextRangeInfoRec, *GetContextRangeInfoPtr;
+
+
+/* RecordAllocRanges
+ *
+ * Arguments:
+ * pri is a pointer to a GetContextRangeInfoRec to allocate for.
+ * nRanges is the number of xRecordRanges desired for pri.
+ *
+ * Returns: BadAlloc if a memory allocation error occurred, else Success.
+ *
+ * Side Effects:
+ * If Success is returned, pri->pRanges points to at least nRanges
+ * ranges. pri->nRanges is set to nRanges. pri->size is the actual
+ * number of ranges. Newly allocated ranges are zeroed.
+ */
+static int
+RecordAllocRanges(GetContextRangeInfoPtr pri, int nRanges)
+{
+ int newsize;
+ xRecordRange *pNewRange;
+#define SZINCR 8
+
+ newsize = max(pri->size + SZINCR, nRanges);
+ pNewRange = (xRecordRange *)realloc(pri->pRanges,
+ newsize * sizeof(xRecordRange));
+ if (!pNewRange)
+ return BadAlloc;
+
+ pri->pRanges = pNewRange;
+ pri->size = newsize;
+ memset(&pri->pRanges[pri->size - SZINCR], 0, SZINCR * sizeof(xRecordRange));
+ if (pri->nRanges < nRanges)
+ pri->nRanges = nRanges;
+ return Success;
+} /* RecordAllocRanges */
+
+
+/* RecordConvertSetToRanges
+ *
+ * Arguments:
+ * pSet is the set to be converted.
+ * pri is where the result should be stored.
+ * byteoffset is the offset from the start of an xRecordRange of the
+ * two vales (first, last) we are interested in.
+ * card8 is TRUE if the vales are one byte each and FALSE if two bytes
+ * each.
+ * imax is the largest set value to store in pri->pRanges.
+ * pStartIndex, if non-NULL, is the index of the first range in
+ * pri->pRanges that should be stored to. If NULL,
+ * start at index 0.
+ *
+ * Returns: BadAlloc if a memory allocation error occurred, else Success.
+ *
+ * Side Effects:
+ * If Success is returned, the slice of pri->pRanges indicated by
+ * byteoffset and card8 is filled in with the intervals from pSet.
+ * if pStartIndex was non-NULL, *pStartIndex is filled in with one
+ * more than the index of the last xRecordRange that was touched.
+ */
+static int
+RecordConvertSetToRanges(
+ RecordSetPtr pSet,
+ GetContextRangeInfoPtr pri,
+ int byteoffset,
+ Bool card8,
+ unsigned int imax,
+ int *pStartIndex
+)
+{
+ int nRanges;
+ RecordSetIteratePtr pIter = NULL;
+ RecordSetInterval interval;
+ CARD8 *pCARD8;
+ CARD16 *pCARD16;
+ int err;
+
+ if (!pSet)
+ return Success;
+
+ nRanges = pStartIndex ? *pStartIndex : 0;
+ while ((pIter = RecordIterateSet(pSet, pIter, &interval)))
+ {
+ if (interval.first > imax) break;
+ if (interval.last > imax) interval.last = imax;
+ nRanges++;
+ if (nRanges > pri->size)
+ {
+ err = RecordAllocRanges(pri, nRanges);
+ if (err != Success)
+ return err;
+ }
+ else
+ pri->nRanges = max(pri->nRanges, nRanges);
+ if (card8)
+ {
+ pCARD8 = ((CARD8 *)&pri->pRanges[nRanges-1]) + byteoffset;
+ *pCARD8++ = interval.first;
+ *pCARD8 = interval.last;
+ }
+ else
+ {
+ pCARD16 = (CARD16 *)
+ (((char *)&pri->pRanges[nRanges-1]) + byteoffset);
+ *pCARD16++ = interval.first;
+ *pCARD16 = interval.last;
+ }
+ }
+ if (pStartIndex)
+ *pStartIndex = nRanges;
+ return Success;
+} /* RecordConvertSetToRanges */
+
+
+/* RecordConvertMinorOpInfoToRanges
+ *
+ * Arguments:
+ * pMinOpInfo is the minor opcode info to convert to xRecordRanges.
+ * pri is where the result should be stored.
+ * byteoffset is the offset from the start of an xRecordRange of the
+ * four vales (CARD8 major_first, CARD8 major_last,
+ * CARD16 minor_first, CARD16 minor_last) we are going to store.
+ *
+ * Returns: BadAlloc if a memory allocation error occurred, else Success.
+ *
+ * Side Effects:
+ * If Success is returned, the slice of pri->pRanges indicated by
+ * byteoffset is filled in with the information from pMinOpInfo.
+ */
+static int
+RecordConvertMinorOpInfoToRanges(
+ RecordMinorOpPtr pMinOpInfo,
+ GetContextRangeInfoPtr pri,
+ int byteoffset
+)
+{
+ int nsets;
+ int start;
+ int i;
+ int err;
+
+ if (!pMinOpInfo)
+ return Success;
+
+ nsets = pMinOpInfo->count;
+ pMinOpInfo++;
+ start = 0;
+ for (i = 0; i < nsets; i++)
+ {
+ int j, s;
+ s = start;
+ err = RecordConvertSetToRanges(pMinOpInfo[i].major.pMinOpSet, pri,
+ byteoffset + 2, FALSE, 65535, &start);
+ if (err != Success) return err;
+ for (j = s; j < start; j++)
+ {
+ CARD8 *pCARD8 = ((CARD8 *)&pri->pRanges[j]) + byteoffset;
+ *pCARD8++ = pMinOpInfo[i].major.first;
+ *pCARD8 = pMinOpInfo[i].major.last;
+ }
+ }
+ return Success;
+} /* RecordConvertMinorOpInfoToRanges */
+
+
+/* RecordSwapRanges
+ *
+ * Arguments:
+ * pRanges is an array of xRecordRanges.
+ * nRanges is the number of elements in pRanges.
+ *
+ * Returns: nothing.
+ *
+ * Side Effects:
+ * The 16 bit fields of each xRecordRange are byte swapped.
+ */
+static void
+RecordSwapRanges(xRecordRange *pRanges, int nRanges)
+{
+ int i;
+ register char n;
+ for (i = 0; i < nRanges; i++, pRanges++)
+ {
+ swaps(&pRanges->extRequestsMinorFirst, n);
+ swaps(&pRanges->extRequestsMinorLast, n);
+ swaps(&pRanges->extRepliesMinorFirst, n);
+ swaps(&pRanges->extRepliesMinorLast, n);
+ }
+} /* RecordSwapRanges */
+
+
+static int
+ProcRecordGetContext(ClientPtr client)
+{
+ RecordContextPtr pContext;
+ REQUEST(xRecordGetContextReq);
+ xRecordGetContextReply rep;
+ int n;
+ RecordClientsAndProtocolPtr pRCAP;
+ int nRCAPs = 0;
+ GetContextRangeInfoPtr pRangeInfo;
+ GetContextRangeInfoPtr pri;
+ int i;
+ int err;
+
+ REQUEST_SIZE_MATCH(xRecordGetContextReq);
+ VERIFY_CONTEXT(pContext, stuff->context, client);
+
+ /* how many RCAPs are there on this context? */
+
+ for (pRCAP = pContext->pListOfRCAP; pRCAP; pRCAP = pRCAP->pNextRCAP)
+ nRCAPs++;
+
+ /* allocate and initialize space for record range info */
+
+ pRangeInfo = (GetContextRangeInfoPtr)malloc(
+ nRCAPs * sizeof(GetContextRangeInfoRec));
+ if (!pRangeInfo && nRCAPs > 0)
+ return BadAlloc;
+ for (i = 0; i < nRCAPs; i++)
+ {
+ pRangeInfo[i].pRanges = NULL;
+ pRangeInfo[i].size = 0;
+ pRangeInfo[i].nRanges = 0;
+ }
+
+ /* convert the RCAP (internal) representation of the recorded protocol
+ * to the wire protocol (external) representation, storing the information
+ * for the ith RCAP in pri[i]
+ */
+
+ for (pRCAP = pContext->pListOfRCAP, pri = pRangeInfo;
+ pRCAP;
+ pRCAP = pRCAP->pNextRCAP, pri++)
+ {
+ xRecordRange rr;
+
+ err = RecordConvertSetToRanges(pRCAP->pRequestMajorOpSet, pri,
+ offset_of(rr, coreRequestsFirst), TRUE, 127, NULL);
+ if (err != Success) goto bailout;
+
+ err = RecordConvertSetToRanges(pRCAP->pReplyMajorOpSet, pri,
+ offset_of(rr, coreRepliesFirst), TRUE, 127, NULL);
+ if (err != Success) goto bailout;
+
+ err = RecordConvertSetToRanges(pRCAP->pDeliveredEventSet, pri,
+ offset_of(rr, deliveredEventsFirst), TRUE, 255, NULL);
+ if (err != Success) goto bailout;
+
+ err = RecordConvertSetToRanges(pRCAP->pDeviceEventSet, pri,
+ offset_of(rr, deviceEventsFirst), TRUE, 255, NULL);
+ if (err != Success) goto bailout;
+
+ err = RecordConvertSetToRanges(pRCAP->pErrorSet, pri,
+ offset_of(rr, errorsFirst), TRUE, 255, NULL);
+ if (err != Success) goto bailout;
+
+ err = RecordConvertMinorOpInfoToRanges(pRCAP->pRequestMinOpInfo,
+ pri, offset_of(rr, extRequestsMajorFirst));
+ if (err != Success) goto bailout;
+
+ err = RecordConvertMinorOpInfoToRanges(pRCAP->pReplyMinOpInfo,
+ pri, offset_of(rr, extRepliesMajorFirst));
+ if (err != Success) goto bailout;
+
+ if (pRCAP->clientStarted || pRCAP->clientDied)
+ {
+ if (pri->nRanges == 0)
+ RecordAllocRanges(pri, 1);
+ pri->pRanges[0].clientStarted = pRCAP->clientStarted;
+ pri->pRanges[0].clientDied = pRCAP->clientDied;
+ }
+ }
+
+ /* calculate number of clients and reply length */
+
+ rep.nClients = 0;
+ rep.length = 0;
+ for (pRCAP = pContext->pListOfRCAP, pri = pRangeInfo;
+ pRCAP;
+ pRCAP = pRCAP->pNextRCAP, pri++)
+ {
+ rep.nClients += pRCAP->numClients;
+ rep.length += pRCAP->numClients *
+ ( bytes_to_int32(sizeof(xRecordClientInfo)) +
+ pri->nRanges * bytes_to_int32(sizeof(xRecordRange)));
+ }
+
+ /* write the reply header */
+
+ rep.type = X_Reply;
+ rep.sequenceNumber = client->sequence;
+ rep.enabled = pContext->pRecordingClient != NULL;
+ rep.elementHeader = pContext->elemHeaders;
+ if(client->swapped)
+ {
+ swaps(&rep.sequenceNumber, n);
+ swapl(&rep.length, n);
+ swapl(&rep.nClients, n);
+ }
+ (void)WriteToClient(client, sizeof(xRecordGetContextReply),
+ (char *)&rep);
+
+ /* write all the CLIENT_INFOs */
+
+ for (pRCAP = pContext->pListOfRCAP, pri = pRangeInfo;
+ pRCAP;
+ pRCAP = pRCAP->pNextRCAP, pri++)
+ {
+ xRecordClientInfo rci;
+ rci.nRanges = pri->nRanges;
+ if (client->swapped)
+ {
+ swapl(&rci.nRanges, n);
+ RecordSwapRanges(pri->pRanges, pri->nRanges);
+ }
+ for (i = 0; i < pRCAP->numClients; i++)
+ {
+ rci.clientResource = pRCAP->pClientIDs[i];
+ if (client->swapped) swapl(&rci.clientResource, n);
+ WriteToClient(client, sizeof(xRecordClientInfo), (char *)&rci);
+ WriteToClient(client, sizeof(xRecordRange) * pri->nRanges,
+ (char *)pri->pRanges);
+ }
+ }
+ err = Success;
+
+bailout:
+ for (i = 0; i < nRCAPs; i++)
+ {
+ free(pRangeInfo[i].pRanges);
+ }
+ free(pRangeInfo);
+ return err;
+} /* ProcRecordGetContext */
+
+
+static int
+ProcRecordEnableContext(ClientPtr client)
+{
+ RecordContextPtr pContext;
+ REQUEST(xRecordEnableContextReq);
+ int i;
+ RecordClientsAndProtocolPtr pRCAP;
+
+ REQUEST_SIZE_MATCH(xRecordGetContextReq);
+ VERIFY_CONTEXT(pContext, stuff->context, client);
+ if (pContext->pRecordingClient)
+ return BadMatch; /* already enabled */
+
+ /* install record hooks for each RCAP */
+
+ for (pRCAP = pContext->pListOfRCAP; pRCAP; pRCAP = pRCAP->pNextRCAP)
+ {
+ int err = RecordInstallHooks(pRCAP, 0);
+ if (err != Success)
+ { /* undo the previous installs */
+ RecordClientsAndProtocolPtr pUninstallRCAP;
+ for (pUninstallRCAP = pContext->pListOfRCAP;
+ pUninstallRCAP != pRCAP;
+ pUninstallRCAP = pUninstallRCAP->pNextRCAP)
+ {
+ RecordUninstallHooks(pUninstallRCAP, 0);
+ }
+ return err;
+ }
+ }
+
+ /* Disallow further request processing on this connection until
+ * the context is disabled.
+ */
+ IgnoreClient(client);
+ pContext->pRecordingClient = client;
+
+ /* Don't allow the data connection to record itself; unregister it. */
+ RecordDeleteClientFromContext(pContext,
+ pContext->pRecordingClient->clientAsMask);
+
+ /* move the newly enabled context to the front part of ppAllContexts,
+ * where all the enabled contexts are
+ */
+ i = RecordFindContextOnAllContexts(pContext);
+ assert(i >= numEnabledContexts);
+ if (i != numEnabledContexts)
+ {
+ ppAllContexts[i] = ppAllContexts[numEnabledContexts];
+ ppAllContexts[numEnabledContexts] = pContext;
+ }
+
+ ++numEnabledContexts;
+ assert(numEnabledContexts > 0);
+
+ /* send StartOfData */
+ RecordAProtocolElement(pContext, NULL, XRecordStartOfData, NULL, 0, 0);
+ RecordFlushReplyBuffer(pContext, NULL, 0, NULL, 0);
+ return Success;
+} /* ProcRecordEnableContext */
+
+
+/* RecordDisableContext
+ *
+ * Arguments:
+ * pContext is the context to disable.
+ * nRanges is the number of elements in pRanges.
+ *
+ * Returns: nothing.
+ *
+ * Side Effects:
+ * If the context was enabled, it is disabled. An EndOfData
+ * message is sent to the recording client. Recording hooks for
+ * this context are uninstalled. The context is moved to the
+ * rear part of the ppAllContexts array. numEnabledContexts is
+ * decremented. Request processing for the formerly recording client
+ * is resumed.
+ */
+static void
+RecordDisableContext(RecordContextPtr pContext)
+{
+ RecordClientsAndProtocolPtr pRCAP;
+ int i;
+
+ if (!pContext->pRecordingClient) return;
+ if (!pContext->pRecordingClient->clientGone)
+ {
+ RecordAProtocolElement(pContext, NULL, XRecordEndOfData, NULL, 0, 0);
+ RecordFlushReplyBuffer(pContext, NULL, 0, NULL, 0);
+ /* Re-enable request processing on this connection. */
+ AttendClient(pContext->pRecordingClient);
+ }
+
+ for (pRCAP = pContext->pListOfRCAP; pRCAP; pRCAP = pRCAP->pNextRCAP)
+ {
+ RecordUninstallHooks(pRCAP, 0);
+ }
+
+ pContext->pRecordingClient = NULL;
+
+ /* move the newly disabled context to the rear part of ppAllContexts,
+ * where all the disabled contexts are
+ */
+ i = RecordFindContextOnAllContexts(pContext);
+ assert( (i != -1) && (i < numEnabledContexts) );
+ if (i != (numEnabledContexts - 1) )
+ {
+ ppAllContexts[i] = ppAllContexts[numEnabledContexts-1];
+ ppAllContexts[numEnabledContexts-1] = pContext;
+ }
+ --numEnabledContexts;
+ assert(numEnabledContexts >= 0);
+} /* RecordDisableContext */
+
+
+static int
+ProcRecordDisableContext(ClientPtr client)
+{
+ RecordContextPtr pContext;
+ REQUEST(xRecordDisableContextReq);
+
+ REQUEST_SIZE_MATCH(xRecordDisableContextReq);
+ VERIFY_CONTEXT(pContext, stuff->context, client);
+ RecordDisableContext(pContext);
+ return Success;
+} /* ProcRecordDisableContext */
+
+
+/* RecordDeleteContext
+ *
+ * Arguments:
+ * value is the context to delete.
+ * id is its resource ID.
+ *
+ * Returns: Success.
+ *
+ * Side Effects:
+ * Disables the context, frees all associated memory, and removes
+ * it from the ppAllContexts array.
+ */
+static int
+RecordDeleteContext(pointer value, XID id)
+{
+ int i;
+ RecordContextPtr pContext = (RecordContextPtr)value;
+ RecordClientsAndProtocolPtr pRCAP;
+
+ RecordDisableContext(pContext);
+
+ /* Remove all the clients from all the RCAPs.
+ * As a result, the RCAPs will be freed.
+ */
+
+ while ((pRCAP = pContext->pListOfRCAP))
+ {
+ int numClients = pRCAP->numClients;
+ /* when the last client is deleted, the RCAP will go away. */
+ while(numClients--)
+ {
+ RecordDeleteClientFromRCAP(pRCAP, numClients);
+ }
+ }
+
+ /* remove context from AllContexts list */
+
+ if (-1 != (i = RecordFindContextOnAllContexts(pContext)))
+ {
+ ppAllContexts[i] = ppAllContexts[numContexts - 1];
+ if (--numContexts == 0)
+ {
+ free(ppAllContexts);
+ ppAllContexts = NULL;
+ }
+ }
+ free(pContext);
+
+ return Success;
+} /* RecordDeleteContext */
+
+
+static int
+ProcRecordFreeContext(ClientPtr client)
+{
+ RecordContextPtr pContext;
+ REQUEST(xRecordFreeContextReq);
+
+ REQUEST_SIZE_MATCH(xRecordFreeContextReq);
+ VERIFY_CONTEXT(pContext, stuff->context, client);
+ FreeResource(stuff->context, RT_NONE);
+ return Success;
+} /* ProcRecordFreeContext */
+
+
+static int
+ProcRecordDispatch(ClientPtr client)
+{
+ REQUEST(xReq);
+
+ switch (stuff->data)
+ {
+ case X_RecordQueryVersion:
+ return ProcRecordQueryVersion(client);
+ case X_RecordCreateContext:
+ return ProcRecordCreateContext(client);
+ case X_RecordRegisterClients:
+ return ProcRecordRegisterClients(client);
+ case X_RecordUnregisterClients:
+ return ProcRecordUnregisterClients(client);
+ case X_RecordGetContext:
+ return ProcRecordGetContext(client);
+ case X_RecordEnableContext:
+ return ProcRecordEnableContext(client);
+ case X_RecordDisableContext:
+ return ProcRecordDisableContext(client);
+ case X_RecordFreeContext:
+ return ProcRecordFreeContext(client);
+ default:
+ return BadRequest;
+ }
+} /* ProcRecordDispatch */
+
+
+static int
+SProcRecordQueryVersion(ClientPtr client)
+{
+ REQUEST(xRecordQueryVersionReq);
+ register char n;
+
+ swaps(&stuff->length, n);
+ REQUEST_SIZE_MATCH(xRecordQueryVersionReq);
+ swaps(&stuff->majorVersion, n);
+ swaps(&stuff->minorVersion,n);
+ return ProcRecordQueryVersion(client);
+} /* SProcRecordQueryVersion */
+
+
+static int
+SwapCreateRegister(xRecordRegisterClientsReq *stuff)
+{
+ register char n;
+ int i;
+ XID *pClientID;
+
+ swapl(&stuff->context, n);
+ swapl(&stuff->nClients, n);
+ swapl(&stuff->nRanges, n);
+ pClientID = (XID *)&stuff[1];
+ if (stuff->nClients > stuff->length - bytes_to_int32(sz_xRecordRegisterClientsReq))
+ return BadLength;
+ for (i = 0; i < stuff->nClients; i++, pClientID++)
+ {
+ swapl(pClientID, n);
+ }
+ if (stuff->nRanges > stuff->length - bytes_to_int32(sz_xRecordRegisterClientsReq)
+ - stuff->nClients)
+ return BadLength;
+ RecordSwapRanges((xRecordRange *)pClientID, stuff->nRanges);
+ return Success;
+} /* SwapCreateRegister */
+
+
+static int
+SProcRecordCreateContext(ClientPtr client)
+{
+ REQUEST(xRecordCreateContextReq);
+ int status;
+ register char n;
+
+ swaps(&stuff->length, n);
+ REQUEST_AT_LEAST_SIZE(xRecordCreateContextReq);
+ if ((status = SwapCreateRegister((pointer)stuff)) != Success)
+ return status;
+ return ProcRecordCreateContext(client);
+} /* SProcRecordCreateContext */
+
+
+static int
+SProcRecordRegisterClients(ClientPtr client)
+{
+ REQUEST(xRecordRegisterClientsReq);
+ int status;
+ register char n;
+
+ swaps(&stuff->length, n);
+ REQUEST_AT_LEAST_SIZE(xRecordRegisterClientsReq);
+ if ((status = SwapCreateRegister((pointer)stuff)) != Success)
+ return status;
+ return ProcRecordRegisterClients(client);
+} /* SProcRecordRegisterClients */
+
+
+static int
+SProcRecordUnregisterClients(ClientPtr client)
+{
+ REQUEST(xRecordUnregisterClientsReq);
+ register char n;
+
+ swaps(&stuff->length, n);
+ REQUEST_AT_LEAST_SIZE(xRecordUnregisterClientsReq);
+ swapl(&stuff->context, n);
+ swapl(&stuff->nClients, n);
+ SwapRestL(stuff);
+ return ProcRecordUnregisterClients(client);
+} /* SProcRecordUnregisterClients */
+
+
+static int
+SProcRecordGetContext(ClientPtr client)
+{
+ REQUEST(xRecordGetContextReq);
+ register char n;
+
+ swaps(&stuff->length, n);
+ REQUEST_SIZE_MATCH(xRecordGetContextReq);
+ swapl(&stuff->context, n);
+ return ProcRecordGetContext(client);
+} /* SProcRecordGetContext */
+
+static int
+SProcRecordEnableContext(ClientPtr client)
+{
+ REQUEST(xRecordEnableContextReq);
+ register char n;
+
+ swaps(&stuff->length, n);
+ REQUEST_SIZE_MATCH(xRecordEnableContextReq);
+ swapl(&stuff->context, n);
+ return ProcRecordEnableContext(client);
+} /* SProcRecordEnableContext */
+
+
+static int
+SProcRecordDisableContext(ClientPtr client)
+{
+ REQUEST(xRecordDisableContextReq);
+ register char n;
+
+ swaps(&stuff->length, n);
+ REQUEST_SIZE_MATCH(xRecordDisableContextReq);
+ swapl(&stuff->context, n);
+ return ProcRecordDisableContext(client);
+} /* SProcRecordDisableContext */
+
+
+static int
+SProcRecordFreeContext(ClientPtr client)
+{
+ REQUEST(xRecordFreeContextReq);
+ register char n;
+
+ swaps(&stuff->length, n);
+ REQUEST_SIZE_MATCH(xRecordFreeContextReq);
+ swapl(&stuff->context, n);
+ return ProcRecordFreeContext(client);
+} /* SProcRecordFreeContext */
+
+
+static int
+SProcRecordDispatch(ClientPtr client)
+{
+ REQUEST(xReq);
+
+ switch (stuff->data)
+ {
+ case X_RecordQueryVersion:
+ return SProcRecordQueryVersion(client);
+ case X_RecordCreateContext:
+ return SProcRecordCreateContext(client);
+ case X_RecordRegisterClients:
+ return SProcRecordRegisterClients(client);
+ case X_RecordUnregisterClients:
+ return SProcRecordUnregisterClients(client);
+ case X_RecordGetContext:
+ return SProcRecordGetContext(client);
+ case X_RecordEnableContext:
+ return SProcRecordEnableContext(client);
+ case X_RecordDisableContext:
+ return SProcRecordDisableContext(client);
+ case X_RecordFreeContext:
+ return SProcRecordFreeContext(client);
+ default:
+ return BadRequest;
+ }
+} /* SProcRecordDispatch */
+
+/* RecordConnectionSetupInfo
+ *
+ * Arguments:
+ * pContext is an enabled context that specifies recording of
+ * connection setup info.
+ * pci holds the connection setup info.
+ *
+ * Returns: nothing.
+ *
+ * Side Effects:
+ * The connection setup info is sent to the recording client.
+ */
+static void
+RecordConnectionSetupInfo(RecordContextPtr pContext, NewClientInfoRec *pci)
+{
+ int prefixsize = SIZEOF(xConnSetupPrefix);
+ int restsize = pci->prefix->length * 4;
+
+ if (pci->client->swapped)
+ {
+ char *pConnSetup = (char *)malloc(prefixsize + restsize);
+ if (!pConnSetup)
+ return;
+ SwapConnSetupPrefix(pci->prefix, (xConnSetupPrefix*)pConnSetup);
+ SwapConnSetupInfo((char*)pci->setup, (char*)(pConnSetup + prefixsize));
+ RecordAProtocolElement(pContext, pci->client, XRecordClientStarted,
+ (pointer)pConnSetup, prefixsize + restsize, 0);
+ free(pConnSetup);
+ }
+ else
+ {
+ /* don't alloc and copy as in the swapped case; just send the
+ * data in two pieces
+ */
+ RecordAProtocolElement(pContext, pci->client, XRecordClientStarted,
+ (pointer)pci->prefix, prefixsize, restsize);
+ RecordAProtocolElement(pContext, pci->client, XRecordClientStarted,
+ (pointer)pci->setup, restsize, /* continuation */ -1);
+ }
+} /* RecordConnectionSetupInfo */
+
+
+/* RecordDeleteContext
+ *
+ * Arguments:
+ * pcbl is &ClientStateCallback.
+ * nullata is NULL.
+ * calldata is a pointer to a NewClientInfoRec (include/dixstruct.h)
+ * which contains information about client state changes.
+ *
+ * Returns: nothing.
+ *
+ * Side Effects:
+ * If a new client has connected and any contexts have specified
+ * XRecordFutureClients, the new client is registered on those contexts.
+ * If any of those contexts specify recording of the connection setup
+ * info, it is recorded.
+ *
+ * If an existing client has disconnected, it is deleted from any
+ * contexts that it was registered on. If any of those contexts
+ * specified XRecordClientDied, they record a ClientDied protocol element.
+ * If the disconnectiong client happened to be the data connection of an
+ * enabled context, the context is disabled.
+ */
+
+static void
+RecordAClientStateChange(CallbackListPtr *pcbl, pointer nulldata, pointer calldata)
+{
+ NewClientInfoRec *pci = (NewClientInfoRec *)calldata;
+ int i;
+ ClientPtr pClient = pci->client;
+ RecordContextPtr *ppAllContextsCopy = NULL;
+ int numContextsCopy = 0;
+
+ switch (pClient->clientState)
+ {
+ case ClientStateRunning: /* new client */
+ for (i = 0; i < numContexts; i++)
+ {
+ RecordClientsAndProtocolPtr pRCAP;
+ RecordContextPtr pContext = ppAllContexts[i];
+
+ if ((pRCAP = RecordFindClientOnContext(pContext,
+ XRecordFutureClients, NULL)))
+ {
+ RecordAddClientToRCAP(pRCAP, pClient->clientAsMask);
+ if (pContext->pRecordingClient && pRCAP->clientStarted)
+ RecordConnectionSetupInfo(pContext, pci);
+ }
+ }
+ break;
+
+ case ClientStateGone:
+ case ClientStateRetained: /* client disconnected */
+
+ /* RecordDisableContext modifies contents of ppAllContexts. */
+ numContextsCopy = numContexts;
+ ppAllContextsCopy = malloc(numContextsCopy * sizeof(RecordContextPtr));
+ assert(ppAllContextsCopy);
+ memcpy(ppAllContextsCopy, ppAllContexts, numContextsCopy * sizeof(RecordContextPtr));
+
+ for (i = 0; i < numContextsCopy; i++)
+ {
+ RecordClientsAndProtocolPtr pRCAP;
+ RecordContextPtr pContext = ppAllContextsCopy[i];
+ int pos;
+
+ if (pContext->pRecordingClient == pClient)
+ RecordDisableContext(pContext);
+ if ((pRCAP = RecordFindClientOnContext(pContext,
+ pClient->clientAsMask, &pos)))
+ {
+ if (pContext->pRecordingClient && pRCAP->clientDied)
+ RecordAProtocolElement(pContext, pClient,
+ XRecordClientDied, NULL, 0, 0);
+ RecordDeleteClientFromRCAP(pRCAP, pos);
+ }
+ }
+
+ free(ppAllContextsCopy);
+ break;
+
+ default:
+ break;
+ } /* end switch on client state */
+} /* RecordAClientStateChange */
+
+
+/* RecordCloseDown
+ *
+ * Arguments:
+ * extEntry is the extension information for RECORD.
+ *
+ * Returns: nothing.
+ *
+ * Side Effects:
+ * Performs any cleanup needed by RECORD at server shutdown time.
+ *
+ */
+static void
+RecordCloseDown(ExtensionEntry *extEntry)
+{
+ DeleteCallback(&ClientStateCallback, RecordAClientStateChange, NULL);
+} /* RecordCloseDown */
+
+
+/* RecordExtensionInit
+ *
+ * Arguments: none.
+ *
+ * Returns: nothing.
+ *
+ * Side Effects:
+ * Enables the RECORD extension if possible.
+ */
+void
+RecordExtensionInit(void)
+{
+ ExtensionEntry *extentry;
+
+ RTContext = CreateNewResourceType(RecordDeleteContext, "RecordContext");
+ if (!RTContext)
+ return;
+
+ if (!dixRegisterPrivateKey(RecordClientPrivateKey, PRIVATE_CLIENT, 0))
+ return;
+
+ ppAllContexts = NULL;
+ numContexts = numEnabledContexts = numEnabledRCAPs = 0;
+
+ if (!AddCallback(&ClientStateCallback, RecordAClientStateChange, NULL))
+ return;
+
+ extentry = AddExtension(RECORD_NAME, RecordNumEvents, RecordNumErrors,
+ ProcRecordDispatch, SProcRecordDispatch,
+ RecordCloseDown, StandardMinorOpcode);
+ if (!extentry)
+ {
+ DeleteCallback(&ClientStateCallback, RecordAClientStateChange, NULL);
+ return;
+ }
+ SetResourceTypeErrorValue(RTContext, extentry->errorBase + XRecordBadContext);
+
+} /* RecordExtensionInit */
+
diff --git a/xorg-server/test/Makefile.am b/xorg-server/test/Makefile.am
index fe9bc1f2e..b7ee070a1 100644
--- a/xorg-server/test/Makefile.am
+++ b/xorg-server/test/Makefile.am
@@ -1,7 +1,7 @@
if ENABLE_UNIT_TESTS
if HAVE_LD_WRAP
SUBDIRS= . xi2
-noinst_PROGRAMS = xkb input xtest list
+noinst_PROGRAMS = xkb input xtest list misc
check_LTLIBRARIES = libxservertest.la
TESTS=$(noinst_PROGRAMS)
@@ -18,6 +18,7 @@ xkb_LDADD=$(TEST_LDADD)
input_LDADD=$(TEST_LDADD)
xtest_LDADD=$(TEST_LDADD)
list_LDADD=$(TEST_LDADD)
+misc_LDADD=$(TEST_LDADD)
libxservertest_la_LIBADD = \
$(XSERVER_LIBS) \
diff --git a/xorg-server/test/misc.c b/xorg-server/test/misc.c
new file mode 100644
index 000000000..3d3b1a1e3
--- /dev/null
+++ b/xorg-server/test/misc.c
@@ -0,0 +1,62 @@
+/**
+ * Copyright © 2011 Red Hat, 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 (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <stdint.h>
+#include "misc.h"
+
+static void dix_version_compare(void)
+{
+ int rc;
+
+ rc = version_compare(0, 0, 1, 0);
+ assert(rc < 0);
+ rc = version_compare(1, 0, 0, 0);
+ assert(rc > 0);
+ rc = version_compare(0, 0, 0, 0);
+ assert(rc == 0);
+ rc = version_compare(1, 0, 1, 0);
+ assert(rc == 0);
+ rc = version_compare(1, 0, 0, 9);
+ assert(rc > 0);
+ rc = version_compare(0, 9, 1, 0);
+ assert(rc < 0);
+ rc = version_compare(1, 0, 1, 9);
+ assert(rc < 0);
+ rc = version_compare(1, 9, 1, 0);
+ assert(rc > 0);
+ rc = version_compare(2, 0, 1, 9);
+ assert(rc > 0);
+ rc = version_compare(1, 9, 2, 0);
+ assert(rc < 0);
+}
+
+int main(int argc, char** argv)
+{
+ dix_version_compare();
+
+ return 0;
+}
diff --git a/xorg-server/xfixes/xfixes.c b/xorg-server/xfixes/xfixes.c
index 80f212273..54f0df341 100644
--- a/xorg-server/xfixes/xfixes.c
+++ b/xorg-server/xfixes/xfixes.c
@@ -1,294 +1,294 @@
-/*
- * Copyright (c) 2006, Oracle and/or its affiliates. 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 (including the next
- * paragraph) shall be included in all copies or substantial portions of the
- * Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
- * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
- * DEALINGS IN THE SOFTWARE.
- *
- * Copyright © 2002 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 "xfixesint.h"
-#include "protocol-versions.h"
-/*
- * Must use these instead of the constants from xfixeswire.h. They advertise
- * what we implement, not what the protocol headers define.
- */
-
-static unsigned char XFixesReqCode;
-int XFixesEventBase;
-int XFixesErrorBase;
-
-static DevPrivateKeyRec XFixesClientPrivateKeyRec;
-#define XFixesClientPrivateKey (&XFixesClientPrivateKeyRec)
-
-static int
-ProcXFixesQueryVersion(ClientPtr client)
-{
- XFixesClientPtr pXFixesClient = GetXFixesClient (client);
- xXFixesQueryVersionReply rep;
- register int n;
- REQUEST(xXFixesQueryVersionReq);
-
- REQUEST_SIZE_MATCH(xXFixesQueryVersionReq);
- memset(&rep, 0, sizeof(xXFixesQueryVersionReply));
- rep.type = X_Reply;
- rep.length = 0;
- rep.sequenceNumber = client->sequence;
- if (stuff->majorVersion < SERVER_XFIXES_MAJOR_VERSION) {
- rep.majorVersion = stuff->majorVersion;
- rep.minorVersion = stuff->minorVersion;
- } else {
- rep.majorVersion = SERVER_XFIXES_MAJOR_VERSION;
- if (stuff->majorVersion == SERVER_XFIXES_MAJOR_VERSION &&
- stuff->minorVersion < SERVER_XFIXES_MINOR_VERSION)
- rep.minorVersion = stuff->minorVersion;
- else
- rep.minorVersion = SERVER_XFIXES_MINOR_VERSION;
- }
- pXFixesClient->major_version = rep.majorVersion;
- pXFixesClient->minor_version = rep.minorVersion;
- if (client->swapped) {
- swaps(&rep.sequenceNumber, n);
- swapl(&rep.length, n);
- swapl(&rep.majorVersion, n);
- swapl(&rep.minorVersion, n);
- }
- WriteToClient(client, sizeof(xXFixesQueryVersionReply), (char *)&rep);
- return Success;
-}
-
-/* Major version controls available requests */
-static const int version_requests[] = {
- X_XFixesQueryVersion, /* before client sends QueryVersion */
- X_XFixesGetCursorImage, /* Version 1 */
- X_XFixesChangeCursorByName, /* Version 2 */
- X_XFixesExpandRegion, /* Version 3 */
- X_XFixesShowCursor, /* Version 4 */
-};
-
-#define NUM_VERSION_REQUESTS (sizeof (version_requests) / sizeof (version_requests[0]))
-
-int (*ProcXFixesVector[XFixesNumberRequests])(ClientPtr) = {
-/*************** Version 1 ******************/
- ProcXFixesQueryVersion,
- ProcXFixesChangeSaveSet,
- ProcXFixesSelectSelectionInput,
- ProcXFixesSelectCursorInput,
- ProcXFixesGetCursorImage,
-/*************** Version 2 ******************/
- ProcXFixesCreateRegion,
- ProcXFixesCreateRegionFromBitmap,
- ProcXFixesCreateRegionFromWindow,
- ProcXFixesCreateRegionFromGC,
- ProcXFixesCreateRegionFromPicture,
- ProcXFixesDestroyRegion,
- ProcXFixesSetRegion,
- ProcXFixesCopyRegion,
- ProcXFixesCombineRegion,
- ProcXFixesCombineRegion,
- ProcXFixesCombineRegion,
- ProcXFixesInvertRegion,
- ProcXFixesTranslateRegion,
- ProcXFixesRegionExtents,
- ProcXFixesFetchRegion,
- ProcXFixesSetGCClipRegion,
- ProcXFixesSetWindowShapeRegion,
- ProcXFixesSetPictureClipRegion,
- ProcXFixesSetCursorName,
- ProcXFixesGetCursorName,
- ProcXFixesGetCursorImageAndName,
- ProcXFixesChangeCursor,
- ProcXFixesChangeCursorByName,
-/*************** Version 3 ******************/
- ProcXFixesExpandRegion,
-/*************** Version 4 ****************/
- ProcXFixesHideCursor,
- ProcXFixesShowCursor,
-};
-
-static int
-ProcXFixesDispatch (ClientPtr client)
-{
- REQUEST(xXFixesReq);
- XFixesClientPtr pXFixesClient = GetXFixesClient (client);
-
- if (pXFixesClient->major_version >= NUM_VERSION_REQUESTS)
- return BadRequest;
- if (stuff->xfixesReqType > version_requests[pXFixesClient->major_version])
- return BadRequest;
- return (*ProcXFixesVector[stuff->xfixesReqType]) (client);
-}
-
-static int
-SProcXFixesQueryVersion(ClientPtr client)
-{
- register int n;
- REQUEST(xXFixesQueryVersionReq);
-
- swaps(&stuff->length, n);
- swapl(&stuff->majorVersion, n);
- swapl(&stuff->minorVersion, n);
- return (*ProcXFixesVector[stuff->xfixesReqType]) (client);
-}
-
-static int (*SProcXFixesVector[XFixesNumberRequests])(ClientPtr) = {
-/*************** Version 1 ******************/
- SProcXFixesQueryVersion,
- SProcXFixesChangeSaveSet,
- SProcXFixesSelectSelectionInput,
- SProcXFixesSelectCursorInput,
- SProcXFixesGetCursorImage,
-/*************** Version 2 ******************/
- SProcXFixesCreateRegion,
- SProcXFixesCreateRegionFromBitmap,
- SProcXFixesCreateRegionFromWindow,
- SProcXFixesCreateRegionFromGC,
- SProcXFixesCreateRegionFromPicture,
- SProcXFixesDestroyRegion,
- SProcXFixesSetRegion,
- SProcXFixesCopyRegion,
- SProcXFixesCombineRegion,
- SProcXFixesCombineRegion,
- SProcXFixesCombineRegion,
- SProcXFixesInvertRegion,
- SProcXFixesTranslateRegion,
- SProcXFixesRegionExtents,
- SProcXFixesFetchRegion,
- SProcXFixesSetGCClipRegion,
- SProcXFixesSetWindowShapeRegion,
- SProcXFixesSetPictureClipRegion,
- SProcXFixesSetCursorName,
- SProcXFixesGetCursorName,
- SProcXFixesGetCursorImageAndName,
- SProcXFixesChangeCursor,
- SProcXFixesChangeCursorByName,
-/*************** Version 3 ******************/
- SProcXFixesExpandRegion,
-/*************** Version 4 ****************/
- SProcXFixesHideCursor,
- SProcXFixesShowCursor,
-};
-
-static int
-SProcXFixesDispatch (ClientPtr client)
-{
- REQUEST(xXFixesReq);
- if (stuff->xfixesReqType >= XFixesNumberRequests)
- return BadRequest;
- return (*SProcXFixesVector[stuff->xfixesReqType]) (client);
-}
-
-static void
-XFixesClientCallback (CallbackListPtr *list,
- pointer closure,
- pointer data)
-{
- NewClientInfoRec *clientinfo = (NewClientInfoRec *) data;
- ClientPtr pClient = clientinfo->client;
- XFixesClientPtr pXFixesClient = GetXFixesClient (pClient);
-
- pXFixesClient->major_version = 0;
- pXFixesClient->minor_version = 0;
-}
-
-/*ARGSUSED*/
-static void
-XFixesResetProc (ExtensionEntry *extEntry)
-{
- DeleteCallback (&ClientStateCallback, XFixesClientCallback, 0);
-}
-
-void
-XFixesExtensionInit(void)
-{
- ExtensionEntry *extEntry;
-
- if (!dixRegisterPrivateKey(&XFixesClientPrivateKeyRec, PRIVATE_CLIENT, sizeof (XFixesClientRec)))
- return;
- if (!AddCallback (&ClientStateCallback, XFixesClientCallback, 0))
- return;
-
- if (XFixesSelectionInit() && XFixesCursorInit () && XFixesRegionInit () &&
- (extEntry = AddExtension(XFIXES_NAME, XFixesNumberEvents,
- XFixesNumberErrors,
- ProcXFixesDispatch, SProcXFixesDispatch,
- XFixesResetProc, StandardMinorOpcode)) != 0)
- {
- XFixesReqCode = (unsigned char)extEntry->base;
- XFixesEventBase = extEntry->eventBase;
- XFixesErrorBase = extEntry->errorBase;
- EventSwapVector[XFixesEventBase + XFixesSelectionNotify] =
- (EventSwapPtr) SXFixesSelectionNotifyEvent;
- EventSwapVector[XFixesEventBase + XFixesCursorNotify] =
- (EventSwapPtr) SXFixesCursorNotifyEvent;
- SetResourceTypeErrorValue(RegionResType, XFixesErrorBase + BadRegion);
- }
-}
-
-#ifdef PANORAMIX
-
-int (*PanoramiXSaveXFixesVector[XFixesNumberRequests])(ClientPtr);
-
-void
-PanoramiXFixesInit (void)
-{
- int i;
-
- for (i = 0; i < XFixesNumberRequests; i++)
- PanoramiXSaveXFixesVector[i] = ProcXFixesVector[i];
- /*
- * Stuff in Xinerama aware request processing hooks
- */
- ProcXFixesVector[X_XFixesSetGCClipRegion] = PanoramiXFixesSetGCClipRegion;
- ProcXFixesVector[X_XFixesSetWindowShapeRegion] = PanoramiXFixesSetWindowShapeRegion;
- ProcXFixesVector[X_XFixesSetPictureClipRegion] = PanoramiXFixesSetPictureClipRegion;
-}
-
-void
-PanoramiXFixesReset (void)
-{
- int i;
-
- for (i = 0; i < XFixesNumberRequests; i++)
- ProcXFixesVector[i] = PanoramiXSaveXFixesVector[i];
-}
-
-#endif
+/*
+ * Copyright (c) 2006, Oracle and/or its affiliates. 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 (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ *
+ * Copyright © 2002 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 "xfixesint.h"
+#include "protocol-versions.h"
+/*
+ * Must use these instead of the constants from xfixeswire.h. They advertise
+ * what we implement, not what the protocol headers define.
+ */
+
+static unsigned char XFixesReqCode;
+int XFixesEventBase;
+int XFixesErrorBase;
+
+static DevPrivateKeyRec XFixesClientPrivateKeyRec;
+#define XFixesClientPrivateKey (&XFixesClientPrivateKeyRec)
+
+static int
+ProcXFixesQueryVersion(ClientPtr client)
+{
+ XFixesClientPtr pXFixesClient = GetXFixesClient (client);
+ xXFixesQueryVersionReply rep;
+ register int n;
+ REQUEST(xXFixesQueryVersionReq);
+
+ REQUEST_SIZE_MATCH(xXFixesQueryVersionReq);
+ memset(&rep, 0, sizeof(xXFixesQueryVersionReply));
+ rep.type = X_Reply;
+ rep.length = 0;
+ rep.sequenceNumber = client->sequence;
+
+ if (version_compare(stuff->majorVersion, stuff->minorVersion,
+ SERVER_XFIXES_MAJOR_VERSION, SERVER_XFIXES_MAJOR_VERSION) < 0)
+ {
+ rep.majorVersion = stuff->majorVersion;
+ rep.minorVersion = stuff->minorVersion;
+ } else {
+ rep.majorVersion = SERVER_XFIXES_MAJOR_VERSION;
+ rep.minorVersion = SERVER_XFIXES_MINOR_VERSION;
+ }
+
+ pXFixesClient->major_version = rep.majorVersion;
+ pXFixesClient->minor_version = rep.minorVersion;
+ if (client->swapped) {
+ swaps(&rep.sequenceNumber, n);
+ swapl(&rep.length, n);
+ swapl(&rep.majorVersion, n);
+ swapl(&rep.minorVersion, n);
+ }
+ WriteToClient(client, sizeof(xXFixesQueryVersionReply), (char *)&rep);
+ return Success;
+}
+
+/* Major version controls available requests */
+static const int version_requests[] = {
+ X_XFixesQueryVersion, /* before client sends QueryVersion */
+ X_XFixesGetCursorImage, /* Version 1 */
+ X_XFixesChangeCursorByName, /* Version 2 */
+ X_XFixesExpandRegion, /* Version 3 */
+ X_XFixesShowCursor, /* Version 4 */
+};
+
+#define NUM_VERSION_REQUESTS (sizeof (version_requests) / sizeof (version_requests[0]))
+
+int (*ProcXFixesVector[XFixesNumberRequests])(ClientPtr) = {
+/*************** Version 1 ******************/
+ ProcXFixesQueryVersion,
+ ProcXFixesChangeSaveSet,
+ ProcXFixesSelectSelectionInput,
+ ProcXFixesSelectCursorInput,
+ ProcXFixesGetCursorImage,
+/*************** Version 2 ******************/
+ ProcXFixesCreateRegion,
+ ProcXFixesCreateRegionFromBitmap,
+ ProcXFixesCreateRegionFromWindow,
+ ProcXFixesCreateRegionFromGC,
+ ProcXFixesCreateRegionFromPicture,
+ ProcXFixesDestroyRegion,
+ ProcXFixesSetRegion,
+ ProcXFixesCopyRegion,
+ ProcXFixesCombineRegion,
+ ProcXFixesCombineRegion,
+ ProcXFixesCombineRegion,
+ ProcXFixesInvertRegion,
+ ProcXFixesTranslateRegion,
+ ProcXFixesRegionExtents,
+ ProcXFixesFetchRegion,
+ ProcXFixesSetGCClipRegion,
+ ProcXFixesSetWindowShapeRegion,
+ ProcXFixesSetPictureClipRegion,
+ ProcXFixesSetCursorName,
+ ProcXFixesGetCursorName,
+ ProcXFixesGetCursorImageAndName,
+ ProcXFixesChangeCursor,
+ ProcXFixesChangeCursorByName,
+/*************** Version 3 ******************/
+ ProcXFixesExpandRegion,
+/*************** Version 4 ****************/
+ ProcXFixesHideCursor,
+ ProcXFixesShowCursor,
+};
+
+static int
+ProcXFixesDispatch (ClientPtr client)
+{
+ REQUEST(xXFixesReq);
+ XFixesClientPtr pXFixesClient = GetXFixesClient (client);
+
+ if (pXFixesClient->major_version >= NUM_VERSION_REQUESTS)
+ return BadRequest;
+ if (stuff->xfixesReqType > version_requests[pXFixesClient->major_version])
+ return BadRequest;
+ return (*ProcXFixesVector[stuff->xfixesReqType]) (client);
+}
+
+static int
+SProcXFixesQueryVersion(ClientPtr client)
+{
+ register int n;
+ REQUEST(xXFixesQueryVersionReq);
+
+ swaps(&stuff->length, n);
+ swapl(&stuff->majorVersion, n);
+ swapl(&stuff->minorVersion, n);
+ return (*ProcXFixesVector[stuff->xfixesReqType]) (client);
+}
+
+static int (*SProcXFixesVector[XFixesNumberRequests])(ClientPtr) = {
+/*************** Version 1 ******************/
+ SProcXFixesQueryVersion,
+ SProcXFixesChangeSaveSet,
+ SProcXFixesSelectSelectionInput,
+ SProcXFixesSelectCursorInput,
+ SProcXFixesGetCursorImage,
+/*************** Version 2 ******************/
+ SProcXFixesCreateRegion,
+ SProcXFixesCreateRegionFromBitmap,
+ SProcXFixesCreateRegionFromWindow,
+ SProcXFixesCreateRegionFromGC,
+ SProcXFixesCreateRegionFromPicture,
+ SProcXFixesDestroyRegion,
+ SProcXFixesSetRegion,
+ SProcXFixesCopyRegion,
+ SProcXFixesCombineRegion,
+ SProcXFixesCombineRegion,
+ SProcXFixesCombineRegion,
+ SProcXFixesInvertRegion,
+ SProcXFixesTranslateRegion,
+ SProcXFixesRegionExtents,
+ SProcXFixesFetchRegion,
+ SProcXFixesSetGCClipRegion,
+ SProcXFixesSetWindowShapeRegion,
+ SProcXFixesSetPictureClipRegion,
+ SProcXFixesSetCursorName,
+ SProcXFixesGetCursorName,
+ SProcXFixesGetCursorImageAndName,
+ SProcXFixesChangeCursor,
+ SProcXFixesChangeCursorByName,
+/*************** Version 3 ******************/
+ SProcXFixesExpandRegion,
+/*************** Version 4 ****************/
+ SProcXFixesHideCursor,
+ SProcXFixesShowCursor,
+};
+
+static int
+SProcXFixesDispatch (ClientPtr client)
+{
+ REQUEST(xXFixesReq);
+ if (stuff->xfixesReqType >= XFixesNumberRequests)
+ return BadRequest;
+ return (*SProcXFixesVector[stuff->xfixesReqType]) (client);
+}
+
+static void
+XFixesClientCallback (CallbackListPtr *list,
+ pointer closure,
+ pointer data)
+{
+ NewClientInfoRec *clientinfo = (NewClientInfoRec *) data;
+ ClientPtr pClient = clientinfo->client;
+ XFixesClientPtr pXFixesClient = GetXFixesClient (pClient);
+
+ pXFixesClient->major_version = 0;
+ pXFixesClient->minor_version = 0;
+}
+
+/*ARGSUSED*/
+static void
+XFixesResetProc (ExtensionEntry *extEntry)
+{
+ DeleteCallback (&ClientStateCallback, XFixesClientCallback, 0);
+}
+
+void
+XFixesExtensionInit(void)
+{
+ ExtensionEntry *extEntry;
+
+ if (!dixRegisterPrivateKey(&XFixesClientPrivateKeyRec, PRIVATE_CLIENT, sizeof (XFixesClientRec)))
+ return;
+ if (!AddCallback (&ClientStateCallback, XFixesClientCallback, 0))
+ return;
+
+ if (XFixesSelectionInit() && XFixesCursorInit () && XFixesRegionInit () &&
+ (extEntry = AddExtension(XFIXES_NAME, XFixesNumberEvents,
+ XFixesNumberErrors,
+ ProcXFixesDispatch, SProcXFixesDispatch,
+ XFixesResetProc, StandardMinorOpcode)) != 0)
+ {
+ XFixesReqCode = (unsigned char)extEntry->base;
+ XFixesEventBase = extEntry->eventBase;
+ XFixesErrorBase = extEntry->errorBase;
+ EventSwapVector[XFixesEventBase + XFixesSelectionNotify] =
+ (EventSwapPtr) SXFixesSelectionNotifyEvent;
+ EventSwapVector[XFixesEventBase + XFixesCursorNotify] =
+ (EventSwapPtr) SXFixesCursorNotifyEvent;
+ SetResourceTypeErrorValue(RegionResType, XFixesErrorBase + BadRegion);
+ }
+}
+
+#ifdef PANORAMIX
+
+int (*PanoramiXSaveXFixesVector[XFixesNumberRequests])(ClientPtr);
+
+void
+PanoramiXFixesInit (void)
+{
+ int i;
+
+ for (i = 0; i < XFixesNumberRequests; i++)
+ PanoramiXSaveXFixesVector[i] = ProcXFixesVector[i];
+ /*
+ * Stuff in Xinerama aware request processing hooks
+ */
+ ProcXFixesVector[X_XFixesSetGCClipRegion] = PanoramiXFixesSetGCClipRegion;
+ ProcXFixesVector[X_XFixesSetWindowShapeRegion] = PanoramiXFixesSetWindowShapeRegion;
+ ProcXFixesVector[X_XFixesSetPictureClipRegion] = PanoramiXFixesSetPictureClipRegion;
+}
+
+void
+PanoramiXFixesReset (void)
+{
+ int i;
+
+ for (i = 0; i < XFixesNumberRequests; i++)
+ ProcXFixesVector[i] = PanoramiXSaveXFixesVector[i];
+}
+
+#endif
diff --git a/xorg-server/xkb/xkb.c b/xorg-server/xkb/xkb.c
index 4044d333d..86231a895 100644
--- a/xorg-server/xkb/xkb.c
+++ b/xorg-server/xkb/xkb.c
@@ -5586,6 +5586,7 @@ ProcXkbGetKbdByName(ClientPtr client)
{
DeviceIntPtr dev;
DeviceIntPtr tmpd;
+ DeviceIntPtr master;
xkbGetKbdByNameReply rep = {0};
xkbGetMapReply mrep = {0};
xkbGetCompatMapReply crep = {0};
@@ -5611,6 +5612,7 @@ ProcXkbGetKbdByName(ClientPtr client)
return BadAccess;
CHK_KBD_DEVICE(dev, stuff->deviceSpec, client, access_mode);
+ master = GetMaster(dev, MASTER_KEYBOARD);
xkb = dev->key->xkbInfo->desc;
status= Success;
@@ -5869,25 +5871,6 @@ ProcXkbGetKbdByName(ClientPtr client)
}
xkb->ctrls->num_groups= nTG;
- for (tmpd = inputInfo.devices; tmpd; tmpd = tmpd->next) {
- if ((tmpd == dev) || (!IsMaster(tmpd) && GetMaster(tmpd, MASTER_KEYBOARD) == dev)) {
- if (tmpd != dev)
- XkbCopyDeviceKeymap(tmpd, dev);
-
- if (tmpd->kbdfeed && tmpd->kbdfeed->xkb_sli) {
- old_sli = tmpd->kbdfeed->xkb_sli;
- tmpd->kbdfeed->xkb_sli = NULL;
- sli = XkbAllocSrvLedInfo(tmpd, tmpd->kbdfeed, NULL, 0);
- if (sli) {
- sli->explicitState = old_sli->explicitState;
- sli->effectiveState = old_sli->effectiveState;
- }
- tmpd->kbdfeed->xkb_sli = sli;
- XkbFreeSrvLedInfo(old_sli);
- }
- }
- }
-
nkn.deviceID= nkn.oldDeviceID= dev->id;
nkn.minKeyCode= new->min_key_code;
nkn.maxKeyCode= new->max_key_code;
@@ -5900,13 +5883,29 @@ ProcXkbGetKbdByName(ClientPtr client)
nkn.changed|= XkbNKN_GeometryMask;
XkbSendNewKeyboardNotify(dev,&nkn);
- if (!IsMaster(dev)) {
- DeviceIntPtr master = GetMaster(dev, MASTER_KEYBOARD);
- if (master && master->lastSlave == dev) {
- XkbCopyDeviceKeymap(master, dev);
- XkbSendNewKeyboardNotify(dev,&nkn);
- }
- }
+ /* Update the map and LED info on the device itself, as well as
+ * any slaves if it's an MD, or its MD if it's an SD and was the
+ * last device used on that MD. */
+ for (tmpd = inputInfo.devices; tmpd; tmpd = tmpd->next) {
+ if (tmpd != dev && GetMaster(tmpd, MASTER_KEYBOARD) != dev &&
+ (tmpd != master || dev != master->lastSlave))
+ continue;
+
+ if (tmpd != dev)
+ XkbCopyDeviceKeymap(tmpd, dev);
+
+ if (tmpd->kbdfeed && tmpd->kbdfeed->xkb_sli) {
+ old_sli = tmpd->kbdfeed->xkb_sli;
+ tmpd->kbdfeed->xkb_sli = NULL;
+ sli = XkbAllocSrvLedInfo(tmpd, tmpd->kbdfeed, NULL, 0);
+ if (sli) {
+ sli->explicitState = old_sli->explicitState;
+ sli->effectiveState = old_sli->effectiveState;
+ }
+ tmpd->kbdfeed->xkb_sli = sli;
+ XkbFreeSrvLedInfo(old_sli);
+ }
+ }
}
if ((new!=NULL)&&(new!=xkb)) {
XkbFreeKeyboard(new,XkbAllComponentsMask,TRUE);
diff --git a/xorg-server/xkb/xkbActions.c b/xorg-server/xkb/xkbActions.c
index 8cd9b44a1..4b5405ab0 100644
--- a/xorg-server/xkb/xkbActions.c
+++ b/xorg-server/xkb/xkbActions.c
@@ -1,1434 +1,1434 @@
-/************************************************************
-Copyright (c) 1993 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 <stdio.h>
-#include <math.h>
-#include <X11/X.h>
-#include <X11/Xproto.h>
-#include <X11/keysym.h>
-#include "misc.h"
-#include "inputstr.h"
-#include "exevents.h"
-#include "eventstr.h"
-#include <xkbsrv.h>
-#include "xkb.h"
-#include <ctype.h>
-#include "mi.h"
-#include "mipointer.h"
-#include "inpututils.h"
-#define EXTENSION_EVENT_BASE 64
-
-DevPrivateKeyRec xkbDevicePrivateKeyRec;
-
-void XkbFakeDeviceButton(DeviceIntPtr dev,Bool press,int button);
-static void XkbFakePointerMotion(DeviceIntPtr dev, unsigned flags,int x,int y);
-
-void
-xkbUnwrapProc(DeviceIntPtr device, DeviceHandleProc proc,
- pointer data)
-{
- xkbDeviceInfoPtr xkbPrivPtr = XKBDEVICEINFO(device);
- ProcessInputProc backupproc;
- if(xkbPrivPtr->unwrapProc)
- xkbPrivPtr->unwrapProc = NULL;
-
- UNWRAP_PROCESS_INPUT_PROC(device,xkbPrivPtr, backupproc);
- proc(device,data);
- COND_WRAP_PROCESS_INPUT_PROC(device,xkbPrivPtr,
- backupproc,xkbUnwrapProc);
-}
-
-Bool
-XkbInitPrivates(void)
-{
- return dixRegisterPrivateKey(&xkbDevicePrivateKeyRec, PRIVATE_DEVICE, sizeof(xkbDeviceInfoRec));
-}
-
-void
-XkbSetExtension(DeviceIntPtr device, ProcessInputProc proc)
-{
- xkbDeviceInfoPtr xkbPrivPtr = XKBDEVICEINFO(device);
- WRAP_PROCESS_INPUT_PROC(device, xkbPrivPtr, proc, xkbUnwrapProc);
-}
-
-/***====================================================================***/
-
-static XkbAction
-_FixUpAction(XkbDescPtr xkb,XkbAction *act)
-{
-static XkbAction fake;
-
- if (XkbIsPtrAction(act)&&(!(xkb->ctrls->enabled_ctrls&XkbMouseKeysMask))) {
- fake.type = XkbSA_NoAction;
- return fake;
- }
- if (xkb->ctrls->enabled_ctrls&XkbStickyKeysMask) {
- if (act->any.type==XkbSA_SetMods) {
- fake.mods.type = XkbSA_LatchMods;
- fake.mods.mask = act->mods.mask;
- if (XkbAX_NeedOption(xkb->ctrls,XkbAX_LatchToLockMask))
- fake.mods.flags= XkbSA_ClearLocks|XkbSA_LatchToLock;
- else fake.mods.flags= XkbSA_ClearLocks;
- return fake;
- }
- if (act->any.type==XkbSA_SetGroup) {
- fake.group.type = XkbSA_LatchGroup;
- if (XkbAX_NeedOption(xkb->ctrls,XkbAX_LatchToLockMask))
- fake.group.flags= XkbSA_ClearLocks|XkbSA_LatchToLock;
- else fake.group.flags= XkbSA_ClearLocks;
- XkbSASetGroup(&fake.group,XkbSAGroup(&act->group));
- return fake;
- }
- }
- return *act;
-}
-
-static XkbAction
-XkbGetKeyAction(XkbSrvInfoPtr xkbi,XkbStatePtr xkbState,CARD8 key)
-{
-int effectiveGroup;
-int col;
-XkbDescPtr xkb;
-XkbKeyTypePtr type;
-XkbAction * pActs;
-static XkbAction fake;
-
- xkb= xkbi->desc;
- if (!XkbKeyHasActions(xkb,key) || !XkbKeycodeInRange(xkb,key)) {
- fake.type = XkbSA_NoAction;
- return fake;
- }
- pActs= XkbKeyActionsPtr(xkb,key);
- col= 0;
-
- effectiveGroup = XkbGetEffectiveGroup(xkbi, xkbState, key);
- if (effectiveGroup != XkbGroup1Index)
- col += (effectiveGroup * XkbKeyGroupsWidth(xkb, key));
-
- type= XkbKeyKeyType(xkb,key,effectiveGroup);
- if (type->map!=NULL) {
- register unsigned i,mods;
- register XkbKTMapEntryPtr entry;
- mods= xkbState->mods&type->mods.mask;
- for (entry= type->map,i=0;i<type->map_count;i++,entry++) {
- if ((entry->active)&&(entry->mods.mask==mods)) {
- col+= entry->level;
- break;
- }
- }
- }
- if (pActs[col].any.type==XkbSA_NoAction)
- return pActs[col];
- fake= _FixUpAction(xkb,&pActs[col]);
- return fake;
-}
-
-static XkbAction
-XkbGetButtonAction(DeviceIntPtr kbd,DeviceIntPtr dev,int button)
-{
-XkbAction fake;
- if ((dev->button)&&(dev->button->xkb_acts)) {
- if (dev->button->xkb_acts[button-1].any.type!=XkbSA_NoAction) {
- fake= _FixUpAction(kbd->key->xkbInfo->desc,
- &dev->button->xkb_acts[button-1]);
- return fake;
- }
- }
- fake.any.type= XkbSA_NoAction;
- return fake;
-}
-
-/***====================================================================***/
-
-#define SYNTHETIC_KEYCODE 1
-#define BTN_ACT_FLAG 0x100
-
-static int
-_XkbFilterSetState( XkbSrvInfoPtr xkbi,
- XkbFilterPtr filter,
- unsigned keycode,
- XkbAction *pAction)
-{
- if (filter->keycode==0) { /* initial press */
- filter->keycode = keycode;
- filter->active = 1;
- filter->filterOthers = ((pAction->mods.mask&XkbSA_ClearLocks)!=0);
- filter->priv = 0;
- filter->filter = _XkbFilterSetState;
- if (pAction->type==XkbSA_SetMods) {
- filter->upAction = *pAction;
- xkbi->setMods= pAction->mods.mask;
- }
- else {
- xkbi->groupChange = XkbSAGroup(&pAction->group);
- if (pAction->group.flags&XkbSA_GroupAbsolute)
- xkbi->groupChange-= xkbi->state.base_group;
- filter->upAction= *pAction;
- XkbSASetGroup(&filter->upAction.group,xkbi->groupChange);
- }
- }
- else if (filter->keycode==keycode) {
- if (filter->upAction.type==XkbSA_SetMods) {
- xkbi->clearMods = filter->upAction.mods.mask;
- if (filter->upAction.mods.flags&XkbSA_ClearLocks) {
- xkbi->state.locked_mods&= ~filter->upAction.mods.mask;
- }
- }
- else {
- if (filter->upAction.group.flags&XkbSA_ClearLocks) {
- xkbi->state.locked_group = 0;
- }
- xkbi->groupChange = -XkbSAGroup(&filter->upAction.group);
- }
- filter->active = 0;
- }
- else {
- filter->upAction.mods.flags&= ~XkbSA_ClearLocks;
- filter->filterOthers = 0;
- }
- return 1;
-}
-
-#define LATCH_KEY_DOWN 1
-#define LATCH_PENDING 2
-#define NO_LATCH 3
-
-static int
-_XkbFilterLatchState( XkbSrvInfoPtr xkbi,
- XkbFilterPtr filter,
- unsigned keycode,
- XkbAction * pAction)
-{
-
- if (filter->keycode==0) { /* initial press */
- filter->keycode = keycode;
- filter->active = 1;
- filter->filterOthers = 1;
- filter->priv = LATCH_KEY_DOWN;
- filter->filter = _XkbFilterLatchState;
- if (pAction->type==XkbSA_LatchMods) {
- filter->upAction = *pAction;
- xkbi->setMods = pAction->mods.mask;
- }
- else {
- xkbi->groupChange = XkbSAGroup(&pAction->group);
- if (pAction->group.flags&XkbSA_GroupAbsolute)
- xkbi->groupChange-= xkbi->state.base_group;
- filter->upAction= *pAction;
- XkbSASetGroup(&filter->upAction.group,xkbi->groupChange);
- }
- }
- else if ( pAction && (filter->priv==LATCH_PENDING) ) {
- if (((1<<pAction->type)&XkbSA_BreakLatch)!=0) {
- filter->active = 0;
- if (filter->upAction.type==XkbSA_LatchMods)
- xkbi->state.latched_mods&= ~filter->upAction.mods.mask;
- else xkbi->state.latched_group-=XkbSAGroup(&filter->upAction.group);
- }
- else if ((pAction->type==filter->upAction.type)&&
- (pAction->mods.flags==filter->upAction.mods.flags)&&
- (pAction->mods.mask==filter->upAction.mods.mask)) {
- if (filter->upAction.mods.flags&XkbSA_LatchToLock) {
- XkbControlsPtr ctrls= xkbi->desc->ctrls;
- if (filter->upAction.type==XkbSA_LatchMods)
- pAction->mods.type= XkbSA_LockMods;
- else pAction->group.type= XkbSA_LockGroup;
- if (XkbAX_NeedFeedback(ctrls,XkbAX_StickyKeysFBMask)&&
- (ctrls->enabled_ctrls&XkbStickyKeysMask)) {
- XkbDDXAccessXBeep(xkbi->device,_BEEP_STICKY_LOCK,
- XkbStickyKeysMask);
- }
- }
- else {
- if (filter->upAction.type==XkbSA_LatchMods)
- pAction->mods.type= XkbSA_SetMods;
- else pAction->group.type= XkbSA_SetGroup;
- }
- if (filter->upAction.type==XkbSA_LatchMods)
- xkbi->state.latched_mods&= ~filter->upAction.mods.mask;
- else xkbi->state.latched_group-=XkbSAGroup(&filter->upAction.group);
- filter->active = 0;
- }
- }
- else if (filter->keycode==keycode) { /* release */
- XkbControlsPtr ctrls= xkbi->desc->ctrls;
- int needBeep;
- int beepType= _BEEP_NONE;
-
- needBeep= ((ctrls->enabled_ctrls&XkbStickyKeysMask)&&
- XkbAX_NeedFeedback(ctrls,XkbAX_StickyKeysFBMask));
- if (filter->upAction.type==XkbSA_LatchMods) {
- xkbi->clearMods = filter->upAction.mods.mask;
- if ((filter->upAction.mods.flags&XkbSA_ClearLocks)&&
- (xkbi->clearMods&xkbi->state.locked_mods)==xkbi->clearMods) {
- xkbi->state.locked_mods&= ~xkbi->clearMods;
- filter->priv= NO_LATCH;
- beepType= _BEEP_STICKY_UNLOCK;
- }
- }
- else {
- xkbi->groupChange = -XkbSAGroup(&filter->upAction.group);
- if ((filter->upAction.group.flags&XkbSA_ClearLocks)&&
- (xkbi->state.locked_group)) {
- xkbi->state.locked_group = 0;
- filter->priv = NO_LATCH;
- beepType= _BEEP_STICKY_UNLOCK;
- }
- }
- if (filter->priv==NO_LATCH) {
- filter->active= 0;
- }
- else {
- filter->priv= LATCH_PENDING;
- if (filter->upAction.type==XkbSA_LatchMods) {
- xkbi->state.latched_mods |= filter->upAction.mods.mask;
- needBeep = xkbi->state.latched_mods ? needBeep : 0;
- xkbi->state.latched_mods |= filter->upAction.mods.mask;
- }
- else {
- xkbi->state.latched_group+= XkbSAGroup(&filter->upAction.group);
- }
- if (needBeep && (beepType==_BEEP_NONE))
- beepType= _BEEP_STICKY_LATCH;
- }
- if (needBeep && (beepType!=_BEEP_NONE))
- XkbDDXAccessXBeep(xkbi->device,beepType,XkbStickyKeysMask);
- }
- else if (filter->priv==LATCH_KEY_DOWN) {
- filter->priv= NO_LATCH;
- filter->filterOthers = 0;
- }
- return 1;
-}
-
-static int
-_XkbFilterLockState( XkbSrvInfoPtr xkbi,
- XkbFilterPtr filter,
- unsigned keycode,
- XkbAction * pAction)
-{
- if (pAction&&(pAction->type==XkbSA_LockGroup)) {
- if (pAction->group.flags&XkbSA_GroupAbsolute)
- xkbi->state.locked_group= XkbSAGroup(&pAction->group);
- else xkbi->state.locked_group+= XkbSAGroup(&pAction->group);
- return 1;
- }
- if (filter->keycode==0) { /* initial press */
- filter->keycode = keycode;
- filter->active = 1;
- filter->filterOthers = 0;
- filter->priv = 0;
- filter->filter = _XkbFilterLockState;
- filter->upAction = *pAction;
- xkbi->state.locked_mods^= pAction->mods.mask;
- xkbi->setMods = pAction->mods.mask;
- }
- else if (filter->keycode==keycode) {
- filter->active = 0;
- xkbi->clearMods = filter->upAction.mods.mask;
- }
- return 1;
-}
-
-#define ISO_KEY_DOWN 0
-#define NO_ISO_LOCK 1
-
-static int
-_XkbFilterISOLock( XkbSrvInfoPtr xkbi,
- XkbFilterPtr filter,
- unsigned keycode,
- XkbAction * pAction)
-{
-
- if (filter->keycode==0) { /* initial press */
- CARD8 flags= pAction->iso.flags;
-
- filter->keycode = keycode;
- filter->active = 1;
- filter->filterOthers = 1;
- filter->priv = ISO_KEY_DOWN;
- filter->upAction = *pAction;
- filter->filter = _XkbFilterISOLock;
- if (flags&XkbSA_ISODfltIsGroup) {
- xkbi->groupChange = XkbSAGroup(&pAction->iso);
- xkbi->setMods = 0;
- }
- else {
- xkbi->setMods = pAction->iso.mask;
- xkbi->groupChange = 0;
- }
- if ((!(flags&XkbSA_ISONoAffectMods))&&(xkbi->state.base_mods)) {
- filter->priv= NO_ISO_LOCK;
- xkbi->state.locked_mods^= xkbi->state.base_mods;
- }
- if ((!(flags&XkbSA_ISONoAffectGroup))&&(xkbi->state.base_group)) {
-/* 6/22/93 (ef) -- lock groups if group key is down first */
- }
- if (!(flags&XkbSA_ISONoAffectPtr)) {
-/* 6/22/93 (ef) -- lock mouse buttons if they're down */
- }
- }
- else if (filter->keycode==keycode) {
- CARD8 flags= filter->upAction.iso.flags;
-
- if (flags&XkbSA_ISODfltIsGroup) {
- xkbi->groupChange = -XkbSAGroup(&filter->upAction.iso);
- xkbi->clearMods = 0;
- if (filter->priv==ISO_KEY_DOWN)
- xkbi->state.locked_group+= XkbSAGroup(&filter->upAction.iso);
- }
- else {
- xkbi->clearMods= filter->upAction.iso.mask;
- xkbi->groupChange= 0;
- if (filter->priv==ISO_KEY_DOWN)
- xkbi->state.locked_mods^= filter->upAction.iso.mask;
- }
- filter->active = 0;
- }
- else if (pAction) {
- CARD8 flags= filter->upAction.iso.flags;
-
- switch (pAction->type) {
- case XkbSA_SetMods: case XkbSA_LatchMods:
- if (!(flags&XkbSA_ISONoAffectMods)) {
- pAction->type= XkbSA_LockMods;
- filter->priv= NO_ISO_LOCK;
- }
- break;
- case XkbSA_SetGroup: case XkbSA_LatchGroup:
- if (!(flags&XkbSA_ISONoAffectGroup)) {
- pAction->type= XkbSA_LockGroup;
- filter->priv= NO_ISO_LOCK;
- }
- break;
- case XkbSA_PtrBtn:
- if (!(flags&XkbSA_ISONoAffectPtr)) {
- pAction->type= XkbSA_LockPtrBtn;
- filter->priv= NO_ISO_LOCK;
- }
- break;
- case XkbSA_SetControls:
- if (!(flags&XkbSA_ISONoAffectCtrls)) {
- pAction->type= XkbSA_LockControls;
- filter->priv= NO_ISO_LOCK;
- }
- break;
- }
- }
- return 1;
-}
-
-
-static CARD32
-_XkbPtrAccelExpire(OsTimerPtr timer,CARD32 now,pointer arg)
-{
-XkbSrvInfoPtr xkbi= (XkbSrvInfoPtr)arg;
-XkbControlsPtr ctrls= xkbi->desc->ctrls;
-int dx,dy;
-
- if (xkbi->mouseKey==0)
- return 0;
-
- if (xkbi->mouseKeysAccel) {
- if ((xkbi->mouseKeysCounter)<ctrls->mk_time_to_max) {
- double step;
- xkbi->mouseKeysCounter++;
- step= xkbi->mouseKeysCurveFactor*
- pow((double)xkbi->mouseKeysCounter,xkbi->mouseKeysCurve);
- if (xkbi->mouseKeysDX<0)
- dx= floor( ((double)xkbi->mouseKeysDX)*step );
- else dx= ceil( ((double)xkbi->mouseKeysDX)*step );
- if (xkbi->mouseKeysDY<0)
- dy= floor( ((double)xkbi->mouseKeysDY)*step );
- else dy= ceil( ((double)xkbi->mouseKeysDY)*step );
- }
- else {
- dx= xkbi->mouseKeysDX*ctrls->mk_max_speed;
- dy= xkbi->mouseKeysDY*ctrls->mk_max_speed;
- }
- if (xkbi->mouseKeysFlags&XkbSA_MoveAbsoluteX)
- dx= xkbi->mouseKeysDX;
- if (xkbi->mouseKeysFlags&XkbSA_MoveAbsoluteY)
- dy= xkbi->mouseKeysDY;
- }
- else {
- dx= xkbi->mouseKeysDX;
- dy= xkbi->mouseKeysDY;
- }
- XkbFakePointerMotion(xkbi->device, xkbi->mouseKeysFlags,dx,dy);
- return xkbi->desc->ctrls->mk_interval;
-}
-
-static int
-_XkbFilterPointerMove( XkbSrvInfoPtr xkbi,
- XkbFilterPtr filter,
- unsigned keycode,
- XkbAction * pAction)
-{
-int x,y;
-Bool accel;
-
- if (filter->keycode==0) { /* initial press */
- filter->keycode = keycode;
- filter->active = 1;
- filter->filterOthers = 0;
- filter->priv=0;
- filter->filter = _XkbFilterPointerMove;
- filter->upAction= *pAction;
- xkbi->mouseKeysCounter= 0;
- xkbi->mouseKey= keycode;
- accel= ((pAction->ptr.flags&XkbSA_NoAcceleration)==0);
- x= XkbPtrActionX(&pAction->ptr);
- y= XkbPtrActionY(&pAction->ptr);
- XkbFakePointerMotion(xkbi->device, pAction->ptr.flags,x,y);
- AccessXCancelRepeatKey(xkbi,keycode);
- xkbi->mouseKeysAccel= accel&&
- (xkbi->desc->ctrls->enabled_ctrls&XkbMouseKeysAccelMask);
- xkbi->mouseKeysFlags= pAction->ptr.flags;
- xkbi->mouseKeysDX= XkbPtrActionX(&pAction->ptr);
- xkbi->mouseKeysDY= XkbPtrActionY(&pAction->ptr);
- xkbi->mouseKeyTimer= TimerSet(xkbi->mouseKeyTimer, 0,
- xkbi->desc->ctrls->mk_delay,
- _XkbPtrAccelExpire,(pointer)xkbi);
- }
- else if (filter->keycode==keycode) {
- filter->active = 0;
- if (xkbi->mouseKey==keycode) {
- xkbi->mouseKey= 0;
- xkbi->mouseKeyTimer= TimerSet(xkbi->mouseKeyTimer, 0, 0,
- NULL, NULL);
- }
- }
- return 0;
-}
-
-static int
-_XkbFilterPointerBtn( XkbSrvInfoPtr xkbi,
- XkbFilterPtr filter,
- unsigned keycode,
- XkbAction * pAction)
-{
- if (filter->keycode==0) { /* initial press */
- int button= pAction->btn.button;
-
- if (button==XkbSA_UseDfltButton)
- button = xkbi->desc->ctrls->mk_dflt_btn;
-
- filter->keycode = keycode;
- filter->active = 1;
- filter->filterOthers = 0;
- filter->priv=0;
- filter->filter = _XkbFilterPointerBtn;
- filter->upAction= *pAction;
- filter->upAction.btn.button= button;
- switch (pAction->type) {
- case XkbSA_LockPtrBtn:
- if (((xkbi->lockedPtrButtons&(1<<button))==0)&&
- ((pAction->btn.flags&XkbSA_LockNoLock)==0)) {
- xkbi->lockedPtrButtons|= (1<<button);
- AccessXCancelRepeatKey(xkbi,keycode);
- XkbFakeDeviceButton(xkbi->device, 1, button);
- filter->upAction.type= XkbSA_NoAction;
- }
- break;
- case XkbSA_PtrBtn:
- {
- register int i,nClicks;
- AccessXCancelRepeatKey(xkbi,keycode);
- if (pAction->btn.count>0) {
- nClicks= pAction->btn.count;
- for (i=0;i<nClicks;i++) {
- XkbFakeDeviceButton(xkbi->device, 1, button);
- XkbFakeDeviceButton(xkbi->device, 0, button);
- }
- filter->upAction.type= XkbSA_NoAction;
- }
- else XkbFakeDeviceButton(xkbi->device, 1, button);
- }
- break;
- case XkbSA_SetPtrDflt:
- {
- XkbControlsPtr ctrls= xkbi->desc->ctrls;
- XkbControlsRec old;
- xkbControlsNotify cn;
-
- old= *ctrls;
- AccessXCancelRepeatKey(xkbi,keycode);
- switch (pAction->dflt.affect) {
- case XkbSA_AffectDfltBtn:
- if (pAction->dflt.flags&XkbSA_DfltBtnAbsolute)
- ctrls->mk_dflt_btn=
- XkbSAPtrDfltValue(&pAction->dflt);
- else {
- ctrls->mk_dflt_btn+=
- XkbSAPtrDfltValue(&pAction->dflt);
- if (ctrls->mk_dflt_btn>5)
- ctrls->mk_dflt_btn= 5;
- else if (ctrls->mk_dflt_btn<1)
- ctrls->mk_dflt_btn= 1;
- }
- break;
- default:
- ErrorF(
- "Attempt to change unknown pointer default (%d) ignored\n",
- pAction->dflt.affect);
- break;
- }
- if (XkbComputeControlsNotify(xkbi->device,
- &old,xkbi->desc->ctrls,
- &cn,FALSE)) {
- cn.keycode = keycode;
- /* XXX: what about DeviceKeyPress? */
- cn.eventType = KeyPress;
- cn.requestMajor = 0;
- cn.requestMinor = 0;
- XkbSendControlsNotify(xkbi->device,&cn);
- }
- }
- break;
- }
- }
- else if (filter->keycode==keycode) {
- int button= filter->upAction.btn.button;
-
- switch (filter->upAction.type) {
- case XkbSA_LockPtrBtn:
- if (((filter->upAction.btn.flags&XkbSA_LockNoUnlock)!=0)||
- ((xkbi->lockedPtrButtons&(1<<button))==0)) {
- break;
- }
- xkbi->lockedPtrButtons&= ~(1<<button);
-
- if (IsMaster(xkbi->device))
- {
- XkbMergeLockedPtrBtns(xkbi->device);
- /* One SD still has lock set, don't post event */
- if ((xkbi->lockedPtrButtons & (1 << button)) != 0)
- break;
- }
-
- /* fallthrough */
- case XkbSA_PtrBtn:
- XkbFakeDeviceButton(xkbi->device, 0, button);
- break;
- }
- filter->active = 0;
- }
- return 0;
-}
-
-static int
-_XkbFilterControls( XkbSrvInfoPtr xkbi,
- XkbFilterPtr filter,
- unsigned keycode,
- XkbAction * pAction)
-{
-XkbControlsRec old;
-XkbControlsPtr ctrls;
-DeviceIntPtr kbd;
-unsigned int change;
-XkbEventCauseRec cause;
-
- kbd= xkbi->device;
- ctrls= xkbi->desc->ctrls;
- old= *ctrls;
- if (filter->keycode==0) { /* initial press */
- filter->keycode = keycode;
- filter->active = 1;
- filter->filterOthers = 0;
- change= XkbActionCtrls(&pAction->ctrls);
- filter->priv = change;
- filter->filter = _XkbFilterControls;
- filter->upAction = *pAction;
-
- if (pAction->type==XkbSA_LockControls) {
- filter->priv= (ctrls->enabled_ctrls&change);
- change&= ~ctrls->enabled_ctrls;
- }
-
- if (change) {
- xkbControlsNotify cn;
- XkbSrvLedInfoPtr sli;
-
- ctrls->enabled_ctrls|= change;
- if (XkbComputeControlsNotify(kbd,&old,ctrls,&cn,FALSE)) {
- cn.keycode = keycode;
- /* XXX: what about DeviceKeyPress? */
- cn.eventType = KeyPress;
- cn.requestMajor = 0;
- cn.requestMinor = 0;
- XkbSendControlsNotify(kbd,&cn);
- }
-
- XkbSetCauseKey(&cause,keycode,KeyPress);
-
- /* If sticky keys were disabled, clear all locks and latches */
- if ((old.enabled_ctrls&XkbStickyKeysMask)&&
- (!(ctrls->enabled_ctrls&XkbStickyKeysMask))) {
- XkbClearAllLatchesAndLocks(kbd,xkbi,FALSE,&cause);
- }
- sli= XkbFindSrvLedInfo(kbd,XkbDfltXIClass,XkbDfltXIId,0);
- XkbUpdateIndicators(kbd,sli->usesControls,TRUE,NULL,&cause);
- if (XkbAX_NeedFeedback(ctrls,XkbAX_FeatureFBMask))
- XkbDDXAccessXBeep(kbd,_BEEP_FEATURE_ON,change);
- }
- }
- else if (filter->keycode==keycode) {
- change= filter->priv;
- if (change) {
- xkbControlsNotify cn;
- XkbSrvLedInfoPtr sli;
-
- ctrls->enabled_ctrls&= ~change;
- if (XkbComputeControlsNotify(kbd,&old,ctrls,&cn,FALSE)) {
- cn.keycode = keycode;
- cn.eventType = KeyRelease;
- cn.requestMajor = 0;
- cn.requestMinor = 0;
- XkbSendControlsNotify(kbd,&cn);
- }
-
- XkbSetCauseKey(&cause,keycode,KeyRelease);
- /* If sticky keys were disabled, clear all locks and latches */
- if ((old.enabled_ctrls&XkbStickyKeysMask)&&
- (!(ctrls->enabled_ctrls&XkbStickyKeysMask))) {
- XkbClearAllLatchesAndLocks(kbd,xkbi,FALSE,&cause);
- }
- sli= XkbFindSrvLedInfo(kbd,XkbDfltXIClass,XkbDfltXIId,0);
- XkbUpdateIndicators(kbd,sli->usesControls,TRUE,NULL,&cause);
- if (XkbAX_NeedFeedback(ctrls,XkbAX_FeatureFBMask))
- XkbDDXAccessXBeep(kbd,_BEEP_FEATURE_OFF,change);
- }
- filter->keycode= 0;
- filter->active= 0;
- }
- return 1;
-}
-
-static int
-_XkbFilterActionMessage(XkbSrvInfoPtr xkbi,
- XkbFilterPtr filter,
- unsigned keycode,
- XkbAction * pAction)
-{
-XkbMessageAction * pMsg;
-DeviceIntPtr kbd;
-
- kbd= xkbi->device;
- if (filter->keycode==0) { /* initial press */
- pMsg= &pAction->msg;
- if ((pMsg->flags&XkbSA_MessageOnRelease)||
- ((pMsg->flags&XkbSA_MessageGenKeyEvent)==0)) {
- filter->keycode = keycode;
- filter->active = 1;
- filter->filterOthers = 0;
- filter->priv = 0;
- filter->filter = _XkbFilterActionMessage;
- filter->upAction = *pAction;
- }
- if (pMsg->flags&XkbSA_MessageOnPress) {
- xkbActionMessage msg;
-
- msg.keycode= keycode;
- msg.press= 1;
- msg.keyEventFollows=((pMsg->flags&XkbSA_MessageGenKeyEvent)!=0);
- memcpy((char *)msg.message,
- (char *)pMsg->message,XkbActionMessageLength);
- XkbSendActionMessage(kbd,&msg);
- }
- return ((pAction->msg.flags&XkbSA_MessageGenKeyEvent)!=0);
- }
- else if (filter->keycode==keycode) {
- pMsg= &filter->upAction.msg;
- if (pMsg->flags&XkbSA_MessageOnRelease) {
- xkbActionMessage msg;
-
- msg.keycode= keycode;
- msg.press= 0;
- msg.keyEventFollows=((pMsg->flags&XkbSA_MessageGenKeyEvent)!=0);
- memcpy((char *)msg.message,(char *)pMsg->message,
- XkbActionMessageLength);
- XkbSendActionMessage(kbd,&msg);
- }
- filter->keycode= 0;
- filter->active= 0;
- return ((pMsg->flags&XkbSA_MessageGenKeyEvent)!=0);
- }
- return 0;
-}
-
-static int
-_XkbFilterRedirectKey( XkbSrvInfoPtr xkbi,
- XkbFilterPtr filter,
- unsigned keycode,
- XkbAction * pAction)
-{
-DeviceEvent ev;
-int x,y;
-XkbStateRec old;
-unsigned mods,mask;
-xkbDeviceInfoPtr xkbPrivPtr = XKBDEVICEINFO(xkbi->device);
-ProcessInputProc backupproc;
-
- /* never actually used uninitialised, but gcc isn't smart enough
- * to work that out. */
- memset(&old, 0, sizeof(old));
- memset(&ev, 0, sizeof(ev));
-
- if ((filter->keycode!=0)&&(filter->keycode!=keycode))
- return 1;
-
- GetSpritePosition(xkbi->device, &x,&y);
- ev.header = ET_Internal;
- ev.length = sizeof(DeviceEvent);
- ev.time = GetTimeInMillis();
- ev.root_x = x;
- ev.root_y = y;
-
- if (filter->keycode==0) { /* initial press */
- if ((pAction->redirect.new_key<xkbi->desc->min_key_code)||
- (pAction->redirect.new_key>xkbi->desc->max_key_code)) {
- return 1;
- }
- filter->keycode = keycode;
- filter->active = 1;
- filter->filterOthers = 0;
- filter->priv = 0;
- filter->filter = _XkbFilterRedirectKey;
- filter->upAction = *pAction;
-
- ev.type = ET_KeyPress;
- ev.detail.key = pAction->redirect.new_key;
-
- mask= XkbSARedirectVModsMask(&pAction->redirect);
- mods= XkbSARedirectVMods(&pAction->redirect);
- if (mask) XkbVirtualModsToReal(xkbi->desc,mask,&mask);
- if (mods) XkbVirtualModsToReal(xkbi->desc,mods,&mods);
- mask|= pAction->redirect.mods_mask;
- mods|= pAction->redirect.mods;
-
- if ( mask || mods ) {
- old= xkbi->state;
- xkbi->state.base_mods&= ~mask;
- xkbi->state.base_mods|= (mods&mask);
- xkbi->state.latched_mods&= ~mask;
- xkbi->state.latched_mods|= (mods&mask);
- xkbi->state.locked_mods&= ~mask;
- xkbi->state.locked_mods|= (mods&mask);
- XkbComputeDerivedState(xkbi);
- }
-
- UNWRAP_PROCESS_INPUT_PROC(xkbi->device,xkbPrivPtr, backupproc);
- xkbi->device->public.processInputProc((InternalEvent*)&ev, xkbi->device);
- COND_WRAP_PROCESS_INPUT_PROC(xkbi->device, xkbPrivPtr,
- backupproc,xkbUnwrapProc);
-
- if ( mask || mods )
- xkbi->state= old;
- }
- else if (filter->keycode==keycode) {
-
- ev.type = ET_KeyRelease;
- ev.detail.key = filter->upAction.redirect.new_key;
-
- mask= XkbSARedirectVModsMask(&filter->upAction.redirect);
- mods= XkbSARedirectVMods(&filter->upAction.redirect);
- if (mask) XkbVirtualModsToReal(xkbi->desc,mask,&mask);
- if (mods) XkbVirtualModsToReal(xkbi->desc,mods,&mods);
- mask|= filter->upAction.redirect.mods_mask;
- mods|= filter->upAction.redirect.mods;
-
- if ( mask || mods ) {
- old= xkbi->state;
- xkbi->state.base_mods&= ~mask;
- xkbi->state.base_mods|= (mods&mask);
- xkbi->state.latched_mods&= ~mask;
- xkbi->state.latched_mods|= (mods&mask);
- xkbi->state.locked_mods&= ~mask;
- xkbi->state.locked_mods|= (mods&mask);
- XkbComputeDerivedState(xkbi);
- }
-
- UNWRAP_PROCESS_INPUT_PROC(xkbi->device,xkbPrivPtr, backupproc);
- xkbi->device->public.processInputProc((InternalEvent*)&ev, xkbi->device);
- COND_WRAP_PROCESS_INPUT_PROC(xkbi->device, xkbPrivPtr,
- backupproc,xkbUnwrapProc);
-
- if ( mask || mods )
- xkbi->state= old;
-
- filter->keycode= 0;
- filter->active= 0;
- }
- return 0;
-}
-
-static int
-_XkbFilterSwitchScreen( XkbSrvInfoPtr xkbi,
- XkbFilterPtr filter,
- unsigned keycode,
- XkbAction * pAction)
-{
- DeviceIntPtr dev = xkbi->device;
- if (dev == inputInfo.keyboard)
- return 0;
-
- if (filter->keycode==0) { /* initial press */
- filter->keycode = keycode;
- filter->active = 1;
- filter->filterOthers = 0;
- filter->filter = _XkbFilterSwitchScreen;
- AccessXCancelRepeatKey(xkbi, keycode);
- XkbDDXSwitchScreen(dev,keycode,pAction);
- return 0;
- }
- else if (filter->keycode==keycode) {
- filter->active= 0;
- return 0;
- }
- return 1;
-}
-
-static int
-_XkbFilterXF86Private( XkbSrvInfoPtr xkbi,
- XkbFilterPtr filter,
- unsigned keycode,
- XkbAction * pAction)
-{
- DeviceIntPtr dev = xkbi->device;
- if (dev == inputInfo.keyboard)
- return 0;
-
- if (filter->keycode==0) { /* initial press */
- filter->keycode = keycode;
- filter->active = 1;
- filter->filterOthers = 0;
- filter->filter = _XkbFilterXF86Private;
- XkbDDXPrivate(dev,keycode,pAction);
- return 0;
- }
- else if (filter->keycode==keycode) {
- filter->active= 0;
- return 0;
- }
- return 1;
-}
-
-
-static int
-_XkbFilterDeviceBtn( XkbSrvInfoPtr xkbi,
- XkbFilterPtr filter,
- unsigned keycode,
- XkbAction * pAction)
-{
-DeviceIntPtr dev;
-int button;
-
- if (xkbi->device == inputInfo.keyboard)
- return 0;
-
- if (filter->keycode==0) { /* initial press */
- _XkbLookupButtonDevice(&dev, pAction->devbtn.device, serverClient,
- DixUnknownAccess, &button);
- if (!dev || !dev->public.on)
- return 1;
-
- button= pAction->devbtn.button;
- if ((button<1)||(button>dev->button->numButtons))
- return 1;
-
- filter->keycode = keycode;
- filter->active = 1;
- filter->filterOthers = 0;
- filter->priv=0;
- filter->filter = _XkbFilterDeviceBtn;
- filter->upAction= *pAction;
- switch (pAction->type) {
- case XkbSA_LockDeviceBtn:
- if ((pAction->devbtn.flags&XkbSA_LockNoLock)||
- BitIsOn(dev->button->down, button))
- return 0;
- XkbFakeDeviceButton(dev,TRUE,button);
- filter->upAction.type= XkbSA_NoAction;
- break;
- case XkbSA_DeviceBtn:
- if (pAction->devbtn.count>0) {
- int nClicks,i;
- nClicks= pAction->btn.count;
- for (i=0;i<nClicks;i++) {
- XkbFakeDeviceButton(dev,TRUE,button);
- XkbFakeDeviceButton(dev,FALSE,button);
- }
- filter->upAction.type= XkbSA_NoAction;
- }
- else XkbFakeDeviceButton(dev,TRUE,button);
- break;
- }
- }
- else if (filter->keycode==keycode) {
- int button;
-
- filter->active= 0;
- _XkbLookupButtonDevice(&dev, filter->upAction.devbtn.device,
- serverClient, DixUnknownAccess, &button);
- if (!dev || !dev->public.on)
- return 1;
-
- button= filter->upAction.btn.button;
- switch (filter->upAction.type) {
- case XkbSA_LockDeviceBtn:
- if ((filter->upAction.devbtn.flags&XkbSA_LockNoUnlock)||
- !BitIsOn(dev->button->down, button))
- return 0;
- XkbFakeDeviceButton(dev,FALSE,button);
- break;
- case XkbSA_DeviceBtn:
- XkbFakeDeviceButton(dev,FALSE,button);
- break;
- }
- filter->active = 0;
- }
- return 0;
-}
-
-static XkbFilterPtr
-_XkbNextFreeFilter(
- XkbSrvInfoPtr xkbi
-)
-{
-register int i;
-
- if (xkbi->szFilters==0) {
- xkbi->szFilters = 4;
- xkbi->filters = calloc(xkbi->szFilters, sizeof(XkbFilterRec));
- /* 6/21/93 (ef) -- XXX! deal with allocation failure */
- }
- for (i=0;i<xkbi->szFilters;i++) {
- if (!xkbi->filters[i].active) {
- xkbi->filters[i].keycode = 0;
- return &xkbi->filters[i];
- }
- }
- xkbi->szFilters*=2;
- xkbi->filters= realloc(xkbi->filters,
- xkbi->szFilters * sizeof(XkbFilterRec));
- /* 6/21/93 (ef) -- XXX! deal with allocation failure */
- memset(&xkbi->filters[xkbi->szFilters/2], 0,
- (xkbi->szFilters/2)*sizeof(XkbFilterRec));
- return &xkbi->filters[xkbi->szFilters/2];
-}
-
-static int
-_XkbApplyFilters(XkbSrvInfoPtr xkbi,unsigned kc,XkbAction *pAction)
-{
-register int i,send;
-
- send= 1;
- for (i=0;i<xkbi->szFilters;i++) {
- if ((xkbi->filters[i].active)&&(xkbi->filters[i].filter))
- send= ((*xkbi->filters[i].filter)(xkbi,&xkbi->filters[i],kc,pAction)
- && send);
- }
- return send;
-}
-
-void
-XkbHandleActions(DeviceIntPtr dev, DeviceIntPtr kbd, DeviceEvent* event)
-{
-int key,bit,i;
-XkbSrvInfoPtr xkbi;
-KeyClassPtr keyc;
-int changed,sendEvent;
-Bool genStateNotify;
-XkbAction act;
-XkbFilterPtr filter;
-Bool keyEvent;
-Bool pressEvent;
-ProcessInputProc backupproc;
-
-xkbDeviceInfoPtr xkbPrivPtr = XKBDEVICEINFO(dev);
-
- keyc= kbd->key;
- xkbi= keyc->xkbInfo;
- key= event->detail.key;
- /* The state may change, so if we're not in the middle of sending a state
- * notify, prepare for it */
- if ((xkbi->flags&_XkbStateNotifyInProgress)==0) {
- xkbi->prev_state = xkbi->state;
- xkbi->flags|= _XkbStateNotifyInProgress;
- genStateNotify= TRUE;
- }
- else genStateNotify= FALSE;
-
- xkbi->clearMods = xkbi->setMods = 0;
- xkbi->groupChange = 0;
-
- sendEvent = 1;
- keyEvent= ((event->type == ET_KeyPress) || (event->type == ET_KeyRelease));
- pressEvent= ((event->type == ET_KeyPress)|| (event->type == ET_ButtonPress));
-
- if (pressEvent) {
- if (keyEvent)
- act = XkbGetKeyAction(xkbi,&xkbi->state,key);
- else {
- act = XkbGetButtonAction(kbd,dev,key);
- key|= BTN_ACT_FLAG;
- }
- sendEvent = _XkbApplyFilters(xkbi,key,&act);
- if (sendEvent) {
- switch (act.type) {
- case XkbSA_SetMods:
- case XkbSA_SetGroup:
- filter = _XkbNextFreeFilter(xkbi);
- sendEvent = _XkbFilterSetState(xkbi,filter,key,&act);
- break;
- case XkbSA_LatchMods:
- case XkbSA_LatchGroup:
- filter = _XkbNextFreeFilter(xkbi);
- sendEvent=_XkbFilterLatchState(xkbi,filter,key,&act);
- break;
- case XkbSA_LockMods:
- case XkbSA_LockGroup:
- filter = _XkbNextFreeFilter(xkbi);
- sendEvent=_XkbFilterLockState(xkbi,filter,key,&act);
- break;
- case XkbSA_ISOLock:
- filter = _XkbNextFreeFilter(xkbi);
- sendEvent=_XkbFilterISOLock(xkbi,filter,key,&act);
- break;
- case XkbSA_MovePtr:
- filter = _XkbNextFreeFilter(xkbi);
- sendEvent= _XkbFilterPointerMove(xkbi,filter,key,&act);
- break;
- case XkbSA_PtrBtn:
- case XkbSA_LockPtrBtn:
- case XkbSA_SetPtrDflt:
- filter = _XkbNextFreeFilter(xkbi);
- sendEvent= _XkbFilterPointerBtn(xkbi,filter,key,&act);
- break;
- case XkbSA_Terminate:
- sendEvent= XkbDDXTerminateServer(dev,key,&act);
- break;
- case XkbSA_SwitchScreen:
- filter = _XkbNextFreeFilter(xkbi);
- sendEvent=_XkbFilterSwitchScreen(xkbi,filter,key,&act);
- break;
- case XkbSA_SetControls:
- case XkbSA_LockControls:
- filter = _XkbNextFreeFilter(xkbi);
- sendEvent=_XkbFilterControls(xkbi,filter,key,&act);
- break;
- case XkbSA_ActionMessage:
- filter = _XkbNextFreeFilter(xkbi);
- sendEvent=_XkbFilterActionMessage(xkbi,filter,key,&act);
- break;
- case XkbSA_RedirectKey:
- filter = _XkbNextFreeFilter(xkbi);
- sendEvent= _XkbFilterRedirectKey(xkbi,filter,key,&act);
- break;
- case XkbSA_DeviceBtn:
- case XkbSA_LockDeviceBtn:
- filter = _XkbNextFreeFilter(xkbi);
- sendEvent= _XkbFilterDeviceBtn(xkbi,filter,key,&act);
- break;
- case XkbSA_XFree86Private:
- filter = _XkbNextFreeFilter(xkbi);
- sendEvent= _XkbFilterXF86Private(xkbi,filter,key,&act);
- break;
- }
- }
- }
- else {
- if (!keyEvent)
- key|= BTN_ACT_FLAG;
- sendEvent = _XkbApplyFilters(xkbi,key,NULL);
- }
-
- if (xkbi->groupChange!=0)
- xkbi->state.base_group+= xkbi->groupChange;
- if (xkbi->setMods) {
- for (i=0,bit=1; xkbi->setMods; i++,bit<<=1 ) {
- if (xkbi->setMods&bit) {
- keyc->modifierKeyCount[i]++;
- xkbi->state.base_mods|= bit;
- xkbi->setMods&= ~bit;
- }
- }
- }
- if (xkbi->clearMods) {
- for (i=0,bit=1; xkbi->clearMods; i++,bit<<=1 ) {
- if (xkbi->clearMods&bit) {
- keyc->modifierKeyCount[i]--;
- if (keyc->modifierKeyCount[i]<=0) {
- xkbi->state.base_mods&= ~bit;
- keyc->modifierKeyCount[i] = 0;
- }
- xkbi->clearMods&= ~bit;
- }
- }
- }
-
- if (sendEvent) {
- DeviceIntPtr tmpdev;
- if (keyEvent)
- tmpdev = dev;
- else
- tmpdev = GetPairedDevice(dev);
-
- UNWRAP_PROCESS_INPUT_PROC(tmpdev,xkbPrivPtr, backupproc);
- dev->public.processInputProc((InternalEvent*)event, tmpdev);
- COND_WRAP_PROCESS_INPUT_PROC(tmpdev, xkbPrivPtr,
- backupproc,xkbUnwrapProc);
- }
- else if (keyEvent) {
- FixKeyState(event, dev);
- }
-
- XkbComputeDerivedState(xkbi);
- changed = XkbStateChangedFlags(&xkbi->prev_state,&xkbi->state);
- if (genStateNotify) {
- if (changed) {
- xkbStateNotify sn;
- sn.keycode= key;
- sn.eventType= event->type;
- sn.requestMajor = sn.requestMinor = 0;
- sn.changed= changed;
- XkbSendStateNotify(dev,&sn);
- }
- xkbi->flags&= ~_XkbStateNotifyInProgress;
- }
- changed= XkbIndicatorsToUpdate(dev,changed,FALSE);
- if (changed) {
- XkbEventCauseRec cause;
- XkbSetCauseKey(&cause, key, event->type);
- XkbUpdateIndicators(dev,changed,FALSE,NULL,&cause);
- }
- return;
-}
-
-int
-XkbLatchModifiers(DeviceIntPtr pXDev,CARD8 mask,CARD8 latches)
-{
-XkbSrvInfoPtr xkbi;
-XkbFilterPtr filter;
-XkbAction act;
-unsigned clear;
-
- if ( pXDev && pXDev->key && pXDev->key->xkbInfo ) {
- xkbi = pXDev->key->xkbInfo;
- clear= (mask&(~latches));
- xkbi->state.latched_mods&= ~clear;
- /* Clear any pending latch to locks.
- */
- act.type = XkbSA_NoAction;
- _XkbApplyFilters(xkbi,SYNTHETIC_KEYCODE,&act);
- act.type = XkbSA_LatchMods;
- act.mods.flags = 0;
- act.mods.mask = mask&latches;
- filter = _XkbNextFreeFilter(xkbi);
- _XkbFilterLatchState(xkbi,filter,SYNTHETIC_KEYCODE,&act);
- _XkbFilterLatchState(xkbi,filter,SYNTHETIC_KEYCODE,(XkbAction *)NULL);
- return Success;
- }
- return BadValue;
-}
-
-int
-XkbLatchGroup(DeviceIntPtr pXDev,int group)
-{
-XkbSrvInfoPtr xkbi;
-XkbFilterPtr filter;
-XkbAction act;
-
- if ( pXDev && pXDev->key && pXDev->key->xkbInfo ) {
- xkbi = pXDev->key->xkbInfo;
- act.type = XkbSA_LatchGroup;
- act.group.flags = 0;
- XkbSASetGroup(&act.group,group);
- filter = _XkbNextFreeFilter(xkbi);
- _XkbFilterLatchState(xkbi,filter,SYNTHETIC_KEYCODE,&act);
- _XkbFilterLatchState(xkbi,filter,SYNTHETIC_KEYCODE,(XkbAction *)NULL);
- return Success;
- }
- return BadValue;
-}
-
-/***====================================================================***/
-
-void
-XkbClearAllLatchesAndLocks( DeviceIntPtr dev,
- XkbSrvInfoPtr xkbi,
- Bool genEv,
- XkbEventCausePtr cause)
-{
-XkbStateRec os;
-xkbStateNotify sn;
-
- sn.changed= 0;
- os= xkbi->state;
- if (os.latched_mods) { /* clear all latches */
- XkbLatchModifiers(dev,~0,0);
- sn.changed|= XkbModifierLatchMask;
- }
- if (os.latched_group) {
- XkbLatchGroup(dev,0);
- sn.changed|= XkbGroupLatchMask;
- }
- if (os.locked_mods) {
- xkbi->state.locked_mods= 0;
- sn.changed|= XkbModifierLockMask;
- }
- if (os.locked_group) {
- xkbi->state.locked_group= 0;
- sn.changed|= XkbGroupLockMask;
- }
- if ( genEv && sn.changed) {
- CARD32 changed;
-
- XkbComputeDerivedState(xkbi);
- sn.keycode= cause->kc;
- sn.eventType= cause->event;
- sn.requestMajor= cause->mjr;
- sn.requestMinor= cause->mnr;
- sn.changed= XkbStateChangedFlags(&os,&xkbi->state);
- XkbSendStateNotify(dev,&sn);
- changed= XkbIndicatorsToUpdate(dev,sn.changed,FALSE);
- if (changed) {
- XkbUpdateIndicators(dev,changed,TRUE,NULL,cause);
- }
- }
- return;
-}
-
-/*
- * The event is injected into the event processing, not the EQ. Thus,
- * ensure that we restore the master after the event sequence to the
- * original set of classes. Otherwise, the master remains on the XTEST
- * classes and drops events that don't fit into the XTEST layout (e.g.
- * events with more than 2 valuators).
- *
- * FIXME: EQ injection in the processing stage is not designed for, so this
- * is a rather awkward hack. The event list returned by GetPointerEvents()
- * and friends is always prefixed with a DCE if the last _posted_ device was
- * different. For normal events, this sequence then resets the master during
- * the processing stage. Since we inject the PointerKey events in the
- * processing stage though, we need to manually reset to restore the
- * previous order, because the events already in the EQ must be sent for the
- * right device.
- * So we post-fix the event list we get from GPE with a DCE back to the
- * previous slave device.
- *
- * First one on drinking island wins!
- */
-static void
-InjectPointerKeyEvents(DeviceIntPtr dev, int type, int button, int flags, ValuatorMask *mask)
-{
- ScreenPtr pScreen;
- EventListPtr events;
- int nevents, i;
- DeviceIntPtr ptr, mpointer, lastSlave = NULL;
- Bool saveWait;
-
- if (IsMaster(dev)) {
- mpointer = GetMaster(dev, MASTER_POINTER);
- lastSlave = mpointer->lastSlave;
- ptr = GetXTestDevice(mpointer);
- } else if (IsFloating(dev))
- ptr = dev;
- else
- return;
-
-
- events = InitEventList(GetMaximumEventsNum() + 1);
- OsBlockSignals();
- pScreen = miPointerGetScreen(ptr);
- saveWait = miPointerSetWaitForUpdate(pScreen, FALSE);
- nevents = GetPointerEvents(events, ptr, type, button, flags, mask);
- if (IsMaster(dev) && (lastSlave && lastSlave != ptr))
- UpdateFromMaster(&events[nevents], lastSlave, DEVCHANGE_POINTER_EVENT, &nevents);
- miPointerSetWaitForUpdate(pScreen, saveWait);
- OsReleaseSignals();
-
- for (i = 0; i < nevents; i++)
- mieqProcessDeviceEvent(ptr, (InternalEvent*)events[i].event, NULL);
-
- FreeEventList(events, GetMaximumEventsNum());
-
-}
-
-static void
-XkbFakePointerMotion(DeviceIntPtr dev, unsigned flags,int x,int y)
-{
- ValuatorMask mask;
- int gpe_flags = 0;
-
- /* ignore attached SDs */
- if (!IsMaster(dev) && !IsFloating(dev))
- return;
-
- if (flags & XkbSA_MoveAbsoluteX || flags & XkbSA_MoveAbsoluteY)
- gpe_flags = POINTER_ABSOLUTE;
- else
- gpe_flags = POINTER_RELATIVE;
-
- valuator_mask_set_range(&mask, 0, 2, (int[]){x, y});
-
- InjectPointerKeyEvents(dev, MotionNotify, 0, gpe_flags, &mask);
-}
-
-void
-XkbFakeDeviceButton(DeviceIntPtr dev,Bool press,int button)
-{
- DeviceIntPtr ptr;
- int down;
-
- /* If dev is a slave device, and the SD is attached, do nothing. If we'd
- * post through the attached master pointer we'd get duplicate events.
- *
- * if dev is a master keyboard, post through the XTEST device
- *
- * if dev is a floating slave, post through the device itself.
- */
-
- if (IsMaster(dev)) {
- DeviceIntPtr mpointer = GetMaster(dev, MASTER_POINTER);
- ptr = GetXTestDevice(mpointer);
- } else if (IsFloating(dev))
- ptr = dev;
- else
- return;
-
- down = button_is_down(ptr, button, BUTTON_PROCESSED);
- if (press == down)
- return;
-
- InjectPointerKeyEvents(dev, press ? ButtonPress : ButtonRelease,
- button, 0, NULL);
-}
+/************************************************************
+Copyright (c) 1993 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 <stdio.h>
+#include <math.h>
+#include <X11/X.h>
+#include <X11/Xproto.h>
+#include <X11/keysym.h>
+#include "misc.h"
+#include "inputstr.h"
+#include "exevents.h"
+#include "eventstr.h"
+#include <xkbsrv.h>
+#include "xkb.h"
+#include <ctype.h>
+#include "mi.h"
+#include "mipointer.h"
+#include "inpututils.h"
+#define EXTENSION_EVENT_BASE 64
+
+DevPrivateKeyRec xkbDevicePrivateKeyRec;
+
+void XkbFakeDeviceButton(DeviceIntPtr dev,Bool press,int button);
+static void XkbFakePointerMotion(DeviceIntPtr dev, unsigned flags,int x,int y);
+
+void
+xkbUnwrapProc(DeviceIntPtr device, DeviceHandleProc proc,
+ pointer data)
+{
+ xkbDeviceInfoPtr xkbPrivPtr = XKBDEVICEINFO(device);
+ ProcessInputProc backupproc;
+ if(xkbPrivPtr->unwrapProc)
+ xkbPrivPtr->unwrapProc = NULL;
+
+ UNWRAP_PROCESS_INPUT_PROC(device,xkbPrivPtr, backupproc);
+ proc(device,data);
+ COND_WRAP_PROCESS_INPUT_PROC(device,xkbPrivPtr,
+ backupproc,xkbUnwrapProc);
+}
+
+Bool
+XkbInitPrivates(void)
+{
+ return dixRegisterPrivateKey(&xkbDevicePrivateKeyRec, PRIVATE_DEVICE, sizeof(xkbDeviceInfoRec));
+}
+
+void
+XkbSetExtension(DeviceIntPtr device, ProcessInputProc proc)
+{
+ xkbDeviceInfoPtr xkbPrivPtr = XKBDEVICEINFO(device);
+ WRAP_PROCESS_INPUT_PROC(device, xkbPrivPtr, proc, xkbUnwrapProc);
+}
+
+/***====================================================================***/
+
+static XkbAction
+_FixUpAction(XkbDescPtr xkb,XkbAction *act)
+{
+static XkbAction fake;
+
+ if (XkbIsPtrAction(act)&&(!(xkb->ctrls->enabled_ctrls&XkbMouseKeysMask))) {
+ fake.type = XkbSA_NoAction;
+ return fake;
+ }
+ if (xkb->ctrls->enabled_ctrls&XkbStickyKeysMask) {
+ if (act->any.type==XkbSA_SetMods) {
+ fake.mods.type = XkbSA_LatchMods;
+ fake.mods.mask = act->mods.mask;
+ if (XkbAX_NeedOption(xkb->ctrls,XkbAX_LatchToLockMask))
+ fake.mods.flags= XkbSA_ClearLocks|XkbSA_LatchToLock;
+ else fake.mods.flags= XkbSA_ClearLocks;
+ return fake;
+ }
+ if (act->any.type==XkbSA_SetGroup) {
+ fake.group.type = XkbSA_LatchGroup;
+ if (XkbAX_NeedOption(xkb->ctrls,XkbAX_LatchToLockMask))
+ fake.group.flags= XkbSA_ClearLocks|XkbSA_LatchToLock;
+ else fake.group.flags= XkbSA_ClearLocks;
+ XkbSASetGroup(&fake.group,XkbSAGroup(&act->group));
+ return fake;
+ }
+ }
+ return *act;
+}
+
+static XkbAction
+XkbGetKeyAction(XkbSrvInfoPtr xkbi,XkbStatePtr xkbState,CARD8 key)
+{
+int effectiveGroup;
+int col;
+XkbDescPtr xkb;
+XkbKeyTypePtr type;
+XkbAction * pActs;
+static XkbAction fake;
+
+ xkb= xkbi->desc;
+ if (!XkbKeyHasActions(xkb,key) || !XkbKeycodeInRange(xkb,key)) {
+ fake.type = XkbSA_NoAction;
+ return fake;
+ }
+ pActs= XkbKeyActionsPtr(xkb,key);
+ col= 0;
+
+ effectiveGroup = XkbGetEffectiveGroup(xkbi, xkbState, key);
+ if (effectiveGroup != XkbGroup1Index)
+ col += (effectiveGroup * XkbKeyGroupsWidth(xkb, key));
+
+ type= XkbKeyKeyType(xkb,key,effectiveGroup);
+ if (type->map!=NULL) {
+ register unsigned i,mods;
+ register XkbKTMapEntryPtr entry;
+ mods= xkbState->mods&type->mods.mask;
+ for (entry= type->map,i=0;i<type->map_count;i++,entry++) {
+ if ((entry->active)&&(entry->mods.mask==mods)) {
+ col+= entry->level;
+ break;
+ }
+ }
+ }
+ if (pActs[col].any.type==XkbSA_NoAction)
+ return pActs[col];
+ fake= _FixUpAction(xkb,&pActs[col]);
+ return fake;
+}
+
+static XkbAction
+XkbGetButtonAction(DeviceIntPtr kbd,DeviceIntPtr dev,int button)
+{
+XkbAction fake;
+ if ((dev->button)&&(dev->button->xkb_acts)) {
+ if (dev->button->xkb_acts[button-1].any.type!=XkbSA_NoAction) {
+ fake= _FixUpAction(kbd->key->xkbInfo->desc,
+ &dev->button->xkb_acts[button-1]);
+ return fake;
+ }
+ }
+ fake.any.type= XkbSA_NoAction;
+ return fake;
+}
+
+/***====================================================================***/
+
+#define SYNTHETIC_KEYCODE 1
+#define BTN_ACT_FLAG 0x100
+
+static int
+_XkbFilterSetState( XkbSrvInfoPtr xkbi,
+ XkbFilterPtr filter,
+ unsigned keycode,
+ XkbAction *pAction)
+{
+ if (filter->keycode==0) { /* initial press */
+ filter->keycode = keycode;
+ filter->active = 1;
+ filter->filterOthers = ((pAction->mods.mask&XkbSA_ClearLocks)!=0);
+ filter->priv = 0;
+ filter->filter = _XkbFilterSetState;
+ if (pAction->type==XkbSA_SetMods) {
+ filter->upAction = *pAction;
+ xkbi->setMods= pAction->mods.mask;
+ }
+ else {
+ xkbi->groupChange = XkbSAGroup(&pAction->group);
+ if (pAction->group.flags&XkbSA_GroupAbsolute)
+ xkbi->groupChange-= xkbi->state.base_group;
+ filter->upAction= *pAction;
+ XkbSASetGroup(&filter->upAction.group,xkbi->groupChange);
+ }
+ }
+ else if (filter->keycode==keycode) {
+ if (filter->upAction.type==XkbSA_SetMods) {
+ xkbi->clearMods = filter->upAction.mods.mask;
+ if (filter->upAction.mods.flags&XkbSA_ClearLocks) {
+ xkbi->state.locked_mods&= ~filter->upAction.mods.mask;
+ }
+ }
+ else {
+ if (filter->upAction.group.flags&XkbSA_ClearLocks) {
+ xkbi->state.locked_group = 0;
+ }
+ xkbi->groupChange = -XkbSAGroup(&filter->upAction.group);
+ }
+ filter->active = 0;
+ }
+ else {
+ filter->upAction.mods.flags&= ~XkbSA_ClearLocks;
+ filter->filterOthers = 0;
+ }
+ return 1;
+}
+
+#define LATCH_KEY_DOWN 1
+#define LATCH_PENDING 2
+#define NO_LATCH 3
+
+static int
+_XkbFilterLatchState( XkbSrvInfoPtr xkbi,
+ XkbFilterPtr filter,
+ unsigned keycode,
+ XkbAction * pAction)
+{
+
+ if (filter->keycode==0) { /* initial press */
+ filter->keycode = keycode;
+ filter->active = 1;
+ filter->filterOthers = 1;
+ filter->priv = LATCH_KEY_DOWN;
+ filter->filter = _XkbFilterLatchState;
+ if (pAction->type==XkbSA_LatchMods) {
+ filter->upAction = *pAction;
+ xkbi->setMods = pAction->mods.mask;
+ }
+ else {
+ xkbi->groupChange = XkbSAGroup(&pAction->group);
+ if (pAction->group.flags&XkbSA_GroupAbsolute)
+ xkbi->groupChange-= xkbi->state.base_group;
+ filter->upAction= *pAction;
+ XkbSASetGroup(&filter->upAction.group,xkbi->groupChange);
+ }
+ }
+ else if ( pAction && (filter->priv==LATCH_PENDING) ) {
+ if (((1<<pAction->type)&XkbSA_BreakLatch)!=0) {
+ filter->active = 0;
+ if (filter->upAction.type==XkbSA_LatchMods)
+ xkbi->state.latched_mods&= ~filter->upAction.mods.mask;
+ else xkbi->state.latched_group-=XkbSAGroup(&filter->upAction.group);
+ }
+ else if ((pAction->type==filter->upAction.type)&&
+ (pAction->mods.flags==filter->upAction.mods.flags)&&
+ (pAction->mods.mask==filter->upAction.mods.mask)) {
+ if (filter->upAction.mods.flags&XkbSA_LatchToLock) {
+ XkbControlsPtr ctrls= xkbi->desc->ctrls;
+ if (filter->upAction.type==XkbSA_LatchMods)
+ pAction->mods.type= XkbSA_LockMods;
+ else pAction->group.type= XkbSA_LockGroup;
+ if (XkbAX_NeedFeedback(ctrls,XkbAX_StickyKeysFBMask)&&
+ (ctrls->enabled_ctrls&XkbStickyKeysMask)) {
+ XkbDDXAccessXBeep(xkbi->device,_BEEP_STICKY_LOCK,
+ XkbStickyKeysMask);
+ }
+ }
+ else {
+ if (filter->upAction.type==XkbSA_LatchMods)
+ pAction->mods.type= XkbSA_SetMods;
+ else pAction->group.type= XkbSA_SetGroup;
+ }
+ if (filter->upAction.type==XkbSA_LatchMods)
+ xkbi->state.latched_mods&= ~filter->upAction.mods.mask;
+ else xkbi->state.latched_group-=XkbSAGroup(&filter->upAction.group);
+ filter->active = 0;
+ }
+ }
+ else if (filter->keycode==keycode) { /* release */
+ XkbControlsPtr ctrls= xkbi->desc->ctrls;
+ int needBeep;
+ int beepType= _BEEP_NONE;
+
+ needBeep= ((ctrls->enabled_ctrls&XkbStickyKeysMask)&&
+ XkbAX_NeedFeedback(ctrls,XkbAX_StickyKeysFBMask));
+ if (filter->upAction.type==XkbSA_LatchMods) {
+ xkbi->clearMods = filter->upAction.mods.mask;
+ if ((filter->upAction.mods.flags&XkbSA_ClearLocks)&&
+ (xkbi->clearMods&xkbi->state.locked_mods)==xkbi->clearMods) {
+ xkbi->state.locked_mods&= ~xkbi->clearMods;
+ filter->priv= NO_LATCH;
+ beepType= _BEEP_STICKY_UNLOCK;
+ }
+ }
+ else {
+ xkbi->groupChange = -XkbSAGroup(&filter->upAction.group);
+ if ((filter->upAction.group.flags&XkbSA_ClearLocks)&&
+ (xkbi->state.locked_group)) {
+ xkbi->state.locked_group = 0;
+ filter->priv = NO_LATCH;
+ beepType= _BEEP_STICKY_UNLOCK;
+ }
+ }
+ if (filter->priv==NO_LATCH) {
+ filter->active= 0;
+ }
+ else {
+ filter->priv= LATCH_PENDING;
+ if (filter->upAction.type==XkbSA_LatchMods) {
+ xkbi->state.latched_mods |= filter->upAction.mods.mask;
+ needBeep = xkbi->state.latched_mods ? needBeep : 0;
+ xkbi->state.latched_mods |= filter->upAction.mods.mask;
+ }
+ else {
+ xkbi->state.latched_group+= XkbSAGroup(&filter->upAction.group);
+ }
+ if (needBeep && (beepType==_BEEP_NONE))
+ beepType= _BEEP_STICKY_LATCH;
+ }
+ if (needBeep && (beepType!=_BEEP_NONE))
+ XkbDDXAccessXBeep(xkbi->device,beepType,XkbStickyKeysMask);
+ }
+ else if (filter->priv==LATCH_KEY_DOWN) {
+ filter->priv= NO_LATCH;
+ filter->filterOthers = 0;
+ }
+ return 1;
+}
+
+static int
+_XkbFilterLockState( XkbSrvInfoPtr xkbi,
+ XkbFilterPtr filter,
+ unsigned keycode,
+ XkbAction * pAction)
+{
+ if (pAction&&(pAction->type==XkbSA_LockGroup)) {
+ if (pAction->group.flags&XkbSA_GroupAbsolute)
+ xkbi->state.locked_group= XkbSAGroup(&pAction->group);
+ else xkbi->state.locked_group+= XkbSAGroup(&pAction->group);
+ return 1;
+ }
+ if (filter->keycode==0) { /* initial press */
+ filter->keycode = keycode;
+ filter->active = 1;
+ filter->filterOthers = 0;
+ filter->priv = 0;
+ filter->filter = _XkbFilterLockState;
+ filter->upAction = *pAction;
+ xkbi->state.locked_mods^= pAction->mods.mask;
+ xkbi->setMods = pAction->mods.mask;
+ }
+ else if (filter->keycode==keycode) {
+ filter->active = 0;
+ xkbi->clearMods = filter->upAction.mods.mask;
+ }
+ return 1;
+}
+
+#define ISO_KEY_DOWN 0
+#define NO_ISO_LOCK 1
+
+static int
+_XkbFilterISOLock( XkbSrvInfoPtr xkbi,
+ XkbFilterPtr filter,
+ unsigned keycode,
+ XkbAction * pAction)
+{
+
+ if (filter->keycode==0) { /* initial press */
+ CARD8 flags= pAction->iso.flags;
+
+ filter->keycode = keycode;
+ filter->active = 1;
+ filter->filterOthers = 1;
+ filter->priv = ISO_KEY_DOWN;
+ filter->upAction = *pAction;
+ filter->filter = _XkbFilterISOLock;
+ if (flags&XkbSA_ISODfltIsGroup) {
+ xkbi->groupChange = XkbSAGroup(&pAction->iso);
+ xkbi->setMods = 0;
+ }
+ else {
+ xkbi->setMods = pAction->iso.mask;
+ xkbi->groupChange = 0;
+ }
+ if ((!(flags&XkbSA_ISONoAffectMods))&&(xkbi->state.base_mods)) {
+ filter->priv= NO_ISO_LOCK;
+ xkbi->state.locked_mods^= xkbi->state.base_mods;
+ }
+ if ((!(flags&XkbSA_ISONoAffectGroup))&&(xkbi->state.base_group)) {
+/* 6/22/93 (ef) -- lock groups if group key is down first */
+ }
+ if (!(flags&XkbSA_ISONoAffectPtr)) {
+/* 6/22/93 (ef) -- lock mouse buttons if they're down */
+ }
+ }
+ else if (filter->keycode==keycode) {
+ CARD8 flags= filter->upAction.iso.flags;
+
+ if (flags&XkbSA_ISODfltIsGroup) {
+ xkbi->groupChange = -XkbSAGroup(&filter->upAction.iso);
+ xkbi->clearMods = 0;
+ if (filter->priv==ISO_KEY_DOWN)
+ xkbi->state.locked_group+= XkbSAGroup(&filter->upAction.iso);
+ }
+ else {
+ xkbi->clearMods= filter->upAction.iso.mask;
+ xkbi->groupChange= 0;
+ if (filter->priv==ISO_KEY_DOWN)
+ xkbi->state.locked_mods^= filter->upAction.iso.mask;
+ }
+ filter->active = 0;
+ }
+ else if (pAction) {
+ CARD8 flags= filter->upAction.iso.flags;
+
+ switch (pAction->type) {
+ case XkbSA_SetMods: case XkbSA_LatchMods:
+ if (!(flags&XkbSA_ISONoAffectMods)) {
+ pAction->type= XkbSA_LockMods;
+ filter->priv= NO_ISO_LOCK;
+ }
+ break;
+ case XkbSA_SetGroup: case XkbSA_LatchGroup:
+ if (!(flags&XkbSA_ISONoAffectGroup)) {
+ pAction->type= XkbSA_LockGroup;
+ filter->priv= NO_ISO_LOCK;
+ }
+ break;
+ case XkbSA_PtrBtn:
+ if (!(flags&XkbSA_ISONoAffectPtr)) {
+ pAction->type= XkbSA_LockPtrBtn;
+ filter->priv= NO_ISO_LOCK;
+ }
+ break;
+ case XkbSA_SetControls:
+ if (!(flags&XkbSA_ISONoAffectCtrls)) {
+ pAction->type= XkbSA_LockControls;
+ filter->priv= NO_ISO_LOCK;
+ }
+ break;
+ }
+ }
+ return 1;
+}
+
+
+static CARD32
+_XkbPtrAccelExpire(OsTimerPtr timer,CARD32 now,pointer arg)
+{
+XkbSrvInfoPtr xkbi= (XkbSrvInfoPtr)arg;
+XkbControlsPtr ctrls= xkbi->desc->ctrls;
+int dx,dy;
+
+ if (xkbi->mouseKey==0)
+ return 0;
+
+ if (xkbi->mouseKeysAccel) {
+ if ((xkbi->mouseKeysCounter)<ctrls->mk_time_to_max) {
+ double step;
+ xkbi->mouseKeysCounter++;
+ step= xkbi->mouseKeysCurveFactor*
+ pow((double)xkbi->mouseKeysCounter,xkbi->mouseKeysCurve);
+ if (xkbi->mouseKeysDX<0)
+ dx= floor( ((double)xkbi->mouseKeysDX)*step );
+ else dx= ceil( ((double)xkbi->mouseKeysDX)*step );
+ if (xkbi->mouseKeysDY<0)
+ dy= floor( ((double)xkbi->mouseKeysDY)*step );
+ else dy= ceil( ((double)xkbi->mouseKeysDY)*step );
+ }
+ else {
+ dx= xkbi->mouseKeysDX*ctrls->mk_max_speed;
+ dy= xkbi->mouseKeysDY*ctrls->mk_max_speed;
+ }
+ if (xkbi->mouseKeysFlags&XkbSA_MoveAbsoluteX)
+ dx= xkbi->mouseKeysDX;
+ if (xkbi->mouseKeysFlags&XkbSA_MoveAbsoluteY)
+ dy= xkbi->mouseKeysDY;
+ }
+ else {
+ dx= xkbi->mouseKeysDX;
+ dy= xkbi->mouseKeysDY;
+ }
+ XkbFakePointerMotion(xkbi->device, xkbi->mouseKeysFlags,dx,dy);
+ return xkbi->desc->ctrls->mk_interval;
+}
+
+static int
+_XkbFilterPointerMove( XkbSrvInfoPtr xkbi,
+ XkbFilterPtr filter,
+ unsigned keycode,
+ XkbAction * pAction)
+{
+int x,y;
+Bool accel;
+
+ if (filter->keycode==0) { /* initial press */
+ filter->keycode = keycode;
+ filter->active = 1;
+ filter->filterOthers = 0;
+ filter->priv=0;
+ filter->filter = _XkbFilterPointerMove;
+ filter->upAction= *pAction;
+ xkbi->mouseKeysCounter= 0;
+ xkbi->mouseKey= keycode;
+ accel= ((pAction->ptr.flags&XkbSA_NoAcceleration)==0);
+ x= XkbPtrActionX(&pAction->ptr);
+ y= XkbPtrActionY(&pAction->ptr);
+ XkbFakePointerMotion(xkbi->device, pAction->ptr.flags,x,y);
+ AccessXCancelRepeatKey(xkbi,keycode);
+ xkbi->mouseKeysAccel= accel&&
+ (xkbi->desc->ctrls->enabled_ctrls&XkbMouseKeysAccelMask);
+ xkbi->mouseKeysFlags= pAction->ptr.flags;
+ xkbi->mouseKeysDX= XkbPtrActionX(&pAction->ptr);
+ xkbi->mouseKeysDY= XkbPtrActionY(&pAction->ptr);
+ xkbi->mouseKeyTimer= TimerSet(xkbi->mouseKeyTimer, 0,
+ xkbi->desc->ctrls->mk_delay,
+ _XkbPtrAccelExpire,(pointer)xkbi);
+ }
+ else if (filter->keycode==keycode) {
+ filter->active = 0;
+ if (xkbi->mouseKey==keycode) {
+ xkbi->mouseKey= 0;
+ xkbi->mouseKeyTimer= TimerSet(xkbi->mouseKeyTimer, 0, 0,
+ NULL, NULL);
+ }
+ }
+ return 0;
+}
+
+static int
+_XkbFilterPointerBtn( XkbSrvInfoPtr xkbi,
+ XkbFilterPtr filter,
+ unsigned keycode,
+ XkbAction * pAction)
+{
+ if (filter->keycode==0) { /* initial press */
+ int button= pAction->btn.button;
+
+ if (button==XkbSA_UseDfltButton)
+ button = xkbi->desc->ctrls->mk_dflt_btn;
+
+ filter->keycode = keycode;
+ filter->active = 1;
+ filter->filterOthers = 0;
+ filter->priv=0;
+ filter->filter = _XkbFilterPointerBtn;
+ filter->upAction= *pAction;
+ filter->upAction.btn.button= button;
+ switch (pAction->type) {
+ case XkbSA_LockPtrBtn:
+ if (((xkbi->lockedPtrButtons&(1<<button))==0)&&
+ ((pAction->btn.flags&XkbSA_LockNoLock)==0)) {
+ xkbi->lockedPtrButtons|= (1<<button);
+ AccessXCancelRepeatKey(xkbi,keycode);
+ XkbFakeDeviceButton(xkbi->device, 1, button);
+ filter->upAction.type= XkbSA_NoAction;
+ }
+ break;
+ case XkbSA_PtrBtn:
+ {
+ register int i,nClicks;
+ AccessXCancelRepeatKey(xkbi,keycode);
+ if (pAction->btn.count>0) {
+ nClicks= pAction->btn.count;
+ for (i=0;i<nClicks;i++) {
+ XkbFakeDeviceButton(xkbi->device, 1, button);
+ XkbFakeDeviceButton(xkbi->device, 0, button);
+ }
+ filter->upAction.type= XkbSA_NoAction;
+ }
+ else XkbFakeDeviceButton(xkbi->device, 1, button);
+ }
+ break;
+ case XkbSA_SetPtrDflt:
+ {
+ XkbControlsPtr ctrls= xkbi->desc->ctrls;
+ XkbControlsRec old;
+ xkbControlsNotify cn;
+
+ old= *ctrls;
+ AccessXCancelRepeatKey(xkbi,keycode);
+ switch (pAction->dflt.affect) {
+ case XkbSA_AffectDfltBtn:
+ if (pAction->dflt.flags&XkbSA_DfltBtnAbsolute)
+ ctrls->mk_dflt_btn=
+ XkbSAPtrDfltValue(&pAction->dflt);
+ else {
+ ctrls->mk_dflt_btn+=
+ XkbSAPtrDfltValue(&pAction->dflt);
+ if (ctrls->mk_dflt_btn>5)
+ ctrls->mk_dflt_btn= 5;
+ else if (ctrls->mk_dflt_btn<1)
+ ctrls->mk_dflt_btn= 1;
+ }
+ break;
+ default:
+ ErrorF(
+ "Attempt to change unknown pointer default (%d) ignored\n",
+ pAction->dflt.affect);
+ break;
+ }
+ if (XkbComputeControlsNotify(xkbi->device,
+ &old,xkbi->desc->ctrls,
+ &cn,FALSE)) {
+ cn.keycode = keycode;
+ /* XXX: what about DeviceKeyPress? */
+ cn.eventType = KeyPress;
+ cn.requestMajor = 0;
+ cn.requestMinor = 0;
+ XkbSendControlsNotify(xkbi->device,&cn);
+ }
+ }
+ break;
+ }
+ }
+ else if (filter->keycode==keycode) {
+ int button= filter->upAction.btn.button;
+
+ switch (filter->upAction.type) {
+ case XkbSA_LockPtrBtn:
+ if (((filter->upAction.btn.flags&XkbSA_LockNoUnlock)!=0)||
+ ((xkbi->lockedPtrButtons&(1<<button))==0)) {
+ break;
+ }
+ xkbi->lockedPtrButtons&= ~(1<<button);
+
+ if (IsMaster(xkbi->device))
+ {
+ XkbMergeLockedPtrBtns(xkbi->device);
+ /* One SD still has lock set, don't post event */
+ if ((xkbi->lockedPtrButtons & (1 << button)) != 0)
+ break;
+ }
+
+ /* fallthrough */
+ case XkbSA_PtrBtn:
+ XkbFakeDeviceButton(xkbi->device, 0, button);
+ break;
+ }
+ filter->active = 0;
+ }
+ return 0;
+}
+
+static int
+_XkbFilterControls( XkbSrvInfoPtr xkbi,
+ XkbFilterPtr filter,
+ unsigned keycode,
+ XkbAction * pAction)
+{
+XkbControlsRec old;
+XkbControlsPtr ctrls;
+DeviceIntPtr kbd;
+unsigned int change;
+XkbEventCauseRec cause;
+
+ kbd= xkbi->device;
+ ctrls= xkbi->desc->ctrls;
+ old= *ctrls;
+ if (filter->keycode==0) { /* initial press */
+ filter->keycode = keycode;
+ filter->active = 1;
+ filter->filterOthers = 0;
+ change= XkbActionCtrls(&pAction->ctrls);
+ filter->priv = change;
+ filter->filter = _XkbFilterControls;
+ filter->upAction = *pAction;
+
+ if (pAction->type==XkbSA_LockControls) {
+ filter->priv= (ctrls->enabled_ctrls&change);
+ change&= ~ctrls->enabled_ctrls;
+ }
+
+ if (change) {
+ xkbControlsNotify cn;
+ XkbSrvLedInfoPtr sli;
+
+ ctrls->enabled_ctrls|= change;
+ if (XkbComputeControlsNotify(kbd,&old,ctrls,&cn,FALSE)) {
+ cn.keycode = keycode;
+ /* XXX: what about DeviceKeyPress? */
+ cn.eventType = KeyPress;
+ cn.requestMajor = 0;
+ cn.requestMinor = 0;
+ XkbSendControlsNotify(kbd,&cn);
+ }
+
+ XkbSetCauseKey(&cause,keycode,KeyPress);
+
+ /* If sticky keys were disabled, clear all locks and latches */
+ if ((old.enabled_ctrls&XkbStickyKeysMask)&&
+ (!(ctrls->enabled_ctrls&XkbStickyKeysMask))) {
+ XkbClearAllLatchesAndLocks(kbd,xkbi,FALSE,&cause);
+ }
+ sli= XkbFindSrvLedInfo(kbd,XkbDfltXIClass,XkbDfltXIId,0);
+ XkbUpdateIndicators(kbd,sli->usesControls,TRUE,NULL,&cause);
+ if (XkbAX_NeedFeedback(ctrls,XkbAX_FeatureFBMask))
+ XkbDDXAccessXBeep(kbd,_BEEP_FEATURE_ON,change);
+ }
+ }
+ else if (filter->keycode==keycode) {
+ change= filter->priv;
+ if (change) {
+ xkbControlsNotify cn;
+ XkbSrvLedInfoPtr sli;
+
+ ctrls->enabled_ctrls&= ~change;
+ if (XkbComputeControlsNotify(kbd,&old,ctrls,&cn,FALSE)) {
+ cn.keycode = keycode;
+ cn.eventType = KeyRelease;
+ cn.requestMajor = 0;
+ cn.requestMinor = 0;
+ XkbSendControlsNotify(kbd,&cn);
+ }
+
+ XkbSetCauseKey(&cause,keycode,KeyRelease);
+ /* If sticky keys were disabled, clear all locks and latches */
+ if ((old.enabled_ctrls&XkbStickyKeysMask)&&
+ (!(ctrls->enabled_ctrls&XkbStickyKeysMask))) {
+ XkbClearAllLatchesAndLocks(kbd,xkbi,FALSE,&cause);
+ }
+ sli= XkbFindSrvLedInfo(kbd,XkbDfltXIClass,XkbDfltXIId,0);
+ XkbUpdateIndicators(kbd,sli->usesControls,TRUE,NULL,&cause);
+ if (XkbAX_NeedFeedback(ctrls,XkbAX_FeatureFBMask))
+ XkbDDXAccessXBeep(kbd,_BEEP_FEATURE_OFF,change);
+ }
+ filter->keycode= 0;
+ filter->active= 0;
+ }
+ return 1;
+}
+
+static int
+_XkbFilterActionMessage(XkbSrvInfoPtr xkbi,
+ XkbFilterPtr filter,
+ unsigned keycode,
+ XkbAction * pAction)
+{
+XkbMessageAction * pMsg;
+DeviceIntPtr kbd;
+
+ kbd= xkbi->device;
+ if (filter->keycode==0) { /* initial press */
+ pMsg= &pAction->msg;
+ if ((pMsg->flags&XkbSA_MessageOnRelease)||
+ ((pMsg->flags&XkbSA_MessageGenKeyEvent)==0)) {
+ filter->keycode = keycode;
+ filter->active = 1;
+ filter->filterOthers = 0;
+ filter->priv = 0;
+ filter->filter = _XkbFilterActionMessage;
+ filter->upAction = *pAction;
+ }
+ if (pMsg->flags&XkbSA_MessageOnPress) {
+ xkbActionMessage msg;
+
+ msg.keycode= keycode;
+ msg.press= 1;
+ msg.keyEventFollows=((pMsg->flags&XkbSA_MessageGenKeyEvent)!=0);
+ memcpy((char *)msg.message,
+ (char *)pMsg->message,XkbActionMessageLength);
+ XkbSendActionMessage(kbd,&msg);
+ }
+ return ((pAction->msg.flags&XkbSA_MessageGenKeyEvent)!=0);
+ }
+ else if (filter->keycode==keycode) {
+ pMsg= &filter->upAction.msg;
+ if (pMsg->flags&XkbSA_MessageOnRelease) {
+ xkbActionMessage msg;
+
+ msg.keycode= keycode;
+ msg.press= 0;
+ msg.keyEventFollows=((pMsg->flags&XkbSA_MessageGenKeyEvent)!=0);
+ memcpy((char *)msg.message,(char *)pMsg->message,
+ XkbActionMessageLength);
+ XkbSendActionMessage(kbd,&msg);
+ }
+ filter->keycode= 0;
+ filter->active= 0;
+ return ((pMsg->flags&XkbSA_MessageGenKeyEvent)!=0);
+ }
+ return 0;
+}
+
+static int
+_XkbFilterRedirectKey( XkbSrvInfoPtr xkbi,
+ XkbFilterPtr filter,
+ unsigned keycode,
+ XkbAction * pAction)
+{
+DeviceEvent ev;
+int x,y;
+XkbStateRec old;
+unsigned mods,mask;
+xkbDeviceInfoPtr xkbPrivPtr = XKBDEVICEINFO(xkbi->device);
+ProcessInputProc backupproc;
+
+ /* never actually used uninitialised, but gcc isn't smart enough
+ * to work that out. */
+ memset(&old, 0, sizeof(old));
+ memset(&ev, 0, sizeof(ev));
+
+ if ((filter->keycode!=0)&&(filter->keycode!=keycode))
+ return 1;
+
+ GetSpritePosition(xkbi->device, &x,&y);
+ ev.header = ET_Internal;
+ ev.length = sizeof(DeviceEvent);
+ ev.time = GetTimeInMillis();
+ ev.root_x = x;
+ ev.root_y = y;
+
+ if (filter->keycode==0) { /* initial press */
+ if ((pAction->redirect.new_key<xkbi->desc->min_key_code)||
+ (pAction->redirect.new_key>xkbi->desc->max_key_code)) {
+ return 1;
+ }
+ filter->keycode = keycode;
+ filter->active = 1;
+ filter->filterOthers = 0;
+ filter->priv = 0;
+ filter->filter = _XkbFilterRedirectKey;
+ filter->upAction = *pAction;
+
+ ev.type = ET_KeyPress;
+ ev.detail.key = pAction->redirect.new_key;
+
+ mask= XkbSARedirectVModsMask(&pAction->redirect);
+ mods= XkbSARedirectVMods(&pAction->redirect);
+ if (mask) XkbVirtualModsToReal(xkbi->desc,mask,&mask);
+ if (mods) XkbVirtualModsToReal(xkbi->desc,mods,&mods);
+ mask|= pAction->redirect.mods_mask;
+ mods|= pAction->redirect.mods;
+
+ if ( mask || mods ) {
+ old= xkbi->state;
+ xkbi->state.base_mods&= ~mask;
+ xkbi->state.base_mods|= (mods&mask);
+ xkbi->state.latched_mods&= ~mask;
+ xkbi->state.latched_mods|= (mods&mask);
+ xkbi->state.locked_mods&= ~mask;
+ xkbi->state.locked_mods|= (mods&mask);
+ XkbComputeDerivedState(xkbi);
+ }
+
+ UNWRAP_PROCESS_INPUT_PROC(xkbi->device,xkbPrivPtr, backupproc);
+ xkbi->device->public.processInputProc((InternalEvent*)&ev, xkbi->device);
+ COND_WRAP_PROCESS_INPUT_PROC(xkbi->device, xkbPrivPtr,
+ backupproc,xkbUnwrapProc);
+
+ if ( mask || mods )
+ xkbi->state= old;
+ }
+ else if (filter->keycode==keycode) {
+
+ ev.type = ET_KeyRelease;
+ ev.detail.key = filter->upAction.redirect.new_key;
+
+ mask= XkbSARedirectVModsMask(&filter->upAction.redirect);
+ mods= XkbSARedirectVMods(&filter->upAction.redirect);
+ if (mask) XkbVirtualModsToReal(xkbi->desc,mask,&mask);
+ if (mods) XkbVirtualModsToReal(xkbi->desc,mods,&mods);
+ mask|= filter->upAction.redirect.mods_mask;
+ mods|= filter->upAction.redirect.mods;
+
+ if ( mask || mods ) {
+ old= xkbi->state;
+ xkbi->state.base_mods&= ~mask;
+ xkbi->state.base_mods|= (mods&mask);
+ xkbi->state.latched_mods&= ~mask;
+ xkbi->state.latched_mods|= (mods&mask);
+ xkbi->state.locked_mods&= ~mask;
+ xkbi->state.locked_mods|= (mods&mask);
+ XkbComputeDerivedState(xkbi);
+ }
+
+ UNWRAP_PROCESS_INPUT_PROC(xkbi->device,xkbPrivPtr, backupproc);
+ xkbi->device->public.processInputProc((InternalEvent*)&ev, xkbi->device);
+ COND_WRAP_PROCESS_INPUT_PROC(xkbi->device, xkbPrivPtr,
+ backupproc,xkbUnwrapProc);
+
+ if ( mask || mods )
+ xkbi->state= old;
+
+ filter->keycode= 0;
+ filter->active= 0;
+ }
+ return 0;
+}
+
+static int
+_XkbFilterSwitchScreen( XkbSrvInfoPtr xkbi,
+ XkbFilterPtr filter,
+ unsigned keycode,
+ XkbAction * pAction)
+{
+ DeviceIntPtr dev = xkbi->device;
+ if (dev == inputInfo.keyboard)
+ return 0;
+
+ if (filter->keycode==0) { /* initial press */
+ filter->keycode = keycode;
+ filter->active = 1;
+ filter->filterOthers = 0;
+ filter->filter = _XkbFilterSwitchScreen;
+ AccessXCancelRepeatKey(xkbi, keycode);
+ XkbDDXSwitchScreen(dev,keycode,pAction);
+ return 0;
+ }
+ else if (filter->keycode==keycode) {
+ filter->active= 0;
+ return 0;
+ }
+ return 1;
+}
+
+static int
+_XkbFilterXF86Private( XkbSrvInfoPtr xkbi,
+ XkbFilterPtr filter,
+ unsigned keycode,
+ XkbAction * pAction)
+{
+ DeviceIntPtr dev = xkbi->device;
+ if (dev == inputInfo.keyboard)
+ return 0;
+
+ if (filter->keycode==0) { /* initial press */
+ filter->keycode = keycode;
+ filter->active = 1;
+ filter->filterOthers = 0;
+ filter->filter = _XkbFilterXF86Private;
+ XkbDDXPrivate(dev,keycode,pAction);
+ return 0;
+ }
+ else if (filter->keycode==keycode) {
+ filter->active= 0;
+ return 0;
+ }
+ return 1;
+}
+
+
+static int
+_XkbFilterDeviceBtn( XkbSrvInfoPtr xkbi,
+ XkbFilterPtr filter,
+ unsigned keycode,
+ XkbAction * pAction)
+{
+DeviceIntPtr dev;
+int button;
+
+ if (xkbi->device == inputInfo.keyboard)
+ return 0;
+
+ if (filter->keycode==0) { /* initial press */
+ _XkbLookupButtonDevice(&dev, pAction->devbtn.device, serverClient,
+ DixUnknownAccess, &button);
+ if (!dev || !dev->public.on)
+ return 1;
+
+ button= pAction->devbtn.button;
+ if ((button<1)||(button>dev->button->numButtons))
+ return 1;
+
+ filter->keycode = keycode;
+ filter->active = 1;
+ filter->filterOthers = 0;
+ filter->priv=0;
+ filter->filter = _XkbFilterDeviceBtn;
+ filter->upAction= *pAction;
+ switch (pAction->type) {
+ case XkbSA_LockDeviceBtn:
+ if ((pAction->devbtn.flags&XkbSA_LockNoLock)||
+ BitIsOn(dev->button->down, button))
+ return 0;
+ XkbFakeDeviceButton(dev,TRUE,button);
+ filter->upAction.type= XkbSA_NoAction;
+ break;
+ case XkbSA_DeviceBtn:
+ if (pAction->devbtn.count>0) {
+ int nClicks,i;
+ nClicks= pAction->btn.count;
+ for (i=0;i<nClicks;i++) {
+ XkbFakeDeviceButton(dev,TRUE,button);
+ XkbFakeDeviceButton(dev,FALSE,button);
+ }
+ filter->upAction.type= XkbSA_NoAction;
+ }
+ else XkbFakeDeviceButton(dev,TRUE,button);
+ break;
+ }
+ }
+ else if (filter->keycode==keycode) {
+ int button;
+
+ filter->active= 0;
+ _XkbLookupButtonDevice(&dev, filter->upAction.devbtn.device,
+ serverClient, DixUnknownAccess, &button);
+ if (!dev || !dev->public.on)
+ return 1;
+
+ button= filter->upAction.btn.button;
+ switch (filter->upAction.type) {
+ case XkbSA_LockDeviceBtn:
+ if ((filter->upAction.devbtn.flags&XkbSA_LockNoUnlock)||
+ !BitIsOn(dev->button->down, button))
+ return 0;
+ XkbFakeDeviceButton(dev,FALSE,button);
+ break;
+ case XkbSA_DeviceBtn:
+ XkbFakeDeviceButton(dev,FALSE,button);
+ break;
+ }
+ filter->active = 0;
+ }
+ return 0;
+}
+
+static XkbFilterPtr
+_XkbNextFreeFilter(
+ XkbSrvInfoPtr xkbi
+)
+{
+register int i;
+
+ if (xkbi->szFilters==0) {
+ xkbi->szFilters = 4;
+ xkbi->filters = calloc(xkbi->szFilters, sizeof(XkbFilterRec));
+ /* 6/21/93 (ef) -- XXX! deal with allocation failure */
+ }
+ for (i=0;i<xkbi->szFilters;i++) {
+ if (!xkbi->filters[i].active) {
+ xkbi->filters[i].keycode = 0;
+ return &xkbi->filters[i];
+ }
+ }
+ xkbi->szFilters*=2;
+ xkbi->filters= realloc(xkbi->filters,
+ xkbi->szFilters * sizeof(XkbFilterRec));
+ /* 6/21/93 (ef) -- XXX! deal with allocation failure */
+ memset(&xkbi->filters[xkbi->szFilters/2], 0,
+ (xkbi->szFilters/2)*sizeof(XkbFilterRec));
+ return &xkbi->filters[xkbi->szFilters/2];
+}
+
+static int
+_XkbApplyFilters(XkbSrvInfoPtr xkbi,unsigned kc,XkbAction *pAction)
+{
+register int i,send;
+
+ send= 1;
+ for (i=0;i<xkbi->szFilters;i++) {
+ if ((xkbi->filters[i].active)&&(xkbi->filters[i].filter))
+ send= ((*xkbi->filters[i].filter)(xkbi,&xkbi->filters[i],kc,pAction)
+ && send);
+ }
+ return send;
+}
+
+void
+XkbHandleActions(DeviceIntPtr dev, DeviceIntPtr kbd, DeviceEvent* event)
+{
+int key,bit,i;
+XkbSrvInfoPtr xkbi;
+KeyClassPtr keyc;
+int changed,sendEvent;
+Bool genStateNotify;
+XkbAction act;
+XkbFilterPtr filter;
+Bool keyEvent;
+Bool pressEvent;
+ProcessInputProc backupproc;
+
+xkbDeviceInfoPtr xkbPrivPtr = XKBDEVICEINFO(dev);
+
+ keyc= kbd->key;
+ xkbi= keyc->xkbInfo;
+ key= event->detail.key;
+ /* The state may change, so if we're not in the middle of sending a state
+ * notify, prepare for it */
+ if ((xkbi->flags&_XkbStateNotifyInProgress)==0) {
+ xkbi->prev_state = xkbi->state;
+ xkbi->flags|= _XkbStateNotifyInProgress;
+ genStateNotify= TRUE;
+ }
+ else genStateNotify= FALSE;
+
+ xkbi->clearMods = xkbi->setMods = 0;
+ xkbi->groupChange = 0;
+
+ sendEvent = 1;
+ keyEvent= ((event->type == ET_KeyPress) || (event->type == ET_KeyRelease));
+ pressEvent= ((event->type == ET_KeyPress)|| (event->type == ET_ButtonPress));
+
+ if (pressEvent) {
+ if (keyEvent)
+ act = XkbGetKeyAction(xkbi,&xkbi->state,key);
+ else {
+ act = XkbGetButtonAction(kbd,dev,key);
+ key|= BTN_ACT_FLAG;
+ }
+ sendEvent = _XkbApplyFilters(xkbi,key,&act);
+ if (sendEvent) {
+ switch (act.type) {
+ case XkbSA_SetMods:
+ case XkbSA_SetGroup:
+ filter = _XkbNextFreeFilter(xkbi);
+ sendEvent = _XkbFilterSetState(xkbi,filter,key,&act);
+ break;
+ case XkbSA_LatchMods:
+ case XkbSA_LatchGroup:
+ filter = _XkbNextFreeFilter(xkbi);
+ sendEvent=_XkbFilterLatchState(xkbi,filter,key,&act);
+ break;
+ case XkbSA_LockMods:
+ case XkbSA_LockGroup:
+ filter = _XkbNextFreeFilter(xkbi);
+ sendEvent=_XkbFilterLockState(xkbi,filter,key,&act);
+ break;
+ case XkbSA_ISOLock:
+ filter = _XkbNextFreeFilter(xkbi);
+ sendEvent=_XkbFilterISOLock(xkbi,filter,key,&act);
+ break;
+ case XkbSA_MovePtr:
+ filter = _XkbNextFreeFilter(xkbi);
+ sendEvent= _XkbFilterPointerMove(xkbi,filter,key,&act);
+ break;
+ case XkbSA_PtrBtn:
+ case XkbSA_LockPtrBtn:
+ case XkbSA_SetPtrDflt:
+ filter = _XkbNextFreeFilter(xkbi);
+ sendEvent= _XkbFilterPointerBtn(xkbi,filter,key,&act);
+ break;
+ case XkbSA_Terminate:
+ sendEvent= XkbDDXTerminateServer(dev,key,&act);
+ break;
+ case XkbSA_SwitchScreen:
+ filter = _XkbNextFreeFilter(xkbi);
+ sendEvent=_XkbFilterSwitchScreen(xkbi,filter,key,&act);
+ break;
+ case XkbSA_SetControls:
+ case XkbSA_LockControls:
+ filter = _XkbNextFreeFilter(xkbi);
+ sendEvent=_XkbFilterControls(xkbi,filter,key,&act);
+ break;
+ case XkbSA_ActionMessage:
+ filter = _XkbNextFreeFilter(xkbi);
+ sendEvent=_XkbFilterActionMessage(xkbi,filter,key,&act);
+ break;
+ case XkbSA_RedirectKey:
+ filter = _XkbNextFreeFilter(xkbi);
+ sendEvent= _XkbFilterRedirectKey(xkbi,filter,key,&act);
+ break;
+ case XkbSA_DeviceBtn:
+ case XkbSA_LockDeviceBtn:
+ filter = _XkbNextFreeFilter(xkbi);
+ sendEvent= _XkbFilterDeviceBtn(xkbi,filter,key,&act);
+ break;
+ case XkbSA_XFree86Private:
+ filter = _XkbNextFreeFilter(xkbi);
+ sendEvent= _XkbFilterXF86Private(xkbi,filter,key,&act);
+ break;
+ }
+ }
+ }
+ else {
+ if (!keyEvent)
+ key|= BTN_ACT_FLAG;
+ sendEvent = _XkbApplyFilters(xkbi,key,NULL);
+ }
+
+ if (xkbi->groupChange!=0)
+ xkbi->state.base_group+= xkbi->groupChange;
+ if (xkbi->setMods) {
+ for (i=0,bit=1; xkbi->setMods; i++,bit<<=1 ) {
+ if (xkbi->setMods&bit) {
+ keyc->modifierKeyCount[i]++;
+ xkbi->state.base_mods|= bit;
+ xkbi->setMods&= ~bit;
+ }
+ }
+ }
+ if (xkbi->clearMods) {
+ for (i=0,bit=1; xkbi->clearMods; i++,bit<<=1 ) {
+ if (xkbi->clearMods&bit) {
+ keyc->modifierKeyCount[i]--;
+ if (keyc->modifierKeyCount[i]<=0) {
+ xkbi->state.base_mods&= ~bit;
+ keyc->modifierKeyCount[i] = 0;
+ }
+ xkbi->clearMods&= ~bit;
+ }
+ }
+ }
+
+ if (sendEvent) {
+ DeviceIntPtr tmpdev;
+ if (keyEvent)
+ tmpdev = dev;
+ else
+ tmpdev = GetPairedDevice(dev);
+
+ UNWRAP_PROCESS_INPUT_PROC(tmpdev,xkbPrivPtr, backupproc);
+ dev->public.processInputProc((InternalEvent*)event, tmpdev);
+ COND_WRAP_PROCESS_INPUT_PROC(tmpdev, xkbPrivPtr,
+ backupproc,xkbUnwrapProc);
+ }
+ else if (keyEvent) {
+ FixKeyState(event, dev);
+ }
+
+ XkbComputeDerivedState(xkbi);
+ changed = XkbStateChangedFlags(&xkbi->prev_state,&xkbi->state);
+ if (genStateNotify) {
+ if (changed) {
+ xkbStateNotify sn;
+ sn.keycode= key;
+ sn.eventType= event->type;
+ sn.requestMajor = sn.requestMinor = 0;
+ sn.changed= changed;
+ XkbSendStateNotify(dev,&sn);
+ }
+ xkbi->flags&= ~_XkbStateNotifyInProgress;
+ }
+ changed= XkbIndicatorsToUpdate(dev,changed,FALSE);
+ if (changed) {
+ XkbEventCauseRec cause;
+ XkbSetCauseKey(&cause, key, event->type);
+ XkbUpdateIndicators(dev,changed,FALSE,NULL,&cause);
+ }
+ return;
+}
+
+int
+XkbLatchModifiers(DeviceIntPtr pXDev,CARD8 mask,CARD8 latches)
+{
+XkbSrvInfoPtr xkbi;
+XkbFilterPtr filter;
+XkbAction act;
+unsigned clear;
+
+ if ( pXDev && pXDev->key && pXDev->key->xkbInfo ) {
+ xkbi = pXDev->key->xkbInfo;
+ clear= (mask&(~latches));
+ xkbi->state.latched_mods&= ~clear;
+ /* Clear any pending latch to locks.
+ */
+ act.type = XkbSA_NoAction;
+ _XkbApplyFilters(xkbi,SYNTHETIC_KEYCODE,&act);
+ act.type = XkbSA_LatchMods;
+ act.mods.flags = 0;
+ act.mods.mask = mask&latches;
+ filter = _XkbNextFreeFilter(xkbi);
+ _XkbFilterLatchState(xkbi,filter,SYNTHETIC_KEYCODE,&act);
+ _XkbFilterLatchState(xkbi,filter,SYNTHETIC_KEYCODE,(XkbAction *)NULL);
+ return Success;
+ }
+ return BadValue;
+}
+
+int
+XkbLatchGroup(DeviceIntPtr pXDev,int group)
+{
+XkbSrvInfoPtr xkbi;
+XkbFilterPtr filter;
+XkbAction act;
+
+ if ( pXDev && pXDev->key && pXDev->key->xkbInfo ) {
+ xkbi = pXDev->key->xkbInfo;
+ act.type = XkbSA_LatchGroup;
+ act.group.flags = 0;
+ XkbSASetGroup(&act.group,group);
+ filter = _XkbNextFreeFilter(xkbi);
+ _XkbFilterLatchState(xkbi,filter,SYNTHETIC_KEYCODE,&act);
+ _XkbFilterLatchState(xkbi,filter,SYNTHETIC_KEYCODE,(XkbAction *)NULL);
+ return Success;
+ }
+ return BadValue;
+}
+
+/***====================================================================***/
+
+void
+XkbClearAllLatchesAndLocks( DeviceIntPtr dev,
+ XkbSrvInfoPtr xkbi,
+ Bool genEv,
+ XkbEventCausePtr cause)
+{
+XkbStateRec os;
+xkbStateNotify sn;
+
+ sn.changed= 0;
+ os= xkbi->state;
+ if (os.latched_mods) { /* clear all latches */
+ XkbLatchModifiers(dev,~0,0);
+ sn.changed|= XkbModifierLatchMask;
+ }
+ if (os.latched_group) {
+ XkbLatchGroup(dev,0);
+ sn.changed|= XkbGroupLatchMask;
+ }
+ if (os.locked_mods) {
+ xkbi->state.locked_mods= 0;
+ sn.changed|= XkbModifierLockMask;
+ }
+ if (os.locked_group) {
+ xkbi->state.locked_group= 0;
+ sn.changed|= XkbGroupLockMask;
+ }
+ if ( genEv && sn.changed) {
+ CARD32 changed;
+
+ XkbComputeDerivedState(xkbi);
+ sn.keycode= cause->kc;
+ sn.eventType= cause->event;
+ sn.requestMajor= cause->mjr;
+ sn.requestMinor= cause->mnr;
+ sn.changed= XkbStateChangedFlags(&os,&xkbi->state);
+ XkbSendStateNotify(dev,&sn);
+ changed= XkbIndicatorsToUpdate(dev,sn.changed,FALSE);
+ if (changed) {
+ XkbUpdateIndicators(dev,changed,TRUE,NULL,cause);
+ }
+ }
+ return;
+}
+
+/*
+ * The event is injected into the event processing, not the EQ. Thus,
+ * ensure that we restore the master after the event sequence to the
+ * original set of classes. Otherwise, the master remains on the XTEST
+ * classes and drops events that don't fit into the XTEST layout (e.g.
+ * events with more than 2 valuators).
+ *
+ * FIXME: EQ injection in the processing stage is not designed for, so this
+ * is a rather awkward hack. The event list returned by GetPointerEvents()
+ * and friends is always prefixed with a DCE if the last _posted_ device was
+ * different. For normal events, this sequence then resets the master during
+ * the processing stage. Since we inject the PointerKey events in the
+ * processing stage though, we need to manually reset to restore the
+ * previous order, because the events already in the EQ must be sent for the
+ * right device.
+ * So we post-fix the event list we get from GPE with a DCE back to the
+ * previous slave device.
+ *
+ * First one on drinking island wins!
+ */
+static void
+InjectPointerKeyEvents(DeviceIntPtr dev, int type, int button, int flags, ValuatorMask *mask)
+{
+ ScreenPtr pScreen;
+ InternalEvent* events;
+ int nevents, i;
+ DeviceIntPtr ptr, mpointer, lastSlave = NULL;
+ Bool saveWait;
+
+ if (IsMaster(dev)) {
+ mpointer = GetMaster(dev, MASTER_POINTER);
+ lastSlave = mpointer->lastSlave;
+ ptr = GetXTestDevice(mpointer);
+ } else if (IsFloating(dev))
+ ptr = dev;
+ else
+ return;
+
+
+ events = InitEventList(GetMaximumEventsNum() + 1);
+ OsBlockSignals();
+ pScreen = miPointerGetScreen(ptr);
+ saveWait = miPointerSetWaitForUpdate(pScreen, FALSE);
+ nevents = GetPointerEvents(events, ptr, type, button, flags, mask);
+ if (IsMaster(dev) && (lastSlave && lastSlave != ptr))
+ UpdateFromMaster(&events[nevents], lastSlave, DEVCHANGE_POINTER_EVENT, &nevents);
+ miPointerSetWaitForUpdate(pScreen, saveWait);
+ OsReleaseSignals();
+
+ for (i = 0; i < nevents; i++)
+ mieqProcessDeviceEvent(ptr, &events[i], NULL);
+
+ FreeEventList(events, GetMaximumEventsNum());
+
+}
+
+static void
+XkbFakePointerMotion(DeviceIntPtr dev, unsigned flags,int x,int y)
+{
+ ValuatorMask mask;
+ int gpe_flags = 0;
+
+ /* ignore attached SDs */
+ if (!IsMaster(dev) && !IsFloating(dev))
+ return;
+
+ if (flags & XkbSA_MoveAbsoluteX || flags & XkbSA_MoveAbsoluteY)
+ gpe_flags = POINTER_ABSOLUTE;
+ else
+ gpe_flags = POINTER_RELATIVE;
+
+ valuator_mask_set_range(&mask, 0, 2, (int[]){x, y});
+
+ InjectPointerKeyEvents(dev, MotionNotify, 0, gpe_flags, &mask);
+}
+
+void
+XkbFakeDeviceButton(DeviceIntPtr dev,Bool press,int button)
+{
+ DeviceIntPtr ptr;
+ int down;
+
+ /* If dev is a slave device, and the SD is attached, do nothing. If we'd
+ * post through the attached master pointer we'd get duplicate events.
+ *
+ * if dev is a master keyboard, post through the XTEST device
+ *
+ * if dev is a floating slave, post through the device itself.
+ */
+
+ if (IsMaster(dev)) {
+ DeviceIntPtr mpointer = GetMaster(dev, MASTER_POINTER);
+ ptr = GetXTestDevice(mpointer);
+ } else if (IsFloating(dev))
+ ptr = dev;
+ else
+ return;
+
+ down = button_is_down(ptr, button, BUTTON_PROCESSED);
+ if (press == down)
+ return;
+
+ InjectPointerKeyEvents(dev, press ? ButtonPress : ButtonRelease,
+ button, 0, NULL);
+}
diff --git a/xorg-server/xkb/xkbEvents.c b/xorg-server/xkb/xkbEvents.c
index 7f91e9ae1..dfbf7f2b3 100644
--- a/xorg-server/xkb/xkbEvents.c
+++ b/xorg-server/xkb/xkbEvents.c
@@ -88,11 +88,15 @@ XkbSendLegacyMapNotify(DeviceIntPtr kbd, CARD16 xkb_event, CARD16 changed,
if (!clients[i] || clients[i]->clientState != ClientStateRunning)
continue;
- /* Ignore clients which will have already received this.
- * Inconsistent with themselves, but consistent with previous
- * behaviour.*/
- if (xkb_event == XkbMapNotify && (clients[i]->mapNotifyMask & changed))
+ /* XKB allows clients to restrict the MappingNotify events sent to
+ * them. This was broken for three years. Sorry. */
+ if (xkb_event == XkbMapNotify &&
+ (clients[i]->xkbClientFlags & _XkbClientInitialized) &&
+ !(clients[i]->mapNotifyMask & changed))
continue;
+ /* Emulate previous server behaviour: any client which has activated
+ * XKB will not receive core events emulated from a NewKeyboardNotify
+ * at all. */
if (xkb_event == XkbNewKeyboardNotify &&
(clients[i]->xkbClientFlags & _XkbClientInitialized))
continue;
@@ -164,9 +168,6 @@ XkbSendNewKeyboardNotify(DeviceIntPtr kbd,xkbNewKeyboardNotify *pNKN)
if (!(clients[i]->newKeyboardNotifyMask & changed))
continue;
- if (!XIShouldNotify(clients[i], kbd))
- continue;
-
pNKN->sequenceNumber = clients[i]->sequence;
pNKN->time = time;
pNKN->changed = changed;
@@ -232,8 +233,7 @@ register CARD16 changed,bState;
if ((!interest->client->clientGone) &&
(interest->client->requestVector != InitialVector) &&
(interest->client->xkbClientFlags&_XkbClientInitialized) &&
- (interest->stateNotifyMask&changed) &&
- XIShouldNotify(interest->client,kbd)) {
+ (interest->stateNotifyMask&changed)) {
pSN->sequenceNumber = interest->client->sequence;
pSN->time = time;
pSN->changed = changed;
@@ -280,9 +280,6 @@ XkbSendMapNotify(DeviceIntPtr kbd, xkbMapNotify *pMN)
if (!(clients[i]->mapNotifyMask & changed))
continue;
- if (!XIShouldNotify(clients[i], kbd))
- continue;
-
pMN->time = time;
pMN->sequenceNumber = clients[i]->sequence;
pMN->changed = changed;
@@ -401,8 +398,7 @@ Time time = 0;
if ((!interest->client->clientGone) &&
(interest->client->requestVector != InitialVector) &&
(interest->client->xkbClientFlags&_XkbClientInitialized) &&
- (interest->ctrlsNotifyMask&changedControls) &&
- XIShouldNotify(interest->client, kbd)) {
+ (interest->ctrlsNotifyMask&changedControls)) {
if (!initialized) {
pCN->type = XkbEventCode + XkbEventBase;
pCN->xkbType = XkbControlsNotify;
@@ -450,7 +446,6 @@ CARD32 state,changed;
if ((!interest->client->clientGone) &&
(interest->client->requestVector != InitialVector) &&
(interest->client->xkbClientFlags&_XkbClientInitialized) &&
- XIShouldNotify(interest->client, kbd) &&
(((xkbType==XkbIndicatorStateNotify)&&
(interest->iStateNotifyMask&changed))||
((xkbType==XkbIndicatorMapNotify)&&
@@ -534,8 +529,7 @@ XID winID = 0;
if ((!interest->client->clientGone) &&
(interest->client->requestVector != InitialVector) &&
(interest->client->xkbClientFlags&_XkbClientInitialized) &&
- (interest->bellNotifyMask) &&
- XIShouldNotify(interest->client,kbd)) {
+ (interest->bellNotifyMask)) {
if (!initialized) {
time = GetTimeInMillis();
bn.type = XkbEventCode + XkbEventBase;
@@ -589,8 +583,7 @@ CARD16 sk_delay,db_delay;
if ((!interest->client->clientGone) &&
(interest->client->requestVector != InitialVector) &&
(interest->client->xkbClientFlags&_XkbClientInitialized) &&
- (interest->accessXNotifyMask&(1<<pEv->detail)) &&
- XIShouldNotify(interest->client, kbd)) {
+ (interest->accessXNotifyMask&(1<<pEv->detail))) {
if (!initialized) {
pEv->type = XkbEventCode + XkbEventBase;
pEv->xkbType = XkbAccessXNotify;
@@ -637,8 +630,7 @@ CARD32 changedIndicators;
if ((!interest->client->clientGone) &&
(interest->client->requestVector != InitialVector) &&
(interest->client->xkbClientFlags&_XkbClientInitialized) &&
- (interest->namesNotifyMask&pEv->changed) &&
- XIShouldNotify(interest->client, kbd)) {
+ (interest->namesNotifyMask&pEv->changed)) {
if (!initialized) {
pEv->type = XkbEventCode + XkbEventBase;
pEv->xkbType = XkbNamesNotify;
@@ -683,8 +675,7 @@ CARD16 firstSI = 0, nSI = 0, nTotalSI = 0;
if ((!interest->client->clientGone) &&
(interest->client->requestVector != InitialVector) &&
(interest->client->xkbClientFlags&_XkbClientInitialized) &&
- (interest->compatNotifyMask) &&
- XIShouldNotify(interest->client, kbd)) {
+ (interest->compatNotifyMask)) {
if (!initialized) {
pEv->type = XkbEventCode + XkbEventBase;
pEv->xkbType = XkbCompatMapNotify;
@@ -736,8 +727,7 @@ Time time = 0;
if ((!interest->client->clientGone) &&
(interest->client->requestVector != InitialVector) &&
(interest->client->xkbClientFlags&_XkbClientInitialized) &&
- (interest->actionMessageMask) &&
- XIShouldNotify(interest->client, kbd)) {
+ (interest->actionMessageMask)) {
if (!initialized) {
pEv->type = XkbEventCode + XkbEventBase;
pEv->xkbType = XkbActionMessage;
@@ -783,8 +773,7 @@ CARD16 reason;
if ((!interest->client->clientGone) &&
(interest->client->requestVector != InitialVector) &&
(interest->client->xkbClientFlags&_XkbClientInitialized) &&
- (interest->extDevNotifyMask&reason) &&
- XIShouldNotify(interest->client, dev)) {
+ (interest->extDevNotifyMask&reason)) {
if (!initialized) {
pEv->type = XkbEventCode + XkbEventBase;
pEv->xkbType = XkbExtensionDeviceNotify;
diff --git a/xorg-server/xkeyboard-config/rules/base.extras.xml.in b/xorg-server/xkeyboard-config/rules/base.extras.xml.in
index 4faff93c3..050141434 100644
--- a/xorg-server/xkeyboard-config/rules/base.extras.xml.in
+++ b/xorg-server/xkeyboard-config/rules/base.extras.xml.in
@@ -167,6 +167,22 @@
</layout>
<layout>
<configItem>
+ <name>pl</name>
+ <_shortDescription>pl</_shortDescription>
+ <_description>Polish</_description>
+ <languageList><iso639Id>pol</iso639Id></languageList>
+ </configItem>
+ <variantList>
+ <variant>
+ <configItem>
+ <name>intl</name>
+ <_description>Polish (international with dead keys)</_description>
+ </configItem>
+ </variant>
+ </variantList>
+ </layout>
+ <layout>
+ <configItem>
<name>ro</name>
<_shortDescription>Rou</_shortDescription>
<_description>Romanian</_description>
diff --git a/xorg-server/xkeyboard-config/rules/base.xml.in b/xorg-server/xkeyboard-config/rules/base.xml.in
index 5d74a3900..9ddba2e64 100644
--- a/xorg-server/xkeyboard-config/rules/base.xml.in
+++ b/xorg-server/xkeyboard-config/rules/base.xml.in
@@ -2116,6 +2116,103 @@
</layout>
<layout>
<configItem>
+ <name>cm</name>
+ <_shortDescription>cm</_shortDescription>
+ <_description>English (Cameroon)</_description>
+ <languageList><iso639Id>eng</iso639Id></languageList>
+ </configItem>
+ <variantList>
+ <variant>
+ <configItem>
+ <name>french</name>
+ <_description>French (Cameroon)</_description>
+ <languageList><iso639Id>fra</iso639Id></languageList>
+ </configItem>
+ </variant>
+ <variant>
+ <configItem>
+ <name>qwerty</name>
+ <_description>English (Cameroon qwerty)</_description>
+ <languageList>
+ <iso639Id>eng</iso639Id>
+ <iso639Id>bas</iso639Id>
+ <iso639Id>nmg</iso639Id>
+ <iso639Id>fub</iso639Id>
+ <iso639Id>ewo</iso639Id>
+ <iso639Id>xmd</iso639Id>
+ <iso639Id>mfh</iso639Id>
+ <iso639Id>bkm</iso639Id>
+ <iso639Id>ozm</iso639Id>
+ <iso639Id>lns</iso639Id>
+ <iso639Id>sox</iso639Id>
+ <iso639Id>pny</iso639Id>
+ <iso639Id>wes</iso639Id>
+ <iso639Id>lem</iso639Id>
+ <iso639Id>nyj</iso639Id>
+ <iso639Id>mfk</iso639Id>
+ <iso639Id>mcp</iso639Id>
+ <iso639Id>ass</iso639Id>
+ <iso639Id>xed</iso639Id>
+ <iso639Id>dua</iso639Id>
+ <iso639Id>anv</iso639Id>
+ <iso639Id>bum</iso639Id>
+ <iso639Id>btb</iso639Id>
+ <iso639Id>bfd</iso639Id>
+ <iso639Id>azo</iso639Id>
+ <iso639Id>ken</iso639Id>
+ <iso639Id>yam</iso639Id>
+ <iso639Id>yat</iso639Id>
+ <iso639Id>yas</iso639Id>
+ </languageList>
+ </configItem>
+ </variant>
+ <variant>
+ <configItem>
+ <name>azerty</name>
+ <_description>French (Cameroon azerty)</_description>
+ <languageList>
+ <iso639Id>fra</iso639Id>
+ <iso639Id>bas</iso639Id>
+ <iso639Id>nmg</iso639Id>
+ <iso639Id>fub</iso639Id>
+ <iso639Id>ewo</iso639Id>
+ <iso639Id>xmd</iso639Id>
+ <iso639Id>mfh</iso639Id>
+ <iso639Id>bkm</iso639Id>
+ <iso639Id>ozm</iso639Id>
+ <iso639Id>lns</iso639Id>
+ <iso639Id>sox</iso639Id>
+ <iso639Id>pny</iso639Id>
+ <iso639Id>wes</iso639Id>
+ <iso639Id>lem</iso639Id>
+ <iso639Id>nyj</iso639Id>
+ <iso639Id>mfk</iso639Id>
+ <iso639Id>mcp</iso639Id>
+ <iso639Id>ass</iso639Id>
+ <iso639Id>xed</iso639Id>
+ <iso639Id>dua</iso639Id>
+ <iso639Id>anv</iso639Id>
+ <iso639Id>bum</iso639Id>
+ <iso639Id>btb</iso639Id>
+ <iso639Id>bfd</iso639Id>
+ <iso639Id>azo</iso639Id>
+ <iso639Id>ken</iso639Id>
+ <iso639Id>yam</iso639Id>
+ <iso639Id>yat</iso639Id>
+ <iso639Id>yas</iso639Id>
+ </languageList>
+ </configItem>
+ </variant>
+ <variant>
+ <configItem>
+ <name>dvorak</name>
+ <_description>English (Cameroon Dvorak)</_description>
+ </configItem>
+ </variant>
+ </variantList>
+ </layout>
+ <layout>
+ <configItem>
<name>mm</name>
<_shortDescription>my</_shortDescription>
<_description>Burmese</_description>
diff --git a/xorg-server/xkeyboard-config/symbols/Makefile.am b/xorg-server/xkeyboard-config/symbols/Makefile.am
index a56c1b700..ecd9f25fd 100644
--- a/xorg-server/xkeyboard-config/symbols/Makefile.am
+++ b/xorg-server/xkeyboard-config/symbols/Makefile.am
@@ -1,41 +1,41 @@
-SUBDIRS = digital_vndr fujitsu_vndr hp_vndr macintosh_vndr nec_vndr nokia_vndr sgi_vndr sony_vndr sun_vndr xfree68_vndr
-
-symbolsdir = $(xkb_base)/symbols
-dist_symbols_DATA = \
-ad af al \
-am apl ara \
-at az \
-ba bd be \
-bg br brai \
-bt bw by \
-ca cd \
-ch cn cz \
-de dk \
-ee es et epo \
-fi fo fr \
-gb ge gh gn \
-gr hr hu \
-ie il in iq \
-ir is it jp \
-ke kg kh \
-kr kz \
-la latam latin \
-lk lt lv \
-ma mao me \
-mk ml mm \
-mn mt mv \
-ng nl no np \
-pc ph pk pl pt \
-ro rs ru \
-se si sk sn \
-sy th \
-terminate \
-tj tm tr tw tz \
-ua us uz vn \
-za \
-altwin capslock compose ctrl empty eurosign rupeesign group inet \
-keypad kpdl level3 level5 nbsp olpc shift srvr_ctrl typo
-
-dir_data = $(dist_symbols_DATA)
-
-include $(top_srcdir)/xkbrules.am
+SUBDIRS = digital_vndr fujitsu_vndr hp_vndr macintosh_vndr nec_vndr nokia_vndr sgi_vndr sony_vndr sun_vndr xfree68_vndr
+
+symbolsdir = $(xkb_base)/symbols
+dist_symbols_DATA = \
+ad af al \
+am apl ara \
+at az \
+ba bd be \
+bg br brai \
+bt bw by \
+ca cd ch \
+cm cn cz \
+de dk \
+ee es et epo \
+fi fo fr \
+gb ge gh gn \
+gr hr hu \
+ie il in iq \
+ir is it jp \
+ke kg kh \
+kr kz \
+la latam latin \
+lk lt lv \
+ma mao me \
+mk ml mm \
+mn mt mv \
+ng nl no np \
+pc ph pk pl pt \
+ro rs ru \
+se si sk sn \
+sy th \
+terminate \
+tj tm tr tw tz \
+ua us uz vn \
+za \
+altwin capslock compose ctrl empty eurosign rupeesign group inet \
+keypad kpdl level3 level5 nbsp olpc shift srvr_ctrl typo
+
+dir_data = $(dist_symbols_DATA)
+
+include $(top_srcdir)/xkbrules.am
diff --git a/xorg-server/xkeyboard-config/symbols/cm b/xorg-server/xkeyboard-config/symbols/cm
new file mode 100644
index 000000000..449bbcad3
--- /dev/null
+++ b/xorg-server/xkeyboard-config/symbols/cm
@@ -0,0 +1,331 @@
+// ========== Cameroon Keyboards ==========
+// ****** For Instructions, see "Use of Cameroon Keyboards" section below ******
+
+
+// The XKB versions of these keyboards were developed by Matthew Lee, Jenni Beadle, and Bruce Cox of SIL Cameroon in association with Going Komputya, Uwe Yung of the Goethe Institute, Yaoundé, and Centre ANACLAC.
+
+// Cameroon is officially a bilingual country, using French and English, but there are over 270 minority languages.
+
+// * Cameroon Français is an exact copy of the French France keyboard intended for AZERTY users.
+// * Cameroon is an exact copy of the Basic US Keyboard. I can not currently name this "Cameroon English" due to a limitation of XKB.
+// * Cameroon QWERTY and Cameroon AZERTY are based largely on SIL Cameroon's Keyman and Microsoft keyboards of the same style already in wide use. These keyboards are designed to allow the user to type any of Cameroon's 270+ languages and dialects that use the approved orthography. This Approved Orthography was adopted in 1979 by the National Committee for the Unification and Harmonisation of Alphabets of Camerooninan Languages.
+// * Cameroon Dvorak is described below.
+
+// ===== Use of Cameroon Keyboards =====
+
+// == Fonts ==
+// These keyboards are fully Unicode (5.1), so we recommend using a good unicode font for diacritics to position correctly. Recommended fonts are: ttf-sil-charis, ttf-sil-doulos, ttf-sil-gentium and ttf-sil-andika (All of which are free for Linux, Mac, and Windows).
+
+
+// == Cameroon AZERTY ==
+// Cameroon AZERTY uses the French France (AZERTY) layout, as french keyboards are widely used here. While this keyboard is designed for Cameroonian orthography, it still is possible but not recommended, to type French with minimal discomfort using this keyboard.
+// Cameroon AZERTY uses the "!" (exclamation) key as the "Cameroon" key. Pressing this key before another key allows you to access the special letters and diacritics needed in Cameroonian orthography.
+// For example, press "!" then "a" and get "ɛ" (small epsilon). "!" then "Shift" + "a" (A) will get an "Ɛ" (capital epsilon). Press the "!" key twice to get a "!".
+// If you prefer, you can hold the AltGr (and/or Shift) key to access the same letters, but we have found this to be much more awkward in practice. If you really don't like our Cameroon key, simply comment out "include "cm(exclamation_switch)"" and the exclamation key will return to normal.
+// All Diacritics (with the exception of French Trema and Circumflex) must be typed (in order of stacking) after the letter.
+
+
+// == Cameroon QWERTY ==
+// Cameroon QWERTY uses the US QWERTY layout, as US keyboards are also widely used here. While this keyboard is designed for Cameroonian orthography, it is possible, but not recommended, to type English with minimal discomfort using this keyboard.
+// Cameroon QWERTY uses the ";" (semicolon) key as the "Cameroon" key. Pressing this key before another key allows you to access the special letters and diacritics needed in Cameroonian orthography.
+// For example, press ";" then "a" and get "ɛ" (small epsilon). ";" then "Shift" + "a" (A) will get an "Ɛ" (capital epsilon). Press ";" twice to get a ";", or press Shift + ; (:) twice to get a ":" (colon).
+// If you prefer, you can hold the AltGr (and/or Shift) key to access the same letters, but we have found this to be much more awkward in practice. If you really don't like our Cameroon key, simply comment out "include "cm(semicolon_switch)"" and the semicolon key will return to normal.
+// All Diacritics must be typed (in order of stacking) after the letter.
+
+
+// == Cameroon Dvorak ==
+// Cameroon Dvorak is uses a similar system to Cameroon QWERTY.
+
+default
+partial alphanumeric_keys
+xkb_symbols "basic" {
+
+ name[Group1]="English (Cameroon)";
+
+ // Alphanumeric section
+ key <TLDE> { [ grave, asciitilde ] };
+ key <AE01> { [ 1, exclam ] };
+ key <AE02> { [ 2, at ] };
+ key <AE03> { [ 3, numbersign ] };
+ key <AE04> { [ 4, dollar ] };
+ key <AE05> { [ 5, percent ] };
+ key <AE06> { [ 6, asciicircum ] };
+ key <AE07> { [ 7, ampersand ] };
+ key <AE08> { [ 8, asterisk ] };
+ key <AE09> { [ 9, parenleft ] };
+ key <AE10> { [ 0, parenright ] };
+ key <AE11> { [ minus, underscore ] };
+ key <AE12> { [ equal, plus ] };
+
+ key <AD01> { [ q, Q ] };
+ key <AD02> { [ w, W ] };
+ key <AD03> { [ e, E ] };
+ key <AD04> { [ r, R ] };
+ key <AD05> { [ t, T ] };
+ key <AD06> { [ y, Y ] };
+ key <AD07> { [ u, U ] };
+ key <AD08> { [ i, I ] };
+ key <AD09> { [ o, O ] };
+ key <AD10> { [ p, P ] };
+ key <AD11> { [ bracketleft, braceleft ] };
+ key <AD12> { [ bracketright, braceright ] };
+ key <AC01> { [ a, A ] };
+ key <AC02> { [ s, S ] };
+ key <AC03> { [ d, D ] };
+ key <AC04> { [ f, F ] };
+ key <AC05> { [ g, G ] };
+ key <AC06> { [ h, H ] };
+ key <AC07> { [ j, J ] };
+ key <AC08> { [ k, K ] };
+ key <AC09> { [ l, L ] };
+ key <AC10> { [ semicolon, colon ] };
+ key <AC11> { [ apostrophe, quotedbl ] };
+
+ key <AB01> { [ z, Z ] };
+ key <AB02> { [ x, X ] };
+ key <AB03> { [ c, C ] };
+ key <AB04> { [ v, V ] };
+ key <AB05> { [ b, B ] };
+ key <AB06> { [ n, N ] };
+ key <AB07> { [ m, M ] };
+ key <AB08> { [ comma, less ] };
+ key <AB09> { [ period, greater ] };
+ key <AB10> { [ slash, U003F ] };
+
+ key <BKSL> { [ backslash, bar ] };
+ // End alphanumeric section
+};
+
+partial alphanumeric_keys
+xkb_symbols "french"
+{
+ name[Group1]="French (Cameroon)";
+ include "latin"
+
+ key <AE01> { [ ampersand, 1, onesuperior, exclamdown ] };
+ key <AE02> { [ eacute, 2, asciitilde, oneeighth ] };
+ key <AE03> { [ quotedbl, 3, numbersign, sterling ] };
+ key <AE04> { [apostrophe, 4, braceleft, dollar ] };
+ key <AE05> { [ parenleft, 5, bracketleft, threeeighths ] };
+ key <AE06> { [ minus, 6, bar, fiveeighths ] };
+ key <AE07> { [ egrave, 7, grave, seveneighths ] };
+ key <AE08> { [underscore, 8, backslash, trademark ] };
+ key <AE09> { [ ccedilla, 9, asciicircum, plusminus ] };
+ key <AE10> { [ agrave, 0, at, degree ] };
+ key <AE11> { [parenright, degree, bracketright, questiondown ] };
+ key <AE12> { [ equal, plus, braceright, dead_ogonek ] };
+
+ key <AD01> { [ a, A, ae, AE ] };
+ key <AD02> { [ z, Z, guillemotleft, less ] };
+ key <AD03> { [ e, E, EuroSign, cent ] };
+ key <AD11> { [dead_circumflex, dead_diaeresis, dead_diaeresis, dead_abovering ] };
+ key <AD12> { [ dollar, sterling, currency, dead_macron ] };
+
+ key <AC01> { [ q, Q, at, Greek_OMEGA ] };
+ key <AC10> { [ m, M, mu, masculine ] };
+ key <AC11> { [ ugrave, percent, dead_circumflex, dead_caron] };
+ key <TLDE> { [twosuperior, asciitilde, notsign, notsign ] };
+
+ key <BKSL> { [ asterisk, mu, dead_grave, dead_breve ] };
+ key <AB01> { [ w, W, lstroke, Lstroke ] };
+ key <AB07> { [ comma, U003F, dead_acute, dead_doubleacute ] };
+ key <AB08> { [ semicolon, period, horizconnector, multiply ] };
+ key <AB09> { [ colon, slash, periodcentered, division ] };
+ key <AB10> { [ exclam, section, dead_belowdot, dead_abovedot ] };
+
+ include "level3(ralt_switch)"
+};
+
+
+partial alphanumeric_keys
+xkb_symbols "azerty"
+{
+ name[Group1] = "French (Cameroon azerty)";
+ include "level3(ralt_switch)"
+ include "cm(basic)"
+ key <AB01> { [ w, W, U1E85, U1E84 ] }; // SMALL LETTER W, CAPITAL LETTER W, SMALL LETTER W WITH DIAERESIS, CAPITAL LETTER W WITH DIAERESIS
+ key <AB02> { [ x, X, U2039, U203A ] }; // SMALL LETTER X, CAPITAL LETTER X, SINGLE LEFT-POINTING ANGLE QUOTATION MARK, SINGLE RIGHT-POINTING ANGLE QUOTATION MARK
+ key <AB03> { [ c, C, U0327, copyright ] }; // SMALL LETTER C, CAPITAL LETTER C, COMBINING CEDILLA, COPYRIGHT SIGN
+ key <AB04> { [ v, V, U25CC, NoSymbol ] }; // SMALL LETTER V, CAPITAL LETTER V, PLACEHOLDER CHARACTER
+ key <AB05> { [ b, B, U0253, U0181 ] }; // SMALL LETTER B, CAPITAL LETTER B, SMALL LETTER B WITH HOOK, CAPITAL LETTER B WITH HOOK
+ key <AB06> { [ n, N, U014B, U014A ] }; // SMALL LETTER N, CAPITAL LETTER N, SMALL LETTER ENG, CAPITAL LETTER ENG
+ key <AB07> { [ U002C, U003F, NoSymbol, U00D7 ] }; // COMMA, QUESTION MARK, , MULTIPLY
+ key <AB08> { [ semicolon, period, dead_acute, dead_grave ] }; // SEMICOLON, PERIOD
+ key <AB09> { [ colon, slash, U0323 ] }; // COLON, SLASH, COMBINING DOT BELOW
+ key <AB10> { [ exclam, U00A7 ] }; // EXCLAMATION MARK, SECTION SIGN
+ key <AC01> { [ q, Q, U2014, U2013 ] }; // SMALL LETTER Q, CAPITAL LETTER Q, EM DASH, EN DASH
+ key <AC02> { [ s, S, U201C, U201D ] }; // SMALL LETTER S, CAPITAL LETTER S, LEFT DOUBLE QUOTES, RIGHT DOUBLE QUOTES
+ key <AC03> { [ d, D, U0257, U018A ] }; // SMALL LETTER D, CAPITAL LETTER D, SMALL LETTER D WITH HOOK, CAPITAL LETTER D WITH HOOK
+ key <AC04> { [ f, F, U00E6, U00C6 ] }; // SMALL LETTER F, CAPITAL LETTER F, SMALL LIGATURE AE, CAPITAL LIGATURE AE
+ key <AC05> { [ g, G, UA78C, UA78B ] }; // SMALL LETTER G, CAPITAL LETTER G, SMALL LETTER GLOTTAL (SALTILLO), CAPITAL LETTER GLOTTAL (SALTILLO)
+ key <AC06> { [ h, H, U0251, U2C6D ] }; // SMALL LETTER H, CAPITAL LETTER H, SMALL LETTER ALPHA, CAPITAL LETTER ALPHA
+ key <AC07> { [ j, J, leftarrow, U2122 ] }; //SMALL LETTER J, CAPITAL LETTER J, LEFT ARROW, TRADE MARK SIGN
+ key <AC08> { [ k, K, downarrow, uparrow ] }; // SMALL LETTER K, CAPITAL LETTER K, DOWN ARROW, UP ARROW
+ key <AC09> { [ l, L, rightarrow, U00A3 ] }; // SMALL LETTER L, CAPITAL LETTER L, RIGHT ARROW, POUND STERLING
+ key <AC10> { [ m, M, U00F9, U00B5 ] }; // SMALL LETTER M, CAPITAL LETTER M, SMALL LETTER U WITH GRAVE, MICRO SYMBOL
+ key <AC11> { [ U0300, U0302, U1DC5, U1DC4 ] }; // COMBINING LOW TONE, COMBINING FALLING TONE, COMBINING LOW-MID TONE, COMBINING MID-HIGH TONE
+ key <AD01> { [ a, A, U025B, U0190 ] }; // SMALL LETTER A, CAPITAL LETTER A, SMALL LETTER OPEN E, CAPITAL LETTER OPEN E
+ key <AD02> { [ z, Z, U2026, U2020 ] }; // SMALL LETTER Z, CAPITAL LETTER Z, ELLIPSIS, DAGGER
+ key <AD03> { [ e, E, U0259, U018F ] }; // SMALL LETTER E, CAPITAL LETTER E, SMALL LETTER SCHWA, CAPITAL LETTER SCHWA
+ key <AD04> { [ r, R, NoSymbol, U00AE ] }; // SMALL LETTER R, CAPITAL LETTER R, , REGISTERED SIGN
+ key <AD05> { [ t, T, U0153, U0152 ] }; // SMALL LETTER T, CAPITAL LETTER T, SMALL LIGATURE OE, CAPITAL LIGATURE OE
+ key <AD06> { [ y, Y, U01B4, U01B3 ] }; // SMALL LETTER Y, CAPITAL LETTER Y, SMALL LETTER Y WITH HOOK, CAPITAL LETTER Y WITH HOOK
+ key <AD07> { [ u, U, U0289, U0244 ] }; // SMALL LETTER U, CAPITAL LETTER U, SMALL LETTER U BAR, CAPITAL LETTER U BAR
+ key <AD08> { [ i, I, U0268, U0197 ] }; // SMALL LETTER I, CAPITAL LETTER I, SMALL LETTER I BAR, CAPITAL LETTER I BAR
+ key <AD09> { [ o, O, U0254, U0186 ] }; // SMALL LETTER O, CAPITAL LETTER O, SMALL LETTER OPEN O, CAPITAL LETTER OPEN O
+ key <AD10> { [ p, P, U00F8, U00D8 ] }; // SMALL LETTER P, CAPITAL LETTER P, SMALL LETTER O BAR, CAPITAL LETTER O BAR
+ key <AD11> { [ U0301, U030C, dead_circumflex, dead_diaeresis ] }; // COMBINING HIGH TONE, COMBINING RISING TONE, DEAD CIRCUMFLEX, DEAD DIAERESIS
+ key <AD12> { [ U0330, U0303, U0304, U030D ] }; // COMBINING TILDE (NASAL) BELOW, COMBINING TILDE (NASAL), COMBINING MID TONE, COMBINING VERTICAL LINE ABOVE
+ key <AE01> { [ U0026, KP_1, U00B9, U2018 ] }; // AMPERSAND, 1, SUPERSCRIPT 1, LEFT SINGLE QUOTE
+ key <AE02> { [ eacute, KP_2, asciitilde, U2019 ] }; // SMALL LETTER E WITH ACUTE, 2, TILDE, RIGHT SINGLE QUOTE
+ key <AE03> { [ U0022, KP_3, U0025 ] }; // QUOTATION MARK, 3, PERCENT SIGN
+ key <AE04> { [ U0027, KP_4, U007B ] }; // APOSTROPHE, 4, LEFT CURLY BRACKET
+ key <AE05> { [ U0028, KP_5, U005B, numbersign ] }; // LEFT PARENTHESIS, 5, LEFT SQUARE BRACKET, NUMBER SIGN
+ key <AE06> { [ U002D, KP_6, U007C ] }; // HYPHEN/MINUS, 6, BAR
+ key <AE07> { [ U00E8, KP_7, U0300 ] }; // SMALL LETTER E WITH GRAVE, 7, COMBINING GRAVE
+ key <AE08> { [ underscore, KP_8, backslash, U20D6 ] }; // UNDERSCORE, 8, BACKSLASH, COMBINING LEFT ARROW ABOVE
+ key <AE09> { [ ccedilla, KP_9, U005E] }; // SMALL LETTER C WITH CEDILLA, 9, CIRCUMFLEX
+ key <AE10> { [ U00E0, KP_0, at, U20D7 ] }; // SMALL LETTER A WITH GRAVE
+ key <AE11> { [ U0029, U00B0, U005D ] }; // RIGHT PARENTHESIS, DEGREE, RIGHT SQUARE BRACKET
+ key <AE12> { [ U003D, U002B, U007D, U00B1 ] }; // EQUAL SIGN, PLUS SIGN, RIGHT CURLY BRACKET, PLUS-MINUS SIGN
+ key <BKSL> { [ U1DC6, U1DC7, KP_Multiply, U00A4 ] }; // COMBINING MID-LOW, COMBINING HIGH-MID, MULTIPLY, CURRENCY SIGN
+ key <LSGT> { [ U003C, U003E, U00AB, U00BB ] }; // LESS THAN, GREATER THAN, LEFT GUILLEMET, RIGHT GUILLEMET
+ key <TLDE> { [ U0024, U20AC, U00B2, U00B3 ] }; // DOLLAR, EURO, SUPERSCRIPT 2, SUPERSCRIPT 3
+ include "cm(exclamation_switch)"
+};
+
+partial alphanumeric_keys
+xkb_symbols "qwerty"
+{
+ name[Group1] = "English (Cameroon qwerty)";
+ include "level3(ralt_switch)"
+ include "cm(basic)"
+ key <AB01> { [ z, Z, U2026, U2020 ] }; // SMALL LETTER Z, CAPITAL LETTER Z, ELLIPSIS, DAGGER
+ key <AB02> { [ x, X ] }; // SMALL LETTER X, CAPITAL LETTER X
+ key <AB03> { [ c, C, NoSymbol, U00A9 ] }; // SMALL LETTER C, CAPITAL LETTER C, , COPYRIGHT
+ key <AB04> { [ v, V, U25CC, NoSymbol ] }; // SMALL LETTER V, CAPITAL LETTER V, PLACEHOLDER CHARACTER
+ key <AB05> { [ b, B, U0253, U0181 ] }; // SMALL LETTER B, CAPITAL LETTER B, SMALL LETTER B WITH HOOK, CAPITAL LETTER B WITH HOOK
+ key <AB06> { [ n, N, U014B, U014A ] }; // SMALL LETTER N, CAPITAL LETTER N, SMALL LETTER ENG, CAPITAL LETTER ENG
+ key <AB07> { [ m, M, NoSymbol, U2122 ] }; // SMALL LETTER M, CAPITAL LETTER M, , TRADEMARK SIGN
+ key <AB08> { [ U002C, U003C, U2039, U00AB ] }; // COMMA, LESS THAN SIGN, LEFT SINGLE GUILLEMET, LEFT DOUBLE GUILLEMET
+ key <AB09> { [ U002B, U003E, U203A, U00BB ] }; // PERIOD, GREATER THAN SIGN, RIGHT SINGLE GUILLEMET, RIGHT DOUBLE GUILLEMET
+ key <AB10> { [ U002F, U003F, U00F7, U0294 ] }; // SLASH, QUESTION MARK, DIVISION SIGN, GLOTTAL STOP
+ key <AC01> { [ a, A, U025B, U0190 ] }; // SMALL LETTER A, CAPITAL LETTER A, SMALL LETTER OPEN E, CAPITAL LETTER OPEN E
+ key <AC02> { [ s, S ] }; // SMALL LETTER S, CAPITAL LETTER S
+ key <AC03> { [ d, D, U0257, U018A ] }; // SMALL LETTER D, CAPITAL LETTER D, SMALL LETTER D WITH HOOK, CAPITAL LETTER D WITH HOOK
+ key <AC04> { [ f, F, U00E6, U00C6 ] }; // SMALL LETTER F, CAPITAL LETTER F, SMALL LIGATURE AE, CAPITAL LIGATURE AE
+ key <AC05> { [ g, G, UA78C, UA78B ] }; // SMALL LETTER G, CAPITAL LETTER G, SMALL LETTER GLOTTAL (SALTILLO), CAPITAL LETTER GLOTTAL (SALTILLO)
+ key <AC06> { [ h, H, U0251, U2C6D ] }; // SMALL LETTER H, CAPITAL LETTER H, SMALL LETTER ALPHA, CAPITAL LETTER ALPHA
+ key <AC07> { [ j, J, U0330, U0323 ] }; // SMALL LETTER J, CAPITAL LETTER J, COMBINING TILDE (NASAL) BELOW, COMBINING DOT BELOW
+ key <AC08> { [ k, K, U1DC5, U1DC7 ] }; // SMALL LETTER K, CAPITAL LETTER K, COMBINING LOW-MID TONE, COMBINING HIGH-MID
+ key <AC09> { [ l, L, U1DC6, U1DC4 ] }; // SMALL LETTER L, CAPITAL LETTER L, COMBINING MID-LOW, COMBINING MID-HIGH TONE
+ key <AC10> { [ U003B, U003A ] }; // SEMICOLON, COLON
+ key <AC11> { [ U0300, U0302, U0027, U0022 ] }; // COMBINING LOW TONE, COMBINING FALLING TONE, APOSTROPHE, QUOTATION MARK
+ key <AD01> { [ q, Q, U2014, U2013 ] }; // SMALL LETTER Q, CAPITAL LETTER Q, EM DASH, EN DASH
+ key <AD02> { [ w, W, U1E85, U1E84 ] }; // SMALL LETTER W, CAPITAL LETTER W, SMALL LETTER W WITH DIAERESIS, CAPITAL LETTER W WITH DIAERESIS
+ key <AD03> { [ e, E, U0259, U018F ] }; // SMALL LETTER E, CAPITAL LETTER E, SMALL LETTER SCHWA, CAPITAL LETTER SCHWA
+ key <AD04> { [ r, R, NoSymbol, U00AE ] }; // SMALL LETTER R, CAPITAL LETTER R, , REGISTERED SIGN
+ key <AD05> { [ t, T, U0153, U0152 ] }; // SMALL LETTER T, CAPITAL LETTER T, SMALL LIGATURE OE, CAPITAL LIGATURE OE
+ key <AD06> { [ y, Y, U01B4, U01B3 ] }; // SMALL LETTER Y, CAPITAL LETTER Y, SMALL LETTER Y WITH HOOK, CAPITAL LETTER Y WITH HOOK
+ key <AD07> { [ u, U, U0289, U0244 ] }; // SMALL LETTER U, CAPITAL LETTER U, SMALL LETTER U BAR, CAPITAL LETTER U BAR
+ key <AD08> { [ i, I, U0268, U0197 ] }; // SMALL LETTER I, CAPITAL LETTER I, SMALL LETTER I BAR, CAPITAL LETTER I BAR
+ key <AD09> { [ o, O, U0254, U0186 ] }; // SMALL LETTER O, CAPITAL LETTER O, SMALL LETTER OPEN O, CAPITAL LETTER OPEN O
+ key <AD10> { [ p, P, U00F8, U00D8 ] }; // SMALL LETTER P, CAPITAL LETTER P, SMALL LETTER O BAR, CAPITAL LETTER O BAR
+ key <AD11> { [ U0301, U030C, U005B, U007B ] }; // COMBINING HIGH TONE, COMBINING RISING TONE, LEFT SQUARE BRACKET, LEFT CURLY BRACKET
+ key <AD12> { [ U0327, U0308, U005D, U007D ] }; // COMBINING CEDILLA, COMBINING DIAERESIS, RIGHT SQUARE BRACKET, RIGHT CURLY BRACKET
+ key <AE01> { [ U0031, U0021, U00BC ] }; // 1, EXCLAMATION POINT, ONE QUARTER
+ key <AE02> { [ U0032, U0040, U00BD ] }; //2, AT SYMBOL, ONE HALF
+ key <AE03> { [ U0033, U0023, U00BE ] }; // 3, NUMBER SIGN, THREE QUARTERS
+ key <AE04> { [ U0034, U0024, NoSymbol, U20AC ] }; // 4, DOLLAR, , EURO SIGN
+ key <AE08> { [ U0038, U002A, NoSymbol, U00D7 ] }; // 8, ASTERISK, , MATH MULTIPLY
+ key <AE09> { [ U0039, U0028, U2018, U201C ] }; // 9, LEFT PARENTHESIS, LEFT SINGLE QUOTE MARK, LEFT DOUBLE QUOTE MARK
+ key <AE10> { [ U0030, U0029, U2019, U201D ] }; // 0, RIGHT PARENTHESIS, RIGHT SINGLE QUOTE MARK, LEFT DOUBLE QUOTE MARK
+ key <AE11> { [ U002D, U005F, U0304 ] }; // MINUS, UNDERSCORE, COMBINING MID TONE, COMBINING MID TONE
+ key <AE12> { [ U003D, U002B, NoSymbol, U00B1 ] }; // EQUAL, PLUS, , PLUS-MINUS
+ key <BKSL> { [ U005C, U007C ] }; // BACKSLASH, BAR
+ key <TLDE> { [ U030D, U0303, U0060, U007E ] }; // COMBINING VERTICAL LINE ABOVE, COMBINING TILDE ABOVE, GRAVE ACCENT, TILDE
+ include "cm(semicolon_switch)"
+};
+
+
+partial alphanumeric_keys
+xkb_symbols "dvorak"
+{
+ name[Group1] = "English (Cameroon Dvorak)";
+ include "level3(ralt_switch)"
+ include "us(dvorak)"
+ key <AB01> { [ semicolon, colon ] }; // SEMICOLON, COLON
+ key <AB02> { [ q, Q, U2014, U2013 ] }; // SMALL LETTER Q, CAPITAL LETTER Q, EM DASH, EN DASH
+ key <AB03> { [ j, J, U0330, U0323 ] }; // SMALL LETTER J, CAPITAL LETTER J, COMBINING TILDE (NASAL) BELOW, COMBINING DOT BELOW
+ key <AB04> { [ k, K, U1DC5, U1DC7 ] }; // SMALL LETTER K, CAPITAL LETTER K, COMBINING LOW-MID TONE, COMBINING HIGH-MID
+ key <AB05> { [ x, X ] }; // SMALL LETTER X, CAPITAL LETTER X
+ key <AB06> { [ b, B, U0253, U0181 ] }; // SMALL LETTER B, CAPITAL LETTER B, SMALL LETTER B WITH HOOK, CAPITAL LETTER B WITH HOOK
+ key <AB07> { [ m, M, NoSymbol, U2122 ] }; // SMALL LETTER M, CAPITAL LETTER M, , TRADEMARK SIGN
+ key <AB08> { [ w, W, U1E85, U1E84 ] }; // SMALL LETTER W, CAPITAL LETTER W, SMALL LETTER W WITH DIAERESIS, CAPITAL LETTER W WITH DIAERESIS
+ key <AB09> { [ v, V, U25CC, NoSymbol ] }; // SMALL LETTER V, CAPITAL LETTER V, PLACEHOLDER CHARACTER
+ key <AB10> { [ z, Z, U2026, U2020 ] }; // SMALL LETTER Z, CAPITAL LETTER Z, ELLIPSIS, DAGGER
+ key <AC01> { [ a, A, U025B, U0190 ] }; // SMALL LETTER A, CAPITAL LETTER A, SMALL LETTER OPEN E, CAPITAL LETTER OPEN E
+ key <AC02> { [ o, O, U0254, U0186 ] }; // SMALL LETTER O, CAPITAL LETTER O, SMALL LETTER OPEN O, CAPITAL LETTER OPEN O
+ key <AC03> { [ e, E, U0259, U018F ] }; // SMALL LETTER E, CAPITAL LETTER E, SMALL LETTER SCHWA, CAPITAL LETTER SCHWA
+ key <AC04> { [ u, U, U0289, U0244 ] }; // SMALL LETTER U, CAPITAL LETTER U, SMALL LETTER U BAR, CAPITAL LETTER U BAR
+ key <AC05> { [ i, I, U0268, U0197 ] }; // SMALL LETTER I, CAPITAL LETTER I, SMALL LETTER I BAR, CAPITAL LETTER I BAR
+ key <AC06> { [ d, D, U0257, U018A ] }; // SMALL LETTER D, CAPITAL LETTER D, SMALL LETTER D WITH HOOK, CAPITAL LETTER D WITH HOOK
+ key <AC07> { [ h, H, U0251, U2C6D ] }; // SMALL LETTER H, CAPITAL LETTER H, SMALL LETTER ALPHA, CAPITAL LETTER ALPHA
+ key <AC08> { [ t, T, U0153, U0152 ] }; // SMALL LETTER T, CAPITAL LETTER T, SMALL LIGATURE OE, CAPITAL LIGATURE OE
+ key <AC09> { [ n, N, U014B, U014A ] }; // SMALL LETTER N, CAPITAL LETTER N, SMALL LETTER ENG, CAPITAL LETTER ENG
+ key <AC10> { [ s, S ] }; // SMALL LETTER S, CAPITAL LETTER S
+ key <AC11> { [ minus, underscore, U0304 ] }; // MINUS, UNDERSCORE, COMBINING MID TONE
+ key <AD01> { [ U0300, U0302, U0027, U0022 ] }; // COMBINING LOW TONE, COMBINING FALLING TONE, APOSTROPHE, QUOTATION MARK
+ key <AD02> { [ comma, less, U2039, U00AB ] }; // COMMA, LESS THAN SIGN, LEFT SINGLE GUILLEMET, LEFT DOUBLE GUILLEMET
+ key <AD03> { [ period, greater, U203A, U00BB ] }; // PERIOD, GREATER THAN SIGN, RIGHT SINGLE GUILLEMET, RIGHT DOUBLE GUILLEMET
+ key <AD04> { [ p, P, U00F8, U00D8 ] }; // SMALL LETTER P, CAPITAL LETTER P, SMALL LETTER O BAR, CAPITAL LETTER O BAR
+ key <AD05> { [ y, Y, U01B4, U01B3 ] }; // SMALL LETTER Y, CAPITAL LETTER Y, SMALL LETTER Y WITH HOOK, CAPITAL LETTER Y WITH HOOK
+ key <AD06> { [ f, F, U00E6, U00C6 ] }; // SMALL LETTER F, CAPITAL LETTER F, SMALL LIGATURE AE, CAPITAL LIGATURE AE
+ key <AD07> { [ g, G, UA78C, UA78B ] }; // SMALL LETTER G, CAPITAL LETTER G, SMALL LETTER GLOTTAL (SALTILLO), CAPITAL LETTER GLOTTAL (SALTILLO)
+ key <AD08> { [ c, C, NoSymbol, U00A9 ] }; // SMALL LETTER C, CAPITAL LETTER C, , COPYRIGHT
+ key <AD09> { [ r, R, NoSymbol, U00AE ] }; // SMALL LETTER R, CAPITAL LETTER R, , REGISTERED SIGN
+ key <AD10> { [ l, L, U1DC6, U1DC4 ] }; // SMALL LETTER L, CAPITAL LETTER L, COMBINING MID-LOW, COMBINING MID-HIGH TONE
+ key <AD11> { [ slash, U003F, U00F7, U0294 ] }; // SLASH, QUESTION MARK, DIVISION SIGN, GLOTTAL STOP
+ key <AD12> { [ equal, plus, NoSymbol, plusminus ] }; // EQUAL, PLUS, , PLUS-MINUS
+ key <AE01> { [ KP_1, exclam, U00BC ] }; // 1, EXCLAMATION POINT, ONE QUARTER
+ key <AE02> { [ KP_2, at, U00BD ] }; // 2, AT SYMBOL, ONE HALF
+ key <AE03> { [ KP_3, numbersign, U00BE ] }; // 3, NUMBER SIGN, THREE QUARTERS
+ key <AE04> { [ KP_4, dollar, NoSymbol, U20AC ] }; // 4, DOLLAR, , EURO SIGN
+ key <AE05> { [ KP_5, percent ] }; // 5, PERCENT
+ key <AE06> { [ KP_6, asciicircum ] }; // 6, CARET
+ key <AE07> { [ KP_7, ampersand ] }; // 7, AMPERSAND
+ key <AE08> { [ KP_8, asterisk, NoSymbol, multiply ] }; // 8, ASTERISK, , MULTIPLY
+ key <AE09> { [ KP_9, parenleft, leftsinglequotemark, leftdoublequotemark ] }; // 9, LEFT PARENTHESIS, LEFT SINGLE QUOTE MARK, LEFT DOUBLE QUOTE MARK
+ key <AE10> { [ KP_0, parenright, rightsinglequotemark, rightdoublequotemark ] }; // 0, RIGHT PARENTHESIS, RIGHT SINGLE QUOTE MARK, LEFT DOUBLE QUOTE MARK
+ key <AE11> { [ U0301, U030C, U005B, U007B ] }; // COMBINING HIGH TONE, COMBINING RISING TONE, LEFT SQUARE BRACKET, LEFT CURLY BRACKET
+ key <AE12> { [ U0327, dead_diaeresis, U005D, braceright ] }; // COMBINING CEDILLA, DEAD DIAERESIS, RIGHT SQUARE BRACKET, RIGHT CURLY BRACKET
+ key <BKSL> { [ backslash, bar ] }; // BACKSLASH, BAR
+ key <TLDE> { [ U030D, U0303, U0060, U007E ] }; // COMBINING VERTICAL LINE ABOVE, COMBINING TILDE ABOVE, GRAVE ACCENT, TILDE
+ include "cm(semicolon_switch_dvorak)"
+};
+
+// The following code creates the "Cameroon key" phenomenon.
+
+partial modifier_keys
+xkb_symbols "semicolon_switch" {
+ key <AC10> {
+ symbols[Group1] = [ ISO_Level3_Latch, colon, semicolon, colon ]};
+ modifier_map Mod5 { ISO_Level3_Latch };
+};
+
+partial modifier_keys
+xkb_symbols "exclamation_switch" {
+ key <AB10> {
+ symbols[Group1] = [ ISO_Level3_Latch, U00A7, exclam, U00A7 ]
+ };
+ modifier_map Mod5 { ISO_Level3_Latch };
+};
+
+partial modifier_keys
+xkb_symbols "semicolon_switch_dvorak" {
+ key <AB01> {
+ symbols[Group1] = [ ISO_Level3_Latch, colon, semicolon, colon ]
+ };
+modifier_map Mod5 { ISO_Level3_Latch };
+};
+
diff --git a/xorg-server/xkeyboard-config/symbols/latin b/xorg-server/xkeyboard-config/symbols/latin
index e8cb03715..77b99d46c 100644
--- a/xorg-server/xkeyboard-config/symbols/latin
+++ b/xorg-server/xkeyboard-config/symbols/latin
@@ -1,175 +1,256 @@
-// Common Latin alphabet layout
-
-default partial
-xkb_symbols "basic" {
-
- key <AE01> { [ 1, exclam, onesuperior, exclamdown ] };
- key <AE02> { [ 2, at, twosuperior, oneeighth ] };
- key <AE03> { [ 3, numbersign, threesuperior, sterling ] };
- key <AE04> { [ 4, dollar, onequarter, dollar ] };
- key <AE05> { [ 5, percent, onehalf, threeeighths ] };
- key <AE06> { [ 6, asciicircum, threequarters, fiveeighths ] };
- key <AE07> { [ 7, ampersand, braceleft, seveneighths ] };
- key <AE08> { [ 8, asterisk, bracketleft, trademark ] };
- key <AE09> { [ 9, parenleft, bracketright, plusminus ] };
- key <AE10> { [ 0, parenright, braceright, degree ] };
- key <AE11> { [ minus, underscore, backslash, questiondown ] };
- key <AE12> { [ equal, plus, dead_cedilla, dead_ogonek ] };
-
- key <AD01> { [ q, Q, at, Greek_OMEGA ] };
- key <AD02> { [ w, W, lstroke, Lstroke ] };
- key <AD03> { [ e, E, e, E ] };
- key <AD04> { [ r, R, paragraph, registered ] };
- key <AD05> { [ t, T, tslash, Tslash ] };
- key <AD06> { [ y, Y, leftarrow, yen ] };
- key <AD07> { [ u, U, downarrow, uparrow ] };
- key <AD08> { [ i, I, rightarrow, idotless ] };
- key <AD09> { [ o, O, oslash, Ooblique ] };
- key <AD10> { [ p, P, thorn, THORN ] };
- key <AD11> { [bracketleft, braceleft, dead_diaeresis, dead_abovering ] };
- key <AD12> { [bracketright, braceright, dead_tilde, dead_macron ] };
-
- key <AC01> { [ a, A, ae, AE ] };
- key <AC02> { [ s, S, ssharp, section ] };
- key <AC03> { [ d, D, eth, ETH ] };
- key <AC04> { [ f, F, dstroke, ordfeminine ] };
- key <AC05> { [ g, G, eng, ENG ] };
- key <AC06> { [ h, H, hstroke, Hstroke ] };
- key <AC07> { [ j, J, j, J ] };
- key <AC08> { [ k, K, kra, ampersand ] };
- key <AC09> { [ l, L, lstroke, Lstroke ] };
- key <AC10> { [ semicolon, colon, dead_acute, dead_doubleacute ] };
- key <AC11> { [apostrophe, quotedbl, dead_circumflex, dead_caron ] };
- key <TLDE> { [ grave, asciitilde, notsign, notsign ] };
-
- key <BKSL> { [ backslash, bar, dead_grave, dead_breve ] };
- key <AB01> { [ z, Z, guillemotleft, less ] };
- key <AB02> { [ x, X, guillemotright, greater ] };
- key <AB03> { [ c, C, cent, copyright ] };
- key <AB04> { [ v, V, leftdoublequotemark, leftsinglequotemark ] };
- key <AB05> { [ b, B, rightdoublequotemark, rightsinglequotemark ] };
- key <AB06> { [ n, N, n, N ] };
- key <AB07> { [ m, M, mu, masculine ] };
- key <AB08> { [ comma, less, horizconnector, multiply ] };
- key <AB09> { [ period, greater, periodcentered, division ] };
- key <AB10> { [ slash, question, dead_belowdot, dead_abovedot ] };
-
-};
-
-// Northern Europe ( Danish, Finnish, Norwegian, Swedish) common layout
-
-partial
-xkb_symbols "type2" {
-
- include "latin"
-
- key <AE01> { [ 1, exclam, exclamdown, onesuperior ] };
- key <AE02> { [ 2, quotedbl, at, twosuperior ] };
- key <AE03> { [ 3, numbersign, sterling, threesuperior] };
- key <AE04> { [ 4, currency, dollar, onequarter ] };
- key <AE05> { [ 5, percent, onehalf, cent ] };
- key <AE06> { [ 6, ampersand, yen, fiveeighths ] };
- key <AE07> { [ 7, slash, braceleft, division ] };
- key <AE08> { [ 8, parenleft, bracketleft, guillemotleft] };
- key <AE09> { [ 9, parenright, bracketright, guillemotright] };
- key <AE10> { [ 0, equal, braceright, degree ] };
-
- key <AD03> { [ e, E, EuroSign, cent ] };
- key <AD04> { [ r, R, registered, registered ] };
- key <AD05> { [ t, T, thorn, THORN ] };
- key <AD09> { [ o, O, oe, OE ] };
- key <AD11> { [ aring, Aring, dead_diaeresis, dead_abovering ] };
- key <AD12> { [dead_diaeresis, dead_circumflex, dead_tilde, dead_caron ] };
-
- key <AC01> { [ a, A, ordfeminine, masculine ] };
-
- key <AB03> { [ c, C, copyright, copyright ] };
- key <AB08> { [ comma, semicolon, dead_cedilla, dead_ogonek ] };
- key <AB09> { [ period, colon, periodcentered, dead_abovedot ] };
- key <AB10> { [ minus, underscore, dead_belowdot, dead_abovedot ] };
-};
-
-// Slavic Latin ( Albanian, Croatian, Polish, Slovene, Yugoslav)
-// common layout
-
-partial
-xkb_symbols "type3" {
-
- include "latin"
-
- key <AD01> { [ q, Q, backslash, Greek_OMEGA ] };
- key <AD02> { [ w, W, bar, Lstroke ] };
- key <AD06> { [ z, Z, leftarrow, yen ] };
-
- key <AC04> { [ f, F, bracketleft, ordfeminine ] };
- key <AC05> { [ g, G, bracketright, ENG ] };
- key <AC08> { [ k, K, lstroke, ampersand ] };
-
- key <AB01> { [ y, Y, guillemotleft, less ] };
- key <AB04> { [ v, V, at, grave ] };
- key <AB05> { [ b, B, braceleft, apostrophe ] };
- key <AB06> { [ n, N, braceright, braceright ] };
- key <AB07> { [ m, M, section, masculine ] };
- key <AB08> { [ comma, semicolon, less, multiply ] };
- key <AB09> { [ period, colon, greater, division ] };
-};
-
-// Another one Latin common layout
-// (German, Estonian, Spanish, Icelandic, Italian, Latin American, Portuguese)
-
-partial
-xkb_symbols "type4" {
-
- include "latin"
-
- key <AE02> { [ 2, quotedbl, at, oneeighth ] };
- key <AE06> { [ 6, ampersand, notsign, fiveeighths ] };
- key <AE07> { [ 7, slash, braceleft, seveneighths ] };
- key <AE08> { [ 8, parenleft, bracketleft, trademark ] };
- key <AE09> { [ 9, parenright, bracketright, plusminus ] };
- key <AE10> { [ 0, equal, braceright, degree ] };
-
- key <AD03> { [ e, E, EuroSign, cent ] };
-
- key <AB08> { [ comma, semicolon, horizconnector, multiply ] };
- key <AB09> { [ period, colon, periodcentered, division ] };
- key <AB10> { [ minus, underscore, dead_belowdot, dead_abovedot ] };
-};
-
-partial
-xkb_symbols "nodeadkeys" {
-
- key <AE12> { [ equal, plus, cedilla, ogonek ] };
- key <AD11> { [bracketleft, braceleft, diaeresis, degree ] };
- key <AD12> { [bracketright, braceright, asciitilde, macron ] };
- key <AC10> { [ semicolon, colon, acute, doubleacute ] };
- key <AC11> { [apostrophe, quotedbl, asciicircum, caron ] };
- key <BKSL> { [ backslash, bar, grave, breve ] };
- key <AB10> { [ slash, question, dead_belowdot, abovedot ] };
-};
-
-partial
-xkb_symbols "type2_nodeadkeys" {
-
- include "latin(nodeadkeys)"
-
- key <AD11> { [ aring, Aring, diaeresis, degree ] };
- key <AD12> { [ diaeresis, asciicircum, asciitilde, caron ] };
- key <AB08> { [ comma, semicolon, cedilla, ogonek ] };
- key <AB09> { [ period, colon, periodcentered, abovedot ] };
- key <AB10> { [ minus, underscore, dead_belowdot, abovedot ] };
-};
-
-partial
-xkb_symbols "type3_nodeadkeys" {
-
- include "latin(nodeadkeys)"
-};
-
-partial
-xkb_symbols "type4_nodeadkeys" {
-
- include "latin(nodeadkeys)"
-
- key <AB10> { [ minus, underscore, dead_belowdot, abovedot ] };
-};
+// Common Latin alphabet layout
+
+default partial
+xkb_symbols "basic" {
+
+ key <AE01> { [ 1, exclam, onesuperior, exclamdown ] };
+ key <AE02> { [ 2, at, twosuperior, oneeighth ] };
+ key <AE03> { [ 3, numbersign, threesuperior, sterling ] };
+ key <AE04> { [ 4, dollar, onequarter, dollar ] };
+ key <AE05> { [ 5, percent, onehalf, threeeighths ] };
+ key <AE06> { [ 6, asciicircum, threequarters, fiveeighths ] };
+ key <AE07> { [ 7, ampersand, braceleft, seveneighths ] };
+ key <AE08> { [ 8, asterisk, bracketleft, trademark ] };
+ key <AE09> { [ 9, parenleft, bracketright, plusminus ] };
+ key <AE10> { [ 0, parenright, braceright, degree ] };
+ key <AE11> { [ minus, underscore, backslash, questiondown ] };
+ key <AE12> { [ equal, plus, dead_cedilla, dead_ogonek ] };
+
+ key <AD01> { [ q, Q, at, Greek_OMEGA ] };
+ key <AD02> { [ w, W, lstroke, Lstroke ] };
+ key <AD03> { [ e, E, e, E ] };
+ key <AD04> { [ r, R, paragraph, registered ] };
+ key <AD05> { [ t, T, tslash, Tslash ] };
+ key <AD06> { [ y, Y, leftarrow, yen ] };
+ key <AD07> { [ u, U, downarrow, uparrow ] };
+ key <AD08> { [ i, I, rightarrow, idotless ] };
+ key <AD09> { [ o, O, oslash, Ooblique ] };
+ key <AD10> { [ p, P, thorn, THORN ] };
+ key <AD11> { [bracketleft, braceleft, dead_diaeresis, dead_abovering ] };
+ key <AD12> { [bracketright, braceright, dead_tilde, dead_macron ] };
+
+ key <AC01> { [ a, A, ae, AE ] };
+ key <AC02> { [ s, S, ssharp, section ] };
+ key <AC03> { [ d, D, eth, ETH ] };
+ key <AC04> { [ f, F, dstroke, ordfeminine ] };
+ key <AC05> { [ g, G, eng, ENG ] };
+ key <AC06> { [ h, H, hstroke, Hstroke ] };
+ key <AC07> { [ j, J, j, J ] };
+ key <AC08> { [ k, K, kra, ampersand ] };
+ key <AC09> { [ l, L, lstroke, Lstroke ] };
+ key <AC10> { [ semicolon, colon, dead_acute, dead_doubleacute ] };
+ key <AC11> { [apostrophe, quotedbl, dead_circumflex, dead_caron ] };
+ key <TLDE> { [ grave, asciitilde, notsign, notsign ] };
+
+ key <BKSL> { [ backslash, bar, dead_grave, dead_breve ] };
+ key <AB01> { [ z, Z, guillemotleft, less ] };
+ key <AB02> { [ x, X, guillemotright, greater ] };
+ key <AB03> { [ c, C, cent, copyright ] };
+ key <AB04> { [ v, V, leftdoublequotemark, leftsinglequotemark ] };
+ key <AB05> { [ b, B, rightdoublequotemark, rightsinglequotemark ] };
+ key <AB06> { [ n, N, n, N ] };
+ key <AB07> { [ m, M, mu, masculine ] };
+ key <AB08> { [ comma, less, horizconnector, multiply ] };
+ key <AB09> { [ period, greater, periodcentered, division ] };
+ key <AB10> { [ slash, question, dead_belowdot, dead_abovedot ] };
+
+};
+
+// Northern Europe ( Danish, Finnish, Norwegian, Swedish) common layout
+
+partial
+xkb_symbols "type2" {
+
+ include "latin"
+
+ key <AE01> { [ 1, exclam, exclamdown, onesuperior ] };
+ key <AE02> { [ 2, quotedbl, at, twosuperior ] };
+ key <AE03> { [ 3, numbersign, sterling, threesuperior] };
+ key <AE04> { [ 4, currency, dollar, onequarter ] };
+ key <AE05> { [ 5, percent, onehalf, cent ] };
+ key <AE06> { [ 6, ampersand, yen, fiveeighths ] };
+ key <AE07> { [ 7, slash, braceleft, division ] };
+ key <AE08> { [ 8, parenleft, bracketleft, guillemotleft] };
+ key <AE09> { [ 9, parenright, bracketright, guillemotright] };
+ key <AE10> { [ 0, equal, braceright, degree ] };
+
+ key <AD03> { [ e, E, EuroSign, cent ] };
+ key <AD04> { [ r, R, registered, registered ] };
+ key <AD05> { [ t, T, thorn, THORN ] };
+ key <AD09> { [ o, O, oe, OE ] };
+ key <AD11> { [ aring, Aring, dead_diaeresis, dead_abovering ] };
+ key <AD12> { [dead_diaeresis, dead_circumflex, dead_tilde, dead_caron ] };
+
+ key <AC01> { [ a, A, ordfeminine, masculine ] };
+
+ key <AB03> { [ c, C, copyright, copyright ] };
+ key <AB08> { [ comma, semicolon, dead_cedilla, dead_ogonek ] };
+ key <AB09> { [ period, colon, periodcentered, dead_abovedot ] };
+ key <AB10> { [ minus, underscore, dead_belowdot, dead_abovedot ] };
+};
+
+// Slavic Latin ( Albanian, Croatian, Polish, Slovene, Yugoslav)
+// common layout
+
+partial
+xkb_symbols "type3" {
+
+ include "latin"
+
+ key <AD01> { [ q, Q, backslash, Greek_OMEGA ] };
+ key <AD02> { [ w, W, bar, Lstroke ] };
+ key <AD06> { [ z, Z, leftarrow, yen ] };
+
+ key <AC04> { [ f, F, bracketleft, ordfeminine ] };
+ key <AC05> { [ g, G, bracketright, ENG ] };
+ key <AC08> { [ k, K, lstroke, ampersand ] };
+
+ key <AB01> { [ y, Y, guillemotleft, less ] };
+ key <AB04> { [ v, V, at, grave ] };
+ key <AB05> { [ b, B, braceleft, apostrophe ] };
+ key <AB06> { [ n, N, braceright, braceright ] };
+ key <AB07> { [ m, M, section, masculine ] };
+ key <AB08> { [ comma, semicolon, less, multiply ] };
+ key <AB09> { [ period, colon, greater, division ] };
+};
+
+// Another one Latin common layout
+// (German, Estonian, Spanish, Icelandic, Italian, Latin American, Portuguese)
+
+partial
+xkb_symbols "type4" {
+
+ include "latin"
+
+ key <AE02> { [ 2, quotedbl, at, oneeighth ] };
+ key <AE06> { [ 6, ampersand, notsign, fiveeighths ] };
+ key <AE07> { [ 7, slash, braceleft, seveneighths ] };
+ key <AE08> { [ 8, parenleft, bracketleft, trademark ] };
+ key <AE09> { [ 9, parenright, bracketright, plusminus ] };
+ key <AE10> { [ 0, equal, braceright, degree ] };
+
+ key <AD03> { [ e, E, EuroSign, cent ] };
+
+ key <AB08> { [ comma, semicolon, horizconnector, multiply ] };
+ key <AB09> { [ period, colon, periodcentered, division ] };
+ key <AB10> { [ minus, underscore, dead_belowdot, dead_abovedot ] };
+};
+
+partial
+xkb_symbols "nodeadkeys" {
+
+ key <AE12> { [ equal, plus, cedilla, ogonek ] };
+ key <AD11> { [bracketleft, braceleft, diaeresis, degree ] };
+ key <AD12> { [bracketright, braceright, asciitilde, macron ] };
+ key <AC10> { [ semicolon, colon, acute, doubleacute ] };
+ key <AC11> { [apostrophe, quotedbl, asciicircum, caron ] };
+ key <BKSL> { [ backslash, bar, grave, breve ] };
+ key <AB10> { [ slash, question, dead_belowdot, abovedot ] };
+};
+
+partial
+xkb_symbols "type2_nodeadkeys" {
+
+ include "latin(nodeadkeys)"
+
+ key <AD11> { [ aring, Aring, diaeresis, degree ] };
+ key <AD12> { [ diaeresis, asciicircum, asciitilde, caron ] };
+ key <AB08> { [ comma, semicolon, cedilla, ogonek ] };
+ key <AB09> { [ period, colon, periodcentered, abovedot ] };
+ key <AB10> { [ minus, underscore, dead_belowdot, abovedot ] };
+};
+
+partial
+xkb_symbols "type3_nodeadkeys" {
+
+ include "latin(nodeadkeys)"
+};
+
+partial
+xkb_symbols "type4_nodeadkeys" {
+
+ include "latin(nodeadkeys)"
+
+ key <AB10> { [ minus, underscore, dead_belowdot, abovedot ] };
+};
+
+// Added 2008.03.05 by Marcin Woliński
+// See http://marcinwolinski.pl/keyboard/ for a description.
+// Used by pl(intl)
+//
+// ┌────┐
+// │ 2 4│ 2 = Shift, 4 = Level3 + Shift
+// │ 1 3│ 1 = Normal, 3 = Level3
+// └────┘
+// ┌─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┲━━━━━━━━━┓
+// │ ~ ~ │ ! ' │ @ " │ # ˝ │ $ ¸ │ % ˇ │ ^ ^ │ & ˘ │ * ˙ │ ( ̣ │ ) ° │ _ ¯ │ + ˛ ┃ ⌫ Back ┃
+// │ ` ` │ 1 ¡ │ 2 © │ 3 • │ 4 § │ 5 € │ 6 ¢ │ 7 − │ 8 × │ 9 ÷ │ 0 ° │ - – │ = — ┃ space ┃
+// ┢━━━━━┷━┱───┴─┬───┴─┬───┴─┬───┴─┬───┴─┬───┴─┬───┴─┬───┴─┬───┴─┬───┴─┬───┴─┬───┺━┳━━━━━━━┫
+// ┃ ┃ Q │ W │ E │ R │ T │ Y │ U │ I │ O │ P │ { « │ } » ┃ Enter ┃
+// ┃Tab ↹ ┃ q │ w │ e │ r │ t │ y │ u │ i │ o │ p │ [ ‹ │ ] › ┃ ⏎ ┃
+// ┣━━━━━━━┻┱────┴┬────┴┬────┴┬────┴┬────┴┬────┴┬────┴┬────┴┬────┴┬────┴┬────┴┬────┺┓ ┃
+// ┃ ┃ A │ S │ D │ F │ G │ H │ J │ K │ L │ : “ │ " ” │ | ¶ ┃ ┃
+// ┃Caps ⇬ ┃ a │ s │ d │ f │ g │ h │ j │ k │ l │ ; ‘ │ ' ’ │ \ ┃ ┃
+// ┣━━━━━━━━┹────┬┴────┬┴────┬┴────┬┴────┬┴────┬┴────┬┴────┬┴────┬┴────┬┴────┲┷━━━━━┻━━━━━━┫
+// ┃ │ Z │ X │ C │ V │ B │ N │ M │ < „ │ > · │ ? ¿ ┃ ┃
+// ┃Shift ⇧ │ z │ x │ c │ v │ b │ n │ m │ , ‚ │ . … │ / ⁄ ┃Shift ⇧ ┃
+// ┣━━━━━━━┳━━━━━┷━┳━━━┷━━━┱─┴─────┴─────┴─────┴─────┴─────┴───┲━┷━━━━━╈━━━━━┻━┳━━━━━━━┳━━━┛
+// ┃ ┃ ┃ ┃ ␣ ⍽ ┃ ┃ ┃ ┃
+// ┃Ctrl ┃Meta ┃Alt ┃ ␣ Space ⍽ ┃AltGr ⇮┃Menu ┃Ctrl ┃
+// ┗━━━━━━━┻━━━━━━━┻━━━━━━━┹───────────────────────────────────┺━━━━━━━┻━━━━━━━┻━━━━━━━┛
+
+partial
+xkb_symbols "intl" {
+
+ key <TLDE> { [ grave, asciitilde, dead_grave, dead_tilde ] };
+ key <AE01> { [ 1, exclam, exclamdown, dead_acute ] };
+ key <AE02> { [ 2, at, copyright, dead_diaeresis ] };
+ key <AE03> { [ 3, numbersign, U2022, dead_doubleacute ] }; // U+2022 is bullet (the name bullet doesn't work)
+ key <AE04> { [ 4, dollar, section, dead_cedilla ] };
+ key <AE05> { [ 5, percent, EuroSign, dead_caron ] };
+ key <AE06> { [ 6, asciicircum, cent, dead_circumflex ] };
+ key <AE07> { [ 7, ampersand, U2212, dead_breve ] }; // U+2212 is MINUS SIGN
+ key <AE08> { [ 8, asterisk, multiply, dead_abovedot ] };
+ key <AE09> { [ 9, parenleft, division, dead_belowdot ] };
+ key <AE10> { [ 0, parenright, degree, dead_abovering ] };
+ key <AE11> { [ minus, underscore, endash, dead_macron ] };
+ key <AE12> { [ equal, plus, emdash, dead_ogonek ] };
+
+ key <AD01> { [ q, Q ] };
+ key <AD02> { [ w, W ] };
+ key <AD03> { [ e, E ] };
+ key <AD04> { [ r, R ] };
+ key <AD05> { [ t, T ] };
+ key <AD06> { [ y, Y ] };
+ key <AD07> { [ u, U ] };
+ key <AD08> { [ i, I ] };
+ key <AD09> { [ o, O ] };
+ key <AD10> { [ p, P ] };
+ key <AD11> { [bracketleft, braceleft, U2039, guillemotleft ] };
+ key <AD12> { [bracketright, braceright, U203A, guillemotright ] };
+
+ key <AC01> { [ a, A ] };
+ key <AC02> { [ s, S ] };
+ key <AC03> { [ d, D ] };
+ key <AC04> { [ f, F ] };
+ key <AC05> { [ g, G ] };
+ key <AC06> { [ h, H ] };
+ key <AC07> { [ j, J ] };
+ key <AC08> { [ k, K ] };
+ key <AC09> { [ l, L ] };
+ key <AC10> { [ semicolon, colon, leftsinglequotemark, leftdoublequotemark ] };
+ key <AC11> { [apostrophe, quotedbl, rightsinglequotemark, rightdoublequotemark ] };
+
+ key <BKSL> { [ backslash, bar, NoSymbol, paragraph ] };
+ key <AB01> { [ z, Z ] };
+ key <AB02> { [ x, X ] };
+ key <AB03> { [ c, C ] };
+ key <AB04> { [ v, V ] };
+ key <AB05> { [ b, B ] };
+ key <AB06> { [ n, N ] };
+ key <AB07> { [ m, M ] };
+ key <AB08> { [ comma, less, singlelowquotemark, doublelowquotemark ] };
+ key <AB09> { [ period, greater, ellipsis, periodcentered ] };
+ key <AB10> { [ slash, question, U2044, questiondown ] }; // U+2044 is FRACTION SLASH
+
+};
diff --git a/xorg-server/xkeyboard-config/symbols/pl b/xorg-server/xkeyboard-config/symbols/pl
index 12f3e012d..6d227237f 100644
--- a/xorg-server/xkeyboard-config/symbols/pl
+++ b/xorg-server/xkeyboard-config/symbols/pl
@@ -73,6 +73,55 @@ xkb_symbols "qwertz" {
include "level3(ralt_switch)"
};
+// A Polish keymap with a comprehensive set of quotes, dashes, and dead accents
+//
+// See http://marcinwolinski.pl/keyboard/ for a description.
+//
+// ┌────┐
+// │ 2 4│ 2 = Shift, 4 = Level3 + Shift
+// │ 1 3│ 1 = Normal, 3 = Level3
+// └────┘
+// ┌─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┲━━━━━━━━━┓
+// │ ~ ~ │ ! ' │ @ " │ # ˝ │ $ ¸ │ % ˇ │ ^ ^ │ & ˘ │ * ˙ │ ( ̣ │ ) ° │ _ ¯ │ + ˛ ┃ ⌫ Back ┃
+// │ ` ` │ 1 ¡ │ 2 © │ 3 • │ 4 § │ 5 € │ 6 ¢ │ 7 − │ 8 × │ 9 ÷ │ 0 ° │ - – │ = — ┃ space ┃
+// ┢━━━━━┷━┱───┴─┬───┴─┬───┴─┬───┴─┬───┴─┬───┴─┬───┴─┬───┴─┬───┴─┬───┴─┬───┴─┬───┺━┳━━━━━━━┫
+// ┃ ┃ Q │ W │ E Ę │ R │ T │ Y │ U │ I │ O Ó │ P │ { « │ } » ┃ Enter ┃
+// ┃Tab ↹ ┃ q │ w │ e ę │ r │ t │ y │ u │ i │ o ó │ p │ [ ‹ │ ] › ┃ ⏎ ┃
+// ┣━━━━━━━┻┱────┴┬────┴┬────┴┬────┴┬────┴┬────┴┬────┴┬────┴┬────┴┬────┴┬────┴┬────┺┓ ┃
+// ┃ ┃ A Ą │ S Ś │ D │ F │ G │ H │ J │ K │ L Ł │ : “ │ " ” │ | ¶ ┃ ┃
+// ┃Caps ⇬ ┃ a ą │ s ś │ d │ f │ g │ h │ j │ k │ l ł │ ; ‘ │ ' ’ │ \ ┃ ┃
+// ┣━━━━━━━━┹────┬┴────┬┴────┬┴────┬┴────┬┴────┬┴────┬┴────┬┴────┬┴────┬┴────┲┷━━━━━┻━━━━━━┫
+// ┃ │ Z Ż │ X Ź │ C Ć │ V │ B │ N Ń │ M │ < „ │ > · │ ? ¿ ┃ ┃
+// ┃Shift ⇧ │ z ż │ x ź │ c ć │ v │ b │ n ń │ m │ , ‚ │ . … │ / ⁄ ┃Shift ⇧ ┃
+// ┣━━━━━━━┳━━━━━┷━┳━━━┷━━━┱─┴─────┴─────┴─────┴─────┴─────┴───┲━┷━━━━━╈━━━━━┻━┳━━━━━━━┳━━━┛
+// ┃ ┃ ┃ ┃ ␣ ⍽ ┃ ┃ ┃ ┃
+// ┃Ctrl ┃Meta ┃Alt ┃ ␣ Space ⍽ ┃AltGr ⇮┃Menu ┃Ctrl ┃
+// ┗━━━━━━━┻━━━━━━━┻━━━━━━━┹───────────────────────────────────┺━━━━━━━┻━━━━━━━┻━━━━━━━┛
+
+partial alphanumeric_keys
+xkb_symbols "intl" {
+
+ include "latin(intl)"
+
+ name[Group1]="Polish (international with dead keys)";
+
+ key <AD03> { [ e, E, eogonek, Eogonek ] };
+ key <AD09> { [ o, O, oacute, Oacute ] };
+
+ key <AC01> { [ a, A, aogonek, Aogonek ] };
+ key <AC02> { [ s, S, sacute, Sacute ] };
+ key <AC09> { [ l, L, lstroke, Lstroke ] };
+
+ key <AB01> { [ z, Z, zabovedot, Zabovedot ] };
+ key <AB02> { [ x, X, zacute, Zacute ] };
+ key <AB03> { [ c, C, cacute, Cacute ] };
+ key <AB06> { [ n, N, nacute, Nacute ] };
+
+ include "kpdl(comma)"
+
+ include "level3(ralt_switch)"
+};
+
// Polish Dvorak keymaps
// by Rafal Rzepecki <divide@users.sf.net>
@@ -348,3 +397,4 @@ xkb_symbols "ru_phonetic_dvorak" {
include "level3(ralt_switch)"
};
+
diff --git a/xorg-server/doc/xml/xserver.ent.in b/xorg-server/xserver.ent.in
index aa02d7b93..aa02d7b93 100644
--- a/xorg-server/doc/xml/xserver.ent.in
+++ b/xorg-server/xserver.ent.in